11package sflow
22
3- import (
4- "fmt"
5- "net"
6- )
3+ import "github.com/netsampler/goflow2/v2/decoders/utils"
74
85type SampledHeader struct {
96 Protocol uint32 `json:"protocol"`
@@ -14,26 +11,20 @@ type SampledHeader struct {
1411}
1512
1613type SampledEthernet struct {
17- Length uint32 `json:"length"`
18- SrcMac MacAddress `json:"src-mac"`
19- DstMac MacAddress `json:"dst-mac"`
20- EthType uint32 `json:"eth-type"`
14+ Length uint32 `json:"length"`
15+ SrcMac utils. MacAddress `json:"src-mac"`
16+ DstMac utils. MacAddress `json:"dst-mac"`
17+ EthType uint32 `json:"eth-type"`
2118}
2219
2320type SampledIPBase struct {
24- Length uint32 `json:"length"`
25- Protocol uint32 `json:"protocol"`
26- SrcIP IPAddress `json:"src-ip"`
27- DstIP IPAddress `json:"dst-ip"`
28- SrcPort uint32 `json:"src-port"`
29- DstPort uint32 `json:"dst-port"`
30- TcpFlags uint32 `json:"tcp-flags"`
31- }
32-
33- type MacAddress []byte // purely for the formatting purpose
34-
35- func (s * MacAddress ) MarshalJSON () ([]byte , error ) {
36- return []byte (fmt .Sprintf ("\" %s\" " , net .HardwareAddr ([]byte (* s )).String ())), nil
21+ Length uint32 `json:"length"`
22+ Protocol uint32 `json:"protocol"`
23+ SrcIP utils.IPAddress `json:"src-ip"`
24+ DstIP utils.IPAddress `json:"dst-ip"`
25+ SrcPort uint32 `json:"src-port"`
26+ DstPort uint32 `json:"dst-port"`
27+ TcpFlags uint32 `json:"tcp-flags"`
3728}
3829
3930type SampledIPv4 struct {
@@ -54,25 +45,25 @@ type ExtendedSwitch struct {
5445}
5546
5647type ExtendedRouter struct {
57- NextHopIPVersion uint32 `json:"next-hop-ip-version"`
58- NextHop IPAddress `json:"next-hop"`
59- SrcMaskLen uint32 `json:"src-mask-len"`
60- DstMaskLen uint32 `json:"dst-mask-len"`
48+ NextHopIPVersion uint32 `json:"next-hop-ip-version"`
49+ NextHop utils. IPAddress `json:"next-hop"`
50+ SrcMaskLen uint32 `json:"src-mask-len"`
51+ DstMaskLen uint32 `json:"dst-mask-len"`
6152}
6253
6354type ExtendedGateway struct {
64- NextHopIPVersion uint32 `json:"next-hop-ip-version"`
65- NextHop IPAddress `json:"next-hop"`
66- AS uint32 `json:"as"`
67- SrcAS uint32 `json:"src-as"`
68- SrcPeerAS uint32 `json:"src-peer-as"`
69- ASDestinations uint32 `json:"as-destinations"`
70- ASPathType uint32 `json:"as-path-type"`
71- ASPathLength uint32 `json:"as-path-length"`
72- ASPath []uint32 `json:"as-path"`
73- CommunitiesLength uint32 `json:"communities-length"`
74- Communities []uint32 `json:"communities"`
75- LocalPref uint32 `json:"local-pref"`
55+ NextHopIPVersion uint32 `json:"next-hop-ip-version"`
56+ NextHop utils. IPAddress `json:"next-hop"`
57+ AS uint32 `json:"as"`
58+ SrcAS uint32 `json:"src-as"`
59+ SrcPeerAS uint32 `json:"src-peer-as"`
60+ ASDestinations uint32 `json:"as-destinations"`
61+ ASPathType uint32 `json:"as-path-type"`
62+ ASPathLength uint32 `json:"as-path-length"`
63+ ASPath []uint32 `json:"as-path"`
64+ CommunitiesLength uint32 `json:"communities-length"`
65+ Communities []uint32 `json:"communities"`
66+ LocalPref uint32 `json:"local-pref"`
7667}
7768
7869type IfCounters struct {
0 commit comments