1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
--- a/vendor/github.com/google/gopacket/pcap/pcap.go
+++ b/vendor/github.com/google/gopacket/pcap/pcap.go
@@ -170,7 +170,7 @@
// BPF is a compiled filter program, useful for offline packet matching.
type BPF struct {
orig string
- bpf _Ctype_struct_bpf_program // takes a finalizer, not overriden by outsiders
+ bpf C.struct_bpf_program // takes a finalizer, not overriden by outsiders
}
// BPFInstruction is a byte encoded structure holding a BPF instruction
@@ -381,7 +381,7 @@
// Stats returns statistics on the underlying pcap handle.
func (p *Handle) Stats() (stat *Stats, err error) {
- var cstats _Ctype_struct_pcap_stat
+ var cstats C.struct_pcap_stat
if -1 == C.pcap_stats(p.cptr, &cstats) {
return nil, p.Error()
}
@@ -418,7 +418,7 @@
return datalinks, nil
}
-func (p *Handle) compileBPFFilter(expr string) (_Ctype_struct_bpf_program, error) {
+func (p *Handle) compileBPFFilter(expr string) (C.struct_bpf_program, error) {
errorBuf := (*C.char)(C.calloc(errorBufferSize, 1))
defer C.free(unsafe.Pointer(errorBuf))
@@ -441,7 +441,7 @@
}
}
- var bpf _Ctype_struct_bpf_program
+ var bpf C.struct_bpf_program
cexpr := C.CString(expr)
defer C.free(unsafe.Pointer(cexpr))
@@ -459,7 +459,7 @@
return nil, err
}
- bpfInsn := (*[bpfInstructionBufferSize]_Ctype_struct_bpf_insn)(unsafe.Pointer(bpf.bf_insns))[0:bpf.bf_len:bpf.bf_len]
+ bpfInsn := (*[bpfInstructionBufferSize]C.struct_bpf_insn)(unsafe.Pointer(bpf.bf_insns))[0:bpf.bf_len:bpf.bf_len]
bpfInstruction := make([]BPFInstruction, len(bpfInsn), len(bpfInsn))
for i, v := range bpfInsn {
@@ -535,7 +535,7 @@
return nil
}
-func bpfInstructionFilter(bpfInstructions []BPFInstruction) (bpf _Ctype_struct_bpf_program, err error) {
+func bpfInstructionFilter(bpfInstructions []BPFInstruction) (bpf C.struct_bpf_program, err error) {
if len(bpfInstructions) < 1 {
return bpf, errors.New("bpfInstructions must not be empty")
}
@@ -548,7 +548,7 @@
cbpfInsns := C.calloc(C.size_t(len(bpfInstructions)), C.size_t(unsafe.Sizeof(bpfInstructions[0])))
copy((*[bpfInstructionBufferSize]BPFInstruction)(cbpfInsns)[0:len(bpfInstructions)], bpfInstructions)
- bpf.bf_insns = (*_Ctype_struct_bpf_insn)(cbpfInsns)
+ bpf.bf_insns = (*C.struct_bpf_insn)(cbpfInsns)
return
}
@@ -656,10 +656,10 @@
return
}
-func findalladdresses(addresses *_Ctype_struct_pcap_addr) (retval []InterfaceAddress) {
+func findalladdresses(addresses *C.struct_pcap_addr) (retval []InterfaceAddress) {
// TODO - make it support more than IPv4 and IPv6?
retval = make([]InterfaceAddress, 0, 1)
- for curaddr := addresses; curaddr != nil; curaddr = (*_Ctype_struct_pcap_addr)(curaddr.next) {
+ for curaddr := addresses; curaddr != nil; curaddr = (*C.struct_pcap_addr)(curaddr.next) {
// Strangely, it appears that in some cases, we get a pcap address back from
// pcap_findalldevs with a nil .addr. It appears that we can skip over
// these.
|