Skip to content
forked from raboof/netlink

simple netlink lib for golang

License

Notifications You must be signed in to change notification settings

We-unite/netlink

 
 

Repository files navigation

netlink - a simple netlink library for go

Build Status GoDoc

what's netlink ?

The netlink package provides a simple netlink library for go. Netlink is the interface a user-space program in linux uses to communicate with the kernel.

more information here

example

func (c *ExecCollector) prepareSocket() (*netlink.NetlinkSocket, error) {
	ns, err := netlink.NewNetlinkSocket(netlink.CONNECTOR, netlink.CN_IDX_PROC)
	if err != nil {
		return nil, fmt.Errorf("create netlink socket: %v", err)
	}
	req := netlink.NewNetlinkRequest()
	{
		msg := netlink.NewCnMsg()
		req.AddData(msg)
		op := netlink.PROC_CN_MCAST_LISTEN
		req.AddData(&op)
	}
	err = ns.Send(req)
	if err != nil {
		return nil, fmt.Errorf("Exec: %v", err)
	}
	go func() {
		<-c.shutdown
		ns.Close()
	}()
	return ns, nil
}

future work

WIP

About

simple netlink lib for golang

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 89.1%
  • C 10.9%