forked from google/gopacket
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add EtherIP and IP4/6 encapsulation in IP packets.
- Loading branch information
Showing
4 changed files
with
53 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// Copyright (c) 2012 Google, Inc. All rights reserved. | ||
|
||
package gopacket | ||
|
||
import ( | ||
"encoding/binary" | ||
"errors" | ||
) | ||
|
||
// EtherIP is the struct for storing RFC 3378 EtherIP packet headers. | ||
type EtherIP struct { | ||
Version uint8 | ||
Reserved uint16 | ||
} | ||
|
||
// LayerType returns LayerTypeEtherIP. | ||
func (e *EtherIP) LayerType() LayerType { return LayerTypeEtherIP } | ||
|
||
func decodeEtherIP(data []byte) (out DecodeResult, _ error) { | ||
out.DecodedLayer = &EtherIP{ | ||
Version: data[0] >> 4, | ||
Reserved: binary.BigEndian.Uint16(data[:2]) & 0x0fff, | ||
} | ||
out.NextDecoder = decodeEthernet | ||
out.RemainingBytes = data[2:] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters