Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implemented suport for NortelDiscovery
- Loading branch information
Showing
7 changed files
with
976 additions
and
692 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* NETCAP - Traffic Analysis Framework | ||
* Copyright (c) 2017 Philipp Mieden <dreadl0ck [at] protonmail [dot] ch> | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
*/ | ||
|
||
package encoder | ||
|
||
import ( | ||
"github.com/dreadl0ck/netcap/types" | ||
"github.com/golang/protobuf/proto" | ||
"github.com/google/gopacket" | ||
"github.com/google/gopacket/layers" | ||
) | ||
|
||
var nortelDiscoveryEncoder = CreateLayerEncoder(types.Type_NC_NortelDiscovery, layers.LayerTypeNortelDiscovery, func(layer gopacket.Layer, timestamp string) proto.Message { | ||
if nortel, ok := layer.(*layers.NortelDiscovery); ok { | ||
return &types.NortelDiscovery{ | ||
Timestamp: timestamp, | ||
IPAddress: string(nortel.IPAddress), | ||
SegmentID: []byte(nortel.SegmentID), | ||
Chassis: int32(nortel.Chassis), | ||
Backplane: int32(nortel.Backplane), | ||
State: int32(nortel.State), | ||
NumLinks: int32(nortel.NumLinks), | ||
} | ||
} | ||
return nil | ||
}) |
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
Large diffs are not rendered by default.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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,44 @@ | ||
/* | ||
* NETCAP - Traffic Analysis Framework | ||
* Copyright (c) 2017 Philipp Mieden <dreadl0ck [at] protonmail [dot] ch> | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
*/ | ||
|
||
package types | ||
|
||
import "encoding/hex" | ||
|
||
func (a NortelDiscovery) CSVHeader() []string { | ||
return filter([]string{ | ||
"Timestamp", | ||
"IPAddress", // string | ||
"SegmentID", // []byte | ||
"Chassis", // int32 | ||
"Backplane", // int32 | ||
"State", // int32 | ||
"NumLinks", // int32 | ||
}) | ||
} | ||
|
||
func (a NortelDiscovery) CSVRecord() []string { | ||
return filter([]string{ | ||
formatTimestamp(a.Timestamp), | ||
a.IPAddress, // string | ||
hex.EncodeToString(a.SegmentID), // []byte | ||
formatInt32(a.Chassis), // int32 | ||
formatInt32(a.Backplane), // int32 | ||
formatInt32(a.State), // int32 | ||
formatInt32(a.NumLinks), // int32 | ||
}) | ||
} | ||
|
||
func (a NortelDiscovery) NetcapTimestamp() string { | ||
return a.Timestamp | ||
} |