pf

package
v0.0.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 25, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PF_ANCHOR_NAME_SIZE = 64
	Pfioc_rulesetSize   = 1092
)
View Source
const IOCPARM_MASK uint32 = 0x1fff

https://github.com/apple/darwin-xnu/blob/0a798f6738bc1db01281fc08ae024145e84df927/bsd/sys/ioccom.h#L91

View Source
const IOC_GROUP_D = 68 // 'D'
View Source
const IOC_IN uint32 = 0x80000000
View Source
const IOC_INOUT uint32 = IOC_IN | IOC_OUT
View Source
const IOC_OUT uint32 = 0x40000000
View Source
const MAXPATHLEN = 1024
View Source
const (
	PF_OUT = 2
)
View Source
const Pfioc_natlookSize = 84
View Source
const Pfioc_pooladdrSize = 1136
View Source
const Pfioc_ruleSize = 3104

Variables

View Source
var (
	DIOCBEGINADDRS  uint32 = _IOC(IOC_INOUT, IOC_GROUP_D, 51, Pfioc_pooladdrSize)
	DIOCCHANGERULE  uint32 = _IOC(IOC_INOUT, IOC_GROUP_D, 26, Pfioc_ruleSize)
	DIOCNATLOOK     uint32 = _IOC(IOC_INOUT, IOC_GROUP_D, 23, Pfioc_natlookSize)
	DIOCGETRULESETS uint32 = _IOC(IOC_INOUT, IOC_GROUP_D, 58, Pfioc_rulesetSize)
	DIOCGETRULESET  uint32 = _IOC(IOC_INOUT, IOC_GROUP_D, 59, Pfioc_rulesetSize)
)

https://github.com/apple/darwin-xnu/blob/0a798f6738bc1db01281fc08ae024145e84df927/bsd/net/pfvar.h (also https://www.mirbsd.org/htman/i386/man4/pf.htm) (also https://www.qnx.com/developers/docs/6.4.1/neutrino/utilities/p/pf.html)

Functions

func Htonl

func Htonl(i uint32) uint32

func Htons

func Htons(i uint16) uint16

func Ntohl

func Ntohl(i uint32) uint32

func Ntohs

func Ntohs(i uint16) uint16

Types

type Action

type Action uint32
const (
	PF_CHANGE_ADD_TAIL   Action = 2
	PF_CHANGE_REMOVE     Action = 5
	PF_CHANGE_GET_TICKET Action = 6
)

type Ioctl

type Ioctl struct {
	// contains filtered or unexported fields
}

func NewIoctl

func NewIoctl(path string) (*Ioctl, error)

func (*Ioctl) Close

func (c *Ioctl) Close() error

func (*Ioctl) Read

func (c *Ioctl) Read(cmd uint32, ptr unsafe.Pointer) error

type LookUpNATOpts

type LookUpNATOpts struct {
	SrcIP   net.IP
	SrcPort int32
	DstIP   net.IP
	DstPort int32
}

type Pfctl

type Pfctl struct {
	// contains filtered or unexported fields
}

func NewPfctl

func NewPfctl() (*Pfctl, error)

func (*Pfctl) AddAnchorIfNotExist

func (p *Pfctl) AddAnchorIfNotExist(name string, ruleAction RuleAction) error

func (*Pfctl) Close

func (p *Pfctl) Close() error

func (*Pfctl) DeleteAnchorIfExists

func (p *Pfctl) DeleteAnchorIfExists(name string, ruleActions []RuleAction) error

func (*Pfctl) LookUpNAT

func (p *Pfctl) LookUpNAT(opts LookUpNATOpts) (net.IP, int, error)

type Pfioc_natlook

type Pfioc_natlook struct {
	// contains filtered or unexported fields
}

func (*Pfioc_natlook) GetIP

func (natlook *Pfioc_natlook) GetIP() net.IP

func (*Pfioc_natlook) GetPort

func (natlook *Pfioc_natlook) GetPort() int

func (*Pfioc_natlook) SetDstIP

func (natlook *Pfioc_natlook) SetDstIP(ip net.IP)

func (*Pfioc_natlook) SetDstPort

func (natlook *Pfioc_natlook) SetDstPort(port int32)

func (*Pfioc_natlook) SetSrcIP

func (natlook *Pfioc_natlook) SetSrcIP(ip net.IP)

func (*Pfioc_natlook) SetSrcPort

func (natlook *Pfioc_natlook) SetSrcPort(port int32)

type Pfioc_pooladdr

type Pfioc_pooladdr struct {
	Action   uint32
	Ticket   uint32
	Nr       uint32
	R_num    uint32
	R_action uint8
	R_last   uint8
	Af       uint8

	Padding__ [1117]byte // ...
}

type Pfioc_rule

type Pfioc_rule struct {
	Action      uint32 // type Action
	Ticket      uint32
	Pool_ticket uint32
	Nr          uint32
	Anchor      [MAXPATHLEN]byte
	Anchor_call [MAXPATHLEN]byte

	Padding__ [1040]byte // struct pf_rule rule;
}

func (*Pfioc_rule) SetAction

func (rule *Pfioc_rule) SetAction(action Action)

func (*Pfioc_rule) SetAnchor

func (rule *Pfioc_rule) SetAnchor(name string)

func (*Pfioc_rule) SetAnchorCall

func (rule *Pfioc_rule) SetAnchorCall(name string)

func (*Pfioc_rule) SetPoolTicket

func (rule *Pfioc_rule) SetPoolTicket(pooladdr Pfioc_pooladdr)

func (*Pfioc_rule) SetRuleAction

func (rule *Pfioc_rule) SetRuleAction(ruleAction RuleAction)

type Pfioc_ruleset

type Pfioc_ruleset struct {
	Nr   uint32
	Path [MAXPATHLEN]byte
	Name [PF_ANCHOR_NAME_SIZE]byte
}

func (Pfioc_ruleset) NameString

func (ruleset Pfioc_ruleset) NameString() string

type RuleAction

type RuleAction byte
const (
	PF_RDR  RuleAction = 8
	PF_PASS RuleAction = 0
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL