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