1
0
mirror of https://github.com/golang/go synced 2024-11-21 19:24:45 -07:00

syscall: add BPF support for freebsd/386, freebsd/amd64

R=rsc
CC=golang-dev
https://golang.org/cl/4331050
This commit is contained in:
Mikio Hara 2011-04-04 15:40:40 -04:00 committed by Russ Cox
parent cc40870f4b
commit 5a59b9eba3
6 changed files with 2141 additions and 1599 deletions

View File

@ -60,6 +60,7 @@ includes_FreeBSD='
#include <sys/sockio.h>
#include <sys/sysctl.h>
#include <sys/wait.h>
#include <net/bpf.h>
#include <net/if.h>
#include <net/route.h>
#include <netinet/in.h>
@ -118,7 +119,7 @@ done
$2 ~ /^E[A-Z0-9_]+$/ ||
$2 ~ /^SIG[^_]/ ||
$2 ~ /^IN_/ ||
$2 ~ /^(AF|SOCK|SO|SOL|IPPROTO|IP|IPV6|TCP|EVFILT|EV|SHUT|PROT|MAP|PACKET|MSG|SCM|IFF|NET_RT|RTM|RTF|RTV|RTA|RTAX|MCL)_/ ||
$2 ~ /^(AF|SOCK|SO|SOL|IPPROTO|IP|IPV6|TCP|EVFILT|EV|SHUT|PROT|MAP|PACKET|MSG|SCM|MCL)_/ ||
$2 == "SOMAXCONN" ||
$2 == "NAME_MAX" ||
$2 == "IFNAMSIZ" ||
@ -130,6 +131,9 @@ done
$2 ~ /^LINUX_REBOOT_CMD_/ ||
$2 ~ /^LINUX_REBOOT_MAGIC[12]$/ ||
$2 ~ /^SIOC/ ||
$2 ~ /^(IFF|NET_RT|RTM|RTF|RTV|RTA|RTAX)_/ ||
$2 ~ /^BIOC/ ||
$2 ~ /^(BPF|DLT)_/ ||
$2 !~ "WMESGLEN" &&
$2 ~ /^W[A-Z0-9]+$/ {printf("\t$%s = %s,\n", $2, $2)}
$2 ~ /^__WCOREFLAG$/ {next}

View File

@ -26,6 +26,7 @@ Input to godefs. See also mkerrors.sh and mkall.sh
#include <sys/types.h>
#include <sys/un.h>
#include <sys/wait.h>
#include <net/bpf.h>
#include <net/if.h>
#include <net/if_dl.h>
#include <net/route.h>
@ -167,3 +168,23 @@ typedef struct if_data $IfData;
typedef struct ifa_msghdr $IfaMsghdr;
typedef struct rt_msghdr $RtMsghdr;
typedef struct rt_metrics $RtMetrics;
// Berkeley packet filter
enum {
$SizeofBpfVersion = sizeof(struct bpf_version),
$SizeofBpfStat = sizeof(struct bpf_stat),
$SizeofBpfZbuf = sizeof(struct bpf_zbuf),
$SizeofBpfProgram = sizeof(struct bpf_program),
$SizeofBpfInsn = sizeof(struct bpf_insn),
$SizeofBpfHdr = sizeof(struct bpf_hdr),
$SizeofBpfZbufHeader = sizeof(struct bpf_zbuf_header),
};
typedef struct bpf_version $BpfVersion;
typedef struct bpf_stat $BpfStat;
typedef struct bpf_zbuf $BpfZbuf;
typedef struct bpf_program $BpfProgram;
typedef struct bpf_insn $BpfInsn;
typedef struct bpf_hdr $BpfHdr;
typedef struct bpf_zbuf_header $BpfZbufHeader;

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -43,6 +43,13 @@ const (
SizeofIfaMsghdr = 0x14
SizeofRtMsghdr = 0x5c
SizeofRtMetrics = 0x38
SizeofBpfVersion = 0x4
SizeofBpfStat = 0x8
SizeofBpfZbuf = 0xc
SizeofBpfProgram = 0x8
SizeofBpfInsn = 0x8
SizeofBpfHdr = 0x14
SizeofBpfZbufHeader = 0x20
)
// Types
@ -326,3 +333,46 @@ type RtMetrics struct {
Weight uint32
Filler [3]uint32
}
type BpfVersion struct {
Major uint16
Minor uint16
}
type BpfStat struct {
Recv uint32
Drop uint32
}
type BpfZbuf struct {
Bufa *byte
Bufb *byte
Buflen uint32
}
type BpfProgram struct {
Len uint32
Insns *BpfInsn
}
type BpfInsn struct {
Code uint16
Jt uint8
Jf uint8
K uint32
}
type BpfHdr struct {
Tstamp Timeval
Caplen uint32
Datalen uint32
Hdrlen uint16
Pad_godefs_0 [2]byte
}
type BpfZbufHeader struct {
Kernel_gen uint32
Kernel_len uint32
User_gen uint32
X_bzh_pad [5]uint32
}

View File

@ -43,6 +43,13 @@ const (
SizeofIfaMsghdr = 0x14
SizeofRtMsghdr = 0x98
SizeofRtMetrics = 0x70
SizeofBpfVersion = 0x4
SizeofBpfStat = 0x8
SizeofBpfZbuf = 0x18
SizeofBpfProgram = 0x10
SizeofBpfInsn = 0x8
SizeofBpfHdr = 0x20
SizeofBpfZbufHeader = 0x20
)
// Types
@ -329,3 +336,47 @@ type RtMetrics struct {
Weight uint64
Filler [3]uint64
}
type BpfVersion struct {
Major uint16
Minor uint16
}
type BpfStat struct {
Recv uint32
Drop uint32
}
type BpfZbuf struct {
Bufa *byte
Bufb *byte
Buflen uint64
}
type BpfProgram struct {
Len uint32
Pad_godefs_0 [4]byte
Insns *BpfInsn
}
type BpfInsn struct {
Code uint16
Jt uint8
Jf uint8
K uint32
}
type BpfHdr struct {
Tstamp Timeval
Caplen uint32
Datalen uint32
Hdrlen uint16
Pad_godefs_0 [6]byte
}
type BpfZbufHeader struct {
Kernel_gen uint32
Kernel_len uint32
User_gen uint32
X_bzh_pad [5]uint32
}