Add support for inverted set lookups. (#10)

This commit is contained in:
Tom D 2019-02-13 01:06:43 -08:00 committed by Michael Stapelberg
parent 51ca8da884
commit ca263a814b
1 changed files with 4 additions and 0 deletions

View File

@ -29,6 +29,7 @@ type Lookup struct {
SetID uint32
SetName string
Invert bool
}
func (e *Lookup) marshal() ([]byte, error) {
@ -40,6 +41,9 @@ func (e *Lookup) marshal() ([]byte, error) {
if e.DestRegister != 0 {
opAttrs = append(opAttrs, netlink.Attribute{Type: unix.NFTA_LOOKUP_DREG, Data: binaryutil.BigEndian.PutUint32(e.DestRegister)})
}
if e.Invert {
opAttrs = append(opAttrs, netlink.Attribute{Type: unix.NFTA_LOOKUP_FLAGS, Data: binaryutil.BigEndian.PutUint32(unix.NFT_LOOKUP_F_INV)})
}
opAttrs = append(opAttrs,
netlink.Attribute{Type: unix.NFTA_LOOKUP_SET, Data: []byte(e.SetName + "\x00")},
netlink.Attribute{Type: unix.NFTA_LOOKUP_SET_ID, Data: binaryutil.BigEndian.PutUint32(e.SetID)},