// LinkSetAllmulticastOn enables the reception of all hardware multicast packets for the link device.
// Equivalent to: `ip link set $link allmulticast on`
185253
func (h *Handle) LinkSetAllmulticastOn(link Link) error {
	base := link.Attrs()
	h.ensureIndex(base)
	req := h.newNetlinkRequest(unix.RTM_NEWLINK, unix.NLM_F_ACK)

	msg := nl.NewIfInfomsg(unix.AF_UNSPEC)
	msg.Change = unix.IFF_ALLMULTI
	msg.Flags = unix.IFF_ALLMULTI

	msg.Index = int32(base.Index)
	req.AddData(msg)

	_, err := req.Execute(unix.NETLINK_ROUTE, 0)
	return err
}
1196681
func (c *Client) SubscribeMultiple(filters map[string]byte, callback MessageHandler) Token {
	var err error
	token := newToken(packets.Subscribe).(*SubscribeToken)
	DEBUG.Println(CLI, "enter SubscribeMultiple")
	if !c.IsConnected() {
		token.err = ErrNotConnected
		token.flowComplete()
		return token
	}
	sub := packets.NewControlPacket(packets.Subscribe).(*packets.SubscribePacket)
	if sub.Topics, sub.Qoss, err = validateSubscribeMap(filters); err != nil {
		token.err = err
		return token
	}

	if callback != nil {
		for topic := range filters {
			c.msgRouter.addRoute(topic, callback)
		}
	}
	token.subs = make([]string, len(sub.Topics))
	copy(token.subs, sub.Topics)
	c.oboundP <- &PacketAndToken{p: sub, t: token}
	DEBUG.Println(CLI, "exit SubscribeMultiple")
	return token
}
884392
func (api *IPv6NetAPI) FilterMultiBy(key string, value interface{}) *IPv6NetAPI {
	api.filterBy(key, value, true)
	return api
}
688280
func LinkSetHardwareAddr(link Link, hwaddr net.HardwareAddr) error {
	return pkgHandle.LinkSetHardwareAddr(link, hwaddr)
}
770003
func NewMultiStream(
	listen net.Listener,
	dial func(string, time.Duration) (net.Conn, error),
	advertise net.Addr,
	lg *log.Logger,
	serviceCodes ...byte,
) (map[byte]raft.StreamLayer, error) {
	// sanity checks for listener and advertised address
	if advertise == nil {
		advertise = listen.Addr()
	}
	tcpAdvertise, ok := advertise.(*net.TCPAddr)
	if !ok {
		lg.Printf("NewMultiStream Warning: advertising non TCP address %s", advertise)
	} else if tcpAdvertise.IP.IsUnspecified() {
		lg.Printf("NewMultiStream Warning: advertising unspecified IP: %s for address %s", tcpAdvertise.IP, tcpAdvertise.String())
	}
	// set up router
	r := &router{listen, make(chan net.Conn, 16), make(chan closeReq, 16), make(map[byte]*serviceStreams), lg}
	// set up a channel of conns for each unique serviceCode
	for _, b := range serviceCodes {
		_, exists := r.chans[b]
		if exists {
			lg.Printf("Warning, serviceCode %d was present more than once in NewMultiStream -- allocating a single service")
			continue
		}
		r.chans[b] = &serviceStreams{
			r:      r,
			addr:   advertise,
			conns:  make(chan net.Conn, 16),
			closed: false,
			myCode: b,
			dial:   dial,
		}
	}
	// type hack, force to map[byte]raft.StreamLayer for return type
	retMap := make(map[byte]raft.StreamLayer)
	for k, v := range r.chans {
		retMap[k] = v
	}
	go r.serve()
	return retMap, nil
}
445022
func (b *Bucket) InitMulti(key string, contType string, perm ACL, options Options) (*Multi, error) {
	headers := make(http.Header)
	headers.Set("Content-Length", "0")
	headers.Set("Content-Type", contType)
	headers.Set("x-oss-acl", string(perm))

	options.addHeaders(headers)
	params := make(url.Values)
	params.Set("uploads", "")
	req := &request{
		method:  "POST",
		bucket:  b.Name,
		path:    key,
		headers: headers,
		params:  params,
	}
	var err error
	var resp struct {
		UploadId string `xml:"UploadId"`
	}
	for attempt := attempts.Start(); attempt.Next(); {
		err = b.Client.query(req, &resp)
		if !shouldRetry(err) {
			break
		}
	}
	if err != nil {
		return nil, err
	}
	return &Multi{Bucket: b, Key: key, UploadId: resp.UploadId}, nil
}
647772
func ParseTeamChainLink(link string) (res SCChainLink, err error) {
	err = json.Unmarshal([]byte(link), &res)
	return res, err
}
594993
func (s *Service) SubscribeMultiple(subscriptions []packet.Subscription) SubscribeFuture {
	s.mutex.Lock()
	defer s.mutex.Unlock()

	// save subscription
	for _, v := range subscriptions {
		s.subscriptions.Set(v.Topic, v)
	}

	// allocate future
	f := future.New()

	// queue subscribe
	s.commandQueue <- &command{
		subscribe:     true,
		future:        f,
		subscriptions: subscriptions,
	}

	return &subscribeFuture{f}
}
73932
func (c *Client) YoAllLink(link string) error {
	data := url.Values{}
	data.Set("api_token", c.Token)
	data.Set("link", link)

	res, err := http.PostForm(YO_API+"/yoall/", data)
	if err != nil {
		return err
	}

	defer res.Body.Close()

	if res.StatusCode != http.StatusCreated {
		return errors.New("Received response with non 201 status code.")
	}

	return nil
}
955157
func UpdateMulticastGroup(db sqlx.Execer, mg *MulticastGroup) error {
	mg.UpdatedAt = time.Now()

	res, err := db.Exec(`
		update
			multicast_group
		set
			updated_at = $2,
			mc_addr = $3,
			mc_nwk_s_key = $4,
			f_cnt = $5,
			group_type = $6,
			dr = $7,
			frequency = $8,
			ping_slot_period = $9,
			service_profile_id = $10,
			routing_profile_id = $11
		where
			id = $1`,
		mg.ID,
		mg.UpdatedAt,
		mg.MCAddr[:],
		mg.MCNwkSKey[:],
		mg.FCnt,
		mg.GroupType,
		mg.DR,
		mg.Frequency,
		mg.PingSlotPeriod,
		mg.ServiceProfileID,
		mg.RoutingProfileID,
	)
	if err != nil {
		return handlePSQLError(err, "update error")
	}
	ra, err := res.RowsAffected()
	if err != nil {
		return handlePSQLError(err, "get rows affected error")
	}
	if ra == 0 {
		return ErrDoesNotExist
	}

	log.WithFields(log.Fields{
		"id": mg.ID,
	}).Info("multicast-group updated")

	return nil
}
606924
func (r *rpcHandler) handleMultiplex(ctx context.Context, conn net.Conn, rpcCtx *RPCContext) {
	defer func() {
		// Remove any potential mapping between a NodeID to this connection and
		// close the underlying connection.
		r.removeNodeConn(rpcCtx)
		conn.Close()
	}()

	conf := yamux.DefaultConfig()
	conf.LogOutput = nil
	conf.Logger = r.gologger
	server, err := yamux.Server(conn, conf)
	if err != nil {
		r.logger.Error("multiplex failed to create yamux server", "error", err)
		return
	}

	// Update the context to store the yamux session
	rpcCtx.Session = server

	// Create the RPC server for this connection
	rpcServer := rpc.NewServer()
	r.setupRpcServer(rpcServer, rpcCtx)

	for {
		// stop handling connections if context was cancelled
		if ctx.Err() != nil {
			return
		}

		sub, err := server.Accept()
		if err != nil {
			if err != io.EOF {
				r.logger.Error("multiplex conn accept failed", "error", err)
			}
			return
		}
		go r.handleNomadConn(ctx, sub, rpcServer)
	}
}
487771
func GetMulticastGroup(db sqlx.Queryer, id uuid.UUID, forUpdate bool) (MulticastGroup, error) {
	var mg MulticastGroup
	var fu string

	if forUpdate {
		fu = " for update"
	}

	err := sqlx.Get(db, &mg, `
		select
			*
		from
			multicast_group
		where
			id = $1`+fu,
		id,
	)
	if err != nil {
		return mg, handlePSQLError(err, "select error")
	}
	return mg, nil
}
954532
func (api *PrivateHostAPI) SetFilterMultiBy(key string, value interface{}) {
	api.filterBy(key, value, true)
}
807305
func (api *DNSAPI) SetFilterMultiBy(key string, value interface{}) {
	api.filterBy(key, value, true)
}
860079
func buildRespForMulticast(to []string, mrs multicastResultsState, mid int) *HttpResponse {
	resp := &HttpResponse{}
	resp.MulticastId = mid
	resp.Results = make([]Result, len(to))
	for i, regId := range to {
		result, ok := mrs[regId]
		if !ok {
			continue
		}
		resp.Results[i] = *result
		if result.MessageId != "" {
			resp.Success++
		} else if result.Error != "" {
			resp.Failure++
		}
		if result.RegistrationId != "" {
			resp.CanonicalIds++
		}
	}
	return resp
}
1086640
func IsV4MulticastAddress(addr net.IP) bool {
	if len(addr) != IPv4AddressSize {
		return false
	}
	return (addr[0] & 0xf0) == 0xe0
}
139029
func (db *DB) FetchAllLinkNodes() ([]*LinkNode, error) {
	var linkNodes []*LinkNode
	err := db.View(func(tx *bbolt.Tx) error {
		nodes, err := db.fetchAllLinkNodes(tx)
		if err != nil {
			return err
		}

		linkNodes = nodes
		return nil
	})
	if err != nil {
		return nil, err
	}

	return linkNodes, nil
}