当前位置: 首页>>代码示例>>Golang>>正文


Golang types.GetIPNetCopy函数代码示例

本文整理汇总了Golang中github.com/docker/libnetwork/types.GetIPNetCopy函数的典型用法代码示例。如果您正苦于以下问题:Golang GetIPNetCopy函数的具体用法?Golang GetIPNetCopy怎么用?Golang GetIPNetCopy使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了GetIPNetCopy函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: processIPAM

func (c *networkConfiguration) processIPAM(id string, ipamV4Data, ipamV6Data []driverapi.IPAMData) error {
	if len(ipamV4Data) > 1 || len(ipamV6Data) > 1 {
		return types.ForbiddenErrorf("bridge driver doesn't support multiple subnets")
	}

	if len(ipamV4Data) == 0 {
		return types.BadRequestErrorf("bridge network %s requires ipv4 configuration", id)
	}

	if ipamV4Data[0].Gateway != nil {
		c.AddressIPv4 = types.GetIPNetCopy(ipamV4Data[0].Gateway)
	}

	if gw, ok := ipamV4Data[0].AuxAddresses[DefaultGatewayV4AuxKey]; ok {
		c.DefaultGatewayIPv4 = gw.IP
	}

	if len(ipamV6Data) > 0 {
		c.AddressIPv6 = ipamV6Data[0].Pool

		if ipamV6Data[0].Gateway != nil {
			c.AddressIPv6 = types.GetIPNetCopy(ipamV6Data[0].Gateway)
		}

		if gw, ok := ipamV6Data[0].AuxAddresses[DefaultGatewayV6AuxKey]; ok {
			c.DefaultGatewayIPv6 = gw.IP
		}
	}

	return nil
}
开发者ID:jak-atx,项目名称:vic,代码行数:31,代码来源:bridge.go

示例2: GetCopy

// GetCopy returns a copy of this Interface structure
func (i *Interface) GetCopy() *Interface {
	return &Interface{
		SrcName:     i.SrcName,
		DstName:     i.DstName,
		Address:     types.GetIPNetCopy(i.Address),
		AddressIPv6: types.GetIPNetCopy(i.AddressIPv6),
	}
}
开发者ID:AdamOssenford,项目名称:docker-pi,代码行数:9,代码来源:sandbox.go

示例3: CopyTo

// CopyTo deep copies the pool data to the destination pooldata
func (p *PoolData) CopyTo(dstP *PoolData) error {
	dstP.ParentKey = p.ParentKey
	dstP.Pool = types.GetIPNetCopy(p.Pool)

	if p.Range != nil {
		dstP.Range = &AddressRange{}
		dstP.Range.Sub = types.GetIPNetCopy(p.Range.Sub)
		dstP.Range.Start = p.Range.Start
		dstP.Range.End = p.Range.End
	}

	dstP.RefCount = p.RefCount
	return nil
}
开发者ID:DaveDaCoda,项目名称:docker,代码行数:15,代码来源:structures.go

示例4: CopyTo

func (epi *endpointInterface) CopyTo(dstEpi *endpointInterface) error {
	dstEpi.mac = types.GetMacCopy(epi.mac)
	dstEpi.addr = types.GetIPNetCopy(epi.addr)
	dstEpi.addrv6 = types.GetIPNetCopy(epi.addrv6)
	dstEpi.srcName = epi.srcName
	dstEpi.dstPrefix = epi.dstPrefix
	dstEpi.poolID = epi.poolID

	for _, route := range epi.routes {
		dstEpi.routes = append(dstEpi.routes, types.GetIPNetCopy(route))
	}

	return nil
}
开发者ID:dhiltgen,项目名称:libnetwork,代码行数:14,代码来源:endpoint_info.go

示例5: setAddress

func setAddress(ifaceAddr **net.IPNet, address *net.IPNet) error {
	if *ifaceAddr != nil {
		return types.ForbiddenErrorf("endpoint interface IP present (%s). Cannot be modified with (%s).", *ifaceAddr, address)
	}
	*ifaceAddr = types.GetIPNetCopy(address)
	return nil
}
开发者ID:winsx,项目名称:libnetwork,代码行数:7,代码来源:bridge_test.go

示例6: getAddress

func (a *Allocator) getAddress(nw *net.IPNet, bitmask *bitseq.Handle, prefAddress net.IP, ipr *AddressRange) (net.IP, error) {
	var (
		ordinal uint64
		err     error
		base    *net.IPNet
	)

	base = types.GetIPNetCopy(nw)

	if bitmask.Unselected() <= 0 {
		return nil, ipamapi.ErrNoAvailableIPs
	}
	if ipr == nil && prefAddress == nil {
		ordinal, err = bitmask.SetAny()
	} else if prefAddress != nil {
		hostPart, e := types.GetHostPartIP(prefAddress, base.Mask)
		if e != nil {
			return nil, fmt.Errorf("failed to allocate preferred address %s: %v", prefAddress.String(), e)
		}
		ordinal = ipToUint64(types.GetMinimalIP(hostPart))
		err = bitmask.Set(ordinal)
	} else {
		base.IP = ipr.Sub.IP
		ordinal, err = bitmask.SetAnyInRange(ipr.Start, ipr.End)
	}
	if err != nil {
		return nil, ipamapi.ErrNoAvailableIPs
	}

	// Convert IP ordinal for this subnet into IP address
	return generateAddress(ordinal, base), nil
}
开发者ID:newdeamon,项目名称:docker,代码行数:32,代码来源:allocator.go

示例7: IPAliases

func (epi *endpointInterface) IPAliases() []*net.IPNet {
	var aliases []*net.IPNet
	for _, alias := range epi.ipAliases {
		aliases = append(aliases, types.GetIPNetCopy(alias))
	}
	return aliases
}
开发者ID:jc-m,项目名称:test-docker-plugin,代码行数:7,代码来源:endpoint_info.go

示例8: SetIPAliases

func (epi *endpointInterface) SetIPAliases(aliases []*net.IPNet) error {

	if epi.ipAliases != nil {
		return types.ForbiddenErrorf("endpoint aliases present. Cannot be modified with (%s).", aliases)
	}
	epi.ipAliases = make([]*net.IPNet, 0)
	for _, alias := range aliases {
		epi.ipAliases = append(epi.ipAliases, types.GetIPNetCopy(alias))
	}
	return nil
}
开发者ID:jc-m,项目名称:test-docker-plugin,代码行数:11,代码来源:endpoint_info.go

示例9: IPAliases

func (i *nwIface) IPAliases() []*net.IPNet {
	i.Lock()
	defer i.Unlock()

	aliases := make([]*net.IPNet, len(i.aliases))
	for index, alias := range i.aliases {
		ipa := types.GetIPNetCopy(alias)
		aliases[index] = ipa
	}

	return aliases
}
开发者ID:jc-m,项目名称:test-docker-plugin,代码行数:12,代码来源:interface_linux.go

示例10: getIPv4Data

func getIPv4Data(t *testing.T) []driverapi.IPAMData {
	ipd := driverapi.IPAMData{AddressSpace: "full"}
	nw, _, err := ipamutils.ElectInterfaceAddresses("")
	if err != nil {
		t.Fatal(err)
	}
	ipd.Pool = nw
	// Set network gateway to X.X.X.1
	ipd.Gateway = types.GetIPNetCopy(nw)
	ipd.Gateway.IP[len(ipd.Gateway.IP)-1] = 1
	return []driverapi.IPAMData{ipd}
}
开发者ID:winsx,项目名称:libnetwork,代码行数:12,代码来源:bridge_test.go

示例11: CopyTo

func (epi *endpointInterface) CopyTo(dstEpi *endpointInterface) error {
	dstEpi.mac = types.GetMacCopy(epi.mac)
	dstEpi.addr = types.GetIPNetCopy(epi.addr)
	dstEpi.addrv6 = types.GetIPNetCopy(epi.addrv6)
	dstEpi.srcName = epi.srcName
	dstEpi.dstPrefix = epi.dstPrefix
	dstEpi.v4PoolID = epi.v4PoolID
	dstEpi.v6PoolID = epi.v6PoolID
	if len(epi.llAddrs) != 0 {
		dstEpi.llAddrs = make([]*net.IPNet, 0, len(epi.llAddrs))
		for _, ll := range epi.llAddrs {
			dstEpi.llAddrs = append(dstEpi.llAddrs, ll)
		}
	}

	for _, route := range epi.routes {
		dstEpi.routes = append(dstEpi.routes, types.GetIPNetCopy(route))
	}

	return nil
}
开发者ID:harche,项目名称:docker,代码行数:21,代码来源:endpoint_info.go

示例12: Routes

func (i *nwIface) Routes() []*net.IPNet {
	i.Lock()
	defer i.Unlock()

	routes := make([]*net.IPNet, len(i.routes))
	for index, route := range i.routes {
		r := types.GetIPNetCopy(route)
		routes[index] = r
	}

	return routes
}
开发者ID:DaveDaCoda,项目名称:docker,代码行数:12,代码来源:interface_linux.go

示例13: CopyTo

// CopyTo deep copies to the destination IpamInfo
func (i *IpamInfo) CopyTo(dstI *IpamInfo) error {
	dstI.PoolID = i.PoolID
	if i.Meta != nil {
		dstI.Meta = make(map[string]string)
		for k, v := range i.Meta {
			dstI.Meta[k] = v
		}
	}

	dstI.AddressSpace = i.AddressSpace
	dstI.Pool = types.GetIPNetCopy(i.Pool)
	dstI.Gateway = types.GetIPNetCopy(i.Gateway)

	if i.AuxAddresses != nil {
		dstI.AuxAddresses = make(map[string]*net.IPNet)
		for k, v := range i.AuxAddresses {
			dstI.AuxAddresses[k] = types.GetIPNetCopy(v)
		}
	}

	return nil
}
开发者ID:amitshukla,项目名称:docker,代码行数:23,代码来源:network.go

示例14: SetIPAddress

func (ep *endpoint) SetIPAddress(address *net.IPNet) error {
	if address.IP == nil {
		return types.BadRequestErrorf("tried to set nil IP address to endpoint interface")
	}
	if address.IP.To4() == nil {
		return types.NotImplementedErrorf("do not support ipv6 yet")
	}
	if ep.addr != nil {
		return types.ForbiddenErrorf("endpoint interface IP present (%s). Cannot be modified with %s.", ep.addr, address)
	}
	ep.addr = types.GetIPNetCopy(address)
	return nil
}
开发者ID:c0b,项目名称:libnetwork,代码行数:13,代码来源:ovrouter.go

示例15: verifyV4INCEntries

func verifyV4INCEntries(networks map[string]*bridgeNetwork, numEntries int, t *testing.T) {
	out, err := iptables.Raw("-L", "FORWARD")
	if err != nil {
		t.Fatal(err)
	}
	for _, nw := range networks {
		nt := types.GetIPNetCopy(nw.bridge.bridgeIPv4)
		nt.IP = nt.IP.Mask(nt.Mask)
		re := regexp.MustCompile(nt.String())
		matches := re.FindAllString(string(out[:]), -1)
		if len(matches) != numEntries {
			t.Fatalf("Cannot find expected inter-network isolation rules in IP Tables:\n%s", string(out[:]))
		}
	}
}
开发者ID:hurrygeek,项目名称:libnetwork,代码行数:15,代码来源:bridge_test.go


注:本文中的github.com/docker/libnetwork/types.GetIPNetCopy函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。