Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for nfqueue repeat-with-mark #6

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions nfqueue/nfqueue.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ const (

NF_DROP = 0
NF_ACCEPT = 1
NF_REPEAT = 4
)

type NFQPacket struct {
Expand Down Expand Up @@ -214,7 +215,18 @@ func (p *NFQPacket) Accept() error {
return p.verdict(NF_ACCEPT)
}

// Repeat sets the NF_REPEAT verdict on this packet with the given mark
func (p *NFQPacket) Repeat(mark uint32) error {
return p.verdictWithMark(NF_REPEAT, mark)
}

// verdict sends a NFQNL_MSG_VERDICT message for the packet id with the verdict value v
func (p *NFQPacket) verdict(v uint32) error {
return p.q.nfqRequestVerdictMark(v, p.id, false, 0).Send()
}

// verdictWithMark sends a NFQNL_MSG_VERDICT message for the packet id with the verdict value v,
// and the NFQA_MARK attribute with the given mark.
func (p *NFQPacket) verdictWithMark(v uint32, mark uint32) error {
return p.q.nfqRequestVerdictMark(v, p.id, true, mark).Send()
}