package netlink import ( "errors" "fmt" "github.com/mdlayher/netlink/nlenc" ) // Various errors which may occur when attempting to marshal or unmarshal // a Message to and from its binary form. var ( errIncorrectMessageLength = errors.New("netlink message header length incorrect") errShortMessage = errors.New("not enough data to create a netlink message") errUnalignedMessage = errors.New("input data is not properly aligned for netlink message") ) // HeaderFlags specify flags which may be present in a Header. type HeaderFlags uint16 const ( // General netlink communication flags. // HeaderFlagsRequest indicates a request to netlink. HeaderFlagsRequest HeaderFlags = 1 // HeaderFlagsMulti indicates a multi-part message, terminated // by HeaderTypeDone on the last message. HeaderFlagsMulti HeaderFlags = 2 // HeaderFlagsAcknowledge requests that netlink reply with // an acknowledgement using HeaderTypeError and, if needed, // an error code. HeaderFlagsAcknowledge HeaderFlags = 4 // HeaderFlagsEcho requests that netlink echo this request // back to the sender. HeaderFlagsEcho HeaderFlags = 8 // HeaderFlagsDumpInterrupted indicates that a dump was // inconsistent due to a sequence change. HeaderFlagsDumpInterrupted HeaderFlags = 16 // HeaderFlagsDumpFiltered indicates that a dump was filtered // as requested. HeaderFlagsDumpFiltered HeaderFlags = 32 // Flags used to retrieve data from netlink. // HeaderFlagsRoot requests that netlink return a complete table instead // of a single entry. HeaderFlagsRoot HeaderFlags = 0x100 // HeaderFlagsMatch requests that netlink return a list of all matching // entries. HeaderFlagsMatch HeaderFlags = 0x200 // HeaderFlagsAtomic requests that netlink send an atomic snapshot of // its entries. Requires CAP_NET_ADMIN or an effective UID of 0. HeaderFlagsAtomic HeaderFlags = 0x400 // HeaderFlagsDump requests that netlink return a complete list of // all entries. HeaderFlagsDump HeaderFlags = HeaderFlagsRoot | HeaderFlagsMatch ) // String returns the string representation of a HeaderFlags. func (f HeaderFlags) String() string { names := []string{ "request", "multi", "acknowledge", "echo", "dumpinterrupted", "dumpfiltered", "1<<6", "1<<7", "root", "match", "atomic", } var s string for i, name := range names { if f&(1<