diff --git a/cmd/root.go b/cmd/root.go index 93a4791..fc09a96 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -173,13 +173,13 @@ type cliConfig struct { } type cliConfigIO struct { - QueueSize uint32 `mapstructure:"queueSize"` - QueueNum uint16 `mapstructure:"queueNum"` - Table string `mapstructure:"table"` - ReadBuffer int `mapstructure:"rcvBuf"` - WriteBuffer int `mapstructure:"sndBuf"` - Local bool `mapstructure:"local"` - RST bool `mapstructure:"rst"` + QueueSize uint32 `mapstructure:"queueSize"` + QueueNum *uint16 `mapstructure:"queueNum"` + Table string `mapstructure:"table"` + ReadBuffer int `mapstructure:"rcvBuf"` + WriteBuffer int `mapstructure:"sndBuf"` + Local bool `mapstructure:"local"` + RST bool `mapstructure:"rst"` } type cliConfigReplay struct { diff --git a/io/nfqueue.go b/io/nfqueue.go index eeca6d7..58c85c9 100644 --- a/io/nfqueue.go +++ b/io/nfqueue.go @@ -110,7 +110,7 @@ type nfqueuePacketIO struct { type NFQueuePacketIOConfig struct { QueueSize uint32 - QueueNum uint16 + QueueNum *uint16 Table string ReadBuffer int WriteBuffer int @@ -122,8 +122,9 @@ func NewNFQueuePacketIO(config NFQueuePacketIOConfig) (PacketIO, error) { if config.QueueSize == 0 { config.QueueSize = nfqueueDefaultQueueSize } - if config.QueueNum == 0 { - config.QueueNum = nfqueueDefaultQueueNum + if config.QueueNum == nil { + queueNum := uint16(nfqueueDefaultQueueNum) + config.QueueNum = &queueNum } if config.Table == "" { config.Table = nftDefaultTable @@ -142,7 +143,7 @@ func NewNFQueuePacketIO(config NFQueuePacketIOConfig) (PacketIO, error) { } } n, err := nfqueue.Open(&nfqueue.Config{ - NfQueue: config.QueueNum, + NfQueue: *config.QueueNum, MaxPacketLen: nfqueueMaxPacketLen, MaxQueueLen: config.QueueSize, Copymode: nfqueue.NfQnlCopyPacket, @@ -169,7 +170,7 @@ func NewNFQueuePacketIO(config NFQueuePacketIOConfig) (PacketIO, error) { n: n, local: config.Local, rst: config.RST, - queueNum: int(config.QueueNum), + queueNum: int(*config.QueueNum), table: config.Table, ipt4: ipt4, ipt6: ipt6,