// NetworkInterfaces is part of the Networking interface
334965
func (n *switchingNetworking) NetworkInterfaces(instId instance.Id) ([]network.InterfaceInfo, error) {
	if err := n.initNetworking(); err != nil {
		return nil, errors.Trace(err)
	}
	return n.networking.NetworkInterfaces(instId)
}
25513
func (e *Environ) NetworkInterfaces(ctx context.ProviderCallContext, instId instance.Id) ([]network.InterfaceInfo, error) {
	infos, err := e.networking.NetworkInterfaces(instId)
	if err != nil {
		common.HandleCredentialError(IsAuthorisationFailure, err, ctx)
		return infos, errors.Trace(err)
	}
	return infos, nil
}
450836
func (client *Client) CreateRouterInterface(args *CreateRouterInterfaceArgs) (response *CreateRouterInterfaceResponse, err error) {
	response = &CreateRouterInterfaceResponse{}
	err = client.Invoke("CreateRouterInterface", args, &response)
	if err != nil {
		return response, err
	}
	return response, nil
}
114389
func (vm *VM) GetInterfaces() ([]NIC, error) {
	nics := []NIC{}
	stdout, err := runner.RunCombinedError("showvminfo", vm.Name)
	if err != nil {
		return nil, err
	}

	for _, line := range strings.Split(stdout, "\n") {
		// See if this is a NIC
		if match := nicRegexp.FindStringSubmatch(line); match != nil {
			var nic NIC
			// Get the nic index and the backing
			// substr is the nic index with a trailing `:`
			substr := strings.Split(match[0], " ")[1]
			//Remove the trailing `:` and convert to an integer
			idx, err := strconv.Atoi(strings.TrimSuffix(substr, ":"))
			if err != nil {
				return nil, err
			}
			nic.Idx = idx
			if match := backingRegexp.FindStringSubmatch(line); match != nil {
				nic.Backing = Nat
			} else if match := disabledRegexp.FindStringSubmatch(line); match != nil {
				nic.Backing = Disabled
			} else {
				nic.Backing = Unsupported
			}
			nics = append(nics, nic)
		}
	}
	return nics, nil
}
331649
func getInterface(c context.Context) config.Interface {
	return c.Value(&cfgKey).(config.Interface)
}
156008
func (s *ContainerDetail) SetNetworkInterfaces(v []*NetworkInterface) *ContainerDetail {
	s.NetworkInterfaces = v
	return s
}
993990
func newInterface(nlh *netlink.Handle, config *networkConfiguration) (*bridgeInterface, error) {
	var err error
	i := &bridgeInterface{nlh: nlh}

	// Initialize the bridge name to the default if unspecified.
	if config.BridgeName == "" {
		config.BridgeName = DefaultBridgeName
	}

	// Attempt to find an existing bridge named with the specified name.
	i.Link, err = nlh.LinkByName(config.BridgeName)
	if err != nil {
		logrus.Debugf("Did not find any interface with name %s: %v", config.BridgeName, err)
	} else if _, ok := i.Link.(*netlink.Bridge); !ok {
		return nil, fmt.Errorf("existing interface %s is not a bridge", i.Link.Attrs().Name)
	}
	return i, nil
}
399490
func (r *Router) useInterface(mw middleware) {
	r.middlewares = append(r.middlewares, mw)
}
865355
func (s *VolumeiSCSIAttributes) SetNetworkInterfacePort(v int64) *VolumeiSCSIAttributes {
	s.NetworkInterfacePort = &v
	return s
}
310942
func resolveInterface(uses map[*ast.Ident]types.Object, iface *ast.InterfaceType) error {
	var rmi []int
	for i, m := range iface.Methods.List {
		if len(m.Names) > 0 {
			continue
		}
		newIface, err := exprInterfaceType(uses, m.Type)
		if err != nil {
			return err
		}
		iface.Methods.List = append(iface.Methods.List, newIface.Methods.List...)
		rmi = append(rmi, i)
	}

	// After adding the signatures, remove the embedded interface
	for i := len(rmi) - 1; i >= 0; i-- {
		iface.Methods.List = append(iface.Methods.List[:i], iface.Methods.List[i+1:]...)
	}

	return nil
}
1054778
func (o *Disk) SetInterface(v *string) *Disk {
	if o.Interface = v; o.Interface == nil {
		o.nullFields = append(o.nullFields, "Interface")
	}
	return o
}
559236
func addrsForInterface(iface *net.Interface) ([]net.IP, []net.IP) {
	var v4, v6, v6local []net.IP

	addrs, _ := iface.Addrs()
	for _, address := range addrs {
		if ipnet, ok := address.(*net.IPNet); ok && !ipnet.IP.IsLoopback() {
			if ipnet.IP.To4() != nil {
				v4 = append(v4, ipnet.IP)
			} else {
				switch ip := ipnet.IP.To16(); ip != nil {
				case ip.IsGlobalUnicast():
					v6 = append(v6, ipnet.IP)
				case ip.IsLinkLocalUnicast():
					v6local = append(v6local, ipnet.IP)
				}
			}
		}
	}
	if len(v6) == 0 {
		v6 = v6local
	}
	return v4, v6
}
1150777
func (v *VPCRouter) HasInterfaces() bool {
	return v.HasSetting() && v.Settings.Router.HasInterfaces()
}
217977
func NewInterfaces(less func(x, y interface{}) bool, cap int) Interfaces {
	h := &interfaces{}

	h.less = func(i, j int) bool {
		return less(h.list[i], h.list[j])
	}
	if cap > 0 {
		h.list = make([]interface{}, 0, cap+1)
	}

	return h
}
901438
func GetInterfaces() map[string]struct{} {
	ipmap := map[string]struct{}{}

	ifaces, _ := net.Interfaces()
	for _, intf := range ifaces {
		addrs, _ := intf.Addrs()
		for _, addr := range addrs {
			ip, _, _ := net.ParseCIDR(addr.String())
			if ip.To4() != nil {
				ipmap[ip.String()] = struct{}{}
			}
		}
	}
	return ipmap
}
335776
func (c *StatsConnection) GetInterfaceStats() (*api.InterfaceStats, error) {
	stats, err := c.statsClient.DumpStats(InterfaceStatsPrefix)
	if err != nil {
		return nil, err
	}

	ifStats := &api.InterfaceStats{}

	var setPerIf = func(perIf []uint64, fn func(c *api.InterfaceCounters, v uint64)) {
		if ifStats.Interfaces == nil {
			ifStats.Interfaces = make([]api.InterfaceCounters, len(perIf))
			for i := range perIf {
				ifStats.Interfaces[i].InterfaceIndex = uint32(i)
			}
		}
		for i, v := range perIf {
			if len(ifStats.Interfaces) <= i {
				break
			}
			ifCounters := ifStats.Interfaces[i]
			fn(&ifCounters, v)
			ifStats.Interfaces[i] = ifCounters
		}
	}

	for _, stat := range stats {
		switch stat.Name {
		case InterfaceStats_Names:
			if names, ok := stat.Data.(adapter.NameStat); !ok {
				return nil, fmt.Errorf("invalid stat type for %s", stat.Name)
			} else {
				if ifStats.Interfaces == nil {
					ifStats.Interfaces = make([]api.InterfaceCounters, len(names))
					for i := range names {
						ifStats.Interfaces[i].InterfaceIndex = uint32(i)
					}
				}
				for i, name := range names {
					ifStats.Interfaces[i].InterfaceName = string(name)
				}
			}
		case InterfaceStats_Drops:
			setPerIf(reduceSimpleCounterStat(stat.Data), func(c *api.InterfaceCounters, v uint64) {
				c.Drops = v
			})
		case InterfaceStats_Punt:
			setPerIf(reduceSimpleCounterStat(stat.Data), func(c *api.InterfaceCounters, v uint64) {
				c.Punts = v
			})
		case InterfaceStats_IP4:
			setPerIf(reduceSimpleCounterStat(stat.Data), func(c *api.InterfaceCounters, v uint64) {
				c.IP4 = v
			})
		case InterfaceStats_IP6:
			setPerIf(reduceSimpleCounterStat(stat.Data), func(c *api.InterfaceCounters, v uint64) {
				c.IP6 = v
			})
		case InterfaceStats_RxNoBuf:
			setPerIf(reduceSimpleCounterStat(stat.Data), func(c *api.InterfaceCounters, v uint64) {
				c.RxNoBuf = v
			})
		case InterfaceStats_RxMiss:
			setPerIf(reduceSimpleCounterStat(stat.Data), func(c *api.InterfaceCounters, v uint64) {
				c.RxMiss = v
			})
		case InterfaceStats_RxError:
			setPerIf(reduceSimpleCounterStat(stat.Data), func(c *api.InterfaceCounters, v uint64) {
				c.RxErrors = v
			})
		case InterfaceStats_TxError:
			setPerIf(reduceSimpleCounterStat(stat.Data), func(c *api.InterfaceCounters, v uint64) {
				c.TxErrors = v
			})
		case InterfaceStats_Rx:
			per := reduceCombinedCounterStat(stat.Data)
			setPerIf(per[0], func(c *api.InterfaceCounters, v uint64) {
				c.RxPackets = v
			})
			setPerIf(per[1], func(c *api.InterfaceCounters, v uint64) {
				c.RxBytes = v
			})
		case InterfaceStats_RxUnicast:
			per := reduceCombinedCounterStat(stat.Data)
			setPerIf(per[0], func(c *api.InterfaceCounters, v uint64) {
				c.RxUnicast[0] = v
			})
			setPerIf(per[1], func(c *api.InterfaceCounters, v uint64) {
				c.RxUnicast[1] = v
			})
		case InterfaceStats_RxMulticast:
			per := reduceCombinedCounterStat(stat.Data)
			setPerIf(per[0], func(c *api.InterfaceCounters, v uint64) {
				c.RxMulticast[0] = v
			})
			setPerIf(per[1], func(c *api.InterfaceCounters, v uint64) {
				c.RxMulticast[1] = v
			})
		case InterfaceStats_RxBroadcast:
			per := reduceCombinedCounterStat(stat.Data)
			setPerIf(per[0], func(c *api.InterfaceCounters, v uint64) {
				c.RxBroadcast[0] = v
			})
			setPerIf(per[1], func(c *api.InterfaceCounters, v uint64) {
				c.RxBroadcast[1] = v
			})
		case InterfaceStats_Tx:
			per := reduceCombinedCounterStat(stat.Data)
			setPerIf(per[0], func(c *api.InterfaceCounters, v uint64) {
				c.TxPackets = v
			})
			setPerIf(per[1], func(c *api.InterfaceCounters, v uint64) {
				c.TxBytes = v
			})
		case InterfaceStats_TxUnicastMiss:
			per := reduceCombinedCounterStat(stat.Data)
			setPerIf(per[0], func(c *api.InterfaceCounters, v uint64) {
				c.TxUnicastMiss[0] = v
			})
			setPerIf(per[1], func(c *api.InterfaceCounters, v uint64) {
				c.TxUnicastMiss[1] = v
			})
		case InterfaceStats_TxMulticast:
			per := reduceCombinedCounterStat(stat.Data)
			setPerIf(per[0], func(c *api.InterfaceCounters, v uint64) {
				c.TxMulticast[0] = v
			})
			setPerIf(per[1], func(c *api.InterfaceCounters, v uint64) {
				c.TxMulticast[1] = v
			})
		case InterfaceStats_TxBroadcast:
			per := reduceCombinedCounterStat(stat.Data)
			setPerIf(per[0], func(c *api.InterfaceCounters, v uint64) {
				c.TxBroadcast[0] = v
			})
			setPerIf(per[1], func(c *api.InterfaceCounters, v uint64) {
				c.TxBroadcast[1] = v
			})
		}
	}

	return ifStats, nil
}
1220786
func (s *DeviceiSCSIAttributes) SetNetworkInterfacePort(v int64) *DeviceiSCSIAttributes {
	s.NetworkInterfacePort = &v
	return s
}