forked from Cistern/sflow
/
ethernet_frame_flow.go
80 lines (69 loc) · 2.06 KB
/
ethernet_frame_flow.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
package records
import (
"fmt"
//"bytes"
"encoding/binary"
"io"
)
type EthernetFrameFlow struct {
Dot3StatsAlignmentErrors uint32
Dot3StatsFCSErrors uint32
Dot3StatsSingleCollisionFrames uint32
Dot3StatsMultipleCollisionFrames uint32
Dot3StatsSQETestErrors uint32
Dot3StatsDeferredTransmissions uint32
Dot3StatsLateCollisions uint32
Dot3StatsExcessiveCollisions uint32
Dot3StatsInternalMacTransmitErrors uint32
Dot3StatsCarrierSenseErrors uint32
Dot3StatsFrameTooLongs uint32
Dot3StatsInternalMacReceiveErrors uint32
Dot3StatsSymbolErrors uint32
/*
struct ethernet_counters {
unsigned int dot3StatsAlignmentErrors;
unsigned int dot3StatsFCSErrors;
unsigned int dot3StatsSingleCollisionFrames;
unsigned int dot3StatsMultipleCollisionFrames;
unsigned int dot3StatsSQETestErrors;
unsigned int dot3StatsDeferredTransmissions;
unsigned int dot3StatsLateCollisions;
unsigned int dot3StatsExcessiveCollisions;
unsigned int dot3StatsInternalMacTransmitErrors;
unsigned int dot3StatsCarrierSenseErrors;
unsigned int dot3StatsFrameTooLongs;
unsigned int dot3StatsInternalMacReceiveErrors;
unsigned int dot3StatsSymbolErrors;
}
*/
}
func (f EthernetFrameFlow) String() string {
type X EthernetFrameFlow
x := X(f)
return fmt.Sprintf("EthernetFrameFlow: %+v", x)
}
// RecordType returns the type of flow record.
func (f EthernetFrameFlow) RecordType() int {
return TypeEthernetFrameFlowRecord
}
// RecordName returns the Name of this flow record
func (f EthernetFrameFlow) RecordName() string {
return "EthernerFrameFlow"
}
func DecodeEthernetFrameFlow(r io.Reader) (EthernetFrameFlow, error) {
f := EthernetFrameFlow{}
var err error
err = binary.Read(r, binary.BigEndian, &f)
if err != nil {
return f, err
}
return f, err
}
func (f EthernetFrameFlow) Encode(w io.Writer) error {
var err error
err = binary.Write(w, binary.BigEndian, f)
if err != nil {
return err
}
return nil
}