opration type
This commit is contained in:
parent
33734fa169
commit
62b241d6b7
|
@ -24,6 +24,7 @@ import (
|
|||
|
||||
type PayloadBase uint32
|
||||
type PayloadCsumType uint32
|
||||
type PayloadOperationType uint32
|
||||
|
||||
// Possible PayloadBase values.
|
||||
const (
|
||||
|
@ -38,7 +39,14 @@ const (
|
|||
CsumTypeInet PayloadCsumType = unix.NFT_PAYLOAD_CSUM_INET
|
||||
)
|
||||
|
||||
// Possible PayloadType values.
|
||||
const (
|
||||
PayloadLoad PayloadOperationType = iota
|
||||
PayloadWrite
|
||||
)
|
||||
|
||||
type Payload struct {
|
||||
OperationType PayloadOperationType
|
||||
DestRegister uint32
|
||||
SourceRegister uint32
|
||||
Base PayloadBase
|
||||
|
@ -53,7 +61,7 @@ func (e *Payload) marshal() ([]byte, error) {
|
|||
|
||||
var attrs []netlink.Attribute
|
||||
|
||||
if e.SourceRegister > 0 {
|
||||
if e.OperationType == PayloadWrite {
|
||||
attrs = []netlink.Attribute{
|
||||
{Type: unix.NFTA_PAYLOAD_SREG, Data: binaryutil.BigEndian.PutUint32(e.SourceRegister)},
|
||||
}
|
||||
|
|
|
@ -3962,6 +3962,7 @@ func TestStatelessNAT(t *testing.T) {
|
|||
},
|
||||
// [ payload write reg 1 => 4b @ network header + 16 csum_type 1 csum_off 10 csum_flags 0x1 ]
|
||||
&expr.Payload{
|
||||
OperationType: expr.PayloadWrite,
|
||||
SourceRegister: 1,
|
||||
Base: expr.PayloadBaseNetworkHeader,
|
||||
Offset: 16,
|
||||
|
|
Loading…
Reference in New Issue