Vendor update gopacket and unix package

This commit is contained in:
Manjunath A Kumatagi committed 2019-02-01 21:28:56 -06:00
1 parent 54d24e65ef
commit 43d3339b39
319 files changed
+91339 -13246

No files matched your search

+7 -2
View File
@@ -22,6 +22,8 @@ useful, including:
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.
Basic Usage
gopacket takes in packet data as a []byte and decodes it into a packet with
@@ -288,7 +290,10 @@ the packet's information. A quick example:
parser := gopacket.NewDecodingLayerParser(layers.LayerTypeEthernet, &eth, &ip4, &ip6, &tcp)
decoded := []gopacket.LayerType{}
for packetData := range somehowGetPacketData() {
err := parser.DecodeLayers(packetData, &decoded)
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:
@@ -329,7 +334,7 @@ the following manner:
}
buf := gopacket.NewSerializeBuffer()
opts := gopacket.SerializeOptions{} // See SerializeOptions for more details.
err := ip.SerializeTo(&buf, opts)
err := ip.SerializeTo(buf, opts)
if err != nil { panic(err) }
fmt.Println(buf.Bytes()) // prints out a byte slice containing the serialized IPv4 layer.