Showing preview only (3,931K chars total). Download the full file or copy to clipboard to get everything.
Repository: google/gopacket
Branch: master
Commit: b7d9dbd15ae4
Files: 298
Total size: 3.7 MB
Directory structure:
gitextract_4ywj3pz3/
├── .gitignore
├── .travis.gofmt.sh
├── .travis.golint.sh
├── .travis.govet.sh
├── .travis.install.sh
├── .travis.script.sh
├── .travis.yml
├── AUTHORS
├── CONTRIBUTING.md
├── LICENSE
├── README.md
├── afpacket/
│ ├── afpacket.go
│ ├── afpacket_test.go
│ ├── header.go
│ ├── options.go
│ └── sockopt_linux.go
├── base.go
├── benchmark_test.go
├── bsdbpf/
│ └── bsd_bpf_sniffer.go
├── bytediff/
│ ├── bytediff.go
│ └── bytediff_test.go
├── decode.go
├── defrag/
│ └── lcmdefrag/
│ ├── lcmdefrag.go
│ └── lcmdefrag_test.go
├── doc.go
├── dumpcommand/
│ └── tcpdump.go
├── examples/
│ ├── afpacket/
│ │ └── afpacket.go
│ ├── arpscan/
│ │ └── arpscan.go
│ ├── bidirectional/
│ │ └── main.go
│ ├── bytediff/
│ │ └── main.go
│ ├── httpassembly/
│ │ └── main.go
│ ├── pcapdump/
│ │ └── main.go
│ ├── pcaplay/
│ │ └── main.go
│ ├── pfdump/
│ │ └── main.go
│ ├── reassemblydump/
│ │ ├── compare.sh
│ │ └── main.go
│ ├── snoopread/
│ │ └── main.go
│ ├── statsassembly/
│ │ └── main.go
│ ├── synscan/
│ │ └── main.go
│ └── util/
│ └── util.go
├── flows.go
├── gc
├── gen.go
├── go.mod
├── go.sum
├── ip4defrag/
│ ├── defrag.go
│ └── defrag_test.go
├── layerclass.go
├── layers/
│ ├── .lint_blacklist
│ ├── ague_var0.go
│ ├── ague_var0_test.go
│ ├── ague_var1.go
│ ├── ague_var1_test.go
│ ├── apsp.go
│ ├── apsp_test.go
│ ├── arp.go
│ ├── asf.go
│ ├── asf_presencepong.go
│ ├── asf_presencepong_test.go
│ ├── asf_test.go
│ ├── base.go
│ ├── base_test.go
│ ├── bfd.go
│ ├── bfd_test.go
│ ├── bitfield.go
│ ├── bitfield_test.go
│ ├── cdp.go
│ ├── ctp.go
│ ├── decode_test.go
│ ├── dhcp_test.go
│ ├── dhcpv4.go
│ ├── dhcpv6.go
│ ├── dhcpv6_options.go
│ ├── dhcpv6_test.go
│ ├── dns.go
│ ├── dns_test.go
│ ├── doc.go
│ ├── dot11.go
│ ├── dot11_test.go
│ ├── dot1q.go
│ ├── dot1q_test.go
│ ├── eap.go
│ ├── eapol.go
│ ├── eapol_test.go
│ ├── endpoints.go
│ ├── endpoints_test.go
│ ├── enums.go
│ ├── enums_generated.go
│ ├── erspan2.go
│ ├── erspan2_test.go
│ ├── etherip.go
│ ├── ethernet.go
│ ├── fddi.go
│ ├── fuzz_layer.go
│ ├── gen.go
│ ├── gen2.go
│ ├── gen_linted.sh
│ ├── geneve.go
│ ├── geneve_test.go
│ ├── gre.go
│ ├── gre_test.go
│ ├── gtp.go
│ ├── gtp_test.go
│ ├── iana_ports.go
│ ├── icmp4.go
│ ├── icmp6.go
│ ├── icmp6NDflags_test.go
│ ├── icmp6_test.go
│ ├── icmp6hopbyhop_test.go
│ ├── icmp6msg.go
│ ├── icmp6msg_test.go
│ ├── igmp.go
│ ├── igmp_test.go
│ ├── ip4.go
│ ├── ip4_test.go
│ ├── ip6.go
│ ├── ip6_test.go
│ ├── ipsec.go
│ ├── ipsec_test.go
│ ├── layertypes.go
│ ├── lcm.go
│ ├── lcm_test.go
│ ├── linux_sll.go
│ ├── llc.go
│ ├── lldp.go
│ ├── lldp_test.go
│ ├── loopback.go
│ ├── mldv1.go
│ ├── mldv1_test.go
│ ├── mldv2.go
│ ├── mldv2_test.go
│ ├── modbustcp.go
│ ├── mpls.go
│ ├── mpls_test.go
│ ├── ndp.go
│ ├── ntp.go
│ ├── ntp_test.go
│ ├── ospf.go
│ ├── ospf_test.go
│ ├── pflog.go
│ ├── ports.go
│ ├── ppp.go
│ ├── pppoe.go
│ ├── prism.go
│ ├── prism_test.go
│ ├── radiotap.go
│ ├── radiotap_test.go
│ ├── radius.go
│ ├── radius_test.go
│ ├── rmcp.go
│ ├── rmcp_test.go
│ ├── rudp.go
│ ├── sctp.go
│ ├── sflow.go
│ ├── sflow_test.go
│ ├── sip.go
│ ├── sip_test.go
│ ├── stp.go
│ ├── stp_test.go
│ ├── tcp.go
│ ├── tcp_test.go
│ ├── tcpip.go
│ ├── tcpip_test.go
│ ├── test_creator.py
│ ├── testdata/
│ │ └── fuzz/
│ │ └── FuzzDecodeFromBytes/
│ │ ├── 27d23183d8ce7b719228870c23869cf21bf8829d7160c82da88f80aeff2d861c
│ │ ├── 3b53f220d321f20980b59f64e1617d6b334b152a90b141a7407c3c8fa4837a31
│ │ ├── f539b7a397cf68c2129abd63d4c7cfb1979c489ad9bad6898510a4d4759bb85f
│ │ └── fe20300d6b2057b406a06ec4f04065f6d0dda6b2b362c0a89192c1933e927adf
│ ├── tls.go
│ ├── tls_alert.go
│ ├── tls_appdata.go
│ ├── tls_cipherspec.go
│ ├── tls_handshake.go
│ ├── tls_test.go
│ ├── udp.go
│ ├── udp_test.go
│ ├── udplite.go
│ ├── usb.go
│ ├── usb_test.go
│ ├── vrrp.go
│ ├── vrrp_test.go
│ ├── vxlan.go
│ └── vxlan_test.go
├── layers_decoder.go
├── layertype.go
├── macs/
│ ├── benchmark_test.go
│ ├── doc.go
│ ├── gen.go
│ └── valid_mac_prefixes.go
├── packet.go
├── packet_test.go
├── parser.go
├── pcap/
│ ├── bpf_test.go
│ ├── defs_windows_386.go
│ ├── defs_windows_amd64.go
│ ├── doc.go
│ ├── generate_defs.go
│ ├── gopacket_benchmark/
│ │ └── benchmark.go
│ ├── pcap.go
│ ├── pcap_test.go
│ ├── pcap_tester.go
│ ├── pcap_unix.go
│ ├── pcap_windows.go
│ ├── pcapgo_test.go
│ ├── pcapnggo_test.go
│ ├── test_dns.pcap
│ ├── test_ethernet.pcap
│ └── test_loopback.pcap
├── pcapgo/
│ ├── capture.go
│ ├── capture_test.go
│ ├── doc.go
│ ├── ngread.go
│ ├── ngread_test.go
│ ├── ngwrite.go
│ ├── ngwrite_test.go
│ ├── pcapng.go
│ ├── read.go
│ ├── read_test.go
│ ├── snoop.go
│ ├── snoop_test.go
│ ├── tests/
│ │ ├── README.md
│ │ ├── be/
│ │ │ ├── test001.pcapng
│ │ │ ├── test002.pcapng
│ │ │ ├── test003.pcapng
│ │ │ ├── test004.pcapng
│ │ │ ├── test005.pcapng
│ │ │ ├── test006.pcapng
│ │ │ ├── test007.pcapng
│ │ │ ├── test008.pcapng
│ │ │ ├── test009.pcapng
│ │ │ ├── test010.pcapng
│ │ │ ├── test011.pcapng
│ │ │ ├── test012.pcapng
│ │ │ ├── test013.pcapng
│ │ │ ├── test014.pcapng
│ │ │ ├── test015.pcapng
│ │ │ ├── test016.pcapng
│ │ │ ├── test017.pcapng
│ │ │ ├── test018.pcapng
│ │ │ ├── test100.pcapng
│ │ │ ├── test101.pcapng
│ │ │ ├── test102.pcapng
│ │ │ ├── test200.pcapng
│ │ │ ├── test201.pcapng
│ │ │ ├── test202.pcapng
│ │ │ ├── test901.pcapng
│ │ │ └── test902.pcapng
│ │ ├── le/
│ │ │ ├── test001.pcapng
│ │ │ ├── test002.pcapng
│ │ │ ├── test003.pcapng
│ │ │ ├── test004.pcapng
│ │ │ ├── test005.pcapng
│ │ │ ├── test006.pcapng
│ │ │ ├── test007.pcapng
│ │ │ ├── test008.pcapng
│ │ │ ├── test009.pcapng
│ │ │ ├── test010.pcapng
│ │ │ ├── test011.pcapng
│ │ │ ├── test012.pcapng
│ │ │ ├── test013.pcapng
│ │ │ ├── test014.pcapng
│ │ │ ├── test015.pcapng
│ │ │ ├── test016.pcapng
│ │ │ ├── test017.pcapng
│ │ │ ├── test018.pcapng
│ │ │ ├── test100.pcapng
│ │ │ ├── test101.pcapng
│ │ │ ├── test102.pcapng
│ │ │ ├── test200.pcapng
│ │ │ ├── test201.pcapng
│ │ │ ├── test202.pcapng
│ │ │ ├── test901.pcapng
│ │ │ └── test902.pcapng
│ │ ├── test901.lua
│ │ └── test902.lua
│ ├── write.go
│ └── write_test.go
├── pfring/
│ ├── doc.go
│ ├── pfring.go
│ └── pfring_test.go
├── reassembly/
│ ├── cap2test.go
│ ├── memory.go
│ ├── tcpassembly.go
│ ├── tcpassembly_test.go
│ ├── tcpcheck.go
│ └── tcpcheck_test.go
├── routing/
│ ├── common.go
│ ├── other.go
│ ├── routing.go
│ └── routing_test.go
├── tcpassembly/
│ ├── assembly.go
│ ├── assembly_test.go
│ └── tcpreader/
│ ├── reader.go
│ └── reader_test.go
├── time.go
├── time_test.go
├── writer.go
└── writer_test.go
================================================
FILE CONTENTS
================================================
================================================
FILE: .gitignore
================================================
# Compiled Object files, Static and Dynamic libs (Shared Objects)
*.o
*.a
*.so
# Folders
_obj
_test
# Architecture specific extensions/prefixes
*.[568vq]
[568vq].out
*.cgo1.go
*.cgo2.c
_cgo_defun.c
_cgo_gotypes.go
_cgo_export.*
_testmain.go
*.exe
#*
*~
# examples binaries
examples/synscan/synscan
examples/pfdump/pfdump
examples/pcapdump/pcapdump
examples/httpassembly/httpassembly
examples/statsassembly/statsassembly
examples/arpscan/arpscan
examples/bidirectional/bidirectional
examples/bytediff/bytediff
examples/reassemblydump/reassemblydump
layers/gen
macs/gen
pcap/pcap_tester
================================================
FILE: .travis.gofmt.sh
================================================
#!/bin/bash
cd "$(dirname $0)"
if [ -n "$(go fmt ./...)" ]; then
echo "Go code is not formatted, run 'go fmt github.com/google/stenographer/...'" >&2
exit 1
fi
================================================
FILE: .travis.golint.sh
================================================
#!/bin/bash
cd "$(dirname $0)"
go get golang.org/x/lint/golint
DIRS=". tcpassembly tcpassembly/tcpreader ip4defrag reassembly macs pcapgo pcap afpacket pfring routing defrag/lcmdefrag"
# Add subdirectories here as we clean up golint on each.
for subdir in $DIRS; do
pushd $subdir
if golint |
grep -v CannotSetRFMon | # pcap exported error name
grep -v DataLost | # tcpassembly/tcpreader exported error name
grep .; then
exit 1
fi
popd
done
pushd layers
for file in *.go; do
if cat .lint_blacklist | grep -q $file; then
echo "Skipping lint of $file due to .lint_blacklist"
elif golint $file | grep .; then
echo "Lint error in file $file"
exit 1
fi
done
popd
================================================
FILE: .travis.govet.sh
================================================
#!/bin/bash
cd "$(dirname $0)"
DIRS=". layers pcap pcapgo tcpassembly tcpassembly/tcpreader routing ip4defrag bytediff macs defrag/lcmdefrag"
set -e
for subdir in $DIRS; do
pushd $subdir
go vet
popd
done
================================================
FILE: .travis.install.sh
================================================
#!/bin/bash
set -ev
go get github.com/google/gopacket
go get github.com/google/gopacket/layers
go get github.com/google/gopacket/tcpassembly
go get github.com/google/gopacket/reassembly
go get github.com/google/gopacket/pcapgo
================================================
FILE: .travis.script.sh
================================================
#!/bin/bash
set -ev
go test github.com/google/gopacket
go test github.com/google/gopacket/layers
go test github.com/google/gopacket/tcpassembly
go test github.com/google/gopacket/reassembly
go test github.com/google/gopacket/pcapgo
go test github.com/google/gopacket/pcap
sudo $(which go) test github.com/google/gopacket/routing
================================================
FILE: .travis.yml
================================================
language: go
go:
- 1.11.x
- 1.12.x
- 1.13.x
- master
addons:
apt:
packages:
libpcap-dev
# use modules except for older versions (see below)
install: true
env:
- GO111MODULE=on
script: ./.travis.script.sh
matrix:
fast_finish: true
allow_failures:
- go: master
jobs:
include:
- go: 1.5.x
install: ./.travis.install.sh
- go: 1.6.x
install: ./.travis.install.sh
- go: 1.7.x
install: ./.travis.install.sh
- go: 1.8.x
install: ./.travis.install.sh
- go: 1.9.x
install: ./.travis.install.sh
- go: 1.10.x
install: ./.travis.install.sh
- os: osx
go: 1.x
# windows doesn't work on travis (package installation just hangs and then errors out)
# - os: windows
# go: 1.x
# # We don't need nmap - but that's the only way to get npcap:
# before_install: choco install npcap --version 0.86 -y
- stage: style
name: "fmt/vet/lint"
go: 1.x
script:
- ./.travis.gofmt.sh
- ./.travis.govet.sh
- ./.travis.golint.sh
stages:
- style
- test
================================================
FILE: AUTHORS
================================================
AUTHORS AND MAINTAINERS:
MAIN DEVELOPERS:
Graeme Connell <gconnell@google.com, gsconnell@gmail.com>
AUTHORS:
Nigel Tao <nigeltao@google.com>
Cole Mickens <cole.mickens@gmail.com>
Ben Daglish <bdaglish@restorepoint.com>
Luis Martinez <martinezlc99@gmail.com>
Remco Verhoef <remco@dutchcoders.io>
Hiroaki Kawai <Hiroaki.Kawai@gmail.com>
Lukas Lueg <lukas.lueg@gmail.com>
Laurent Hausermann <laurent.hausermann@gmail.com>
Bill Green <bgreen@newrelic.com>
Christian Mäder <christian.maeder@nine.ch>
Gernot Vormayr <gvormayr@gmail.com>
Vitor Garcia Graveto <victor.graveto@gmail.com>
Elias Chavarria Reyes <elchavar@cisco.com>
Daniel Rittweiler <ripx80@protonmail.com>
CONTRIBUTORS:
Attila Oláh <attila@attilaolah.eu>
Vittus Mikiassen <matt.miki.vimik@gmail.com>
Matthias Radestock <matthias.radestock@gmail.com>
Matthew Sackman <matthew@wellquite.org>
Loic Prylli <loicp@google.com>
Alexandre Fiori <fiorix@gmail.com>
Adrian Tam <adrian.c.m.tam@gmail.com>
Satoshi Matsumoto <kaorimatz@gmail.com>
David Stainton <dstainton415@gmail.com>
Jesse Ward <jesse@jesseward.com>
Kane Mathers <kane@kanemathers.name>
Jose Selvi <jselvi@pentester.es>
Yerden Zhumabekov <yerden.zhumabekov@gmail.com>
Jensen Hwa <jensenhwa@gmail.com>
-----------------------------------------------
FORKED FROM github.com/akrennmair/gopcap
ALL THE FOLLOWING ARE FOR THAT PROJECT
MAIN DEVELOPERS:
Andreas Krennmair <ak@synflood.at>
CONTRIBUTORS:
Andrea Nall <anall@andreanall.com>
Daniel Arndt <danielarndt@gmail.com>
Dustin Sallings <dustin@spy.net>
Graeme Connell <gconnell@google.com, gsconnell@gmail.com>
Guillaume Savary <guillaume@savary.name>
Mark Smith <mark@qq.is>
Miek Gieben <miek@miek.nl>
Mike Bell <mike@mikebell.org>
Trevor Strohman <strohman@google.com>
================================================
FILE: CONTRIBUTING.md
================================================
Contributing To gopacket
========================
So you've got some code and you'd like it to be part of gopacket... wonderful!
We're happy to accept contributions, whether they're fixes to old protocols, new
protocols entirely, or anything else you think would improve the gopacket
library. This document is designed to help you to do just that.
The first section deals with the plumbing: how to actually get a change
submitted.
The second section deals with coding style... Go is great in that it
has a uniform style implemented by 'go fmt', but there's still some decisions
we've made that go above and beyond, and if you follow them, they won't come up
in your code review.
The third section deals with some of the implementation decisions we've made,
which may help you to understand the current code and which we may ask you to
conform to (or provide compelling reasons for ignoring).
Overall, we hope this document will help you to understand our system and write
great code which fits in, and help us to turn around on your code review quickly
so the code can make it into the master branch as quickly as possible.
How To Submit Code
------------------
We use github.com's Pull Request feature to receive code contributions from
external contributors. See
https://help.github.com/articles/creating-a-pull-request/ for details on
how to create a request.
Also, there's a local script `gc` in the base directory of GoPacket that
runs a local set of checks, which should give you relatively high confidence
that your pull won't fail github pull checks.
```sh
go get github.com/google/gopacket
cd $GOROOT/src/pkg/github.com/google/gopacket
git checkout -b <mynewfeature> # create a new branch to work from
... code code code ...
./gc # Run this to do local commits, it performs a number of checks
```
To sum up:
* DO
+ Pull down the latest version.
+ Make a feature-specific branch.
+ Code using the style and methods discussed in the rest of this document.
+ Use the ./gc command to do local commits or check correctness.
+ Push your new feature branch up to github.com, as a pull request.
+ Handle comments and requests from reviewers, pushing new commits up to
your feature branch as problems are addressed.
+ Put interesting comments and discussions into commit comments.
* DON'T
+ Push to someone else's branch without their permission.
Coding Style
------------
* Go code must be run through `go fmt`, `go vet`, and `golint`
* Follow http://golang.org/doc/effective_go.html as much as possible.
+ In particular, http://golang.org/doc/effective_go.html#mixed-caps. Enums
should be be CamelCase, with acronyms capitalized (TCPSourcePort, vs.
TcpSourcePort or TCP_SOURCE_PORT).
* Bonus points for giving enum types a String() field.
* Any exported types or functions should have commentary
(http://golang.org/doc/effective_go.html#commentary)
Coding Methods And Implementation Notes
---------------------------------------
### Error Handling
Many times, you'll be decoding a protocol and run across something bad, a packet
corruption or the like. How do you handle this? First off, ALWAYS report the
error. You can do this either by returning the error from the decode() function
(most common), or if you're up for it you can implement and add an ErrorLayer
through the packet builder (the first method is a simple shortcut that does
exactly this, then stops any future decoding).
Often, you'll already have decode some part of your protocol by the time you hit
your error. Use your own discretion to determine whether the stuff you've
already decoded should be returned to the caller or not:
```go
func decodeMyProtocol(data []byte, p gopacket.PacketBuilder) error {
prot := &MyProtocol{}
if len(data) < 10 {
// This error occurred before we did ANYTHING, so there's nothing in my
// protocol that the caller could possibly want. Just return the error.
return fmt.Errorf("Length %d less than 10", len(data))
}
prot.ImportantField1 = data[:5]
prot.ImportantField2 = data[5:10]
// At this point, we've already got enough information in 'prot' to
// warrant returning it to the caller, so we'll add it now.
p.AddLayer(prot)
if len(data) < 15 {
// We encountered an error later in the packet, but the caller already
// has the important info we've gleaned so far.
return fmt.Errorf("Length %d less than 15", len(data))
}
prot.ImportantField3 = data[10:15]
return nil // We've already added the layer, we can just return success.
}
```
In general, our code follows the approach of returning the first error it
encounters. In general, we don't trust any bytes after the first error we see.
### What Is A Layer?
The definition of a layer is up to the discretion of the coder. It should be
something important enough that it's actually useful to the caller (IE: every
TLV value should probably NOT be a layer). However, it can be more granular
than a single protocol... IPv6 and SCTP both implement many layers to handle the
various parts of the protocol. Use your best judgement, and prepare to defend
your decisions during code review. ;)
### Performance
We strive to make gopacket as fast as possible while still providing lots of
features. In general, this means:
* Focus performance tuning on common protocols (IP4/6, TCP, etc), and optimize
others on an as-needed basis (tons of MPLS on your network? Time to optimize
MPLS!)
* Use fast operations. See the toplevel benchmark_test for benchmarks of some
of Go's underlying features and types.
* Test your performance changes! You should use the ./gc script's --benchmark
flag to submit any performance-related changes. Use pcap/gopacket_benchmark
to test your change against a PCAP file based on your traffic patterns.
* Don't be TOO hacky. Sometimes, removing an unused struct from a field causes
a huge performance hit, due to the way that Go currently handles its segmented
stack... don't be afraid to clean it up anyway. We'll trust the Go compiler
to get good enough over time to handle this. Also, this type of
compiler-specific optimization is very fragile; someone adding a field to an
entirely different struct elsewhere in the codebase could reverse any gains
you might achieve by aligning your allocations.
* Try to minimize memory allocations. If possible, use []byte to reference
pieces of the input, instead of using string, which requires copying the bytes
into a new memory allocation.
* Think hard about what should be evaluated lazily vs. not. In general, a
layer's struct should almost exactly mirror the layer's frame. Anything
that's more interesting should be a function. This may not always be
possible, but it's a good rule of thumb.
* Don't fear micro-optimizations. With the above in mind, we welcome
micro-optimizations that we think will have positive/neutral impacts on the
majority of workloads. A prime example of this is pre-allocating certain
structs within a larger one:
```go
type MyProtocol struct {
// Most packets have 1-4 of VeryCommon, so we preallocate it here.
initialAllocation [4]uint32
VeryCommon []uint32
}
func decodeMyProtocol(data []byte, p gopacket.PacketBuilder) error {
prot := &MyProtocol{}
prot.VeryCommon = proto.initialAllocation[:0]
for len(data) > 4 {
field := binary.BigEndian.Uint32(data[:4])
data = data[4:]
// Since we're using the underlying initialAllocation, we won't need to
// allocate new memory for the following append unless we more than 16
// bytes of data, which should be the uncommon case.
prot.VeryCommon = append(prot.VeryCommon, field)
}
p.AddLayer(prot)
if len(data) > 0 {
return fmt.Errorf("MyProtocol packet has %d bytes left after decoding", len(data))
}
return nil
}
```
### Slices And Data
If you're pulling a slice from the data you're decoding, don't copy it. Just
use the slice itself.
```go
type MyProtocol struct {
A, B net.IP
}
func decodeMyProtocol(data []byte, p gopacket.PacketBuilder) error {
p.AddLayer(&MyProtocol{
A: data[:4],
B: data[4:8],
})
return nil
}
```
The caller has already agreed, by using this library, that they won't modify the
set of bytes they pass in to the decoder, or the library has already copied the
set of bytes to a read-only location. See DecodeOptions.NoCopy for more
information.
### Enums/Types
If a protocol has an integer field (uint8, uint16, etc) with a couple of known
values that mean something special, make it a type. This allows us to do really
nice things like adding a String() function to them, so we can more easily
display those to users. Check out layers/enums.go for one example, as well as
layers/icmp.go for layer-specific enums.
When naming things, try for descriptiveness over suscinctness. For example,
choose DNSResponseRecord over DNSRR.
================================================
FILE: LICENSE
================================================
Copyright (c) 2012 Google, Inc. All rights reserved.
Copyright (c) 2009-2011 Andreas Krennmair. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
* Neither the name of Andreas Krennmair, Google, nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
================================================
FILE: README.md
================================================
# GoPacket
This library provides packet decoding capabilities for Go.
See [godoc](https://godoc.org/github.com/google/gopacket) for more details.
[](https://travis-ci.org/google/gopacket)
[](https://godoc.org/github.com/google/gopacket)
Minimum Go version required is 1.5 except for pcapgo/EthernetHandle, afpacket, and bsdbpf which need at least 1.9 due to x/sys/unix dependencies.
Originally forked from the gopcap project written by Andreas
Krennmair <ak@synflood.at> (http://github.com/akrennmair/gopcap).
================================================
FILE: afpacket/afpacket.go
================================================
// Copyright 2012 Google, Inc. All rights reserved.
//
// Use of this source code is governed by a BSD-style license
// that can be found in the LICENSE file in the root of the source
// tree.
//go:build linux
// +build linux
// Package afpacket provides Go bindings for MMap'd AF_PACKET socket reading.
package afpacket
// Couldn't have done this without:
// http://lxr.free-electrons.com/source/Documentation/networking/packet_mmap.txt
// http://codemonkeytips.blogspot.co.uk/2011/07/asynchronous-packet-socket-reading-with.html
import (
"errors"
"fmt"
"net"
"runtime"
"sync"
"sync/atomic"
"syscall"
"time"
"unsafe"
"golang.org/x/net/bpf"
"golang.org/x/sys/unix"
"github.com/google/gopacket"
)
/*
#include <linux/if_packet.h> // AF_PACKET, sockaddr_ll
#include <linux/if_ether.h> // ETH_P_ALL
#include <sys/socket.h> // socket()
#include <unistd.h> // close()
#include <arpa/inet.h> // htons()
#include <sys/mman.h> // mmap(), munmap()
#include <poll.h> // poll()
*/
import "C"
var pageSize = unix.Getpagesize()
// ErrPoll returned by poll
var ErrPoll = errors.New("packet poll failed")
// ErrTimeout returned on poll timeout
var ErrTimeout = errors.New("packet poll timeout expired")
// AncillaryVLAN structures are used to pass the captured VLAN
// as ancillary data via CaptureInfo.
type AncillaryVLAN struct {
// The VLAN VID provided by the kernel.
VLAN int
}
// Stats is a set of counters detailing the work TPacket has done so far.
type Stats struct {
// Packets is the total number of packets returned to the caller.
Packets int64
// Polls is the number of blocking syscalls made waiting for packets.
// This should always be <= Packets, since with TPacket one syscall
// can (and often does) return many results.
Polls int64
}
// SocketStats is a struct where socket stats are stored
type SocketStats C.struct_tpacket_stats
// Packets returns the number of packets seen by this socket.
func (s *SocketStats) Packets() uint {
return uint(s.tp_packets)
}
// Drops returns the number of packets dropped on this socket.
func (s *SocketStats) Drops() uint {
return uint(s.tp_drops)
}
// SocketStatsV3 is a struct where socket stats for TPacketV3 are stored
type SocketStatsV3 C.struct_tpacket_stats_v3
// Packets returns the number of packets seen by this socket.
func (s *SocketStatsV3) Packets() uint {
return uint(s.tp_packets)
}
// Drops returns the number of packets dropped on this socket.
func (s *SocketStatsV3) Drops() uint {
return uint(s.tp_drops)
}
// QueueFreezes returns the number of queue freezes on this socket.
func (s *SocketStatsV3) QueueFreezes() uint {
return uint(s.tp_freeze_q_cnt)
}
// TPacket implements packet receiving for Linux AF_PACKET versions 1, 2, and 3.
type TPacket struct {
// stats is simple statistics on TPacket's run. This MUST be the first entry to ensure alignment for sync.atomic
stats Stats
// fd is the C file descriptor.
fd int
// ring points to the memory space of the ring buffer shared by tpacket and the kernel.
ring []byte
// rawring is the unsafe pointer that we use to poll for packets
rawring unsafe.Pointer
// opts contains read-only options for the TPacket object.
opts options
mu sync.Mutex // guards below
// offset is the offset into the ring of the current header.
offset int
// current is the current header.
current header
// shouldReleasePacket is set to true whenever we return packet data, to make sure we remember to release that data back to the kernel.
shouldReleasePacket bool
// headerNextNeeded is set to true when header need to move to the next packet. No need to move it case of poll error.
headerNextNeeded bool
// tpVersion is the version of TPacket actually in use, set by setRequestedTPacketVersion.
tpVersion OptTPacketVersion
// Hackity hack hack hack. We need to return a pointer to the header with
// getTPacketHeader, and we don't want to allocate a v3wrapper every time,
// so we leave it in the TPacket object and return a pointer to it.
v3 v3wrapper
statsMu sync.Mutex // guards stats below
// socketStats contains stats from the socket
socketStats SocketStats
// same as socketStats, but with an extra field freeze_q_cnt
socketStatsV3 SocketStatsV3
}
var _ gopacket.ZeroCopyPacketDataSource = &TPacket{}
// bindToInterface binds the TPacket socket to a particular named interface.
func (h *TPacket) bindToInterface(ifaceName string) error {
ifIndex := 0
// An empty string here means to listen to all interfaces
if ifaceName != "" {
iface, err := net.InterfaceByName(ifaceName)
if err != nil {
return fmt.Errorf("InterfaceByName: %v", err)
}
ifIndex = iface.Index
}
s := &unix.SockaddrLinklayer{
Protocol: htons(uint16(unix.ETH_P_ALL)),
Ifindex: ifIndex,
}
return unix.Bind(h.fd, s)
}
// setTPacketVersion asks the kernel to set TPacket to a particular version, and returns an error on failure.
func (h *TPacket) setTPacketVersion(version OptTPacketVersion) error {
if err := unix.SetsockoptInt(h.fd, unix.SOL_PACKET, unix.PACKET_VERSION, int(version)); err != nil {
return fmt.Errorf("setsockopt packet_version: %v", err)
}
return nil
}
// setRequestedTPacketVersion tries to set TPacket to the requested version or versions.
func (h *TPacket) setRequestedTPacketVersion() error {
switch {
case (h.opts.version == TPacketVersionHighestAvailable || h.opts.version == TPacketVersion3) && h.setTPacketVersion(TPacketVersion3) == nil:
h.tpVersion = TPacketVersion3
case (h.opts.version == TPacketVersionHighestAvailable || h.opts.version == TPacketVersion2) && h.setTPacketVersion(TPacketVersion2) == nil:
h.tpVersion = TPacketVersion2
case (h.opts.version == TPacketVersionHighestAvailable || h.opts.version == TPacketVersion1) && h.setTPacketVersion(TPacketVersion1) == nil:
h.tpVersion = TPacketVersion1
default:
return errors.New("no known tpacket versions work on this machine")
}
return nil
}
// setUpRing sets up the shared-memory ring buffer between the user process and the kernel.
func (h *TPacket) setUpRing() (err error) {
totalSize := int(h.opts.framesPerBlock * h.opts.numBlocks * h.opts.frameSize)
switch h.tpVersion {
case TPacketVersion1, TPacketVersion2:
var tp C.struct_tpacket_req
tp.tp_block_size = C.uint(h.opts.blockSize)
tp.tp_block_nr = C.uint(h.opts.numBlocks)
tp.tp_frame_size = C.uint(h.opts.frameSize)
tp.tp_frame_nr = C.uint(h.opts.framesPerBlock * h.opts.numBlocks)
if err := setsockopt(h.fd, unix.SOL_PACKET, unix.PACKET_RX_RING, unsafe.Pointer(&tp), unsafe.Sizeof(tp)); err != nil {
return fmt.Errorf("setsockopt packet_rx_ring: %v", err)
}
case TPacketVersion3:
var tp C.struct_tpacket_req3
tp.tp_block_size = C.uint(h.opts.blockSize)
tp.tp_block_nr = C.uint(h.opts.numBlocks)
tp.tp_frame_size = C.uint(h.opts.frameSize)
tp.tp_frame_nr = C.uint(h.opts.framesPerBlock * h.opts.numBlocks)
tp.tp_retire_blk_tov = C.uint(h.opts.blockTimeout / time.Millisecond)
if err := setsockopt(h.fd, unix.SOL_PACKET, unix.PACKET_RX_RING, unsafe.Pointer(&tp), unsafe.Sizeof(tp)); err != nil {
return fmt.Errorf("setsockopt packet_rx_ring v3: %v", err)
}
default:
return errors.New("invalid tpVersion")
}
h.ring, err = unix.Mmap(h.fd, 0, totalSize, unix.PROT_READ|unix.PROT_WRITE, unix.MAP_SHARED)
if err != nil {
return err
}
if h.ring == nil {
return errors.New("no ring")
}
h.rawring = unsafe.Pointer(&h.ring[0])
return nil
}
// Close cleans up the TPacket. It should not be used after the Close call.
func (h *TPacket) Close() {
if h.fd == -1 {
return // already closed.
}
if h.ring != nil {
unix.Munmap(h.ring)
}
h.ring = nil
unix.Close(h.fd)
h.fd = -1
runtime.SetFinalizer(h, nil)
}
// NewTPacket returns a new TPacket object for reading packets off the wire.
// Its behavior may be modified by passing in any/all of afpacket.Opt* to this
// function.
// If this function succeeds, the user should be sure to Close the returned
// TPacket when finished with it.
func NewTPacket(opts ...interface{}) (h *TPacket, err error) {
h = &TPacket{}
if h.opts, err = parseOptions(opts...); err != nil {
return nil, err
}
fd, err := unix.Socket(unix.AF_PACKET, int(h.opts.socktype), int(htons(unix.ETH_P_ALL)))
if err != nil {
return nil, err
}
h.fd = fd
if err = h.bindToInterface(h.opts.iface); err != nil {
goto errlbl
}
if err = h.setRequestedTPacketVersion(); err != nil {
goto errlbl
}
if err = h.setUpRing(); err != nil {
goto errlbl
}
// Clear stat counter from socket
if err = h.InitSocketStats(); err != nil {
goto errlbl
}
runtime.SetFinalizer(h, (*TPacket).Close)
return h, nil
errlbl:
h.Close()
return nil, err
}
// SetBPF attaches a BPF filter to the underlying socket
func (h *TPacket) SetBPF(filter []bpf.RawInstruction) error {
var p unix.SockFprog
if len(filter) > int(^uint16(0)) {
return errors.New("filter too large")
}
p.Len = uint16(len(filter))
p.Filter = (*unix.SockFilter)(unsafe.Pointer(&filter[0]))
return setsockopt(h.fd, unix.SOL_SOCKET, unix.SO_ATTACH_FILTER, unsafe.Pointer(&p), unix.SizeofSockFprog)
}
// attach ebpf filter to af-packet
func (h *TPacket) SetEBPF(progFd int32) error {
return setsockopt(h.fd, unix.SOL_SOCKET, unix.SO_ATTACH_BPF, unsafe.Pointer(&progFd), 4)
}
func (h *TPacket) releaseCurrentPacket() error {
h.current.clearStatus()
h.offset++
h.shouldReleasePacket = false
return nil
}
// ZeroCopyReadPacketData reads the next packet off the wire, and returns its data.
// The slice returned by ZeroCopyReadPacketData points to bytes owned by the
// TPacket. Each call to ZeroCopyReadPacketData invalidates any data previously
// returned by ZeroCopyReadPacketData. Care must be taken not to keep pointers
// to old bytes when using ZeroCopyReadPacketData... if you need to keep data past
// the next time you call ZeroCopyReadPacketData, use ReadPacketData, which copies
// the bytes into a new buffer for you.
// tp, _ := NewTPacket(...)
// data1, _, _ := tp.ZeroCopyReadPacketData()
// // do everything you want with data1 here, copying bytes out of it if you'd like to keep them around.
// data2, _, _ := tp.ZeroCopyReadPacketData() // invalidates bytes in data1
func (h *TPacket) ZeroCopyReadPacketData() (data []byte, ci gopacket.CaptureInfo, err error) {
h.mu.Lock()
retry:
if h.current == nil || !h.headerNextNeeded || !h.current.next() {
if h.shouldReleasePacket {
h.releaseCurrentPacket()
}
h.current = h.getTPacketHeader()
if err = h.pollForFirstPacket(h.current); err != nil {
h.headerNextNeeded = false
h.mu.Unlock()
return
}
// We received an empty block
if h.current.getLength() == 0 {
goto retry
}
}
data = h.current.getData(&h.opts)
ci.Timestamp = h.current.getTime()
ci.CaptureLength = len(data)
ci.Length = h.current.getLength()
ci.InterfaceIndex = h.current.getIfaceIndex()
vlan := h.current.getVLAN()
if vlan >= 0 {
ci.AncillaryData = append(ci.AncillaryData, AncillaryVLAN{vlan})
}
atomic.AddInt64(&h.stats.Packets, 1)
h.headerNextNeeded = true
h.mu.Unlock()
return
}
// Stats returns statistics on the packets the TPacket has seen so far.
func (h *TPacket) Stats() (Stats, error) {
return Stats{
Polls: atomic.LoadInt64(&h.stats.Polls),
Packets: atomic.LoadInt64(&h.stats.Packets),
}, nil
}
// InitSocketStats clears socket counters and return empty stats.
func (h *TPacket) InitSocketStats() error {
if h.tpVersion == TPacketVersion3 {
socklen := unsafe.Sizeof(h.socketStatsV3)
slt := C.socklen_t(socklen)
var ssv3 SocketStatsV3
err := getsockopt(h.fd, unix.SOL_PACKET, unix.PACKET_STATISTICS, unsafe.Pointer(&ssv3), uintptr(unsafe.Pointer(&slt)))
if err != nil {
return err
}
h.socketStatsV3 = SocketStatsV3{}
} else {
socklen := unsafe.Sizeof(h.socketStats)
slt := C.socklen_t(socklen)
var ss SocketStats
err := getsockopt(h.fd, unix.SOL_PACKET, unix.PACKET_STATISTICS, unsafe.Pointer(&ss), uintptr(unsafe.Pointer(&slt)))
if err != nil {
return err
}
h.socketStats = SocketStats{}
}
return nil
}
// SocketStats saves stats from the socket to the TPacket instance.
func (h *TPacket) SocketStats() (SocketStats, SocketStatsV3, error) {
h.statsMu.Lock()
defer h.statsMu.Unlock()
// We need to save the counters since asking for the stats will clear them
if h.tpVersion == TPacketVersion3 {
socklen := unsafe.Sizeof(h.socketStatsV3)
slt := C.socklen_t(socklen)
var ssv3 SocketStatsV3
err := getsockopt(h.fd, unix.SOL_PACKET, unix.PACKET_STATISTICS, unsafe.Pointer(&ssv3), uintptr(unsafe.Pointer(&slt)))
if err != nil {
return SocketStats{}, SocketStatsV3{}, err
}
h.socketStatsV3.tp_packets += ssv3.tp_packets
h.socketStatsV3.tp_drops += ssv3.tp_drops
h.socketStatsV3.tp_freeze_q_cnt += ssv3.tp_freeze_q_cnt
return h.socketStats, h.socketStatsV3, nil
}
socklen := unsafe.Sizeof(h.socketStats)
slt := C.socklen_t(socklen)
var ss SocketStats
err := getsockopt(h.fd, unix.SOL_PACKET, unix.PACKET_STATISTICS, unsafe.Pointer(&ss), uintptr(unsafe.Pointer(&slt)))
if err != nil {
return SocketStats{}, SocketStatsV3{}, err
}
h.socketStats.tp_packets += ss.tp_packets
h.socketStats.tp_drops += ss.tp_drops
return h.socketStats, h.socketStatsV3, nil
}
// ReadPacketDataTo reads packet data into a user-supplied buffer.
// This function reads up to the length of the passed-in slice.
// The number of bytes read into data will be returned in ci.CaptureLength,
// which is the minimum of the size of the passed-in buffer and the size of
// the captured packet.
func (h *TPacket) ReadPacketDataTo(data []byte) (ci gopacket.CaptureInfo, err error) {
var d []byte
d, ci, err = h.ZeroCopyReadPacketData()
if err != nil {
return
}
ci.CaptureLength = copy(data, d)
return
}
// ReadPacketData reads the next packet, copies it into a new buffer, and returns
// that buffer. Since the buffer is allocated by ReadPacketData, it is safe for long-term
// use. This implements gopacket.PacketDataSource.
func (h *TPacket) ReadPacketData() (data []byte, ci gopacket.CaptureInfo, err error) {
var d []byte
d, ci, err = h.ZeroCopyReadPacketData()
if err != nil {
return
}
data = make([]byte, len(d))
copy(data, d)
return
}
func (h *TPacket) getTPacketHeader() header {
switch h.tpVersion {
case TPacketVersion1:
if h.offset >= h.opts.framesPerBlock*h.opts.numBlocks {
h.offset = 0
}
position := uintptr(h.rawring) + uintptr(h.opts.frameSize*h.offset)
return (*v1header)(unsafe.Pointer(position))
case TPacketVersion2:
if h.offset >= h.opts.framesPerBlock*h.opts.numBlocks {
h.offset = 0
}
position := uintptr(h.rawring) + uintptr(h.opts.frameSize*h.offset)
return (*v2header)(unsafe.Pointer(position))
case TPacketVersion3:
// TPacket3 uses each block to return values, instead of each frame. Hence we need to rotate when we hit #blocks, not #frames.
if h.offset >= h.opts.numBlocks {
h.offset = 0
}
position := uintptr(h.rawring) + uintptr(h.opts.frameSize*h.offset*h.opts.framesPerBlock)
h.v3 = initV3Wrapper(unsafe.Pointer(position))
return &h.v3
}
panic("handle tpacket version is invalid")
}
func (h *TPacket) pollForFirstPacket(hdr header) error {
tm := int(h.opts.pollTimeout / time.Millisecond)
for hdr.getStatus()&unix.TP_STATUS_USER == 0 {
pollset := [1]unix.PollFd{
{
Fd: int32(h.fd),
Events: unix.POLLIN,
},
}
n, err := unix.Poll(pollset[:], tm)
if n == 0 {
return ErrTimeout
}
atomic.AddInt64(&h.stats.Polls, 1)
if pollset[0].Revents&unix.POLLERR > 0 {
return ErrPoll
}
if err == syscall.EINTR {
continue
}
if err != nil {
return err
}
}
h.shouldReleasePacket = true
return nil
}
// FanoutType determines the type of fanout to use with a TPacket SetFanout call.
type FanoutType int
// FanoutType values.
const (
FanoutHash FanoutType = unix.PACKET_FANOUT_HASH
// It appears that defrag only works with FanoutHash, see:
// http://lxr.free-electrons.com/source/net/packet/af_packet.c#L1204
FanoutHashWithDefrag FanoutType = unix.PACKET_FANOUT_FLAG_DEFRAG
FanoutLoadBalance FanoutType = unix.PACKET_FANOUT_LB
FanoutCPU FanoutType = unix.PACKET_FANOUT_CPU
FanoutRollover FanoutType = unix.PACKET_FANOUT_ROLLOVER
FanoutRandom FanoutType = unix.PACKET_FANOUT_RND
FanoutQueueMapping FanoutType = unix.PACKET_FANOUT_QM
FanoutCBPF FanoutType = unix.PACKET_FANOUT_CBPF
FanoutEBPF FanoutType = unix.PACKET_FANOUT_EBPF
)
// SetFanout activates TPacket's fanout ability.
// Use of Fanout requires creating multiple TPacket objects and the same id/type to
// a SetFanout call on each. Note that this can be done cross-process, so if two
// different processes both call SetFanout with the same type/id, they'll share
// packets between them. The same should work for multiple TPacket objects within
// the same process.
func (h *TPacket) SetFanout(t FanoutType, id uint16) error {
h.mu.Lock()
defer h.mu.Unlock()
arg := C.int(t) << 16
arg |= C.int(id)
return setsockopt(h.fd, unix.SOL_PACKET, unix.PACKET_FANOUT, unsafe.Pointer(&arg), unsafe.Sizeof(arg))
}
// WritePacketData transmits a raw packet.
func (h *TPacket) WritePacketData(pkt []byte) error {
_, err := unix.Write(h.fd, pkt)
return err
}
================================================
FILE: afpacket/afpacket_test.go
================================================
// Copyright 2012 Google, Inc. All rights reserved.
//
// Use of this source code is governed by a BSD-style license
// that can be found in the LICENSE file in the root of the source
// tree.
// +build linux
package afpacket
import (
"reflect"
"testing"
)
func TestParseOptions(t *testing.T) {
wanted1 := defaultOpts
wanted1.frameSize = 1 << 10
wanted1.framesPerBlock = wanted1.blockSize / wanted1.frameSize
for i, test := range []struct {
opts []interface{}
want options
err bool
}{
{opts: []interface{}{OptBlockSize(2)}, err: true},
{opts: []interface{}{OptFrameSize(333)}, err: true},
{opts: []interface{}{OptTPacketVersion(-3)}, err: true},
{opts: []interface{}{OptTPacketVersion(5)}, err: true},
{opts: []interface{}{OptFrameSize(1 << 10)}, want: wanted1},
} {
got, err := parseOptions(test.opts...)
t.Logf("got: %#v\nerr: %v", got, err)
if test.err && err == nil || !test.err && err != nil {
t.Errorf("%d error mismatch, want error? %v. error: %v", i, test.err, err)
}
if !test.err && !reflect.DeepEqual(test.want, got) {
t.Errorf("%d opts mismatch, want\n%#v", i, test.want)
}
}
}
================================================
FILE: afpacket/header.go
================================================
// Copyright 2012 Google, Inc. All rights reserved.
//
// Use of this source code is governed by a BSD-style license
// that can be found in the LICENSE file in the root of the source
// tree.
// +build linux
package afpacket
import (
"reflect"
"time"
"unsafe"
"golang.org/x/sys/unix"
)
// #include <linux/if_packet.h>
// #include <linux/if_ether.h>
// #define VLAN_HLEN 4
import "C"
// Our model of handling all TPacket versions is a little hacky, to say the
// least. We use the header interface to handle interactions with the
// tpacket1/tpacket2 packet header AND the tpacket3 block header. The big
// difference is that tpacket3's block header implements the next() call to get
// the next packet within the block, while v1/v2 just always return false.
type header interface {
// getStatus returns the TPacket status of the current header.
getStatus() int
// clearStatus clears the status of the current header, releasing its
// underlying data back to the kernel for future use with new packets.
// Using the header after calling clearStatus is an error. clearStatus
// should only be called after next() returns false.
clearStatus()
// getTime returns the timestamp for the current packet pointed to by
// the header.
getTime() time.Time
// getData returns the packet data pointed to by the current header.
getData(opts *options) []byte
// getLength returns the total length of the packet.
getLength() int
// getIfaceIndex returns the index of the network interface
// where the packet was seen. The index can later be translated to a name.
getIfaceIndex() int
// getVLAN returns the VLAN of a packet if it was provided out-of-band
getVLAN() int
// next moves this header to point to the next packet it contains,
// returning true on success (in which case getTime and getData will
// return values for the new packet) or false if there are no more
// packets (in which case clearStatus should be called).
next() bool
}
const tpacketAlignment = uint(unix.TPACKET_ALIGNMENT)
func tpAlign(x int) int {
return int((uint(x) + tpacketAlignment - 1) &^ (tpacketAlignment - 1))
}
type v1header C.struct_tpacket_hdr
type v2header C.struct_tpacket2_hdr
func makeSlice(start uintptr, length int) (data []byte) {
slice := (*reflect.SliceHeader)(unsafe.Pointer(&data))
slice.Data = start
slice.Len = length
slice.Cap = length
return
}
func insertVlanHeader(data []byte, vlanTCI int, opts *options) []byte {
if vlanTCI == 0 || !opts.addVLANHeader {
return data
}
eth := make([]byte, 0, len(data)+C.VLAN_HLEN)
eth = append(eth, data[0:C.ETH_ALEN*2]...)
eth = append(eth, []byte{0x81, 0, byte((vlanTCI >> 8) & 0xff), byte(vlanTCI & 0xff)}...)
return append(eth, data[C.ETH_ALEN*2:]...)
}
func (h *v1header) getVLAN() int {
return -1
}
func (h *v1header) getStatus() int {
return int(h.tp_status)
}
func (h *v1header) clearStatus() {
h.tp_status = 0
}
func (h *v1header) getTime() time.Time {
return time.Unix(int64(h.tp_sec), int64(h.tp_usec)*1000)
}
func (h *v1header) getData(opts *options) []byte {
return makeSlice(uintptr(unsafe.Pointer(h))+uintptr(h.tp_mac), int(h.tp_snaplen))
}
func (h *v1header) getLength() int {
return int(h.tp_len)
}
func (h *v1header) getIfaceIndex() int {
ll := (*C.struct_sockaddr_ll)(unsafe.Pointer(uintptr(unsafe.Pointer(h)) + uintptr(tpAlign(int(C.sizeof_struct_tpacket_hdr)))))
return int(ll.sll_ifindex)
}
func (h *v1header) next() bool {
return false
}
func (h *v2header) getVLAN() int {
return -1
}
func (h *v2header) getStatus() int {
return int(h.tp_status)
}
func (h *v2header) clearStatus() {
h.tp_status = 0
}
func (h *v2header) getTime() time.Time {
return time.Unix(int64(h.tp_sec), int64(h.tp_nsec))
}
func (h *v2header) getData(opts *options) []byte {
data := makeSlice(uintptr(unsafe.Pointer(h))+uintptr(h.tp_mac), int(h.tp_snaplen))
return insertVlanHeader(data, int(h.tp_vlan_tci), opts)
}
func (h *v2header) getLength() int {
return int(h.tp_len)
}
func (h *v2header) getIfaceIndex() int {
ll := (*C.struct_sockaddr_ll)(unsafe.Pointer(uintptr(unsafe.Pointer(h)) + uintptr(tpAlign(int(C.sizeof_struct_tpacket2_hdr)))))
return int(ll.sll_ifindex)
}
func (h *v2header) next() bool {
return false
}
type v3wrapper struct {
block *C.struct_tpacket_block_desc
blockhdr *C.struct_tpacket_hdr_v1
packet *C.struct_tpacket3_hdr
used C.__u32
}
func initV3Wrapper(block unsafe.Pointer) (w v3wrapper) {
w.block = (*C.struct_tpacket_block_desc)(block)
w.blockhdr = (*C.struct_tpacket_hdr_v1)(unsafe.Pointer(&w.block.hdr[0]))
w.packet = (*C.struct_tpacket3_hdr)(unsafe.Pointer(uintptr(block) + uintptr(w.blockhdr.offset_to_first_pkt)))
return
}
func (w *v3wrapper) getVLAN() int {
if w.packet.tp_status&unix.TP_STATUS_VLAN_VALID != 0 {
hv1 := (*C.struct_tpacket_hdr_variant1)(unsafe.Pointer(&w.packet.anon0[0]))
return int(hv1.tp_vlan_tci & 0xfff)
}
return -1
}
func (w *v3wrapper) getStatus() int {
return int(w.blockhdr.block_status)
}
func (w *v3wrapper) clearStatus() {
w.blockhdr.block_status = 0
}
func (w *v3wrapper) getTime() time.Time {
return time.Unix(int64(w.packet.tp_sec), int64(w.packet.tp_nsec))
}
func (w *v3wrapper) getData(opts *options) []byte {
data := makeSlice(uintptr(unsafe.Pointer(w.packet))+uintptr(w.packet.tp_mac), int(w.packet.tp_snaplen))
hv1 := (*C.struct_tpacket_hdr_variant1)(unsafe.Pointer(&w.packet.anon0[0]))
return insertVlanHeader(data, int(hv1.tp_vlan_tci), opts)
}
func (w *v3wrapper) getLength() int {
return int(w.packet.tp_len)
}
func (w *v3wrapper) getIfaceIndex() int {
ll := (*C.struct_sockaddr_ll)(unsafe.Pointer(uintptr(unsafe.Pointer(w.packet)) + uintptr(tpAlign(int(C.sizeof_struct_tpacket3_hdr)))))
return int(ll.sll_ifindex)
}
func (w *v3wrapper) next() bool {
w.used++
if w.used >= w.blockhdr.num_pkts {
return false
}
next := uintptr(unsafe.Pointer(w.packet))
if w.packet.tp_next_offset != 0 {
next += uintptr(w.packet.tp_next_offset)
} else {
next += uintptr(tpAlign(int(w.packet.tp_snaplen) + int(w.packet.tp_mac)))
}
w.packet = (*C.struct_tpacket3_hdr)(unsafe.Pointer(next))
return true
}
================================================
FILE: afpacket/options.go
================================================
// Copyright 2012 Google, Inc. All rights reserved.
//
// Use of this source code is governed by a BSD-style license
// that can be found in the LICENSE file in the root of the source
// tree.
// +build linux
package afpacket
import (
"errors"
"fmt"
"time"
"golang.org/x/sys/unix"
)
// OptTPacketVersion is the version of TPacket to use.
// It can be passed into NewTPacket.
type OptTPacketVersion int
// String returns a string representation of the version, generally of the form V#.
func (t OptTPacketVersion) String() string {
switch t {
case TPacketVersion1:
return "V1"
case TPacketVersion2:
return "V2"
case TPacketVersion3:
return "V3"
case TPacketVersionHighestAvailable:
return "HighestAvailable"
}
return "InvalidVersion"
}
// OptSocketType is the socket type used to open the TPacket socket.
type OptSocketType int
func (t OptSocketType) String() string {
switch t {
case SocketRaw:
return "SOCK_RAW"
case SocketDgram:
return "SOCK_DGRAM"
}
return "UnknownSocketType"
}
// TPacket version numbers for use with NewHandle.
const (
// TPacketVersionHighestAvailable tells NewHandle to use the highest available version of tpacket the kernel has available.
// This is the default, should a version number not be given in NewHandle's options.
TPacketVersionHighestAvailable = OptTPacketVersion(-1)
TPacketVersion1 = OptTPacketVersion(unix.TPACKET_V1)
TPacketVersion2 = OptTPacketVersion(unix.TPACKET_V2)
TPacketVersion3 = OptTPacketVersion(unix.TPACKET_V3)
tpacketVersionMax = TPacketVersion3
tpacketVersionMin = -1
// SocketRaw is the default socket type. It returns packet data
// including the link layer (ethernet headers, etc).
SocketRaw = OptSocketType(unix.SOCK_RAW)
// SocketDgram strips off the link layer when reading packets, and adds
// the link layer back automatically on packet writes (coming soon...)
SocketDgram = OptSocketType(unix.SOCK_DGRAM)
)
// OptInterface is the specific interface to bind to.
// It can be passed into NewTPacket.
type OptInterface string
// OptFrameSize is TPacket's tp_frame_size
// It can be passed into NewTPacket.
type OptFrameSize int
// OptBlockSize is TPacket's tp_block_size
// It can be passed into NewTPacket.
type OptBlockSize int
// OptNumBlocks is TPacket's tp_block_nr
// It can be passed into NewTPacket.
type OptNumBlocks int
// OptBlockTimeout is TPacket v3's tp_retire_blk_tov. Note that it has only millisecond granularity, so must be >= 1 ms.
// It can be passed into NewTPacket.
type OptBlockTimeout time.Duration
// OptPollTimeout is the number of milliseconds that poll() should block waiting for a file
// descriptor to become ready. Specifying a negative value in time‐out means an infinite timeout.
type OptPollTimeout time.Duration
// OptAddVLANHeader modifies the packet data that comes back from the
// kernel by adding in the VLAN header that the NIC stripped. AF_PACKET by
// default uses VLAN offloading, in which the NIC strips the VLAN header off of
// the packet before handing it to the kernel. This means that, even if a
// packet has an 802.1q header on the wire, it'll show up without one by the
// time it goes through AF_PACKET. If this option is true, the VLAN header is
// added back in before the packet is returned. Note that this potentially has
// a large performance hit, especially in otherwise zero-copy operation.
//
// Note that if you do not need to have a "real" VLAN layer, it may be
// preferable to use the VLAN ID provided by the AncillaryVLAN struct
// in CaptureInfo.AncillaryData, which is populated out-of-band and has
// negligible performance impact. Such ancillary data will automatically
// be provided if available.
type OptAddVLANHeader bool
// Default constants used by options.
const (
DefaultFrameSize = 4096 // Default value for OptFrameSize.
DefaultBlockSize = DefaultFrameSize * 128 // Default value for OptBlockSize.
DefaultNumBlocks = 128 // Default value for OptNumBlocks.
DefaultBlockTimeout = 64 * time.Millisecond // Default value for OptBlockTimeout.
DefaultPollTimeout = -1 * time.Millisecond // Default value for OptPollTimeout. This blocks forever.
)
type options struct {
frameSize int
framesPerBlock int
blockSize int
numBlocks int
addVLANHeader bool
blockTimeout time.Duration
pollTimeout time.Duration
version OptTPacketVersion
socktype OptSocketType
iface string
}
var defaultOpts = options{
frameSize: DefaultFrameSize,
blockSize: DefaultBlockSize,
numBlocks: DefaultNumBlocks,
blockTimeout: DefaultBlockTimeout,
pollTimeout: DefaultPollTimeout,
version: TPacketVersionHighestAvailable,
socktype: SocketRaw,
}
func parseOptions(opts ...interface{}) (ret options, err error) {
ret = defaultOpts
for _, opt := range opts {
switch v := opt.(type) {
case OptFrameSize:
ret.frameSize = int(v)
case OptBlockSize:
ret.blockSize = int(v)
case OptNumBlocks:
ret.numBlocks = int(v)
case OptBlockTimeout:
ret.blockTimeout = time.Duration(v)
case OptPollTimeout:
ret.pollTimeout = time.Duration(v)
case OptTPacketVersion:
ret.version = v
case OptInterface:
ret.iface = string(v)
case OptSocketType:
ret.socktype = v
case OptAddVLANHeader:
ret.addVLANHeader = bool(v)
default:
err = errors.New("unknown type in options")
return
}
}
if err = ret.check(); err != nil {
return
}
ret.framesPerBlock = ret.blockSize / ret.frameSize
return
}
func (o options) check() error {
switch {
case o.blockSize%pageSize != 0:
return fmt.Errorf("block size %d must be divisible by page size %d", o.blockSize, pageSize)
case o.blockSize%o.frameSize != 0:
return fmt.Errorf("block size %d must be divisible by frame size %d", o.blockSize, o.frameSize)
case o.numBlocks < 1:
return fmt.Errorf("num blocks %d must be >= 1", o.numBlocks)
case o.blockTimeout < time.Millisecond:
return fmt.Errorf("block timeout %v must be > %v", o.blockTimeout, time.Millisecond)
case o.version < tpacketVersionMin || o.version > tpacketVersionMax:
return fmt.Errorf("tpacket version %v is invalid", o.version)
}
return nil
}
================================================
FILE: afpacket/sockopt_linux.go
================================================
// Copyright 2012 Google, Inc. All rights reserved.
//
// Use of this source code is governed by a BSD-style license
// that can be found in the LICENSE file in the root of the source
// tree.
// +build linux
package afpacket
import (
"unsafe"
"golang.org/x/sys/unix"
)
// setsockopt provides access to the setsockopt syscall.
func setsockopt(fd, level, name int, val unsafe.Pointer, vallen uintptr) error {
_, _, errno := unix.Syscall6(
unix.SYS_SETSOCKOPT,
uintptr(fd),
uintptr(level),
uintptr(name),
uintptr(val),
vallen,
0,
)
if errno != 0 {
return error(errno)
}
return nil
}
// getsockopt provides access to the getsockopt syscall.
func getsockopt(fd, level, name int, val unsafe.Pointer, vallen uintptr) error {
_, _, errno := unix.Syscall6(
unix.SYS_GETSOCKOPT,
uintptr(fd),
uintptr(level),
uintptr(name),
uintptr(val),
vallen,
0,
)
if errno != 0 {
return error(errno)
}
return nil
}
// htons converts a short (uint16) from host-to-network byte order.
// Thanks to mikioh for this neat trick:
// https://github.com/mikioh/-stdyng/blob/master/afpacket.go
func htons(i uint16) uint16 {
return (i<<8)&0xff00 | i>>8
}
================================================
FILE: base.go
================================================
// Copyright 2012 Google, Inc. All rights reserved.
//
// Use of this source code is governed by a BSD-style license
// that can be found in the LICENSE file in the root of the source
// tree.
package gopacket
import (
"fmt"
)
// Layer represents a single decoded packet layer (using either the
// OSI or TCP/IP definition of a layer). When decoding, a packet's data is
// broken up into a number of layers. The caller may call LayerType() to
// figure out which type of layer they've received from the packet. Optionally,
// they may then use a type assertion to get the actual layer type for deep
// inspection of the data.
type Layer interface {
// LayerType is the gopacket type for this layer.
LayerType() LayerType
// LayerContents returns the set of bytes that make up this layer.
LayerContents() []byte
// LayerPayload returns the set of bytes contained within this layer, not
// including the layer itself.
LayerPayload() []byte
}
// Payload is a Layer containing the payload of a packet. The definition of
// what constitutes the payload of a packet depends on previous layers; for
// TCP and UDP, we stop decoding above layer 4 and return the remaining
// bytes as a Payload. Payload is an ApplicationLayer.
type Payload []byte
// LayerType returns LayerTypePayload
func (p Payload) LayerType() LayerType { return LayerTypePayload }
// LayerContents returns the bytes making up this layer.
func (p Payload) LayerContents() []byte { return []byte(p) }
// LayerPayload returns the payload within this layer.
func (p Payload) LayerPayload() []byte { return nil }
// Payload returns this layer as bytes.
func (p Payload) Payload() []byte { return []byte(p) }
// String implements fmt.Stringer.
func (p Payload) String() string { return fmt.Sprintf("%d byte(s)", len(p)) }
// GoString implements fmt.GoStringer.
func (p Payload) GoString() string { return LongBytesGoString([]byte(p)) }
// CanDecode implements DecodingLayer.
func (p Payload) CanDecode() LayerClass { return LayerTypePayload }
// NextLayerType implements DecodingLayer.
func (p Payload) NextLayerType() LayerType { return LayerTypeZero }
// DecodeFromBytes implements DecodingLayer.
func (p *Payload) DecodeFromBytes(data []byte, df DecodeFeedback) error {
*p = Payload(data)
return nil
}
// SerializeTo writes the serialized form of this layer into the
// SerializationBuffer, implementing gopacket.SerializableLayer.
// See the docs for gopacket.SerializableLayer for more info.
func (p Payload) SerializeTo(b SerializeBuffer, opts SerializeOptions) error {
bytes, err := b.PrependBytes(len(p))
if err != nil {
return err
}
copy(bytes, p)
return nil
}
// decodePayload decodes data by returning it all in a Payload layer.
func decodePayload(data []byte, p PacketBuilder) error {
payload := &Payload{}
if err := payload.DecodeFromBytes(data, p); err != nil {
return err
}
p.AddLayer(payload)
p.SetApplicationLayer(payload)
return nil
}
// Fragment is a Layer containing a fragment of a larger frame, used by layers
// like IPv4 and IPv6 that allow for fragmentation of their payloads.
type Fragment []byte
// LayerType returns LayerTypeFragment
func (p *Fragment) LayerType() LayerType { return LayerTypeFragment }
// LayerContents implements Layer.
func (p *Fragment) LayerContents() []byte { return []byte(*p) }
// LayerPayload implements Layer.
func (p *Fragment) LayerPayload() []byte { return nil }
// Payload returns this layer as a byte slice.
func (p *Fragment) Payload() []byte { return []byte(*p) }
// String implements fmt.Stringer.
func (p *Fragment) String() string { return fmt.Sprintf("%d byte(s)", len(*p)) }
// CanDecode implements DecodingLayer.
func (p *Fragment) CanDecode() LayerClass { return LayerTypeFragment }
// NextLayerType implements DecodingLayer.
func (p *Fragment) NextLayerType() LayerType { return LayerTypeZero }
// DecodeFromBytes implements DecodingLayer.
func (p *Fragment) DecodeFromBytes(data []byte, df DecodeFeedback) error {
*p = Fragment(data)
return nil
}
// SerializeTo writes the serialized form of this layer into the
// SerializationBuffer, implementing gopacket.SerializableLayer.
// See the docs for gopacket.SerializableLayer for more info.
func (p *Fragment) SerializeTo(b SerializeBuffer, opts SerializeOptions) error {
bytes, err := b.PrependBytes(len(*p))
if err != nil {
return err
}
copy(bytes, *p)
return nil
}
// decodeFragment decodes data by returning it all in a Fragment layer.
func decodeFragment(data []byte, p PacketBuilder) error {
payload := &Fragment{}
if err := payload.DecodeFromBytes(data, p); err != nil {
return err
}
p.AddLayer(payload)
p.SetApplicationLayer(payload)
return nil
}
// These layers correspond to Internet Protocol Suite (TCP/IP) layers, and their
// corresponding OSI layers, as best as possible.
// LinkLayer is the packet layer corresponding to TCP/IP layer 1 (OSI layer 2)
type LinkLayer interface {
Layer
LinkFlow() Flow
}
// NetworkLayer is the packet layer corresponding to TCP/IP layer 2 (OSI
// layer 3)
type NetworkLayer interface {
Layer
NetworkFlow() Flow
}
// TransportLayer is the packet layer corresponding to the TCP/IP layer 3 (OSI
// layer 4)
type TransportLayer interface {
Layer
TransportFlow() Flow
}
// ApplicationLayer is the packet layer corresponding to the TCP/IP layer 4 (OSI
// layer 7), also known as the packet payload.
type ApplicationLayer interface {
Layer
Payload() []byte
}
// ErrorLayer is a packet layer created when decoding of the packet has failed.
// Its payload is all the bytes that we were unable to decode, and the returned
// error details why the decoding failed.
type ErrorLayer interface {
Layer
Error() error
}
================================================
FILE: benchmark_test.go
================================================
// Copyright 2012, Google, Inc. All rights reserved.
//
// Use of this source code is governed by a BSD-style license
// that can be found in the LICENSE file in the root of the source
// tree.
package gopacket
import (
"runtime"
"testing"
)
// A few benchmarks for figuring out exactly how fast some underlying Go
// things are.
type testError struct{}
func (t *testError) Error() string { return "abc" }
func BenchmarkTypeAssertion(b *testing.B) {
var e error = &testError{}
for i := 0; i < b.N; i++ {
_, _ = e.(*testError)
}
}
func BenchmarkMapLookup(b *testing.B) {
m := map[LayerType]bool{
LayerTypePayload: true,
}
for i := 0; i < b.N; i++ {
_ = m[LayerTypePayload]
}
}
func BenchmarkNilMapLookup(b *testing.B) {
var m map[LayerType]bool
for i := 0; i < b.N; i++ {
_ = m[LayerTypePayload]
}
}
func BenchmarkNilMapLookupWithNilCheck(b *testing.B) {
var m map[LayerType]bool
for i := 0; i < b.N; i++ {
if m != nil {
_ = m[LayerTypePayload]
}
}
}
func BenchmarkArrayLookup(b *testing.B) {
m := make([]bool, 100)
for i := 0; i < b.N; i++ {
_ = m[LayerTypePayload]
}
}
var testError1 = &testError{}
var testError2 error = testError1
func BenchmarkTypeToInterface1(b *testing.B) {
var e error
for i := 0; i < b.N; i++ {
e = testError1
}
// Have to do someting with 'e' or the compiler complains about an unused
// variable.
testError2 = e
}
func BenchmarkTypeToInterface2(b *testing.B) {
var e error
for i := 0; i < b.N; i++ {
e = testError2
}
// Have to do someting with 'e' or the compiler complains about an unused
// variable.
testError2 = e
}
var decodeOpts DecodeOptions
func decodeOptsByValue(_ DecodeOptions) {}
func decodeOptsByPointer(_ *DecodeOptions) {}
func BenchmarkPassDecodeOptionsByValue(b *testing.B) {
for i := 0; i < b.N; i++ {
decodeOptsByValue(decodeOpts)
}
}
func BenchmarkPassDecodeOptionsByPointer(b *testing.B) {
for i := 0; i < b.N; i++ {
decodeOptsByPointer(&decodeOpts)
}
}
func BenchmarkLockOSThread(b *testing.B) {
for i := 0; i < b.N; i++ {
runtime.LockOSThread()
}
}
func BenchmarkUnlockOSThread(b *testing.B) {
for i := 0; i < b.N; i++ {
runtime.UnlockOSThread()
}
}
func lockUnlock() {
runtime.LockOSThread()
runtime.UnlockOSThread()
}
func lockDeferUnlock() {
runtime.LockOSThread()
defer runtime.UnlockOSThread()
}
func BenchmarkLockUnlockOSThread(b *testing.B) {
for i := 0; i < b.N; i++ {
lockUnlock()
}
}
func BenchmarkLockDeferUnlockOSThread(b *testing.B) {
for i := 0; i < b.N; i++ {
lockDeferUnlock()
}
}
func BenchmarkUnbufferedChannel(b *testing.B) {
ca := make(chan bool)
cb := make(chan bool)
defer close(ca)
go func() {
defer close(cb)
for range ca {
cb <- true
}
}()
for i := 0; i < b.N; i++ {
ca <- true
<-cb
}
}
func BenchmarkSmallBufferedChannel(b *testing.B) {
ca := make(chan bool, 1)
cb := make(chan bool, 1)
defer close(ca)
go func() {
defer close(cb)
for range ca {
cb <- true
}
}()
for i := 0; i < b.N; i++ {
ca <- true
<-cb
}
}
func BenchmarkLargeBufferedChannel(b *testing.B) {
ca := make(chan bool, 1000)
cb := make(chan bool, 1000)
defer close(ca)
go func() {
defer close(cb)
for range ca {
cb <- true
}
}()
for i := 0; i < b.N; i++ {
ca <- true
<-cb
}
}
func BenchmarkEndpointFastHashShort(b *testing.B) {
e := Endpoint{typ: 1, len: 2}
for i := 0; i < b.N; i++ {
e.FastHash()
}
}
func BenchmarkEndpointFastHashLong(b *testing.B) {
e := Endpoint{typ: 1, len: 16}
for i := 0; i < b.N; i++ {
e.FastHash()
}
}
func BenchmarkFlowFastHashShort(b *testing.B) {
e := Flow{typ: 1, slen: 2, dlen: 2}
for i := 0; i < b.N; i++ {
e.FastHash()
}
}
func BenchmarkFlowFastHashLong(b *testing.B) {
e := Flow{typ: 1, slen: 16, dlen: 16}
for i := 0; i < b.N; i++ {
e.FastHash()
}
}
================================================
FILE: bsdbpf/bsd_bpf_sniffer.go
================================================
// Copyright 2012 Google, Inc. All rights reserved.
//
// Use of this source code is governed by a BSD-style license
// that can be found in the LICENSE file in the root of the source
// tree.
// +build darwin dragonfly freebsd netbsd openbsd
package bsdbpf
import (
"errors"
"fmt"
"syscall"
"time"
"unsafe"
"github.com/google/gopacket"
"golang.org/x/sys/unix"
)
const wordSize = int(unsafe.Sizeof(uintptr(0)))
func bpfWordAlign(x int) int {
return (((x) + (wordSize - 1)) &^ (wordSize - 1))
}
// Options is used to configure various properties of the BPF sniffer.
// Default values are used when a nil Options pointer is passed to NewBPFSniffer.
type Options struct {
// BPFDeviceName is name of the bpf device to use for sniffing
// the network device. The default value of BPFDeviceName is empty string
// which causes the first available BPF device file /dev/bpfX to be used.
BPFDeviceName string
// ReadBufLen specifies the size of the buffer used to read packets
// off the wire such that multiple packets are buffered with each read syscall.
// Note that an individual packet larger than the buffer size is necessarily truncated.
// A larger buffer should increase performance because fewer read syscalls would be made.
// If zero is used, the system's default buffer length will be used which depending on the
// system may default to 4096 bytes which is not big enough to accomodate some link layers
// such as WLAN (802.11).
// ReadBufLen defaults to 32767... however typical BSD manual pages for BPF indicate that
// if the requested buffer size cannot be accommodated, the closest allowable size will be
// set and returned... hence our GetReadBufLen method.
ReadBufLen int
// Timeout is the length of time to wait before timing out on a read request.
// Timeout defaults to nil which means no timeout is used.
Timeout *syscall.Timeval
// Promisc is set to true for promiscuous mode ethernet sniffing.
// Promisc defaults to true.
Promisc bool
// Immediate is set to true to make our read requests return as soon as a packet becomes available.
// Otherwise, a read will block until either the kernel buffer becomes full or a timeout occurs.
// The default is true.
Immediate bool
// PreserveLinkAddr is set to false if the link level source address should be filled in automatically
// by the interface output routine. Set to true if the link level source address will be written,
// as provided, to the wire.
// The default is true.
PreserveLinkAddr bool
}
var defaultOptions = Options{
BPFDeviceName: "",
ReadBufLen: 32767,
Timeout: nil,
Promisc: true,
Immediate: true,
PreserveLinkAddr: true,
}
// BPFSniffer is a struct used to track state of a BSD BPF ethernet sniffer
// such that gopacket's PacketDataSource interface is implemented.
type BPFSniffer struct {
options *Options
sniffDeviceName string
fd int
readBuffer []byte
lastReadLen int
readBytesConsumed int
}
// NewBPFSniffer is used to create BSD-only BPF ethernet sniffer
// iface is the network interface device name that you wish to sniff
// options can set to nil in order to utilize default values for everything.
// Each field of Options also have a default setting if left unspecified by
// the user's custome Options struct.
func NewBPFSniffer(iface string, options *Options) (*BPFSniffer, error) {
var err error
enable := 1
sniffer := BPFSniffer{
sniffDeviceName: iface,
}
if options == nil {
sniffer.options = &defaultOptions
} else {
sniffer.options = options
}
if sniffer.options.BPFDeviceName == "" {
sniffer.pickBpfDevice()
}
// setup our read buffer
if sniffer.options.ReadBufLen == 0 {
sniffer.options.ReadBufLen, err = syscall.BpfBuflen(sniffer.fd)
if err != nil {
return nil, err
}
} else {
sniffer.options.ReadBufLen, err = syscall.SetBpfBuflen(sniffer.fd, sniffer.options.ReadBufLen)
if err != nil {
return nil, err
}
}
sniffer.readBuffer = make([]byte, sniffer.options.ReadBufLen)
err = syscall.SetBpfInterface(sniffer.fd, sniffer.sniffDeviceName)
if err != nil {
return nil, err
}
if sniffer.options.Immediate {
// turn immediate mode on. This makes the snffer non-blocking.
err = syscall.SetBpfImmediate(sniffer.fd, enable)
if err != nil {
return nil, err
}
}
// the above call to syscall.SetBpfImmediate needs to be made
// before setting a timer otherwise the reads will block for the
// entire timer duration even if there are packets to return.
if sniffer.options.Timeout != nil {
err = syscall.SetBpfTimeout(sniffer.fd, sniffer.options.Timeout)
if err != nil {
return nil, err
}
}
if sniffer.options.PreserveLinkAddr {
// preserves the link level source address...
// higher level protocol analyzers will not need this
err = syscall.SetBpfHeadercmpl(sniffer.fd, enable)
if err != nil {
return nil, err
}
}
if sniffer.options.Promisc {
// forces the interface into promiscuous mode
err = syscall.SetBpfPromisc(sniffer.fd, enable)
if err != nil {
return nil, err
}
}
return &sniffer, nil
}
// Close is used to close the file-descriptor of the BPF device file.
func (b *BPFSniffer) Close() error {
return syscall.Close(b.fd)
}
func (b *BPFSniffer) pickBpfDevice() {
var err error
b.options.BPFDeviceName = ""
for i := 0; i < 99; i++ {
b.options.BPFDeviceName = fmt.Sprintf("/dev/bpf%d", i)
b.fd, err = syscall.Open(b.options.BPFDeviceName, syscall.O_RDWR, 0)
if err == nil {
return
}
}
panic("failed to acquire a BPF device for read-write access")
}
func (b *BPFSniffer) ReadPacketData() ([]byte, gopacket.CaptureInfo, error) {
var err error
if b.readBytesConsumed >= b.lastReadLen {
b.readBytesConsumed = 0
b.readBuffer = make([]byte, b.options.ReadBufLen)
b.lastReadLen, err = syscall.Read(b.fd, b.readBuffer)
if err != nil {
b.lastReadLen = 0
return nil, gopacket.CaptureInfo{}, err
}
}
hdr := (*unix.BpfHdr)(unsafe.Pointer(&b.readBuffer[b.readBytesConsumed]))
frameStart := b.readBytesConsumed + int(hdr.Hdrlen)
b.readBytesConsumed += bpfWordAlign(int(hdr.Hdrlen) + int(hdr.Caplen))
if frameStart+int(hdr.Caplen) > len(b.readBuffer) {
captureInfo := gopacket.CaptureInfo{
Timestamp: time.Unix(int64(hdr.Tstamp.Sec), int64(hdr.Tstamp.Usec)*1000),
CaptureLength: 0,
Length: 0,
}
return nil, captureInfo, errors.New("BPF captured frame received with corrupted BpfHdr struct.")
}
rawFrame := b.readBuffer[frameStart : frameStart+int(hdr.Caplen)]
captureInfo := gopacket.CaptureInfo{
Timestamp: time.Unix(int64(hdr.Tstamp.Sec), int64(hdr.Tstamp.Usec)*1000),
CaptureLength: len(rawFrame),
Length: len(rawFrame),
}
return rawFrame, captureInfo, nil
}
// GetReadBufLen returns the BPF read buffer length
func (b *BPFSniffer) GetReadBufLen() int {
return b.options.ReadBufLen
}
================================================
FILE: bytediff/bytediff.go
================================================
// Copyright 2012 Google, Inc. All rights reserved.
//
// Use of this source code is governed by a BSD-style license
// that can be found in the LICENSE file in the root of the source
// tree.
// Package bytediff provides a simple diff utility for looking at differences in byte
// slices. It's slow, clunky, and not particularly good by any measure, but
// it does provide very useful visualizations for diffs between small byte
// slices.
//
// Our diff algorithm uses a dynamic programming implementation of longest common
// substring to find matching parts of slices, then recursively calls itself on
// the prefix/suffix of that matching part for each packet. This is a Bad Idea
// (tm) for normal (especially large) input, but for packets where large portions
// repeat frequently and we expect minor changes between results, it's actually
// quite useful.
package bytediff
import (
"bytes"
"fmt"
)
// OutputFormat tells a Differences.String call how to format the set of
// differences into a human-readable string. Its internals are currently
// unexported because we may want to change them drastically in the future. For
// the moment, please just use one of the provided OutputFormats that comes with
// this library.
type OutputFormat struct {
start, finish, add, remove, change, reset string
}
var (
// BashOutput uses bash escape sequences to color output.
BashOutput = &OutputFormat{
reset: "\033[0m",
remove: "\033[32m",
add: "\033[31m",
change: "\033[33m",
}
// HTMLOutput uses a <pre> to wrap output, and <span>s to color it.
// HTMLOutput is pretty experimental, so use at your own risk ;)
HTMLOutput = &OutputFormat{
start: "<pre>",
finish: "</pre>",
reset: "</span>",
remove: "<span style='color:red'>",
add: "<span style='color:green'>",
change: "<span style='color:yellow'>",
}
)
// longestCommonSubstring uses a O(MN) dynamic programming approach to find the
// longest common substring in a set of slices. It returns the index in each
// slice at which the substring begins, plus the length of the commonality.
func longestCommonSubstring(strA, strB []byte) (indexA, indexB, length int) {
lenA, lenB := len(strA), len(strB)
if lenA == 0 || lenB == 0 {
return 0, 0, 0
}
arr := make([][]int, lenA)
for i := 0; i < lenA; i++ {
arr[i] = make([]int, lenB)
}
var maxLength int
var maxA, maxB int
for a := 0; a < lenA; a++ {
for b := 0; b < lenB; b++ {
if strA[a] == strB[b] {
length := 1
if a > 0 && b > 0 {
length = arr[a-1][b-1] + 1
}
arr[a][b] = length
if length > maxLength {
maxLength = length
maxA = a
maxB = b
}
}
}
}
a, b := maxA, maxB
for a >= 0 && b >= 0 && strA[a] == strB[b] {
indexA = a
indexB = b
a--
b--
length++
}
return
}
// Difference represents a single part of the data being diffed, containing
// information about both the original and new values.
// From and To are the sets of bytes in the original and the new byte slice.
// !Replace implies From == To (no change)
// len(To) == 0 implies From is being deleted
// len(From) == 0 implies To is being inserted
// else implies From is being replaced by To
type Difference struct {
Replace bool
From, To []byte
}
// color returns the bash color for a given difference.
func (c *OutputFormat) color(d Difference) string {
switch {
case !d.Replace:
return ""
case len(d.From) == 0:
return c.remove
case len(d.To) == 0:
return c.add
default:
return c.change
}
}
// Diff diffs strA and strB, returning a list of differences which
// can be used to construct either the original or new string.
//
// Diff is optimized for comparing VERY SHORT slices. It's meant for comparing
// things like packets off the wire, not large files or the like.
// As such, its runtime can be catastrophic if large inputs are passed in.
// You've been warned.
func Diff(strA, strB []byte) Differences {
if len(strA) == 0 && len(strB) == 0 {
return nil
}
ia, ib, l := longestCommonSubstring(strA, strB)
if l == 0 {
return Differences{
Difference{true, strA, strB},
}
}
beforeA, match, afterA := strA[:ia], strA[ia:ia+l], strA[ia+l:]
beforeB, afterB := strB[:ib], strB[ib+l:]
var diffs Differences
diffs = append(diffs, Diff(beforeA, beforeB)...)
diffs = append(diffs, Difference{false, match, match})
diffs = append(diffs, Diff(afterA, afterB)...)
return diffs
}
// Differences is a set of differences for a given diff'd pair of byte slices.
type Differences []Difference
// String outputs a previously diff'd set of strings, showing differences
// between them, highlighted by colors.
//
// The output format of this function is NOT guaranteed consistent, and may be
// changed at any time by the library authors. It's meant solely for human
// consumption.
func (c *OutputFormat) String(diffs Differences) string {
var buf bytes.Buffer
count := 0
fmt.Fprintf(&buf, "%s", c.start)
fmt.Fprintf(&buf, "00000000 ")
for i := 0; i < len(diffs); i++ {
diff := diffs[i]
color := c.color(diff)
reset := ""
if color != "" {
reset = c.reset
}
fmt.Fprint(&buf, color)
for _, b := range diff.From {
fmt.Fprintf(&buf, " %02x", b)
count++
switch count % 16 {
case 0:
fmt.Fprintf(&buf, "%v\n%08x%v ", reset, count, color)
case 8:
fmt.Fprintf(&buf, " ")
}
}
fmt.Fprint(&buf, reset)
}
fmt.Fprintf(&buf, "\n\n00000000 ")
count = 0
for i := 0; i < len(diffs); i++ {
diff := diffs[i]
str := diff.From
if diff.Replace {
str = diff.To
}
color := c.color(diff)
reset := ""
if color != "" {
reset = c.reset
}
fmt.Fprint(&buf, color)
for _, b := range str {
fmt.Fprintf(&buf, " %02x", b)
count++
switch count % 16 {
case 0:
fmt.Fprintf(&buf, "%v\n%08x%v ", reset, count, color)
case 8:
fmt.Fprintf(&buf, " ")
}
}
fmt.Fprint(&buf, reset)
}
fmt.Fprint(&buf, "\n")
fmt.Fprintf(&buf, "%s", c.finish)
return buf.String()
}
================================================
FILE: bytediff/bytediff_test.go
================================================
// Copyright 2012 Google, Inc. All rights reserved.
//
// Use of this source code is governed by a BSD-style license
// that can be found in the LICENSE file in the root of the source
// tree.
package bytediff
import (
"reflect"
"testing"
)
func TestLCS(t *testing.T) {
for i, test := range []struct {
a, b []byte
indexA, indexB, length int
}{
{[]byte{1, 2, 3}, []byte{1, 2, 3}, 0, 0, 3},
{[]byte{0, 1, 2, 3}, []byte{1, 2, 3, 4}, 1, 0, 3},
{[]byte{0, 1, 2, 3, 1, 2, 3, 4, 1, 2, 3}, []byte{1, 2, 3, 4}, 4, 0, 4},
{[]byte{1, 2, 2, 3, 4}, []byte{1, 2, 3, 4}, 2, 1, 3},
{[]byte{0, 1, 2, 3, 4}, []byte{1, 1, 2, 2, 3, 4}, 2, 3, 3},
} {
ia, ib, l := longestCommonSubstring(test.a, test.b)
if ia != test.indexA || ib != test.indexB || l != test.length {
t.Errorf("%d: want (%d %d %d) got (%d %d %d)", i, test.indexA, test.indexB, test.length, ia, ib, l)
}
}
}
func TestDiff(t *testing.T) {
for i, test := range []struct {
a, b []byte
d Differences
}{
{
[]byte{0, 1, 2, 3, 4},
[]byte{1, 1, 2, 2, 3, 4},
Differences{
Difference{true, []byte{0}, []byte{}},
Difference{false, []byte{1}, []byte{1}},
Difference{true, []byte{}, []byte{1, 2}},
Difference{false, []byte{2, 3, 4}, []byte{2, 3, 4}},
},
},
} {
diffs := Diff(test.a, test.b)
if !reflect.DeepEqual(diffs, test.d) {
t.Errorf("%d want %v got %v", i, test.d, diffs)
}
}
}
================================================
FILE: decode.go
================================================
// Copyright 2012 Google, Inc. All rights reserved.
//
// Use of this source code is governed by a BSD-style license
// that can be found in the LICENSE file in the root of the source
// tree.
package gopacket
import (
"errors"
)
// DecodeFeedback is used by DecodingLayer layers to provide decoding metadata.
type DecodeFeedback interface {
// SetTruncated should be called if during decoding you notice that a packet
// is shorter than internal layer variables (HeaderLength, or the like) say it
// should be. It sets packet.Metadata().Truncated.
SetTruncated()
}
type nilDecodeFeedback struct{}
func (nilDecodeFeedback) SetTruncated() {}
// NilDecodeFeedback implements DecodeFeedback by doing nothing.
var NilDecodeFeedback DecodeFeedback = nilDecodeFeedback{}
// PacketBuilder is used by layer decoders to store the layers they've decoded,
// and to defer future decoding via NextDecoder.
// Typically, the pattern for use is:
// func (m *myDecoder) Decode(data []byte, p PacketBuilder) error {
// if myLayer, err := myDecodingLogic(data); err != nil {
// return err
// } else {
// p.AddLayer(myLayer)
// }
// // maybe do this, if myLayer is a LinkLayer
// p.SetLinkLayer(myLayer)
// return p.NextDecoder(nextDecoder)
// }
type PacketBuilder interface {
DecodeFeedback
// AddLayer should be called by a decoder immediately upon successful
// decoding of a layer.
AddLayer(l Layer)
// The following functions set the various specific layers in the final
// packet. Note that if many layers call SetX, the first call is kept and all
// other calls are ignored.
SetLinkLayer(LinkLayer)
SetNetworkLayer(NetworkLayer)
SetTransportLayer(TransportLayer)
SetApplicationLayer(ApplicationLayer)
SetErrorLayer(ErrorLayer)
// NextDecoder should be called by a decoder when they're done decoding a
// packet layer but not done with decoding the entire packet. The next
// decoder will be called to decode the last AddLayer's LayerPayload.
// Because of this, NextDecoder must only be called once all other
// PacketBuilder calls have been made. Set*Layer and AddLayer calls after
// NextDecoder calls will behave incorrectly.
NextDecoder(next Decoder) error
// DumpPacketData is used solely for decoding. If you come across an error
// you need to diagnose while processing a packet, call this and your packet's
// data will be dumped to stderr so you can create a test. This should never
// be called from a production decoder.
DumpPacketData()
// DecodeOptions returns the decode options
DecodeOptions() *DecodeOptions
}
// Decoder is an interface for logic to decode a packet layer. Users may
// implement a Decoder to handle their own strange packet types, or may use one
// of the many decoders available in the 'layers' subpackage to decode things
// for them.
type Decoder interface {
// Decode decodes the bytes of a packet, sending decoded values and other
// information to PacketBuilder, and returning an error if unsuccessful. See
// the PacketBuilder documentation for more details.
Decode([]byte, PacketBuilder) error
}
// DecodeFunc wraps a function to make it a Decoder.
type DecodeFunc func([]byte, PacketBuilder) error
// Decode implements Decoder by calling itself.
func (d DecodeFunc) Decode(data []byte, p PacketBuilder) error {
// function, call thyself.
return d(data, p)
}
// DecodePayload is a Decoder that returns a Payload layer containing all
// remaining bytes.
var DecodePayload Decoder = DecodeFunc(decodePayload)
// DecodeUnknown is a Decoder that returns an Unknown layer containing all
// remaining bytes, useful if you run up against a layer that you're unable to
// decode yet. This layer is considered an ErrorLayer.
var DecodeUnknown Decoder = DecodeFunc(decodeUnknown)
// DecodeFragment is a Decoder that returns a Fragment layer containing all
// remaining bytes.
var DecodeFragment Decoder = DecodeFunc(decodeFragment)
// LayerTypeZero is an invalid layer type, but can be used to determine whether
// layer type has actually been set correctly.
var LayerTypeZero = RegisterLayerType(0, LayerTypeMetadata{Name: "Unknown", Decoder: DecodeUnknown})
// LayerTypeDecodeFailure is the layer type for the default error layer.
var LayerTypeDecodeFailure = RegisterLayerType(1, LayerTypeMetadata{Name: "DecodeFailure", Decoder: DecodeUnknown})
// LayerTypePayload is the layer type for a payload that we don't try to decode
// but treat as a success, IE: an application-level payload.
var LayerTypePayload = RegisterLayerType(2, LayerTypeMetadata{Name: "Payload", Decoder: DecodePayload})
// LayerTypeFragment is the layer type for a fragment of a layer transported
// by an underlying layer that supports fragmentation.
var LayerTypeFragment = RegisterLayerType(3, LayerTypeMetadata{Name: "Fragment", Decoder: DecodeFragment})
// DecodeFailure is a packet layer created if decoding of the packet data failed
// for some reason. It implements ErrorLayer. LayerContents will be the entire
// set of bytes that failed to parse, and Error will return the reason parsing
// failed.
type DecodeFailure struct {
data []byte
err error
stack []byte
}
// Error returns the error encountered during decoding.
func (d *DecodeFailure) Error() error { return d.err }
// LayerContents implements Layer.
func (d *DecodeFailure) LayerContents() []byte { return d.data }
// LayerPayload implements Layer.
func (d *DecodeFailure) LayerPayload() []byte { return nil }
// String implements fmt.Stringer.
func (d *DecodeFailure) String() string {
return "Packet decoding error: " + d.Error().Error()
}
// Dump implements Dumper.
func (d *DecodeFailure) Dump() (s string) {
if d.stack != nil {
s = string(d.stack)
}
return
}
// LayerType returns LayerTypeDecodeFailure
func (d *DecodeFailure) LayerType() LayerType { return LayerTypeDecodeFailure }
// decodeUnknown "decodes" unsupported data types by returning an error.
// This decoder will thus always return a DecodeFailure layer.
func decodeUnknown(data []byte, p PacketBuilder) error {
return errors.New("Layer type not currently supported")
}
================================================
FILE: defrag/lcmdefrag/lcmdefrag.go
================================================
// Copyright 2018 Google, Inc. All rights reserved.
//
// Use of this source code is governed by a BSD-style license
// that can be found in the LICENSE file in the root of the source
// tree.
// Package lcmdefrag contains a defragmenter for LCM messages.
package lcmdefrag
import (
"fmt"
"time"
"github.com/google/gopacket"
"github.com/google/gopacket/layers"
)
const (
// Packages are cleaned up/removed after no input was received for this
// amount of seconds.
timeout time.Duration = 3 * time.Second
)
type lcmPacket struct {
lastPacket time.Time
done bool
recFrags uint16
totalFrags uint16
frags map[uint16]*layers.LCM
}
// LCMDefragmenter supports defragmentation of LCM messages.
//
// References
// https://lcm-proj.github.io/
// https://github.com/lcm-proj/lcm
type LCMDefragmenter struct {
packets map[uint32]*lcmPacket
}
func newLCMPacket(totalFrags uint16) *lcmPacket {
return &lcmPacket{
done: false,
recFrags: 0,
totalFrags: totalFrags,
frags: make(map[uint16]*layers.LCM),
}
}
// NewLCMDefragmenter returns a new LCMDefragmenter.
func NewLCMDefragmenter() *LCMDefragmenter {
return &LCMDefragmenter{
packets: make(map[uint32]*lcmPacket),
}
}
func (lp *lcmPacket) append(in *layers.LCM) {
lp.frags[in.FragmentNumber] = in
lp.recFrags++
lp.lastPacket = time.Now()
}
func (lp *lcmPacket) assemble() (out *layers.LCM, err error) {
var blob []byte
//Extract packets
for i := uint16(0); i < lp.totalFrags; i++ {
fragment, ok := lp.frags[i]
if !ok {
err = fmt.Errorf("Tried to defragment incomplete packet. Waiting "+
"for more potential (unordered) packets... %d", i)
return
}
// For the very first packet, we also want the header.
if i == 0 {
blob = append(blob, fragment.LayerContents()...)
}
// Append the data for each packet.
blob = append(blob, fragment.Payload()...)
}
packet := gopacket.NewPacket(blob, layers.LayerTypeLCM, gopacket.NoCopy)
lcmHdrLayer := packet.Layer(layers.LayerTypeLCM)
out, ok := lcmHdrLayer.(*layers.LCM)
if !ok {
err = fmt.Errorf("Error while decoding the defragmented packet. " +
"Erasing/dropping packet.")
}
lp.done = true
return
}
func (ld *LCMDefragmenter) cleanUp() {
for key, packet := range ld.packets {
if packet.done || time.Now().Sub(packet.lastPacket) > timeout {
delete(ld.packets, key)
}
}
}
// Defrag takes a reference to an LCM packet and processes it.
// In case the packet does not need to be defragmented, it immediately returns
// the as in passed reference. In case in was the last missing fragment, out
// will be the defragmented packet. If in was a fragment, but we are awaiting
// more, out will be set to nil.
// In the case that in was nil, we will just run the internal cleanup of the
// defragmenter that times out packages.
// If an error was encountered during defragmentation, out will also be nil,
// while err will contain further information on the failure.
func (ld *LCMDefragmenter) Defrag(in *layers.LCM) (out *layers.LCM, err error) {
// Timeout old packages and erase error prone ones.
ld.cleanUp()
// For running cleanup only
if in == nil {
return
}
// Quick check if this is acutally a single packet. In that case, just
// return it quickly.
if !in.Fragmented {
out = in
return
}
// Do we need to start a new fragments obj?
if _, ok := ld.packets[in.SequenceNumber]; !ok {
ld.packets[in.SequenceNumber] = newLCMPacket(in.TotalFragments)
}
// Append the packet
ld.packets[in.SequenceNumber].append(in)
// Check if this is the last package of that series
if ld.packets[in.SequenceNumber].recFrags == in.TotalFragments {
out, err = ld.packets[in.SequenceNumber].assemble()
}
return
}
================================================
FILE: defrag/lcmdefrag/lcmdefrag_test.go
================================================
// Copyright 2018 Google, Inc. All rights reserved.
//
// Use of this source code is governed by a BSD-style license
// that can be found in the LICENSE file in the root of the source
// tree.
package lcmdefrag
import (
"testing"
"github.com/google/gopacket"
"github.com/google/gopacket/layers"
)
var (
fragmentOne = []byte{
0x4c, 0x43, 0x30, 0x33, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0d,
0x00, 0x00, 0x00, 0x2d, 0x00, 0x00, 0x00, 0x02, 0x4c, 0x43, 0x4d, 0x5f,
0x53, 0x45, 0x4c, 0x46, 0x5f, 0x54, 0x45, 0x53, 0x54, 0x00, 0x6c, 0x63,
0x6d, 0x20, 0x73, 0x65, 0x6c, 0x66, 0x20, 0x74, 0x65, 0x73, 0x74,
}
fragmentTwo = []byte{
0x4c, 0x43, 0x30, 0x33, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0d,
0x00, 0x00, 0x00, 0x2d, 0x00, 0x01, 0x00, 0x02, 0x6c, 0x63, 0x6d, 0x20,
0x73, 0x65, 0x6c, 0x66, 0x20, 0x74, 0x65, 0x73, 0x74,
}
completePacket = []byte{
0x4c, 0x43, 0x30, 0x32, 0x00, 0x00, 0x00, 0x00, 0x4c, 0x43, 0x4d, 0x5f,
0x53, 0x45, 0x4c, 0x46, 0x5f, 0x54, 0x45, 0x53, 0x54, 0x00, 0x6c, 0x63,
0x6d, 0x20, 0x73, 0x65, 0x6c, 0x66, 0x20, 0x74, 0x65, 0x73, 0x74,
}
)
func TestOrderedLCMDefrag(t *testing.T) {
defragmenter := NewLCMDefragmenter()
var err error
packet := gopacket.NewPacket(fragmentOne, layers.LayerTypeLCM, gopacket.NoCopy)
lcm := packet.Layer(layers.LayerTypeLCM).(*layers.LCM)
lcm, err = defragmenter.Defrag(lcm)
if lcm != nil {
t.Fatal("Returned incomplete LCM message.")
}
if err != nil {
t.Fatal(err)
}
packet = gopacket.NewPacket(fragmentTwo, layers.LayerTypeLCM, gopacket.NoCopy)
lcm = packet.Layer(layers.LayerTypeLCM).(*layers.LCM)
lcm, err = defragmenter.Defrag(lcm)
if lcm == nil {
t.Fatal("Did not receive defragmented LCM message.")
}
if err != nil {
t.Fatal(err)
}
}
func TestUnorderedLCMDefrag(t *testing.T) {
defragmenter := NewLCMDefragmenter()
var err error
packet := gopacket.NewPacket(fragmentTwo, layers.LayerTypeLCM, gopacket.NoCopy)
lcm := packet.Layer(layers.LayerTypeLCM).(*layers.LCM)
lcm, err = defragmenter.Defrag(lcm)
if lcm != nil {
t.Fatal("Returned incomplete LCM message.")
}
if err != nil {
t.Fatal(err)
}
packet = gopacket.NewPacket(fragmentOne, layers.LayerTypeLCM, gopacket.NoCopy)
lcm = packet.Layer(layers.LayerTypeLCM).(*layers.LCM)
lcm, err = defragmenter.Defrag(lcm)
if lcm == nil {
t.Fatal("Did not receive defragmented LCM message.")
}
if err != nil {
t.Fatal(err)
}
}
func TestNonLCMDefrag(t *testing.T) {
defragmenter := NewLCMDefragmenter()
var err error
packet := gopacket.NewPacket(completePacket, layers.LayerTypeLCM, gopacket.NoCopy)
lcm := packet.Layer(layers.LayerTypeLCM).(*layers.LCM)
lcm, err = defragmenter.Defrag(lcm)
if lcm == nil {
t.Fatal("Did not receive complete LCM message.")
}
if err != nil {
t.Fatal(err)
}
}
================================================
FILE: doc.go
================================================
// Copyright 2012 Google, Inc. All rights reserved.
//
// Use of this source code is governed by a BSD-style license
// that can be found in the LICENSE file in the root of the source
// tree.
/*
Package gopacket provides packet decoding for the Go language.
gopacket contains many sub-packages with additional functionality you may find
useful, including:
* layers: You'll probably use this every time. This contains of the logic
built into gopacket for decoding packet protocols. Note that all example
code below assumes that you have imported both gopacket and
gopacket/layers.
* pcap: C bindings to use libpcap to read packets off the wire.
* pfring: C bindings to use PF_RING to read packets off the wire.
* afpacket: C bindings for Linux's AF_PACKET to read packets off the wire.
* tcpassembly: TCP stream reassembly
Also, if you're looking to dive right into code, see the examples subdirectory
for numerous simple binaries built using gopacket libraries.
Minimum go version required is 1.5 except for pcapgo/EthernetHandle, afpacket,
and bsdbpf which need at least 1.7 due to x/sys/unix dependencies.
Basic Usage
gopacket takes in packet data as a []byte and decodes it into a packet with
a non-zero number of "layers". Each layer corresponds to a protocol
within the bytes. Once a packet has been decoded, the layers of the packet
can be requested from the packet.
// Decode a packet
packet := gopacket.NewPacket(myPacketData, layers.LayerTypeEthernet, gopacket.Default)
// Get the TCP layer from this packet
if tcpLayer := packet.Layer(layers.LayerTypeTCP); tcpLayer != nil {
fmt.Println("This is a TCP packet!")
// Get actual TCP data from this layer
tcp, _ := tcpLayer.(*layers.TCP)
fmt.Printf("From src port %d to dst port %d\n", tcp.SrcPort, tcp.DstPort)
}
// Iterate over all layers, printing out each layer type
for _, layer := range packet.Layers() {
fmt.Println("PACKET LAYER:", layer.LayerType())
}
Packets can be decoded from a number of starting points. Many of our base
types implement Decoder, which allow us to decode packets for which
we don't have full data.
// Decode an ethernet packet
ethP := gopacket.NewPacket(p1, layers.LayerTypeEthernet, gopacket.Default)
// Decode an IPv6 header and everything it contains
ipP := gopacket.NewPacket(p2, layers.LayerTypeIPv6, gopacket.Default)
// Decode a TCP header and its payload
tcpP := gopacket.NewPacket(p3, layers.LayerTypeTCP, gopacket.Default)
Reading Packets From A Source
Most of the time, you won't just have a []byte of packet data lying around.
Instead, you'll want to read packets in from somewhere (file, interface, etc)
and process them. To do that, you'll want to build a PacketSource.
First, you'll need to construct an object that implements the PacketDataSource
interface. There are implementations of this interface bundled with gopacket
in the gopacket/pcap and gopacket/pfring subpackages... see their documentation
for more information on their usage. Once you have a PacketDataSource, you can
pass it into NewPacketSource, along with a Decoder of your choice, to create
a PacketSource.
Once you have a PacketSource, you can read packets from it in multiple ways.
See the docs for PacketSource for more details. The easiest method is the
Packets function, which returns a channel, then asynchronously writes new
packets into that channel, closing the channel if the packetSource hits an
end-of-file.
packetSource := ... // construct using pcap or pfring
for packet := range packetSource.Packets() {
handlePacket(packet) // do something with each packet
}
You can change the decoding options of the packetSource by setting fields in
packetSource.DecodeOptions... see the following sections for more details.
Lazy Decoding
gopacket optionally decodes packet data lazily, meaning it
only decodes a packet layer when it needs to handle a function call.
// Create a packet, but don't actually decode anything yet
packet := gopacket.NewPacket(myPacketData, layers.LayerTypeEthernet, gopacket.Lazy)
// Now, decode the packet up to the first IPv4 layer found but no further.
// If no IPv4 layer was found, the whole packet will be decoded looking for
// it.
ip4 := packet.Layer(layers.LayerTypeIPv4)
// Decode all layers and return them. The layers up to the first IPv4 layer
// are already decoded, and will not require decoding a second time.
layers := packet.Layers()
Lazily-decoded packets are not concurrency-safe. Since layers have not all been
decoded, each call to Layer() or Layers() has the potential to mutate the packet
in order to decode the next layer. If a packet is used
in multiple goroutines concurrently, don't use gopacket.Lazy. Then gopacket
will decode the packet fully, and all future function calls won't mutate the
object.
NoCopy Decoding
By default, gopacket will copy the slice passed to NewPacket and store the
copy within the packet, so future mutations to the bytes underlying the slice
don't affect the packet and its layers. If you can guarantee that the
underlying slice bytes won't be changed, you can use NoCopy to tell
gopacket.NewPacket, and it'll use the passed-in slice itself.
// This channel returns new byte slices, each of which points to a new
// memory location that's guaranteed immutable for the duration of the
// packet.
for data := range myByteSliceChannel {
p := gopacket.NewPacket(data, layers.LayerTypeEthernet, gopacket.NoCopy)
doSomethingWithPacket(p)
}
The fastest method of decoding is to use both Lazy and NoCopy, but note from
the many caveats above that for some implementations either or both may be
dangerous.
Pointers To Known Layers
During decoding, certain layers are stored in the packet as well-known
layer types. For example, IPv4 and IPv6 are both considered NetworkLayer
layers, while TCP and UDP are both TransportLayer layers. We support 4
layers, corresponding to the 4 layers of the TCP/IP layering scheme (roughly
anagalous to layers 2, 3, 4, and 7 of the OSI model). To access these,
you can use the packet.LinkLayer, packet.NetworkLayer,
packet.TransportLayer, and packet.ApplicationLayer functions. Each of
these functions returns a corresponding interface
(gopacket.{Link,Network,Transport,Application}Layer). The first three
provide methods for getting src/dst addresses for that particular layer,
while the final layer provides a Payload function to get payload data.
This is helpful, for example, to get payloads for all packets regardless
of their underlying data type:
// Get packets from some source
for packet := range someSource {
if app := packet.ApplicationLayer(); app != nil {
if strings.Contains(string(app.Payload()), "magic string") {
fmt.Println("Found magic string in a packet!")
}
}
}
A particularly useful layer is ErrorLayer, which is set whenever there's
an error parsing part of the packet.
packet := gopacket.NewPacket(myPacketData, layers.LayerTypeEthernet, gopacket.Default)
if err := packet.ErrorLayer(); err != nil {
fmt.Println("Error decoding some part of the packet:", err)
}
Note that we don't return an error from NewPacket because we may have decoded
a number of layers successfully before running into our erroneous layer. You
may still be able to get your Ethernet and IPv4 layers correctly, even if
your TCP layer is malformed.
Flow And Endpoint
gopacket has two useful objects, Flow and Endpoint, for communicating in a protocol
independent manner the fact that a packet is coming from A and going to B.
The general layer types LinkLayer, NetworkLayer, and TransportLayer all provide
methods for extracting their flow information, without worrying about the type
of the underlying Layer.
A Flow is a simple object made up of a set of two Endpoints, one source and one
destination. It details the sender and receiver of the Layer of the Packet.
An Endpoint is a hashable representation of a source or destination. For
example, for LayerTypeIPv4, an Endpoint contains the IP address bytes for a v4
IP packet. A Flow can be broken into Endpoints, and Endpoints can be combined
into Flows:
packet := gopacket.NewPacket(myPacketData, layers.LayerTypeEthernet, gopacket.Lazy)
netFlow := packet.NetworkLayer().NetworkFlow()
src, dst := netFlow.Endpoints()
reverseFlow := gopacket.NewFlow(dst, src)
Both Endpoint and Flow objects can be used as map keys, and the equality
operator can compare them, so you can easily group together all packets
based on endpoint criteria:
flows := map[gopacket.Endpoint]chan gopacket.Packet
packet := gopacket.NewPacket(myPacketData, layers.LayerTypeEthernet, gopacket.Lazy)
// Send all TCP packets to channels based on their destination port.
if tcp := packet.Layer(layers.LayerTypeTCP); tcp != nil {
flows[tcp.TransportFlow().Dst()] <- packet
}
// Look for all packets with the same source and destination network address
if net := packet.NetworkLayer(); net != nil {
src, dst := net.NetworkFlow().Endpoints()
if src == dst {
fmt.Println("Fishy packet has same network source and dst: %s", src)
}
}
// Find all packets coming from UDP port 1000 to UDP port 500
interestingFlow := gopacket.FlowFromEndpoints(layers.NewUDPPortEndpoint(1000), layers.NewUDPPortEndpoint(500))
if t := packet.NetworkLayer(); t != nil && t.TransportFlow() == interestingFlow {
fmt.Println("Found that UDP flow I was looking for!")
}
For load-balancing purposes, both Flow and Endpoint have FastHash() functions,
which provide quick, non-cryptographic hashes of their contents. Of particular
importance is the fact that Flow FastHash() is symmetric: A->B will have the same
hash as B->A. An example usage could be:
channels := [8]chan gopacket.Packet
for i := 0; i < 8; i++ {
channels[i] = make(chan gopacket.Packet)
go packetHandler(channels[i])
}
for packet := range getPackets() {
if net := packet.NetworkLayer(); net != nil {
channels[int(net.NetworkFlow().FastHash()) & 0x7] <- packet
}
}
This allows us to split up a packet stream while still making sure that each
stream sees all packets for a flow (and its bidirectional opposite).
Implementing Your Own Decoder
If your network has some strange encapsulation, you can implement your own
decoder. In this example, we handle Ethernet packets which are encapsulated
in a 4-byte header.
// Create a layer type, should be unique and high, so it doesn't conflict,
// giving it a name and a decoder to use.
var MyLayerType = gopacket.RegisterLayerType(12345, gopacket.LayerTypeMetadata{Name: "MyLayerType", Decoder: gopacket.DecodeFunc(decodeMyLayer)})
// Implement my layer
type MyLayer struct {
StrangeHeader []byte
payload []byte
}
func (m MyLayer) LayerType() gopacket.LayerType { return MyLayerType }
func (m MyLayer) LayerContents() []byte { return m.StrangeHeader }
func (m MyLayer) LayerPayload() []byte { return m.payload }
// Now implement a decoder... this one strips off the first 4 bytes of the
// packet.
func decodeMyLayer(data []byte, p gopacket.PacketBuilder) error {
// Create my layer
p.AddLayer(&MyLayer{data[:4], data[4:]})
// Determine how to handle the rest of the packet
return p.NextDecoder(layers.LayerTypeEthernet)
}
// Finally, decode your packets:
p := gopacket.NewPacket(data, MyLayerType, gopacket.Lazy)
See the docs for Decoder and PacketBuilder for more details on how coding
decoders works, or look at RegisterLayerType and RegisterEndpointType to see how
to add layer/endpoint types to gopacket.
Fast Decoding With DecodingLayerParser
TLDR: DecodingLayerParser takes about 10% of the time as NewPacket to decode
packet data, but only for known packet stacks.
Basic decoding using gopacket.NewPacket or PacketSource.Packets is somewhat slow
due to its need to allocate a new packet and every respective layer. It's very
versatile and can handle all known layer types, but sometimes you really only
care about a specific set of layers regardless, so that versatility is wasted.
DecodingLayerParser avoids memory allocation altogether by decoding packet
layers directly into preallocated objects, which you can then reference to get
the packet's information. A quick example:
func main() {
var eth layers.Ethernet
var ip4 layers.IPv4
var ip6 layers.IPv6
var tcp layers.TCP
parser := gopacket.NewDecodingLayerParser(layers.LayerTypeEthernet, ð, &ip4, &ip6, &tcp)
decoded := []gopacket.LayerType{}
for packetData := range somehowGetPacketData() {
if err := parser.DecodeLayers(packetData, &decoded); err != nil {
fmt.Fprintf(os.Stderr, "Could not decode layers: %v\n", err)
continue
}
for _, layerType := range decoded {
switch layerType {
case layers.LayerTypeIPv6:
fmt.Println(" IP6 ", ip6.SrcIP, ip6.DstIP)
case layers.LayerTypeIPv4:
fmt.Println(" IP4 ", ip4.SrcIP, ip4.DstIP)
}
}
}
}
The important thing to note here is that the parser is modifying the passed in
layers (eth, ip4, ip6, tcp) instead of allocating new ones, thus greatly
speeding up the decoding process. It's even branching based on layer type...
it'll handle an (eth, ip4, tcp) or (eth, ip6, tcp) stack. However, it won't
handle any other type... since no other decoders were passed in, an (eth, ip4,
udp) stack will stop decoding after ip4, and only pass back [LayerTypeEthernet,
LayerTypeIPv4] through the 'decoded' slice (along with an error saying it can't
decode a UDP packet).
Unfortunately, not all layers can be used by DecodingLayerParser... only those
implementing the DecodingLayer interface are usable. Also, it's possible to
create DecodingLayers that are not themselves Layers... see
layers.IPv6ExtensionSkipper for an example of this.
Faster And Customized Decoding with DecodingLayerContainer
By default, DecodingLayerParser uses native map to store and search for a layer
to decode. Though being versatile, in some cases this solution may be not so
optimal. For example, if you have only few layers faster operations may be
provided by sparse array indexing or linear array scan.
To accomodate these scenarios, DecodingLayerContainer interface is introduced
along with its implementations: DecodingLayerSparse, DecodingLayerArray and
DecodingLayerMap. You can specify a container implementation to
DecodingLayerParser with SetDecodingLayerContainer method. Example:
dlp := gopacket.NewDecodingLayerParser(LayerTypeEthernet)
dlp.SetDecodingLayerContainer(gopacket.DecodingLayerSparse(nil))
var eth layers.Ethernet
dlp.AddDecodingLayer(ð)
// ... add layers and use DecodingLayerParser as usual...
To skip one level of indirection (though sacrificing some capabilities) you may
also use DecodingLayerContainer as a decoding tool as it is. In this case you have to
handle unknown layer types and layer panics by yourself. Example:
func main() {
var eth layers.Ethernet
var ip4 layers.IPv4
var ip6 layers.IPv6
var tcp layers.TCP
dlc := gopacket.DecodingLayerContainer(gopacket.DecodingLayerArray(nil))
dlc = dlc.Put(ð)
dlc = dlc.Put(&ip4)
dlc = dlc.Put(&ip6)
dlc = dlc.Put(&tcp)
// you may specify some meaningful DecodeFeedback
decoder := dlc.LayersDecoder(LayerTypeEthernet, gopacket.NilDecodeFeedback)
decoded := make([]gopacket.LayerType, 0, 20)
for packetData := range somehowGetPacketData() {
lt, err := decoder(packetData, &decoded)
if err != nil {
fmt.Fprintf(os.Stderr, "Could not decode layers: %v\n", err)
continue
}
if lt != gopacket.LayerTypeZero {
fmt.Fprintf(os.Stderr, "unknown layer type: %v\n", lt)
continue
}
for _, layerType := range decoded {
// examine decoded layertypes just as already shown above
}
}
}
DecodingLayerSparse is the fastest but most effective when LayerType values
that layers in use can decode are not large because otherwise that would lead
to bigger memory footprint. DecodingLayerArray is very compact and primarily
usable if the number of decoding layers is not big (up to ~10-15, but please do
your own benchmarks). DecodingLayerMap is the most versatile one and used by
DecodingLayerParser by default. Please refer to tests and benchmarks in layers
subpackage to further examine usage examples and performance measurements.
You may also choose to implement your own DecodingLayerContainer if you want to
make use of your own internal packet decoding logic.
Creating Packet Data
As well as offering the ability to decode packet data, gopacket will allow you
to create packets from scratch, as well. A number of gopacket layers implement
the SerializableLayer interface; these layers can be serialized to a []byte in
the following manner:
ip := &layers.IPv4{
SrcIP: net.IP{1, 2, 3, 4},
DstIP: net.IP{5, 6, 7, 8},
// etc...
}
buf := gopacket.NewSerializeBuffer()
opts := gopacket.SerializeOptions{} // See SerializeOptions for more details.
err := ip.SerializeTo(buf, opts)
if err != nil { panic(err) }
fmt.Println(buf.Bytes()) // prints out a byte slice containing the serialized IPv4 layer.
SerializeTo PREPENDS the given layer onto the SerializeBuffer, and they treat
the current buffer's Bytes() slice as the payload of the serializing layer.
Therefore, you can serialize an entire packet by serializing a set of layers in
reverse order (Payload, then TCP, then IP, then Ethernet, for example). The
SerializeBuffer's SerializeLayers function is a helper that does exactly that.
To generate a (empty and useless, because no fields are set)
Ethernet(IPv4(TCP(Payload))) packet, for example, you can run:
buf := gopacket.NewSerializeBuffer()
opts := gopacket.SerializeOptions{}
gopacket.SerializeLayers(buf, opts,
&layers.Ethernet{},
&layers.IPv4{},
&layers.TCP{},
gopacket.Payload([]byte{1, 2, 3, 4}))
packetData := buf.Bytes()
A Final Note
If you use gopacket, you'll almost definitely want to make sure gopacket/layers
is imported, since when imported it sets all the LayerType variables and fills
in a lot of interesting variables/maps (DecodersByLayerName, etc). Therefore,
it's recommended that even if you don't use any layers functions directly, you still import with:
import (
_ "github.com/google/gopacket/layers"
)
*/
package gopacket
================================================
FILE: dumpcommand/tcpdump.go
================================================
// Copyright 2012 Google, Inc. All rights reserved.
//
// Use of this source code is governed by a BSD-style license
// that can be found in the LICENSE file in the root of the source
// tree.
// Package dumpcommand implements a run function for pfdump and pcapdump
// with many similar flags/features to tcpdump. This code is split out seperate
// from data sources (pcap/pfring) so it can be used by both.
package dumpcommand
import (
"flag"
"fmt"
"log"
"os"
"time"
"github.com/google/gopacket"
"github.com/google/gopacket/ip4defrag"
"github.com/google/gopacket/layers" // pulls in all layers decoders
)
var (
print = flag.Bool("print", true, "Print out packets, if false only prints out statistics")
maxcount = flag.Int("c", -1, "Only grab this many packets, then exit")
decoder = flag.String("decoder", "Ethernet", "Name of the decoder to use")
dump = flag.Bool("X", false, "If true, dump very verbose info on each packet")
statsevery = flag.Int("stats", 1000, "Output statistics every N packets")
printErrors = flag.Bool("errors", false, "Print out packet dumps of decode errors, useful for checking decoders against live traffic")
lazy = flag.Bool("lazy", false, "If true, do lazy decoding")
defrag = flag.Bool("defrag", false, "If true, do IPv4 defrag")
)
func Run(src gopacket.PacketDataSource) {
if !flag.Parsed() {
log.Fatalln("Run called without flags.Parse() being called")
}
var dec gopacket.Decoder
var ok bool
if dec, ok = gopacket.DecodersByLayerName[*decoder]; !ok {
log.Fatalln("No decoder named", *decoder)
}
source := gopacket.NewPacketSource(src, dec)
source.Lazy = *lazy
source.NoCopy = true
source.DecodeStreamsAsDatagrams = true
fmt.Fprintln(os.Stderr, "Starting to read packets")
count := 0
bytes := int64(0)
start := time.Now()
errors := 0
truncated := 0
layertypes := map[gopacket.LayerType]int{}
defragger := ip4defrag.NewIPv4Defragmenter()
for packet := range source.Packets() {
count++
bytes += int64(len(packet.Data()))
// defrag the IPv4 packet if required
if *defrag {
ip4Layer := packet.Layer(layers.LayerTypeIPv4)
if ip4Layer == nil {
continue
}
ip4 := ip4Layer.(*layers.IPv4)
l := ip4.Length
newip4, err := defragger.DefragIPv4(ip4)
if err != nil {
log.Fatalln("Error while de-fragmenting", err)
} else if newip4 == nil {
continue // packet fragment, we don't have whole packet yet.
}
if newip4.Length != l {
fmt.Printf("Decoding re-assembled packet: %s\n", newip4.NextLayerType())
pb, ok := packet.(gopacket.PacketBuilder)
if !ok {
panic("Not a PacketBuilder")
}
nextDecoder := newip4.NextLayerType()
nextDecoder.Decode(newip4.Payload, pb)
}
}
if *dump {
fmt.Println(packet.Dump())
} else if *print {
fmt.Println(packet)
}
if !*lazy || *print || *dump { // if we've already decoded all layers...
for _, layer := range packet.Layers() {
layertypes[layer.LayerType()]++
}
if packet.Metadata().Truncated {
truncated++
}
if errLayer := packet.ErrorLayer(); errLayer != nil {
errors++
if *printErrors {
fmt.Println("Error:", errLayer.Error())
fmt.Println("--- Packet ---")
fmt.Println(packet.Dump())
}
}
}
done := *maxcount > 0 && count >= *maxcount
if count%*statsevery == 0 || done {
fmt.Fprintf(os.Stderr, "Processed %v packets (%v bytes) in %v, %v errors and %v truncated packets\n", count, bytes, time.Since(start), errors, truncated)
if len(layertypes) > 0 {
fmt.Fprintf(os.Stderr, "Layer types seen: %+v\n", layertypes)
}
}
if done {
break
}
}
}
================================================
FILE: examples/afpacket/afpacket.go
================================================
// Copyright 2018 Google, Inc. All rights reserved.
//
// Use of this source code is governed by a BSD-style license
// that can be found in the LICENSE file in the root of the source
// tree.
// afpacket provides a simple example of using afpacket with zero-copy to read
// packet data.
package main
import (
"flag"
"fmt"
"log"
"os"
"runtime/pprof"
"time"
"github.com/google/gopacket"
"github.com/google/gopacket/afpacket"
"github.com/google/gopacket/layers"
"github.com/google/gopacket/pcap"
"golang.org/x/net/bpf"
_ "github.com/google/gopacket/layers"
)
var (
iface = flag.String("i", "any", "Interface to read from")
cpuprofile = flag.String("cpuprofile", "", "If non-empty, write CPU profile here")
snaplen = flag.Int("s", 0, "Snaplen, if <= 0, use 65535")
bufferSize = flag.Int("b", 8, "Interface buffersize (MB)")
filter = flag.String("f", "port not 22", "BPF filter")
count = flag.Int64("c", -1, "If >= 0, # of packets to capture before returning")
verbose = flag.Int64("log_every", 1, "Write a log every X packets")
addVLAN = flag.Bool("add_vlan", false, "If true, add VLAN header")
)
type afpacketHandle struct {
TPacket *afpacket.TPacket
}
func newAfpacketHandle(device string, snaplen int, block_size int, num_blocks int,
useVLAN bool, timeout time.Duration) (*afpacketHandle, error) {
h := &afpacketHandle{}
var err error
if device == "any" {
h.TPacket, err = afpacket.NewTPacket(
afpacket.OptFrameSize(snaplen),
afpacket.OptBlockSize(block_size),
afpacket.OptNumBlocks(num_blocks),
afpacket.OptAddVLANHeader(useVLAN),
afpacket.OptPollTimeout(timeout),
afpacket.SocketRaw,
afpacket.TPacketVersion3)
} else {
h.TPacket, err = afpacket.NewTPacket(
afpacket.OptInterface(device),
afpacket.OptFrameSize(snaplen),
afpacket.OptBlockSize(block_size),
afpacket.OptNumBlocks(num_blocks),
afpacket.OptAddVLANHeader(useVLAN),
afpacket.OptPollTimeout(timeout),
afpacket.SocketRaw,
afpacket.TPacketVersion3)
}
return h, err
}
// ZeroCopyReadPacketData satisfies ZeroCopyPacketDataSource interface
func (h *afpacketHandle) ZeroCopyReadPacketData() (data []byte, ci gopacket.CaptureInfo, err error) {
return h.TPacket.ZeroCopyReadPacketData()
}
// SetBPFFilter translates a BPF filter string into BPF RawInstruction and applies them.
func (h *afpacketHandle) SetBPFFilter(filter string, snaplen int) (err error) {
pcapBPF, err := pcap.CompileBPFFilter(layers.LinkTypeEthernet, snaplen, filter)
if err != nil {
return err
}
bpfIns := []bpf.RawInstruction{}
for _, ins := range pcapBPF {
bpfIns2 := bpf.RawInstruction{
Op: ins.Code,
Jt: ins.Jt,
Jf: ins.Jf,
K: ins.K,
}
bpfIns = append(bpfIns, bpfIns2)
}
if h.TPacket.SetBPF(bpfIns); err != nil {
return err
}
return h.TPacket.SetBPF(bpfIns)
}
// LinkType returns ethernet link type.
func (h *afpacketHandle) LinkType() layers.LinkType {
return layers.LinkTypeEthernet
}
// Close will close afpacket source.
func (h *afpacketHandle) Close() {
h.TPacket.Close()
}
// SocketStats prints received, dropped, queue-freeze packet stats.
func (h *afpacketHandle) SocketStats() (as afpacket.SocketStats, asv afpacket.SocketStatsV3, err error) {
return h.TPacket.SocketStats()
}
// afpacketComputeSize computes the block_size and the num_blocks in such a way that the
// allocated mmap buffer is close to but smaller than target_size_mb.
// The restriction is that the block_size must be divisible by both the
// frame size and page size.
func afpacketComputeSize(targetSizeMb int, snaplen int, pageSize int) (
frameSize int, blockSize int, numBlocks int, err error) {
if snaplen < pageSize {
frameSize = pageSize / (pageSize / snaplen)
} else {
frameSize = (snaplen/pageSize + 1) * pageSize
}
// 128 is the default from the gopacket library so just use that
blockSize = frameSize * 128
numBlocks = (targetSizeMb * 1024 * 1024) / blockSize
if numBlocks == 0 {
return 0, 0, 0, fmt.Errorf("Interface buffersize is too small")
}
return frameSize, blockSize, numBlocks, nil
}
func main() {
flag.Parse()
if *cpuprofile != "" {
log.Printf("Writing CPU profile to %q", *cpuprofile)
f, err := os.Create(*cpuprofile)
if err != nil {
log.Fatal(err)
}
if err := pprof.StartCPUProfile(f); err != nil {
log.Fatal(err)
}
defer pprof.StopCPUProfile()
}
log.Printf("Starting on interface %q", *iface)
if *snaplen <= 0 {
*snaplen = 65535
}
szFrame, szBlock, numBlocks, err := afpacketComputeSize(*bufferSize, *snaplen, os.Getpagesize())
if err != nil {
log.Fatal(err)
}
afpacketHandle, err := newAfpacketHandle(*iface, szFrame, szBlock, numBlocks, *addVLAN, pcap.BlockForever)
if err != nil {
log.Fatal(err)
}
err = afpacketHandle.SetBPFFilter(*filter, *snaplen)
if err != nil {
log.Fatal(err)
}
source := gopacket.ZeroCopyPacketDataSource(afpacketHandle)
defer afpacketHandle.Close()
bytes := uint64(0)
packets := uint64(0)
for ; *count != 0; *count-- {
data, _, err := source.ZeroCopyReadPacketData()
if err != nil {
log.Fatal(err)
}
bytes += uint64(len(data))
packets++
if *count%*verbose == 0 {
_, afpacketStats, err := afpacketHandle.SocketStats()
if err != nil {
log.Println(err)
}
log.Printf("Read in %d bytes in %d packets", bytes, packets)
log.Printf("Stats {received dropped queue-freeze}: %d", afpacketStats)
}
}
}
================================================
FILE: examples/arpscan/arpscan.go
================================================
// Copyright 2012 Google, Inc. All rights reserved.
//
// Use of this source code is governed by a BSD-style license
// that can be found in the LICENSE file in the root of the source
// tree.
// arpscan implements ARP scanning of all interfaces' local networks using
// gopacket and its subpackages. This example shows, among other things:
// * Generating and sending packet data
// * Reading in packet data and interpreting it
// * Use of the 'pcap' subpackage for reading/writing
package main
import (
"bytes"
"encoding/binary"
"errors"
"log"
"net"
"sync"
"time"
"github.com/google/gopacket"
"github.com/google/gopacket/layers"
"github.com/google/gopacket/pcap"
)
func main() {
// Get a list of all interfaces.
ifaces, err := net.Interfaces()
if err != nil {
panic(err)
}
var wg sync.WaitGroup
for _, iface := range ifaces {
wg.Add(1)
// Start up a scan on each interface.
go func(iface net.Interface) {
defer wg.Done()
if err := scan(&iface); err != nil {
log.Printf("interface %v: %v", iface.Name, err)
}
}(iface)
}
// Wait for all interfaces' scans to complete. They'll try to run
// forever, but will stop on an error, so if we get past this Wait
// it means all attempts to write have failed.
wg.Wait()
}
// scan scans an individual interface's local network for machines using ARP requests/replies.
//
// scan loops forever, sending packets out regularly. It returns an error if
// it's ever unable to write a packet.
func scan(iface *net.Interface) error {
// We just look for IPv4 addresses, so try to find if the interface has one.
var addr *net.IPNet
if addrs, err := iface.Addrs(); err != nil {
return err
} else {
for _, a := range addrs {
if ipnet, ok := a.(*net.IPNet); ok {
if ip4 := ipnet.IP.To4(); ip4 != nil {
addr = &net.IPNet{
IP: ip4,
Mask: ipnet.Mask[len(ipnet.Mask)-4:],
}
break
}
}
}
}
// Sanity-check that the interface has a good address.
if addr == nil {
return errors.New("no good IP network found")
} else if addr.IP[0] == 127 {
return errors.New("skipping localhost")
} else if addr.Mask[0] != 0xff || addr.Mask[1] != 0xff {
return errors.New("mask means network is too large")
}
log.Printf("Using network range %v for interface %v", addr, iface.Name)
// Open up a pcap handle for packet reads/writes.
handle, err := pcap.OpenLive(iface.Name, 65536, true, pcap.BlockForever)
if err != nil {
return err
}
defer handle.Close()
// Start up a goroutine to read in packet data.
stop := make(chan struct{})
go readARP(handle, iface, stop)
defer close(stop)
for {
// Write our scan packets out to the handle.
if err := writeARP(handle, iface, addr); err != nil {
log.Printf("error writing packets on %v: %v", iface.Name, err)
return err
}
// We don't know exactly how long it'll take for packets to be
// sent back to us, but 10 seconds should be more than enough
// time ;)
time.Sleep(10 * time.Second)
}
}
// readARP watches a handle for incoming ARP responses we might care about, and prints them.
//
// readARP loops until 'stop' is closed.
func readARP(handle *pcap.Handle, iface *net.Interface, stop chan struct{}) {
src := gopacket.NewPacketSource(handle, layers.LayerTypeEthernet)
in := src.Packets()
for {
var packet gopacket.Packet
select {
case <-stop:
return
case packet = <-in:
arpLayer := packet.Layer(layers.LayerTypeARP)
if arpLayer == nil {
continue
}
arp := arpLayer.(*layers.ARP)
if arp.Operation != layers.ARPReply || bytes.Equal([]byte(iface.HardwareAddr), arp.SourceHwAddress) {
// This is a packet I sent.
continue
}
// Note: we might get some packets here that aren't responses to ones we've sent,
// if for example someone else sends US an ARP request. Doesn't much matter, though...
// all information is good information :)
log.Printf("IP %v is at %v", net.IP(arp.SourceProtAddress), net.HardwareAddr(arp.SourceHwAddress))
}
}
}
// writeARP writes an ARP request for each address on our local network to the
// pcap handle.
func writeARP(handle *pcap.Handle, iface *net.Interface, addr *net.IPNet) error {
// Set up all the layers' fields we can.
eth := layers.Ethernet{
SrcMAC: iface.HardwareAddr,
DstMAC: net.HardwareAddr{0xff, 0xff, 0xff, 0xff, 0xff, 0xff},
EthernetType: layers.EthernetTypeARP,
}
arp := layers.ARP{
AddrType: layers.LinkTypeEthernet,
Protocol: layers.EthernetTypeIPv4,
HwAddressSize: 6,
ProtAddressSize: 4,
Operation: layers.ARPRequest,
SourceHwAddress: []byte(iface.HardwareAddr),
SourceProtAddress: []byte(addr.IP),
DstHwAddress: []byte{0, 0, 0, 0, 0, 0},
}
// Set up buffer and options for serialization.
buf := gopacket.NewSerializeBuffer()
opts := gopacket.SerializeOptions{
FixLengths: true,
ComputeChecksums: true,
}
// Send one packet for every address.
for _, ip := range ips(addr) {
arp.DstProtAddress = []byte(ip)
gopacket.SerializeLayers(buf, opts, ð, &arp)
if err := handle.WritePacketData(buf.Bytes()); err != nil {
return err
}
}
return nil
}
// ips is a simple and not very good method for getting all IPv4 addresses from a
// net.IPNet. It returns all IPs it can over the channel it sends back, closing
// the channel when done.
func ips(n *net.IPNet) (out []net.IP) {
num := binary.BigEndian.Uint32([]byte(n.IP))
mask := binary.BigEndian.Uint32([]byte(n.Mask))
network := num & mask
broadcast := network | ^mask
for network++; network < broadcast; network++ {
var buf [4]byte
binary.BigEndian.PutUint32(buf[:], network)
out = append(out, net.IP(buf[:]))
}
return
}
================================================
FILE: examples/bidirectional/main.go
================================================
// Copyright 2012 Google, Inc. All rights reserved.
//
// Use of this source code is governed by a BSD-style license
// that can be found in the LICENSE file in the root of the source
// tree.
// This binary provides an example of connecting up bidirectional streams from
// the unidirectional streams provided by gopacket/tcpassembly.
package main
import (
"flag"
"fmt"
"github.com/google/gopacket"
"github.com/google/gopacket/examples/util"
"github.com/google/gopacket/layers"
"github.com/google/gopacket/pcap"
"github.com/google/gopacket/tcpassembly"
"log"
"time"
)
var iface = flag.String("i", "eth0", "Interface to get packets from")
var snaplen = flag.Int("s", 16<<10, "SnapLen for pcap packet capture")
var filter = flag.String("f", "tcp", "BPF filter for pcap")
var logAllPackets = flag.Bool("v", false, "Logs every packet in great detail")
// key is used to map bidirectional streams to each other.
type key struct {
net, transport gopacket.Flow
}
// String prints out the key in a human-readable fashion.
func (k key) String() string {
return fmt.Sprintf("%v:%v", k.net, k.transport)
}
// timeout is the length of time to wait befor flushing connections and
// bidirectional stream pairs.
const timeout time.Duration = time.Minute * 5
// myStream implements tcpassembly.Stream
type myStream struct {
bytes int64 // total bytes seen on this stream.
bidi *bidi // maps to my bidirectional twin.
done bool // if true, we've seen the last packet we're going to for this stream.
}
// bidi stores each unidirectional side of a bidirectional stream.
//
// When a new stream comes in, if we don't have an opposite stream, a bidi is
// created with 'a' set to the new stream. If we DO have an opposite stream,
// 'b' is set to the new stream.
type bidi struct {
key key // Key of the first stream, mostly for logging.
a, b *myStream // the two bidirectional streams.
lastPacketSeen time.Time // last time we saw a packet from either stream.
}
// myFactory implements tcpassmebly.StreamFactory
type myFactory struct {
// bidiMap maps keys to bidirectional stream pairs.
bidiMap map[key]*bidi
}
// New handles creating a new tcpassembly.Stream.
func (f *myFactory) New(netFlow, tcpFlow gopacket.Flow) tcpassembly.Stream {
// Create a new stream.
s := &myStream{}
// Find the bidi bidirectional struct for this stream, creating a new one if
// one doesn't already exist in the map.
k := key{netFlow, tcpFlow}
bd := f.bidiMap[k]
if bd == nil {
bd = &bidi{a: s, key: k}
log.Printf("[%v] created first side of bidirectional stream", bd.key)
// Register bidirectional with the reverse key, so the matching stream going
// the other direction will find it.
f.bidiMap[key{netFlow.Reverse(), tcpFlow.Reverse()}] = bd
} else {
log.Printf("[%v] found second side of bidirectional stream", bd.key)
bd.b = s
// Clear out the bidi we're using from the map, just in case.
delete(f.bidiMap, k)
}
s.bidi = bd
return s
}
// emptyStream is used to finish bidi that only have one stream, in
// collectOldStreams.
var emptyStream = &myStream{done: true}
// collectOldStreams finds any streams that haven't received a packet within
// 'timeout', and sets/finishes the 'b' stream inside them. The 'a' stream may
// still receive packets after this.
func (f *myFactory) collectOldStreams() {
cutoff := time.Now().Add(-timeout)
for k, bd := range f.bidiMap {
if bd.lastPacketSeen.Before(cutoff) {
log.Printf("[%v] timing out old stream", bd.key)
bd.b = emptyStream // stub out b with an empty stream.
delete(f.bidiMap, k) // remove it from our map.
bd.maybeFinish() // if b was the last stream we were waiting for, finish up.
}
}
}
// Reassembled handles reassembled TCP stream data.
func (s *myStream) Reassembled(rs []tcpassembly.Reassembly) {
for _, r := range rs {
// For now, we'll simply count the bytes on each side of the TCP stream.
s.bytes += int64(len(r.Bytes))
if r.Skip > 0 {
s.bytes += int64(r.Skip)
}
// Mark that we've received new packet data.
// We could just use time.Now, but by using r.Seen we handle the case
// where packets are being read from a file and could be very old.
if s.bidi.lastPacketSeen.Before(r.Seen) {
s.bidi.lastPacketSeen = r.Seen
}
}
}
// ReassemblyComplete marks this stream as finished.
func (s *myStream) ReassemblyComplete() {
s.done = true
s.bidi.maybeFinish()
}
// maybeFinish will wait until both directions are complete, then print out
// stats.
func (bd *bidi) maybeFinish() {
switch {
case bd.a == nil:
log.Fatalf("[%v] a should always be non-nil, since it's set when bidis are created", bd.key)
case !bd.a.done:
log.Printf("[%v] still waiting on first stream", bd.key)
case bd.b == nil:
log.Printf("[%v] no second stream yet", bd.key)
case !bd.b.done:
log.Printf("[%v] still waiting on second stream", bd.key)
default:
log.Printf("[%v] FINISHED, bytes: %d tx, %d rx", bd.key, bd.a.bytes, bd.b.bytes)
}
}
func main() {
defer util.Run()()
log.Printf("starting capture on interface %q", *iface)
// Set up pcap packet capture
handle, err := pcap.OpenLive(*iface, int32(*snaplen), true, pcap.BlockForever)
if err != nil {
panic(err)
}
if err := handle.SetBPFFilter(*filter); err != nil {
panic(err)
}
// Set up assembly
streamFactory := &myFactory{bidiMap: make(map[key]*bidi)}
streamPool := tcpassembly.NewStreamPool(streamFactory)
assembler := tcpassembly.NewAssembler(streamPool)
// Limit memory usage by auto-flushing connection state if we get over 100K
// packets in memory, or over 1000 for a single stream.
assembler.MaxBufferedPagesTotal = 100000
assembler.MaxBufferedPagesPerConnection = 1000
log.Println("reading in packets")
// Read in packets, pass to assembler.
packetSource := gopacket.NewPacketSource(handle, handle.LinkType())
packets := packetSource.Packets()
ticker := time.Tick(timeout / 4)
for {
select {
case packet := <-packets:
if *logAllPackets {
log.Println(packet)
}
if packet.NetworkLayer() == nil || packet.TransportLayer() == nil || packet.TransportLayer().LayerType() != layers.LayerTypeTCP {
log.Println("Unusable packet")
continue
}
tcp := packet.TransportLayer().(*layers.TCP)
assembler.AssembleWithTimestamp(packet.NetworkLayer().NetworkFlow(), tcp, packet.Metadata().Timestamp)
case <-ticker:
// Every minute, flush connections that haven't seen activity in the past minute.
log.Println("---- FLUSHING ----")
assembler.FlushOlderThan(time.Now().Add(-timeout))
streamFactory.collectOldStreams()
}
}
}
================================================
FILE: examples/bytediff/main.go
================================================
// Copyright 2012 Google, Inc. All rights reserved.
//
// Use of this source code is governed by a BSD-style license
// that can be found in the LICENSE file in the root of the source
// tree.
// This binary shows how to display byte differences to users via the bytediff
// library.
package main
import (
"fmt"
"github.com/google/gopacket/bytediff"
)
var sliceA = []byte{
0x00, 0x00, 0x0c, 0x9f, 0xf0, 0x20, 0xbc, 0x30, 0x5b, 0xe8, 0xd3, 0x49,
0x08, 0x00, 0x45, 0x00, 0x01, 0xa4, 0x39, 0xdf, 0x40, 0x00, 0x40, 0x06,
0x55, 0x5a, 0xac, 0x11, 0x51, 0x49, 0xad, 0xde, 0xfe, 0xe1, 0xc5, 0xf7,
0x00, 0x50, 0xc5, 0x7e, 0x0e, 0x48, 0x49, 0x07, 0x42, 0x32, 0x80, 0x18,
0x00, 0x73, 0x9a, 0x8f, 0x00, 0x00, 0x01, 0x01, 0x08, 0x0a, 0x03, 0x77,
0x37, 0x9c, 0x42, 0x77, 0x5e, 0x3a, 0x47, 0x45, 0x54, 0x20, 0x2f, 0x20,
0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x31, 0x0d, 0x0a, 0x48, 0x6f,
0x73, 0x74, 0x3a, 0x20, 0x77, 0x77, 0x77, 0x2e, 0x66, 0x69, 0x73, 0x68,
0x2e, 0x63, 0x6f, 0x6d, 0x0d, 0x0a, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63,
0x74, 0x69, 0x6f, 0x6e, 0x3a, 0x20, 0x6b, 0x65, 0x65, 0x70, 0x2d, 0x61,
0x6c, 0x69, 0x76, 0x65, 0x0d, 0x0a, 0x55, 0x73, 0x65, 0x72, 0x2d, 0x41,
0x67, 0x65, 0x6e, 0x74, 0x3a, 0x20, 0x4d, 0x6f, 0x7a, 0x69, 0x6c, 0x6c,
0x61, 0x2f, 0x35, 0x2e, 0x30, 0x20, 0x28, 0x58, 0x31, 0x31, 0x3b, 0x20,
0x4c, 0x69, 0x6e, 0x75, 0x78, 0x20, 0x78, 0x38, 0x36, 0x5f, 0x36, 0x34,
0x29, 0x20, 0x41, 0x70, 0x70, 0x6c, 0x65, 0x57, 0x65, 0x62, 0x4b, 0x69,
0x74, 0x2f, 0x35, 0x33, 0x35, 0x2e, 0x32, 0x20, 0x28, 0x4b, 0x48, 0x54,
0x4d, 0x4c, 0x2c, 0x20, 0x6c, 0x69, 0x6b, 0x65, 0x20, 0x47, 0x65, 0x63,
0x6b, 0x6f, 0x29, 0x20, 0x43, 0x68, 0x72, 0x6f, 0x6d, 0x65, 0x2f, 0x31,
0x35, 0x2e, 0x30, 0x2e, 0x38, 0x37, 0x34, 0x2e, 0x31, 0x32, 0x31, 0x20,
0x53, 0x61, 0x66, 0x61, 0x72, 0x69, 0x2f, 0x35, 0x2e, 0x31,
0x0d, 0x0a, 0x41, 0x63, 0x63, 0x65, 0x70, 0x74, 0x3a, 0x20, 0x74, 0x65,
0x78, 0x74, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0x2c, 0x61, 0x70, 0x70, 0x6c,
0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x78, 0x68, 0x74, 0x6d,
0x6c, 0x2b, 0x78, 0x6d, 0x6c, 0x2c, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63,
0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x78, 0x6d, 0x6c, 0x3b, 0x71, 0x3d,
0x30, 0x2e, 0x39, 0x2c, 0x2a, 0x2f, 0x2a, 0x3b, 0x71, 0x3d, 0x30, 0x2e,
0x38, 0x0d, 0x0a, 0x41, 0x63, 0x63, 0x65, 0x70, 0x74, 0x2d, 0x45, 0x6e,
0x63, 0x6f, 0x64, 0x69, 0x6e, 0x67, 0x3a, 0x20, 0x67, 0x7a, 0x69, 0x70,
0x2c, 0x64, 0x65, 0x66, 0x6c, 0x61, 0x74, 0x65, 0x2c, 0x73, 0x64, 0x63,
0x68, 0x0d, 0x0a, 0x41, 0x63, 0x63, 0x65, 0x70, 0x74, 0x2d, 0x4c, 0x61,
0x6e, 0x67, 0x75, 0x61, 0x67, 0x65, 0x3a, 0x20, 0x65, 0x6e, 0x2d, 0x55,
0x53, 0x2c, 0x65, 0x6e, 0x3b, 0x71, 0x3d, 0x30, 0x2e, 0x38, 0x0d, 0x0a,
0x41, 0x63, 0x63, 0x65, 0x70, 0x74, 0x2d, 0x43, 0x68, 0x61, 0x72, 0x73,
0x65, 0x74, 0x3a, 0x20, 0x49, 0x53, 0x4f, 0x2d, 0x38, 0x38, 0x35, 0x39,
0x2d, 0x31, 0x2c, 0x75, 0x74, 0x66, 0x2d, 0x38, 0x3b, 0x71, 0x3d, 0x30,
0x2e, 0x37, 0x2c, 0x2a, 0x3b, 0x71, 0x3d, 0x30, 0x2e, 0x33, 0x0d, 0x0a,
0x0d, 0x0a,
}
var sliceB = []byte{
0x00, 0x00, 0x0c, 0x9f, 0xf0, 0x20, 0xbc, 0x30, 0x5b, 0xe8, 0xd3, 0x49,
0x08, 0x00, 0x45, 0x00, 0x01, 0xa4, 0x39, 0xdf, 0x40, 0x00, 0x40, 0x06,
0x55, 0x5a, 0xac, 0x11, 0x51, 0x49, 0xad, 0xde, 0xfe, 0xe1, 0xc5, 0xf7,
0x00, 0x50, 0xc5, 0x7e, 0x0e, 0x48, 0x49, 0x07, 0x42, 0x32, 0x80, 0x18,
0x00, 0x73, 0x9a, 0x8f, 0x00, 0x00, 0x01, 0x01, 0x08, 0x0a, 0x03, 0x77,
0x37, 0x9c, 0x42, 0x77, 0x5e, 0x3a, 0x47, 0x45, 0x54, 0x20, 0x2f, 0x20,
0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x31, 0x0d, 0x0a, 0x48, 0x6f,
0x73, 0x74, 0x3a, 0x20, 0x77, 0x77, 0x77, 0x2e, 0x66, 0x69, 0x73, 0x68,
0x2e, 0x63, 0x6f, 0x6d, 0x0d, 0x0a, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63,
0x6c, 0x69, 0x76, 0x65, 0x0d, 0x0a, 0x55, 0x73, 0x65, 0x72, 0x2d, 0x41,
0x67, 0x65, 0x6e, 0x74, 0x3a, 0x20, 0x4d, 0x6f, 0x7a, 0x69, 0x6c, 0x6c,
0x61, 0x2f, 0x35, 0x2e, 0x30, 0x20, 0x28, 0x58, 0x31, 0x31, 0x3b, 0x20,
0x4c, 0x69, 0x6e, 0x75, 0x78, 0x20, 0x78, 0x38, 0x36, 0x5f, 0x36, 0x34,
0x29, 0x20, 0x41, 0x70, 0x70, 0x6c, 0x65, 0x57, 0x65, 0x62, 0x4b, 0x69,
0x74, 0x2f, 0x35, 0x33, 0x35, 0x2e, 0x32, 0x20, 0x28, 0x4b, 0x48, 0x54,
0x4d, 0x4c, 0x2c, 0x20, 0x6c, 0x69, 0x6b, 0x65, 0x20, 0x47, 0x65, 0x63,
0x6b, 0x6f, 0x29, 0x20, 0x43, 0x68, 0x72, 0x6f, 0x6d, 0x65, 0x2f, 0x31,
0x35, 0x2e, 0x30, 0x2e, 0x38, 0x37, 0x34, 0x2e, 0x31, 0x32, 0x31, 0x20,
0x53, 0x61, 0x66, 0x61, 0x72, 0x69, 0x2f, 0x35, 0x33, 0x35, 0x2e, 0x32,
0x0d, 0x0a, 0x41, 0x63, 0x63, 0x65, 0x70, 0x74, 0x3a, 0x20, 0x74, 0x65,
0x78, 0x74, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0x2c, 0x61, 0x70, 0x70, 0x6c,
0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x78, 0x68, 0x74, 0x6d,
0x6c, 0x2b, 0x78, 0x6d, 0x6c, 0x2c, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63,
0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x78, 0x6d, 0x6c, 0x3b, 0x71, 0x3d,
0x30, 0x2e, 0x39, 0x2c, 0x2a, 0x2f, 0x2a, 0x3b, 0x71, 0x3d, 0x30, 0x2e,
0x38, 0x0d, 0x0a, 0x41, 0x63, 0x63, 0x65, 0x70, 0x74, 0x2d, 0x45, 0x6e,
0x63, 0x6f, 0x64, 0x69, 0x6e, 0x67, 0x3a, 0x20, 0x67, 0x7a, 0x69, 0x70,
0x2c, 0x64, 0x65, 0x66, 0x6c, 0x61, 0x74, 0x65, 0x2c, 0x73, 0x64, 0x63,
0x68, 0x0d, 0x0a, 0x41, 0x63, 0x63, 0x65, 0x70, 0x74, 0x2d, 0x4c, 0x61,
0x6e, 0x67, 0x75, 0x61, 0x67, 0x65, 0x3a, 0x20, 0x65, 0x6e, 0x2d, 0x55,
0x53, 0x2c, 0x65, 0x6e, 0x3b, 0x71, 0x3d, 0x30, 0x2e, 0x38, 0x0d, 0x0a,
0x41, 0x63, 0x63, 0x65, 0x70, 0x74, 0x2d, 0x43, 0x68, 0x61, 0x72, 0x73,
0x65, 0x74, 0x3a, 0x20, 0x49, 0x53, 0x4f, 0x2e, 0x39, 0x55, 0x35, 0x39,
0x2d, 0x31, 0x2c, 0x75, 0x74, 0x66, 0x2d, 0x38, 0x3b, 0x71, 0x3d, 0x30,
0x2e, 0x37, 0x2c, 0x2a, 0x3b, 0x71, 0x3d, 0x30, 0x2e, 0x33, 0x0d, 0x0a,
0x0d, 0x0a,
}
func main() {
fmt.Println(bytediff.BashOutput.String(bytediff.Diff(sliceA, sliceB)))
}
================================================
FILE: examples/httpassembly/main.go
================================================
// Copyright 2012 Google, Inc. All rights reserved.
//
// Use of this source code is governed by a BSD-style license
// that can be found in the LICENSE file in the root of the source
// tree.
// This binary provides sample code for using the gopacket TCP assembler and TCP
// stream reader. It reads packets off the wire and reconstructs HTTP requests
// it sees, logging them.
package main
import (
"bufio"
"flag"
"io"
"log"
"net/http"
"time"
"github.com/google/gopacket"
"github.com/google/gopacket/examples/util"
"github.com/google/gopacket/layers"
"github.com/google/gopacket/pcap"
"github.com/google/gopacket/tcpassembly"
"github.com/google/gopacket/tcpassembly/tcpreader"
)
var iface = flag.String("i", "eth0", "Interface to get packets from")
var fname = flag.String("r", "", "Filename to read from, overrides -i")
var snaplen = flag.Int("s", 1600, "SnapLen for pcap packet capture")
var filter = flag.String("f", "tcp and dst port 80", "BPF filter for pcap")
var logAllPackets = flag.Bool("v", false, "Logs every packet in great detail")
// Build a simple HTTP request parser using tcpassembly.StreamFactory and tcpassembly.Stream interfaces
// httpStreamFactory implements tcpassembly.StreamFactory
type httpStreamFactory struct{}
// httpStream will handle the actual decoding of http requests.
type httpStream struct {
net, transport gopacket.Flow
r tcpreader.ReaderStream
}
func (h *httpStreamFactory) New(net, transport gopacket.Flow) tcpassembly.Stream {
hstream := &httpStream{
net: net,
transport: transport,
r: tcpreader.NewReaderStream(),
}
go hstream.run() // Important... we must guarantee that data from the reader stream is read.
// ReaderStream implements tcpassembly.Stream, so we can return a pointer to it.
return &hstream.r
}
func (h *httpStream) run() {
buf := bufio.NewReader(&h.r)
for {
req, err := http.ReadRequest(buf)
if err == io.EOF {
// We must read until we see an EOF... very important!
return
} else if err != nil {
log.Println("Error reading stream", h.net, h.transport, ":", err)
} else {
bodyBytes := tcpreader.DiscardBytesToEOF(req.Body)
req.Body.Close()
log.Println("Received request from stream", h.net, h.transport, ":", req, "with", bodyBytes, "bytes in request body")
}
}
}
func main() {
defer util.Run()()
var handle *pcap.Handle
var err error
// Set up pcap packet capture
if *fname != "" {
log.Printf("Reading from pcap dump %q", *fname)
handle, err = pcap.OpenOffline(*fname)
} else {
log.Printf("Starting capture on interface %q", *iface)
handle, err = pcap.OpenLive(*iface, int32(*snaplen), true, pcap.BlockForever)
}
if err != nil {
log.Fatal(err)
}
if err := handle.SetBPFFilter(*filter); err != nil {
log.Fatal(err)
}
// Set up assembly
streamFactory := &httpStreamFactory{}
streamPool := tcpassembly.NewStreamPool(streamFactory)
assembler := tcpassembly.NewAssembler(streamPool)
log.Println("reading in packets")
// Read in packets, pass to assembler.
packetSource := gopacket.NewPacketSource(handle, handle.LinkType())
packets := packetSource.Packets()
ticker := time.Tick(time.Minute)
for {
select {
case packet := <-packets:
// A nil packet indicates the end of a pcap file.
if packet == nil {
return
}
if *logAllPackets {
log.Println(packet)
}
if packet.NetworkLayer() == nil || packet.TransportLayer() == nil || packet.TransportLayer().LayerType() != layers.LayerTypeTCP {
log.Println("Unusable packet")
continue
}
tcp := packet.TransportLayer().(*layers.TCP)
assembler.AssembleWithTimestamp(packet.NetworkLayer().NetworkFlow(), tcp, packet.Metadata().Timestamp)
case <-ticker:
// Every minute, flush connections that haven't seen activity in the past 2 minutes.
assembler.FlushOlderThan(time.Now().Add(time.Minute * -2))
}
}
}
================================================
FILE: examples/pcapdump/main.go
================================================
// Copyright 2012 Google, Inc. All rights reserved.
//
// Use of this source code is governed by a BSD-style license
// that can be found in the LICENSE file in the root of the source
// tree.
// The pcapdump binary implements a tcpdump-like command line tool with gopacket
// using pcap as a backend data collection mechanism.
package main
import (
"flag"
"fmt"
"github.com/google/gopacket/dumpcommand"
"github.com/google/gopacket/examples/util"
"github.com/google/gopacket/pcap"
"log"
"os"
"strings"
"time"
)
var iface = flag.String("i", "eth0", "Interface to read packets from")
var fname = flag.String("r", "", "Filename to read from, overrides -i")
var snaplen = flag.Int("s", 65536, "Snap length (number of bytes max to read per packet")
var tstype = flag.String("timestamp_type", "", "Type of timestamps to use")
var promisc = flag.Bool("promisc", true, "Set promiscuous mode")
func main() {
defer util.Run()()
var handle *pcap.Handle
var err error
if *fname != "" {
if handle, err = pcap.OpenOffline(*fname); err != nil {
log.Fatal("PCAP OpenOffline error:", err)
}
} else {
// This is a little complicated because we want to allow all possible options
// for creating the packet capture handle... instead of all this you can
// just call pcap.OpenLive if you want a simple handle.
inactive, err := pcap.NewInactiveHandle(*iface)
if err != nil {
log.Fatalf("could not create: %v", err)
}
defer inactive.CleanUp()
if err = inactive.SetSnapLen(*snaplen); err != nil {
log.Fatalf("could not set snap length: %v", err)
} else if err = inactive.SetPromisc(*promisc); err != nil {
log.Fatalf("could not set promisc mode: %v", err)
} else if err = inactive.SetTimeout(time.Second); err != nil {
log.Fatalf("could not set timeout: %v", err)
}
if *tstype != "" {
if t, err := pcap.TimestampSourceFromString(*tstype); err != nil {
log.Fatalf("Supported timestamp types: %v", inactive.SupportedTimestamps())
} else if err := inactive.SetTimestampSource(t); err != nil {
log.Fatalf("Supported timestamp types: %v", inactive.SupportedTimestamps())
}
}
if handle, err = inactive.Activate(); err != nil {
log.Fatal("PCAP Activate error:", err)
}
defer handle.Close()
}
if len(flag.Args()) > 0 {
bpffilter := strings.Join(flag.Args(), " ")
fmt.Fprintf(os.Stderr, "Using BPF filter %q\n", bpffilter)
if err = handle.SetBPFFilter(bpffilter); err != nil {
log.Fatal("BPF filter error:", err)
}
}
dumpcommand.Run(handle)
}
================================================
FILE: examples/pcaplay/main.go
================================================
// Copyright 2012 Google, Inc. All rights reserved.
//
// Use of this source code is governed by a BSD-style license
// that can be found in the LICENSE file in the root of the source
// tree.
// The pcaplay binary load an offline capture (pcap file) and replay
// it on the select interface, with an emphasis on packet timing
package main
import (
"flag"
"fmt"
"io"
"log"
"os"
"strings"
"time"
"github.com/google/gopacket"
"github.com/google/gopacket/examples/util"
"github.com/google/gopacket/pcap"
)
var iface = flag.String("i", "eth0", "Interface to write packets to")
var fname = flag.String("r", "", "Filename to read from")
var fast = flag.Bool("f", false, "Send each packets as fast as possible")
var lastTS time.Time
var lastSend time.Time
var start time.Time
var bytesSent int
func writePacketDelayed(handle *pcap.Handle, buf []byte, ci gopacket.CaptureInfo) {
if ci.CaptureLength != ci.Length {
// do not write truncated packets
return
}
intervalInCapture := ci.Timestamp.Sub(lastTS)
elapsedTime := time.Since(lastSend)
if (intervalInCapture > elapsedTime) && !lastSend.IsZero() {
time.Sleep(intervalInCapture - elapsedTime)
}
lastSend = time.Now()
writePacket(handle, buf)
lastTS = ci.Timestamp
}
func writePacket(handle *pcap.Handle, buf []byte) error {
if err := handle.WritePacketData(buf); err != nil {
log.Printf("Failed to send packet: %s\n", err)
return err
}
return nil
}
func pcapInfo(filename string) (start time.Time, end time.Time, packets int, size int) {
handleRead, err := pcap.OpenOffline(*fname)
if err != nil {
log.Fatal("PCAP OpenOffline error (handle to read packet):", err)
}
var previousTs time.Time
var deltaTotal time.Duration
for {
data, ci, err := handleRead.ReadPacketData()
if err != nil && err != io.EOF {
log.Fatal(err)
} else if err == io.EOF {
break
} else {
if start.IsZero() {
start = ci.Timestamp
}
end = ci.Timestamp
packets++
size += len(data)
if previousTs.IsZero() {
previousTs = ci.Timestamp
} else {
deltaTotal += ci.Timestamp.Sub(previousTs)
previousTs = ci.Timestamp
}
}
}
sec := int(deltaTotal.Seconds())
if sec == 0 {
sec = 1
}
fmt.Printf("Avg packet rate %d/s\n", packets/sec)
return start, end, packets, size
}
func main() {
defer util.Run()()
// Sanity checks
if *fname == "" {
log.Fatal("Need a input file")
}
// Open PCAP file + handle potential BPF Filter
handleRead, err := pcap.OpenOffline(*fname)
if err != nil {
log.Fatal("PCAP OpenOffline error (handle to read packet):", err)
}
defer handleRead.Close()
if len(flag.Args()) > 0 {
bpffilter := strings.Join(flag.Args(), " ")
fmt.Fprintf(os.Stderr, "Using BPF filter %q\n", bpffilter)
if err = handleRead.SetBPFFilter(bpffilter); err != nil {
log.Fatal("BPF filter error:", err)
}
}
// Open up a second pcap handle for packet writes.
handleWrite, err := pcap.OpenLive(*iface, 65536, true, pcap.BlockForever)
if err != nil {
log.Fatal("PCAP OpenLive error (handle to write packet):", err)
}
defer handleWrite.Close()
start = time.Now()
pkt := 0
tsStart, tsEnd, packets, size := pcapInfo(*fname)
// Loop over packets and write them
for {
data, ci, err := handleRead.ReadPacketData()
switch {
case err == io.EOF:
fmt.Printf("\nFinished in %s", time.Since(start))
return
case err != nil:
log.Printf("Failed to read packet %d: %s\n", pkt, err)
default:
if *fast {
writePacket(handleWrite, data)
} else {
writePacketDelayed(handleWrite, data, ci)
}
bytesSent += len(data)
duration := time.Since(start)
pkt++
if duration > time.Second {
rate := bytesSent / int(duration.Seconds())
remainingTime := tsEnd.Sub(tsStart) - duration
fmt.Printf("\rrate %d kB/sec - sent %d/%d kB - %d/%d packets - remaining time %s",
rate/1000, bytesSent/1000, size/1000,
pkt, packets, remainingTime)
}
}
}
}
================================================
FILE: examples/pfdump/main.go
================================================
// Copyright 2012 Google, Inc. All rights reserved.
//
// Use of this source code is governed by a BSD-style license
// that can be found in the LICENSE file in the root of the source
// tree.
// The pfdump binary implements a tcpdump-like command line tool with gopacket
// using pfring as a backend data collection mechanism.
package main
import (
"flag"
"fmt"
"github.com/google/gopacket/dumpcommand"
"github.com/google/gopacket/examples/util"
"github.com/google/gopacket/pfring"
"log"
"os"
"strings"
)
var iface = flag.String("i", "eth0", "Interface to read packets from")
var snaplen = flag.Int("s", 65536, "Snap length (number of bytes max to read per packet")
var cluster = flag.Int("cluster", -1, "If >= 0, sets the pfring cluster to this value")
var clustertype = flag.Int("clustertype", int(pfring.ClusterPerFlow), "Cluster type")
func main() {
defer util.Run()()
var ring *pfring.Ring
var err error
if ring, err = pfring.NewRing(*iface, uint32(*snaplen), pfring.FlagPromisc); err != nil {
log.Fatalln("pfring ring creation error:", err)
}
if len(flag.Args()) > 0 {
bpffilter := strings.Join(flag.Args(), " ")
fmt.Fprintf(os.Stderr, "Using BPF filter %q\n", bpffilter)
if err = ring.SetBPFFilter(bpffilter); err != nil {
log.Fatalln("BPF filter error:", err)
}
}
if *cluster >= 0 {
if err = ring.SetCluster(*cluster, pfring.ClusterType(*clustertype)); err != nil {
log.Fatalln("pfring SetCluster error:", err)
}
}
if err = ring.SetSocketMode(pfring.ReadOnly); err != nil {
log.Fatalln("pfring SetSocketMode error:", err)
} else if err = ring.Enable(); err != nil {
log.Fatalln("pfring Enable error:", err)
}
dumpcommand.Run(ring)
}
================================================
FILE: examples/reassemblydump/compare.sh
================================================
#!/bin/bash
# Limitations: if the number extracted files in too big, finding identical
# files might fail due to '*' in cmdline
# This would require to split sha256sum symlinks in xx/yyyyy
usage()
{
echo "Usage: $0 <file.pcap> <output-dir>"
echo "Compares tcpreassembly against tcpflow"
echo ""
echo "$@"
exit 1
}
debug() {
return # comment me for debug
echo "$@"
}
die()
{
(
echo "$@"
echo
) >&2
exit 1
}
rename()
{
local path="$1"
local filter="$2"
find "$path" -type f -name "$filter" -print0 |
while IFS= read -r -d $'\0' f; do
local sha256="$(sha256sum "$f" | cut -d ' ' -f 1)"
local target="$(dirname $f)/../sha256/$sha256"
debug "$target → $f"
mkdir -p "$(dirname "$target")" || return 1
if [ ! -f "$target" ]; then
ln -sr "$f" "$target" || return 1
fi
done
return $?
}
main()
{
local src="$1"
local out="$2"
# TODO: make options
local extra=""
extra="$extra -debug"
extra="$extra -cpuprofile "$out/gopacket/cpu.prof""
extra="$extra -memprofile "$out/gopacket/mem.prof""
[ ! -f "$src" ] && usage "Missing pcap"
[ ! -d "$out" ] && ( mkdir "$out" || die "Failed to create $out" )
mkdir -p "$out/gopacket/all" || die "Failed to create $out/gopacket/all"
mkdir -p "$out/tcpflow/all" || die "Faield to create $out/tcpflow/all"
echo " * Running go reassembly"
time ./reassemblydump -r "$src" $debug -output "$out/gopacket/all" $extra -writeincomplete -ignorefsmerr -nooptcheck -allowmissinginit port 80 &> "$out/gopacket.txt" || die "Failed to run reassmbly. Check $out/gopacket.txt"
echo " * Running tcpflow"
time tcpflow -e http -r "$src" -o "$out/tcpflow/all" port 80 &> "$out/tcpflow.txt" || die "Failed to run tcpflow. Check $out/tcpflow.txt"
echo " * Creating sha256sum symlinks for gopacket"
rename "$out/gopacket/all" '*' || die "Failed to rename in $out/gopacket"
echo " * Creating sha256sum symlinks for tcpflow"
rename "$out/tcpflow/all" '*HTTPBODY*' || die "Failed to rename in $out/tcpflow"
# Remove identical files
echo " * Finding identical files"
local nb=0
mkdir -p "$out/gopacket/sha256-equal"
mkdir -p "$out/tcpflow/sha256-equal"
for f in "$out/gopacket/sha256/"*; do
local f="$(basename "$f")"
[ -f "$out/tcpflow/sha256/$f" ] && {
debug " $f"
mv "$out/gopacket/sha256/$f" "$out/gopacket/sha256-equal"
mv "$out/tcpflow/sha256/$f" "$out/tcpflow/sha256-equal"
nb=$((nb+1))
}
done
echo " → found $nb files"
echo " * Diffing {gopacket,tcpflow}/sha256"
local rc=0
for p in "gopacket" "tcpflow"; do
local nb=$(ls -1 "$out/$p/sha256/" | wc -l)
if [ $nb -ne 0 ]; then
rc=$((rc+1))
echo " → $nb files in $out/$p/sha256"
fi
done
return $rc
}
main "$@"
exit $?
================================================
FILE: examples/reassemblydump/main.go
================================================
// Copyright 2012 Google, Inc. All rights reserved.
//
// Use of this source code is governed by a BSD-style license
// that can be found in the LICENSE file in the root of the source
// tree.
// The pcapdump binary implements a tcpdump-like command line tool with gopacket
// using pcap as a backend data collection mechanism.
package main
import (
"bufio"
"bytes"
"compress/gzip"
"encoding/binary"
"encoding/hex"
"flag"
"fmt"
"io"
"io/ioutil"
"log"
"net/http"
"net/url"
"os"
"os/signal"
"path"
"runtime/pprof"
"strings"
"sync"
"time"
"github.com/google/gopacket"
"github.com/google/gopacket/examples/util"
"github.com/google/gopacket/ip4defrag"
"github.com/google/gopacket/layers" // pulls in all layers decoders
"github.com/google/gopacket/pcap"
"github.com/google/gopacket/reassembly"
)
var maxcount = flag.Int("c", -1, "Only grab this many packets, then exit")
var decoder = flag.String("decoder", "", "Name of the decoder to use (default: guess from capture)")
var statsevery = flag.Int("stats", 1000, "Output statistics every N packets")
var lazy = flag.Bool("lazy", false, "If true, do lazy decoding")
var nodefrag = flag.Bool("nodefrag", false, "If true, do not do IPv4 defrag")
var checksum = flag.Bool("checksum", false, "Check TCP checksum")
var nooptcheck = flag.Bool("nooptcheck", false, "Do not check TCP options (useful to ignore MSS on captures with TSO)")
var ignorefsmerr = flag.Bool("ignorefsmerr", false, "Ignore TCP FSM errors")
var allowmissinginit = flag.Bool("allowmissinginit", false, "Support streams without SYN/SYN+ACK/ACK sequence")
var verbose = flag.Bool("verbose", false, "Be verbose")
var debug = flag.Bool("debug", false, "Display debug information")
var quiet = flag.Bool("quiet", false, "Be quiet regarding errors")
// http
var nohttp = flag.Bool("nohttp", false, "Disable HTTP parsing")
var output = flag.String("output", "", "Path to create file for HTTP 200 OK responses")
var writeincomplete = flag.Bool("writeincomplete", false, "Write incomplete response")
var hexdump = flag.Bool("dump", false, "Dump HTTP request/response as hex")
var hexdumppkt = flag.Bool("dumppkt", false, "Dump packet as hex")
// capture
var iface = flag.String("i", "eth0", "Interface to read packets from")
var fname = flag.String("r", "", "Filename to read from, overrides -i")
var snaplen = flag.Int("s", 65536, "Snap length (number of bytes max to read per packet")
var tstype = flag.String("timestamp_type", "", "Type of timestamps to use")
var promisc = flag.Bool("promisc", true, "Set promiscuous mode")
var memprofile = flag.String("memprofile", "", "Write memory profile")
var stats struct {
ipdefrag int
missedBytes int
pkt int
sz int
totalsz int
rejectFsm int
rejectOpt int
rejectConnFsm int
reassembled int
outOfOrderBytes int
outOfOrderPackets int
biggestChunkBytes int
biggestChunkPackets int
overlapBytes int
overlapPackets int
}
const closeTimeout time.Duration = time.Hour * 24 // Closing inactive: TODO: from CLI
const timeout time.Duration = time.Minute * 5 // Pending bytes: TODO: from CLI
/*
* HTTP part
*/
type httpReader struct {
ident string
isClient bool
bytes chan []byte
data []byte
hexdump bool
parent *tcpStream
}
func (h *httpReader) Read(p []byte) (int, error) {
ok := true
for ok && len(h.data) == 0 {
h.data, ok = <-h.bytes
}
if !ok || len(h.data) == 0 {
return 0, io.EOF
}
l := copy(p, h.data)
h.data = h.data[l:]
return l, nil
}
var outputLevel int
var errorsMap map[string]uint
var errorsMapMutex sync.Mutex
var errors uint
// Too bad for perf that a... is evaluated
func Error(t string, s string, a ...interface{}) {
errorsMapMutex.Lock()
errors++
nb, _ := errorsMap[t]
errorsMap[t] = nb + 1
errorsMapMutex.Unlock()
if outputLevel >= 0 {
fmt.Printf(s, a...)
}
}
func Info(s string, a ...interface{}) {
if outputLevel >= 1 {
fmt.Printf(s, a...)
}
}
func Debug(s string, a ...interface{}) {
if outputLevel >= 2 {
fmt.Printf(s, a...)
}
}
func (h *httpReader) run(wg *sync.WaitGroup) {
defer wg.Done()
b := bufio.NewReader(h)
for true {
if h.isClient {
req, err := http.ReadRequest(b)
if err == io.EOF || err == io.ErrUnexpectedEOF {
break
} else if err != nil {
Error("HTTP-request", "HTTP/%s Request error: %s (%v,%+v)\n", h.ident, err, err, err)
continue
}
body, err := ioutil.ReadAll(req.Body)
s := len(body)
if err != nil {
Error("HTTP-request-body", "Got body err: %s\n", err)
} else if h.hexdump {
Info("Body(%d/0x%x)\n%s\n", len(body), len(body), hex.Dump(body))
}
req.Body.Close()
Info("HTTP/%s Request: %s %s (body:%d)\n", h.ident, req.Method, req.URL, s)
h.parent.Lock()
h.parent.urls = append(h.parent.urls, req.URL.String())
h.parent.Unlock()
} else {
res, err := http.ReadResponse(b, nil)
var req string
h.parent.Lock()
if len(h.parent.urls) == 0 {
req = fmt.Sprintf("<no-request-seen>")
} else {
req, h.parent.urls = h.parent.urls[0], h.parent.urls[1:]
}
h.parent.Unlock()
if err == io.EOF || err == io.ErrUnexpectedEOF {
break
} else if err != nil {
Error("HTTP-response", "HTTP/%s Response error: %s (%v,%+v)\n", h.ident, err, err, err)
continue
}
body, err := ioutil.ReadAll(res.Body)
s := len(body)
if err != nil {
Error("HTTP-response-body", "HTTP/%s: failed to get body(parsed len:%d): %s\n", h.ident, s, err)
}
if h.hexdump {
Info("Body(%d/0x%x)\n%s\n", len(body), len(body), hex.Dump(body))
}
res.Body.Close()
sym := ","
if res.ContentLength > 0 && res.ContentLength != int64(s) {
sym = "!="
}
contentType, ok := res.Header["Content-Type"]
if !ok {
contentType = []string{http.DetectContentType(body)}
}
encoding := res.Header["Content-Encoding"]
Info("HTTP/%s Response: %s URL:%s (%d%s%d%s) -> %s\n", h.ident, res.Status, req, res.ContentLength, sym, s, contentType, encoding)
if (err == nil || *writeincomplete) && *output != "" {
base := url.QueryEscape(path.Base(req))
if err != nil {
base = "incomplete-" + base
}
base = path.Join(*output, base)
if len(base) > 250 {
base = base[:250] + "..."
}
if base == *output {
base = path.Join(*output, "noname")
}
target := base
n := 0
for true {
_, err := os.Stat(target)
//if os.IsNotExist(err) != nil {
if err != nil {
break
}
target = fmt.Sprintf("%s-%d", base, n)
n++
}
f, err := os.Create(target)
if err != nil {
Error("HTTP-create", "Cannot create %s: %s\n", target, err)
continue
}
var r io.Reader
r = bytes.NewBuffer(body)
if len(encoding) > 0 && (encoding[0] == "gzip" || encoding[0] == "deflate") {
r, err = gzip.NewReader(r)
if err != nil {
Error("HTTP-gunzip", "Failed to gzip decode: %s", err)
}
}
if err == nil {
w, err := io.Copy(f, r)
if _, ok := r.(*gzip.Reader); ok {
r.(*gzip.Reader).Close()
}
f.Close()
if err != nil {
Error("HTTP-save", "%s: failed to save %s (l:%d): %s\n", h.ident, target, w, err)
} else {
Info("%s: Saved %s (l:%d)\n", h.ident, target, w)
}
}
}
}
}
}
/*
* The TCP factory: returns a new Stream
*/
type tcpStreamFactory struct {
wg sync.WaitGroup
doHTTP bool
}
func (factory *tcpStreamFactory) New(net, transport gopacket.Flow, tcp *layers.TCP, ac reassembly.AssemblerContext) reassembly.Stream {
Debug("* NEW: %s %s\n", net, transport)
fsmOptions := reassembly.TCPSimpleFSMOptions{
SupportMissingEstablishment: *allowmissinginit,
}
stream := &tcpStream{
net: net,
transport: transport,
isDNS: tcp.SrcPort == 53 || tcp.DstPort == 53,
isHTTP: (tcp.SrcPort == 80 || tcp.DstPort == 80) && factory.doHTTP,
reversed: tcp.SrcPort == 80,
tcpstate: reassembly.NewTCPSimpleFSM(fsmOptions),
ident: fmt.Sprintf("%s:%s", net, transport),
optchecker: reassembly.NewTCPOptionCheck(),
}
if stream.isHTTP {
stream.client = httpReader{
bytes: make(chan []byte),
ident: fmt.Sprintf("%s %s", net, transport),
hexdump: *hexdump,
parent: stream,
isClient: true,
}
stream.server = httpReader{
bytes: make(chan []byte),
ident: fmt.Sprintf("%s %s", net.Reverse(), transport.Reverse()),
hexdump: *hexdump,
parent: stream,
}
factory.wg.Add(2)
go stream.client.run(&factory.wg)
go stream.server.run(&factory.wg)
}
return stream
}
func (factory *tcpStreamFactory) WaitGoRoutines() {
factory.wg.Wait()
}
/*
* The assembler context
*/
type Context struct {
CaptureInfo gopacket.CaptureInfo
}
func (c *Context) GetCaptureInfo() gopacket.CaptureInfo {
return c.CaptureInfo
}
/*
* TCP stream
*/
/* It's a connection (bidirectional) */
type tcpStream struct {
tcpstate *reassembly.TCPSimpleFSM
fsmerr bool
optchecker reassembly.TCPOptionCheck
net, transport gopacket.Flow
isDNS bool
isHTTP bool
reversed bool
client httpReader
server httpReader
urls []string
ident string
sync.Mutex
}
func (t *tcpStream) Accept(tcp *layers.TCP, ci gopacket.CaptureInfo, dir reassembly.TCPFlowDirection, nextSeq reassembly.Sequence, start *bool, ac reassembly.AssemblerContext) bool {
// FSM
if !t.tcpstate.CheckState(tcp, dir) {
Error("FSM", "%s: Packet rejected by FSM (state:%s)\n", t.ident, t.tcpstate.String())
stats.rejectFsm++
if !t.fsmerr {
t.fsmerr = true
stats.rejectConnFsm++
}
if !*ignorefsmerr {
return false
}
}
// Options
err := t.optchecker.Accept(tcp, ci, dir, nextSeq, start)
if err != nil {
Error("OptionChecker", "%s: Packet rejected by OptionChecker: %s\n", t.ident, err)
stats.rejectOpt++
if !*nooptcheck {
return false
}
}
// Checksum
accept := true
if *checksum {
c, err := tcp.ComputeChecksum()
if err != nil {
Error("ChecksumCompute", "%s: Got error computing checksum: %s\n", t.ident, err)
accept = false
} else if c != 0x0 {
Error("Checksum", "%s: Invalid checksum: 0x%x\n", t.ident, c)
accept = false
}
}
if !accept {
stats.rejectOpt++
}
return accept
}
func (t *tcpStream) ReassembledSG(sg reassembly.ScatterGather, ac reassembly.AssemblerContext) {
dir, start, end, skip := sg.Info()
length, saved := sg.Lengths()
// update stats
sgStats := sg.Stats()
if skip > 0 {
stats.missedBytes += skip
}
stats.sz += length - saved
stats.pkt += sgStats.Packets
if sgStats.Chunks > 1 {
stats.reassembled++
}
stats.outOfOrderPackets += sgStats.QueuedPackets
stats.outOfOrderBytes += sgStats.QueuedBytes
if length > stats.biggestChunkBytes {
stats.biggestChunkBytes = length
}
if sgStats.Packets > stats.biggestChunkPackets {
stats.biggestChunkPackets = sgStats.Packets
}
if sgStats.OverlapBytes != 0 && sgStats.OverlapPackets == 0 {
fmt.Printf("bytes:%d, pkts:%d\n", sgStats.OverlapBytes, sgStats.OverlapPackets)
panic("Invalid overlap")
}
stats.overlapBytes += sgStats.OverlapBytes
stats.overlapPackets += sgStats.OverlapPackets
var ident string
if dir == reassembly.TCPDirClientToServer {
ident = fmt.Sprintf("%v %v(%s): ", t.net, t.transport, dir)
} else {
ident = fmt.Sprintf("%v %v(%s): ", t.net.Reverse(), t.transport.Reverse(), dir)
}
Debug("%s: SG reassembled packet with %d bytes (start:%v,end:%v,skip:%d,saved:%d,nb:%d,%d,overlap:%d,%d)\n", ident, length, start, end, skip, saved, sgStats.Packets, sgStats.Chunks, sgStats.OverlapBytes, sgStats.OverlapPackets)
if skip == -1 && *allowmissinginit {
// this is allowed
} else if skip != 0 {
// Missing bytes in stream: do not even try to parse it
return
}
data := sg.Fetch(length)
if t.isDNS {
dns := &layers.DNS{}
var decoded []gopacket.LayerType
if len(data) < 2 {
if len(data) > 0 {
sg.KeepFrom(0)
}
return
}
dnsSize := binary.BigEndian.Uint16(data[:2])
missing := int(dnsSize) - len(data[2:])
Debug("dnsSize: %d, missing: %d\n", dnsSize, missing)
if missing > 0 {
Info("Missing some bytes: %d\n", missing)
sg.KeepFrom(0)
return
}
p := gopacket.NewDecodingLayerParser(layers.LayerTypeDNS, dns)
err := p.DecodeLayers(data[2:], &decoded)
if err != nil {
Error("DNS-parser", "Failed to decode DNS: %v\n", err)
} else {
Debug("DNS: %s\n", gopacket.LayerDump(dns))
}
if len(data) > 2+int(dnsSize) {
sg.KeepFrom(2 + int(dnsSize))
}
} else if t.isHTTP {
if length > 0 {
if *hexdump {
Debug("Feeding http with:\n%s", hex.Dump(data))
}
if dir == reassembly.TCPDirClientToServer && !t.reversed {
t.client.bytes <- data
} else {
t.server.bytes <- data
}
}
}
}
func (t *tcpStream) ReassemblyComplete(ac reassembly.AssemblerContext) bool {
Debug("%s: Connection closed\n", t.ident)
if t.isHTTP {
close(t.client.bytes)
close(t.server.bytes)
}
// do not remove the connection to allow last ACK
return false
}
func main() {
defer util.Run()()
var handle *pcap.Handle
var err error
if *debug {
outputLevel = 2
} else if *verbose {
outputLevel = 1
} else if *quiet {
outputLevel = -1
}
errorsMap = make(map[string]uint)
if *fname != "" {
if handle, err = pcap.OpenOffline(*fname); err != nil {
log.Fatal("PCAP OpenOffline error:", err)
}
} else {
// This is a little complicated because we want to allow all possible options
// for creating the packet capture handle... instead of all this you can
// just call pcap.OpenLive if you want a simple handle.
inactive, err := pcap.NewInactiveHandle(*iface)
if err != nil {
log.Fatalf("could not create: %v", err)
}
defer inactive.CleanUp()
if err = inactive.SetSnapLen(*snaplen); err != nil {
log.Fatalf("could not set snap length: %v", err)
} else if err = inactive.SetPromisc(*promisc); err != nil {
log.Fatalf("could not set promisc mode: %v", err)
} else if err = inactive.SetTimeout(time.Second); err != nil {
log.Fatalf("could not set timeout: %v", err)
}
if *tstype != "" {
if t, err := pcap.TimestampSourceFromString(*tstype); err != nil {
log.Fatalf("Supported timestamp types: %v", inactive.SupportedTimestamps())
} else if err := inactive.SetTimestampSource(t); err != nil {
log.Fatalf("Supported timestamp types: %v", inactive.SupportedTimestamps())
}
}
if handle, err = inactive.Activate(); err != nil {
log.Fatal("PCAP Activate error:", err)
}
defer handle.Close()
}
if len(flag.Args()) > 0 {
bpffilter := strings.Join(flag.Args(), " ")
Info("Using BPF filter %q\n", bpffilter)
if err = handle.SetBPFFilter(bpffilter); err != nil {
log.Fatal("BPF filter error:", err)
}
}
var dec gopacket.Decoder
var ok bool
decoder_name := *decoder
if decoder_name == "" {
decoder_name = fmt.Sprintf("%s", handle.LinkType())
}
if dec, ok = gopacket.DecodersByLayerName[decoder_name]; !ok {
log.Fatalln("No decoder named", decoder_name)
}
source := gopacket.NewPacketSource(handle, dec)
source.Lazy = *lazy
source.NoCopy = true
Info("Starting to read packets\n")
count := 0
bytes := int64(0)
start := time.Now()
defragger := ip4defrag.NewIPv4Defragmenter()
streamFactory := &tcpStreamFactory{doHTTP: !*nohttp}
streamPool := reassembly.NewStreamPool(streamFactory)
assembler := reassembly.NewAssembler(streamPool)
signalChan := make(chan os.Signal, 1)
signal.Notify(signalChan, os.Interrupt)
for packet := range source.Packets() {
count++
Debug("PACKET #%d\n", count)
data := packet.Data()
bytes += int64(len(data))
if *hexdumppkt {
Debug("Packet content (%d/0x%x)\n%s\n", len(data), len(data), hex.Dump(data))
}
// defrag the IPv4 packet if required
if !*nodefrag {
ip4Layer := packet.Layer(layers.LayerTypeIPv4)
if ip4Layer == nil {
continue
}
ip4 := ip4Layer.(*layers.IPv4)
l := ip4.Length
newip4, err := defragger.DefragIPv4(ip4)
if err != nil {
log.Fatalln("Error while de-fragmenting", err)
} else if newip4 == nil {
Debug("Fragment...\n")
continue // packet fragment, we don't have whole packet yet.
}
if newip4.Length != l {
stats.ipdefrag++
Debug("Decoding re-assembled packet: %s\n", newip4.NextLayerType())
pb, ok := packet.(gopacket.PacketBuilder)
if !ok {
panic("Not a PacketBuilder")
}
nextDecoder := newip4.NextLayerType()
nextDecoder.Decode(newip4.Payload, pb)
}
}
tcp := packet.Layer(layers.LayerTypeTCP)
if tcp != nil {
tcp := tcp.(*layers.TCP)
if *checksum {
err := tcp.SetNetworkLayerForChecksum(packet.NetworkLayer())
if err != nil {
log.Fatalf("Failed to set network layer for checksum: %s\n", err)
}
}
c := Context{
CaptureInfo: packet.Metadata().CaptureInfo,
}
stats.totalsz += len(tcp.Payload)
assembler.AssembleWithContext(packet.NetworkLayer().NetworkFlow(), tcp, &c)
}
if count%*statsevery == 0 {
ref := packet.Metadata().CaptureInfo.Timestamp
flushed, closed := assembler.FlushWithOptions(reassembly.FlushOptions{T: ref.Add(-timeout), TC: ref.Add(-closeTimeout)})
Debug("Forced flush: %d flushed, %d closed (%s)", flushed, closed, ref)
}
done := *maxcount > 0 && count >= *maxcount
if count%*statsevery == 0 || done {
errorsMapMutex.Lock()
errorMapLen := len(errorsMap)
errorsMapMutex.Unlock()
fmt.Fprintf(os.Stderr, "Processed %v packets (%v bytes) in %v (errors: %v, errTypes:%v)\n", count, bytes, time.Since(start), errors, errorMapLen)
}
select {
case <-signalChan:
fmt.Fprintf(os.Stderr, "\nCaught SIGINT: aborting\n")
done = true
default:
// NOP: continue
}
if done {
break
}
}
closed := assembler.FlushAll()
Debug("Final flush: %d closed", closed)
if outputLevel >= 2 {
streamPool.Dump()
}
if *memprofile != "" {
f, err := os.Create(*memprofile)
if err != nil {
log.Fatal(err)
}
pprof.WriteHeapProfile(f)
f.Close()
}
streamFactory.WaitGoRoutines()
Debug("%s\n", assembler.Dump())
if !*nodefrag {
fmt.Printf("IPdefrag:\t\t%d\n", stats.ipdefrag)
}
fmt.Printf("TCP stats:\n")
fmt.Printf(" missed bytes:\t\t%d\n", stats.missedBytes)
fmt.Printf(" total packets:\t\t%d\n", stats.pkt)
fmt.Printf(" rejected FSM:\t\t%d\n", stats.rejectFsm)
fmt.Printf(" rejected Options:\t%d\n", stats.rejectOpt)
fmt.Printf(" reassembled bytes:\t%d\n", stats.sz)
fmt.Printf(" total TCP bytes:\t%d\n", stats.totalsz)
fmt.Printf(" conn rejected FSM:\t%d\n", stats.rejectConnFsm)
fmt.Printf(" reassembled chunks:\t%d\n", stats.reassembled)
fmt.Printf(" out-of-order packets:\t%d\n", stats.outOfOrderPackets)
fmt.Printf(" out-of-order bytes:\t%d\n", stats.outOfOrderBytes)
fmt.Printf(" biggest-chunk packets:\t%d\n", stats.biggestChunkPackets)
fmt.Printf(" biggest-chunk bytes:\t%d\n", stats.biggestChunkBytes)
fmt.Printf(" overlap packets:\t%d\n", stats.overlapPackets)
fmt.Printf(" overlap bytes:\t\t%d\n", stats.overlapBytes)
fmt.Printf("Errors: %d\n", errors)
for e, _ := range errorsMap {
fmt.Printf(" %s:\t\t%d\n", e, errorsMap[e])
}
}
================================================
FILE: examples/snoopread/main.go
================================================
// Copyright 2019 The GoPacket Authors. All rights reserved.
//
// Use of this source code is governed by a BSD-style license
// that can be found in the LICENSE file in the root of the source
// tree.
// snoopread is a example for read a snoop file using
// gopacket and its subpackages and output the decoded data with a package count
package main
import (
"fmt"
"log"
"os"
"github.com/google/gopacket"
"github.com/google/gopacket/pcapgo"
)
func main() {
//download snoop from https://wiki.wireshark.org/SampleCaptures
f, err := os.Open("example.snoop")
if err != nil {
log.Fatal(err)
return
}
defer f.Close()
handle, err := pcapgo.NewSnoopReader(f)
if err != nil {
log.Fatal(err)
return
}
lt, err := handle.LinkType()
if err != nil {
log.Fatal(err)
return
}
packetSource := gopacket.NewPacketSource(handle, lt)
cnt := 0
for packet := range packetSource.Packets() {
fmt.Println(packet)
cnt++
}
fmt.Printf("Packet count: %d\n", cnt)
}
================================================
FILE: examples/statsassembly/main.go
================================================
// Copyright 2012 Google, Inc. All rights reserved.
//
// Use of this source code is governed by a BSD-style license
// that can be found in the LICENSE file in the root of the source
// tree.
// This binary provides sample code for using the gopacket TCP assembler raw,
// without the help of the tcpreader library. It watches TCP streams and
// reports statistics on completed streams.
//
// It also uses gopacket.DecodingLayerParser instead of the normal
// gopacket.PacketSource, to highlight the methods, pros, and cons of this
// approach.
package main
import (
"flag"
"github.com/google/gopacket"
"github.com/google/gopacket/examples/util"
"github.com/google/gopacket/layers"
"github.com/google/gopacket/pcap"
"github.com/google/gopacket/tcpassembly"
"log"
"time"
)
var iface = flag.String("i", "eth0", "Interface to get packets from")
var snaplen = flag.Int("s", 65536, "SnapLen for pcap packet capture")
var filter = flag.String("f", "tcp", "BPF filter for pcap")
var logAllPackets = flag.Bool("v", false, "Log whenever we see a packet")
var bufferedPerConnection = flag.Int("connection_max_buffer", 0, `
Max packets to buffer for a single connection before skipping over a gap in data
and continuing to stream the connection after the buffer. If zero or less, this
is infinite.`)
var bufferedTotal = flag.Int("total_max_buffer", 0, `
Max packets to buffer total before skipping over gaps in connections and
continuing to stream connection data. If zero or less, this is infinite`)
var flushAfter = flag.String("flush_after", "2m", `
Connections which have buffered packets (they've gotten packets out of order and
are waiting for old packets to fill the gaps) are flushed after they're this old
(their oldest gap is skipped). Any string parsed by time.ParseDuration is
acceptable here`)
var packetCount = flag.Int("c", -1, `
Quit after processing this many packets, flushing all currently buffered
connections. If negative, this is infinite`)
// simpleStreamFactory implements tcpassembly.StreamFactory
type statsStreamFactory struct{}
// statsStream will handle the actual decoding of stats requests.
type statsStream struct {
net, transport gopacket.Flow
bytes, packets, outOfOrder, skipped int64
start, end time.Time
sawStart, sawEnd bool
}
// New creates a new stream. It's called whenever the assembler sees a stream
// it isn't currently following.
func (factory *statsStreamFactory) New(net, transport gopacket.Flow) tcpassembly.Stream {
log.Printf("new stream %v:%v started", net, transport)
s := &statsStream{
net: net,
transport: transport,
start: time.Now(),
}
s.end = s.start
// ReaderStream implements tcpassembly.Stream, so we can return a pointer to it.
return s
}
// Reassembled is called whenever new packet data is available for reading.
// Reassembly objects contain stream data IN ORDER.
func (s *statsStream) Reassembled(reassemblies []tcpassembly.Reassembly) {
for _, reassembly := range reassemblies {
if reassembly.Seen.Before(s.end) {
s.outOfOrder++
} else {
s.end = reassembly.Seen
}
s.bytes += int64(len(reassembly.Bytes))
s.packets += 1
if reassembly.Skip > 0 {
s.skipped += int64(reassembly.Skip)
}
s.sawStart = s.sawStart || reassembly.Start
s.sawEnd = s.sawEnd || reassembly.End
}
}
// ReassemblyComplete is called when the TCP assembler believes a stream has
// finished.
func (s *statsStream) ReassemblyComplete() {
diffSecs := float64(s.end.Sub(s.start)) / float64(time.Second)
log.Printf("Reassembly of stream %v:%v complete - start:%v end:%v bytes:%v packets:%v ooo:%v bps:%v pps:%v skipped:%v",
s.net, s.transport, s.start, s.end, s.bytes, s.packets, s.outOfOrder,
float64(s.bytes)/diffSecs, float64(s.packets)/diffSecs, s.skipped)
}
func main() {
defer util.Run()()
flushDuration, err := time.ParseDuration(*flushAfter)
if err != nil {
log.Fatal("invalid flush duration: ", *flushAfter)
}
log.Printf("starting capture on interface %q", *iface)
// Set up pcap packet capture
handle, err := pcap.OpenLive(*iface, int32(*snaplen), true, flushDuration/2)
if err != nil {
log.Fatal("error opening pcap handle: ", err)
}
if err := handle.SetBPFFilter(*filter); err != nil {
log.Fatal("error setting BPF filter: ", err)
}
// Set up assembly
streamFactory := &statsStreamFactory{}
streamPool := tcpassembly.NewStreamPool(streamFactory)
assembler := tcpassembly.NewAssembler(streamPool)
assembler.MaxBufferedPagesPerConnection = *bufferedPerConnection
assembler.MaxBufferedPagesTotal = *bufferedTotal
log.Println("reading in packets")
// We use a DecodingLayerParser here instead of a simpler PacketSource.
// This approach should be measurably faster, but is also more rigid.
// PacketSource will handle any known type of packet safely and easily,
// but DecodingLayerParser will only handle those packet types we
// specifically pass in. This trade-off can be quite useful, though, in
// high-throughput situations.
var eth layers.Ethernet
var dot1q layers.Dot1Q
var ip4 layers.IPv4
var ip6 layers.IPv6
var ip6extensions layers.IPv6ExtensionSkipper
var tcp layers.TCP
var payload gopacket.Payload
parser := gopacket.NewDecodingLayerParser(layers.LayerTypeEthernet,
ð, &dot1q, &ip4, &ip6, &ip6extensions, &tcp, &payload)
decoded := make([]gopacket.LayerType, 0, 4)
nextFlush := time.Now().Add(flushDuration / 2)
var byteCount int64
start := time.Now()
loop:
for ; *packetCount != 0; *packetCount-- {
// Check to see if we should flush the streams we have
// that haven't seen any new data in a while. Note we set a
// timeout on our PCAP handle, so this should happen even if we
// never see packet data.
if time.Now().After(nextFlush) {
stats, _ := handle.Stats()
log.Printf("flushing all streams that haven't seen packets in the last 2 minutes, pcap stats: %+v", stats)
assembler.FlushOlderThan(time.Now().Add(flushDuration))
nextFlush = time.Now().Add(flushDuration / 2)
}
// To speed things up, we're also using the ZeroCopy method for
// reading packet data. This method is faster than the normal
// ReadPacketData, but the returned bytes in 'data' are
// invalidated by any subsequent ZeroCopyReadPacketData call.
// Note that tcpassembly is entirely compatible with this packet
// reading method. This is another trade-off which might be
// appropriate for high-throughput sniffing: it avoids a packet
// copy, but its cost is much more careful handling of the
// resulting byte slice.
data, ci, err := handle.ZeroCopyReadPacketData()
if err != nil {
log.Printf("error getting packet: %v", err)
continue
}
err = parser.DecodeLayers(data, &decoded)
if err != nil {
log.Printf("error decoding packet: %v", err)
continue
}
if *logAllPackets {
log.Printf("decoded the following layers: %v", decoded)
}
byteCount += int64(len(data))
// Find either the IPv4 or IPv6 address to use as our network
// layer.
foundNetLayer := false
var netFlow gopacket.Flow
for _, typ := range decoded {
switch typ {
case layers.LayerTypeIPv4:
netFlow = ip4.NetworkFlow()
foundNetLayer = true
case layers.LayerTypeIPv6:
netFlow = ip6.NetworkFlow()
foundNetLayer = true
case layers.LayerTypeTCP:
if foundNetLayer {
assembler.AssembleWithTimestamp(netFlow, &tcp, ci.Timestamp)
} else {
log.Println("could not find IPv4 or IPv6 layer, inoring")
}
continue loop
}
}
log.Println("could not find TCP layer")
}
assembler.FlushAll()
log.Printf("processed %d bytes in %v", byteCount, time.Since(start))
}
================================================
FILE: examples/synscan/main.go
================================================
// Copyright 2012 Google, Inc. All rights reserved.
//
// Use of this source code is governed by a BSD-style license
// that can be found in the LICENSE file in the root of the source
// tree.
// synscan implements a TCP syn scanner on top of pcap.
// It's more complicated than arpscan, since it has to handle sending packets
// outside the local network, requiring some routing and ARP work.
//
// Since this is just an example program, it aims for simplicity over
// performance. It doesn't handle sending packets very quickly, it scans IPs
// serially instead of in parallel, and uses gopacket.Packet instead of
// gopacket.DecodingLayerParser for packet processing. We also make use of very
// simple timeout logic with time.Since.
//
// Making it blazingly fast is left as an exercise to the reader.
package main
import (
"errors"
"flag"
"log"
"net"
"time"
"github.com/google/gopacket"
"github.com/google/gopacket/examples/util"
"github.com/google/gopacket/layers"
"github.com/google/gopacket/pcap"
"github.com/google/gopacket/routing"
)
// scanner handles scanning a single IP address.
type scanner struct {
// iface is the interface to send packets on.
iface *net.Interface
// destination, gateway (if applicable), and source IP addresses to use.
dst, gw, src net.IP
handle *pcap.Handle
// opts and buf allow us to easily serialize packets in the send()
// method.
opts gopacket.SerializeOptions
buf gopacket.SerializeBuffer
}
// newScanner creates a new scanner for a given destination IP address, using
// router to determine how to route packets to that IP.
func newScanner(ip net.IP, router routing.Router) (*scanner, error) {
s := &scanner{
dst: ip,
opts: gopacket.SerializeOptions{
FixLengths: true,
ComputeChecksums: true,
},
buf: gopacket.NewSerializeBuffer(),
}
// Figure out the route to the IP.
iface, gw, src, err := router.Route(ip)
if err != nil {
return nil, err
}
log.Printf("scanning ip %v with interface %v, gateway %v, src %v", ip, iface.Name, gw, src)
s.gw, s.src, s.iface = gw, src, iface
// Open the handle for reading/writing.
// Note we could very easily add some BPF filtering here to greatly
// decrease the number of packets we have to look at when getting back
// scan results.
handle, err := pcap.OpenLive(iface.Name, 65536, true, pcap.BlockForever)
if err != nil {
return nil, err
}
s.handle = handle
return s, nil
}
// close cleans up the handle.
func (s *scanner) close() {
s.handle.Close()
}
// getHwAddr is a hacky but effective way to get the destination hardware
// address for our packets. It does an ARP request for our gateway (if there is
// one) or destination IP (if no gateway is necessary), then waits for an ARP
// reply. This is pretty slow right now, since it blocks on the ARP
// request/reply.
func (s *scanner) getHwAddr() (net.HardwareAddr, error) {
start := time.Now()
arpDst := s.dst
if s.gw != nil {
arpDst = s.gw
}
// Prepare the layers to send for an ARP request.
eth := layers.Ethernet{
SrcMAC: s.iface.HardwareAddr,
DstMAC: net.HardwareAddr{0xff, 0xff, 0xff, 0xff, 0xff, 0xff},
EthernetType: layers.EthernetTypeARP,
}
arp := layers.ARP{
AddrType: layers.LinkTypeEthernet,
Protocol: layers.EthernetTypeIPv4,
HwAddressSize: 6,
ProtAddressSize: 4,
Operation: layers.ARPRequest,
SourceHwAddress: []byte(s.iface.HardwareAddr),
SourceProtAddress: []byte(s.src),
DstHwAddress: []byte{0, 0, 0, 0, 0, 0},
DstProtAddress: []byte(arpDst),
}
// Send a single ARP request packet (we never retry a send, since this
// is just an example ;)
if err := s.send(ð, &arp); err != nil {
return nil, err
}
// Wait 3 seconds for an ARP reply.
for {
if time.Since(start) > time.Second*3 {
return nil, errors.New("timeout getting ARP reply")
}
data, _, err := s.handle.ReadPacketData()
if err == pcap.NextErrorTimeoutExpired {
continue
} else if err != nil {
return nil, err
}
packet := gopacket.NewPacket(data, layers.LayerTypeEthernet, gopacket.NoCopy)
if arpLayer := packet.Layer(layers.LayerTypeARP); arpLayer != nil {
arp := arpLayer.(*layers.ARP)
if net.IP(arp.SourceProtAddress).Equal(net.IP(arpDst)) {
return net.HardwareAddr(arp.SourceHwAddress), nil
}
}
}
}
// scan scans the dst IP address of this scanner.
func (s *scanner) scan() error {
// First off, get the MAC address we should be sending packets to.
hwaddr, err := s.getHwAddr()
if err != nil {
return err
}
// Construct all the network layers we need.
eth := layers.Ethernet{
SrcMAC: s.iface.HardwareAddr,
DstMAC: hwaddr,
EthernetType: layers.EthernetTypeIPv4,
}
ip4 := layers.IPv4{
SrcIP: s.src,
DstIP: s.dst,
Version: 4,
TTL: 64,
Protocol: layers.IPProtocolTCP,
}
tcp := layers.TCP{
SrcPort: 54321,
DstPort: 0, // will be incremented during the scan
SYN: true,
}
tcp.SetNetworkLayerForChecksum(&ip4)
// Create the flow we expect returning packets to have, so we can check
// against it and discard useless packets.
ipFlow := gopacket.NewFlow(layers.EndpointIPv4, s.dst, s.src)
start := time.Now()
for {
// Send one packet per loop iteration until we've sent packets
// to all of ports [1, 65535].
if tcp.DstPort < 65535 {
start = time.Now()
tcp.DstPort++
if err := s.send(ð, &ip4, &tcp); err != nil {
log.Printf("error sending to port %v: %v", tcp.DstPort, err)
}
}
// Time out 5 seconds after the last packet we sent.
if time.Since(start) > time.Second*5 {
log.Printf("timed out for %v, assuming we've seen all we can", s.dst)
return nil
}
// Read in the next packet.
data, _, err := s.handle.ReadPacketData()
if err == pcap.NextErrorTimeoutExpired {
continue
} else if err != nil {
log.Printf("error reading packet: %v", err)
continue
}
// Parse the packet. We'd use DecodingLayerParser here if we
// wanted to be really fast.
packet := gopacket.NewPacket(data, layers.LayerTypeEthernet, gopacket.NoCopy)
// Find the packets we care about, and print out logging
// information about them. All others are ignored.
if net := packet.NetworkLayer(); net == nil {
// log.Printf("packet has no network layer")
} else if net.NetworkFlow() != ipFlow {
// log.Printf("packet does not match our ip src/dst")
} else if tcpLayer := packet.Layer(layers.LayerTypeTCP); tcpLayer == nil {
// log.Printf("packet has not tcp layer")
} else if tcp, ok := tcpLayer.(*layers.TCP); !ok {
// We panic here because this is guaranteed to never
// happen.
panic("tcp layer is not tcp layer :-/")
} else if tcp.DstPort != 54321 {
// log.Printf("dst port %v does not match", tcp.DstPort)
} else if tcp.RST {
log.Printf(" port %v closed", tcp.SrcPort)
} else if tcp.SYN && tcp.ACK {
log.Printf(" port %v open", tcp.SrcPort)
} else {
// log.Printf("ignoring useless packet")
}
}
}
// send sends the given layers as a single packet on the network.
func (s *scanner) send(l ...gopacket.SerializableLayer) error {
if err := gopacket.SerializeLayers(s.buf, s.opts, l...); err != nil {
return err
}
return s.handle.WritePacketData(s.buf.Bytes())
}
func main() {
defer util.Run()()
router, err := routing.New()
if err != nil {
log.Fatal("routing error:", err)
}
for _, arg := range flag.Args() {
var ip net.IP
if ip = net.ParseIP(arg); ip == nil {
log.Printf("non-ip target: %q", arg)
continue
} else if ip = ip.To4(); ip == nil {
log.Printf("non-ipv4 target: %q", arg)
continue
}
// Note: newScanner creates and closes a pcap Handle once for
// every scan target. We could do much better, were this not an
// example ;)
s, err := newScanner(ip, router)
if err != nil {
log.Printf("unable to create scanner for %v: %v", ip, err)
continue
}
if err := s.scan(); err != nil {
log.Printf("unable to scan %v: %v", ip, err)
}
s.close()
}
}
================================================
FILE: examples/util/util.go
================================================
// Copyright 2012 Google, Inc. All rights reserved.
//
// Use of this source code is governed by a BSD-style license
// that can be found in the LICENSE file in the root of the source
// tree.
// Package util provides shared utilities for all gopacket examples.
package util
import (
"flag"
"log"
"os"
"runtime/pprof"
)
var cpuprofile = flag.String("cpuprofile", "", "Where to write CPU profile")
// Run starts up stuff at the beginning of a main function, and returns a
// function to defer until the function completes. It should be used like this:
//
// func main() {
// defer util.Run()()
// ... stuff ...
// }
func Run() func() {
flag.Parse()
if *cpuprofile != "" {
f, err := os.Create(*cpuprofile)
if err != nil {
log.Fatalf("could not open cpu profile file %q", *cpuprofile)
}
pprof.StartCPUProfile(f)
return func() {
pprof.StopCPUProfile()
f.Close()
}
}
return func() {}
}
================================================
FILE: flows.go
================================================
// Copyright 2012 Google, Inc. All rights reserved.
//
// Use of this source code is governed by a BSD-style license
// that can be found in the LICENSE file in the root of the source
// tree.
package gopacket
import (
"bytes"
"fmt"
"strconv"
)
// MaxEndpointSize determines the maximum size in bytes of an endpoint address.
//
// Endpoints/Flows have a problem: They need to be hashable. Therefore, they
// can't use a byte slice. The two obvious choices are to use a string or a
// byte array. Strings work great, but string creation requires memory
// allocation, which can be slow. Arrays work great, but have a fixed size. We
// originally used the former, now we've switched to the latter. Use of a fixed
// byte-array doubles the speed of constructing a flow (due to not needing to
// allocate). This is a huge increase... too much for us to pass up.
//
// The end result of this, though, is that an endpoint/flow can't be created
// using more than MaxEndpointSize bytes per address.
const MaxEndpointSize = 16
// Endpoint is the set of bytes used to address packets at various layers.
// See LinkLayer, NetworkLayer, and TransportLayer specifications.
// Endpoints are usable as map keys.
type Endpoint struct {
typ EndpointType
len int
raw [MaxEndpointSize]byte
}
// EndpointType returns the endpoint type associated with this endpoint.
func (a Endpoint) EndpointType() EndpointType { return a.typ }
// Raw returns the raw bytes of this endpoint. These aren't human-readable
// most of the time, but they are faster than calling String.
func (a Endpoint) Raw() []byte { return a.raw[:a.len] }
// LessThan provides a stable ordering for all endpoints. It sorts first based
// on the EndpointType of an endpoint, then based on the raw bytes of that
// endpoint.
//
// For some endpoints, the actual comparison may not make sense, however this
// ordering does provide useful information for most Endpoint types.
// Ordering is based first on endpoint type, then on raw endpoint bytes.
// Endpoint bytes are sorted lexicographically.
func (a Endpoint) LessThan(b Endpoint) bool {
return a.typ < b.typ || (a.typ == b.typ && bytes.Compare(a.raw[:a.len], b.raw[:b.len]) < 0)
}
// fnvHash is used by our FastHash functions, and implements the FNV hash
// created by Glenn Fowler, Landon Curt Noll, and Phong Vo.
// See http://isthe.com/chongo/tech/comp/fnv/.
func fnvHash(s []byte) (h uint64) {
h = fnvBasis
for i := 0; i < len(s); i++ {
h ^= uint64(s[i])
h *= fnvPrime
}
return
}
const fnvBasis = 14695981039346656037
const fnvPrime = 1099511628211
// FastHash provides a quick hashing function for an endpoint, useful if you'd
// like to split up endpoints by modulos or other load-balancing techniques.
// It uses a variant of Fowler-Noll-Vo hashing.
//
// The output of FastHash is not guaranteed to remain the same through future
// code revisions, so should not be used to key values in persistent storage.
func (a Endpoint) FastHash() (h uint64) {
h = fnvHash(a.raw[:a.len])
h ^= uint64(a.typ)
h *= fnvPrime
return
}
// NewEndpoint creates a new Endpoint object.
//
// The size of raw must be less than MaxEndpointSize, otherwise this function
// will panic.
func NewEndpoint(typ EndpointType, raw []byte) (e Endpoint) {
e.len = len(raw)
if e.len > MaxEndpointSize {
panic("raw byte length greater than MaxEndpointSize")
}
e.typ = typ
copy(e.raw[:], raw)
return
}
// EndpointTypeMetadata is used to register a new endpoint type.
type EndpointTypeMetadata struct {
// Name is the string returned by an EndpointType's String function.
Name string
// Formatter is called from an Endpoint's String function to format the raw
// bytes in an Endpoint into a human-readable string.
Formatter func([]byte) string
}
// EndpointType is the type of a gopacket Endpoint. This type determines how
// the bytes stored in the endpoint should be interpreted.
type EndpointType int64
var endpointTypes = map[EndpointType]EndpointTypeMetadata{}
// RegisterEndpointType creates a new EndpointType and registers it globally.
// It MUST be passed a unique number, or it will panic. Numbers 0-999 are
// reserved for gopacket's use.
func RegisterEndpointType(num int, meta EndpointTypeMetadata) EndpointType {
t := EndpointType(num)
if _, ok := endpointTypes[t]; ok {
panic("Endpoint type number already in use")
}
endpointTypes[t] = meta
return t
}
func (e EndpointType) String() string {
if t, ok := endpointTypes[e]; ok {
return t.Name
}
return strconv.Itoa(int(e))
}
func (a Endpoint) String() string {
if t, ok := endpointTypes[a.typ]; ok && t.Formatter != nil {
return t.Formatter(a.raw[:a.len])
}
return fmt.Sprintf("%v:%v", a.typ, a.raw)
}
// Flow represents the direction of traffic for a packet layer, as a source and destination Endpoint.
// Flows are usable as map keys.
type Flow struct {
typ EndpointType
slen, dlen int
src, dst [MaxEndpointSize]byte
}
// FlowFromEndpoints creates a new flow by pasting together two endpoints.
// The endpoints must have the same EndpointType, or this function will return
// an error.
func FlowFromEndpoints(src, dst Endpoint) (_ Flow, err error) {
if src.typ != dst.typ {
err = fmt.Errorf("Mismatched endpoint types: %v->%v", src.typ, dst.typ)
return
}
return Flow{src.typ, src.len, dst.len, src.raw, dst.raw}, nil
}
// FastHash provides a quick hashing function for a flow, useful if you'd
// like to split up flows by modulos or other load-balancing techniques.
// It uses a variant of Fowler-Noll-Vo hashing, and is guaranteed to collide
// with its reverse flow. IE: the flow A->B will have the same hash as the flow
// B->A.
//
// The output of FastHash is not guaranteed to remain the same through future
// code revisions, so should not be used to key values in persistent storage.
func (f Flow) FastHash() (h uint64) {
// This combination must be commutative. We don't use ^, since that would
// give the same hash for all A->A flows.
h = fnvHash(f.src[:f.slen]) + fnvHash(f.dst[:f.dlen])
h ^= uint64(f.typ)
h *= fnvPrime
return
}
// String returns a human-readable representation of this flow, in the form
// "Src->Dst"
func (f Flow) String() string {
s, d := f.Endpoints()
return fmt.Sprintf("%v->%v", s, d)
}
// EndpointType returns the EndpointType for this Flow.
func (f Flow) EndpointType() EndpointType {
return f.typ
}
// Endpoints returns the two Endpoints for this flow.
func (f Flow) Endpoints() (src, dst Endpoint) {
return Endpoint{f.typ, f.slen, f.src}, Endpoint{f.typ, f.dlen, f.dst}
}
// Src returns the source Endpoint for this flow.
func (f Flow) Src() (src Endpoint) {
src, _ = f.Endpoints()
return
}
// Dst returns the destination Endpoint for this flow.
func (f Flow) Dst() (dst Endpoint) {
_, dst = f.Endpoints()
return
}
// Reverse returns a new flow with endpoints reversed.
func (f Flow) Reverse() Flow {
return Flow{f.typ, f.dlen, f.slen, f.dst, f.src}
}
// NewFlow creates a new flow.
//
// src and dst must have length <= MaxEndpointSize, otherwise NewFlow will
// panic.
func NewFlow(t EndpointType, src, dst []byte) (f Flow) {
f.slen = len(src)
f.dlen = len(dst)
if f.slen > MaxEndpointSize || f.dlen > MaxEndpointSize {
panic("flow raw byte length greater than MaxEndpointSize")
}
f.typ = t
copy(f.src[:], src)
copy(f.dst[:], dst)
return
}
// EndpointInvalid is an endpoint type used for invalid endpoints, IE endpoints
// that are specified incorrectly during creation.
var EndpointInvalid = RegisterEndpointType(0, EndpointTypeMetadata{Name: "invalid", Formatter: func(b []byte) string {
return fmt.Sprintf("%v", b)
}})
// InvalidEndpoint is a singleton Endpoint of type EndpointInvalid.
var InvalidEndpoint = NewEndpoint(EndpointInvalid, nil)
// InvalidFlow is a singleton Flow of type EndpointInvalid.
var InvalidFlow = NewFlow(EndpointInvalid, nil, nil)
================================================
FILE: gc
================================================
#!/bin/bash
# Copyright 2012 Google, Inc. All rights reserved.
# This script provides a simple way to run benchmarks against previous code and
# keep a log of how benchmarks change over time. When used with the --benchmark
# flag, it runs benchmarks from the current code and from the last commit run
# with --benchmark, then stores the results in the git commit description. We
# rerun the old benchmarks along with the new ones, since there's no guarantee
# that git commits will happen on the same machine, so machine differences could
# cause wildly inaccurate results.
#
# If you're making changes to 'gopacket' which could cause performance changes,
# you may be requested to use this commit script to make sure your changes don't
# have large detrimental effects (or to show off how awesome your performance
# improvements are).
#
# If not run with the --benchmark flag, this script is still very useful... it
# makes sure all the correct go formatting, building, and testing work as
# expected.
function Usage {
cat <<EOF
USAGE: $0 [--benchmark regexp] [--root] [--gen] <git commit flags...>
--benchmark: Run benchmark comparisons against last benchmark'd commit
--root: Run tests that require root priviledges
--gen: Generate code for MACs/ports by pulling down external data
Note, some 'git commit' flags are necessary, if all else fails, pass in -a
EOF
exit 1
}
BENCH=""
GEN=""
ROOT=""
while [ ! -z "$1" ]; do
case "$1" in
"--benchmark")
BENCH="$2"
shift
shift
;;
"--gen")
GEN="yes"
shift
;;
"--root")
ROOT="yes"
shift
;;
"--help")
Usage
;;
"-h")
Usage
;;
"help")
Usage
;;
*)
break
;;
esac
done
function Root {
if [ ! -z "$ROOT" ]; then
local exec="$1"
# Some folks (like me) keep source code in places inaccessible by root (like
# NFS), so to make sure things run smoothly we copy them to a /tmp location.
local tmpfile="$(mktemp -t gopacket_XXXXXXXX)"
echo "Running root test executable $exec as $tmpfile"
cp "$exec" "$tmpfile"
chmod a+x "$tmpfile"
shift
sudo "$tmpfile" "$@"
fi
}
if [ "$#" -eq "0" ]; then
Usage
fi
cd $(dirname $0)
# Check for copyright notices.
for filename in $(find ./ -type f -name '*.go'); do
if ! head -n 1 "$filename" | grep -q Copyright; then
echo "File '$filename' may not have copyright notice"
exit 1
fi
done
set -e
set -x
if [ ! -z "$ROOT" ]; then
echo "Running SUDO to get root priviledges for root tests"
sudo echo "have root"
fi
if [ ! -z "$GEN" ]; then
pushd macs
go run gen.go | gofmt > valid_mac_prefixes.go
popd
pushd layers
go run gen.go | gofmt > iana_ports.go
go run gen2.go | gofmt > enums_generated.go
popd
fi
# Make sure everything is formatted, compiles, and tests pass.
go fmt ./...
go test -i ./... 2>/dev/null >/dev/null || true
go test
go build
pushd examples/bytediff
go build
popd
if [ -f /usr/include/pcap.h ]; then
pushd pcap
go test ./...
go build ./...
go build pcap_tester.go
Root pcap_tester --mode=basic
Root pcap_tester --mode=filtered
Root pcap_tester --mode=timestamp || echo "You might not support timestamp sources"
popd
pushd examples/afpacket
go build
popd
pushd examples/pcapdump
go build
popd
pushd examples/arpscan
go build
popd
pushd examples/bidirectional
go build
popd
pushd examples/synscan
go build
popd
pushd examples/httpassembly
go build
popd
pushd examples/statsassembly
go build
popd
fi
pushd macs
go test ./...
gofmt -w gen.go
go build gen.go
popd
pushd tcpassembly
go test ./...
popd
pushd reassembly
go test ./...
popd
pushd layers
gofmt -w gen.go
go build gen.go
go test ./...
popd
pushd pcapgo
go test ./...
go build ./...
popd
if [ -f /usr/include/linux/if_packet.h ]; then
if grep -q TPACKET_V3 /usr/include/linux/if_packet.h; then
pushd afpacket
go build ./...
go test ./...
popd
fi
fi
if [ -f /usr/include/pfring.h ]; then
pushd pfring
go test ./...
go build ./...
popd
pushd examples/pfdump
go build
popd
fi
pushd ip4defrag
go test ./...
popd
pushd defrag
go test ./...
popd
for travis_script in `ls .travis.*.sh`; do
./$travis_script
done
# Run our initial commit
git commit "$@"
if [ -z "$BENCH" ]; then
set +x
echo "We're not benchmarking and we've committed... we're done!"
exit
fi
### If we get here, we want to run benchmarks from current commit, and compare
### then to benchmarks from the last --benchmark commit
gitextract_4ywj3pz3/ ├── .gitignore ├── .travis.gofmt.sh ├── .travis.golint.sh ├── .travis.govet.sh ├── .travis.install.sh ├── .travis.script.sh ├── .travis.yml ├── AUTHORS ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── afpacket/ │ ├── afpacket.go │ ├── afpacket_test.go │ ├── header.go │ ├── options.go │ └── sockopt_linux.go ├── base.go ├── benchmark_test.go ├── bsdbpf/ │ └── bsd_bpf_sniffer.go ├── bytediff/ │ ├── bytediff.go │ └── bytediff_test.go ├── decode.go ├── defrag/ │ └── lcmdefrag/ │ ├── lcmdefrag.go │ └── lcmdefrag_test.go ├── doc.go ├── dumpcommand/ │ └── tcpdump.go ├── examples/ │ ├── afpacket/ │ │ └── afpacket.go │ ├── arpscan/ │ │ └── arpscan.go │ ├── bidirectional/ │ │ └── main.go │ ├── bytediff/ │ │ └── main.go │ ├── httpassembly/ │ │ └── main.go │ ├── pcapdump/ │ │ └── main.go │ ├── pcaplay/ │ │ └── main.go │ ├── pfdump/ │ │ └── main.go │ ├── reassemblydump/ │ │ ├── compare.sh │ │ └── main.go │ ├── snoopread/ │ │ └── main.go │ ├── statsassembly/ │ │ └── main.go │ ├── synscan/ │ │ └── main.go │ └── util/ │ └── util.go ├── flows.go ├── gc ├── gen.go ├── go.mod ├── go.sum ├── ip4defrag/ │ ├── defrag.go │ └── defrag_test.go ├── layerclass.go ├── layers/ │ ├── .lint_blacklist │ ├── ague_var0.go │ ├── ague_var0_test.go │ ├── ague_var1.go │ ├── ague_var1_test.go │ ├── apsp.go │ ├── apsp_test.go │ ├── arp.go │ ├── asf.go │ ├── asf_presencepong.go │ ├── asf_presencepong_test.go │ ├── asf_test.go │ ├── base.go │ ├── base_test.go │ ├── bfd.go │ ├── bfd_test.go │ ├── bitfield.go │ ├── bitfield_test.go │ ├── cdp.go │ ├── ctp.go │ ├── decode_test.go │ ├── dhcp_test.go │ ├── dhcpv4.go │ ├── dhcpv6.go │ ├── dhcpv6_options.go │ ├── dhcpv6_test.go │ ├── dns.go │ ├── dns_test.go │ ├── doc.go │ ├── dot11.go │ ├── dot11_test.go │ ├── dot1q.go │ ├── dot1q_test.go │ ├── eap.go │ ├── eapol.go │ ├── eapol_test.go │ ├── endpoints.go │ ├── endpoints_test.go │ ├── enums.go │ ├── enums_generated.go │ ├── erspan2.go │ ├── erspan2_test.go │ ├── etherip.go │ ├── ethernet.go │ ├── fddi.go │ ├── fuzz_layer.go │ ├── gen.go │ ├── gen2.go │ ├── gen_linted.sh │ ├── geneve.go │ ├── geneve_test.go │ ├── gre.go │ ├── gre_test.go │ ├── gtp.go │ ├── gtp_test.go │ ├── iana_ports.go │ ├── icmp4.go │ ├── icmp6.go │ ├── icmp6NDflags_test.go │ ├── icmp6_test.go │ ├── icmp6hopbyhop_test.go │ ├── icmp6msg.go │ ├── icmp6msg_test.go │ ├── igmp.go │ ├── igmp_test.go │ ├── ip4.go │ ├── ip4_test.go │ ├── ip6.go │ ├── ip6_test.go │ ├── ipsec.go │ ├── ipsec_test.go │ ├── layertypes.go │ ├── lcm.go │ ├── lcm_test.go │ ├── linux_sll.go │ ├── llc.go │ ├── lldp.go │ ├── lldp_test.go │ ├── loopback.go │ ├── mldv1.go │ ├── mldv1_test.go │ ├── mldv2.go │ ├── mldv2_test.go │ ├── modbustcp.go │ ├── mpls.go │ ├── mpls_test.go │ ├── ndp.go │ ├── ntp.go │ ├── ntp_test.go │ ├── ospf.go │ ├── ospf_test.go │ ├── pflog.go │ ├── ports.go │ ├── ppp.go │ ├── pppoe.go │ ├── prism.go │ ├── prism_test.go │ ├── radiotap.go │ ├── radiotap_test.go │ ├── radius.go │ ├── radius_test.go │ ├── rmcp.go │ ├── rmcp_test.go │ ├── rudp.go │ ├── sctp.go │ ├── sflow.go │ ├── sflow_test.go │ ├── sip.go │ ├── sip_test.go │ ├── stp.go │ ├── stp_test.go │ ├── tcp.go │ ├── tcp_test.go │ ├── tcpip.go │ ├── tcpip_test.go │ ├── test_creator.py │ ├── testdata/ │ │ └── fuzz/ │ │ └── FuzzDecodeFromBytes/ │ │ ├── 27d23183d8ce7b719228870c23869cf21bf8829d7160c82da88f80aeff2d861c │ │ ├── 3b53f220d321f20980b59f64e1617d6b334b152a90b141a7407c3c8fa4837a31 │ │ ├── f539b7a397cf68c2129abd63d4c7cfb1979c489ad9bad6898510a4d4759bb85f │ │ └── fe20300d6b2057b406a06ec4f04065f6d0dda6b2b362c0a89192c1933e927adf │ ├── tls.go │ ├── tls_alert.go │ ├── tls_appdata.go │ ├── tls_cipherspec.go │ ├── tls_handshake.go │ ├── tls_test.go │ ├── udp.go │ ├── udp_test.go │ ├── udplite.go │ ├── usb.go │ ├── usb_test.go │ ├── vrrp.go │ ├── vrrp_test.go │ ├── vxlan.go │ └── vxlan_test.go ├── layers_decoder.go ├── layertype.go ├── macs/ │ ├── benchmark_test.go │ ├── doc.go │ ├── gen.go │ └── valid_mac_prefixes.go ├── packet.go ├── packet_test.go ├── parser.go ├── pcap/ │ ├── bpf_test.go │ ├── defs_windows_386.go │ ├── defs_windows_amd64.go │ ├── doc.go │ ├── generate_defs.go │ ├── gopacket_benchmark/ │ │ └── benchmark.go │ ├── pcap.go │ ├── pcap_test.go │ ├── pcap_tester.go │ ├── pcap_unix.go │ ├── pcap_windows.go │ ├── pcapgo_test.go │ ├── pcapnggo_test.go │ ├── test_dns.pcap │ ├── test_ethernet.pcap │ └── test_loopback.pcap ├── pcapgo/ │ ├── capture.go │ ├── capture_test.go │ ├── doc.go │ ├── ngread.go │ ├── ngread_test.go │ ├── ngwrite.go │ ├── ngwrite_test.go │ ├── pcapng.go │ ├── read.go │ ├── read_test.go │ ├── snoop.go │ ├── snoop_test.go │ ├── tests/ │ │ ├── README.md │ │ ├── be/ │ │ │ ├── test001.pcapng │ │ │ ├── test002.pcapng │ │ │ ├── test003.pcapng │ │ │ ├── test004.pcapng │ │ │ ├── test005.pcapng │ │ │ ├── test006.pcapng │ │ │ ├── test007.pcapng │ │ │ ├── test008.pcapng │ │ │ ├── test009.pcapng │ │ │ ├── test010.pcapng │ │ │ ├── test011.pcapng │ │ │ ├── test012.pcapng │ │ │ ├── test013.pcapng │ │ │ ├── test014.pcapng │ │ │ ├── test015.pcapng │ │ │ ├── test016.pcapng │ │ │ ├── test017.pcapng │ │ │ ├── test018.pcapng │ │ │ ├── test100.pcapng │ │ │ ├── test101.pcapng │ │ │ ├── test102.pcapng │ │ │ ├── test200.pcapng │ │ │ ├── test201.pcapng │ │ │ ├── test202.pcapng │ │ │ ├── test901.pcapng │ │ │ └── test902.pcapng │ │ ├── le/ │ │ │ ├── test001.pcapng │ │ │ ├── test002.pcapng │ │ │ ├── test003.pcapng │ │ │ ├── test004.pcapng │ │ │ ├── test005.pcapng │ │ │ ├── test006.pcapng │ │ │ ├── test007.pcapng │ │ │ ├── test008.pcapng │ │ │ ├── test009.pcapng │ │ │ ├── test010.pcapng │ │ │ ├── test011.pcapng │ │ │ ├── test012.pcapng │ │ │ ├── test013.pcapng │ │ │ ├── test014.pcapng │ │ │ ├── test015.pcapng │ │ │ ├── test016.pcapng │ │ │ ├── test017.pcapng │ │ │ ├── test018.pcapng │ │ │ ├── test100.pcapng │ │ │ ├── test101.pcapng │ │ │ ├── test102.pcapng │ │ │ ├── test200.pcapng │ │ │ ├── test201.pcapng │ │ │ ├── test202.pcapng │ │ │ ├── test901.pcapng │ │ │ └── test902.pcapng │ │ ├── test901.lua │ │ └── test902.lua │ ├── write.go │ └── write_test.go ├── pfring/ │ ├── doc.go │ ├── pfring.go │ └── pfring_test.go ├── reassembly/ │ ├── cap2test.go │ ├── memory.go │ ├── tcpassembly.go │ ├── tcpassembly_test.go │ ├── tcpcheck.go │ └── tcpcheck_test.go ├── routing/ │ ├── common.go │ ├── other.go │ ├── routing.go │ └── routing_test.go ├── tcpassembly/ │ ├── assembly.go │ ├── assembly_test.go │ └── tcpreader/ │ ├── reader.go │ └── reader_test.go ├── time.go ├── time_test.go ├── writer.go └── writer_test.go
Showing preview only (485K chars total). Download the full file or copy to clipboard to get everything.
SYMBOL INDEX (5291 symbols across 210 files)
FILE: afpacket/afpacket.go
type AncillaryVLAN (line 55) | type AncillaryVLAN struct
type Stats (line 61) | type Stats struct
type SocketStats (line 71) | type SocketStats
method Packets (line 74) | func (s *SocketStats) Packets() uint {
method Drops (line 79) | func (s *SocketStats) Drops() uint {
type SocketStatsV3 (line 84) | type SocketStatsV3
method Packets (line 87) | func (s *SocketStatsV3) Packets() uint {
method Drops (line 92) | func (s *SocketStatsV3) Drops() uint {
method QueueFreezes (line 97) | func (s *SocketStatsV3) QueueFreezes() uint {
type TPacket (line 102) | type TPacket struct
method bindToInterface (line 139) | func (h *TPacket) bindToInterface(ifaceName string) error {
method setTPacketVersion (line 157) | func (h *TPacket) setTPacketVersion(version OptTPacketVersion) error {
method setRequestedTPacketVersion (line 165) | func (h *TPacket) setRequestedTPacketVersion() error {
method setUpRing (line 180) | func (h *TPacket) setUpRing() (err error) {
method Close (line 217) | func (h *TPacket) Close() {
method SetBPF (line 266) | func (h *TPacket) SetBPF(filter []bpf.RawInstruction) error {
method SetEBPF (line 278) | func (h *TPacket) SetEBPF(progFd int32) error {
method releaseCurrentPacket (line 282) | func (h *TPacket) releaseCurrentPacket() error {
method ZeroCopyReadPacketData (line 300) | func (h *TPacket) ZeroCopyReadPacketData() (data []byte, ci gopacket.C...
method Stats (line 335) | func (h *TPacket) Stats() (Stats, error) {
method InitSocketStats (line 343) | func (h *TPacket) InitSocketStats() error {
method SocketStats (line 369) | func (h *TPacket) SocketStats() (SocketStats, SocketStatsV3, error) {
method ReadPacketDataTo (line 407) | func (h *TPacket) ReadPacketDataTo(data []byte) (ci gopacket.CaptureIn...
method ReadPacketData (line 420) | func (h *TPacket) ReadPacketData() (data []byte, ci gopacket.CaptureIn...
method getTPacketHeader (line 431) | func (h *TPacket) getTPacketHeader() header {
method pollForFirstPacket (line 457) | func (h *TPacket) pollForFirstPacket(hdr header) error {
method SetFanout (line 511) | func (h *TPacket) SetFanout(t FanoutType, id uint16) error {
method WritePacketData (line 520) | func (h *TPacket) WritePacketData(pkt []byte) error {
function NewTPacket (line 235) | func NewTPacket(opts ...interface{}) (h *TPacket, err error) {
type FanoutType (line 488) | type FanoutType
constant FanoutHash (line 492) | FanoutHash FanoutType = unix.PACKET_FANOUT_HASH
constant FanoutHashWithDefrag (line 495) | FanoutHashWithDefrag FanoutType = unix.PACKET_FANOUT_FLAG_DEFRAG
constant FanoutLoadBalance (line 496) | FanoutLoadBalance FanoutType = unix.PACKET_FANOUT_LB
constant FanoutCPU (line 497) | FanoutCPU FanoutType = unix.PACKET_FANOUT_CPU
constant FanoutRollover (line 498) | FanoutRollover FanoutType = unix.PACKET_FANOUT_ROLLOVER
constant FanoutRandom (line 499) | FanoutRandom FanoutType = unix.PACKET_FANOUT_RND
constant FanoutQueueMapping (line 500) | FanoutQueueMapping FanoutType = unix.PACKET_FANOUT_QM
constant FanoutCBPF (line 501) | FanoutCBPF FanoutType = unix.PACKET_FANOUT_CBPF
constant FanoutEBPF (line 502) | FanoutEBPF FanoutType = unix.PACKET_FANOUT_EBPF
FILE: afpacket/afpacket_test.go
function TestParseOptions (line 16) | func TestParseOptions(t *testing.T) {
FILE: afpacket/header.go
type header (line 30) | type header interface
constant tpacketAlignment (line 57) | tpacketAlignment = uint(unix.TPACKET_ALIGNMENT)
function tpAlign (line 59) | func tpAlign(x int) int {
type v1header (line 63) | type v1header
method getVLAN (line 84) | func (h *v1header) getVLAN() int {
method getStatus (line 87) | func (h *v1header) getStatus() int {
method clearStatus (line 90) | func (h *v1header) clearStatus() {
method getTime (line 93) | func (h *v1header) getTime() time.Time {
method getData (line 96) | func (h *v1header) getData(opts *options) []byte {
method getLength (line 99) | func (h *v1header) getLength() int {
method getIfaceIndex (line 102) | func (h *v1header) getIfaceIndex() int {
method next (line 106) | func (h *v1header) next() bool {
type v2header (line 64) | type v2header
method getVLAN (line 110) | func (h *v2header) getVLAN() int {
method getStatus (line 113) | func (h *v2header) getStatus() int {
method clearStatus (line 116) | func (h *v2header) clearStatus() {
method getTime (line 119) | func (h *v2header) getTime() time.Time {
method getData (line 122) | func (h *v2header) getData(opts *options) []byte {
method getLength (line 126) | func (h *v2header) getLength() int {
method getIfaceIndex (line 129) | func (h *v2header) getIfaceIndex() int {
method next (line 133) | func (h *v2header) next() bool {
function makeSlice (line 66) | func makeSlice(start uintptr, length int) (data []byte) {
function insertVlanHeader (line 74) | func insertVlanHeader(data []byte, vlanTCI int, opts *options) []byte {
type v3wrapper (line 137) | type v3wrapper struct
method getVLAN (line 151) | func (w *v3wrapper) getVLAN() int {
method getStatus (line 159) | func (w *v3wrapper) getStatus() int {
method clearStatus (line 162) | func (w *v3wrapper) clearStatus() {
method getTime (line 165) | func (w *v3wrapper) getTime() time.Time {
method getData (line 168) | func (w *v3wrapper) getData(opts *options) []byte {
method getLength (line 174) | func (w *v3wrapper) getLength() int {
method getIfaceIndex (line 177) | func (w *v3wrapper) getIfaceIndex() int {
method next (line 181) | func (w *v3wrapper) next() bool {
function initV3Wrapper (line 144) | func initV3Wrapper(block unsafe.Pointer) (w v3wrapper) {
FILE: afpacket/options.go
type OptTPacketVersion (line 21) | type OptTPacketVersion
method String (line 24) | func (t OptTPacketVersion) String() string {
type OptSocketType (line 39) | type OptSocketType
method String (line 41) | func (t OptSocketType) String() string {
constant TPacketVersionHighestAvailable (line 55) | TPacketVersionHighestAvailable = OptTPacketVersion(-1)
constant TPacketVersion1 (line 56) | TPacketVersion1 = OptTPacketVersion(unix.TPACKET_V1)
constant TPacketVersion2 (line 57) | TPacketVersion2 = OptTPacketVersion(unix.TPACKET_V2)
constant TPacketVersion3 (line 58) | TPacketVersion3 = OptTPacketVersion(unix.TPACKET_V3)
constant tpacketVersionMax (line 59) | tpacketVersionMax = TPacketVersion3
constant tpacketVersionMin (line 60) | tpacketVersionMin = -1
constant SocketRaw (line 63) | SocketRaw = OptSocketType(unix.SOCK_RAW)
constant SocketDgram (line 66) | SocketDgram = OptSocketType(unix.SOCK_DGRAM)
type OptInterface (line 71) | type OptInterface
type OptFrameSize (line 75) | type OptFrameSize
type OptBlockSize (line 79) | type OptBlockSize
type OptNumBlocks (line 83) | type OptNumBlocks
type OptBlockTimeout (line 87) | type OptBlockTimeout
type OptPollTimeout (line 91) | type OptPollTimeout
type OptAddVLANHeader (line 107) | type OptAddVLANHeader
constant DefaultFrameSize (line 111) | DefaultFrameSize = 4096
constant DefaultBlockSize (line 112) | DefaultBlockSize = DefaultFrameSize * 128
constant DefaultNumBlocks (line 113) | DefaultNumBlocks = 128
constant DefaultBlockTimeout (line 114) | DefaultBlockTimeout = 64 * time.Millisecond
constant DefaultPollTimeout (line 115) | DefaultPollTimeout = -1 * time.Millisecond
type options (line 118) | type options struct
method check (line 174) | func (o options) check() error {
function parseOptions (line 141) | func parseOptions(opts ...interface{}) (ret options, err error) {
FILE: afpacket/sockopt_linux.go
function setsockopt (line 18) | func setsockopt(fd, level, name int, val unsafe.Pointer, vallen uintptr)...
function getsockopt (line 36) | func getsockopt(fd, level, name int, val unsafe.Pointer, vallen uintptr)...
function htons (line 56) | func htons(i uint16) uint16 {
FILE: base.go
type Layer (line 19) | type Layer interface
type Payload (line 33) | type Payload
method LayerType (line 36) | func (p Payload) LayerType() LayerType { return LayerTypePayload }
method LayerContents (line 39) | func (p Payload) LayerContents() []byte { return []byte(p) }
method LayerPayload (line 42) | func (p Payload) LayerPayload() []byte { return nil }
method Payload (line 45) | func (p Payload) Payload() []byte { return []byte(p) }
method String (line 48) | func (p Payload) String() string { return fmt.Sprintf("%d byte(s)", le...
method GoString (line 51) | func (p Payload) GoString() string { return LongBytesGoString([]byte(p...
method CanDecode (line 54) | func (p Payload) CanDecode() LayerClass { return LayerTypePayload }
method NextLayerType (line 57) | func (p Payload) NextLayerType() LayerType { return LayerTypeZero }
method DecodeFromBytes (line 60) | func (p *Payload) DecodeFromBytes(data []byte, df DecodeFeedback) error {
method SerializeTo (line 68) | func (p Payload) SerializeTo(b SerializeBuffer, opts SerializeOptions)...
function decodePayload (line 78) | func decodePayload(data []byte, p PacketBuilder) error {
type Fragment (line 90) | type Fragment
method LayerType (line 93) | func (p *Fragment) LayerType() LayerType { return LayerTypeFragment }
method LayerContents (line 96) | func (p *Fragment) LayerContents() []byte { return []byte(*p) }
method LayerPayload (line 99) | func (p *Fragment) LayerPayload() []byte { return nil }
method Payload (line 102) | func (p *Fragment) Payload() []byte { return []byte(*p) }
method String (line 105) | func (p *Fragment) String() string { return fmt.Sprintf("%d byte(s)", ...
method CanDecode (line 108) | func (p *Fragment) CanDecode() LayerClass { return LayerTypeFragment }
method NextLayerType (line 111) | func (p *Fragment) NextLayerType() LayerType { return LayerTypeZero }
method DecodeFromBytes (line 114) | func (p *Fragment) DecodeFromBytes(data []byte, df DecodeFeedback) err...
method SerializeTo (line 122) | func (p *Fragment) SerializeTo(b SerializeBuffer, opts SerializeOption...
function decodeFragment (line 132) | func decodeFragment(data []byte, p PacketBuilder) error {
type LinkLayer (line 146) | type LinkLayer interface
type NetworkLayer (line 153) | type NetworkLayer interface
type TransportLayer (line 160) | type TransportLayer interface
type ApplicationLayer (line 167) | type ApplicationLayer interface
type ErrorLayer (line 175) | type ErrorLayer interface
FILE: benchmark_test.go
type testError (line 17) | type testError struct
method Error (line 19) | func (t *testError) Error() string { return "abc" }
function BenchmarkTypeAssertion (line 21) | func BenchmarkTypeAssertion(b *testing.B) {
function BenchmarkMapLookup (line 28) | func BenchmarkMapLookup(b *testing.B) {
function BenchmarkNilMapLookup (line 37) | func BenchmarkNilMapLookup(b *testing.B) {
function BenchmarkNilMapLookupWithNilCheck (line 44) | func BenchmarkNilMapLookupWithNilCheck(b *testing.B) {
function BenchmarkArrayLookup (line 53) | func BenchmarkArrayLookup(b *testing.B) {
function BenchmarkTypeToInterface1 (line 63) | func BenchmarkTypeToInterface1(b *testing.B) {
function BenchmarkTypeToInterface2 (line 72) | func BenchmarkTypeToInterface2(b *testing.B) {
function decodeOptsByValue (line 84) | func decodeOptsByValue(_ DecodeOptions) {}
function decodeOptsByPointer (line 85) | func decodeOptsByPointer(_ *DecodeOptions) {}
function BenchmarkPassDecodeOptionsByValue (line 86) | func BenchmarkPassDecodeOptionsByValue(b *testing.B) {
function BenchmarkPassDecodeOptionsByPointer (line 91) | func BenchmarkPassDecodeOptionsByPointer(b *testing.B) {
function BenchmarkLockOSThread (line 97) | func BenchmarkLockOSThread(b *testing.B) {
function BenchmarkUnlockOSThread (line 102) | func BenchmarkUnlockOSThread(b *testing.B) {
function lockUnlock (line 107) | func lockUnlock() {
function lockDeferUnlock (line 111) | func lockDeferUnlock() {
function BenchmarkLockUnlockOSThread (line 115) | func BenchmarkLockUnlockOSThread(b *testing.B) {
function BenchmarkLockDeferUnlockOSThread (line 120) | func BenchmarkLockDeferUnlockOSThread(b *testing.B) {
function BenchmarkUnbufferedChannel (line 126) | func BenchmarkUnbufferedChannel(b *testing.B) {
function BenchmarkSmallBufferedChannel (line 141) | func BenchmarkSmallBufferedChannel(b *testing.B) {
function BenchmarkLargeBufferedChannel (line 156) | func BenchmarkLargeBufferedChannel(b *testing.B) {
function BenchmarkEndpointFastHashShort (line 171) | func BenchmarkEndpointFastHashShort(b *testing.B) {
function BenchmarkEndpointFastHashLong (line 177) | func BenchmarkEndpointFastHashLong(b *testing.B) {
function BenchmarkFlowFastHashShort (line 183) | func BenchmarkFlowFastHashShort(b *testing.B) {
function BenchmarkFlowFastHashLong (line 189) | func BenchmarkFlowFastHashLong(b *testing.B) {
FILE: bsdbpf/bsd_bpf_sniffer.go
constant wordSize (line 22) | wordSize = int(unsafe.Sizeof(uintptr(0)))
function bpfWordAlign (line 24) | func bpfWordAlign(x int) int {
type Options (line 30) | type Options struct
type BPFSniffer (line 74) | type BPFSniffer struct
method Close (line 162) | func (b *BPFSniffer) Close() error {
method pickBpfDevice (line 166) | func (b *BPFSniffer) pickBpfDevice() {
method ReadPacketData (line 179) | func (b *BPFSniffer) ReadPacketData() ([]byte, gopacket.CaptureInfo, e...
method GetReadBufLen (line 213) | func (b *BPFSniffer) GetReadBufLen() int {
function NewBPFSniffer (line 88) | func NewBPFSniffer(iface string, options *Options) (*BPFSniffer, error) {
FILE: bytediff/bytediff.go
type OutputFormat (line 30) | type OutputFormat struct
method color (line 108) | func (c *OutputFormat) color(d Difference) string {
method String (line 156) | func (c *OutputFormat) String(diffs Differences) string {
function longestCommonSubstring (line 57) | func longestCommonSubstring(strA, strB []byte) (indexA, indexB, length i...
type Difference (line 102) | type Difference struct
function Diff (line 128) | func Diff(strA, strB []byte) Differences {
type Differences (line 148) | type Differences
FILE: bytediff/bytediff_test.go
function TestLCS (line 14) | func TestLCS(t *testing.T) {
function TestDiff (line 32) | func TestDiff(t *testing.T) {
FILE: decode.go
type DecodeFeedback (line 14) | type DecodeFeedback interface
type nilDecodeFeedback (line 21) | type nilDecodeFeedback struct
method SetTruncated (line 23) | func (nilDecodeFeedback) SetTruncated() {}
type PacketBuilder (line 41) | type PacketBuilder interface
type Decoder (line 74) | type Decoder interface
type DecodeFunc (line 82) | type DecodeFunc
method Decode (line 85) | func (d DecodeFunc) Decode(data []byte, p PacketBuilder) error {
type DecodeFailure (line 122) | type DecodeFailure struct
method Error (line 129) | func (d *DecodeFailure) Error() error { return d.err }
method LayerContents (line 132) | func (d *DecodeFailure) LayerContents() []byte { return d.data }
method LayerPayload (line 135) | func (d *DecodeFailure) LayerPayload() []byte { return nil }
method String (line 138) | func (d *DecodeFailure) String() string {
method Dump (line 143) | func (d *DecodeFailure) Dump() (s string) {
method LayerType (line 151) | func (d *DecodeFailure) LayerType() LayerType { return LayerTypeDecode...
function decodeUnknown (line 155) | func decodeUnknown(data []byte, p PacketBuilder) error {
FILE: defrag/lcmdefrag/lcmdefrag.go
constant timeout (line 21) | timeout time.Duration = 3 * time.Second
type lcmPacket (line 24) | type lcmPacket struct
method append (line 57) | func (lp *lcmPacket) append(in *layers.LCM) {
method assemble (line 63) | func (lp *lcmPacket) assemble() (out *layers.LCM, err error) {
type LCMDefragmenter (line 37) | type LCMDefragmenter struct
method cleanUp (line 97) | func (ld *LCMDefragmenter) cleanUp() {
method Defrag (line 114) | func (ld *LCMDefragmenter) Defrag(in *layers.LCM) (out *layers.LCM, er...
function newLCMPacket (line 41) | func newLCMPacket(totalFrags uint16) *lcmPacket {
function NewLCMDefragmenter (line 51) | func NewLCMDefragmenter() *LCMDefragmenter {
FILE: defrag/lcmdefrag/lcmdefrag_test.go
function TestOrderedLCMDefrag (line 37) | func TestOrderedLCMDefrag(t *testing.T) {
function TestUnorderedLCMDefrag (line 64) | func TestUnorderedLCMDefrag(t *testing.T) {
function TestNonLCMDefrag (line 91) | func TestNonLCMDefrag(t *testing.T) {
FILE: dumpcommand/tcpdump.go
function Run (line 35) | func Run(src gopacket.PacketDataSource) {
FILE: examples/afpacket/afpacket.go
type afpacketHandle (line 39) | type afpacketHandle struct
method ZeroCopyReadPacketData (line 73) | func (h *afpacketHandle) ZeroCopyReadPacketData() (data []byte, ci gop...
method SetBPFFilter (line 78) | func (h *afpacketHandle) SetBPFFilter(filter string, snaplen int) (err...
method LinkType (line 100) | func (h *afpacketHandle) LinkType() layers.LinkType {
method Close (line 105) | func (h *afpacketHandle) Close() {
method SocketStats (line 110) | func (h *afpacketHandle) SocketStats() (as afpacket.SocketStats, asv a...
function newAfpacketHandle (line 43) | func newAfpacketHandle(device string, snaplen int, block_size int, num_b...
function afpacketComputeSize (line 118) | func afpacketComputeSize(targetSizeMb int, snaplen int, pageSize int) (
function main (line 138) | func main() {
FILE: examples/arpscan/arpscan.go
function main (line 28) | func main() {
function scan (line 56) | func scan(iface *net.Interface) error {
function readARP (line 111) | func readARP(handle *pcap.Handle, iface *net.Interface, stop chan struct...
function writeARP (line 139) | func writeARP(handle *pcap.Handle, iface *net.Interface, addr *net.IPNet...
function ips (line 176) | func ips(n *net.IPNet) (out []net.IP) {
FILE: examples/bidirectional/main.go
type key (line 29) | type key struct
method String (line 34) | func (k key) String() string {
constant timeout (line 40) | timeout time.Duration = time.Minute * 5
type myStream (line 43) | type myStream struct
method Reassembled (line 111) | func (s *myStream) Reassembled(rs []tcpassembly.Reassembly) {
method ReassemblyComplete (line 128) | func (s *myStream) ReassemblyComplete() {
type bidi (line 54) | type bidi struct
method maybeFinish (line 135) | func (bd *bidi) maybeFinish() {
type myFactory (line 61) | type myFactory struct
method New (line 67) | func (f *myFactory) New(netFlow, tcpFlow gopacket.Flow) tcpassembly.St...
method collectOldStreams (line 98) | func (f *myFactory) collectOldStreams() {
function main (line 150) | func main() {
FILE: examples/bytediff/main.go
function main (line 94) | func main() {
FILE: examples/httpassembly/main.go
type httpStreamFactory (line 37) | type httpStreamFactory struct
method New (line 45) | func (h *httpStreamFactory) New(net, transport gopacket.Flow) tcpassem...
type httpStream (line 40) | type httpStream struct
method run (line 57) | func (h *httpStream) run() {
function main (line 74) | func main() {
FILE: examples/pcapdump/main.go
function main (line 29) | func main() {
FILE: examples/pcaplay/main.go
function writePacketDelayed (line 35) | func writePacketDelayed(handle *pcap.Handle, buf []byte, ci gopacket.Cap...
function writePacket (line 53) | func writePacket(handle *pcap.Handle, buf []byte) error {
function pcapInfo (line 61) | func pcapInfo(filename string) (start time.Time, end time.Time, packets ...
function main (line 101) | func main() {
FILE: examples/pfdump/main.go
function main (line 27) | func main() {
FILE: examples/reassemblydump/main.go
constant closeTimeout (line 88) | closeTimeout time.Duration = time.Hour * 24
constant timeout (line 89) | timeout time.Duration = time.Minute * 5
type httpReader (line 95) | type httpReader struct
method Read (line 104) | func (h *httpReader) Read(p []byte) (int, error) {
method run (line 145) | func (h *httpReader) run(wg *sync.WaitGroup) {
function Error (line 124) | func Error(t string, s string, a ...interface{}) {
function Info (line 134) | func Info(s string, a ...interface{}) {
function Debug (line 139) | func Debug(s string, a ...interface{}) {
type tcpStreamFactory (line 260) | type tcpStreamFactory struct
method New (line 265) | func (factory *tcpStreamFactory) New(net, transport gopacket.Flow, tcp...
method WaitGoRoutines (line 301) | func (factory *tcpStreamFactory) WaitGoRoutines() {
type Context (line 308) | type Context struct
method GetCaptureInfo (line 312) | func (c *Context) GetCaptureInfo() gopacket.CaptureInfo {
type tcpStream (line 321) | type tcpStream struct
method Accept (line 336) | func (t *tcpStream) Accept(tcp *layers.TCP, ci gopacket.CaptureInfo, d...
method ReassembledSG (line 376) | func (t *tcpStream) ReassembledSG(sg reassembly.ScatterGather, ac reas...
method ReassemblyComplete (line 459) | func (t *tcpStream) ReassemblyComplete(ac reassembly.AssemblerContext)...
function main (line 469) | func main() {
FILE: examples/snoopread/main.go
function main (line 20) | func main() {
FILE: examples/statsassembly/main.go
type statsStreamFactory (line 48) | type statsStreamFactory struct
method New (line 60) | func (factory *statsStreamFactory) New(net, transport gopacket.Flow) t...
type statsStream (line 51) | type statsStream struct
method Reassembled (line 74) | func (s *statsStream) Reassembled(reassemblies []tcpassembly.Reassembl...
method ReassemblyComplete (line 93) | func (s *statsStream) ReassemblyComplete() {
function main (line 100) | func main() {
FILE: examples/synscan/main.go
type scanner (line 35) | type scanner struct
method close (line 81) | func (s *scanner) close() {
method getHwAddr (line 90) | func (s *scanner) getHwAddr() (net.HardwareAddr, error) {
method scan (line 140) | func (s *scanner) scan() error {
method send (line 224) | func (s *scanner) send(l ...gopacket.SerializableLayer) error {
function newScanner (line 51) | func newScanner(ip net.IP, router routing.Router) (*scanner, error) {
function main (line 231) | func main() {
FILE: examples/util/util.go
function Run (line 26) | func Run() func() {
FILE: flows.go
constant MaxEndpointSize (line 27) | MaxEndpointSize = 16
type Endpoint (line 32) | type Endpoint struct
method EndpointType (line 39) | func (a Endpoint) EndpointType() EndpointType { return a.typ }
method Raw (line 43) | func (a Endpoint) Raw() []byte { return a.raw[:a.len] }
method LessThan (line 53) | func (a Endpoint) LessThan(b Endpoint) bool {
method FastHash (line 78) | func (a Endpoint) FastHash() (h uint64) {
method String (line 133) | func (a Endpoint) String() string {
function fnvHash (line 60) | func fnvHash(s []byte) (h uint64) {
constant fnvBasis (line 69) | fnvBasis = 14695981039346656037
constant fnvPrime (line 70) | fnvPrime = 1099511628211
function NewEndpoint (line 89) | func NewEndpoint(typ EndpointType, raw []byte) (e Endpoint) {
type EndpointTypeMetadata (line 100) | type EndpointTypeMetadata struct
type EndpointType (line 110) | type EndpointType
method String (line 126) | func (e EndpointType) String() string {
function RegisterEndpointType (line 117) | func RegisterEndpointType(num int, meta EndpointTypeMetadata) EndpointTy...
type Flow (line 142) | type Flow struct
method FastHash (line 167) | func (f Flow) FastHash() (h uint64) {
method String (line 178) | func (f Flow) String() string {
method EndpointType (line 184) | func (f Flow) EndpointType() EndpointType {
method Endpoints (line 189) | func (f Flow) Endpoints() (src, dst Endpoint) {
method Src (line 194) | func (f Flow) Src() (src Endpoint) {
method Dst (line 200) | func (f Flow) Dst() (dst Endpoint) {
method Reverse (line 206) | func (f Flow) Reverse() Flow {
function FlowFromEndpoints (line 151) | func FlowFromEndpoints(src, dst Endpoint) (_ Flow, err error) {
function NewFlow (line 214) | func NewFlow(t EndpointType, src, dst []byte) (f Flow) {
FILE: gen.go
constant headerFmt (line 19) | headerFmt = `// Copyright 2019 The GoPacket Authors. All rights reserved.
function main (line 58) | func main() {
FILE: ip4defrag/defrag.go
type debugging (line 25) | type debugging
method Printf (line 27) | func (d debugging) Printf(format string, args ...interface{}) {
constant IPv4MinimumFragmentSize (line 36) | IPv4MinimumFragmentSize = 8
constant IPv4MaximumSize (line 37) | IPv4MaximumSize = 65535
constant IPv4MaximumFragmentOffset (line 38) | IPv4MaximumFragmentOffset = 8183
constant IPv4MaximumFragmentListLen (line 39) | IPv4MaximumFragmentListLen = 8192
type fragmentList (line 204) | type fragmentList struct
method insert (line 216) | func (f *fragmentList) insert(in *layers.IPv4, t time.Time) (*layers.I...
method build (line 278) | func (f *fragmentList) build(in *layers.IPv4) (*layers.IPv4, error) {
type ipv4 (line 331) | type ipv4 struct
function newIPv4 (line 337) | func newIPv4(ip *layers.IPv4) ipv4 {
type IPv4Defragmenter (line 346) | type IPv4Defragmenter struct
method DefragIPv4 (line 76) | func (d *IPv4Defragmenter) DefragIPv4(in *layers.IPv4) (*layers.IPv4, ...
method DefragIPv4WithTimestamp (line 86) | func (d *IPv4Defragmenter) DefragIPv4WithTimestamp(in *layers.IPv4, t ...
method DiscardOlderThan (line 140) | func (d *IPv4Defragmenter) DiscardOlderThan(t time.Time) int {
method flush (line 154) | func (d *IPv4Defragmenter) flush(ipf ipv4) {
method dontDefrag (line 162) | func (d *IPv4Defragmenter) dontDefrag(ip *layers.IPv4) bool {
method securityChecks (line 175) | func (d *IPv4Defragmenter) securityChecks(ip *layers.IPv4) error {
function NewIPv4Defragmenter (line 353) | func NewIPv4Defragmenter() *IPv4Defragmenter {
FILE: ip4defrag/defrag_test.go
function TestNotFrag (line 22) | func TestNotFrag(t *testing.T) {
function TestDefragPingMultipleFrags (line 38) | func TestDefragPingMultipleFrags(t *testing.T) {
function TestDefragPing1 (line 69) | func TestDefragPing1(t *testing.T) {
function TestDefragPing1and2 (line 106) | func TestDefragPing1and2(t *testing.T) {
function TestDefragTooSmall (line 153) | func TestDefragTooSmall(t *testing.T) {
function TestDefragFragmentOffset (line 177) | func TestDefragFragmentOffset(t *testing.T) {
function TestDefragDiscard (line 204) | func TestDefragDiscard(t *testing.T) {
function TestDefragMaxSize (line 216) | func TestDefragMaxSize(t *testing.T) {
function TestDefragIDField (line 245) | func TestDefragIDField(t *testing.T) {
function gentestDefrag (line 262) | func gentestDefrag(t *testing.T, defrag *IPv4Defragmenter, buf []byte, e...
FILE: layerclass.go
type LayerClass (line 11) | type LayerClass interface
method Contains (line 22) | func (l LayerType) Contains(a LayerType) bool {
method LayerTypes (line 27) | func (l LayerType) LayerTypes() []LayerType {
type LayerClassSlice (line 32) | type LayerClassSlice
method Contains (line 36) | func (s LayerClassSlice) Contains(t LayerType) bool {
method LayerTypes (line 42) | func (s LayerClassSlice) LayerTypes() (all []LayerType) {
function NewLayerClassSlice (line 55) | func NewLayerClassSlice(types []LayerType) LayerClassSlice {
type LayerClassMap (line 70) | type LayerClassMap
method Contains (line 74) | func (m LayerClassMap) Contains(t LayerType) bool {
method LayerTypes (line 79) | func (m LayerClassMap) LayerTypes() (all []LayerType) {
function NewLayerClassMap (line 88) | func NewLayerClassMap(types []LayerType) LayerClassMap {
function NewLayerClass (line 98) | func NewLayerClass(types []LayerType) LayerClass {
FILE: layers/ague_var0.go
type AGUEVar0 (line 20) | type AGUEVar0 struct
method LayerType (line 30) | func (l AGUEVar0) LayerType() gopacket.LayerType {
method LayerContents (line 35) | func (l AGUEVar0) LayerContents() []byte {
method LayerPayload (line 51) | func (l AGUEVar0) LayerPayload() []byte {
method SerializeTo (line 56) | func (l AGUEVar0) SerializeTo(buf gopacket.SerializeBuffer, opts gopac...
method CanDecode (line 67) | func (l AGUEVar0) CanDecode() gopacket.LayerClass {
method DecodeFromBytes (line 72) | func (l *AGUEVar0) DecodeFromBytes(data []byte, df gopacket.DecodeFeed...
method NextLayerType (line 84) | func (l AGUEVar0) NextLayerType() gopacket.LayerType {
function decodeAGUE (line 92) | func decodeAGUE(data []byte, p gopacket.PacketBuilder) error {
FILE: layers/ague_var0_test.go
function TestGueDecoding (line 17) | func TestGueDecoding(t *testing.T) {
function TestIPv4OverAGUEVar0Encode (line 93) | func TestIPv4OverAGUEVar0Encode(t *testing.T) {
FILE: layers/ague_var1.go
type AGUEVar1 (line 18) | type AGUEVar1 struct
method LayerType (line 24) | func (l AGUEVar1) LayerType() gopacket.LayerType {
method LayerContents (line 29) | func (l AGUEVar1) LayerContents() []byte {
method LayerPayload (line 35) | func (l AGUEVar1) LayerPayload() []byte {
method SerializeTo (line 40) | func (l AGUEVar1) SerializeTo(buf gopacket.SerializeBuffer, opts gopac...
method CanDecode (line 45) | func (l AGUEVar1) CanDecode() gopacket.LayerClass {
method DecodeFromBytes (line 53) | func (l *AGUEVar1) DecodeFromBytes(data []byte, df gopacket.DecodeFeed...
method NextLayerType (line 70) | func (l AGUEVar1) NextLayerType() gopacket.LayerType {
function decodeAGUEVar1 (line 77) | func decodeAGUEVar1(data []byte, p gopacket.PacketBuilder) error {
FILE: layers/ague_var1_test.go
function logLayers (line 16) | func logLayers(p gopacket.Packet, t *testing.T) {
function TestIPv4OverAGUEVar1Encode (line 87) | func TestIPv4OverAGUEVar1Encode(t *testing.T) {
function TestIPv6OverAGUEVar1Encode (line 119) | func TestIPv6OverAGUEVar1Encode(t *testing.T) {
FILE: layers/apsp.go
type APSP (line 27) | type APSP struct
method CanDecode (line 45) | func (l APSP) CanDecode() gopacket.LayerClass {
method DecodeFromBytes (line 50) | func (l *APSP) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback...
method SerializeTo (line 73) | func (l APSP) SerializeTo(buf gopacket.SerializeBuffer, opts gopacket....
method LayerContents (line 84) | func (l APSP) LayerContents() []byte {
method LayerPayload (line 100) | func (l APSP) LayerPayload() []byte {
method NextLayerType (line 105) | func (l APSP) NextLayerType() gopacket.LayerType {
method LayerType (line 111) | func (l APSP) LayerType() gopacket.LayerType {
constant ApspLen (line 42) | ApspLen = 40
function decodeAPSP (line 115) | func decodeAPSP(data []byte, p gopacket.PacketBuilder) error {
FILE: layers/apsp_test.go
function TestApspDecoding (line 18) | func TestApspDecoding(t *testing.T) {
function TestIPv4OverApspEncode (line 101) | func TestIPv4OverApspEncode(t *testing.T) {
FILE: layers/arp.go
constant ARPRequest (line 20) | ARPRequest = 1
constant ARPReply (line 21) | ARPReply = 2
type ARP (line 25) | type ARP struct
method LayerType (line 39) | func (arp *ARP) LayerType() gopacket.LayerType { return LayerTypeARP }
method DecodeFromBytes (line 42) | func (arp *ARP) DecodeFromBytes(data []byte, df gopacket.DecodeFeedbac...
method SerializeTo (line 70) | func (arp *ARP) SerializeTo(b gopacket.SerializeBuffer, opts gopacket....
method CanDecode (line 105) | func (arp *ARP) CanDecode() gopacket.LayerClass {
method NextLayerType (line 110) | func (arp *ARP) NextLayerType() gopacket.LayerType {
function decodeARP (line 114) | func decodeARP(data []byte, p gopacket.PacketBuilder) error {
FILE: layers/asf.go
constant ASFRMCPEnterprise (line 20) | ASFRMCPEnterprise uint32 = 4542
type ASFDataIdentifier (line 29) | type ASFDataIdentifier struct
method LayerType (line 46) | func (a ASFDataIdentifier) LayerType() gopacket.LayerType {
function RegisterASFLayerType (line 58) | func RegisterASFLayerType(a ASFDataIdentifier, l gopacket.LayerType) {
type ASF (line 91) | type ASF struct
method LayerType (line 109) | func (*ASF) LayerType() gopacket.LayerType {
method CanDecode (line 114) | func (a *ASF) CanDecode() gopacket.LayerClass {
method DecodeFromBytes (line 120) | func (a *ASF) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback)...
method NextLayerType (line 140) | func (a *ASF) NextLayerType() gopacket.LayerType {
method SerializeTo (line 146) | func (a *ASF) SerializeTo(b gopacket.SerializeBuffer, opts gopacket.Se...
function decodeASF (line 164) | func decodeASF(data []byte, p gopacket.PacketBuilder) error {
FILE: layers/asf_presencepong.go
type ASFEntity (line 26) | type ASFEntity
type ASFInteraction (line 33) | type ASFInteraction
constant ASFDCMIEnterprise (line 41) | ASFDCMIEnterprise uint32 = 36465
constant ASFPresencePongEntityIPMI (line 45) | ASFPresencePongEntityIPMI ASFEntity = 1 << 7
constant ASFPresencePongEntityASFv1 (line 49) | ASFPresencePongEntityASFv1 ASFEntity = 1
constant ASFPresencePongInteractionSecurityExtensions (line 54) | ASFPresencePongInteractionSecurityExtensions ASFInteraction = 1 << 7
constant ASFPresencePongInteractionDASH (line 59) | ASFPresencePongInteractionDASH ASFInteraction = 1 << 5
type ASFPresencePong (line 64) | type ASFPresencePong struct
method SupportsDCMI (line 110) | func (a *ASFPresencePong) SupportsDCMI() bool {
method LayerType (line 116) | func (*ASFPresencePong) LayerType() gopacket.LayerType {
method CanDecode (line 122) | func (a *ASFPresencePong) CanDecode() gopacket.LayerClass {
method DecodeFromBytes (line 128) | func (a *ASFPresencePong) DecodeFromBytes(data []byte, df gopacket.Dec...
method NextLayerType (line 150) | func (a *ASFPresencePong) NextLayerType() gopacket.LayerType {
method SerializeTo (line 156) | func (a *ASFPresencePong) SerializeTo(b gopacket.SerializeBuffer, _ go...
function decodeASFPresencePong (line 192) | func decodeASFPresencePong(data []byte, p gopacket.PacketBuilder) error {
FILE: layers/asf_presencepong_test.go
function TestASFPresencePongDecodeFromBytes (line 16) | func TestASFPresencePongDecodeFromBytes(t *testing.T) {
function TestASFPresencePongSupportsDCMI (line 52) | func TestASFPresencePongSupportsDCMI(t *testing.T) {
function serializeASFPresencePong (line 98) | func serializeASFPresencePong(pp *ASFPresencePong) ([]byte, error) {
function TestASFPresencePongSerializeTo (line 104) | func TestASFPresencePongSerializeTo(t *testing.T) {
FILE: layers/asf_test.go
function TestASFDecodeFromBytes (line 16) | func TestASFDecodeFromBytes(t *testing.T) {
function serializeASF (line 46) | func serializeASF(asf *ASF) ([]byte, error) {
function TestASFSerializeTo (line 54) | func TestASFSerializeTo(t *testing.T) {
FILE: layers/base.go
type BaseLayer (line 15) | type BaseLayer struct
method LayerContents (line 27) | func (b *BaseLayer) LayerContents() []byte { return b.Contents }
method LayerPayload (line 30) | func (b *BaseLayer) LayerPayload() []byte { return b.Payload }
type layerDecodingLayer (line 32) | type layerDecodingLayer interface
function decodingLayerDecoder (line 38) | func decodingLayerDecoder(d layerDecodingLayer, data []byte, p gopacket....
FILE: layers/base_test.go
function checkLayers (line 17) | func checkLayers(p gopacket.Packet, want []gopacket.LayerType, t *testin...
function checkSerialization (line 45) | func checkSerialization(p gopacket.Packet, t *testing.T) {
FILE: layers/bfd.go
constant bfdMinimumRecordSizeInBytes (line 88) | bfdMinimumRecordSizeInBytes int = 24
type BFDVersion (line 91) | type BFDVersion
type BFDDiagnostic (line 94) | type BFDDiagnostic
method String (line 110) | func (bd BFDDiagnostic) String() string {
constant BFDDiagnosticNone (line 98) | BFDDiagnosticNone BFDDiagnostic = 0
constant BFDDiagnosticTimeExpired (line 99) | BFDDiagnosticTimeExpired BFDDiagnostic = 1
constant BFDDiagnosticEchoFailed (line 100) | BFDDiagnosticEchoFailed BFDDiagnostic = 2
constant BFDDiagnosticNeighborSignalDown (line 101) | BFDDiagnosticNeighborSignalDown BFDDiagnostic = 3
constant BFDDiagnosticForwardPlaneReset (line 102) | BFDDiagnosticForwardPlaneReset BFDDiagnostic = 4
constant BFDDiagnosticPathDown (line 103) | BFDDiagnosticPathDown BFDDiagnostic = 5
constant BFDDiagnosticConcatPathDown (line 104) | BFDDiagnosticConcatPathDown BFDDiagnostic = 6
constant BFDDiagnosticAdminDown (line 105) | BFDDiagnosticAdminDown BFDDiagnostic = 7
constant BFDDiagnosticRevConcatPathDown (line 106) | BFDDiagnosticRevConcatPathDown BFDDiagnostic = 8
type BFDState (line 136) | type BFDState
method String (line 147) | func (s BFDState) String() string {
constant BFDStateAdminDown (line 140) | BFDStateAdminDown BFDState = 0
constant BFDStateDown (line 141) | BFDStateDown BFDState = 1
constant BFDStateInit (line 142) | BFDStateInit BFDState = 2
constant BFDStateUp (line 143) | BFDStateUp BFDState = 3
type BFDDetectMultiplier (line 165) | type BFDDetectMultiplier
type BFDDiscriminator (line 169) | type BFDDiscriminator
type BFDTimeInterval (line 172) | type BFDTimeInterval
type BFDAuthType (line 175) | type BFDAuthType
method String (line 188) | func (at BFDAuthType) String() string {
constant BFDAuthTypeNone (line 179) | BFDAuthTypeNone BFDAuthType = 0
constant BFDAuthTypePassword (line 180) | BFDAuthTypePassword BFDAuthType = 1
constant BFDAuthTypeKeyedMD5 (line 181) | BFDAuthTypeKeyedMD5 BFDAuthType = 2
constant BFDAuthTypeMeticulousKeyedMD5 (line 182) | BFDAuthTypeMeticulousKeyedMD5 BFDAuthType = 3
constant BFDAuthTypeKeyedSHA1 (line 183) | BFDAuthTypeKeyedSHA1 BFDAuthType = 4
constant BFDAuthTypeMeticulousKeyedSHA1 (line 184) | BFDAuthTypeMeticulousKeyedSHA1 BFDAuthType = 5
type BFDAuthKeyID (line 209) | type BFDAuthKeyID
type BFDAuthSequenceNumber (line 216) | type BFDAuthSequenceNumber
type BFDAuthData (line 219) | type BFDAuthData
type BFDAuthHeader (line 222) | type BFDAuthHeader struct
method Length (line 231) | func (h *BFDAuthHeader) Length() int {
type BFD (line 262) | type BFD struct
method Length (line 286) | func (d *BFD) Length() int {
method LayerType (line 295) | func (d *BFD) LayerType() gopacket.LayerType {
method DecodeFromBytes (line 329) | func (d *BFD) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback)...
method SerializeTo (line 402) | func (d *BFD) SerializeTo(b gopacket.SerializeBuffer, opts gopacket.Se...
method CanDecode (line 459) | func (d *BFD) CanDecode() gopacket.LayerClass {
method NextLayerType (line 466) | func (d *BFD) NextLayerType() gopacket.LayerType {
method Payload (line 471) | func (d *BFD) Payload() []byte {
function decodeBFD (line 306) | func decodeBFD(data []byte, p gopacket.PacketBuilder) error {
function bool2uint8 (line 476) | func bool2uint8(b bool) uint8 {
FILE: layers/bfd_test.go
function checkBFD (line 23) | func checkBFD(desc string, t *testing.T, packetBytes []byte, pExpectedBF...
function TestBFDNoAuth (line 66) | func TestBFDNoAuth(t *testing.T) {
function TestBFDAuthTypePassword (line 115) | func TestBFDAuthTypePassword(t *testing.T) {
function TestBFDAuthTypeKeyedMD5 (line 170) | func TestBFDAuthTypeKeyedMD5(t *testing.T) {
function TestBFDAuthTypeMeticulousKeyedSHA1 (line 230) | func TestBFDAuthTypeMeticulousKeyedSHA1(t *testing.T) {
FILE: layers/bitfield.go
type bitfield (line 8) | type bitfield
method set (line 11) | func (b *bitfield) set(i uint16) {
method has (line 16) | func (b *bitfield) has(i uint16) bool {
FILE: layers/bitfield_test.go
function TestBitfield (line 5) | func TestBitfield(t *testing.T) {
function TestBitfieldStressTest (line 28) | func TestBitfieldStressTest(t *testing.T) {
FILE: layers/cdp.go
type CDPTLVType (line 24) | type CDPTLVType
method String (line 550) | func (t CDPTLVType) String() (s string) {
constant CDPTLVDevID (line 28) | CDPTLVDevID CDPTLVType = 0x0001
constant CDPTLVAddress (line 29) | CDPTLVAddress CDPTLVType = 0x0002
constant CDPTLVPortID (line 30) | CDPTLVPortID CDPTLVType = 0x0003
constant CDPTLVCapabilities (line 31) | CDPTLVCapabilities CDPTLVType = 0x0004
constant CDPTLVVersion (line 32) | CDPTLVVersion CDPTLVType = 0x0005
constant CDPTLVPlatform (line 33) | CDPTLVPlatform CDPTLVType = 0x0006
constant CDPTLVIPPrefix (line 34) | CDPTLVIPPrefix CDPTLVType = 0x0007
constant CDPTLVHello (line 35) | CDPTLVHello CDPTLVType = 0x0008
constant CDPTLVVTPDomain (line 36) | CDPTLVVTPDomain CDPTLVType = 0x0009
constant CDPTLVNativeVLAN (line 37) | CDPTLVNativeVLAN CDPTLVType = 0x000a
constant CDPTLVFullDuplex (line 38) | CDPTLVFullDuplex CDPTLVType = 0x000b
constant CDPTLVVLANReply (line 39) | CDPTLVVLANReply CDPTLVType = 0x000e
constant CDPTLVVLANQuery (line 40) | CDPTLVVLANQuery CDPTLVType = 0x000f
constant CDPTLVPower (line 41) | CDPTLVPower CDPTLVType = 0x0010
constant CDPTLVMTU (line 42) | CDPTLVMTU CDPTLVType = 0x0011
constant CDPTLVExtendedTrust (line 43) | CDPTLVExtendedTrust CDPTLVType = 0x0012
constant CDPTLVUntrustedCOS (line 44) | CDPTLVUntrustedCOS CDPTLVType = 0x0013
constant CDPTLVSysName (line 45) | CDPTLVSysName CDPTLVType = 0x0014
constant CDPTLVSysOID (line 46) | CDPTLVSysOID CDPTLVType = 0x0015
constant CDPTLVMgmtAddresses (line 47) | CDPTLVMgmtAddresses CDPTLVType = 0x0016
constant CDPTLVLocation (line 48) | CDPTLVLocation CDPTLVType = 0x0017
constant CDPTLVExternalPortID (line 49) | CDPTLVExternalPortID CDPTLVType = 0x0018
constant CDPTLVPowerRequested (line 50) | CDPTLVPowerRequested CDPTLVType = 0x0019
constant CDPTLVPowerAvailable (line 51) | CDPTLVPowerAvailable CDPTLVType = 0x001a
constant CDPTLVPortUnidirectional (line 52) | CDPTLVPortUnidirectional CDPTLVType = 0x001b
constant CDPTLVEnergyWise (line 53) | CDPTLVEnergyWise CDPTLVType = 0x001d
constant CDPTLVSparePairPOE (line 54) | CDPTLVSparePairPOE CDPTLVType = 0x001f
type CiscoDiscoveryValue (line 58) | type CiscoDiscoveryValue struct
type CiscoDiscovery (line 66) | type CiscoDiscovery struct
method LayerType (line 217) | func (c *CiscoDiscovery) LayerType() gopacket.LayerType {
type CDPCapability (line 75) | type CDPCapability
constant CDPCapMaskRouter (line 79) | CDPCapMaskRouter CDPCapability = 0x0001
constant CDPCapMaskTBBridge (line 80) | CDPCapMaskTBBridge CDPCapability = 0x0002
constant CDPCapMaskSPBridge (line 81) | CDPCapMaskSPBridge CDPCapability = 0x0004
constant CDPCapMaskSwitch (line 82) | CDPCapMaskSwitch CDPCapability = 0x0008
constant CDPCapMaskHost (line 83) | CDPCapMaskHost CDPCapability = 0x0010
constant CDPCapMaskIGMPFilter (line 84) | CDPCapMaskIGMPFilter CDPCapability = 0x0020
constant CDPCapMaskRepeater (line 85) | CDPCapMaskRepeater CDPCapability = 0x0040
constant CDPCapMaskPhone (line 86) | CDPCapMaskPhone CDPCapability = 0x0080
constant CDPCapMaskRemote (line 87) | CDPCapMaskRemote CDPCapability = 0x0100
type CDPCapabilities (line 91) | type CDPCapabilities struct
constant CDPPoEFourWire (line 105) | CDPPoEFourWire byte = 0x01
constant CDPPoEPDArch (line 106) | CDPPoEPDArch byte = 0x02
constant CDPPoEPDRequest (line 107) | CDPPoEPDRequest byte = 0x04
constant CDPPoEPSE (line 108) | CDPPoEPSE byte = 0x08
type CDPSparePairPoE (line 112) | type CDPSparePairPoE struct
type CDPVLANDialogue (line 120) | type CDPVLANDialogue struct
type CDPPowerDialogue (line 126) | type CDPPowerDialogue struct
type CDPLocation (line 133) | type CDPLocation struct
type CDPHello (line 139) | type CDPHello struct
type CDPEnergyWiseSubtype (line 155) | type CDPEnergyWiseSubtype
method String (line 638) | func (t CDPEnergyWiseSubtype) String() (s string) {
constant CDPEnergyWiseRole (line 159) | CDPEnergyWiseRole CDPEnergyWiseSubtype = 0x00000007
constant CDPEnergyWiseDomain (line 160) | CDPEnergyWiseDomain CDPEnergyWiseSubtype = 0x00000008
constant CDPEnergyWiseName (line 161) | CDPEnergyWiseName CDPEnergyWiseSubtype = 0x00000009
constant CDPEnergyWiseReplyTo (line 162) | CDPEnergyWiseReplyTo CDPEnergyWiseSubtype = 0x00000017
type CDPEnergyWise (line 166) | type CDPEnergyWise struct
type CiscoDiscoveryInfo (line 186) | type CiscoDiscoveryInfo struct
method LayerType (line 242) | func (c *CiscoDiscoveryInfo) LayerType() gopacket.LayerType {
function decodeCiscoDiscovery (line 221) | func decodeCiscoDiscovery(data []byte, p gopacket.PacketBuilder) error {
function decodeCiscoDiscoveryTLVs (line 246) | func decodeCiscoDiscoveryTLVs(data []byte, p gopacket.PacketBuilder) (va...
function decodeCiscoDiscoveryInfo (line 270) | func decodeCiscoDiscoveryInfo(data []byte, p gopacket.PacketBuilder) err...
constant CDPProtocolTypeNLPID (line 490) | CDPProtocolTypeNLPID byte = 1
constant CDPProtocolType802_2 (line 491) | CDPProtocolType802_2 byte = 2
type CDPAddressType (line 495) | type CDPAddressType
method String (line 612) | func (a CDPAddressType) String() (s string) {
constant CDPAddressTypeCLNP (line 499) | CDPAddressTypeCLNP CDPAddressType = 0x81
constant CDPAddressTypeIPV4 (line 500) | CDPAddressTypeIPV4 CDPAddressType = 0xcc
constant CDPAddressTypeIPV6 (line 501) | CDPAddressTypeIPV6 CDPAddressType = 0xaaaa030000000800
constant CDPAddressTypeDECNET (line 502) | CDPAddressTypeDECNET CDPAddressType = 0xaaaa030000006003
constant CDPAddressTypeAPPLETALK (line 503) | CDPAddressTypeAPPLETALK CDPAddressType = 0xaaaa03000000809b
constant CDPAddressTypeIPX (line 504) | CDPAddressTypeIPX CDPAddressType = 0xaaaa030000008137
constant CDPAddressTypeVINES (line 505) | CDPAddressTypeVINES CDPAddressType = 0xaaaa0300000080c4
constant CDPAddressTypeXNS (line 506) | CDPAddressTypeXNS CDPAddressType = 0xaaaa030000000600
constant CDPAddressTypeAPOLLO (line 507) | CDPAddressTypeAPOLLO CDPAddressType = 0xaaaa030000008019
function decodeAddresses (line 510) | func decodeAddresses(v []byte) (addresses []net.IP, err error) {
function checkCDPTLVLen (line 654) | func checkCDPTLVLen(v CiscoDiscoveryValue, l int) (err error) {
FILE: layers/ctp.go
type EthernetCTPFunction (line 17) | type EthernetCTPFunction
constant EthernetCTPFunctionReply (line 21) | EthernetCTPFunctionReply EthernetCTPFunction = 1
constant EthernetCTPFunctionForwardData (line 22) | EthernetCTPFunctionForwardData EthernetCTPFunction = 2
type EthernetCTP (line 28) | type EthernetCTP struct
method LayerType (line 34) | func (c *EthernetCTP) LayerType() gopacket.LayerType {
type EthernetCTPForwardData (line 40) | type EthernetCTPForwardData struct
method LayerType (line 47) | func (c *EthernetCTPForwardData) LayerType() gopacket.LayerType {
method ForwardEndpoint (line 52) | func (c *EthernetCTPForwardData) ForwardEndpoint() gopacket.Endpoint {
type EthernetCTPReply (line 57) | type EthernetCTPReply struct
method LayerType (line 65) | func (c *EthernetCTPReply) LayerType() gopacket.LayerType {
method Payload (line 70) | func (c *EthernetCTPReply) Payload() []byte { return c.Data }
function decodeEthernetCTP (line 72) | func decodeEthernetCTP(data []byte, p gopacket.PacketBuilder) error {
function decodeEthernetCTPFromFunctionType (line 86) | func decodeEthernetCTPFromFunctionType(data []byte, p gopacket.PacketBui...
FILE: layers/decode_test.go
function BenchmarkLayerClassSliceContains (line 69) | func BenchmarkLayerClassSliceContains(b *testing.B) {
function BenchmarkLayerClassMapContains (line 76) | func BenchmarkLayerClassMapContains(b *testing.B) {
function BenchmarkLazyNoCopyEthLayer (line 83) | func BenchmarkLazyNoCopyEthLayer(b *testing.B) {
function BenchmarkLazyNoCopyIPLayer (line 89) | func BenchmarkLazyNoCopyIPLayer(b *testing.B) {
function BenchmarkLazyNoCopyTCPLayer (line 95) | func BenchmarkLazyNoCopyTCPLayer(b *testing.B) {
function BenchmarkLazyNoCopyAllLayers (line 101) | func BenchmarkLazyNoCopyAllLayers(b *testing.B) {
function BenchmarkDefault (line 107) | func BenchmarkDefault(b *testing.B) {
function getSerializeLayers (line 113) | func getSerializeLayers() []gopacket.SerializableLayer {
function BenchmarkSerializeTcpNoOptions (line 124) | func BenchmarkSerializeTcpNoOptions(b *testing.B) {
function BenchmarkSerializeTcpFixLengths (line 133) | func BenchmarkSerializeTcpFixLengths(b *testing.B) {
function BenchmarkSerializeTcpComputeChecksums (line 142) | func BenchmarkSerializeTcpComputeChecksums(b *testing.B) {
function BenchmarkSerializeTcpFixLengthsComputeChecksums (line 151) | func BenchmarkSerializeTcpFixLengthsComputeChecksums(b *testing.B) {
function BenchmarkLazy (line 160) | func BenchmarkLazy(b *testing.B) {
function BenchmarkNoCopy (line 166) | func BenchmarkNoCopy(b *testing.B) {
function BenchmarkLazyNoCopy (line 172) | func BenchmarkLazyNoCopy(b *testing.B) {
function BenchmarkKnownStack (line 178) | func BenchmarkKnownStack(b *testing.B) {
function BenchmarkDecodingLayerParserIgnorePanic (line 190) | func BenchmarkDecodingLayerParserIgnorePanic(b *testing.B) {
function BenchmarkDecodingLayerParserHandlePanic (line 199) | func BenchmarkDecodingLayerParserHandlePanic(b *testing.B) {
function benchmarkDecodingLayerParser (line 208) | func benchmarkDecodingLayerParser(b *testing.B, dlc gopacket.DecodingLay...
function BenchmarkDecodingLayerParserSparseIgnorePanic (line 222) | func BenchmarkDecodingLayerParserSparseIgnorePanic(b *testing.B) {
function BenchmarkDecodingLayerParserSparseHandlePanic (line 226) | func BenchmarkDecodingLayerParserSparseHandlePanic(b *testing.B) {
function BenchmarkDecodingLayerParserArrayIgnorePanic (line 230) | func BenchmarkDecodingLayerParserArrayIgnorePanic(b *testing.B) {
function BenchmarkDecodingLayerParserArrayHandlePanic (line 234) | func BenchmarkDecodingLayerParserArrayHandlePanic(b *testing.B) {
function BenchmarkDecodingLayerParserMapIgnorePanic (line 238) | func BenchmarkDecodingLayerParserMapIgnorePanic(b *testing.B) {
function BenchmarkDecodingLayerParserMapHandlePanic (line 242) | func BenchmarkDecodingLayerParserMapHandlePanic(b *testing.B) {
function benchmarkDecodingLayerContainer (line 246) | func benchmarkDecodingLayerContainer(b *testing.B, dlc gopacket.Decoding...
function BenchmarkDecodingLayerArray (line 259) | func BenchmarkDecodingLayerArray(b *testing.B) {
function BenchmarkDecodingLayerMap (line 263) | func BenchmarkDecodingLayerMap(b *testing.B) {
function BenchmarkDecodingLayerSparse (line 267) | func BenchmarkDecodingLayerSparse(b *testing.B) {
function BenchmarkAlloc (line 271) | func BenchmarkAlloc(b *testing.B) {
function BenchmarkFlow (line 277) | func BenchmarkFlow(b *testing.B) {
function BenchmarkEndpoints (line 285) | func BenchmarkEndpoints(b *testing.B) {
function BenchmarkTCPLayerFromDecodedPacket (line 293) | func BenchmarkTCPLayerFromDecodedPacket(b *testing.B) {
function BenchmarkTCPLayerClassFromDecodedPacket (line 302) | func BenchmarkTCPLayerClassFromDecodedPacket(b *testing.B) {
function BenchmarkTCPTransportLayerFromDecodedPacket (line 312) | func BenchmarkTCPTransportLayerFromDecodedPacket(b *testing.B) {
function testDecoder (line 321) | func testDecoder([]byte, gopacket.PacketBuilder) error {
function BenchmarkDecodeFuncCallOverheadDirectCall (line 325) | func BenchmarkDecodeFuncCallOverheadDirectCall(b *testing.B) {
function BenchmarkDecodeFuncCallOverheadDecoderCall (line 333) | func BenchmarkDecodeFuncCallOverheadDecoderCall(b *testing.B) {
function BenchmarkDecodeFuncCallOverheadArrayCall (line 342) | func BenchmarkDecodeFuncCallOverheadArrayCall(b *testing.B) {
function BenchmarkFmtVerboseString (line 352) | func BenchmarkFmtVerboseString(b *testing.B) {
function BenchmarkPacketString (line 361) | func BenchmarkPacketString(b *testing.B) {
function BenchmarkPacketDumpString (line 370) | func BenchmarkPacketDumpString(b *testing.B) {
function TestFlowMapKey (line 380) | func TestFlowMapKey(t *testing.T) {
function TestDecodeSimpleTCPPacket (line 386) | func TestDecodeSimpleTCPPacket(t *testing.T) {
type canSetNetLayer (line 494) | type canSetNetLayer interface
function testSerialization (line 498) | func testSerialization(t *testing.T, p gopacket.Packet, data []byte) {
function testSerializationWithOpts (line 509) | func testSerializationWithOpts(t *testing.T, p gopacket.Packet, data []b...
function TestDecodeSmallTCPPacketHasEmptyPayload (line 532) | func TestDecodeSmallTCPPacketHasEmptyPayload(t *testing.T) {
function TestDecodeVLANPacket (line 549) | func TestDecodeVLANPacket(t *testing.T) {
function TestDecodeSCTPPackets (line 574) | func TestDecodeSCTPPackets(t *testing.T) {
function TestDecodeCiscoDiscovery (line 686) | func TestDecodeCiscoDiscovery(t *testing.T) {
function TestDecodeLinkLayerDiscovery (line 758) | func TestDecodeLinkLayerDiscovery(t *testing.T) {
function TestDecodeNortelDiscovery (line 963) | func TestDecodeNortelDiscovery(t *testing.T) {
function TestDecodeIPv6Jumbogram (line 991) | func TestDecodeIPv6Jumbogram(t *testing.T) {
function TestDecodeUDPPacketTooSmall (line 1018) | func TestDecodeUDPPacketTooSmall(t *testing.T) {
function TestDecodingLayerParserFullTCPPacket (line 1033) | func TestDecodingLayerParserFullTCPPacket(t *testing.T) {
function testDecodingLayerContainer (line 1045) | func testDecodingLayerContainer(t *testing.T, dlc gopacket.DecodingLayer...
function TestDecodingLayerMap (line 1067) | func TestDecodingLayerMap(t *testing.T) {
function TestDecodingLayerSparse (line 1071) | func TestDecodingLayerSparse(t *testing.T) {
function TestDecodingLayerArray (line 1075) | func TestDecodingLayerArray(t *testing.T) {
function TestICMP (line 1094) | func TestICMP(t *testing.T) {
function BenchmarkDecodeICMP (line 1102) | func BenchmarkDecodeICMP(b *testing.B) {
function TestICMP6 (line 1125) | func TestICMP6(t *testing.T) {
function BenchmarkDecodeICMP6 (line 1133) | func BenchmarkDecodeICMP6(b *testing.B) {
function TestMPLS (line 1160) | func TestMPLS(t *testing.T) {
function BenchmarkDecodeMPLS (line 1168) | func BenchmarkDecodeMPLS(b *testing.B) {
function TestPPPGREIPv4IPv6VLAN (line 1204) | func TestPPPGREIPv4IPv6VLAN(t *testing.T) {
function TestPPPoEICMPv6 (line 1240) | func TestPPPoEICMPv6(t *testing.T) {
function BenchmarkDecodePPPoEICMPv6 (line 1255) | func BenchmarkDecodePPPoEICMPv6(b *testing.B) {
function TestPFLogUDP (line 1271) | func TestPFLogUDP(t *testing.T) {
function TestRegressionDot1QPriority (line 1284) | func TestRegressionDot1QPriority(t *testing.T) {
function TestPacketMPLSInMPLS (line 1320) | func TestPacketMPLSInMPLS(t *testing.T) {
function TestPacketIPv4Fragmented (line 1349) | func TestPacketIPv4Fragmented(t *testing.T) {
function TestSCTPChunkBadLength (line 1359) | func TestSCTPChunkBadLength(t *testing.T) {
function TestSTP (line 1371) | func TestSTP(t *testing.T) {
FILE: layers/dhcp_test.go
function TestDHCPv4EncodeRequest (line 17) | func TestDHCPv4EncodeRequest(t *testing.T) {
function TestDHCPv4EncodeResponse (line 44) | func TestDHCPv4EncodeResponse(t *testing.T) {
function TestDHCPv4DecodeOption (line 70) | func TestDHCPv4DecodeOption(t *testing.T) {
function testDHCPEqual (line 122) | func testDHCPEqual(t *testing.T, d1, d2 *DHCPv4) {
function testDHCPOptionEqual (line 174) | func testDHCPOptionEqual(t *testing.T, idx int, d1, d2 DHCPOption) {
FILE: layers/dhcpv4.go
type DHCPOp (line 19) | type DHCPOp
method String (line 28) | func (o DHCPOp) String() string {
constant DHCPOpRequest (line 23) | DHCPOpRequest DHCPOp = 1
constant DHCPOpReply (line 24) | DHCPOpReply DHCPOp = 2
type DHCPMsgType (line 40) | type DHCPMsgType
method String (line 56) | func (o DHCPMsgType) String() string {
constant DHCPMsgTypeUnspecified (line 44) | DHCPMsgTypeUnspecified DHCPMsgType = iota
constant DHCPMsgTypeDiscover (line 45) | DHCPMsgTypeDiscover
constant DHCPMsgTypeOffer (line 46) | DHCPMsgTypeOffer
constant DHCPMsgTypeRequest (line 47) | DHCPMsgTypeRequest
constant DHCPMsgTypeDecline (line 48) | DHCPMsgTypeDecline
constant DHCPMsgTypeAck (line 49) | DHCPMsgTypeAck
constant DHCPMsgTypeNak (line 50) | DHCPMsgTypeNak
constant DHCPMsgTypeRelease (line 51) | DHCPMsgTypeRelease
constant DHCPMsgTypeInform (line 52) | DHCPMsgTypeInform
type DHCPv4 (line 85) | type DHCPv4 struct
method LayerType (line 123) | func (d *DHCPv4) LayerType() gopacket.LayerType { return LayerTypeDHCP...
method DecodeFromBytes (line 126) | func (d *DHCPv4) DecodeFromBytes(data []byte, df gopacket.DecodeFeedba...
method Len (line 182) | func (d *DHCPv4) Len() uint16 {
method SerializeTo (line 198) | func (d *DHCPv4) SerializeTo(b gopacket.SerializeBuffer, opts gopacket...
method CanDecode (line 247) | func (d *DHCPv4) CanDecode() gopacket.LayerClass {
method NextLayerType (line 252) | func (d *DHCPv4) NextLayerType() gopacket.LayerType {
type DHCPOptions (line 106) | type DHCPOptions
method String (line 109) | func (o DHCPOptions) String() string {
function decodeDHCPv4 (line 256) | func decodeDHCPv4(data []byte, p gopacket.PacketBuilder) error {
type DHCPOpt (line 267) | type DHCPOpt
method String (line 341) | func (o DHCPOpt) String() string {
constant DHCPOptPad (line 271) | DHCPOptPad DHCPOpt = 0
constant DHCPOptSubnetMask (line 272) | DHCPOptSubnetMask DHCPOpt = 1
constant DHCPOptTimeOffset (line 273) | DHCPOptTimeOffset DHCPOpt = 2
constant DHCPOptRouter (line 274) | DHCPOptRouter DHCPOpt = 3
constant DHCPOptTimeServer (line 275) | DHCPOptTimeServer DHCPOpt = 4
constant DHCPOptNameServer (line 276) | DHCPOptNameServer DHCPOpt = 5
constant DHCPOptDNS (line 277) | DHCPOptDNS DHCPOpt = 6
constant DHCPOptLogServer (line 278) | DHCPOptLogServer DHCPOpt = 7
constant DHCPOptCookieServer (line 279) | DHCPOptCookieServer DHCPOpt = 8
constant DHCPOptLPRServer (line 280) | DHCPOptLPRServer DHCPOpt = 9
constant DHCPOptImpressServer (line 281) | DHCPOptImpressServer DHCPOpt = 10
constant DHCPOptResLocServer (line 282) | DHCPOptResLocServer DHCPOpt = 11
constant DHCPOptHostname (line 283) | DHCPOptHostname DHCPOpt = 12
constant DHCPOptBootfileSize (line 284) | DHCPOptBootfileSize DHCPOpt = 13
constant DHCPOptMeritDumpFile (line 285) | DHCPOptMeritDumpFile DHCPOpt = 14
constant DHCPOptDomainName (line 286) | DHCPOptDomainName DHCPOpt = 15
constant DHCPOptSwapServer (line 287) | DHCPOptSwapServer DHCPOpt = 16
constant DHCPOptRootPath (line 288) | DHCPOptRootPath DHCPOpt = 17
constant DHCPOptExtensionsPath (line 289) | DHCPOptExtensionsPath DHCPOpt = 18
constant DHCPOptIPForwarding (line 290) | DHCPOptIPForwarding DHCPOpt = 19
constant DHCPOptSourceRouting (line 291) | DHCPOptSourceRouting DHCPOpt = 20
constant DHCPOptPolicyFilter (line 292) | DHCPOptPolicyFilter DHCPOpt = 21
constant DHCPOptDatagramMTU (line 293) | DHCPOptDatagramMTU DHCPOpt = 22
constant DHCPOptDefaultTTL (line 294) | DHCPOptDefaultTTL DHCPOpt = 23
constant DHCPOptPathMTUAgingTimeout (line 295) | DHCPOptPathMTUAgingTimeout DHCPOpt = 24
constant DHCPOptPathPlateuTableOption (line 296) | DHCPOptPathPlateuTableOption DHCPOpt = 25
constant DHCPOptInterfaceMTU (line 297) | DHCPOptInterfaceMTU DHCPOpt = 26
constant DHCPOptAllSubsLocal (line 298) | DHCPOptAllSubsLocal DHCPOpt = 27
constant DHCPOptBroadcastAddr (line 299) | DHCPOptBroadcastAddr DHCPOpt = 28
constant DHCPOptMaskDiscovery (line 300) | DHCPOptMaskDiscovery DHCPOpt = 29
constant DHCPOptMaskSupplier (line 301) | DHCPOptMaskSupplier DHCPOpt = 30
constant DHCPOptRouterDiscovery (line 302) | DHCPOptRouterDiscovery DHCPOpt = 31
constant DHCPOptSolicitAddr (line 303) | DHCPOptSolicitAddr DHCPOpt = 32
constant DHCPOptStaticRoute (line 304) | DHCPOptStaticRoute DHCPOpt = 33
constant DHCPOptARPTrailers (line 305) | DHCPOptARPTrailers DHCPOpt = 34
constant DHCPOptARPTimeout (line 306) | DHCPOptARPTimeout DHCPOpt = 35
constant DHCPOptEthernetEncap (line 307) | DHCPOptEthernetEncap DHCPOpt = 36
constant DHCPOptTCPTTL (line 308) | DHCPOptTCPTTL DHCPOpt = 37
constant DHCPOptTCPKeepAliveInt (line 309) | DHCPOptTCPKeepAliveInt DHCPOpt = 38
constant DHCPOptTCPKeepAliveGarbage (line 310) | DHCPOptTCPKeepAliveGarbage DHCPOpt = 39
constant DHCPOptNISDomain (line 311) | DHCPOptNISDomain DHCPOpt = 40
constant DHCPOptNISServers (line 312) | DHCPOptNISServers DHCPOpt = 41
constant DHCPOptNTPServers (line 313) | DHCPOptNTPServers DHCPOpt = 42
constant DHCPOptVendorOption (line 314) | DHCPOptVendorOption DHCPOpt = 43
constant DHCPOptNetBIOSTCPNS (line 315) | DHCPOptNetBIOSTCPNS DHCPOpt = 44
constant DHCPOptNetBIOSTCPDDS (line 316) | DHCPOptNetBIOSTCPDDS DHCPOpt = 45
constant DHCPOptNETBIOSTCPNodeType (line 317) | DHCPOptNETBIOSTCPNodeType DHCPOpt = 46
constant DHCPOptNetBIOSTCPScope (line 318) | DHCPOptNetBIOSTCPScope DHCPOpt = 47
constant DHCPOptXFontServer (line 319) | DHCPOptXFontServer DHCPOpt = 48
constant DHCPOptXDisplayManager (line 320) | DHCPOptXDisplayManager DHCPOpt = 49
constant DHCPOptRequestIP (line 321) | DHCPOptRequestIP DHCPOpt = 50
constant DHCPOptLeaseTime (line 322) | DHCPOptLeaseTime DHCPOpt = 51
constant DHCPOptExtOptions (line 323) | DHCPOptExtOptions DHCPOpt = 52
constant DHCPOptMessageType (line 324) | DHCPOptMessageType DHCPOpt = 53
constant DHCPOptServerID (line 325) | DHCPOptServerID DHCPOpt = 54
constant DHCPOptParamsRequest (line 326) | DHCPOptParamsRequest DHCPOpt = 55
constant DHCPOptMessage (line 327) | DHCPOptMessage DHCPOpt = 56
constant DHCPOptMaxMessageSize (line 328) | DHCPOptMaxMessageSize DHCPOpt = 57
constant DHCPOptT1 (line 329) | DHCPOptT1 DHCPOpt = 58
constant DHCPOptT2 (line 330) | DHCPOptT2 DHCPOpt = 59
constant DHCPOptClassID (line 331) | DHCPOptClassID DHCPOpt = 60
constant DHCPOptClientID (line 332) | DHCPOptClientID DHCPOpt = 61
constant DHCPOptDomainSearch (line 333) | DHCPOptDomainSearch DHCPOpt = 119
constant DHCPOptSIPServers (line 334) | DHCPOptSIPServers DHCPOpt = 120
constant DHCPOptClasslessStaticRoute (line 335) | DHCPOptClasslessStaticRoute DHCPOpt = 121
constant DHCPOptMUDURLV4 (line 336) | DHCPOptMUDURLV4 DHCPOpt = 161
constant DHCPOptEnd (line 337) | DHCPOptEnd DHCPOpt = 255
type DHCPOption (line 483) | type DHCPOption struct
method String (line 490) | func (o DHCPOption) String() string {
method encode (line 546) | func (o *DHCPOption) encode(b []byte) error {
method decode (line 558) | func (o *DHCPOption) decode(data []byte) error {
function NewDHCPOption (line 537) | func NewDHCPOption(t DHCPOpt, data []byte) DHCPOption {
type DHCPv4Error (line 581) | type DHCPv4Error
method Error (line 584) | func (d DHCPv4Error) Error() string {
constant DecOptionNotEnoughData (line 590) | DecOptionNotEnoughData = DHCPv4Error("Not enough data to decode")
constant DecOptionMalformed (line 592) | DecOptionMalformed = DHCPv4Error("Option is malformed")
constant InvalidMagicCookie (line 594) | InvalidMagicCookie = DHCPv4Error("Bad DHCP header")
FILE: layers/dhcpv6.go
type DHCPv6MsgType (line 18) | type DHCPv6MsgType
method String (line 39) | func (o DHCPv6MsgType) String() string {
constant DHCPv6MsgTypeUnspecified (line 22) | DHCPv6MsgTypeUnspecified DHCPv6MsgType = iota
constant DHCPv6MsgTypeSolicit (line 23) | DHCPv6MsgTypeSolicit
constant DHCPv6MsgTypeAdvertise (line 24) | DHCPv6MsgTypeAdvertise
constant DHCPv6MsgTypeRequest (line 25) | DHCPv6MsgTypeRequest
constant DHCPv6MsgTypeConfirm (line 26) | DHCPv6MsgTypeConfirm
constant DHCPv6MsgTypeRenew (line 27) | DHCPv6MsgTypeRenew
constant DHCPv6MsgTypeRebind (line 28) | DHCPv6MsgTypeRebind
constant DHCPv6MsgTypeReply (line 29) | DHCPv6MsgTypeReply
constant DHCPv6MsgTypeRelease (line 30) | DHCPv6MsgTypeRelease
constant DHCPv6MsgTypeDecline (line 31) | DHCPv6MsgTypeDecline
constant DHCPv6MsgTypeReconfigure (line 32) | DHCPv6MsgTypeReconfigure
constant DHCPv6MsgTypeInformationRequest (line 33) | DHCPv6MsgTypeInformationRequest
constant DHCPv6MsgTypeRelayForward (line 34) | DHCPv6MsgTypeRelayForward
constant DHCPv6MsgTypeRelayReply (line 35) | DHCPv6MsgTypeRelayReply
type DHCPv6 (line 75) | type DHCPv6 struct
method LayerType (line 86) | func (d *DHCPv6) LayerType() gopacket.LayerType { return LayerTypeDHCP...
method DecodeFromBytes (line 89) | func (d *DHCPv6) DecodeFromBytes(data []byte, df gopacket.DecodeFeedba...
method Len (line 127) | func (d *DHCPv6) Len() int {
method SerializeTo (line 145) | func (d *DHCPv6) SerializeTo(b gopacket.SerializeBuffer, opts gopacket...
method CanDecode (line 177) | func (d *DHCPv6) CanDecode() gopacket.LayerClass {
method NextLayerType (line 182) | func (d *DHCPv6) NextLayerType() gopacket.LayerType {
function decodeDHCPv6 (line 186) | func decodeDHCPv6(data []byte, p gopacket.PacketBuilder) error {
type DHCPv6StatusCode (line 197) | type DHCPv6StatusCode
method String (line 210) | func (o DHCPv6StatusCode) String() string {
constant DHCPv6StatusCodeSuccess (line 201) | DHCPv6StatusCodeSuccess DHCPv6StatusCode = iota
constant DHCPv6StatusCodeUnspecFail (line 202) | DHCPv6StatusCodeUnspecFail
constant DHCPv6StatusCodeNoAddrsAvail (line 203) | DHCPv6StatusCodeNoAddrsAvail
constant DHCPv6StatusCodeNoBinding (line 204) | DHCPv6StatusCodeNoBinding
constant DHCPv6StatusCodeNotOnLink (line 205) | DHCPv6StatusCodeNotOnLink
constant DHCPv6StatusCodeUseMulticast (line 206) | DHCPv6StatusCodeUseMulticast
type DHCPv6DUIDType (line 230) | type DHCPv6DUIDType
method String (line 240) | func (o DHCPv6DUIDType) String() string {
constant DHCPv6DUIDTypeLLT (line 234) | DHCPv6DUIDTypeLLT DHCPv6DUIDType = iota + 1
constant DHCPv6DUIDTypeEN (line 235) | DHCPv6DUIDTypeEN
constant DHCPv6DUIDTypeLL (line 236) | DHCPv6DUIDTypeLL
type DHCPv6DUID (line 254) | type DHCPv6DUID struct
method DecodeFromBytes (line 269) | func (d *DHCPv6DUID) DecodeFromBytes(data []byte) error {
method Encode (line 305) | func (d *DHCPv6DUID) Encode() []byte {
method Len (line 328) | func (d *DHCPv6DUID) Len() int {
method String (line 341) | func (d *DHCPv6DUID) String() string {
function decodeDHCPv6DUID (line 353) | func decodeDHCPv6DUID(data []byte) (*DHCPv6DUID, error) {
FILE: layers/dhcpv6_options.go
type DHCPv6Opt (line 18) | type DHCPv6Opt
method String (line 263) | func (o DHCPv6Opt) String() string {
constant DHCPv6OptClientID (line 22) | DHCPv6OptClientID DHCPv6Opt = 1
constant DHCPv6OptServerID (line 23) | DHCPv6OptServerID DHCPv6Opt = 2
constant DHCPv6OptIANA (line 24) | DHCPv6OptIANA DHCPv6Opt = 3
constant DHCPv6OptIATA (line 25) | DHCPv6OptIATA DHCPv6Opt = 4
constant DHCPv6OptIAAddr (line 26) | DHCPv6OptIAAddr DHCPv6Opt = 5
constant DHCPv6OptOro (line 27) | DHCPv6OptOro DHCPv6Opt = 6
constant DHCPv6OptPreference (line 28) | DHCPv6OptPreference DHCPv6Opt = 7
constant DHCPv6OptElapsedTime (line 29) | DHCPv6OptElapsedTime DHCPv6Opt = 8
constant DHCPv6OptRelayMessage (line 30) | DHCPv6OptRelayMessage DHCPv6Opt = 9
constant DHCPv6OptAuth (line 31) | DHCPv6OptAuth DHCPv6Opt = 11
constant DHCPv6OptUnicast (line 32) | DHCPv6OptUnicast DHCPv6Opt = 12
constant DHCPv6OptStatusCode (line 33) | DHCPv6OptStatusCode DHCPv6Opt = 13
constant DHCPv6OptRapidCommit (line 34) | DHCPv6OptRapidCommit DHCPv6Opt = 14
constant DHCPv6OptUserClass (line 35) | DHCPv6OptUserClass DHCPv6Opt = 15
constant DHCPv6OptVendorClass (line 36) | DHCPv6OptVendorClass DHCPv6Opt = 16
constant DHCPv6OptVendorOpts (line 37) | DHCPv6OptVendorOpts DHCPv6Opt = 17
constant DHCPv6OptInterfaceID (line 38) | DHCPv6OptInterfaceID DHCPv6Opt = 18
constant DHCPv6OptReconfigureMessage (line 39) | DHCPv6OptReconfigureMessage DHCPv6Opt = 19
constant DHCPv6OptReconfigureAccept (line 40) | DHCPv6OptReconfigureAccept DHCPv6Opt = 20
constant DHCPv6OptSIPServersDomainList (line 43) | DHCPv6OptSIPServersDomainList DHCPv6Opt = 21
constant DHCPv6OptSIPServersAddressList (line 44) | DHCPv6OptSIPServersAddressList DHCPv6Opt = 22
constant DHCPv6OptDNSServers (line 47) | DHCPv6OptDNSServers DHCPv6Opt = 23
constant DHCPv6OptDomainList (line 48) | DHCPv6OptDomainList DHCPv6Opt = 24
constant DHCPv6OptIAPD (line 51) | DHCPv6OptIAPD DHCPv6Opt = 25
constant DHCPv6OptIAPrefix (line 52) | DHCPv6OptIAPrefix DHCPv6Opt = 26
constant DHCPv6OptNISServers (line 55) | DHCPv6OptNISServers DHCPv6Opt = 27
constant DHCPv6OptNISPServers (line 56) | DHCPv6OptNISPServers DHCPv6Opt = 28
constant DHCPv6OptNISDomainName (line 57) | DHCPv6OptNISDomainName DHCPv6Opt = 29
constant DHCPv6OptNISPDomainName (line 58) | DHCPv6OptNISPDomainName DHCPv6Opt = 30
constant DHCPv6OptSNTPServers (line 61) | DHCPv6OptSNTPServers DHCPv6Opt = 31
constant DHCPv6OptInformationRefreshTime (line 64) | DHCPv6OptInformationRefreshTime DHCPv6Opt = 32
constant DHCPv6OptBCMCSServerDomainNameList (line 67) | DHCPv6OptBCMCSServerDomainNameList DHCPv6Opt = 33
constant DHCPv6OptBCMCSServerAddressList (line 68) | DHCPv6OptBCMCSServerAddressList DHCPv6Opt = 34
constant DHCPv6OptGeoconfCivic (line 71) | DHCPv6OptGeoconfCivic DHCPv6Opt = 36
constant DHCPv6OptRemoteID (line 74) | DHCPv6OptRemoteID DHCPv6Opt = 37
constant DHCPv6OptSubscriberID (line 77) | DHCPv6OptSubscriberID DHCPv6Opt = 38
constant DHCPv6OptClientFQDN (line 80) | DHCPv6OptClientFQDN DHCPv6Opt = 39
constant DHCPv6OptPanaAgent (line 83) | DHCPv6OptPanaAgent DHCPv6Opt = 40
constant DHCPv6OptNewPOSIXTimezone (line 86) | DHCPv6OptNewPOSIXTimezone DHCPv6Opt = 41
constant DHCPv6OptNewTZDBTimezone (line 87) | DHCPv6OptNewTZDBTimezone DHCPv6Opt = 42
constant DHCPv6OptEchoRequestOption (line 90) | DHCPv6OptEchoRequestOption DHCPv6Opt = 43
constant DHCPv6OptLQQuery (line 93) | DHCPv6OptLQQuery DHCPv6Opt = 44
constant DHCPv6OptCLTTime (line 94) | DHCPv6OptCLTTime DHCPv6Opt = 45
constant DHCPv6OptClientData (line 95) | DHCPv6OptClientData DHCPv6Opt = 46
constant DHCPv6OptLQRelayData (line 96) | DHCPv6OptLQRelayData DHCPv6Opt = 47
constant DHCPv6OptLQClientLink (line 97) | DHCPv6OptLQClientLink DHCPv6Opt = 48
constant DHCPv6OptMIP6HNIDF (line 100) | DHCPv6OptMIP6HNIDF DHCPv6Opt = 49
constant DHCPv6OptMIP6VDINF (line 101) | DHCPv6OptMIP6VDINF DHCPv6Opt = 50
constant DHCPv6OptMIP6IDINF (line 102) | DHCPv6OptMIP6IDINF DHCPv6Opt = 69
constant DHCPv6OptMIP6UDINF (line 103) | DHCPv6OptMIP6UDINF DHCPv6Opt = 70
constant DHCPv6OptMIP6HNP (line 104) | DHCPv6OptMIP6HNP DHCPv6Opt = 71
constant DHCPv6OptMIP6HAA (line 105) | DHCPv6OptMIP6HAA DHCPv6Opt = 72
constant DHCPv6OptMIP6HAF (line 106) | DHCPv6OptMIP6HAF DHCPv6Opt = 73
constant DHCPv6OptV6LOST (line 109) | DHCPv6OptV6LOST DHCPv6Opt = 51
constant DHCPv6OptCAPWAPACV6 (line 112) | DHCPv6OptCAPWAPACV6 DHCPv6Opt = 52
constant DHCPv6OptRelayID (line 115) | DHCPv6OptRelayID DHCPv6Opt = 53
constant DHCPv6OptIPv6AddressMoS (line 118) | DHCPv6OptIPv6AddressMoS DHCPv6Opt = 54
constant DHCPv6OptIPv6FQDNMoS (line 119) | DHCPv6OptIPv6FQDNMoS DHCPv6Opt = 55
constant DHCPv6OptNTPServer (line 122) | DHCPv6OptNTPServer DHCPv6Opt = 56
constant DHCPv6OptV6AccessDomain (line 125) | DHCPv6OptV6AccessDomain DHCPv6Opt = 57
constant DHCPv6OptSIPUACSList (line 128) | DHCPv6OptSIPUACSList DHCPv6Opt = 58
constant DHCPv6OptBootFileURL (line 131) | DHCPv6OptBootFileURL DHCPv6Opt = 59
constant DHCPv6OptBootFileParam (line 132) | DHCPv6OptBootFileParam DHCPv6Opt = 60
constant DHCPv6OptClientArchType (line 133) | DHCPv6OptClientArchType DHCPv6Opt = 61
constant DHCPv6OptNII (line 134) | DHCPv6OptNII DHCPv6Opt = 62
constant DHCPv6OptGeolocation (line 137) | DHCPv6OptGeolocation DHCPv6Opt = 63
constant DHCPv6OptAFTRName (line 140) | DHCPv6OptAFTRName DHCPv6Opt = 64
constant DHCPv6OptERPLocalDomainName (line 143) | DHCPv6OptERPLocalDomainName DHCPv6Opt = 65
constant DHCPv6OptRSOO (line 146) | DHCPv6OptRSOO DHCPv6Opt = 66
constant DHCPv6OptPDExclude (line 149) | DHCPv6OptPDExclude DHCPv6Opt = 67
constant DHCPv6OptVSS (line 152) | DHCPv6OptVSS DHCPv6Opt = 68
constant DHCPv6OptRDNSSSelection (line 155) | DHCPv6OptRDNSSSelection DHCPv6Opt = 74
constant DHCPv6OptKRBPrincipalName (line 158) | DHCPv6OptKRBPrincipalName DHCPv6Opt = 75
constant DHCPv6OptKRBRealmName (line 159) | DHCPv6OptKRBRealmName DHCPv6Opt = 76
constant DHCPv6OptKRBKDC (line 160) | DHCPv6OptKRBKDC DHCPv6Opt = 77
constant DHCPv6OptClientLinkLayerAddress (line 163) | DHCPv6OptClientLinkLayerAddress DHCPv6Opt = 79
constant DHCPv6OptLinkAddress (line 166) | DHCPv6OptLinkAddress DHCPv6Opt = 80
constant DHCPv6OptRADIUS (line 169) | DHCPv6OptRADIUS DHCPv6Opt = 81
constant DHCPv6OptSolMaxRt (line 172) | DHCPv6OptSolMaxRt DHCPv6Opt = 82
constant DHCPv6OptInfMaxRt (line 173) | DHCPv6OptInfMaxRt DHCPv6Opt = 83
constant DHCPv6OptAddrSel (line 176) | DHCPv6OptAddrSel DHCPv6Opt = 84
constant DHCPv6OptAddrSelTable (line 177) | DHCPv6OptAddrSelTable DHCPv6Opt = 85
constant DHCPv6OptV6PCPServer (line 180) | DHCPv6OptV6PCPServer DHCPv6Opt = 86
constant DHCPv6OptDHCPv4Message (line 183) | DHCPv6OptDHCPv4Message DHCPv6Opt = 87
constant DHCPv6OptDHCPv4OverDHCPv6Server (line 184) | DHCPv6OptDHCPv4OverDHCPv6Server DHCPv6Opt = 88
constant DHCPv6OptS46Rule (line 187) | DHCPv6OptS46Rule DHCPv6Opt = 89
constant DHCPv6OptS46BR (line 188) | DHCPv6OptS46BR DHCPv6Opt = 90
constant DHCPv6OptS46DMR (line 189) | DHCPv6OptS46DMR DHCPv6Opt = 91
constant DHCPv6OptS46V4V4Bind (line 190) | DHCPv6OptS46V4V4Bind DHCPv6Opt = 92
constant DHCPv6OptS46PortParameters (line 191) | DHCPv6OptS46PortParameters DHCPv6Opt = 93
constant DHCPv6OptS46ContMAPE (line 192) | DHCPv6OptS46ContMAPE DHCPv6Opt = 94
constant DHCPv6OptS46ContMAPT (line 193) | DHCPv6OptS46ContMAPT DHCPv6Opt = 95
constant DHCPv6OptS46ContLW (line 194) | DHCPv6OptS46ContLW DHCPv6Opt = 96
constant DHCPv6Opt4RD (line 197) | DHCPv6Opt4RD DHCPv6Opt = 97
constant DHCPv6Opt4RDMapRule (line 198) | DHCPv6Opt4RDMapRule DHCPv6Opt = 98
constant DHCPv6Opt4RDNonMapRule (line 199) | DHCPv6Opt4RDNonMapRule DHCPv6Opt = 99
constant DHCPv6OptLQBaseTime (line 202) | DHCPv6OptLQBaseTime DHCPv6Opt = 100
constant DHCPv6OptLQStartTime (line 203) | DHCPv6OptLQStartTime DHCPv6Opt = 101
constant DHCPv6OptLQEndTime (line 204) | DHCPv6OptLQEndTime DHCPv6Opt = 102
constant DHCPv6OptCaptivePortal (line 207) | DHCPv6OptCaptivePortal DHCPv6Opt = 103
constant DHCPv6OptMPLParameters (line 210) | DHCPv6OptMPLParameters DHCPv6Opt = 104
constant DHCPv6OptANIATT (line 213) | DHCPv6OptANIATT DHCPv6Opt = 105
constant DHCPv6OptANINetworkName (line 214) | DHCPv6OptANINetworkName DHCPv6Opt = 106
constant DHCPv6OptANIAPName (line 215) | DHCPv6OptANIAPName DHCPv6Opt = 107
constant DHCPv6OptANIAPBSSID (line 216) | DHCPv6OptANIAPBSSID DHCPv6Opt = 108
constant DHCPv6OptANIOperatorID (line 217) | DHCPv6OptANIOperatorID DHCPv6Opt = 109
constant DHCPv6OptANIOperatorRealm (line 218) | DHCPv6OptANIOperatorRealm DHCPv6Opt = 110
constant DHCPv6OptS46Priority (line 221) | DHCPv6OptS46Priority DHCPv6Opt = 111
constant DHCPv6OptMUDURLV6 (line 224) | DHCPv6OptMUDURLV6 DHCPv6Opt = 112
constant DHCPv6OptV6Prefix64 (line 227) | DHCPv6OptV6Prefix64 DHCPv6Opt = 113
constant DHCPv6OptFBindingStatus (line 230) | DHCPv6OptFBindingStatus DHCPv6Opt = 114
constant DHCPv6OptFConnectFlags (line 231) | DHCPv6OptFConnectFlags DHCPv6Opt = 115
constant DHCPv6OptFDNSRemovalInfo (line 232) | DHCPv6OptFDNSRemovalInfo DHCPv6Opt = 116
constant DHCPv6OptFDNSHostName (line 233) | DHCPv6OptFDNSHostName DHCPv6Opt = 117
constant DHCPv6OptFDNSZoneName (line 234) | DHCPv6OptFDNSZoneName DHCPv6Opt = 118
constant DHCPv6OptFDNSFlags (line 235) | DHCPv6OptFDNSFlags DHCPv6Opt = 119
constant DHCPv6OptFExpirationTime (line 236) | DHCPv6OptFExpirationTime DHCPv6Opt = 120
constant DHCPv6OptFMaxUnacknowledgedBNDUPD (line 237) | DHCPv6OptFMaxUnacknowledgedBNDUPD DHCPv6Opt = 121
constant DHCPv6OptFMCLT (line 238) | DHCPv6OptFMCLT DHCPv6Opt = 122
constant DHCPv6OptFPartnerLifetime (line 239) | DHCPv6OptFPartnerLifetime DHCPv6Opt = 123
constant DHCPv6OptFPartnerLifetimeSent (line 240) | DHCPv6OptFPartnerLifetimeSent DHCPv6Opt = 124
constant DHCPv6OptFPartnerDownTime (line 241) | DHCPv6OptFPartnerDownTime DHCPv6Opt = 125
constant DHCPv6OptFPartnerRawCltTime (line 242) | DHCPv6OptFPartnerRawCltTime DHCPv6Opt = 126
constant DHCPv6OptFProtocolVersion (line 243) | DHCPv6OptFProtocolVersion DHCPv6Opt = 127
constant DHCPv6OptFKeepaliveTime (line 244) | DHCPv6OptFKeepaliveTime DHCPv6Opt = 128
constant DHCPv6OptFReconfigureData (line 245) | DHCPv6OptFReconfigureData DHCPv6Opt = 129
constant DHCPv6OptFRelationshipName (line 246) | DHCPv6OptFRelationshipName DHCPv6Opt = 130
constant DHCPv6OptFServerFlags (line 247) | DHCPv6OptFServerFlags DHCPv6Opt = 131
constant DHCPv6OptFServerState (line 248) | DHCPv6OptFServerState DHCPv6Opt = 132
constant DHCPv6OptFStartTimeOfState (line 249) | DHCPv6OptFStartTimeOfState DHCPv6Opt = 133
constant DHCPv6OptFStateExpirationTime (line 250) | DHCPv6OptFStateExpirationTime DHCPv6Opt = 134
constant DHCPv6OptRelayPort (line 253) | DHCPv6OptRelayPort DHCPv6Opt = 135
constant DHCPv6OptV6ZeroTouchRedirect (line 256) | DHCPv6OptV6ZeroTouchRedirect DHCPv6Opt = 136
constant DHCPv6OptIPV6AddressANDSF (line 259) | DHCPv6OptIPV6AddressANDSF DHCPv6Opt = 143
type DHCPv6Options (line 540) | type DHCPv6Options
method String (line 543) | func (o DHCPv6Options) String() string {
type DHCPv6Option (line 557) | type DHCPv6Option struct
method String (line 564) | func (o DHCPv6Option) String() string {
method encode (line 598) | func (o *DHCPv6Option) encode(b []byte, opts gopacket.SerializeOptions...
method decode (line 610) | func (o *DHCPv6Option) decode(data []byte) error {
function NewDHCPv6Option (line 588) | func NewDHCPv6Option(code DHCPv6Opt, data []byte) DHCPv6Option {
FILE: layers/dhcpv6_test.go
function TestDHCPv6EncodeRequest (line 16) | func TestDHCPv6EncodeRequest(t *testing.T) {
function TestDHCPv6EncodeReply (line 37) | func TestDHCPv6EncodeReply(t *testing.T) {
function testDHCPv6Equal (line 58) | func testDHCPv6Equal(t *testing.T, d1, d2 *DHCPv6) {
function testDHCPv6OptionEqual (line 83) | func testDHCPv6OptionEqual(t *testing.T, idx int, d1, d2 DHCPv6Option) {
FILE: layers/dns.go
type DNSClass (line 21) | type DNSClass
method String (line 32) | func (dc DNSClass) String() string {
constant DNSClassIN (line 25) | DNSClassIN DNSClass = 1
constant DNSClassCS (line 26) | DNSClassCS DNSClass = 2
constant DNSClassCH (line 27) | DNSClassCH DNSClass = 3
constant DNSClassHS (line 28) | DNSClassHS DNSClass = 4
constant DNSClassAny (line 29) | DNSClassAny DNSClass = 255
type DNSType (line 51) | type DNSType
method String (line 77) | func (dt DNSType) String() string {
constant DNSTypeA (line 55) | DNSTypeA DNSType = 1
constant DNSTypeNS (line 56) | DNSTypeNS DNSType = 2
constant DNSTypeMD (line 57) | DNSTypeMD DNSType = 3
constant DNSTypeMF (line 58) | DNSTypeMF DNSType = 4
constant DNSTypeCNAME (line 59) | DNSTypeCNAME DNSType = 5
constant DNSTypeSOA (line 60) | DNSTypeSOA DNSType = 6
constant DNSTypeMB (line 61) | DNSTypeMB DNSType = 7
constant DNSTypeMG (line 62) | DNSTypeMG DNSType = 8
constant DNSTypeMR (line 63) | DNSTypeMR DNSType = 9
constant DNSTypeNULL (line 64) | DNSTypeNULL DNSType = 10
constant DNSTypeWKS (line 65) | DNSTypeWKS DNSType = 11
constant DNSTypePTR (line 66) | DNSTypePTR DNSType = 12
constant DNSTypeHINFO (line 67) | DNSTypeHINFO DNSType = 13
constant DNSTypeMINFO (line 68) | DNSTypeMINFO DNSType = 14
constant DNSTypeMX (line 69) | DNSTypeMX DNSType = 15
constant DNSTypeTXT (line 70) | DNSTypeTXT DNSType = 16
constant DNSTypeAAAA (line 71) | DNSTypeAAAA DNSType = 28
constant DNSTypeSRV (line 72) | DNSTypeSRV DNSType = 33
constant DNSTypeOPT (line 73) | DNSTypeOPT DNSType = 41
constant DNSTypeURI (line 74) | DNSTypeURI DNSType = 256
type DNSResponseCode (line 125) | type DNSResponseCode
method String (line 151) | func (drc DNSResponseCode) String() string {
constant DNSResponseCodeNoErr (line 129) | DNSResponseCodeNoErr DNSResponseCode = 0
constant DNSResponseCodeFormErr (line 130) | DNSResponseCodeFormErr DNSResponseCode = 1
constant DNSResponseCodeServFail (line 131) | DNSResponseCodeServFail DNSResponseCode = 2
constant DNSResponseCodeNXDomain (line 132) | DNSResponseCodeNXDomain DNSResponseCode = 3
constant DNSResponseCodeNotImp (line 133) | DNSResponseCodeNotImp DNSResponseCode = 4
constant DNSResponseCodeRefused (line 134) | DNSResponseCodeRefused DNSResponseCode = 5
constant DNSResponseCodeYXDomain (line 135) | DNSResponseCodeYXDomain DNSResponseCode = 6
constant DNSResponseCodeYXRRSet (line 136) | DNSResponseCodeYXRRSet DNSResponseCode = 7
constant DNSResponseCodeNXRRSet (line 137) | DNSResponseCodeNXRRSet DNSResponseCode = 8
constant DNSResponseCodeNotAuth (line 138) | DNSResponseCodeNotAuth DNSResponseCode = 9
constant DNSResponseCodeNotZone (line 139) | DNSResponseCodeNotZone DNSResponseCode = 10
constant DNSResponseCodeBadVers (line 140) | DNSResponseCodeBadVers DNSResponseCode = 16
constant DNSResponseCodeBadSig (line 141) | DNSResponseCodeBadSig DNSResponseCode = 16
constant DNSResponseCodeBadKey (line 142) | DNSResponseCodeBadKey DNSResponseCode = 17
constant DNSResponseCodeBadTime (line 143) | DNSResponseCodeBadTime DNSResponseCode = 18
constant DNSResponseCodeBadMode (line 144) | DNSResponseCodeBadMode DNSResponseCode = 19
constant DNSResponseCodeBadName (line 145) | DNSResponseCodeBadName DNSResponseCode = 20
constant DNSResponseCodeBadAlg (line 146) | DNSResponseCodeBadAlg DNSResponseCode = 21
constant DNSResponseCodeBadTruc (line 147) | DNSResponseCodeBadTruc DNSResponseCode = 22
constant DNSResponseCodeBadCookie (line 148) | DNSResponseCodeBadCookie DNSResponseCode = 23
type DNSOpCode (line 197) | type DNSOpCode
method String (line 208) | func (doc DNSOpCode) String() string {
constant DNSOpCodeQuery (line 201) | DNSOpCodeQuery DNSOpCode = 0
constant DNSOpCodeIQuery (line 202) | DNSOpCodeIQuery DNSOpCode = 1
constant DNSOpCodeStatus (line 203) | DNSOpCodeStatus DNSOpCode = 2
constant DNSOpCodeNotify (line 204) | DNSOpCodeNotify DNSOpCode = 4
constant DNSOpCodeUpdate (line 205) | DNSOpCodeUpdate DNSOpCode = 5
type DNS (line 255) | type DNS struct
method LayerType (line 288) | func (d *DNS) LayerType() gopacket.LayerType { return LayerTypeDNS }
method DecodeFromBytes (line 304) | func (d *DNS) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback)...
method CanDecode (line 395) | func (d *DNS) CanDecode() gopacket.LayerClass {
method NextLayerType (line 400) | func (d *DNS) NextLayerType() gopacket.LayerType {
method Payload (line 405) | func (d *DNS) Payload() []byte {
method SerializeTo (line 471) | func (d *DNS) SerializeTo(b gopacket.SerializeBuffer, opts gopacket.Se...
function decodeDNS (line 292) | func decodeDNS(data []byte, p gopacket.PacketBuilder) error {
function b2i (line 409) | func b2i(b bool) int {
function recSize (line 416) | func recSize(rr *DNSResourceRecord) int {
function computeSize (line 453) | func computeSize(recs []DNSResourceRecord) int {
constant maxRecursionLevel (line 536) | maxRecursionLevel = 255
function decodeName (line 538) | func decodeName(data []byte, offset int, buffer *[]byte, level int) ([]b...
type DNSQuestion (line 630) | type DNSQuestion struct
method decode (line 636) | func (q *DNSQuestion) decode(data []byte, offset int, df gopacket.Deco...
method encode (line 653) | func (q *DNSQuestion) encode(data []byte, offset int) int {
type DNSResourceRecord (line 684) | type DNSResourceRecord struct
method decode (line 710) | func (rr *DNSResourceRecord) decode(data []byte, offset int, df gopack...
method encode (line 764) | func (rr *DNSResourceRecord) encode(data []byte, offset int, opts gopa...
method String (line 834) | func (rr *DNSResourceRecord) String() string {
method decodeRData (line 906) | func (rr *DNSResourceRecord) decodeRData(data []byte, offset int, buff...
function encodeName (line 740) | func encodeName(name []byte, data []byte, offset int) int {
function decodeCharacterStrings (line 864) | func decodeCharacterStrings(data []byte) ([][]byte, error) {
function decodeOPTs (line 877) | func decodeOPTs(data []byte, offset int) ([]DNSOPT, error) {
type DNSSOA (line 997) | type DNSSOA struct
type DNSSRV (line 1004) | type DNSSRV struct
type DNSMX (line 1011) | type DNSMX struct
type DNSURI (line 1017) | type DNSURI struct
type DNSOptionCode (line 1023) | type DNSOptionCode
method String (line 1025) | func (doc DNSOptionCode) String() string {
constant DNSOptionCodeNSID (line 1062) | DNSOptionCodeNSID DNSOptionCode = 3
constant DNSOptionCodeDAU (line 1063) | DNSOptionCodeDAU DNSOptionCode = 5
constant DNSOptionCodeDHU (line 1064) | DNSOptionCodeDHU DNSOptionCode = 6
constant DNSOptionCodeN3U (line 1065) | DNSOptionCodeN3U DNSOptionCode = 7
constant DNSOptionCodeEDNSClientSubnet (line 1066) | DNSOptionCodeEDNSClientSubnet DNSOptionCode = 8
constant DNSOptionCodeEDNSExpire (line 1067) | DNSOptionCodeEDNSExpire DNSOptionCode = 9
constant DNSOptionCodeCookie (line 1068) | DNSOptionCodeCookie DNSOptionCode = 10
constant DNSOptionCodeEDNSKeepAlive (line 1069) | DNSOptionCodeEDNSKeepAlive DNSOptionCode = 11
constant DNSOptionCodePadding (line 1070) | DNSOptionCodePadding DNSOptionCode = 12
constant DNSOptionCodeChain (line 1071) | DNSOptionCodeChain DNSOptionCode = 13
constant DNSOptionCodeEDNSKeyTag (line 1072) | DNSOptionCodeEDNSKeyTag DNSOptionCode = 14
constant DNSOptionCodeEDNSClientTag (line 1073) | DNSOptionCodeEDNSClientTag DNSOptionCode = 16
constant DNSOptionCodeEDNSServerTag (line 1074) | DNSOptionCodeEDNSServerTag DNSOptionCode = 17
constant DNSOptionCodeDeviceID (line 1075) | DNSOptionCodeDeviceID DNSOptionCode = 26946
type DNSOPT (line 1079) | type DNSOPT struct
method String (line 1084) | func (opt DNSOPT) String() string {
FILE: layers/dns_test.go
function FuzzDecodeFromBytes (line 18) | func FuzzDecodeFromBytes(f *testing.F) {
function TestPacketDNSNilRdata (line 43) | func TestPacketDNSNilRdata(t *testing.T) {
function TestPacketDNSRegression (line 68) | func TestPacketDNSRegression(t *testing.T) {
function BenchmarkDecodePacketDNSRegression (line 75) | func BenchmarkDecodePacketDNSRegression(b *testing.B) {
function TestParseDNSTypeTXT (line 95) | func TestParseDNSTypeTXT(t *testing.T) {
function TestParseDNSBadVers (line 123) | func TestParseDNSBadVers(t *testing.T) {
function TestParseDNSBadCookie (line 163) | func TestParseDNSBadCookie(t *testing.T) {
function TestParseDNSTypeURI (line 206) | func TestParseDNSTypeURI(t *testing.T) {
function TestParseDNSTypeOPT (line 243) | func TestParseDNSTypeOPT(t *testing.T) {
function testQuestionEqual (line 275) | func testQuestionEqual(t *testing.T, i int, exp, got DNSQuestion) {
function testResourceEqual (line 287) | func testResourceEqual(t *testing.T, i int, name string, exp, got DNSRes...
function testDNSEqual (line 396) | func testDNSEqual(t *testing.T, exp, got *DNS) {
function TestDNSEncodeQuery (line 469) | func TestDNSEncodeQuery(t *testing.T) {
function TestDNSEncodeQueryWithOPT (line 500) | func TestDNSEncodeQueryWithOPT(t *testing.T) {
function TestDNSEncodeResponse (line 545) | func TestDNSEncodeResponse(t *testing.T) {
function TestDNSMalformedPacket (line 636) | func TestDNSMalformedPacket(t *testing.T) {
function TestDNSMalformedPacket2 (line 668) | func TestDNSMalformedPacket2(t *testing.T) {
function TestBlankNameRootQuery (line 752) | func TestBlankNameRootQuery(t *testing.T) {
function TestAnotherMalformedDNS (line 950) | func TestAnotherMalformedDNS(t *testing.T) {
function TestMalformedDNSAgain (line 984) | func TestMalformedDNSAgain(t *testing.T) {
function TestMalformedDNSOhGodMakeItStop (line 1016) | func TestMalformedDNSOhGodMakeItStop(t *testing.T) {
function TestMalformedDNSOPT (line 1035) | func TestMalformedDNSOPT(t *testing.T) {
function TestPacketDNSPanic7 (line 1119) | func TestPacketDNSPanic7(t *testing.T) {
function TestDNSPacketWriteAnswer (line 1128) | func TestDNSPacketWriteAnswer(t *testing.T) {
FILE: layers/dot11.go
type Dot11Flags (line 24) | type Dot11Flags
method ToDS (line 37) | func (d Dot11Flags) ToDS() bool {
method FromDS (line 40) | func (d Dot11Flags) FromDS() bool {
method MF (line 43) | func (d Dot11Flags) MF() bool {
method Retry (line 46) | func (d Dot11Flags) Retry() bool {
method PowerManagement (line 49) | func (d Dot11Flags) PowerManagement() bool {
method MD (line 52) | func (d Dot11Flags) MD() bool {
method WEP (line 55) | func (d Dot11Flags) WEP() bool {
method Order (line 58) | func (d Dot11Flags) Order() bool {
method String (line 65) | func (a Dot11Flags) String() string {
constant Dot11FlagsToDS (line 27) | Dot11FlagsToDS Dot11Flags = 1 << iota
constant Dot11FlagsFromDS (line 28) | Dot11FlagsFromDS
constant Dot11FlagsMF (line 29) | Dot11FlagsMF
constant Dot11FlagsRetry (line 30) | Dot11FlagsRetry
constant Dot11FlagsPowerManagement (line 31) | Dot11FlagsPowerManagement
constant Dot11FlagsMD (line 32) | Dot11FlagsMD
constant Dot11FlagsWEP (line 33) | Dot11FlagsWEP
constant Dot11FlagsOrder (line 34) | Dot11FlagsOrder
type Dot11Reason (line 98) | type Dot11Reason
method String (line 118) | func (a Dot11Reason) String() string {
constant Dot11ReasonReserved (line 103) | Dot11ReasonReserved Dot11Reason = 1
constant Dot11ReasonUnspecified (line 104) | Dot11ReasonUnspecified Dot11Reason = 2
constant Dot11ReasonAuthExpired (line 105) | Dot11ReasonAuthExpired Dot11Reason = 3
constant Dot11ReasonDeauthStLeaving (line 106) | Dot11ReasonDeauthStLeaving Dot11Reason = 4
constant Dot11ReasonInactivity (line 107) | Dot11ReasonInactivity Dot11Reason = 5
constant Dot11ReasonApFull (line 108) | Dot11ReasonApFull Dot11Reason = 6
constant Dot11ReasonClass2FromNonAuth (line 109) | Dot11ReasonClass2FromNonAuth Dot11Reason = 7
constant Dot11ReasonClass3FromNonAss (line 110) | Dot11ReasonClass3FromNonAss Dot11Reason = 8
constant Dot11ReasonDisasStLeaving (line 111) | Dot11ReasonDisasStLeaving Dot11Reason = 9
constant Dot11ReasonStNotAuth (line 112) | Dot11ReasonStNotAuth Dot11Reason = 10
type Dot11Status (line 145) | type Dot11Status
method String (line 164) | func (a Dot11Status) String() string {
constant Dot11StatusSuccess (line 148) | Dot11StatusSuccess Dot11Status = 0
constant Dot11StatusFailure (line 149) | Dot11StatusFailure Dot11Status = 1
constant Dot11StatusCannotSupportAllCapabilities (line 150) | Dot11StatusCannotSupportAllCapabilities Dot11Status = 10
constant Dot11StatusInabilityExistsAssociation (line 151) | Dot11StatusInabilityExistsAssociation Dot11Status = 11
constant Dot11StatusAssociationDenied (line 152) | Dot11StatusAssociationDenied Dot11Status = 12
constant Dot11StatusAlgorithmUnsupported (line 153) | Dot11StatusAlgorithmUnsupported Dot11Status = 13
constant Dot11StatusOufOfExpectedSequence (line 154) | Dot11StatusOufOfExpectedSequence Dot11Status = 14
constant Dot11StatusChallengeFailure (line 155) | Dot11StatusChallengeFailure Dot11Status = 15
constant Dot11StatusTimeout (line 156) | Dot11StatusTimeout Dot11Status = 16
constant Dot11StatusAPUnableToHandle (line 157) | Dot11StatusAPUnableToHandle Dot11Status = 17
constant Dot11StatusRateUnsupported (line 158) | Dot11StatusRateUnsupported Dot11Status = 18
type Dot11AckPolicy (line 193) | type Dot11AckPolicy
method String (line 205) | func (a Dot11AckPolicy) String() string {
constant Dot11AckPolicyNormal (line 196) | Dot11AckPolicyNormal Dot11AckPolicy = 0
constant Dot11AckPolicyNone (line 197) | Dot11AckPolicyNone Dot11AckPolicy = 1
constant Dot11AckPolicyNoExplicit (line 198) | Dot11AckPolicyNoExplicit Dot11AckPolicy = 2
constant Dot11AckPolicyBlock (line 199) | Dot11AckPolicyBlock Dot11AckPolicy = 3
type Dot11Algorithm (line 220) | type Dot11Algorithm
method String (line 230) | func (a Dot11Algorithm) String() string {
constant Dot11AlgorithmOpen (line 223) | Dot11AlgorithmOpen Dot11Algorithm = 0
constant Dot11AlgorithmSharedKey (line 224) | Dot11AlgorithmSharedKey Dot11Algorithm = 1
type Dot11InformationElementID (line 241) | type Dot11InformationElementID
method String (line 421) | func (a Dot11InformationElementID) String() string {
constant Dot11InformationElementIDSSID (line 244) | Dot11InformationElementIDSSID Dot11InformationEleme...
constant Dot11InformationElementIDRates (line 245) | Dot11InformationElementIDRates Dot11InformationEleme...
constant Dot11InformationElementIDFHSet (line 246) | Dot11InformationElementIDFHSet Dot11InformationEleme...
constant Dot11InformationElementIDDSSet (line 247) | Dot11InformationElementIDDSSet Dot11InformationEleme...
constant Dot11InformationElementIDCFSet (line 248) | Dot11InformationElementIDCFSet Dot11InformationEleme...
constant Dot11InformationElementIDTIM (line 249) | Dot11InformationElementIDTIM Dot11InformationEleme...
constant Dot11InformationElementIDIBSSSet (line 250) | Dot11InformationElementIDIBSSSet Dot11InformationEleme...
constant Dot11InformationElementIDCountryInfo (line 251) | Dot11InformationElementIDCountryInfo Dot11InformationEleme...
constant Dot11InformationElementIDHoppingPatternParam (line 252) | Dot11InformationElementIDHoppingPatternParam Dot11InformationEleme...
constant Dot11InformationElementIDHoppingPatternTable (line 253) | Dot11InformationElementIDHoppingPatternTable Dot11InformationEleme...
constant Dot11InformationElementIDRequest (line 254) | Dot11InformationElementIDRequest Dot11InformationEleme...
constant Dot11InformationElementIDQBSSLoadElem (line 255) | Dot11InformationElementIDQBSSLoadElem Dot11InformationEleme...
constant Dot11InformationElementIDEDCAParamSet (line 256) | Dot11InformationElementIDEDCAParamSet Dot11InformationEleme...
constant Dot11InformationElementIDTrafficSpec (line 257) | Dot11InformationElementIDTrafficSpec Dot11InformationEleme...
constant Dot11InformationElementIDTrafficClass (line 258) | Dot11InformationElementIDTrafficClass Dot11InformationEleme...
constant Dot11InformationElementIDSchedule (line 259) | Dot11InformationElementIDSchedule Dot11InformationEleme...
constant Dot11InformationElementIDChallenge (line 260) | Dot11InformationElementIDChallenge Dot11InformationEleme...
constant Dot11InformationElementIDPowerConst (line 261) | Dot11InformationElementIDPowerConst Dot11InformationEleme...
constant Dot11InformationElementIDPowerCapability (line 262) | Dot11InformationElementIDPowerCapability Dot11InformationEleme...
constant Dot11InformationElementIDTPCRequest (line 263) | Dot11InformationElementIDTPCRequest Dot11InformationEleme...
constant Dot11InformationElementIDTPCReport (line 264) | Dot11InformationElementIDTPCReport Dot11InformationEleme...
constant Dot11InformationElementIDSupportedChannels (line 265) | Dot11InformationElementIDSupportedChannels Dot11InformationEleme...
constant Dot11InformationElementIDSwitchChannelAnnounce (line 266) | Dot11InformationElementIDSwitchChannelAnnounce Dot11InformationEleme...
constant Dot11InformationElementIDMeasureRequest (line 267) | Dot11InformationElementIDMeasureRequest Dot11InformationEleme...
constant Dot11InformationElementIDMeasureReport (line 268) | Dot11InformationElementIDMeasureReport Dot11InformationEleme...
constant Dot11InformationElementIDQuiet (line 269) | Dot11InformationElementIDQuiet Dot11InformationEleme...
constant Dot11InformationElementIDIBSSDFS (line 270) | Dot11InformationElementIDIBSSDFS Dot11InformationEleme...
constant Dot11InformationElementIDERPInfo (line 271) | Dot11InformationElementIDERPInfo Dot11InformationEleme...
constant Dot11InformationElementIDTSDelay (line 272) | Dot11InformationElementIDTSDelay Dot11InformationEleme...
constant Dot11InformationElementIDTCLASProcessing (line 273) | Dot11InformationElementIDTCLASProcessing Dot11InformationEleme...
constant Dot11InformationElementIDHTCapabilities (line 274) | Dot11InformationElementIDHTCapabilities Dot11InformationEleme...
constant Dot11InformationElementIDQOSCapability (line 275) | Dot11InformationElementIDQOSCapability Dot11InformationEleme...
constant Dot11InformationElementIDERPInfo2 (line 276) | Dot11InformationElementIDERPInfo2 Dot11InformationEleme...
constant Dot11InformationElementIDRSNInfo (line 277) | Dot11InformationElementIDRSNInfo Dot11InformationEleme...
constant Dot11InformationElementIDESRates (line 278) | Dot11InformationElementIDESRates Dot11InformationEleme...
constant Dot11InformationElementIDAPChannelReport (line 279) | Dot11InformationElementIDAPChannelReport Dot11InformationEleme...
constant Dot11InformationElementIDNeighborReport (line 280) | Dot11InformationElementIDNeighborReport Dot11InformationEleme...
constant Dot11InformationElementIDRCPI (line 281) | Dot11InformationElementIDRCPI Dot11InformationEleme...
constant Dot11InformationElementIDMobilityDomain (line 282) | Dot11InformationElementIDMobilityDomain Dot11InformationEleme...
constant Dot11InformationElementIDFastBSSTrans (line 283) | Dot11InformationElementIDFastBSSTrans Dot11InformationEleme...
constant Dot11InformationElementIDTimeoutInt (line 284) | Dot11InformationElementIDTimeoutInt Dot11InformationEleme...
constant Dot11InformationElementIDRICData (line 285) | Dot11InformationElementIDRICData Dot11InformationEleme...
constant Dot11InformationElementIDDSERegisteredLoc (line 286) | Dot11InformationElementIDDSERegisteredLoc Dot11InformationEleme...
constant Dot11InformationElementIDSuppOperatingClass (line 287) | Dot11InformationElementIDSuppOperatingClass Dot11InformationEleme...
constant Dot11InformationElementIDExtChanSwitchAnnounce (line 288) | Dot11InformationElementIDExtChanSwitchAnnounce Dot11InformationEleme...
constant Dot11InformationElementIDHTInfo (line 289) | Dot11InformationElementIDHTInfo Dot11InformationEleme...
constant Dot11InformationElementIDSecChanOffset (line 290) | Dot11InformationElementIDSecChanOffset Dot11InformationEleme...
constant Dot11InformationElementIDBSSAverageAccessDelay (line 291) | Dot11InformationElementIDBSSAverageAccessDelay Dot11InformationEleme...
constant Dot11InformationElementIDAntenna (line 292) | Dot11InformationElementIDAntenna Dot11InformationEleme...
constant Dot11InformationElementIDRSNI (line 293) | Dot11InformationElementIDRSNI Dot11InformationEleme...
constant Dot11InformationElementIDMeasurePilotTrans (line 294) | Dot11InformationElementIDMeasurePilotTrans Dot11InformationEleme...
constant Dot11InformationElementIDBSSAvailAdmCapacity (line 295) | Dot11InformationElementIDBSSAvailAdmCapacity Dot11InformationEleme...
constant Dot11InformationElementIDBSSACAccDelayWAPIParam (line 296) | Dot11InformationElementIDBSSACAccDelayWAPIParam Dot11InformationEleme...
constant Dot11InformationElementIDTimeAdvertisement (line 297) | Dot11InformationElementIDTimeAdvertisement Dot11InformationEleme...
constant Dot11InformationElementIDRMEnabledCapabilities (line 298) | Dot11InformationElementIDRMEnabledCapabilities Dot11InformationEleme...
constant Dot11InformationElementIDMultipleBSSID (line 299) | Dot11InformationElementIDMultipleBSSID Dot11InformationEleme...
constant Dot11InformationElementID2040BSSCoExist (line 300) | Dot11InformationElementID2040BSSCoExist Dot11InformationEleme...
constant Dot11InformationElementID2040BSSIntChanReport (line 301) | Dot11InformationElementID2040BSSIntChanReport Dot11InformationEleme...
constant Dot11InformationElementIDOverlapBSSScanParam (line 302) | Dot11InformationElementIDOverlapBSSScanParam Dot11InformationEleme...
constant Dot11InformationElementIDRICDescriptor (line 303) | Dot11InformationElementIDRICDescriptor Dot11InformationEleme...
constant Dot11InformationElementIDManagementMIC (line 304) | Dot11InformationElementIDManagementMIC Dot11InformationEleme...
constant Dot11InformationElementIDEventRequest (line 305) | Dot11InformationElementIDEventRequest Dot11InformationEleme...
constant Dot11InformationElementIDEventReport (line 306) | Dot11InformationElementIDEventReport Dot11InformationEleme...
constant Dot11InformationElementIDDiagnosticRequest (line 307) | Dot11InformationElementIDDiagnosticRequest Dot11InformationEleme...
constant Dot11InformationElementIDDiagnosticReport (line 308) | Dot11InformationElementIDDiagnosticReport Dot11InformationEleme...
constant Dot11InformationElementIDLocationParam (line 309) | Dot11InformationElementIDLocationParam Dot11InformationEleme...
constant Dot11InformationElementIDNonTransBSSIDCapability (line 310) | Dot11InformationElementIDNonTransBSSIDCapability Dot11InformationEleme...
constant Dot11InformationElementIDSSIDList (line 311) | Dot11InformationElementIDSSIDList Dot11InformationEleme...
constant Dot11InformationElementIDMultipleBSSIDIndex (line 312) | Dot11InformationElementIDMultipleBSSIDIndex Dot11InformationEleme...
constant Dot11InformationElementIDFMSDescriptor (line 313) | Dot11InformationElementIDFMSDescriptor Dot11InformationEleme...
constant Dot11InformationElementIDFMSRequest (line 314) | Dot11InformationElementIDFMSRequest Dot11InformationEleme...
constant Dot11InformationElementIDFMSResponse (line 315) | Dot11InformationElementIDFMSResponse Dot11InformationEleme...
constant Dot11InformationElementIDQOSTrafficCapability (line 316) | Dot11InformationElementIDQOSTrafficCapability Dot11InformationEleme...
constant Dot11InformationElementIDBSSMaxIdlePeriod (line 317) | Dot11InformationElementIDBSSMaxIdlePeriod Dot11InformationEleme...
constant Dot11InformationElementIDTFSRequest (line 318) | Dot11InformationElementIDTFSRequest Dot11InformationEleme...
constant Dot11InformationElementIDTFSResponse (line 319) | Dot11InformationElementIDTFSResponse Dot11InformationEleme...
constant Dot11InformationElementIDWNMSleepMode (line 320) | Dot11InformationElementIDWNMSleepMode Dot11InformationEleme...
constant Dot11InformationElementIDTIMBroadcastRequest (line 321) | Dot11InformationElementIDTIMBroadcastRequest Dot11InformationEleme...
constant Dot11InformationElementIDTIMBroadcastResponse (line 322) | Dot11InformationElementIDTIMBroadcastResponse Dot11InformationEleme...
constant Dot11InformationElementIDCollInterferenceReport (line 323) | Dot11InformationElementIDCollInterferenceReport Dot11InformationEleme...
constant Dot11InformationElementIDChannelUsage (line 324) | Dot11InformationElementIDChannelUsage Dot11InformationEleme...
constant Dot11InformationElementIDTimeZone (line 325) | Dot11InformationElementIDTimeZone Dot11InformationEleme...
constant Dot11InformationElementIDDMSRequest (line 326) | Dot11InformationElementIDDMSRequest Dot11InformationEleme...
constant Dot11InformationElementIDDMSResponse (line 327) | Dot11InformationElementIDDMSResponse Dot11InformationEleme...
constant Dot11InformationElementIDLinkIdentifier (line 328) | Dot11InformationElementIDLinkIdentifier Dot11InformationEleme...
constant Dot11InformationElementIDWakeupSchedule (line 329) | Dot11InformationElementIDWakeupSchedule Dot11InformationEleme...
constant Dot11InformationElementIDChannelSwitchTiming (line 330) | Dot11InformationElementIDChannelSwitchTiming Dot11InformationEleme...
constant Dot11InformationElementIDPTIControl (line 331) | Dot11InformationElementIDPTIControl Dot11InformationEleme...
constant Dot11InformationElementIDPUBufferStatus (line 332) | Dot11InformationElementIDPUBufferStatus Dot11InformationEleme...
constant Dot11InformationElementIDInterworking (line 333) | Dot11InformationElementIDInterworking Dot11InformationEleme...
constant Dot11InformationElementIDAdvertisementProtocol (line 334) | Dot11InformationElementIDAdvertisementProtocol Dot11InformationEleme...
constant Dot11InformationElementIDExpBWRequest (line 335) | Dot11InformationElementIDExpBWRequest Dot11InformationEleme...
constant Dot11InformationElementIDQOSMapSet (line 336) | Dot11InformationElementIDQOSMapSet Dot11InformationEleme...
constant Dot11InformationElementIDRoamingConsortium (line 337) | Dot11InformationElementIDRoamingConsortium Dot11InformationEleme...
constant Dot11InformationElementIDEmergencyAlertIdentifier (line 338) | Dot11InformationElementIDEmergencyAlertIdentifier Dot11InformationEleme...
constant Dot11InformationElementIDMeshConfiguration (line 339) | Dot11InformationElementIDMeshConfiguration Dot11InformationEleme...
constant Dot11InformationElementIDMeshID (line 340) | Dot11InformationElementIDMeshID Dot11InformationEleme...
constant Dot11InformationElementIDMeshLinkMetricReport (line 341) | Dot11InformationElementIDMeshLinkMetricReport Dot11InformationEleme...
constant Dot11InformationElementIDCongestionNotification (line 342) | Dot11InformationElementIDCongestionNotification Dot11InformationEleme...
constant Dot11InformationElementIDMeshPeeringManagement (line 343) | Dot11InformationElementIDMeshPeeringManagement Dot11InformationEleme...
constant Dot11InformationElementIDMeshChannelSwitchParam (line 344) | Dot11InformationElementIDMeshChannelSwitchParam Dot11InformationEleme...
constant Dot11InformationElementIDMeshAwakeWindows (line 345) | Dot11InformationElementIDMeshAwakeWindows Dot11InformationEleme...
constant Dot11InformationElementIDBeaconTiming (line 346) | Dot11InformationElementIDBeaconTiming Dot11InformationEleme...
constant Dot11InformationElementIDMCCAOPSetupRequest (line 347) | Dot11InformationElementIDMCCAOPSetupRequest Dot11InformationEleme...
constant Dot11InformationElementIDMCCAOPSetupReply (line 348) | Dot11InformationElementIDMCCAOPSetupReply Dot11InformationEleme...
constant Dot11InformationElementIDMCCAOPAdvertisement (line 349) | Dot11InformationElementIDMCCAOPAdvertisement Dot11InformationEleme...
constant Dot11InformationElementIDMCCAOPTeardown (line 350) | Dot11InformationElementIDMCCAOPTeardown Dot11InformationEleme...
constant Dot11InformationElementIDGateAnnouncement (line 351) | Dot11InformationElementIDGateAnnouncement Dot11InformationEleme...
constant Dot11InformationElementIDRootAnnouncement (line 352) | Dot11InformationElementIDRootAnnouncement Dot11InformationEleme...
constant Dot11InformationElementIDExtCapability (line 353) | Dot11InformationElementIDExtCapability Dot11InformationEleme...
constant Dot11InformationElementIDAgereProprietary (line 354) | Dot11InformationElementIDAgereProprietary Dot11InformationEleme...
constant Dot11InformationElementIDPathRequest (line 355) | Dot11InformationElementIDPathRequest Dot11InformationEleme...
constant Dot11InformationElementIDPathReply (line 356) | Dot11InformationElementIDPathReply Dot11InformationEleme...
constant Dot11InformationElementIDPathError (line 357) | Dot11InformationElementIDPathError Dot11InformationEleme...
constant Dot11InformationElementIDCiscoCCX1CKIPDeviceName (line 358) | Dot11InformationElementIDCiscoCCX1CKIPDeviceName Dot11InformationEleme...
constant Dot11InformationElementIDCiscoCCX2 (line 359) | Dot11InformationElementIDCiscoCCX2 Dot11InformationEleme...
constant Dot11InformationElementIDProxyUpdate (line 360) | Dot11InformationElementIDProxyUpdate Dot11InformationEleme...
constant Dot11InformationElementIDProxyUpdateConfirmation (line 361) | Dot11InformationElementIDProxyUpdateConfirmation Dot11InformationEleme...
constant Dot11InformationElementIDAuthMeshPerringExch (line 362) | Dot11InformationElementIDAuthMeshPerringExch Dot11InformationEleme...
constant Dot11InformationElementIDMIC (line 363) | Dot11InformationElementIDMIC Dot11InformationEleme...
constant Dot11InformationElementIDDestinationURI (line 364) | Dot11InformationElementIDDestinationURI Dot11InformationEleme...
constant Dot11InformationElementIDUAPSDCoexistence (line 365) | Dot11InformationElementIDUAPSDCoexistence Dot11InformationEleme...
constant Dot11InformationElementIDWakeupSchedule80211ad (line 366) | Dot11InformationElementIDWakeupSchedule80211ad Dot11InformationEleme...
constant Dot11InformationElementIDExtendedSchedule (line 367) | Dot11InformationElementIDExtendedSchedule Dot11InformationEleme...
constant Dot11InformationElementIDSTAAvailability (line 368) | Dot11InformationElementIDSTAAvailability Dot11InformationEleme...
constant Dot11InformationElementIDDMGTSPEC (line 369) | Dot11InformationElementIDDMGTSPEC Dot11InformationEleme...
constant Dot11InformationElementIDNextDMGATI (line 370) | Dot11InformationElementIDNextDMGATI Dot11InformationEleme...
constant Dot11InformationElementIDDMSCapabilities (line 371) | Dot11InformationElementIDDMSCapabilities Dot11InformationEleme...
constant Dot11InformationElementIDCiscoUnknown95 (line 372) | Dot11InformationElementIDCiscoUnknown95 Dot11InformationEleme...
constant Dot11InformationElementIDVendor2 (line 373) | Dot11InformationElementIDVendor2 Dot11InformationEleme...
constant Dot11InformationElementIDDMGOperating (line 374) | Dot11InformationElementIDDMGOperating Dot11InformationEleme...
constant Dot11InformationElementIDDMGBSSParamChange (line 375) | Dot11InformationElementIDDMGBSSParamChange Dot11InformationEleme...
constant Dot11InformationElementIDDMGBeamRefinement (line 376) | Dot11InformationElementIDDMGBeamRefinement Dot11InformationEleme...
constant Dot11InformationElementIDChannelMeasFeedback (line 377) | Dot11InformationElementIDChannelMeasFeedback Dot11InformationEleme...
constant Dot11InformationElementIDAwakeWindow (line 378) | Dot11InformationElementIDAwakeWindow Dot11InformationEleme...
constant Dot11InformationElementIDMultiBand (line 379) | Dot11InformationElementIDMultiBand Dot11InformationEleme...
constant Dot11InformationElementIDADDBAExtension (line 380) | Dot11InformationElementIDADDBAExtension Dot11InformationEleme...
constant Dot11InformationElementIDNEXTPCPList (line 381) | Dot11InformationElementIDNEXTPCPList Dot11InformationEleme...
constant Dot11InformationElementIDPCPHandover (line 382) | Dot11InformationElementIDPCPHandover Dot11InformationEleme...
constant Dot11InformationElementIDDMGLinkMargin (line 383) | Dot11InformationElementIDDMGLinkMargin Dot11InformationEleme...
constant Dot11InformationElementIDSwitchingStream (line 384) | Dot11InformationElementIDSwitchingStream Dot11InformationEleme...
constant Dot11InformationElementIDSessionTransmission (line 385) | Dot11InformationElementIDSessionTransmission Dot11InformationEleme...
constant Dot11InformationElementIDDynamicTonePairReport (line 386) | Dot11InformationElementIDDynamicTonePairReport Dot11InformationEleme...
constant Dot11InformationElementIDClusterReport (line 387) | Dot11InformationElementIDClusterReport Dot11InformationEleme...
constant Dot11InformationElementIDRelayCapabilities (line 388) | Dot11InformationElementIDRelayCapabilities Dot11InformationEleme...
constant Dot11InformationElementIDRelayTransferParameter (line 389) | Dot11InformationElementIDRelayTransferParameter Dot11InformationEleme...
constant Dot11InformationElementIDBeamlinkMaintenance (line 390) | Dot11InformationElementIDBeamlinkMaintenance Dot11InformationEleme...
constant Dot11InformationElementIDMultipleMacSublayers (line 391) | Dot11InformationElementIDMultipleMacSublayers Dot11InformationEleme...
constant Dot11InformationElementIDUPID (line 392) | Dot11InformationElementIDUPID Dot11InformationEleme...
constant Dot11InformationElementIDDMGLinkAdaptionAck (line 393) | Dot11InformationElementIDDMGLinkAdaptionAck Dot11InformationEleme...
constant Dot11InformationElementIDSymbolProprietary (line 394) | Dot11InformationElementIDSymbolProprietary Dot11InformationEleme...
constant Dot11InformationElementIDMCCAOPAdvertOverview (line 395) | Dot11InformationElementIDMCCAOPAdvertOverview Dot11InformationEleme...
constant Dot11InformationElementIDQuietPeriodRequest (line 396) | Dot11InformationElementIDQuietPeriodRequest Dot11InformationEleme...
constant Dot11InformationElementIDQuietPeriodResponse (line 397) | Dot11InformationElementIDQuietPeriodResponse Dot11InformationEleme...
constant Dot11InformationElementIDECPACPolicy (line 398) | Dot11InformationElementIDECPACPolicy Dot11InformationEleme...
constant Dot11InformationElementIDClusterTimeOffset (line 399) | Dot11InformationElementIDClusterTimeOffset Dot11InformationEleme...
constant Dot11InformationElementIDAntennaSectorID (line 400) | Dot11InformationElementIDAntennaSectorID Dot11InformationEleme...
constant Dot11InformationElementIDVHTCapabilities (line 401) | Dot11InformationElementIDVHTCapabilities Dot11InformationEleme...
constant Dot11InformationElementIDVHTOperation (line 402) | Dot11InformationElementIDVHTOperation Dot11InformationEleme...
constant Dot11InformationElementIDExtendedBSSLoad (line 403) | Dot11InformationElementIDExtendedBSSLoad Dot11InformationEleme...
constant Dot11InformationElementIDWideBWChannelSwitch (line 404) | Dot11InformationElementIDWideBWChannelSwitch Dot11InformationEleme...
constant Dot11InformationElementIDVHTTxPowerEnvelope (line 405) | Dot11InformationElementIDVHTTxPowerEnvelope Dot11InformationEleme...
constant Dot11InformationElementIDChannelSwitchWrapper (line 406) | Dot11InformationElementIDChannelSwitchWrapper Dot11InformationEleme...
constant Dot11InformationElementIDOperatingModeNotification (line 407) | Dot11InformationElementIDOperatingModeNotification Dot11InformationEleme...
constant Dot11InformationElementIDUPSIM (line 408) | Dot11InformationElementIDUPSIM Dot11InformationEleme...
constant Dot11InformationElementIDReducedNeighborReport (line 409) | Dot11InformationElementIDReducedNeighborReport Dot11InformationEleme...
constant Dot11InformationElementIDTVHTOperation (line 410) | Dot11InformationElementIDTVHTOperation Dot11InformationEleme...
constant Dot11InformationElementIDDeviceLocation (line 411) | Dot11InformationElementIDDeviceLocation Dot11InformationEleme...
constant Dot11InformationElementIDWhiteSpaceMap (line 412) | Dot11InformationElementIDWhiteSpaceMap Dot11InformationEleme...
constant Dot11InformationElementIDFineTuningMeasureParams (line 413) | Dot11InformationElementIDFineTuningMeasureParams Dot11InformationEleme...
constant Dot11InformationElementIDVendor (line 414) | Dot11InformationElementIDVendor Dot11InformationEleme...
type Dot11 (line 773) | type Dot11 struct
method LayerType (line 884) | func (m *Dot11) LayerType() gopacket.LayerType { return LayerTypeDot11 }
method CanDecode (line 885) | func (m *Dot11) CanDecode() gopacket.LayerClass { return LayerTypeDot11 }
method NextLayerType (line 886) | func (m *Dot11) NextLayerType() gopacket.LayerType {
method DecodeFromBytes (line 918) | func (m *Dot11) DecodeFromBytes(data []byte, df gopacket.DecodeFeedbac...
method ChecksumValid (line 1084) | func (m *Dot11) ChecksumValid() bool {
method SerializeTo (line 1092) | func (m Dot11) SerializeTo(b gopacket.SerializeBuffer, opts gopacket.S...
type Dot11QOS (line 791) | type Dot11QOS struct
type Dot11HTControl (line 798) | type Dot11HTControl struct
type Dot11HTControlHT (line 806) | type Dot11HTControlHT struct
type Dot11HTControlVHT (line 815) | type Dot11HTControlVHT struct
type Dot11HTControlMFB (line 828) | type Dot11HTControlMFB struct
method NoFeedBackPresent (line 867) | func (m *Dot11HTControlMFB) NoFeedBackPresent() bool {
type Dot11LinkAdapationControl (line 835) | type Dot11LinkAdapationControl struct
type Dot11ASEL (line 844) | type Dot11ASEL struct
type Dot11CodingType (line 849) | type Dot11CodingType
method String (line 856) | func (a Dot11CodingType) String() string {
constant Dot11CodingTypeBCC (line 852) | Dot11CodingTypeBCC = 0
constant Dot11CodingTypeLDPC (line 853) | Dot11CodingTypeLDPC = 1
function decodeDot11 (line 871) | func decodeDot11(data []byte, p gopacket.PacketBuilder) error {
function createU8 (line 896) | func createU8(x uint8) *uint8 {
type Dot11Mgmt (line 1134) | type Dot11Mgmt struct
method NextLayerType (line 1138) | func (m *Dot11Mgmt) NextLayerType() gopacket.LayerType { return gopack...
method DecodeFromBytes (line 1139) | func (m *Dot11Mgmt) DecodeFromBytes(data []byte, df gopacket.DecodeFee...
type Dot11Ctrl (line 1145) | type Dot11Ctrl struct
method NextLayerType (line 1149) | func (m *Dot11Ctrl) NextLayerType() gopacket.LayerType { return gopack...
method LayerType (line 1151) | func (m *Dot11Ctrl) LayerType() gopacket.LayerType { return LayerType...
method CanDecode (line 1152) | func (m *Dot11Ctrl) CanDecode() gopacket.LayerClass { return LayerType...
method DecodeFromBytes (line 1153) | func (m *Dot11Ctrl) DecodeFromBytes(data []byte, df gopacket.DecodeFee...
function decodeDot11Ctrl (line 1158) | func decodeDot11Ctrl(data []byte, p gopacket.PacketBuilder) error {
type Dot11WEP (line 1164) | type Dot11WEP struct
method NextLayerType (line 1168) | func (m *Dot11WEP) NextLayerType() gopacket.LayerType { return gopacke...
method LayerType (line 1170) | func (m *Dot11WEP) LayerType() gopacket.LayerType { return LayerTypeD...
method CanDecode (line 1171) | func (m *Dot11WEP) CanDecode() gopacket.LayerClass { return LayerTypeD...
method DecodeFromBytes (line 1172) | func (m *Dot11WEP) DecodeFromBytes(data []byte, df gopacket.DecodeFeed...
function decodeDot11WEP (line 1177) | func decodeDot11WEP(data []byte, p gopacket.PacketBuilder) error {
type Dot11Data (line 1183) | type Dot11Data struct
method NextLayerType (line 1187) | func (m *Dot11Data) NextLayerType() gopacket.LayerType {
method LayerType (line 1191) | func (m *Dot11Data) LayerType() gopacket.LayerType { return LayerType...
method CanDecode (line 1192) | func (m *Dot11Data) CanDecode() gopacket.LayerClass { return LayerType...
method DecodeFromBytes (line 1193) | func (m *Dot11Data) DecodeFromBytes(data []byte, df gopacket.DecodeFee...
function decodeDot11Data (line 1198) | func decodeDot11Data(data []byte, p gopacket.PacketBuilder) error {
type Dot11DataCFAck (line 1203) | type Dot11DataCFAck struct
method LayerType (line 1212) | func (m *Dot11DataCFAck) LayerType() gopacket.LayerType { return Laye...
method CanDecode (line 1213) | func (m *Dot11DataCFAck) CanDecode() gopacket.LayerClass { return Laye...
method DecodeFromBytes (line 1214) | func (m *Dot11DataCFAck) DecodeFromBytes(data []byte, df gopacket.Deco...
function decodeDot11DataCFAck (line 1207) | func decodeDot11DataCFAck(data []byte, p gopacket.PacketBuilder) error {
type Dot11DataCFPoll (line 1218) | type Dot11DataCFPoll struct
method LayerType (line 1227) | func (m *Dot11DataCFPoll) LayerType() gopacket.LayerType { return Lay...
method CanDecode (line 1228) | func (m *Dot11DataCFPoll) CanDecode() gopacket.LayerClass { return Lay...
method DecodeFromBytes (line 1229) | func (m *Dot11DataCFPoll) DecodeFromBytes(data []byte, df gopacket.Dec...
function decodeDot11DataCFPoll (line 1222) | func decodeDot11DataCFPoll(data []byte, p gopacket.PacketBuilder) error {
type Dot11DataCFAckPoll (line 1233) | type Dot11DataCFAckPoll struct
method LayerType (line 1242) | func (m *Dot11DataCFAckPoll) LayerType() gopacket.LayerType { return ...
method CanDecode (line 1243) | func (m *Dot11DataCFAckPoll) CanDecode() gopacket.LayerClass { return ...
method DecodeFromBytes (line 1244) | func (m *Dot11DataCFAckPoll) DecodeFromBytes(data []byte, df gopacket....
function decodeDot11DataCFAckPoll (line 1237) | func decodeDot11DataCFAckPoll(data []byte, p gopacket.PacketBuilder) err...
type Dot11DataNull (line 1248) | type Dot11DataNull struct
method LayerType (line 1257) | func (m *Dot11DataNull) LayerType() gopacket.LayerType { return Layer...
method CanDecode (line 1258) | func (m *Dot11DataNull) CanDecode() gopacket.LayerClass { return Layer...
method DecodeFromBytes (line 1259) | func (m *Dot11DataNull) DecodeFromBytes(data []byte, df gopacket.Decod...
function decodeDot11DataNull (line 1252) | func decodeDot11DataNull(data []byte, p gopacket.PacketBuilder) error {
type Dot11DataCFAckNoData (line 1263) | type Dot11DataCFAckNoData struct
method LayerType (line 1272) | func (m *Dot11DataCFAckNoData) LayerType() gopacket.LayerType { retur...
method CanDecode (line 1273) | func (m *Dot11DataCFAckNoData) CanDecode() gopacket.LayerClass { retur...
method DecodeFromBytes (line 1274) | func (m *Dot11DataCFAckNoData) DecodeFromBytes(data []byte, df gopacke...
function decodeDot11DataCFAckNoData (line 1267) | func decodeDot11DataCFAckNoData(data []byte, p gopacket.PacketBuilder) e...
type Dot11DataCFPollNoData (line 1278) | type Dot11DataCFPollNoData struct
method LayerType (line 1287) | func (m *Dot11DataCFPollNoData) LayerType() gopacket.LayerType { retur...
method CanDecode (line 1288) | func (m *Dot11DataCFPollNoData) CanDecode() gopacket.LayerClass {
method DecodeFromBytes (line 1291) | func (m *Dot11DataCFPollNoData) DecodeFromBytes(data []byte, df gopack...
function decodeDot11DataCFPollNoData (line 1282) | func decodeDot11DataCFPollNoData(data []byte, p gopacket.PacketBuilder) ...
type Dot11DataCFAckPollNoData (line 1295) | type Dot11DataCFAckPollNoData struct
method LayerType (line 1304) | func (m *Dot11DataCFAckPollNoData) LayerType() gopacket.LayerType {
method CanDecode (line 1307) | func (m *Dot11DataCFAckPollNoData) CanDecode() gopacket.LayerClass {
method DecodeFromBytes (line 1310) | func (m *Dot11DataCFAckPollNoData) DecodeFromBytes(data []byte, df gop...
function decodeDot11DataCFAckPollNoData (line 1299) | func decodeDot11DataCFAckPollNoData(data []byte, p gopacket.PacketBuilde...
type Dot11DataQOS (line 1314) | type Dot11DataQOS struct
method DecodeFromBytes (line 1318) | func (m *Dot11DataQOS) DecodeFromBytes(data []byte, df gopacket.Decode...
type Dot11DataQOSData (line 1323) | type Dot11DataQOSData struct
method LayerType (line 1332) | func (m *Dot11DataQOSData) LayerType() gopacket.LayerType { return La...
method CanDecode (line 1333) | func (m *Dot11DataQOSData) CanDecode() gopacket.LayerClass { return La...
method NextLayerType (line 1335) | func (m *Dot11DataQOSData) NextLayerType() gopacket.LayerType {
function decodeDot11DataQOSData (line 1327) | func decodeDot11DataQOSData(data []byte, p gopacket.PacketBuilder) error {
type Dot11DataQOSDataCFAck (line 1339) | type Dot11DataQOSDataCFAck struct
method LayerType (line 1348) | func (m *Dot11DataQOSDataCFAck) LayerType() gopacket.LayerType { retur...
method CanDecode (line 1349) | func (m *Dot11DataQOSDataCFAck) CanDecode() gopacket.LayerClass {
method NextLayerType (line 1352) | func (m *Dot11DataQOSDataCFAck) NextLayerType() gopacket.LayerType { r...
function decodeDot11DataQOSDataCFAck (line 1343) | func decodeDot11DataQOSDataCFAck(data []byte, p gopacket.PacketBuilder) ...
type Dot11DataQOSDataCFPoll (line 1354) | type Dot11DataQOSDataCFPoll struct
method LayerType (line 1363) | func (m *Dot11DataQOSDataCFPoll) LayerType() gopacket.LayerType {
method CanDecode (line 1366) | func (m *Dot11DataQOSDataCFPoll) CanDecode() gopacket.LayerClass {
method NextLayerType (line 1369) | func (m *Dot11DataQOSDataCFPoll) NextLayerType() gopacket.LayerType { ...
function decodeDot11DataQOSDataCFPoll (line 1358) | func decodeDot11DataQOSDataCFPoll(data []byte, p gopacket.PacketBuilder)...
type Dot11DataQOSDataCFAckPoll (line 1371) | type Dot11DataQOSDataCFAckPoll struct
method LayerType (line 1380) | func (m *Dot11DataQOSDataCFAckPoll) LayerType() gopacket.LayerType {
method CanDecode (line 1383) | func (m *Dot11DataQOSDataCFAckPoll) CanDecode() gopacket.LayerClass {
method NextLayerType (line 1386) | func (m *Dot11DataQOSDataCFAckPoll) NextLayerType() gopacket.LayerType {
function decodeDot11DataQOSDataCFAckPoll (line 1375) | func decodeDot11DataQOSDataCFAckPoll(data []byte, p gopacket.PacketBuild...
type Dot11DataQOSNull (line 1390) | type Dot11DataQOSNull struct
method LayerType (line 1399) | func (m *Dot11DataQOSNull) LayerType() gopacket.LayerType { return...
method CanDecode (line 1400) | func (m *Dot11DataQOSNull) CanDecode() gopacket.LayerClass { return...
method NextLayerType (line 1401) | func (m *Dot11DataQOSNull) NextLayerType() gopacket.LayerType { return...
function decodeDot11DataQOSNull (line 1394) | func decodeDot11DataQOSNull(data []byte, p gopacket.PacketBuilder) error {
type Dot11DataQOSCFPollNoData (line 1403) | type Dot11DataQOSCFPollNoData struct
method LayerType (line 1412) | func (m *Dot11DataQOSCFPollNoData) LayerType() gopacket.LayerType {
method CanDecode (line 1415) | func (m *Dot11DataQOSCFPollNoData) CanDecode() gopacket.LayerClass {
method NextLayerType (line 1418) | func (m *Dot11DataQOSCFPollNoData) NextLayerType() gopacket.LayerType {
function decodeDot11DataQOSCFPollNoData (line 1407) | func decodeDot11DataQOSCFPollNoData(data []byte, p gopacket.PacketBuilde...
type Dot11DataQOSCFAckPollNoData (line 1422) | type Dot11DataQOSCFAckPollNoData struct
method LayerType (line 1431) | func (m *Dot11DataQOSCFAckPollNoData) LayerType() gopacket.LayerType {
method CanDecode (line 1434) | func (m *Dot11DataQOSCFAckPollNoData) CanDecode() gopacket.LayerClass {
method NextLayerType (line 1437) | func (m *Dot11DataQOSCFAckPollNoData) NextLayerType() gopacket.LayerTy...
function decodeDot11DataQOSCFAckPollNoData (line 1426) | func decodeDot11DataQOSCFAckPollNoData(data []byte, p gopacket.PacketBui...
type Dot11InformationElement (line 1441) | type Dot11InformationElement struct
method LayerType (line 1449) | func (m *Dot11InformationElement) LayerType() gopacket.LayerType {
method CanDecode (line 1452) | func (m *Dot11InformationElement) CanDecode() gopacket.LayerClass {
method NextLayerType (line 1456) | func (m *Dot11InformationElement) NextLayerType() gopacket.LayerType {
method DecodeFromBytes (line 1460) | func (m *Dot11InformationElement) DecodeFromBytes(data []byte, df gopa...
method String (line 1491) | func (d *Dot11InformationElement) String() string {
method SerializeTo (line 1511) | func (m Dot11InformationElement) SerializeTo(b gopacket.SerializeBuffe...
function decodeDot11InformationElement (line 1524) | func decodeDot11InformationElement(data []byte, p gopacket.PacketBuilder...
type Dot11CtrlCTS (line 1529) | type Dot11CtrlCTS struct
method LayerType (line 1538) | func (m *Dot11CtrlCTS) LayerType() gopacket.LayerType {
method CanDecode (line 1541) | func (m *Dot11CtrlCTS) CanDecode() gopacket.LayerClass {
method DecodeFromBytes (line 1544) | func (m *Dot11CtrlCTS) DecodeFromBytes(data []byte, df gopacket.Decode...
function decodeDot11CtrlCTS (line 1533) | func decodeDot11CtrlCTS(data []byte, p gopacket.PacketBuilder) error {
type Dot11CtrlRTS (line 1548) | type Dot11CtrlRTS struct
method LayerType (line 1557) | func (m *Dot11CtrlRTS) LayerType() gopacket.LayerType {
method CanDecode (line 1560) | func (m *Dot11CtrlRTS) CanDecode() gopacket.LayerClass {
method DecodeFromBytes (line 1563) | func (m *Dot11CtrlRTS) DecodeFromBytes(data []byte, df gopacket.Decode...
function decodeDot11CtrlRTS (line 1552) | func decodeDot11CtrlRTS(data []byte, p gopacket.PacketBuilder) error {
type Dot11CtrlBlockAckReq (line 1567) | type Dot11CtrlBlockAckReq struct
method LayerType (line 1576) | func (m *Dot11CtrlBlockAckReq) LayerType() gopacket.LayerType {
method CanDecode (line 1579) | func (m *Dot11CtrlBlockAckReq) CanDecode() gopacket.LayerClass {
method DecodeFromBytes (line 1582) | func (m *Dot11CtrlBlockAckReq) DecodeFromBytes(data []byte, df gopacke...
function decodeDot11CtrlBlockAckReq (line 1571) | func decodeDot11CtrlBlockAckReq(data []byte, p gopacket.PacketBuilder) e...
type Dot11CtrlBlockAck (line 1586) | type Dot11CtrlBlockAck struct
method LayerType (line 1595) | func (m *Dot11CtrlBlockAck) LayerType() gopacket.LayerType { return L...
method CanDecode (line 1596) | func (m *Dot11CtrlBlockAck) CanDecode() gopacket.LayerClass { return L...
method DecodeFromBytes (line 1597) | func (m *Dot11CtrlBlockAck) DecodeFromBytes(data []byte, df gopacket.D...
function decodeDot11CtrlBlockAck (line 1590) | func decodeDot11CtrlBlockAck(data []byte, p gopacket.PacketBuilder) error {
type Dot11CtrlPowersavePoll (line 1601) | type Dot11CtrlPowersavePoll struct
method LayerType (line 1610) | func (m *Dot11CtrlPowersavePoll) LayerType() gopacket.LayerType {
method CanDecode (line 1613) | func (m *Dot11CtrlPowersavePoll) CanDecode() gopacket.LayerClass {
method DecodeFromBytes (line 1616) | func (m *Dot11CtrlPowersavePoll) DecodeFromBytes(data []byte, df gopac...
function decodeDot11CtrlPowersavePoll (line 1605) | func decodeDot11CtrlPowersavePoll(data []byte, p gopacket.PacketBuilder)...
type Dot11CtrlAck (line 1620) | type Dot11CtrlAck struct
method LayerType (line 1629) | func (m *Dot11CtrlAck) LayerType() gopacket.LayerType { return LayerT...
method CanDecode (line 1630) | func (m *Dot11CtrlAck) CanDecode() gopacket.LayerClass { return LayerT...
method DecodeFromBytes (line 1631) | func (m *Dot11CtrlAck) DecodeFromBytes(data []byte, df gopacket.Decode...
function decodeDot11CtrlAck (line 1624) | func decodeDot11CtrlAck(data []byte, p gopacket.PacketBuilder) error {
type Dot11CtrlCFEnd (line 1635) | type Dot11CtrlCFEnd struct
method LayerType (line 1644) | func (m *Dot11CtrlCFEnd) LayerType() gopacket.LayerType {
method CanDecode (line 1647) | func (m *Dot11CtrlCFEnd) CanDecode() gopacket.LayerClass {
method DecodeFromBytes (line 1650) | func (m *Dot11CtrlCFEnd) DecodeFromBytes(data []byte, df gopacket.Deco...
function decodeDot11CtrlCFEnd (line 1639) | func decodeDot11CtrlCFEnd(data []byte, p gopacket.PacketBuilder) error {
type Dot11CtrlCFEndAck (line 1654) | type Dot11CtrlCFEndAck struct
method LayerType (line 1663) | func (m *Dot11CtrlCFEndAck) LayerType() gopacket.LayerType {
method CanDecode (line 1666) | func (m *Dot11CtrlCFEndAck) CanDecode() gopacket.LayerClass {
method DecodeFromBytes (line 1669) | func (m *Dot11CtrlCFEndAck) DecodeFromBytes(data []byte, df gopacket.D...
function decodeDot11CtrlCFEndAck (line 1658) | func decodeDot11CtrlCFEndAck(data []byte, p gopacket.PacketBuilder) error {
type Dot11MgmtAssociationReq (line 1673) | type Dot11MgmtAssociationReq struct
method LayerType (line 1684) | func (m *Dot11MgmtAssociationReq) LayerType() gopacket.LayerType {
method CanDecode (line 1687) | func (m *Dot11MgmtAssociationReq) CanDecode() gopacket.LayerClass {
method NextLayerType (line 1690) | func (m *Dot11MgmtAssociationReq) NextLayerType() gopacket.LayerType {
method DecodeFromBytes (line 1693) | func (m *Dot11MgmtAssociationReq) DecodeFromBytes(data []byte, df gopa...
method SerializeTo (line 1704) | func (m Dot11MgmtAssociationReq) SerializeTo(b gopacket.SerializeBuffe...
function decodeDot11MgmtAssociationReq (line 1679) | func decodeDot11MgmtAssociationReq(data []byte, p gopacket.PacketBuilder...
type Dot11MgmtAssociationResp (line 1717) | type Dot11MgmtAssociationResp struct
method CanDecode (line 1729) | func (m *Dot11MgmtAssociationResp) CanDecode() gopacket.LayerClass {
method LayerType (line 1732) | func (m *Dot11MgmtAssociationResp) LayerType() gopacket.LayerType {
method NextLayerType (line 1735) | func (m *Dot11MgmtAssociationResp) NextLayerType() gopacket.LayerType {
method DecodeFromBytes (line 1738) | func (m *Dot11MgmtAssociationResp) DecodeFromBytes(data []byte, df gop...
method SerializeTo (line 1750) | func (m Dot11MgmtAssociationResp) SerializeTo(b gopacket.SerializeBuff...
function decodeDot11MgmtAssociationResp (line 1724) | func decodeDot11MgmtAssociationResp(data []byte, p gopacket.PacketBuilde...
type Dot11MgmtReassociationReq (line 1764) | type Dot11MgmtReassociationReq struct
method LayerType (line 1776) | func (m *Dot11MgmtReassociationReq) LayerType() gopacket.LayerType {
method CanDecode (line 1779) | func (m *Dot11MgmtReassociationReq) CanDecode() gopacket.LayerClass {
method NextLayerType (line 1782) | func (m *Dot11MgmtReassociationReq) NextLayerType() gopacket.LayerType {
method DecodeFromBytes (line 1785) | func (m *Dot11MgmtReassociationReq) DecodeFromBytes(data []byte, df go...
method SerializeTo (line 1797) | func (m Dot11MgmtReassociationReq) SerializeTo(b gopacket.SerializeBuf...
function decodeDot11MgmtReassociationReq (line 1771) | func decodeDot11MgmtReassociationReq(data []byte, p gopacket.PacketBuild...
type Dot11MgmtReassociationResp (line 1812) | type Dot11MgmtReassociationResp struct
method LayerType (line 1821) | func (m *Dot11MgmtReassociationResp) LayerType() gopacket.LayerType {
method CanDecode (line 1824) | func (m *Dot11MgmtReassociationResp) CanDecode() gopacket.LayerClass {
method NextLayerType (line 1827) | func (m *Dot11MgmtReassociationResp) NextLayerType() gopacket.LayerType {
function decodeDot11MgmtReassociationResp (line 1816) | func decodeDot11MgmtReassociationResp(data []byte, p gopacket.PacketBuil...
type Dot11MgmtProbeReq (line 1831) | type Dot11MgmtProbeReq struct
method LayerType (line 1840) | func (m *Dot11MgmtProbeReq) LayerType() gopacket.LayerType { return L...
method CanDecode (line 1841) | func (m *Dot11MgmtProbeReq) CanDecode() gopacket.LayerClass { return L...
method NextLayerType (line 1842) | func (m *Dot11MgmtProbeReq) NextLayerType() gopacket.LayerType {
function decodeDot11MgmtProbeReq (line 1835) | func decodeDot11MgmtProbeReq(data []byte, p gopacket.PacketBuilder) error {
type Dot11MgmtProbeResp (line 1846) | type Dot11MgmtProbeResp struct
method LayerType (line 1858) | func (m *Dot11MgmtProbeResp) LayerType() gopacket.LayerType { return ...
method CanDecode (line 1859) | func (m *Dot11MgmtProbeResp) CanDecode() gopacket.LayerClass { return ...
method DecodeFromBytes (line 1860) | func (m *Dot11MgmtProbeResp) DecodeFromBytes(data []byte, df gopacket....
method NextLayerType (line 1875) | func (m *Dot11MgmtProbeResp) NextLayerType() gopacket.LayerType {
method SerializeTo (line 1879) | func (m Dot11MgmtProbeResp) SerializeTo(b gopacket.SerializeBuffer, op...
function decodeDot11MgmtProbeResp (line 1853) | func decodeDot11MgmtProbeResp(data []byte, p gopacket.PacketBuilder) err...
type Dot11MgmtMeasurementPilot (line 1893) | type Dot11MgmtMeasurementPilot struct
method LayerType (line 1902) | func (m *Dot11MgmtMeasurementPilot) LayerType() gopacket.LayerType {
method CanDecode (line 1905) | func (m *Dot11MgmtMeasurementPilot) CanDecode() gopacket.LayerClass {
function decodeDot11MgmtMeasurementPilot (line 1897) | func decodeDot11MgmtMeasurementPilot(data []byte, p gopacket.PacketBuild...
type Dot11MgmtBeacon (line 1909) | type Dot11MgmtBeacon struct
method LayerType (line 1921) | func (m *Dot11MgmtBeacon) LayerType() gopacket.LayerType { return Lay...
method CanDecode (line 1922) | func (m *Dot11MgmtBeacon) CanDecode() gopacket.LayerClass { return Lay...
method DecodeFromBytes (line 1923) | func (m *Dot11MgmtBeacon) DecodeFromBytes(data []byte, df gopacket.Dec...
method NextLayerType (line 1935) | func (m *Dot11MgmtBeacon) NextLayerType() gopacket.LayerType { return ...
method SerializeTo (line 1937) | func (m Dot11MgmtBeacon) SerializeTo(b gopacket.SerializeBuffer, opts ...
function decodeDot11MgmtBeacon (line 1916) | func decodeDot11MgmtBeacon(data []byte, p gopacket.PacketBuilder) error {
type Dot11MgmtATIM (line 1951) | type Dot11MgmtATIM struct
method LayerType (line 1960) | func (m *Dot11MgmtATIM) LayerType() gopacket.LayerType { return Layer...
method CanDecode (line 1961) | func (m *Dot11MgmtATIM) CanDecode() gopacket.LayerClass { return Layer...
function decodeDot11MgmtATIM (line 1955) | func decodeDot11MgmtATIM(data []byte, p gopacket.PacketBuilder) error {
type Dot11MgmtDisassociation (line 1963) | type Dot11MgmtDisassociation struct
method LayerType (line 1973) | func (m *Dot11MgmtDisassociation) LayerType() gopacket.LayerType {
method CanDecode (line 1976) | func (m *Dot11MgmtDisassociation) CanDecode() gopacket.LayerClass {
method DecodeFromBytes (line 1979) | func (m *Dot11MgmtDisassociation) DecodeFromBytes(data []byte, df gopa...
method SerializeTo (line 1988) | func (m Dot11MgmtDisassociation) SerializeTo(b gopacket.SerializeBuffe...
function decodeDot11MgmtDisassociation (line 1968) | func decodeDot11MgmtDisassociation(data []byte, p gopacket.PacketBuilder...
type Dot11MgmtAuthentication (line 2000) | type Dot11MgmtAuthentication struct
method LayerType (line 2012) | func (m *Dot11MgmtAuthentication) LayerType() gopacket.LayerType {
method CanDecode (line 2015) | func (m *Dot11MgmtAuthentication) CanDecode() gopacket.LayerClass {
method NextLayerType (line 2018) | func (m *Dot11MgmtAuthentication) NextLayerType() gopacket.LayerType {
method DecodeFromBytes (line 2021) | func (m *Dot11MgmtAuthentication) DecodeFromBytes(data []byte, df gopa...
method SerializeTo (line 2033) | func (m Dot11MgmtAuthentication) SerializeTo(b gopacket.SerializeBuffe...
function decodeDot11MgmtAuthentication (line 2007) | func decodeDot11MgmtAuthentication(data []byte, p gopacket.PacketBuilder...
type Dot11MgmtDeauthentication (line 2047) | type Dot11MgmtDeauthentication struct
method LayerType (line 2057) | func (m *Dot11MgmtDeauthentication) LayerType() gopacket.LayerType {
method CanDecode (line 2060) | func (m *Dot11MgmtDeauthentication) CanDecode() gopacket.LayerClass {
method DecodeFromBytes (line 2063) | func (m *Dot11MgmtDeauthentication) DecodeFromBytes(data []byte, df go...
method SerializeTo (line 2072) | func (m Dot11MgmtDeauthentication) SerializeTo(b gopacket.SerializeBuf...
function decodeDot11MgmtDeauthentication (line 2052) | func decodeDot11MgmtDeauthentication(data []byte, p gopacket.PacketBuild...
type Dot11MgmtAction (line 2084) | type Dot11MgmtAction struct
method LayerType (line 2093) | func (m *Dot11MgmtAction) LayerType() gopacket.LayerType { return Lay...
method CanDecode (line 2094) | func (m *Dot11MgmtAction) CanDecode() gopacket.LayerClass { return Lay...
function decodeDot11MgmtAction (line 2088) | func decodeDot11MgmtAction(data []byte, p gopacket.PacketBuilder) error {
type Dot11MgmtActionNoAck (line 2096) | type Dot11MgmtActionNoAck struct
method LayerType (line 2105) | func (m *Dot11MgmtActionNoAck) LayerType() gopacket.LayerType { retur...
method CanDecode (line 2106) | func (m *Dot11MgmtActionNoAck) CanDecode() gopacket.LayerClass { retur...
function decodeDot11MgmtActionNoAck (line 2100) | func decodeDot11MgmtActionNoAck(data []byte, p gopacket.PacketBuilder) e...
type Dot11MgmtArubaWLAN (line 2108) | type Dot11MgmtArubaWLAN struct
method LayerType (line 2117) | func (m *Dot11MgmtArubaWLAN) LayerType() gopacket.LayerType { return ...
method CanDecode (line 2118) | func (m *Dot11MgmtArubaWLAN) CanDecode() gopacket.LayerClass { return ...
function decodeDot11MgmtArubaWLAN (line 2112) | func decodeDot11MgmtArubaWLAN(data []byte, p gopacket.PacketBuilder) err...
FILE: layers/dot11_test.go
function TestPacketDot11CtrlCTS (line 33) | func TestPacketDot11CtrlCTS(t *testing.T) {
function BenchmarkDecodePacketDot11CtrlCTS (line 98) | func BenchmarkDecodePacketDot11CtrlCTS(b *testing.B) {
function TestPacketDot11MgmtBeacon (line 139) | func TestPacketDot11MgmtBeacon(t *testing.T) {
function BenchmarkDecodePacketDot11MgmtBeacon (line 161) | func BenchmarkDecodePacketDot11MgmtBeacon(b *testing.B) {
function TestPacketDot11DataQOSData (line 184) | func TestPacketDot11DataQOSData(t *testing.T) {
function BenchmarkDecodePacketDot11DataQOSData (line 212) | func BenchmarkDecodePacketDot11DataQOSData(b *testing.B) {
function TestPacketDot11MgmtAction (line 231) | func TestPacketDot11MgmtAction(t *testing.T) {
function BenchmarkDecodePacketDot11MgmtAction (line 249) | func BenchmarkDecodePacketDot11MgmtAction(b *testing.B) {
function TestPacketDot11CtrlAck (line 266) | func TestPacketDot11CtrlAck(t *testing.T) {
function BenchmarkDecodePacketDot11CtrlAck (line 303) | func BenchmarkDecodePacketDot11CtrlAck(b *testing.B) {
function TestPacketDot11DataARP (line 326) | func TestPacketDot11DataARP(t *testing.T) {
function BenchmarkDecodePacketDot11DataARP (line 356) | func BenchmarkDecodePacketDot11DataARP(b *testing.B) {
function TestPacketDot11DataIP (line 417) | func TestPacketDot11DataIP(t *testing.T) {
function BenchmarkDecodePacketDot11DataIP (line 424) | func BenchmarkDecodePacketDot11DataIP(b *testing.B) {
function TestPacketP6196 (line 461) | func TestPacketP6196(t *testing.T) {
function BenchmarkDecodePacketP6196 (line 470) | func BenchmarkDecodePacketP6196(b *testing.B) {
function TestPacketDot11HTControl (line 520) | func TestPacketDot11HTControl(t *testing.T) {
function TestInformationElement (line 539) | func TestInformationElement(t *testing.T) {
FILE: layers/dot1q.go
type Dot1Q (line 17) | type Dot1Q struct
method LayerType (line 26) | func (d *Dot1Q) LayerType() gopacket.LayerType { return LayerTypeDot1Q }
method DecodeFromBytes (line 29) | func (d *Dot1Q) DecodeFromBytes(data []byte, df gopacket.DecodeFeedbac...
method CanDecode (line 43) | func (d *Dot1Q) CanDecode() gopacket.LayerClass {
method NextLayerType (line 48) | func (d *Dot1Q) NextLayerType() gopacket.LayerType {
method SerializeTo (line 60) | func (d *Dot1Q) SerializeTo(b gopacket.SerializeBuffer, opts gopacket....
function decodeDot1Q (line 52) | func decodeDot1Q(data []byte, p gopacket.PacketBuilder) error {
FILE: layers/dot1q_test.go
function testEncodeDecodeDot1Q (line 18) | func testEncodeDecodeDot1Q(dot1Q *Dot1Q) error {
function TestEncodeDecodeDot1Q (line 43) | func TestEncodeDecodeDot1Q(t *testing.T) {
FILE: layers/eap.go
type EAPCode (line 15) | type EAPCode
type EAPType (line 16) | type EAPType
constant EAPCodeRequest (line 19) | EAPCodeRequest EAPCode = 1
constant EAPCodeResponse (line 20) | EAPCodeResponse EAPCode = 2
constant EAPCodeSuccess (line 21) | EAPCodeSuccess EAPCode = 3
constant EAPCodeFailure (line 22) | EAPCodeFailure EAPCode = 4
constant EAPTypeNone (line 26) | EAPTypeNone EAPType = 0
constant EAPTypeIdentity (line 28) | EAPTypeIdentity EAPType = 1
constant EAPTypeNotification (line 29) | EAPTypeNotification EAPType = 2
constant EAPTypeNACK (line 30) | EAPTypeNACK EAPType = 3
constant EAPTypeOTP (line 31) | EAPTypeOTP EAPType = 4
constant EAPTypeTokenCard (line 32) | EAPTypeTokenCard EAPType = 5
type EAP (line 36) | type EAP struct
method LayerType (line 46) | func (e *EAP) LayerType() gopacket.LayerType { return LayerTypeEAP }
method DecodeFromBytes (line 49) | func (e *EAP) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback)...
method SerializeTo (line 79) | func (e *EAP) SerializeTo(b gopacket.SerializeBuffer, opts gopacket.Se...
method CanDecode (line 102) | func (e *EAP) CanDecode() gopacket.LayerClass {
method NextLayerType (line 107) | func (e *EAP) NextLayerType() gopacket.LayerType {
function decodeEAP (line 111) | func decodeEAP(data []byte, p gopacket.PacketBuilder) error {
FILE: layers/eapol.go
type EAPOL (line 16) | type EAPOL struct
method LayerType (line 24) | func (e *EAPOL) LayerType() gopacket.LayerType { return LayerTypeEAPOL }
method DecodeFromBytes (line 27) | func (e *EAPOL) DecodeFromBytes(data []byte, df gopacket.DecodeFeedbac...
method SerializeTo (line 41) | func (e *EAPOL) SerializeTo(b gopacket.SerializeBuffer, opts gopacket....
method CanDecode (line 50) | func (e *EAPOL) CanDecode() gopacket.LayerClass {
method NextLayerType (line 55) | func (e *EAPOL) NextLayerType() gopacket.LayerType {
function decodeEAPOL (line 59) | func decodeEAPOL(data []byte, p gopacket.PacketBuilder) error {
type EAPOLKeyDescriptorType (line 66) | type EAPOLKeyDescriptorType
method String (line 75) | func (kdt EAPOLKeyDescriptorType) String() string {
constant EAPOLKeyDescriptorTypeRC4 (line 70) | EAPOLKeyDescriptorTypeRC4 EAPOLKeyDescriptorType = 1
constant EAPOLKeyDescriptorTypeDot11 (line 71) | EAPOLKeyDescriptorTypeDot11 EAPOLKeyDescriptorType = 2
constant EAPOLKeyDescriptorTypeWPA (line 72) | EAPOLKeyDescriptorTypeWPA EAPOLKeyDescriptorType = 254
type EAPOLKeyDescriptorVersion (line 91) | type EAPOLKeyDescriptorVersion
method String (line 101) | func (v EAPOLKeyDescriptorVersion) String() string {
constant EAPOLKeyDescriptorVersionOther (line 95) | EAPOLKeyDescriptorVersionOther EAPOLKeyDescriptorVersion = 0
constant EAPOLKeyDescriptorVersionRC4HMACMD5 (line 96) | EAPOLKeyDescriptorVersionRC4HMACMD5 EAPOLKeyDescriptorVersion = 1
constant EAPOLKeyDescriptorVersionAESHMACSHA1 (line 97) | EAPOLKeyDescriptorVersionAESHMACSHA1 EAPOLKeyDescriptorVersion = 2
constant EAPOLKeyDescriptorVersionAES128CMAC (line 98) | EAPOLKeyDescriptorVersionAES128CMAC EAPOLKeyDescriptorVersion = 3
type EAPOLKeyType (line 118) | type EAPOLKeyType
method String (line 126) | func (kt EAPOLKeyType) String() string {
constant EAPOLKeyTypeGroupSMK (line 122) | EAPOLKeyTypeGroupSMK EAPOLKeyType = 0
constant EAPOLKeyTypePairwise (line 123) | EAPOLKeyTypePairwise EAPOLKeyType = 1
type EAPOLKey (line 138) | type EAPOLKey struct
method LayerType (line 164) | func (ek *EAPOLKey) LayerType() gopacket.LayerType {
method CanDecode (line 169) | func (ek *EAPOLKey) CanDecode() gopacket.LayerType {
method NextLayerType (line 175) | func (ek *EAPOLKey) NextLayerType() gopacket.LayerType {
method DecodeFromBytes (line 185) | func (ek *EAPOLKey) DecodeFromBytes(data []byte, df gopacket.DecodeFee...
method SerializeTo (line 244) | func (ek *EAPOLKey) SerializeTo(b gopacket.SerializeBuffer, opts gopac...
constant eapolKeyFrameLen (line 182) | eapolKeyFrameLen = 95
function decodeEAPOLKey (line 299) | func decodeEAPOLKey(data []byte, p gopacket.PacketBuilder) error {
FILE: layers/eapol_test.go
constant eapolErrFmt (line 15) | eapolErrFmt = "%s packet processing failed:\ngot :\n%#v\n\nwant :\n%#v\...
function TestPacketEAPOLKey (line 48) | func TestPacketEAPOLKey(t *testing.T) {
function BenchmarkDecodePacketEAPOLKey (line 119) | func BenchmarkDecodePacketEAPOLKey(b *testing.B) {
FILE: layers/endpoints.go
function NewIPEndpoint (line 52) | func NewIPEndpoint(a net.IP) gopacket.Endpoint {
function NewMACEndpoint (line 67) | func NewMACEndpoint(a net.HardwareAddr) gopacket.Endpoint {
function newPortEndpoint (line 70) | func newPortEndpoint(t gopacket.EndpointType, p uint16) gopacket.Endpoint {
function NewTCPPortEndpoint (line 75) | func NewTCPPortEndpoint(p TCPPort) gopacket.Endpoint {
function NewUDPPortEndpoint (line 80) | func NewUDPPortEndpoint(p UDPPort) gopacket.Endpoint {
function NewSCTPPortEndpoint (line 85) | func NewSCTPPortEndpoint(p SCTPPort) gopacket.Endpoint {
function NewRUDPPortEndpoint (line 90) | func NewRUDPPortEndpoint(p RUDPPort) gopacket.Endpoint {
function NewUDPLitePortEndpoint (line 95) | func NewUDPLitePortEndpoint(p UDPLitePort) gopacket.Endpoint {
FILE: layers/endpoints_test.go
function TestNewIPEndpoint (line 16) | func TestNewIPEndpoint(t *testing.T) {
FILE: layers/enums.go
type EnumMetadata (line 19) | type EnumMetadata struct
type EthernetType (line 30) | type EthernetType
constant EthernetTypeLLC (line 36) | EthernetTypeLLC EthernetType = 0
constant EthernetTypeIPv4 (line 37) | EthernetTypeIPv4 EthernetType = 0x0800
constant EthernetTypeARP (line 38) | EthernetTypeARP EthernetType = 0x0806
constant EthernetTypeIPv6 (line 39) | EthernetTypeIPv6 EthernetType = 0x86DD
constant EthernetTypeCiscoDiscovery (line 40) | EthernetTypeCiscoDiscovery EthernetType = 0x2000
constant EthernetTypeNortelDiscovery (line 41) | EthernetTypeNortelDiscovery EthernetType = 0x01a2
constant EthernetTypeTransparentEthernetBridging (line 42) | EthernetTypeTransparentEthernetBridging EthernetType = 0x6558
constant EthernetTypeDot1Q (line 43) | EthernetTypeDot1Q EthernetType = 0x8100
constant EthernetTypePPP (line 44) | EthernetTypePPP EthernetType = 0x880b
constant EthernetTypePPPoEDiscovery (line 45) | EthernetTypePPPoEDiscovery EthernetType = 0x8863
constant EthernetTypePPPoESession (line 46) | EthernetTypePPPoESession EthernetType = 0x8864
constant EthernetTypeMPLSUnicast (line 47) | EthernetTypeMPLSUnicast EthernetType = 0x8847
constant EthernetTypeMPLSMulticast (line 48) | EthernetTypeMPLSMulticast EthernetType = 0x8848
constant EthernetTypeEAPOL (line 49) | EthernetTypeEAPOL EthernetType = 0x888e
constant EthernetTypeERSPAN (line 50) | EthernetTypeERSPAN EthernetType = 0x88be
constant EthernetTypeQinQ (line 51) | EthernetTypeQinQ EthernetType = 0x88a8
constant EthernetTypeLinkLayerDiscovery (line 52) | EthernetTypeLinkLayerDiscovery EthernetType = 0x88cc
constant EthernetTypeEthernetCTP (line 53) | EthernetTypeEthernetCTP EthernetType = 0x9000
type IPProtocol (line 58) | type IPProtocol
constant IPProtocolIPv6HopByHop (line 61) | IPProtocolIPv6HopByHop IPProtocol = 0
constant IPProtocolICMPv4 (line 62) | IPProtocolICMPv4 IPProtocol = 1
constant IPProtocolIGMP (line 63) | IPProtocolIGMP IPProtocol = 2
constant IPProtocolIPv4 (line 64) | IPProtocolIPv4 IPProtocol = 4
constant IPProtocolTCP (line 65) | IPProtocolTCP IPProtocol = 6
constant IPProtocolUDP (line 66) | IPProtocolUDP IPProtocol = 17
constant IPProtocolRUDP (line 67) | IPProtocolRUDP IPProtocol = 27
constant IPProtocolIPv6 (line 68) | IPProtocolIPv6 IPProtocol = 41
constant IPProtocolIPv6Routing (line 69) | IPProtocolIPv6Routing IPProtocol = 43
constant IPProtocolIPv6Fragment (line 70) | IPProtocolIPv6Fragment IPProtocol = 44
constant IPProtocolGRE (line 71) | IPProtocolGRE IPProtocol = 47
constant IPProtocolESP (line 72) | IPProtocolESP IPProtocol = 50
constant IPProtocolAH (line 73) | IPProtocolAH IPProtocol = 51
constant IPProtocolICMPv6 (line 74) | IPProtocolICMPv6 IPProtocol = 58
constant IPProtocolNoNextHeader (line 75) | IPProtocolNoNextHeader IPProtocol = 59
constant IPProtocolIPv6Destination (line 76) | IPProtocolIPv6Destination IPProtocol = 60
constant IPProtocolOSPF (line 77) | IPProtocolOSPF IPProtocol = 89
constant IPProtocolIPIP (line 78) | IPProtocolIPIP IPProtocol = 94
constant IPProtocolEtherIP (line 79) | IPProtocolEtherIP IPProtocol = 97
constant IPProtocolVRRP (line 80) | IPProtocolVRRP IPProtocol = 112
constant IPProtocolSCTP (line 81) | IPProtocolSCTP IPProtocol = 132
constant IPProtocolUDPLite (line 82) | IPProtocolUDPLite IPProtocol = 136
constant IPProtocolMPLSInIP (line 83) | IPProtocolMPLSInIP IPProtocol = 137
type LinkType (line 88) | type LinkType
constant LinkTypeNull (line 92) | LinkTypeNull LinkType = 0
constant LinkTypeEthernet (line 93) | LinkTypeEthernet LinkType = 1
constant LinkTypeAX25 (line 94) | LinkTypeAX25 LinkType = 3
constant LinkTypeTokenRing (line 95) | LinkTypeTokenRing LinkType = 6
constant LinkTypeArcNet (line 96) | LinkTypeArcNet LinkType = 7
constant LinkTypeSLIP (line 97) | LinkTypeSLIP LinkType = 8
constant LinkTypePPP (line 98) | LinkTypePPP LinkType = 9
constant LinkTypeFDDI (line 99) | LinkTypeFDDI LinkType = 10
constant LinkTypePPP_HDLC (line 100) | LinkTypePPP_HDLC LinkType = 50
constant LinkTypePPPEthernet (line 101) | LinkTypePPPEthernet LinkType = 51
constant LinkTypeATM_RFC1483 (line 102) | LinkTypeATM_RFC1483 LinkType = 100
constant LinkTypeRaw (line 103) | LinkTypeRaw LinkType = 101
constant LinkTypeC_HDLC (line 104) | LinkTypeC_HDLC LinkType = 104
constant LinkTypeIEEE802_11 (line 105) | LinkTypeIEEE802_11 LinkType = 105
constant LinkTypeFRelay (line 106) | LinkTypeFRelay LinkType = 107
constant LinkTypeLoop (line 107) | LinkTypeLoop LinkType = 108
constant LinkTypeLinuxSLL (line 108) | LinkTypeLinuxSLL LinkType = 113
constant LinkTypeLTalk (line 109) | LinkTypeLTalk LinkType = 114
constant LinkTypePFLog (line 110) | LinkTypePFLog LinkType = 117
constant LinkTypePrismHeader (line 111) | LinkTypePrismHeader LinkType = 119
constant LinkTypeIPOverFC (line 112) | LinkTypeIPOverFC LinkType = 122
constant LinkTypeSunATM (line 113) | LinkTypeSunATM LinkType = 123
constant LinkTypeIEEE80211Radio (line 114) | LinkTypeIEEE80211Radio LinkType = 127
constant LinkTypeARCNetLinux (line 115) | LinkTypeARCNetLinux LinkType = 129
constant LinkTypeIPOver1394 (line 116) | LinkTypeIPOver1394 LinkType = 138
constant LinkTypeMTP2Phdr (line 117) | LinkTypeMTP2Phdr LinkType = 139
constant LinkTypeMTP2 (line 118) | LinkTypeMTP2 LinkType = 140
constant LinkTypeMTP3 (line 119) | LinkTypeMTP3 LinkType = 141
constant LinkTypeSCCP (line 120) | LinkTypeSCCP LinkType = 142
constant LinkTypeDOCSIS (line 121) | LinkTypeDOCSIS LinkType = 143
constant LinkTypeLinuxIRDA (line 122) | LinkTypeLinuxIRDA LinkType = 144
constant LinkTypeLinuxLAPD (line 123) | LinkTypeLinuxLAPD LinkType = 177
constant LinkTypeLinuxUSB (line 124) | LinkTypeLinuxUSB LinkType = 220
constant LinkTypeFC2 (line 125) | LinkTypeFC2 LinkType = 224
constant LinkTypeFC2Framed (line 126) | LinkTypeFC2Framed LinkType = 225
constant LinkTypeIPv4 (line 127) | LinkTypeIPv4 LinkType = 228
constant LinkTypeIPv6 (line 128) | LinkTypeIPv6 LinkType = 229
type PPPoECode (line 132) | type PPPoECode
constant PPPoECodePADI (line 135) | PPPoECodePADI PPPoECode = 0x09
constant PPPoECodePADO (line 136) | PPPoECodePADO PPPoECode = 0x07
constant PPPoECodePADR (line 137) | PPPoECodePADR PPPoECode = 0x19
constant PPPoECodePADS (line 138) | PPPoECodePADS PPPoECode = 0x65
constant PPPoECodePADT (line 139) | PPPoECodePADT PPPoECode = 0xA7
constant PPPoECodeSession (line 140) | PPPoECodeSession PPPoECode = 0x00
type PPPType (line 145) | type PPPType
constant PPPTypeIPv4 (line 148) | PPPTypeIPv4 PPPType = 0x0021
constant PPPTypeIPv6 (line 149) | PPPTypeIPv6 PPPType = 0x0057
constant PPPTypeMPLSUnicast (line 150) | PPPTypeMPLSUnicast PPPType = 0x0281
constant PPPTypeMPLSMulticast (line 151) | PPPTypeMPLSMulticast PPPType = 0x0283
type SCTPChunkType (line 155) | type SCTPChunkType
constant SCTPChunkTypeData (line 158) | SCTPChunkTypeData SCTPChunkType = 0
constant SCTPChunkTypeInit (line 159) | SCTPChunkTypeInit SCTPChunkType = 1
constant SCTPChunkTypeInitAck (line 160) | SCTPChunkTypeInitAck SCTPChunkType = 2
constant SCTPChunkTypeSack (line 161) | SCTPChunkTypeSack SCTPChunkType = 3
constant SCTPChunkTypeHeartbeat (line 162) | SCTPChunkTypeHeartbeat SCTPChunkType = 4
constant SCTPChunkTypeHeartbeatAck (line 163) | SCTPChunkTypeHeartbeatAck SCTPChunkType = 5
constant SCTPChunkTypeAbort (line 164) | SCTPChunkTypeAbort SCTPChunkType = 6
constant SCTPChunkTypeShutdown (line 165) | SCTPChunkTypeShutdown SCTPChunkType = 7
constant SCTPChunkTypeShutdownAck (line 166) | SCTPChunkTypeShutdownAck SCTPChunkType = 8
constant SCTPChunkTypeError (line 167) | SCTPChunkTypeError SCTPChunkType = 9
constant SCTPChunkTypeCookieEcho (line 168) | SCTPChunkTypeCookieEcho SCTPChunkType = 10
constant SCTPChunkTypeCookieAck (line 169) | SCTPChunkTypeCookieAck SCTPChunkType = 11
constant SCTPChunkTypeShutdownComplete (line 170) | SCTPChunkTypeShutdownComplete SCTPChunkType = 14
type FDDIFrameControl (line 174) | type FDDIFrameControl
constant FDDIFrameControlLLC (line 177) | FDDIFrameControlLLC FDDIFrameControl = 0x50
type EAPOLType (line 181) | type EAPOLType
constant EAPOLTypeEAP (line 184) | EAPOLTypeEAP EAPOLType = 0
constant EAPOLTypeStart (line 185) | EAPOLTypeStart EAPOLType = 1
constant EAPOLTypeLogOff (line 186) | EAPOLTypeLogOff EAPOLType = 2
constant EAPOLTypeKey (line 187) | EAPOLTypeKey EAPOLType = 3
constant EAPOLTypeASFAlert (line 188) | EAPOLTypeASFAlert EAPOLType = 4
type ProtocolFamily (line 192) | type ProtocolFamily
constant ProtocolFamilyIPv4 (line 195) | ProtocolFamilyIPv4 ProtocolFamily = 2
constant ProtocolFamilyIPv6BSD (line 198) | ProtocolFamilyIPv6BSD ProtocolFamily = 24
constant ProtocolFamilyIPv6FreeBSD (line 199) | ProtocolFamilyIPv6FreeBSD ProtocolFamily = 28
constant ProtocolFamilyIPv6Darwin (line 200) | ProtocolFamilyIPv6Darwin ProtocolFamily = 30
constant ProtocolFamilyIPv6Linux (line 201) | ProtocolFamilyIPv6Linux ProtocolFamily = 10
type Dot11Type (line 210) | type Dot11Type
method MainType (line 214) | func (d Dot11Type) MainType() Dot11Type {
method QOS (line 218) | func (d Dot11Type) QOS() bool {
constant Dot11TypeMgmt (line 223) | Dot11TypeMgmt Dot11Type = 0x00
constant Dot11TypeCtrl (line 224) | Dot11TypeCtrl Dot11Type = 0x01
constant Dot11TypeData (line 225) | Dot11TypeData Dot11Type = 0x02
constant Dot11TypeReserved (line 226) | Dot11TypeReserved Dot11Type = 0x03
constant dot11TypeMask (line 227) | dot11TypeMask = 0x03
constant dot11QOSMask (line 228) | dot11QOSMask = 0x23
constant Dot11TypeMgmtAssociationReq (line 233) | Dot11TypeMgmtAssociationReq Dot11Type = 0x00
constant Dot11TypeMgmtAssociationResp (line 234) | Dot11TypeMgmtAssociationResp Dot11Type = 0x04
constant Dot11TypeMgmtReassociationReq (line 235) | Dot11TypeMgmtReassociationReq Dot11Type = 0x08
constant Dot11TypeMgmtReassociationResp (line 236) | Dot11TypeMgmtReassociationResp Dot11Type = 0x0c
constant Dot11TypeMgmtProbeReq (line 237) | Dot11TypeMgmtProbeReq Dot11Type = 0x10
constant Dot11TypeMgmtProbeResp (line 238) | Dot11TypeMgmtProbeResp Dot11Type = 0x14
constant Dot11TypeMgmtMeasurementPilot (line 239) | Dot11TypeMgmtMeasurementPilot Dot11Type = 0x18
constant Dot11TypeMgmtBeacon (line 240) | Dot11TypeMgmtBeacon Dot11Type = 0x20
constant Dot11TypeMgmtATIM (line 241) | Dot11TypeMgmtATIM Dot11Type = 0x24
constant Dot11TypeMgmtDisassociation (line 242) | Dot11TypeMgmtDisassociation Dot11Type = 0x28
constant Dot11TypeMgmtAuthentication (line 243) | Dot11TypeMgmtAuthentication Dot11Type = 0x2c
constant Dot11TypeMgmtDeauthentication (line 244) | Dot11TypeMgmtDeauthentication Dot11Type = 0x30
constant Dot11TypeMgmtAction (line 245) | Dot11TypeMgmtAction Dot11Type = 0x34
constant Dot11TypeMgmtActionNoAck (line 246) | Dot11TypeMgmtActionNoAck Dot11Type = 0x38
constant Dot11TypeCtrlWrapper (line 249) | Dot11TypeCtrlWrapper Dot11Type = 0x1d
constant Dot11TypeCtrlBlockAckReq (line 250) | Dot11TypeCtrlBlockAckReq Dot11Type = 0x21
constant Dot11TypeCtrlBlockAck (line 251) | Dot11TypeCtrlBlockAck Dot11Type = 0x25
constant Dot11TypeCtrlPowersavePoll (line 252) | Dot11TypeCtrlPowersavePoll Dot11Type = 0x29
constant Dot11TypeCtrlRTS (line 253) | Dot11TypeCtrlRTS Dot11Type = 0x2d
constant Dot11TypeCtrlCTS (line 254) | Dot11TypeCtrlCTS Dot11Type = 0x31
constant Dot11TypeCtrlAck (line 255) | Dot11TypeCtrlAck Dot11Type = 0x35
constant Dot11TypeCtrlCFEnd (line 256) | Dot11TypeCtrlCFEnd Dot11Type = 0x39
constant Dot11TypeCtrlCFEndAck (line 257) | Dot11TypeCtrlCFEndAck Dot11Type = 0x3d
constant Dot11TypeDataCFAck (line 260) | Dot11TypeDataCFAck Dot11Type = 0x06
constant Dot11TypeDataCFPoll (line 261) | Dot11TypeDataCFPoll Dot11Type = 0x0a
constant Dot11TypeDataCFAckPoll (line 262) | Dot11TypeDataCFAckPoll Dot11Type = 0x0e
constant Dot11TypeDataNull (line 263) | Dot11TypeDataNull Dot11Type = 0x12
constant Dot11TypeDataCFAckNoData (line 264) | Dot11TypeDataCFAckNoData Dot11Type = 0x16
constant Dot11TypeDataCFPollNoData (line 265) | Dot11TypeDataCFPollNoData Dot11Type = 0x1a
constant Dot11TypeDataCFAckPollNoData (line 266) | Dot11TypeDataCFAckPollNoData Dot11Type = 0x1e
constant Dot11TypeDataQOSData (line 267) | Dot11TypeDataQOSData Dot11Type = 0x22
constant Dot11TypeDataQOSDataCFAck (line 268) | Dot11TypeDataQOSDataCFAck Dot11Type = 0x26
constant Dot11TypeDataQOSDataCFPoll (line 269) | Dot11TypeDataQOSDataCFPoll Dot11Type = 0x2a
constant Dot11TypeDataQOSDataCFAckPoll (line 270) | Dot11TypeDataQOSDataCFAckPoll Dot11Type = 0x2e
constant Dot11TypeDataQOSNull (line 271) | Dot11TypeDataQOSNull Dot11Type = 0x32
constant Dot11TypeDataQOSCFPollNoData (line 272) | Dot11TypeDataQOSCFPollNoData Dot11Type = 0x3a
constant Dot11TypeDataQOSCFAckPollNoData (line 273) | Dot11TypeDataQOSCFAckPollNoData Dot11Type = 0x3e
function decodeIPv4or6 (line 277) | func decodeIPv4or6(data []byte, p gopacket.PacketBuilder) error {
function initActualTypeData (line 288) | func initActualTypeData() {
FILE: layers/enums_generated.go
function init (line 14) | func init() {
method Decode (line 30) | func (a LinkType) Decode(data []byte, p gopacket.PacketBuilder) error {
method String (line 35) | func (a LinkType) String() string {
method LayerType (line 40) | func (a LinkType) LayerType() gopacket.LayerType {
type errorDecoderForLinkType (line 44) | type errorDecoderForLinkType
method Decode (line 46) | func (a *errorDecoderForLinkType) Decode(data []byte, p gopacket.Packe...
method Error (line 49) | func (a *errorDecoderForLinkType) Error() string {
function initUnknownTypesForLinkType (line 56) | func initUnknownTypesForLinkType() {
method Decode (line 67) | func (a EthernetType) Decode(data []byte, p gopacket.PacketBuilder) error {
method String (line 72) | func (a EthernetType) String() string {
method LayerType (line 77) | func (a EthernetType) LayerType() gopacket.LayerType {
type errorDecoderForEthernetType (line 81) | type errorDecoderForEthernetType
method Decode (line 83) | func (a *errorDecoderForEthernetType) Decode(data []byte, p gopacket.P...
method Error (line 86) | func (a *errorDecoderForEthernetType) Error() string {
function initUnknownTypesForEthernetType (line 93) | func initUnknownTypesForEthernetType() {
method Decode (line 104) | func (a PPPType) Decode(data []byte, p gopacket.PacketBuilder) error {
method String (line 109) | func (a PPPType) String() string {
method LayerType (line 114) | func (a PPPType) LayerType() gopacket.LayerType {
type errorDecoderForPPPType (line 118) | type errorDecoderForPPPType
method Decode (line 120) | func (a *errorDecoderForPPPType) Decode(data []byte, p gopacket.Packet...
method Error (line 123) | func (a *errorDecoderForPPPType) Error() string {
function initUnknownTypesForPPPType (line 130) | func initUnknownTypesForPPPType() {
method Decode (line 141) | func (a IPProtocol) Decode(data []byte, p gopacket.PacketBuilder) error {
method String (line 146) | func (a IPProtocol) String() string {
method LayerType (line 151) | func (a IPProtocol) LayerType() gopacket.LayerType {
type errorDecoderForIPProtocol (line 155) | type errorDecoderForIPProtocol
method Decode (line 157) | func (a *errorDecoderForIPProtocol) Decode(data []byte, p gopacket.Pac...
method Error (line 160) | func (a *errorDecoderForIPProtocol) Error() string {
function initUnknownTypesForIPProtocol (line 167) | func initUnknownTypesForIPProtocol() {
method Decode (line 178) | func (a SCTPChunkType) Decode(data []byte, p gopacket.PacketBuilder) err...
method String (line 183) | func (a SCTPChunkType) String() string {
method LayerType (line 188) | func (a SCTPChunkType) LayerType() gopacket.LayerType {
type errorDecoderForSCTPChunkType (line 192) | type errorDecoderForSCTPChunkType
method Decode (line 194) | func (a *errorDecoderForSCTPChunkType) Decode(data []byte, p gopacket....
method Error (line 197) | func (a *errorDecoderForSCTPChunkType) Error() string {
function initUnknownTypesForSCTPChunkType (line 204) | func initUnknownTypesForSCTPChunkType() {
method Decode (line 215) | func (a PPPoECode) Decode(data []byte, p gopacket.PacketBuilder) error {
method String (line 220) | func (a PPPoECode) String() string {
method LayerType (line 225) | func (a PPPoECode) LayerType() gopacket.LayerType {
type errorDecoderForPPPoECode (line 229) | type errorDecoderForPPPoECode
method Decode (line 231) | func (a *errorDecoderForPPPoECode) Decode(data []byte, p gopacket.Pack...
method Error (line 234) | func (a *errorDecoderForPPPoECode) Error() string {
function initUnknownTypesForPPPoECode (line 241) | func initUnknownTypesForPPPoECode() {
method Decode (line 252) | func (a FDDIFrameControl) Decode(data []byte, p gopacket.PacketBuilder) ...
method String (line 257) | func (a FDDIFrameControl) String() string {
method LayerType (line 262) | func (a FDDIFrameControl) LayerType() gopacket.LayerType {
type errorDecoderForFDDIFrameControl (line 266) | type errorDecoderForFDDIFrameControl
method Decode (line 268) | func (a *errorDecoderForFDDIFrameControl) Decode(data []byte, p gopack...
method Error (line 271) | func (a *errorDecoderForFDDIFrameControl) Error() string {
function initUnknownTypesForFDDIFrameControl (line 278) | func initUnknownTypesForFDDIFrameControl() {
method Decode (line 289) | func (a EAPOLType) Decode(data []byte, p gopacket.PacketBuilder) error {
method String (line 294) | func (a EAPOLType) String() string {
method LayerType (line 299) | func (a EAPOLType) LayerType() gopacket.LayerType {
type errorDecoderForEAPOLType (line 303) | type errorDecoderForEAPOLType
method Decode (line 305) | func (a *errorDecoderForEAPOLType) Decode(data []byte, p gopacket.Pack...
method Error (line 308) | func (a *errorDecoderForEAPOLType) Error() string {
function initUnknownTypesForEAPOLType (line 315) | func initUnknownTypesForEAPOLType() {
method Decode (line 326) | func (a ProtocolFamily) Decode(data []byte, p gopacket.PacketBuilder) er...
method String (line 331) | func (a ProtocolFamily) String() string {
method LayerType (line 336) | func (a ProtocolFamily) LayerType() gopacket.LayerType {
type errorDecoderForProtocolFamily (line 340) | type errorDecoderForProtocolFamily
method Decode (line 342) | func (a *errorDecoderForProtocolFamily) Decode(data []byte, p gopacket...
method Error (line 345) | func (a *errorDecoderForProtocolFamily) Error() string {
function initUnknownTypesForProtocolFamily (line 352) | func initUnknownTypesForProtocolFamily() {
method Decode (line 363) | func (a Dot11Type) Decode(data []byte, p gopacket.PacketBuilder) error {
method String (line 368) | func (a Dot11Type) String() string {
method LayerType (line 373) | func (a Dot11Type) LayerType() gopacket.LayerType {
type errorDecoderForDot11Type (line 377) | type errorDecoderForDot11Type
method Decode (line 379) | func (a *errorDecoderForDot11Type) Decode(data []byte, p gopacket.Pack...
method Error (line 382) | func (a *errorDecoderForDot11Type) Error() string {
function initUnknownTypesForDot11Type (line 389) | func initUnknownTypesForDot11Type() {
method Decode (line 400) | func (a USBTransportType) Decode(data []byte, p gopacket.PacketBuilder) ...
method String (line 405) | func (a USBTransportType) String() string {
method LayerType (line 410) | func (a USBTransportType) LayerType() gopacket.LayerType {
type errorDecoderForUSBTransportType (line 414) | type errorDecoderForUSBTransportType
method Decode (line 416) | func (a *errorDecoderForUSBTransportType) Decode(data []byte, p gopack...
method Error (line 419) | func (a *errorDecoderForUSBTransportType) Error() string {
function initUnknownTypesForUSBTransportType (line 426) | func initUnknownTypesForUSBTransportType() {
FILE: layers/erspan2.go
constant ERSPANIIVersionObsolete (line 17) | ERSPANIIVersionObsolete = 0x0
constant ERSPANIIVersion (line 19) | ERSPANIIVersion = 0x1
type ERSPANII (line 24) | type ERSPANII struct
method LayerType (line 32) | func (erspan2 *ERSPANII) LayerType() gopacket.LayerType { return Layer...
method DecodeFromBytes (line 35) | func (erspan2 *ERSPANII) DecodeFromBytes(data []byte, df gopacket.Deco...
method SerializeTo (line 53) | func (erspan2 *ERSPANII) SerializeTo(b gopacket.SerializeBuffer, opts ...
method CanDecode (line 74) | func (erspan2 *ERSPANII) CanDecode() gopacket.LayerClass {
method NextLayerType (line 79) | func (erspan2 *ERSPANII) NextLayerType() gopacket.LayerType {
function decodeERSPANII (line 83) | func decodeERSPANII(data []byte, p gopacket.PacketBuilder) error {
FILE: layers/erspan2_test.go
function TestDecodeAndEncode (line 15) | func TestDecodeAndEncode(t *testing.T) {
FILE: layers/etherip.go
type EtherIP (line 15) | type EtherIP struct
method LayerType (line 22) | func (e *EtherIP) LayerType() gopacket.LayerType { return LayerTypeEth...
method DecodeFromBytes (line 25) | func (e *EtherIP) DecodeFromBytes(data []byte, df gopacket.DecodeFeedb...
method CanDecode (line 33) | func (e *EtherIP) CanDecode() gopacket.LayerClass {
method NextLayerType (line 38) | func (e *EtherIP) NextLayerType() gopacket.LayerType {
function decodeEtherIP (line 42) | func decodeEtherIP(data []byte, p gopacket.PacketBuilder) error {
FILE: layers/ethernet.go
type Ethernet (line 22) | type Ethernet struct
method LayerType (line 35) | func (e *Ethernet) LayerType() gopacket.LayerType { return LayerTypeEt...
method LinkFlow (line 37) | func (e *Ethernet) LinkFlow() gopacket.Flow {
method DecodeFromBytes (line 41) | func (eth *Ethernet) DecodeFromBytes(data []byte, df gopacket.DecodeFe...
method SerializeTo (line 67) | func (eth *Ethernet) SerializeTo(b gopacket.SerializeBuffer, opts gopa...
method CanDecode (line 106) | func (eth *Ethernet) CanDecode() gopacket.LayerClass {
method NextLayerType (line 110) | func (eth *Ethernet) NextLayerType() gopacket.LayerType {
function decodeEthernet (line 114) | func decodeEthernet(data []byte, p gopacket.PacketBuilder) error {
FILE: layers/fddi.go
type FDDI (line 15) | type FDDI struct
method LayerType (line 23) | func (f *FDDI) LayerType() gopacket.LayerType { return LayerTypeFDDI }
method LinkFlow (line 26) | func (f *FDDI) LinkFlow() gopacket.Flow {
function decodeFDDI (line 30) | func decodeFDDI(data []byte, p gopacket.PacketBuilder) error {
FILE: layers/fuzz_layer.go
function FuzzLayer (line 19) | func FuzzLayer(data []byte) int {
FILE: layers/gen.go
constant fmtString (line 27) | fmtString = `// Copyright 2012 Google, Inc. All rights reserved.
function main (line 54) | func main() {
FILE: layers/gen2.go
constant fmtString (line 22) | fmtString = `// Copyright 2012 Google, Inc. All rights reserved.
function main (line 73) | func main() {
FILE: layers/geneve.go
type Geneve (line 26) | type Geneve struct
method LayerType (line 52) | func (gn *Geneve) LayerType() gopacket.LayerType { return LayerTypeGen...
method DecodeFromBytes (line 76) | func (gn *Geneve) DecodeFromBytes(data []byte, df gopacket.DecodeFeedb...
method NextLayerType (line 115) | func (gn *Geneve) NextLayerType() gopacket.LayerType {
method SerializeTo (line 127) | func (gn *Geneve) SerializeTo(b gopacket.SerializeBuffer, opts gopacke...
type GeneveOption (line 43) | type GeneveOption struct
function decodeGeneveOption (line 54) | func decodeGeneveOption(data []byte, gn *Geneve, df gopacket.DecodeFeedb...
function decodeGeneve (line 119) | func decodeGeneve(data []byte, p gopacket.PacketBuilder) error {
FILE: layers/geneve_test.go
function TestDecodeGeneve1 (line 61) | func TestDecodeGeneve1(t *testing.T) {
function TestDecodeGeneve2 (line 89) | func TestDecodeGeneve2(t *testing.T) {
function TestDecodeGeneve3 (line 117) | func TestDecodeGeneve3(t *testing.T) {
function BenchmarkDecodeGeneve1 (line 153) | func BenchmarkDecodeGeneve1(b *testing.B) {
function TestIsomorphicPacketGeneve (line 159) | func TestIsomorphicPacketGeneve(t *testing.T) {
FILE: layers/gre.go
type GRE (line 16) | type GRE struct
method LayerType (line 36) | func (g *GRE) LayerType() gopacket.LayerType { return LayerTypeGRE }
method DecodeFromBytes (line 39) | func (g *GRE) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback)...
method SerializeTo (line 91) | func (g *GRE) SerializeTo(b gopacket.SerializeBuffer, opts gopacket.Se...
method CanDecode (line 188) | func (g *GRE) CanDecode() gopacket.LayerClass {
method NextLayerType (line 193) | func (g *GRE) NextLayerType() gopacket.LayerType {
type GRERouting (line 28) | type GRERouting struct
function decodeGRE (line 197) | func decodeGRE(data []byte, p gopacket.PacketBuilder) error {
FILE: layers/gre_test.go
function TestPacketGRE (line 38) | func TestPacketGRE(t *testing.T) {
function BenchmarkDecodePacketGRE (line 55) | func BenchmarkDecodePacketGRE(b *testing.B) {
function TestIPv4OverGREEncode (line 103) | func TestIPv4OverGREEncode(t *testing.T) {
function BenchmarkEncodePacketGRE (line 122) | func BenchmarkEncodePacketGRE(b *testing.B) {
function TestPacketEthernetOverGRE (line 157) | func TestPacketEthernetOverGRE(t *testing.T) {
function BenchmarkDecodePacketEthernetOverGRE (line 174) | func BenchmarkDecodePacketEthernetOverGRE(b *testing.B) {
function TestEthernetOverGREEncode (line 227) | func TestEthernetOverGREEncode(t *testing.T) {
function BenchmarkEncodePacketEthernetOverGRE (line 246) | func BenchmarkEncodePacketEthernetOverGRE(b *testing.B) {
function TestGREChecksum (line 340) | func TestGREChecksum(t *testing.T) {
function setNetworkLayer (line 370) | func setNetworkLayer(layers []gopacket.SerializableLayer) error {
FILE: layers/gtp.go
constant gtpMinimumSizeInBytes (line 17) | gtpMinimumSizeInBytes int = 8
type GTPExtensionHeader (line 20) | type GTPExtensionHeader struct
type GTPv1U (line 27) | type GTPv1U struct
method LayerType (line 44) | func (g *GTPv1U) LayerType() gopacket.LayerType { return LayerTypeGTPv...
method DecodeFromBytes (line 47) | func (g *GTPv1U) DecodeFromBytes(data []byte, df gopacket.DecodeFeedba...
method SerializeTo (line 111) | func (g *GTPv1U) SerializeTo(b gopacket.SerializeBuffer, opts gopacket...
method CanDecode (line 157) | func (g *GTPv1U) CanDecode() gopacket.LayerClass {
method NextLayerType (line 162) | func (g *GTPv1U) NextLayerType() gopacket.LayerType {
function decodeGTPv1u (line 176) | func decodeGTPv1u(data []byte, p gopacket.PacketBuilder) error {
FILE: layers/gtp_test.go
function TestGTPPacket (line 48) | func TestGTPPacket(t *testing.T) {
function TestGTPPacketWithEH (line 119) | func TestGTPPacketWithEH(t *testing.T) {
FILE: layers/icmp4.go
constant ICMPv4TypeEchoReply (line 20) | ICMPv4TypeEchoReply = 0
constant ICMPv4TypeDestinationUnreachable (line 21) | ICMPv4TypeDestinationUnreachable = 3
constant ICMPv4TypeSourceQuench (line 22) | ICMPv4TypeSourceQuench = 4
constant ICMPv4TypeRedirect (line 23) | ICMPv4TypeRedirect = 5
constant ICMPv4TypeEchoRequest (line 24) | ICMPv4TypeEchoRequest = 8
constant ICMPv4TypeRouterAdvertisement (line 25) | ICMPv4TypeRouterAdvertisement = 9
constant ICMPv4TypeRouterSolicitation (line 26) | ICMPv4TypeRouterSolicitation = 10
constant ICMPv4TypeTimeExceeded (line 27) | ICMPv4TypeTimeExceeded = 11
constant ICMPv4TypeParameterProblem (line 28) | ICMPv4TypeParameterProblem = 12
constant ICMPv4TypeTimestampRequest (line 29) | ICMPv4TypeTimestampRequest = 13
constant ICMPv4TypeTimestampReply (line 30) | ICMPv4TypeTimestampReply = 14
constant ICMPv4TypeInfoRequest (line 31) | ICMPv4TypeInfoRequest = 15
constant ICMPv4TypeInfoReply (line 32) | ICMPv4TypeInfoReply = 16
constant ICMPv4TypeAddressMaskRequest (line 33) | ICMPv4TypeAddressMaskRequest = 17
constant ICMPv4TypeAddressMaskReply (line 34) | ICMPv4TypeAddressMaskReply = 18
constant ICMPv4CodeNet (line 39) | ICMPv4CodeNet = 0
constant ICMPv4CodeHost (line 40) | ICMPv4CodeHost = 1
constant ICMPv4CodeProtocol (line 41) | ICMPv4CodeProtocol = 2
constant ICMPv4CodePort (line 42) | ICMPv4CodePort = 3
constant ICMPv4CodeFragmentationNeeded (line 43) | ICMPv4CodeFragmentationNeeded = 4
constant ICMPv4CodeSourceRoutingFailed (line 44) | ICMPv4CodeSourceRoutingFailed = 5
constant ICMPv4CodeNetUnknown (line 45) | ICMPv4CodeNetUnknown = 6
constant ICMPv4CodeHostUnknown (line 46) | ICMPv4CodeHostUnknown = 7
constant ICMPv4CodeSourceIsolated (line 47) | ICMPv4CodeSourceIsolated = 8
constant ICMPv4CodeNetAdminProhibited (line 48) | ICMPv4CodeNetAdminProhibited = 9
constant ICMPv4CodeHostAdminProhibited (line 49) | ICMPv4CodeHostAdminProhibited = 10
constant ICMPv4CodeNetTOS (line 50) | ICMPv4CodeNetTOS = 11
constant ICMPv4CodeHostTOS (line 51) | ICMPv4CodeHostTOS = 12
constant ICMPv4CodeCommAdminProhibited (line 52) | ICMPv4CodeCommAdminProhibited = 13
constant ICMPv4CodeHostPrecedence (line 53) | ICMPv4CodeHostPrecedence = 14
constant ICMPv4CodePrecedenceCutoff (line 54) | ICMPv4CodePrecedenceCutoff = 15
constant ICMPv4CodeTTLExceeded (line 57) | ICMPv4CodeTTLExceeded = 0
constant ICMPv4CodeFragmentReassemblyTimeExceeded (line 58) | ICMPv4CodeFragmentReassemblyTimeExceeded = 1
constant ICMPv4CodePointerIndicatesError (line 61) | ICMPv4CodePointerIndicatesError = 0
constant ICMPv4CodeMissingOption (line 62) | ICMPv4CodeMissingOption = 1
constant ICMPv4CodeBadLength (line 63) | ICMPv4CodeBadLength = 2
constant ICMPv4CodeTOSNet (line 68) | ICMPv4CodeTOSNet = 2
constant ICMPv4CodeTOSHost (line 69) | ICMPv4CodeTOSHost = 3
type icmpv4TypeCodeInfoStruct (line 72) | type icmpv4TypeCodeInfoStruct struct
type ICMPv4TypeCode (line 156) | type ICMPv4TypeCode
method Type (line 159) | func (a ICMPv4TypeCode) Type() uint8 {
method Code (line 164) | func (a ICMPv4TypeCode) Code() uint8 {
method String (line 168) | func (a ICMPv4TypeCode) String() string {
method GoString (line 192) | func (a ICMPv4TypeCode) GoString() string {
method SerializeTo (line 198) | func (a ICMPv4TypeCode) SerializeTo(bytes []byte) {
function CreateICMPv4TypeCode (line 204) | func CreateICMPv4TypeCode(typ uint8, code uint8) ICMPv4TypeCode {
type ICMPv4 (line 209) | type ICMPv4 struct
method LayerType (line 218) | func (i *ICMPv4) LayerType() gopacket.LayerType { return LayerTypeICMP...
method DecodeFromBytes (line 221) | func (i *ICMPv4) DecodeFromBytes(data []byte, df gopacket.DecodeFeedba...
method SerializeTo (line 237) | func (i *ICMPv4) SerializeTo(b gopacket.SerializeBuffer, opts gopacket...
method CanDecode (line 255) | func (i *ICMPv4) CanDecode() gopacket.LayerClass {
method NextLayerType (line 260) | func (i *ICMPv4) NextLayerType() gopacket.LayerType {
function decodeICMPv4 (line 264) | func decodeICMPv4(data []byte, p gopacket.PacketBuilder) error {
FILE: layers/icmp6.go
constant ICMPv6TypeDestinationUnreachable (line 21) | ICMPv6TypeDestinationUnreachable = 1
constant ICMPv6TypePacketTooBig (line 22) | ICMPv6TypePacketTooBig = 2
constant ICMPv6TypeTimeExceeded (line 23) | ICMPv6TypeTimeExceeded = 3
constant ICMPv6TypeParameterProblem (line 24) | ICMPv6TypeParameterProblem = 4
constant ICMPv6TypeEchoRequest (line 25) | ICMPv6TypeEchoRequest = 128
constant ICMPv6TypeEchoReply (line 26) | ICMPv6TypeEchoReply = 129
constant ICMPv6TypeRouterSolicitation (line 29) | ICMPv6TypeRouterSolicitation = 133
constant ICMPv6TypeRouterAdvertisement (line 30) | ICMPv6TypeRouterAdvertisement = 134
constant ICMPv6TypeNeighborSolicitation (line 31) | ICMPv6TypeNeighborSolicitation = 135
constant ICMPv6TypeNeighborAdvertisement (line 32) | ICMPv6TypeNeighborAdvertisement = 136
constant ICMPv6TypeRedirect (line 33) | ICMPv6TypeRedirect = 137
constant ICMPv6TypeMLDv1MulticastListenerQueryMessage (line 36) | ICMPv6TypeMLDv1MulticastListenerQueryMessage = 130
constant ICMPv6TypeMLDv1MulticastListenerReportMessage (line 37) | ICMPv6TypeMLDv1MulticastListenerReportMessage = 131
constant ICMPv6TypeMLDv1MulticastListenerDoneMessage (line 38) | ICMPv6TypeMLDv1MulticastListenerDoneMessage = 132
constant ICMPv6TypeMLDv2MulticastListenerReportMessageV2 (line 41) | ICMPv6TypeMLDv2MulticastListenerReportMessageV2 = 143
constant ICMPv6CodeNoRouteToDst (line 46) | ICMPv6CodeNoRouteToDst = 0
constant ICMPv6CodeAdminProhibited (line 47) | ICMPv6CodeAdminProhibited = 1
constant ICMPv6CodeBeyondScopeOfSrc (line 48) | ICMPv6CodeBeyondScopeOfSrc = 2
constant ICMPv6CodeAddressUnreachable (line 49) | ICMPv6CodeAddressUnreachable = 3
constant ICMPv6CodePortUnreachable (line 50) | ICMPv6CodePortUnreachable = 4
constant ICMPv6CodeSrcAddressFailedPolicy (line 51) | ICMPv6CodeSrcAddressFailedPolicy = 5
constant ICMPv6CodeRejectRouteToDst (line 52) | ICMPv6CodeRejectRouteToDst = 6
constant ICMPv6CodeHopLimitExceeded (line 55) | ICMPv6CodeHopLimitExceeded = 0
constant ICMPv6CodeFragmentReassemblyTimeExceeded (line 56) | ICMPv6CodeFragmentReassemblyTimeExceeded = 1
constant ICMPv6CodeErroneousHeaderField (line 59) | ICMPv6CodeErroneousHeaderField = 0
constant ICMPv6CodeUnrecognizedNextHeader (line 60) | ICMPv6CodeUnrecognizedNextHeader = 1
constant ICMPv6CodeUnrecognizedIPv6Option (line 61) | ICMPv6CodeUnrecognizedIPv6Option = 2
type icmpv6TypeCodeInfoStruct (line 64) | type icmpv6TypeCodeInfoStruct struct
type ICMPv6TypeCode (line 122) | type ICMPv6TypeCode
method Type (line 125) | func (a ICMPv6TypeCode) Type() uint8 {
method Code (line 130) | func (a ICMPv6TypeCode) Code() uint8 {
method String (line 134) | func (a ICMPv6TypeCode) String() string {
method GoString (line 158) | func (a ICMPv6TypeCode) GoString() string {
method SerializeTo (line 164) | func (a ICMPv6TypeCode) SerializeTo(bytes []byte) {
function CreateICMPv6TypeCode (line 170) | func CreateICMPv6TypeCode(typ uint8, code uint8) ICMPv6TypeCode {
type ICMPv6 (line 175) | type ICMPv6 struct
method LayerType (line 186) | func (i *ICMPv6) LayerType() gopacket.LayerType { return LayerTypeICMP...
method DecodeFromBytes (line 189) | func (i *ICMPv6) DecodeFromBytes(data []byte, df gopacket.DecodeFeedba...
method SerializeTo (line 203) | func (i *ICMPv6) SerializeTo(b gopacket.SerializeBuffer, opts gopacket...
method CanDecode (line 225) | func (i *ICMPv6) CanDecode() gopacket.LayerClass {
method NextLayerType (line 230) | func (i *ICMPv6) NextLayerType() gopacket.LayerType {
function decodeICMPv6 (line 263) | func decodeICMPv6(data []byte, p gopacket.PacketBuilder) error {
FILE: layers/icmp6NDflags_test.go
function TestPacketICMPv6NeighborAnnouncementFlags (line 64) | func TestPacketICMPv6NeighborAnnouncementFlags(t *testing.T) {
function TestPacketICMPv6RouterAnnouncementFlags (line 99) | func TestPacketICMPv6RouterAnnouncementFlags(t *testing.T) {
FILE: layers/icmp6_test.go
function TestPacketICMPv6 (line 32) | func TestPacketICMPv6(t *testing.T) {
FILE: layers/icmp6hopbyhop_test.go
function TestPacketICMPv6WithHopByHop (line 55) | func TestPacketICMPv6WithHopByHop(t *testing.T) {
FILE: layers/icmp6msg.go
type ICMPv6Opt (line 24) | type ICMPv6Opt
method String (line 115) | func (i ICMPv6Opt) String() string {
constant _ (line 27) | _ ICMPv6Opt = iota
constant ICMPv6OptSourceAddress (line 33) | ICMPv6OptSourceAddress
constant ICMPv6OptTargetAddress (line 38) | ICMPv6OptTargetAddress
constant ICMPv6OptPrefixInfo (line 44) | ICMPv6OptPrefixInfo
constant ICMPv6OptRedirectedHeader (line 48) | ICMPv6OptRedirectedHeader
constant ICMPv6OptMTU (line 54) | ICMPv6OptMTU
type ICMPv6Echo (line 58) | type ICMPv6Echo struct
method CanDecode (line 133) | func (i *ICMPv6Echo) CanDecode() gopacket.LayerClass {
method LayerType (line 138) | func (i *ICMPv6Echo) LayerType() gopacket.LayerType {
method NextLayerType (line 143) | func (i *ICMPv6Echo) NextLayerType() gopacket.LayerType {
method DecodeFromBytes (line 148) | func (i *ICMPv6Echo) DecodeFromBytes(data []byte, df gopacket.DecodeFe...
method SerializeTo (line 162) | func (i *ICMPv6Echo) SerializeTo(b gopacket.SerializeBuffer, opts gopa...
type ICMPv6RouterSolicitation (line 65) | type ICMPv6RouterSolicitation struct
method LayerType (line 174) | func (i *ICMPv6RouterSolicitation) LayerType() gopacket.LayerType {
method NextLayerType (line 179) | func (i *ICMPv6RouterSolicitation) NextLayerType() gopacket.LayerType {
method DecodeFromBytes (line 184) | func (i *ICMPv6RouterSolicitation) DecodeFromBytes(data []byte, df gop...
method SerializeTo (line 200) | func (i *ICMPv6RouterSolicitation) SerializeTo(b gopacket.SerializeBuf...
method CanDecode (line 215) | func (i *ICMPv6RouterSolicitation) CanDecode() gopacket.LayerClass {
type ICMPv6RouterAdvertisement (line 71) | type ICMPv6RouterAdvertisement struct
method LayerType (line 220) | func (i *ICMPv6RouterAdvertisement) LayerType() gopacket.LayerType {
method NextLayerType (line 225) | func (i *ICMPv6RouterAdvertisement) NextLayerType() gopacket.LayerType {
method DecodeFromBytes (line 230) | func (i *ICMPv6RouterAdvertisement) DecodeFromBytes(data []byte, df go...
method SerializeTo (line 253) | func (i *ICMPv6RouterAdvertisement) SerializeTo(b gopacket.SerializeBu...
method CanDecode (line 272) | func (i *ICMPv6RouterAdvertisement) CanDecode() gopacket.LayerClass {
method ManagedAddressConfig (line 278) | func (i *ICMPv6RouterAdvertisement) ManagedAddressConfig() bool {
method OtherConfig (line 284) | func (i *ICMPv6RouterAdvertisement) OtherConfig() bool {
type ICMPv6NeighborSolicitation (line 83) | type ICMPv6NeighborSolicitation struct
method LayerType (line 289) | func (i *ICMPv6NeighborSolicitation) LayerType() gopacket.LayerType {
method NextLayerType (line 294) | func (i *ICMPv6NeighborSolicitation) NextLayerType() gopacket.LayerType {
method DecodeFromBytes (line 299) | func (i *ICMPv6NeighborSolicitation) DecodeFromBytes(data []byte, df g...
method SerializeTo (line 317) | func (i *ICMPv6NeighborSolicitation) SerializeTo(b gopacket.SerializeB...
method CanDecode (line 333) | func (i *ICMPv6NeighborSolicitation) CanDecode() gopacket.LayerClass {
type ICMPv6NeighborAdvertisement (line 90) | type ICMPv6NeighborAdvertisement struct
method LayerType (line 338) | func (i *ICMPv6NeighborAdvertisement) LayerType() gopacket.LayerType {
method NextLayerType (line 343) | func (i *ICMPv6NeighborAdvertisement) NextLayerType() gopacket.LayerTy...
method DecodeFromBytes (line 348) | func (i *ICMPv6NeighborAdvertisement) DecodeFromBytes(data []byte, df ...
method SerializeTo (line 367) | func (i *ICMPv6NeighborAdvertisement) SerializeTo(b gopacket.Serialize...
method CanDecode (line 384) | func (i *ICMPv6NeighborAdvertisement) CanDecode() gopacket.LayerClass {
method Router (line 389) | func (i *ICMPv6NeighborAdvertisement) Router() bool {
method Solicited (line 394) | func (i *ICMPv6NeighborAdvertisement) Solicited() bool {
method Override (line 400) | func (i *ICMPv6NeighborAdvertisement) Override() bool {
type ICMPv6Redirect (line 99) | type ICMPv6Redirect struct
method LayerType (line 405) | func (i *ICMPv6Redirect) LayerType() gopacket.LayerType {
method NextLayerType (line 410) | func (i *ICMPv6Redirect) NextLayerType() gopacket.LayerType {
method DecodeFromBytes (line 415) | func (i *ICMPv6Redirect) DecodeFromBytes(data []byte, df gopacket.Deco...
method SerializeTo (line 434) | func (i *ICMPv6Redirect) SerializeTo(b gopacket.SerializeBuffer, opts ...
method CanDecode (line 451) | func (i *ICMPv6Redirect) CanDecode() gopacket.LayerClass {
type ICMPv6Option (line 107) | type ICMPv6Option struct
method String (line 455) | func (i ICMPv6Option) String() string {
type ICMPv6Options (line 113) | type ICMPv6Options
method DecodeFromBytes (line 497) | func (i *ICMPv6Options) DecodeFromBytes(data []byte, df gopacket.Decod...
method SerializeTo (line 534) | func (i *ICMPv6Options) SerializeTo(b gopacket.SerializeBuffer, opts g...
function decodeICMPv6Echo (line 550) | func decodeICMPv6Echo(data []byte, p gopacket.PacketBuilder) error {
function decodeICMPv6RouterSolicitation (line 555) | func decodeICMPv6RouterSolicitation(data []byte, p gopacket.PacketBuilde...
function decodeICMPv6RouterAdvertisement (line 560) | func decodeICMPv6RouterAdvertisement(data []byte, p gopacket.PacketBuild...
function decodeICMPv6NeighborSolicitation (line 565) | func decodeICMPv6NeighborSolicitation(data []byte, p gopacket.PacketBuil...
function decodeICMPv6NeighborAdvertisement (line 570) | func decodeICMPv6NeighborAdvertisement(data []byte, p gopacket.PacketBui...
function decodeICMPv6Redirect (line 575) | func decodeICMPv6Redirect(data []byte, p gopacket.PacketBuilder) error {
FILE: layers/icmp6msg_test.go
function TestPacketICMPv6RouterAdvertisement (line 44) | func TestPacketICMPv6RouterAdvertisement(t *testing.T) {
function TestPacketICMPv6NeighborSolicitation (line 67) | func TestPacketICMPv6NeighborSolicitation(t *testing.T) {
FILE: layers/igmp.go
type IGMPType (line 19) | type IGMPType
method String (line 30) | func (i IGMPType) String() string {
constant IGMPMembershipQuery (line 22) | IGMPMembershipQuery IGMPType = 0x11
constant IGMPMembershipReportV1 (line 23) | IGMPMembershipReportV1 IGMPType = 0x12
constant IGMPMembershipReportV2 (line 24) | IGMPMembershipReportV2 IGMPType = 0x16
constant IGMPLeaveGroup (line 25) | IGMPLeaveGroup IGMPType = 0x17
constant IGMPMembershipReportV3 (line 26) | IGMPMembershipReportV3 IGMPType = 0x22
type IGMPv3GroupRecordType (line 47) | type IGMPv3GroupRecordType
method String (line 58) | func (i IGMPv3GroupRecordType) String() string {
constant IGMPIsIn (line 50) | IGMPIsIn IGMPv3GroupRecordType = 0x01
constant IGMPIsEx (line 51) | IGMPIsEx IGMPv3GroupRecordType = 0x02
constant IGMPToIn (line 52) | IGMPToIn IGMPv3GroupRecordType = 0x03
constant IGMPToEx (line 53) | IGMPToEx IGMPv3GroupRecordType = 0x04
constant IGMPAllow (line 54) | IGMPAllow IGMPv3GroupRecordType = 0x05
constant IGMPBlock (line 55) | IGMPBlock IGMPv3GroupRecordType = 0x06
type IGMP (line 78) | type IGMP struct
method decodeIGMPv3MembershipReport (line 171) | func (i *IGMP) decodeIGMPv3MembershipReport(data []byte) error {
method decodeIGMPv3MembershipQuery (line 224) | func (i *IGMP) decodeIGMPv3MembershipQuery(data []byte) error {
method LayerType (line 260) | func (i *IGMP) LayerType() gopacket.LayerType { return LayerTypeI...
method DecodeFromBytes (line 285) | func (i *IGMP) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback...
method CanDecode (line 306) | func (i *IGMP) CanDecode() gopacket.LayerClass {
method NextLayerType (line 311) | func (i *IGMP) NextLayerType() gopacket.LayerType {
type IGMPv1or2 (line 103) | type IGMPv1or2 struct
method decodeResponse (line 113) | func (i *IGMPv1or2) decodeResponse(data []byte) error {
method LayerType (line 261) | func (i *IGMPv1or2) LayerType() gopacket.LayerType { return LayerTypeI...
method DecodeFromBytes (line 263) | func (i *IGMPv1or2) DecodeFromBytes(data []byte, df gopacket.DecodeFee...
method NextLayerType (line 276) | func (i *IGMPv1or2) NextLayerType() gopacket.LayerType {
method CanDecode (line 280) | func (i *IGMPv1or2) CanDecode() gopacket.LayerClass {
type IGMPv3GroupRecord (line 162) | type IGMPv3GroupRecord struct
function igmpTimeDecode (line 250) | func igmpTimeDecode(t uint8) time.Duration {
function decodeIGMP (line 319) | func decodeIGMP(data []byte, p gopacket.PacketBuilder) error {
FILE: layers/igmp_test.go
function TestIGMPv1MembershipReportPacket (line 28) | func TestIGMPv1MembershipReportPacket(t *testing.T) {
function BenchmarkDecodeigmpv1MembershipReportPacket (line 41) | func BenchmarkDecodeigmpv1MembershipReportPacket(b *testing.B) {
function TestIGMPv2MembershipQuery (line 60) | func TestIGMPv2MembershipQuery(t *testing.T) {
function BenchmarkDecodeigmpv2MembershipQueryPacket (line 72) | func BenchmarkDecodeigmpv2MembershipQueryPacket(b *testing.B) {
function TestIGMPv2MembershipReport (line 91) | func TestIGMPv2MembershipReport(t *testing.T) {
function BenchmarkDecodeigmpv2MembershipReportPacket (line 103) | func BenchmarkDecodeigmpv2MembershipReportPacket(b *testing.B) {
function TestIGMPv3MembershipQuery (line 122) | func TestIGMPv3MembershipQuery(t *testing.T) {
function BenchmarkDecodeigmp3v3MembershipQueryPacket (line 135) | func BenchmarkDecodeigmp3v3MembershipQueryPacket(b *testing.B) {
function TestIGMPv3MembershipReport2Records (line 154) | func TestIGMPv3MembershipReport2Records(t *testing.T) {
function BenchmarkDecodeigmpv3MembershipReport2Records (line 167) | func BenchmarkDecodeigmpv3MembershipReport2Records(b *testing.B) {
FILE: layers/ip4.go
type IPv4Flag (line 20) | type IPv4Flag
method String (line 28) | func (f IPv4Flag) String() string {
constant IPv4EvilBit (line 23) | IPv4EvilBit IPv4Flag = 1 << 2
constant IPv4DontFragment (line 24) | IPv4DontFragment IPv4Flag = 1 << 1
constant IPv4MoreFragments (line 25) | IPv4MoreFragments IPv4Flag = 1 << 0
type IPv4 (line 43) | type IPv4 struct
method LayerType (line 62) | func (i *IPv4) LayerType() gopacket.LayerType { return LayerTypeIPv4 }
method NetworkFlow (line 63) | func (i *IPv
Condensed preview — 298 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (4,227K chars).
[
{
"path": ".gitignore",
"chars": 591,
"preview": "# Compiled Object files, Static and Dynamic libs (Shared Objects)\n*.o\n*.a\n*.so\n\n# Folders\n_obj\n_test\n\n# Architecture spe"
},
{
"path": ".travis.gofmt.sh",
"chars": 165,
"preview": "#!/bin/bash\n\ncd \"$(dirname $0)\"\nif [ -n \"$(go fmt ./...)\" ]; then\n echo \"Go code is not formatted, run 'go fmt github.c"
},
{
"path": ".travis.golint.sh",
"chars": 716,
"preview": "#!/bin/bash\n\ncd \"$(dirname $0)\"\n\ngo get golang.org/x/lint/golint\nDIRS=\". tcpassembly tcpassembly/tcpreader ip4defrag rea"
},
{
"path": ".travis.govet.sh",
"chars": 211,
"preview": "#!/bin/bash\n\ncd \"$(dirname $0)\"\nDIRS=\". layers pcap pcapgo tcpassembly tcpassembly/tcpreader routing ip4defrag bytediff "
},
{
"path": ".travis.install.sh",
"chars": 229,
"preview": "#!/bin/bash\n\nset -ev\n\ngo get github.com/google/gopacket\ngo get github.com/google/gopacket/layers\ngo get github.com/googl"
},
{
"path": ".travis.script.sh",
"chars": 331,
"preview": "#!/bin/bash\n\nset -ev\n\ngo test github.com/google/gopacket\ngo test github.com/google/gopacket/layers\ngo test github.com/go"
},
{
"path": ".travis.yml",
"chars": 1089,
"preview": "language: go\ngo:\n - 1.11.x\n - 1.12.x\n - 1.13.x\n - master\n\naddons:\n apt:\n packages:\n libpcap-dev\n\n# use modules "
},
{
"path": "AUTHORS",
"chars": 1741,
"preview": "AUTHORS AND MAINTAINERS:\n\nMAIN DEVELOPERS:\nGraeme Connell <gconnell@google.com, gsconnell@gmail.com>\n\nAUTHORS:\nNigel T"
},
{
"path": "CONTRIBUTING.md",
"chars": 8921,
"preview": "Contributing To gopacket\n========================\n\nSo you've got some code and you'd like it to be part of gopacket... w"
},
{
"path": "LICENSE",
"chars": 1555,
"preview": "Copyright (c) 2012 Google, Inc. All rights reserved.\nCopyright (c) 2009-2011 Andreas Krennmair. All rights reserved.\n\nRe"
},
{
"path": "README.md",
"chars": 651,
"preview": "# GoPacket\n\nThis library provides packet decoding capabilities for Go.\nSee [godoc](https://godoc.org/github.com/google/g"
},
{
"path": "afpacket/afpacket.go",
"chars": 17251,
"preview": "// Copyright 2012 Google, Inc. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style license\n// "
},
{
"path": "afpacket/afpacket_test.go",
"chars": 1138,
"preview": "// Copyright 2012 Google, Inc. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style license\n// "
},
{
"path": "afpacket/header.go",
"chars": 6109,
"preview": "// Copyright 2012 Google, Inc. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style license\n// "
},
{
"path": "afpacket/options.go",
"chars": 6271,
"preview": "// Copyright 2012 Google, Inc. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style license\n// "
},
{
"path": "afpacket/sockopt_linux.go",
"chars": 1176,
"preview": "// Copyright 2012 Google, Inc. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style license\n// "
},
{
"path": "base.go",
"chars": 5714,
"preview": "// Copyright 2012 Google, Inc. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style license\n// "
},
{
"path": "benchmark_test.go",
"chars": 3804,
"preview": "// Copyright 2012, Google, Inc. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style license\n//"
},
{
"path": "bsdbpf/bsd_bpf_sniffer.go",
"chars": 6911,
"preview": "// Copyright 2012 Google, Inc. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style license\n// "
},
{
"path": "bytediff/bytediff.go",
"chars": 5985,
"preview": "// Copyright 2012 Google, Inc. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style license\n// "
},
{
"path": "bytediff/bytediff_test.go",
"chars": 1418,
"preview": "// Copyright 2012 Google, Inc. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style license\n// "
},
{
"path": "decode.go",
"chars": 6119,
"preview": "// Copyright 2012 Google, Inc. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style license\n// "
},
{
"path": "defrag/lcmdefrag/lcmdefrag.go",
"chars": 3730,
"preview": "// Copyright 2018 Google, Inc. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style license\n// "
},
{
"path": "defrag/lcmdefrag/lcmdefrag_test.go",
"chars": 2804,
"preview": "// Copyright 2018 Google, Inc. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style license\n// "
},
{
"path": "doc.go",
"chars": 18382,
"preview": "// Copyright 2012 Google, Inc. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style license\n// "
},
{
"path": "dumpcommand/tcpdump.go",
"chars": 3647,
"preview": "// Copyright 2012 Google, Inc. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style license\n// "
},
{
"path": "examples/afpacket/afpacket.go",
"chars": 5403,
"preview": "// Copyright 2018 Google, Inc. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style license\n// "
},
{
"path": "examples/arpscan/arpscan.go",
"chars": 5705,
"preview": "// Copyright 2012 Google, Inc. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style license\n// "
},
{
"path": "examples/bidirectional/main.go",
"chars": 6605,
"preview": "// Copyright 2012 Google, Inc. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style license\n// "
},
{
"path": "examples/bytediff/main.go",
"chars": 5689,
"preview": "// Copyright 2012 Google, Inc. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style license\n// "
},
{
"path": "examples/httpassembly/main.go",
"chars": 3882,
"preview": "// Copyright 2012 Google, Inc. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style license\n// "
},
{
"path": "examples/pcapdump/main.go",
"chars": 2515,
"preview": "// Copyright 2012 Google, Inc. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style license\n// "
},
{
"path": "examples/pcaplay/main.go",
"chars": 3937,
"preview": "// Copyright 2012 Google, Inc. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style license\n// "
},
{
"path": "examples/pfdump/main.go",
"chars": 1691,
"preview": "// Copyright 2012 Google, Inc. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style license\n// "
},
{
"path": "examples/reassemblydump/compare.sh",
"chars": 3451,
"preview": "#!/bin/bash\n\n# Limitations: if the number extracted files in too big, finding identical\n# files might fail "
},
{
"path": "examples/reassemblydump/main.go",
"chars": 19133,
"preview": "// Copyright 2012 Google, Inc. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style license\n// "
},
{
"path": "examples/snoopread/main.go",
"chars": 979,
"preview": "// Copyright 2019 The GoPacket Authors. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style li"
},
{
"path": "examples/statsassembly/main.go",
"chars": 7679,
"preview": "// Copyright 2012 Google, Inc. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style license\n// "
},
{
"path": "examples/synscan/main.go",
"chars": 7988,
"preview": "// Copyright 2012 Google, Inc. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style license\n// "
},
{
"path": "examples/util/util.go",
"chars": 927,
"preview": "// Copyright 2012 Google, Inc. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style license\n// "
},
{
"path": "flows.go",
"chars": 7874,
"preview": "// Copyright 2012 Google, Inc. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style license\n// "
},
{
"path": "gc",
"chars": 6469,
"preview": "#!/bin/bash\n# Copyright 2012 Google, Inc. All rights reserved.\n\n# This script provides a simple way to run benchmarks ag"
},
{
"path": "gen.go",
"chars": 1870,
"preview": "// Copyright 2019 The GoPacket Authors. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style li"
},
{
"path": "go.mod",
"chars": 266,
"preview": "module github.com/google/gopacket\n\ngo 1.12\n\nrequire (\n\tgithub.com/vishvananda/netlink v1.1.0\n\tgithub.com/vishvananda/net"
},
{
"path": "go.sum",
"chars": 1347,
"preview": "github.com/vishvananda/netlink v1.1.0 h1:1iyaYNBLmP6L0220aDnYQpo1QEV4t4hJ+xEEhhJH8j0=\ngithub.com/vishvananda/netlink v1."
},
{
"path": "ip4defrag/defrag.go",
"chars": 10556,
"preview": "// Copyright 2013 Google, Inc. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style license\n// "
},
{
"path": "ip4defrag/defrag_test.go",
"chars": 83232,
"preview": "// Copyright 2013 Google, Inc. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style license\n// "
},
{
"path": "layerclass.go",
"chars": 2997,
"preview": "// Copyright 2012 Google, Inc. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style license\n// "
},
{
"path": "layers/.lint_blacklist",
"chars": 385,
"preview": "dot11.go\neap.go\nendpoints.go\nenums_generated.go\nenums.go\nethernet.go\ngeneve.go\nicmp4.go\nicmp6.go\nigmp.go\nip4.go\nip6.go\nl"
},
{
"path": "layers/ague_var0.go",
"chars": 2952,
"preview": "// Copyright 2025 Google, Inc. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style license\n// "
},
{
"path": "layers/ague_var0_test.go",
"chars": 3433,
"preview": "// Copyright 2025 Google, Inc. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style license\n// "
},
{
"path": "layers/ague_var1.go",
"chars": 2667,
"preview": "// Copyright 2025 Google, Inc. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style license\n// "
},
{
"path": "layers/ague_var1_test.go",
"chars": 4119,
"preview": "// Copyright 2025 Google, Inc. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style license\n// "
},
{
"path": "layers/apsp.go",
"chars": 3923,
"preview": "// Copyright 2025 Google, Inc. All rights reserved.\n// Copyright 2009-2011 Andreas Krennmair. All rights reserved.\n//\n//"
},
{
"path": "layers/apsp_test.go",
"chars": 5602,
"preview": "// Copyright 2025 Google, Inc. All rights reserved.\n// Copyright 2009-2011 Andreas Krennmair. All rights reserved.\n//\n//"
},
{
"path": "layers/arp.go",
"chars": 3705,
"preview": "// Copyright 2012 Google, Inc. All rights reserved.\n// Copyright 2009-2011 Andreas Krennmair. All rights reserved.\n//\n//"
},
{
"path": "layers/asf.go",
"chars": 5428,
"preview": "// Copyright 2019 The GoPacket Authors. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style li"
},
{
"path": "layers/asf_presencepong.go",
"chars": 7124,
"preview": "// Copyright 2019 The GoPacket Authors. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style li"
},
{
"path": "layers/asf_presencepong_test.go",
"chars": 3235,
"preview": "// Copyright 2019 The GoPacket Authors. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style li"
},
{
"path": "layers/asf_test.go",
"chars": 2201,
"preview": "// Copyright 2019 The GoPacket Authors. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style li"
},
{
"path": "layers/base.go",
"chars": 1564,
"preview": "// Copyright 2012 Google, Inc. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style license\n// "
},
{
"path": "layers/base_test.go",
"chars": 1849,
"preview": "// Copyright 2012, Google, Inc. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style license\n//"
},
{
"path": "layers/bfd.go",
"chars": 19069,
"preview": "// Copyright 2017 Google, Inc. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style license\n// "
},
{
"path": "layers/bfd_test.go",
"chars": 11038,
"preview": "// Copyright 2017 Google, Inc. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style license\n// "
},
{
"path": "layers/bitfield.go",
"chars": 483,
"preview": "// Copyright 2021 The GoPacket Authors. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style li"
},
{
"path": "layers/bitfield_test.go",
"chars": 756,
"preview": "package layers\n\nimport \"testing\"\n\nfunc TestBitfield(t *testing.T) {\n\tvar b bitfield\n\n\tconst uint16Max = ^uint16(0)\n\n\tfor"
},
{
"path": "layers/cdp.go",
"chars": 19424,
"preview": "// Copyright 2012 Google, Inc. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style license\n// "
},
{
"path": "layers/ctp.go",
"chars": 3514,
"preview": "// Copyright 2012 Google, Inc. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style license\n// "
},
{
"path": "layers/decode_test.go",
"chars": 63134,
"preview": "// Copyright 2012, Google, Inc. All rights reserved.\n// Copyright 2009-2011 Andreas Krennmair. All rights reserved.\n//\n/"
},
{
"path": "layers/dhcp_test.go",
"chars": 6219,
"preview": "// Copyright 2016, Google, Inc. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style license\n//"
},
{
"path": "layers/dhcpv4.go",
"chars": 17042,
"preview": "// Copyright 2016 Google, Inc. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style license\n// "
},
{
"path": "layers/dhcpv6.go",
"chars": 9108,
"preview": "// Copyright 2018 Google, Inc. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style license\n// "
},
{
"path": "layers/dhcpv6_options.go",
"chars": 18865,
"preview": "// Copyright 2018 The GoPacket Authors. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style li"
},
{
"path": "layers/dhcpv6_test.go",
"chars": 3495,
"preview": "// Copyright 2018, Google, Inc. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style license\n//"
},
{
"path": "layers/dns.go",
"chars": 33412,
"preview": "// Copyright 2014, 2018 GoPacket Authors. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style "
},
{
"path": "layers/dns_test.go",
"chars": 62253,
"preview": "// Copyright 2012, 2018 GoPacket Authors. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style "
},
{
"path": "layers/doc.go",
"chars": 2894,
"preview": "// Copyright 2012 Google, Inc. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style license\n// "
},
{
"path": "layers/dot11.go",
"chars": 75643,
"preview": "// Copyright 2014 Google, Inc. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style license\n// "
},
{
"path": "layers/dot11_test.go",
"chars": 27504,
"preview": "// Copyright 2014, Google, Inc. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style license\n//"
},
{
"path": "layers/dot1q.go",
"chars": 2280,
"preview": "// Copyright 2012 Google, Inc. All rights reserved.\n// Copyright 2009-2011 Andreas Krennmair. All rights reserved.\n//\n//"
},
{
"path": "layers/dot1q_test.go",
"chars": 1386,
"preview": "// Copyright 2012 Google, Inc. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style license\n// "
},
{
"path": "layers/eap.go",
"chars": 2915,
"preview": "// Copyright 2012 Google, Inc. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style license\n// "
},
{
"path": "layers/eapol.go",
"chars": 8428,
"preview": "// Copyright 2012 Google, Inc. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style license\n// "
},
{
"path": "layers/eapol_test.go",
"chars": 4161,
"preview": "// Copyright placeholder\n//\n// Use of this source code is governed by a BSD-style license\n// that can be found in the LI"
},
{
"path": "layers/endpoints.go",
"chars": 3744,
"preview": "// Copyright 2012 Google, Inc. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style license\n// "
},
{
"path": "layers/endpoints_test.go",
"chars": 975,
"preview": "// Copyright 2017, Google, Inc. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style license\n//"
},
{
"path": "layers/enums.go",
"chars": 30255,
"preview": "// Copyright 2012 Google, Inc. All rights reserved.\n// Copyright 2009-2011 Andreas Krennmair. All rights reserved.\n//\n//"
},
{
"path": "layers/enums_generated.go",
"chars": 12848,
"preview": "// Copyright 2012 Google, Inc. All rights reserved.\n\npackage layers\n\n// Created by gen2.go, don't edit manually\n// Gener"
},
{
"path": "layers/erspan2.go",
"chars": 2906,
"preview": "// Copyright 2018 Google, Inc. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style license\n// "
},
{
"path": "layers/erspan2_test.go",
"chars": 1793,
"preview": "// Copyright 2018 Google, Inc. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style license\n// "
},
{
"path": "layers/etherip.go",
"chars": 1265,
"preview": "// Copyright 2012 Google, Inc. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style license\n// "
},
{
"path": "layers/ethernet.go",
"chars": 3757,
"preview": "// Copyright 2012 Google, Inc. All rights reserved.\n// Copyright 2009-2011 Andreas Krennmair. All rights reserved.\n//\n//"
},
{
"path": "layers/fddi.go",
"chars": 1063,
"preview": "// Copyright 2012 Google, Inc. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style license\n// "
},
{
"path": "layers/fuzz_layer.go",
"chars": 1244,
"preview": "// Copyright 2019 The GoPacket Authors. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style li"
},
{
"path": "layers/gen.go",
"chars": 2500,
"preview": "// Copyright 2012 Google, Inc. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style license\n// "
},
{
"path": "layers/gen2.go",
"chars": 2517,
"preview": "// Copyright 2012 Google, Inc. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style license\n// "
},
{
"path": "layers/gen_linted.sh",
"chars": 80,
"preview": "#!/bin/bash\n\nfor i in *.go; do golint $i | grep -q . || echo $i; done > .linted\n"
},
{
"path": "layers/geneve.go",
"chars": 4870,
"preview": "// Copyright 2016 Google, Inc. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style license\n// "
},
{
"path": "layers/geneve_test.go",
"chars": 6996,
"preview": "// Copyright 2016 Google, Inc. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style license\n// "
},
{
"path": "layers/gre.go",
"chars": 5522,
"preview": "// Copyright 2012 Google, Inc. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style license\n// "
},
{
"path": "layers/gre_test.go",
"chars": 13629,
"preview": "// Copyright 2012 Google, Inc. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style license\n// "
},
{
"path": "layers/gtp.go",
"chars": 5399,
"preview": "// Copyright 2017 Google, Inc. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style license\n// "
},
{
"path": "layers/gtp_test.go",
"chars": 6187,
"preview": "// Copyright 2017 Google, Inc. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style license\n// "
},
{
"path": "layers/iana_ports.go",
"chars": 235560,
"preview": "// Copyright 2012 Google, Inc. All rights reserved.\n\npackage layers\n\n// Created by gen.go, don't edit manually\n// Genera"
},
{
"path": "layers/icmp4.go",
"chars": 8162,
"preview": "// Copyright 2012 Google, Inc. All rights reserved.\n// Copyright 2009-2011 Andreas Krennmair. All rights reserved.\n//\n//"
},
{
"path": "layers/icmp6.go",
"chars": 8182,
"preview": "// Copyright 2012 Google, Inc. All rights reserved.\n// Copyright 2009-2011 Andreas Krennmair. All rights reserved.\n//\n//"
},
{
"path": "layers/icmp6NDflags_test.go",
"chars": 4476,
"preview": "// Copyright 2012, Google, Inc. All rights reserved.\n// Copyright 2009-2011 Andreas Krennmair. All rights reserved.\n//\n/"
},
{
"path": "layers/icmp6_test.go",
"chars": 3548,
"preview": "// Copyright 2012, Google, Inc. All rights reserved.\n// Copyright 2009-2011 Andreas Krennmair. All rights reserved.\n//\n/"
},
{
"path": "layers/icmp6hopbyhop_test.go",
"chars": 3251,
"preview": "// Copyright 2012, Google, Inc. All rights reserved.\n// Copyright 2009-2011 Andreas Krennmair. All rights reserved.\n//\n/"
},
{
"path": "layers/icmp6msg.go",
"chars": 17232,
"preview": "// Copyright 2012 Google, Inc. All rights reserved.\n// Copyright 2009-2011 Andreas Krennmair. All rights reserved.\n//\n//"
},
{
"path": "layers/icmp6msg_test.go",
"chars": 4405,
"preview": "// Copyright 2012, Google, Inc. All rights reserved.\n// Copyright 2009-2011 Andreas Krennmair. All rights reserved.\n//\n/"
},
{
"path": "layers/igmp.go",
"chars": 12760,
"preview": "// Copyright 2012 Google, Inc. All rights reserved.\n// Copyright 2009-2011 Andreas Krennmair. All rights reserved.\n//\n//"
},
{
"path": "layers/igmp_test.go",
"chars": 7574,
"preview": "// Copyright 2016, Google, Inc. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style license\n//"
},
{
"path": "layers/ip4.go",
"chars": 8513,
"preview": "// Copyright 2012 Google, Inc. All rights reserved.\n// Copyright 2009-2011 Andreas Krennmair. All rights reserved.\n//\n//"
},
{
"path": "layers/ip4_test.go",
"chars": 6020,
"preview": "// Copyright 2012 Google, Inc. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style license\n// "
},
{
"path": "layers/ip6.go",
"chars": 19758,
"preview": "// Copyright 2012 Google, Inc. All rights reserved.\n// Copyright 2009-2011 Andreas Krennmair. All rights reserved.\n//\n//"
},
{
"path": "layers/ip6_test.go",
"chars": 15621,
"preview": "// Copyright 2014, Google, Inc. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style license\n//"
},
{
"path": "layers/ipsec.go",
"chars": 2210,
"preview": "// Copyright 2012 Google, Inc. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style license\n// "
},
{
"path": "layers/ipsec_test.go",
"chars": 8124,
"preview": "// Copyright 2012, Google, Inc. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style license\n//"
},
{
"path": "layers/layertypes.go",
"chars": 26164,
"preview": "// Copyright 2012 Google, Inc. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style license\n// "
},
{
"path": "layers/lcm.go",
"chars": 6040,
"preview": "// Copyright 2018 Google, Inc. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style license\n// "
},
{
"path": "layers/lcm_test.go",
"chars": 3987,
"preview": "// Copyright 2018 Google, Inc. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style license\n// "
},
{
"path": "layers/linux_sll.go",
"chars": 2693,
"preview": "// Copyright 2012 Google, Inc. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style license\n// "
},
{
"path": "layers/llc.go",
"chars": 5213,
"preview": "// Copyright 2012 Google, Inc. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style license\n// "
},
{
"path": "layers/lldp.go",
"chars": 47915,
"preview": "// Copyright 2012 Google, Inc. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style license\n// "
},
{
"path": "layers/lldp_test.go",
"chars": 4567,
"preview": "// Copyright 2020 The GoPacket Authors. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style li"
},
{
"path": "layers/loopback.go",
"chars": 2293,
"preview": "// Copyright 2012 Google, Inc. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style license\n// "
},
{
"path": "layers/mldv1.go",
"chars": 5844,
"preview": "// Copyright 2018 GoPacket Authors. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style licens"
},
{
"path": "layers/mldv1_test.go",
"chars": 6445,
"preview": "// Copyright 2018 GoPacket Authors. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style licens"
},
{
"path": "layers/mldv2.go",
"chars": 19462,
"preview": "// Copyright 2018 GoPacket Authors. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style licens"
},
{
"path": "layers/mldv2_test.go",
"chars": 5977,
"preview": "// Copyright 2018 GoPacket Authors. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style licens"
},
{
"path": "layers/modbustcp.go",
"chars": 5442,
"preview": "// Copyright 2018, The GoPacket Authors, All rights reserved.\n//\n// Use of this source code is governed by a BSD-style l"
},
{
"path": "layers/mpls.go",
"chars": 2977,
"preview": "// Copyright 2012 Google, Inc. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style license\n// "
},
{
"path": "layers/mpls_test.go",
"chars": 4539,
"preview": "// Copyright 2016 Google, Inc. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style license\n// "
},
{
"path": "layers/ndp.go",
"chars": 26776,
"preview": "// Copyright 2012 Google, Inc. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style license\n// "
},
{
"path": "layers/ntp.go",
"chars": 18058,
"preview": "// Copyright 2016 Google, Inc. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style license\n// "
},
{
"path": "layers/ntp_test.go",
"chars": 8907,
"preview": "// Copyright 2016 Google, Inc. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style license\n// "
},
{
"path": "layers/ospf.go",
"chars": 21242,
"preview": "// Copyright 2017 Google, Inc. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style license\n// "
},
{
"path": "layers/ospf_test.go",
"chars": 45868,
"preview": "// Copyright 2017 Google, Inc. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style license\n// "
},
{
"path": "layers/pflog.go",
"chars": 2318,
"preview": "// Copyright 2012 Google, Inc. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style license\n// "
},
{
"path": "layers/ports.go",
"chars": 4479,
"preview": "// Copyright 2012 Google, Inc. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style license\n// "
},
{
"path": "layers/ppp.go",
"chars": 2417,
"preview": "// Copyright 2012 Google, Inc. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style license\n// "
},
{
"path": "layers/pppoe.go",
"chars": 1660,
"preview": "// Copyright 2012 Google, Inc. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style license\n// "
},
{
"path": "layers/prism.go",
"chars": 4694,
"preview": "// Copyright 2015 Google, Inc. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style license\n// "
},
{
"path": "layers/prism_test.go",
"chars": 8017,
"preview": "// Copyright 2014, Google, Inc. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style license\n//"
},
{
"path": "layers/radiotap.go",
"chars": 30247,
"preview": "// Copyright 2014 Google, Inc. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style license\n// "
},
{
"path": "layers/radiotap_test.go",
"chars": 3136,
"preview": "// Copyright 2012 Google, Inc. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style license\n// "
},
{
"path": "layers/radius.go",
"chars": 22511,
"preview": "// Copyright 2020 The GoPacket Authors. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style li"
},
{
"path": "layers/radius_test.go",
"chars": 16091,
"preview": "// Copyright 2020 The GoPacket Authors. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style li"
},
{
"path": "layers/rmcp.go",
"chars": 5428,
"preview": "// Copyright 2019 The GoPacket Authors. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style li"
},
{
"path": "layers/rmcp_test.go",
"chars": 2075,
"preview": "// Copyright 2019 The GoPacket Authors. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style li"
},
{
"path": "layers/rudp.go",
"chars": 2854,
"preview": "// Copyright 2012 Google, Inc. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style license\n// "
},
{
"path": "layers/sctp.go",
"chars": 22547,
"preview": "// Copyright 2012 Google, Inc. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style license\n// "
},
{
"path": "layers/sflow.go",
"chars": 99929,
"preview": "// Copyright 2014 Google, Inc. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style license\n// "
},
{
"path": "layers/sflow_test.go",
"chars": 75595,
"preview": "// Copyright 2014 Google, Inc. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style license\n// "
},
{
"path": "layers/sip.go",
"chars": 12967,
"preview": "// Copyright 2017 Google, Inc. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style license\n// "
},
{
"path": "layers/sip_test.go",
"chars": 12156,
"preview": "// Copyright 2017 Google, Inc. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style license\n// "
},
{
"path": "layers/stp.go",
"chars": 4438,
"preview": "// Copyright 2017 Google, Inc. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style license\n// "
},
{
"path": "layers/stp_test.go",
"chars": 4411,
"preview": "// Copyright 2021 Google, Inc. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style license\n// "
},
{
"path": "layers/tcp.go",
"chars": 9607,
"preview": "// Copyright 2012 Google, Inc. All rights reserved.\n// Copyright 2009-2011 Andreas Krennmair. All rights reserved.\n//\n//"
},
{
"path": "layers/tcp_test.go",
"chars": 3066,
"preview": "// Copyright 2016, Google, Inc. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style license\n//"
},
{
"path": "layers/tcpip.go",
"chars": 3329,
"preview": "// Copyright 2012 Google, Inc. All rights reserved.\n// Copyright 2009-2011 Andreas Krennmair. All rights reserved.\n//\n//"
},
{
"path": "layers/tcpip_test.go",
"chars": 4960,
"preview": "// Copyright 2014, Google, Inc. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style license\n//"
},
{
"path": "layers/test_creator.py",
"chars": 3683,
"preview": "#!/usr/bin/python\n# Copyright 2012 Google, Inc. All rights reserved.\n\n\"\"\"TestCreator creates test templates from pcap fi"
},
{
"path": "layers/testdata/fuzz/FuzzDecodeFromBytes/27d23183d8ce7b719228870c23869cf21bf8829d7160c82da88f80aeff2d861c",
"chars": 74,
"preview": "go test fuzz v1\n[]byte(\"0000000\\x10\\x10\\x00\\x01\\x01\\x01\\x01\\x01\\x01\\x00\")\n"
},
{
"path": "layers/testdata/fuzz/FuzzDecodeFromBytes/3b53f220d321f20980b59f64e1617d6b334b152a90b141a7407c3c8fa4837a31",
"chars": 43,
"preview": "go test fuzz v1\n[]byte(\"000000000000\\x00\")\n"
},
{
"path": "layers/testdata/fuzz/FuzzDecodeFromBytes/f539b7a397cf68c2129abd63d4c7cfb1979c489ad9bad6898510a4d4759bb85f",
"chars": 78,
"preview": "go test fuzz v1\n[]byte(\"01000\\x10\\x10\\xdfd\\x01\\x01\\x01\\x00d\\x01\\x01\\x01\\x00\")\n"
},
{
"path": "layers/testdata/fuzz/FuzzDecodeFromBytes/fe20300d6b2057b406a06ec4f04065f6d0dda6b2b362c0a89192c1933e927adf",
"chars": 55,
"preview": "go test fuzz v1\n[]byte(\"0000\\x00\\x00000000\\x010\\x000\")\n"
},
{
"path": "layers/tls.go",
"chars": 6919,
"preview": "// Copyright 2018 The GoPacket Authors. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style li"
},
{
"path": "layers/tls_alert.go",
"chars": 4905,
"preview": "// Copyright 2018 The GoPacket Authors. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style li"
},
{
"path": "layers/tls_appdata.go",
"chars": 827,
"preview": "// Copyright 2018 The GoPacket Authors. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style li"
},
{
"path": "layers/tls_cipherspec.go",
"chars": 1583,
"preview": "// Copyright 2018 The GoPacket Authors. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style li"
},
{
"path": "layers/tls_handshake.go",
"chars": 673,
"preview": "// Copyright 2018 The GoPacket Authors. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style li"
},
{
"path": "layers/tls_test.go",
"chars": 16108,
"preview": "// Copyright 2020 The GoPacket Authors. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style li"
},
{
"path": "layers/udp.go",
"chars": 3485,
"preview": "// Copyright 2012 Google, Inc. All rights reserved.\n// Copyright 2009-2011 Andreas Krennmair. All rights reserved.\n//\n//"
},
{
"path": "layers/udp_test.go",
"chars": 16277,
"preview": "// Copyright 2012, Google, Inc. All rights reserved.\n// Copyright 2009-2011 Andreas Krennmair. All rights reserved.\n//\n/"
},
{
"path": "layers/udplite.go",
"chars": 1318,
"preview": "// Copyright 2012 Google, Inc. All rights reserved.\n// Copyright 2009-2011 Andreas Krennmair. All rights reserved.\n//\n//"
},
{
"path": "layers/usb.go",
"chars": 8174,
"preview": "// Copyright 2014 Google, Inc. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style license\n// "
},
{
"path": "layers/usb_test.go",
"chars": 2627,
"preview": "// Copyright 2014, Google, Inc. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style license\n//"
},
{
"path": "layers/vrrp.go",
"chars": 5727,
"preview": "// Copyright 2016 Google, Inc. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style license\n// "
},
{
"path": "layers/vrrp_test.go",
"chars": 2179,
"preview": "// Copyright 2016 Google, Inc. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style license\n// "
},
{
"path": "layers/vxlan.go",
"chars": 4217,
"preview": "// Copyright 2016 Google, Inc. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style license\n// "
},
{
"path": "layers/vxlan_test.go",
"chars": 4877,
"preview": "// Copyright 2016 Google, Inc. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style license\n// "
},
{
"path": "layers_decoder.go",
"chars": 2826,
"preview": "// Copyright 2019 The GoPacket Authors. All rights reserved.\n\npackage gopacket\n\n// Created by gen.go, don't edit manuall"
},
{
"path": "layertype.go",
"chars": 3384,
"preview": "// Copyright 2012 Google, Inc. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style license\n// "
},
{
"path": "macs/benchmark_test.go",
"chars": 368,
"preview": "// Copyright 2012 Google, Inc. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style license\n// "
},
{
"path": "macs/doc.go",
"chars": 474,
"preview": "// Copyright 2012 Google, Inc. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style license\n// "
},
{
"path": "macs/gen.go",
"chars": 2574,
"preview": "// Copyright 2012 Google, Inc. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style license\n// "
},
{
"path": "macs/valid_mac_prefixes.go",
"chars": 1437062,
"preview": "// Copyright 2012 Google, Inc. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style license\n// "
},
{
"path": "packet.go",
"chars": 26994,
"preview": "// Copyright 2012 Google, Inc. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style license\n// "
},
{
"path": "packet_test.go",
"chars": 1593,
"preview": "// Copyright 2012 Google, Inc. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style license\n// "
},
{
"path": "parser.go",
"chars": 12582,
"preview": "// Copyright 2012 Google, Inc. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style license\n// "
},
{
"path": "pcap/bpf_test.go",
"chars": 1672,
"preview": "// Copyright 2018 The GoPacket Authors. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style li"
},
{
"path": "pcap/defs_windows_386.go",
"chars": 1582,
"preview": "// Copyright 2019 The GoPacket Authors. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style li"
},
{
"path": "pcap/defs_windows_amd64.go",
"chars": 1630,
"preview": "// Copyright 2019 The GoPacket Authors. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style li"
},
{
"path": "pcap/doc.go",
"chars": 4130,
"preview": "// Copyright 2012 Google, Inc. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style license\n// "
},
{
"path": "pcap/generate_defs.go",
"chars": 4282,
"preview": "// Copyright 2019 The GoPacket Authors. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style li"
},
{
"path": "pcap/gopacket_benchmark/benchmark.go",
"chars": 8050,
"preview": "// Copyright 2012 Google, Inc. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style license\n// "
},
{
"path": "pcap/pcap.go",
"chars": 26312,
"preview": "// Copyright 2012 Google, Inc. All rights reserved.\n// Copyright 2009-2011 Andreas Krennmair. All rights reserved.\n//\n//"
},
{
"path": "pcap/pcap_test.go",
"chars": 7859,
"preview": "// Copyright 2012 Google, Inc. All rights reserved.\n//\n// Use of this source code is governed by a BSD-style license\n// "
}
]
// ... and 98 more files (download for full content)
About this extraction
This page contains the full source code of the google/gopacket GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 298 files (3.7 MB), approximately 984.3k tokens, and a symbol index with 5291 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.