// NewBridge returns a bridge which implements model.Bridge.
433156
func NewBridge(info Info) *Bridge {
	acc := Bridge{}
	acc.Accessory = New(info, TypeBridge)

	return &acc
}
1230285
func addToBridge(iface, master netlink.Link, options string) error {
	switch master.Type() {
	case "openvswitch":
		return addToOpenvswitchBridge(iface, master, options)
	case "bridge":
		return netlink.LinkSetMaster(iface, master.(*netlink.Bridge))
	default:
		return fmt.Errorf("unknown link type:%+v", master.Type())
	}
}
1228758
func NewDrop(ctx *Context, stmt *rel.SqlDrop) *Drop {
	return &Drop{Stmt: stmt, PlanBase: NewPlanBase(false), Ctx: ctx}
}
121642
func NewConnection(connection net.Conn, context Context) *Connection {
	conn := &Connection{
		connection: connection,
		context:    context,
	}

	// Setup new session for the connection
	session := NewSession(conn)
	context.SetSessionForConnection(session, conn)

	return conn
}
929353
func newX(ch0 interface{}) *x {
	r := &x{}
	r.x[0].ch = ch0
	return r
}
1107740
func (bridge *Bridge) Put(path string, params interface{}) ([]byte, io.Reader, error) {
	uri := fmt.Sprintf("http://" + bridge.IPAddress + path)
	client := &http.Client{Timeout: time.Second * 5}

	data, err := json.Marshal(params)
	if err != nil {
		err = errors.New("unable to marshal PUT request interface")
		return []byte{}, nil, err
	}
	//fmt.Println("\n\nPARAMS: ", params)

	request, _ := http.NewRequest("PUT", uri, bytes.NewReader(data))
	resp, err := client.Do(request)
	if err != nil {
		err = errors.New("unable to access bridge")
		return []byte{}, nil, err
	}
	return HandleResponse(resp)
}
849253
func NewConn(conn net.Conn, isTLS bool) *Conn {
	return &Conn{
		conn:            conn,
		chanConfirm:     make(chan bool),
		chanMessageID:   make(chan int64),
		chanMessage:     make(chan *messagePacket, 10),
		messageContexts: map[int64]*messageContext{},
		requestTimeout:  0,
		isTLS:           isTLS,
	}
}
1137902
func (p *Plugin) NewProtoConnection(name string) mux.Connection {
	return p.mux.NewProtoConnection(name, &keyval.SerializerJSON{})
}
1357973
func NewRouter(rootLogger *logrus.Logger, cfg config.Config, bridgeMap map[string]bridge.Factory) (*Router, error) {
	logger := rootLogger.WithFields(logrus.Fields{"prefix": "router"})

	r := &Router{
		Config:           cfg,
		BridgeMap:        bridgeMap,
		Message:          make(chan config.Message),
		MattermostPlugin: make(chan config.Message),
		Gateways:         make(map[string]*Gateway),
		logger:           logger,
	}
	sgw := samechannel.New(cfg)
	gwconfigs := append(sgw.GetConfig(), cfg.BridgeValues().Gateway...)

	for idx := range gwconfigs {
		entry := &gwconfigs[idx]
		if !entry.Enable {
			continue
		}
		if entry.Name == "" {
			return nil, fmt.Errorf("%s", "Gateway without name found")
		}
		if _, ok := r.Gateways[entry.Name]; ok {
			return nil, fmt.Errorf("Gateway with name %s already exists", entry.Name)
		}
		r.Gateways[entry.Name] = New(rootLogger, entry, r)
	}
	return r, nil
}
704846
func newConn(tr transport) (*Conn, error) {
	conn := new(Conn)
	conn.transport = tr
	conn.calls = make(map[uint32]*Call)
	conn.out = make(chan *Message, 10)
	conn.handlers = make(map[ObjectPath]map[string]interface{})
	conn.nextSerial = 1
	conn.serialUsed = map[uint32]bool{0: true}
	conn.busObj = conn.Object("org.freedesktop.DBus", "/org/freedesktop/DBus")
	return conn, nil
}
1267434
func NewValue(val interface{}, err error) Value {
	confVal := new(configValue)
	confVal.value = val
	confVal.err = err
	return confVal
}
576886
func NewFloat(name string) *Float {
	v := new(Float)
	Publish(name, v)
	return v
}
774850
func (Bridge) Create(name string, ip net.IP, subnet *net.IPNet) (intf *net.Interface, err error) {
	netlinkMu.Lock()
	defer netlinkMu.Unlock()

	if intf, err = idempotentlyCreateBridge(name); err != nil {
		return nil, err
	}

	if err = netlink.NetworkLinkAddIp(intf, ip, subnet); err != nil && err.Error() != "file exists" {
		return nil, fmt.Errorf("devices: add IP to bridge: %v", err)
	}

	return intf, nil
}
120650
func newNonce24() (*nonce24, error) {
	prefix, err := libkb.RandBytes(20)
	if err != nil {
		return nil, err
	}
	return &nonce24{prefix: prefix}, nil
}
222835
func newConn(c net.Conn) *conn {
	br := bufio.NewReader(c)
	bw := bufio.NewWriter(c)

	brw := bufio.NewReadWriter(br, bw)
	return &conn{rwc: c, buf: brw}
}
478211
func NewIndex(kind IndexKind, table string) Index {
	return &index{
		kind:  kind,
		table: table,
	}
}
450567
func NewList(operator ListOperator, filters ...Filter) *List {
	f := &List{
		Operator: operator.toPB(),
	}
	f.AddFilters(filters...)
	return f
}