// HasDHCPStaticMapping DHCPスタティックマッピング設定を保持しているか
169746
func (s *VPCRouterSetting) HasDHCPStaticMapping() bool {
	return s.DHCPStaticMapping != nil && len(s.DHCPStaticMapping.Config) > 0
}
344329
func ReserveIPv6HostID(hostID string, IPv6AllocMap *map[string]bool) {
	if hostID == "" {
		return
	}
	if *IPv6AllocMap == nil {
		*IPv6AllocMap = make(map[string]bool)
	}
	(*IPv6AllocMap)[hostID] = true
}
930740
func GetDHCPMessageType(o dhcp4.Options) DHCPMessageType {
	v := o.Get(dhcp4.OptionDHCPMessageType)
	if v == nil {
		return 0
	}

	var d DHCPMessageType
	if err := (&d).UnmarshalBinary(v); err != nil {
		return 0
	}
	return d
}
1237498
func (t *Template) GetAllAWSEC2DHCPOptionsResources() map[string]*resources.AWSEC2DHCPOptions {
	results := map[string]*resources.AWSEC2DHCPOptions{}
	for name, untyped := range t.Resources {
		switch resource := untyped.(type) {
		case *resources.AWSEC2DHCPOptions:
			results[name] = resource
		}
	}
	return results
}
319835
func (pm *PortMapper) Unmap(host net.Addr) error {
	pm.lock.Lock()
	defer pm.lock.Unlock()

	key := getKey(host)
	data, exists := pm.currentMappings[key]
	if !exists {
		return ErrPortNotMapped
	}

	if data.userlandProxy != nil {
		data.userlandProxy.Stop()
	}

	delete(pm.currentMappings, key)

	containerIP, containerPort := getIPAndPort(data.container)
	hostIP, hostPort := getIPAndPort(data.host)
	if err := pm.DeleteForwardingTableEntry(data.proto, hostIP, hostPort, containerIP.String(), containerPort); err != nil {
		logrus.Errorf("Error on iptables delete: %s", err)
	}

	switch a := host.(type) {
	case *net.TCPAddr:
		return pm.Allocator.ReleasePort(a.IP, "tcp", a.Port)
	case *net.UDPAddr:
		return pm.Allocator.ReleasePort(a.IP, "udp", a.Port)
	case *sctp.SCTPAddr:
		if len(a.IP) == 0 {
			return ErrSCTPAddrNoIP
		}
		return pm.Allocator.ReleasePort(a.IP[0], "sctp", a.Port)
	}
	return ErrUnknownBackendAddressType
}
1027382
func (*protocol) ResolveStaticAddress(addr tcpip.Address) (tcpip.LinkAddress, bool) {
	if addr == header.IPv4Broadcast {
		return broadcastMAC, true
	}
	if header.IsV4MulticastAddress(addr) {
		// RFC 1112 Host Extensions for IP Multicasting
		//
		// 6.4. Extensions to an Ethernet Local Network Module:
		//
		// An IP host group address is mapped to an Ethernet multicast
		// address by placing the low-order 23-bits of the IP address
		// into the low-order 23 bits of the Ethernet multicast address
		// 01-00-5E-00-00-00 (hex).
		return tcpip.LinkAddress([]byte{
			0x01,
			0x00,
			0x5e,
			addr[header.IPv4AddressSize-3] & 0x7f,
			addr[header.IPv4AddressSize-2],
			addr[header.IPv4AddressSize-1],
		}), true
	}
	return "", false
}
296973
func PrefixedHeaders(apiKey, payloadVersion string) map[string]string {
	return map[string]string{
		"Content-Type":            "application/json",
		"Bugsnag-Api-Key":         apiKey,
		"Bugsnag-Payload-Version": payloadVersion,
		"Bugsnag-Sent-At":         time.Now().UTC().Format(time.RFC3339),
	}
}
326201
func WithStaticConnectors(s Storage, staticConnectors []Connector) Storage {
	connectorsByID := make(map[string]Connector, len(staticConnectors))
	for _, c := range staticConnectors {
		connectorsByID[c.ID] = c
	}
	return staticConnectorsStorage{s, staticConnectors, connectorsByID}
}
818237
func (p *PMP) DeletePortMapping(port uint16) error {
	p.forwardedPortsMtx.Lock()
	defer p.forwardedPortsMtx.Unlock()

	if _, exists := p.forwardedPorts[port]; !exists {
		return fmt.Errorf("port %d is not being forwarded", port)
	}

	_, err := p.client.AddPortMapping("tcp", int(port), 0, 0)
	if err != nil {
		return err
	}

	delete(p.forwardedPorts, port)

	return nil
}
715491
func WithStaticClients(s Storage, staticClients []Client) Storage {
	clientsByID := make(map[string]Client, len(staticClients))
	for _, client := range staticClients {
		clientsByID[client.ID] = client
	}

	return staticClientsStorage{s, staticClients, clientsByID}
}
99634
func (a *Client) GetDhcp(params *GetDhcpParams, authInfo runtime.ClientAuthInfoWriter) (*GetDhcpOK, error) {
	// TODO: Validate the params before sending
	if params == nil {
		params = NewGetDhcpParams()
	}

	result, err := a.transport.Submit(&runtime.ClientOperation{
		ID:                 "GetDhcp",
		Method:             "GET",
		PathPattern:        "/dhcp",
		ProducesMediaTypes: []string{"application/json", "application/x-gzip"},
		ConsumesMediaTypes: []string{"application/json"},
		Schemes:            []string{"http", "https"},
		Params:             params,
		Reader:             &GetDhcpReader{formats: a.formats},
		AuthInfo:           authInfo,
	})
	if err != nil {
		return nil, err
	}
	return result.(*GetDhcpOK), nil
}
292264
func (m *sioMgr) isSdcMappedToVol(sdcID string, vol *siotypes.Volume) bool {
	if len(vol.MappedSdcInfo) == 0 {
		klog.V(4).Info(log("no attachment found"))
		return false
	}

	for _, sdcInfo := range vol.MappedSdcInfo {
		if sdcInfo.SdcID == sdcID {
			return true
		}
	}
	return false
}
1246357
func (p *Profile) massageMappings() {
	// Merge adjacent regions with matching names, checking that the offsets match
	if len(p.Mapping) > 1 {
		mappings := []*Mapping{p.Mapping[0]}
		for _, m := range p.Mapping[1:] {
			lm := mappings[len(mappings)-1]
			if adjacent(lm, m) {
				lm.Limit = m.Limit
				if m.File != "" {
					lm.File = m.File
				}
				if m.BuildID != "" {
					lm.BuildID = m.BuildID
				}
				p.updateLocationMapping(m, lm)
				continue
			}
			mappings = append(mappings, m)
		}
		p.Mapping = mappings
	}

	// Use heuristics to identify main binary and move it to the top of the list of mappings
	for i, m := range p.Mapping {
		file := strings.TrimSpace(strings.Replace(m.File, "(deleted)", "", -1))
		if len(file) == 0 {
			continue
		}
		if len(libRx.FindStringSubmatch(file)) > 0 {
			continue
		}
		if file[0] == '[' {
			continue
		}
		// Swap what we guess is main to position 0.
		p.Mapping[0], p.Mapping[i] = p.Mapping[i], p.Mapping[0]
		break
	}

	// Keep the mapping IDs neatly sorted
	for i, m := range p.Mapping {
		m.ID = uint64(i + 1)
	}
}
1058074
func (p *PMP) AddPortMapping(port uint16) error {
	p.forwardedPortsMtx.Lock()
	defer p.forwardedPortsMtx.Unlock()

	_, err := p.client.AddPortMapping("tcp", int(port), int(port), 0)
	if err != nil {
		return err
	}

	p.forwardedPorts[port] = struct{}{}

	return nil
}
992339
func (n *Network) GetDHCPLeases() ([]NetworkDHCPLease, error) {
	if C.LIBVIR_VERSION_NUMBER < 1002006 {
		return []NetworkDHCPLease{}, makeNotImplementedError("virNetworkGetDHCPLeases")
	}
	var cLeases *C.virNetworkDHCPLeasePtr
	var err C.virError
	numLeases := C.virNetworkGetDHCPLeasesWrapper(n.ptr, nil, (**C.virNetworkDHCPLeasePtr)(&cLeases), C.uint(0), &err)
	if numLeases == -1 {
		return nil, makeError(&err)
	}
	hdr := reflect.SliceHeader{
		Data: uintptr(unsafe.Pointer(cLeases)),
		Len:  int(numLeases),
		Cap:  int(numLeases),
	}
	var leases []NetworkDHCPLease
	slice := *(*[]C.virNetworkDHCPLeasePtr)(unsafe.Pointer(&hdr))
	for _, clease := range slice {
		leases = append(leases, NetworkDHCPLease{
			Iface:      C.GoString(clease.iface),
			ExpiryTime: time.Unix(int64(clease.expirytime), 0),
			Type:       IPAddrType(clease._type),
			Mac:        C.GoString(clease.mac),
			Iaid:       C.GoString(clease.iaid),
			IPaddr:     C.GoString(clease.ipaddr),
			Prefix:     uint(clease.prefix),
			Hostname:   C.GoString(clease.hostname),
			Clientid:   C.GoString(clease.clientid),
		})
		C.virNetworkDHCPLeaseFreeWrapper(clease)
	}
	C.free(unsafe.Pointer(cLeases))
	return leases, nil
}
202716
func (s *BaremetalService) ListBaremetalDhcp(p *ListBaremetalDhcpParams) (*ListBaremetalDhcpResponse, error) {
	resp, err := s.cs.newRequest("listBaremetalDhcp", p.toURLValues())
	if err != nil {
		return nil, err
	}

	var r ListBaremetalDhcpResponse
	if err := json.Unmarshal(resp, &r); err != nil {
		return nil, err
	}

	return &r, nil
}
1116932
func (o *Zone) DHCPOptions(info *bambou.FetchingInfo) (DHCPOptionsList, *bambou.Error) {

	var list DHCPOptionsList
	err := bambou.CurrentSession().FetchChildren(o, DHCPOptionIdentity, &list, info)
	return list, err
}