// Enables static nat for given ip address
171193
func (c *Client) EnableStaticNat(p *EnableStaticNatParameter) (*Result, error) {
	obj, err := c.Request("enableStaticNat", convertParamToMap(p))
	if err != nil {
		return nil, err
	}
	return obj.(*Result), err
}
886248
func (n *Networking) GetForwardableNetPodIP() (net.IP, error) {
	net, err := n.GetForwardableNet()
	if err != nil {
		return nil, err
	}
	return net.runtime.IP, nil
}
778877
func (c *sshInstanceConfigurator) ConfigureExternalIpAddress(apiPort int) error {
	cmds := ConfigureExternalIpAddressCommands(apiPort)
	output, err := c.runCommand(strings.Join(cmds, "\n"))
	if err != nil {
		return errors.Errorf("failed to drop all ports: %s", output)
	}
	if err != nil {
		return errors.Errorf("failed to allocate external IP address: %s", output)
	}
	logger.Tracef("configure external ip address output: %s", output)
	return nil
}
1103100
func (s *VPCRouterSetting) SetInternetConnection(enabled bool) {
	if s.InternetConnection == nil {
		s.InternetConnection = &VPCRouterInternetConnection{
			Enabled: "True",
		}
	}
	if enabled {
		s.InternetConnection.Enabled = "True"
	} else {
		s.InternetConnection.Enabled = "False"
	}
}
868216
func (r Network_Storage) AllowAccessToReplicantFromIpAddress(ipAddressObjectTemplate *datatypes.Network_Subnet_IpAddress) (resp bool, err error) {
	params := []interface{}{
		ipAddressObjectTemplate,
	}
	err = r.Session.DoRequest("SoftLayer_Network_Storage", "allowAccessToReplicantFromIpAddress", params, &r.Options, &resp)
	return
}
735742
func (ipv4 IPv4Addr) NetIPMask() *net.IPMask {
	ipv4Mask := net.IPMask{}
	ipv4Mask = make(net.IPMask, IPv4len)
	binary.BigEndian.PutUint32(ipv4Mask, uint32(ipv4.Mask))
	return &ipv4Mask
}
662586
func (s *VPCRouterSetting) AddStaticNAT(globalAddress string, privateAddress string, description string) (int, *VPCRouterStaticNATConfig) {
	if s.StaticNAT == nil {
		s.StaticNAT = &VPCRouterStaticNAT{
			Enabled: "True",
		}
	}

	if s.StaticNAT.Config == nil {
		s.StaticNAT.Config = []*VPCRouterStaticNATConfig{}
	}

	c := &VPCRouterStaticNATConfig{
		GlobalAddress:  globalAddress,
		PrivateAddress: privateAddress,
		Description:    description,
	}

	s.StaticNAT.Config = append(s.StaticNAT.Config, c)
	return len(s.StaticNAT.Config) - 1, c
}
127801
func kvmSetupNetAddressing(network *Networking, n activeNet, ifName string) error {
	// TODO: very ugly hack, that go through upper plugin, down to ipam plugin
	if err := ip.EnableIP4Forward(); err != nil {
		return errwrap.Wrap(errors.New("failed to enable forwarding"), err)
	}

	// patch plugin type only for single IPAM run time, then revert this change
	original_type := n.conf.Type
	n.conf.Type = n.conf.IPAM.Type
	output, err := network.execNetPlugin("ADD", &n, ifName)
	n.conf.Type = original_type
	if err != nil {
		return errwrap.Wrap(fmt.Errorf("problem executing network plugin %q (%q)", n.conf.IPAM.Type, ifName), err)
	}

	result := cnitypes.Result{}
	if err = json.Unmarshal(output, &result); err != nil {
		return errwrap.Wrap(fmt.Errorf("error parsing %q result", n.conf.Name), err)
	}

	if result.IP4 == nil {
		return fmt.Errorf("net-plugin returned no IPv4 configuration")
	}

	n.runtime.MergeCNIResult(result)

	return nil
}
1083827
func ConfigureExternalIpAddressCommands(apiPort int) []string {
	commands := []string{
		`printf 'auto eth1\niface eth1 inet dhcp' | sudo tee -a /etc/network/interfaces.d/eth1.cfg`,
		"sudo ifup eth1",
		iptables.DropCommand{Interface: "eth1"}.Render(),
	}
	if apiPort > 0 {
		commands = append(commands, iptables.AcceptInternalCommand{
			Protocol:        "tcp",
			DestinationPort: apiPort,
		}.Render())
	}
	return commands
}
85735
func (s *VPCRouterSetting) FindStaticNAT(globalAddress string, privateAddress string) (int, *VPCRouterStaticNATConfig) {
	for i, c := range s.StaticNAT.Config {
		if c.GlobalAddress == globalAddress && c.PrivateAddress == privateAddress {
			return i, c
		}
	}
	return -1, nil
}
349661
func (v *VPCRouter) RealIPAddress(index int) (string, int) {
	if !v.HasInterfaces() {
		return "", -1
	}
	for i, nic := range v.Settings.Router.Interfaces {
		if i == index {
			if index > 0 && nic == nil {
				return "", -1
			}

			if index == 0 && v.IsStandardPlan() {
				return v.Interfaces[0].IPAddress, v.Interfaces[0].Switch.Subnet.NetworkMaskLen
			}

			nwMask := nic.NetworkMaskLen
			if index == 0 {
				nwMask = v.Interfaces[0].Switch.Subnet.NetworkMaskLen
			}

			if v.IsStandardPlan() {
				return nic.IPAddress[0], nwMask
			}
			return nic.VirtualIPAddress, nwMask
		}
	}
	return "", -1
}
1157773
func (s *Stack) EnableNIC(id tcpip.NICID) *tcpip.Error {
	s.mu.RLock()
	defer s.mu.RUnlock()

	nic := s.nics[id]
	if nic == nil {
		return tcpip.ErrUnknownNICID
	}

	nic.attachLinkEndpoint()

	return nil
}
810761
func Enable() {
	go func() {
		if err := http.ListenAndServe(apiAddress, nil); err != nil {
			log.WithError(err).Warn("Unable to serve pprof API")
		}
	}()
}
675925
func (r Network_Component) GetIpAddressBindings() (resp []datatypes.Network_Component_IpAddress, err error) {
	err = r.Session.DoRequest("SoftLayer_Network_Component", "getIpAddressBindings", nil, &r.Options, &resp)
	return
}
992671
func (ras RouteAuthenticators) AllowsAnonymous() bool {
	for _, ra := range ras {
		if ra.AllowsAnonymous() {
			return true
		}
	}
	return false
}
200530
func (b *BigIP) VirtualAddressStatus(vaddr, state string) error {
	config := &VirtualAddress{}
	config.Enabled = (state == ENABLED)
	return b.put(config, uriLtm, uriVirtualAddress, vaddr)
}
128540
func NetAddrIPPROTO(addr net.Addr) int {
	switch addr := addr.(type) {
	case *net.IPAddr:
		switch {
		default:
			return IPPROTO_IP

		case addr.IP.To4() != nil:
			return IPPROTO_IPV4

		case addr.IP.To16() != nil:
			return IPPROTO_IPV6
		}

	case *net.TCPAddr:
		return IPPROTO_TCP

	case *net.UDPAddr:
		return IPPROTO_UDP

	default:
		return -1
	}
}