Skip to content
Permalink
Browse files

implemented suport for NortelDiscovery

  • Loading branch information...
dreadl0ck committed Jan 13, 2019
1 parent 88fe7ae commit e5e0b5fa0e0421f616620129622232b34727a198
Showing with 976 additions and 692 deletions.
  1. +36 −0 encoder/nortelDiscovery.go
  2. +2 −0 netcap.go
  3. +10 −0 netcap.proto
  4. +784 −689 types/netcap.pb.go
  5. +11 −0 types/netcap_pb.rb
  6. +89 −3 types/netcap_pb2.py
  7. +44 −0 types/nortelDiscovery.go
@@ -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
})
@@ -140,6 +140,8 @@ func InitRecord(typ types.Type) (record proto.Message) {
record = new(types.CiscoDiscovery)
case types.Type_NC_CiscoDiscoveryInfo:
record = new(types.CiscoDiscoveryInfo)
case types.Type_NC_NortelDiscovery:
record = new(types.NortelDiscovery)
default:
panic("InitRecord: unknown type: " + typ.String())
}
@@ -131,6 +131,7 @@ enum Type {
NC_CiscoDiscovery = 83;
NC_CiscoDiscoveryInfo = 84;
NC_USBRequestBlockSetup = 85;
NC_NortelDiscovery = 86;
}

/*
@@ -1432,3 +1433,12 @@ message IPNet {
string IPMask = 2; // network mask
}

message NortelDiscovery {
string Timestamp = 1;
string IPAddress = 2;
bytes SegmentID = 3;
int32 Chassis = 4;
int32 Backplane = 5;
int32 State = 6;
int32 NumLinks = 7;
}

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more.

Large diffs are not rendered by default.

@@ -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
}

0 comments on commit e5e0b5f

Please sign in to comment.
You can’t perform that action at this time.