// getInterfacePointer returns a pointer that points to the
// interface data of the interface pointed by p.
486295
func (p pointer) getInterfacePointer() pointer {
	if p.v.Elem().IsNil() {
		return pointer{v: p.v.Elem()}
	}
	return pointer{v: p.v.Elem().Elem().Elem().Field(0).Addr()} // *interface -> interface -> *struct -> struct
}
946109
func (c *Context) GetParameter(pname int) *js.Object {
	return c.Call("getParameter", pname)
}
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
}
1081045
func getListenInterface() (*net.Interface, error) {
	ifaces, err := net.Interfaces()
	if err == nil {
		for _, iface := range ifaces {
			addrs, err := iface.Addrs()
			if err != nil {
				logfWarn("Can not get addresses of interface %s", iface.Name)
				continue
			}
			for _, addr := range addrs {
				ip, _, err := net.ParseCIDR(addr.String())
				if err != nil {
					continue
				}
				if ip.String() == GetListenIP().String() {
					logfInfo("Found interface with listen IP: %s", iface.Name)
					return &iface, nil
				}
			}
		}
	}
	return nil, errors.New("Could not determine the interface of the listen IP address")
}
1184370
func GetPointerToInt64(p *float64) *int64 {
	if p == nil {
		return nil
	}
	i := int64(*p)
	return &i
}
101438
func GetFunction(function interface{}) *runtime.Func {
	return runtime.FuncForPC(reflect.ValueOf(function).Pointer())
}
862816
func (sw *OvsSwitch) GetUplinkInterfaces(uplinkID string) []string {
	uplink, _ := sw.uplinkDb.Get(uplinkID)
	if uplink == nil {
		return nil
	}
	return uplink.([]string)
}
9430
func (s *VPCRouterSetting) AddInterface(vip string, ipaddress []string, maskLen int) {
	if s.Interfaces == nil {
		s.Interfaces = []*VPCRouterInterface{nil}
	}
	s.Interfaces = append(s.Interfaces, &VPCRouterInterface{
		VirtualIPAddress: vip,
		IPAddress:        ipaddress,
		NetworkMaskLen:   maskLen,
	})
}
152315
func getPointerToStruct(oldObj interface{}) interface{} {
	resType := reflect.TypeOf(oldObj)
	ptr := reflect.New(resType)
	ptr.Elem().Set(reflect.ValueOf(oldObj))
	return ptr.Interface()
}
76216
func findInterfaceNetwork(pIface *net.Interface, ip net.IP) (*net.Interface, *net.IPNet, error) {
	ifaces, err := vlanInterfaces(pIface)
	ifaces = append(ifaces, pIface)
	if err != nil {
		return nil, nil, err
	}
	for _, iface := range ifaces {
		if network, _ := findNetwork(iface, ip); network != nil {
			return iface, network, nil
		}
	}
	return nil, nil, fmt.Errorf("Failed to find IP %v on any interface", ip)
}
769793
func (p *JsonPointer) Get(document interface{}) (interface{}, reflect.Kind, error) {

	is := &implStruct{mode: "GET", inDocument: document}
	p.implementation(is)
	return is.getOutNode, is.getOutKind, is.outError

}
1003229
func GetAllInterfaces() (IfAddrs, error) {
	ifs, err := net.Interfaces()
	if err != nil {
		return nil, err
	}

	ifAddrs := make(IfAddrs, 0, len(ifs))
	for _, intf := range ifs {
		addrs, err := intf.Addrs()
		if err != nil {
			return nil, err
		}

		for _, addr := range addrs {
			var ipAddr IPAddr
			ipAddr, err = NewIPAddr(addr.String())
			if err != nil {
				return IfAddrs{}, fmt.Errorf("unable to create an IP address from %q", addr.String())
			}

			ifAddr := IfAddr{
				SockAddr:  ipAddr,
				Interface: intf,
			}
			ifAddrs = append(ifAddrs, ifAddr)
		}
	}

	return ifAddrs, nil
}
1019163
func (e *Element) getCenter() (int, int, error) {
	points, err := e.Dimensions()
	if err != nil {
		return 0, 0, err
	}

	x, y, err := centroid(points)
	if err != nil {
		return 0, 0, err
	}
	return x, y, nil
}
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
}
812416
func (tc *typCache) isPointer(typ reflect.Type) bool {
	return tc.info(typ).isPointer
}
682260
func (o *VPort) HostInterfaces(info *bambou.FetchingInfo) (HostInterfacesList, *bambou.Error) {

	var list HostInterfacesList
	err := bambou.CurrentSession().FetchChildren(o, HostInterfaceIdentity, &list, info)
	return list, err
}
1203547
func GetInit(ipamName string) func(ic ipamapi.Callback, l, g interface{}) error {
	return func(ic ipamapi.Callback, l, g interface{}) error {
		return ic.RegisterIpamDriver(ipamName, &allocator{})
	}
}