Documentation ¶
Index ¶
- Constants
- Variables
- func Echo(text string) error
- func GetIPAddressFamily(ip net.IP) int
- func ResetSocket()
- type BridgeLink
- type DummyLink
- type IPVlanLink
- type IPVlanMode
- type Link
- type LinkInfo
- type MockNetlink
- func (f *MockNetlink) AddIPAddress(string, net.IP, *net.IPNet) error
- func (f *MockNetlink) AddIPRoute(*Route) error
- func (f *MockNetlink) AddLink(l Link) error
- func (f *MockNetlink) AddOrRemoveStaticArp(int, string, net.IP, net.HardwareAddr, bool) error
- func (f *MockNetlink) DeleteIPAddress(string, net.IP, *net.IPNet) error
- func (f *MockNetlink) DeleteIPRoute(*Route) error
- func (f *MockNetlink) DeleteLink(name string) error
- func (f *MockNetlink) GetIPRoute(*Route) ([]*Route, error)
- func (f *MockNetlink) SetLinkAddress(string, net.HardwareAddr) error
- func (f *MockNetlink) SetLinkHairpin(string, bool) error
- func (f *MockNetlink) SetLinkMTU(name string, mtu int) error
- func (f *MockNetlink) SetLinkMaster(string, string) error
- func (f *MockNetlink) SetLinkName(string, string) error
- func (f *MockNetlink) SetLinkNetNs(string, uintptr) error
- func (f *MockNetlink) SetLinkPromisc(string, bool) error
- func (f *MockNetlink) SetLinkState(string, bool) error
- type Netlink
- func (n Netlink) AddIPAddress(ifName string, ipAddress net.IP, ipNet *net.IPNet) error
- func (Netlink) AddIPRoute(route *Route) error
- func (Netlink) AddLink(link Link) error
- func (Netlink) AddOrRemoveStaticArp(mode int, name string, ipaddr net.IP, mac net.HardwareAddr, isProxy bool) error
- func (n Netlink) DeleteIPAddress(ifName string, ipAddress net.IP, ipNet *net.IPNet) error
- func (Netlink) DeleteIPRoute(route *Route) error
- func (Netlink) DeleteLink(name string) error
- func (Netlink) GetIPRoute(filter *Route) ([]*Route, error)
- func (Netlink) SetLinkAddress(ifName string, hwAddress net.HardwareAddr) error
- func (Netlink) SetLinkHairpin(bridgeName string, on bool) error
- func (Netlink) SetLinkMTU(name string, mtu int) error
- func (Netlink) SetLinkMaster(name string, master string) error
- func (Netlink) SetLinkName(name string, newName string) error
- func (Netlink) SetLinkNetNs(name string, fd uintptr) error
- func (Netlink) SetLinkPromisc(ifName string, on bool) error
- func (Netlink) SetLinkState(name string, up bool) error
- type NetlinkInterface
- type Route
- type VEthLink
Constants ¶
const ( RT_SCOPE_UNIVERSE = 0 RT_SCOPE_SITE = 200 RT_SCOPE_LINK = 253 RT_SCOPE_HOST = 254 RT_SCOPE_NOWHERE = 255 )
const ( LINK_TYPE_BRIDGE = "bridge" LINK_TYPE_VETH = "veth" LINK_TYPE_IPVLAN = "ipvlan" LINK_TYPE_DUMMY = "dummy" )
Link types.
const ( ADD = iota REMOVE )
const ( NDA_UNSPEC = iota NDA_DST NDA_LLADDR NDA_CACHEINFO NDA_PROBES NDA_VLAN NDA_PORT NDA_VNI NDA_IFINDEX NDA_MAX = NDA_IFINDEX )
const ( NUD_NONE = 0x00 NUD_INCOMPLETE = 0x01 NUD_REACHABLE = 0x02 NUD_STALE = 0x04 NUD_DELAY = 0x08 NUD_PROBE = 0x10 NUD_FAILED = 0x20 NUD_NOARP = 0x40 NUD_PERMANENT = 0x80 )
Neighbor Cache Entry States.
const ( NTF_USE = 0x01 NTF_SELF = 0x02 NTF_MASTER = 0x04 NTF_PROXY = 0x08 NTF_ROUTER = 0x80 )
Neighbor Flags
const ( IFLA_INFO_KIND = 1 IFLA_INFO_DATA = 2 IFLA_NET_NS_FD = 28 IFLA_IPVLAN_MODE = 1 IFLA_BRPORT_MODE = 4 VETH_INFO_PEER = 1 DEFAULT_CHANGE = 0xFFFFFFFF )
Netlink protocol constants that are not already defined in unix package.
const (
RTPROT_KERNEL = 2
)
Variables ¶
var ErrorMockNetlink = errors.New("Mock Netlink Error")
ErrorMockNetlink - netlink mock error
Functions ¶
func GetIPAddressFamily ¶
GetIPAddressFamily returns the address family of an IP address.
Types ¶
type IPVlanLink ¶
type IPVlanLink struct { LinkInfo Mode IPVlanMode }
IPVlanLink represents an IPVlan network interface.
type IPVlanMode ¶
type IPVlanMode uint16
IPVLAN link attributes.
const ( IPVLAN_MODE_L2 IPVlanMode = iota IPVLAN_MODE_L3 IPVLAN_MODE_L3S IPVLAN_MODE_MAX )
type LinkInfo ¶
type LinkInfo struct { Type string Name string Flags net.Flags MTU uint TxQLen uint ParentIndex int }
LinkInfo respresents the common properties of all network interfaces.
type MockNetlink ¶
type MockNetlink struct {
// contains filtered or unexported fields
}
func NewMockNetlink ¶
func NewMockNetlink(returnError bool, errorString string) *MockNetlink
func (*MockNetlink) AddIPAddress ¶
func (*MockNetlink) AddIPRoute ¶
func (f *MockNetlink) AddIPRoute(*Route) error
func (*MockNetlink) AddLink ¶
func (f *MockNetlink) AddLink(l Link) error
func (*MockNetlink) AddOrRemoveStaticArp ¶ added in v1.4.13
func (f *MockNetlink) AddOrRemoveStaticArp(int, string, net.IP, net.HardwareAddr, bool) error
func (*MockNetlink) DeleteIPAddress ¶
func (*MockNetlink) DeleteIPRoute ¶
func (f *MockNetlink) DeleteIPRoute(*Route) error
func (*MockNetlink) DeleteLink ¶
func (f *MockNetlink) DeleteLink(name string) error
func (*MockNetlink) GetIPRoute ¶
func (f *MockNetlink) GetIPRoute(*Route) ([]*Route, error)
func (*MockNetlink) SetLinkAddress ¶
func (f *MockNetlink) SetLinkAddress(string, net.HardwareAddr) error
func (*MockNetlink) SetLinkHairpin ¶
func (f *MockNetlink) SetLinkHairpin(string, bool) error
func (*MockNetlink) SetLinkMTU ¶
func (f *MockNetlink) SetLinkMTU(name string, mtu int) error
func (*MockNetlink) SetLinkMaster ¶
func (f *MockNetlink) SetLinkMaster(string, string) error
func (*MockNetlink) SetLinkName ¶
func (f *MockNetlink) SetLinkName(string, string) error
func (*MockNetlink) SetLinkNetNs ¶
func (f *MockNetlink) SetLinkNetNs(string, uintptr) error
func (*MockNetlink) SetLinkPromisc ¶
func (f *MockNetlink) SetLinkPromisc(string, bool) error
func (*MockNetlink) SetLinkState ¶
func (f *MockNetlink) SetLinkState(string, bool) error
type Netlink ¶
type Netlink struct{}
func NewNetlink ¶
func NewNetlink() *Netlink
func (Netlink) AddIPAddress ¶
AddIPAddress adds an IP address to a network interface.
func (Netlink) AddIPRoute ¶
AddIPRoute adds an IP route to the route table.
func (Netlink) AddOrRemoveStaticArp ¶ added in v1.4.13
func (Netlink) AddOrRemoveStaticArp(mode int, name string, ipaddr net.IP, mac net.HardwareAddr, isProxy bool) error
AddOrRemoveStaticArp sets/removes static arp entry based on mode
func (Netlink) DeleteIPAddress ¶
DeleteIPAddress deletes an IP address from a network interface.
func (Netlink) DeleteIPRoute ¶
DeleteIPRoute deletes an IP route from the route table.
func (Netlink) DeleteLink ¶
DeleteLink deletes a network interface.
func (Netlink) GetIPRoute ¶
GetIPRoute returns a list of IP routes matching the given filter.
func (Netlink) SetLinkAddress ¶
func (Netlink) SetLinkAddress(ifName string, hwAddress net.HardwareAddr) error
SetLinkAddress sets the link layer hardware address of a network interface.
func (Netlink) SetLinkHairpin ¶
SetLinkHairpin sets the hairpin (reflective relay) mode of a bridged interface.
func (Netlink) SetLinkMaster ¶
SetLinkMaster sets the master (upper) device of a network interface.
func (Netlink) SetLinkName ¶
SetLinkName sets the name of a network interface.
func (Netlink) SetLinkNetNs ¶
SetLinkNetNs sets the network namespace of a network interface.
func (Netlink) SetLinkPromisc ¶
SetLinkPromisc sets the promiscuous mode of a network interface. TODO do we need this function, not used anywhere currently
type NetlinkInterface ¶
type NetlinkInterface interface { AddLink(link Link) error DeleteLink(name string) error SetLinkName(name string, newName string) error SetLinkState(name string, up bool) error SetLinkMTU(name string, mtu int) error SetLinkMaster(name string, master string) error SetLinkNetNs(name string, fd uintptr) error SetLinkAddress(ifName string, hwAddress net.HardwareAddr) error SetLinkPromisc(ifName string, on bool) error SetLinkHairpin(bridgeName string, on bool) error AddOrRemoveStaticArp(mode int, name string, ipaddr net.IP, mac net.HardwareAddr, isProxy bool) error AddIPAddress(ifName string, ipAddress net.IP, ipNet *net.IPNet) error DeleteIPAddress(ifName string, ipAddress net.IP, ipNet *net.IPNet) error GetIPRoute(filter *Route) ([]*Route, error) AddIPRoute(route *Route) error DeleteIPRoute(route *Route) error }