Documentation ¶
Overview ¶
Packet netlink provide access to low level Netlink sockets and messages.
Actual implementations are in: netlink_linux.go netlink_darwin.go
Index ¶
- Constants
- Variables
- func AddDefaultGw(ip net.IP) error
- func AddToBridge(iface, master *net.Interface) error
- func CreateBridge(name string, setMacAddr bool) error
- func NetworkChangeName(iface *net.Interface, newName string) error
- func NetworkCreateVethPair(name1, name2 string) error
- func NetworkLinkAdd(name string, linkType string) error
- func NetworkLinkAddIp(iface *net.Interface, ip net.IP, ipNet *net.IPNet) error
- func NetworkLinkDown(iface *net.Interface) error
- func NetworkLinkUp(iface *net.Interface) error
- func NetworkSetMTU(iface *net.Interface, mtu int) error
- func NetworkSetMaster(iface, master *net.Interface) error
- func NetworkSetNsFd(iface *net.Interface, fd int) error
- func NetworkSetNsPid(iface *net.Interface, nspid int) error
- type IfAddrmsg
- type IfInfomsg
- type NetlinkRequest
- type NetlinkRequestData
- type NetlinkSocket
- type Route
- type RtAttr
- type RtMsg
Constants ¶
const ( IFNAMSIZ = 16 DEFAULT_CHANGE = 0xFFFFFFFF IFLA_INFO_KIND = 1 IFLA_INFO_DATA = 2 VETH_INFO_PEER = 1 IFLA_NET_NS_FD = 28 SIOC_BRADDBR = 0x89a0 SIOC_BRADDIF = 0x89a2 )
Variables ¶
var ( ErrWrongSockType = errors.New("Wrong socket type") ErrShortResponse = errors.New("Got short response from netlink") )
Functions ¶
func AddDefaultGw ¶
Add a new default gateway. Identical to: ip route add default via $ip
func AddToBridge ¶ added in v0.11.0
Add a slave to abridge device. This is more backward-compatible than netlink.NetworkSetMaster and works on RHEL 6.
func CreateBridge ¶ added in v0.10.0
Create the actual bridge device. This is more backward-compatible than netlink.NetworkLinkAdd and works on RHEL 6.
func NetworkChangeName ¶ added in v0.9.0
func NetworkCreateVethPair ¶ added in v0.9.0
func NetworkLinkAdd ¶
Add a new network link of a specified type. This is identical to running: ip add link $name type $linkType
func NetworkLinkAddIp ¶
Add an Ip address to an interface. This is identical to: ip addr add $ip/$ipNet dev $iface
func NetworkLinkDown ¶ added in v0.9.0
func NetworkLinkUp ¶
Bring up a particular network interface
func NetworkSetMaster ¶ added in v0.9.0
same as ip link set $name master $master
Types ¶
type IfAddrmsg ¶
func (*IfAddrmsg) ToWireFormat ¶
type IfInfomsg ¶
func (*IfInfomsg) ToWireFormat ¶
type NetlinkRequest ¶
type NetlinkRequest struct { syscall.NlMsghdr Data []NetlinkRequestData }
func (*NetlinkRequest) AddData ¶
func (rr *NetlinkRequest) AddData(data NetlinkRequestData)
func (*NetlinkRequest) ToWireFormat ¶
func (rr *NetlinkRequest) ToWireFormat() []byte
type NetlinkRequestData ¶
type NetlinkSocket ¶
type NetlinkSocket struct {
// contains filtered or unexported fields
}
func (*NetlinkSocket) Close ¶
func (s *NetlinkSocket) Close()
func (*NetlinkSocket) GetPid ¶
func (s *NetlinkSocket) GetPid() (uint32, error)
func (*NetlinkSocket) HandleAck ¶
func (s *NetlinkSocket) HandleAck(seq uint32) error
func (*NetlinkSocket) Receive ¶ added in v0.7.5
func (s *NetlinkSocket) Receive() ([]syscall.NetlinkMessage, error)
func (*NetlinkSocket) Send ¶
func (s *NetlinkSocket) Send(request *NetlinkRequest) error
type Route ¶ added in v0.8.0
A Route is a subnet associated with the interface to reach it.
func NetworkGetRoutes ¶
Returns an array of IPNet for all the currently routed subnets on ipv4 This is similar to the first column of "ip route" output