Documentation
¶
Index ¶
- Variables
- func DataRecordDecode(r *reader.Reader, AgentID string, localport int, m *MessageHeader, ...) (datarecord.DataFrame, error)
- func FieldValueDecode(r *reader.Reader, tr *TemplateFieldSpecifier) (interface{}, error)
- func HandleTemplateRecord(packet *Packet, msghdr *MessageHeader, flowsethdr *FlowSetHeader) error
- func IPFIXWorker(output chan *datarecord.DataFrame)
- func PacketParser(r *RawMessageUDP, outputChan chan *datarecord.DataFrame) error
- type FlowSetHeader
- type IPFIXCollector
- type MessageHeader
- type Packet
- type RawMessageUDP
- type TemplateFieldSpecifier
- type TemplateHeader
- type TemplateMapKey
- type TemplateRecord
Constants ¶
This section is empty.
Variables ¶
var IPFIXRawPacketChan = make(chan *RawMessageUDP, 100)
IPFIXRawPacketChan is used to dispatch raw packet to multi goroutine workers.
var TEMPLATE_DEBUG bool = false
var TemplateMap sync.Map
Functions ¶
func DataRecordDecode ¶
func DataRecordDecode(r *reader.Reader, AgentID string, localport int, m *MessageHeader, s *FlowSetHeader) (datarecord.DataFrame, error)
DataRecordDecode : decode function
func FieldValueDecode ¶
func FieldValueDecode(r *reader.Reader, tr *TemplateFieldSpecifier) (interface{}, error)
FieldValueDecode : a fv decode function
func HandleTemplateRecord ¶
func HandleTemplateRecord(packet *Packet, msghdr *MessageHeader, flowsethdr *FlowSetHeader) error
func IPFIXWorker ¶
func IPFIXWorker(output chan *datarecord.DataFrame)
func PacketParser ¶
func PacketParser(r *RawMessageUDP, outputChan chan *datarecord.DataFrame) error
Types ¶
type FlowSetHeader ¶
type FlowSetHeader struct { SetID uint16 Length uint16 IsTemplate bool //add istemplate for template cache handling... }
FlowSetHeader : RFC 7011 - 3.3.2. Set Header Format 0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Set ID | Length | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
func (*FlowSetHeader) Decode ¶
func (s *FlowSetHeader) Decode(r *reader.Reader) error
Decode : A method to parse FlowSetHeader
func (*FlowSetHeader) String ¶
func (s *FlowSetHeader) String() string
type IPFIXCollector ¶
type IPFIXCollector struct {
// contains filtered or unexported fields
}
func NewIPFIXCollector ¶
func NewIPFIXCollector(addr string, port int, outputChan chan *datarecord.DataFrame, workerNum int) *IPFIXCollector
func (*IPFIXCollector) Run ¶
func (i *IPFIXCollector) Run()
type MessageHeader ¶
type MessageHeader struct { Version uint16 Length uint16 ExportTime uint32 SeqNo uint32 DomainID uint32 }
MessageHeader : RFC 7011 - Message Header Format
0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Version Number | Length | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Export Time | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Sequence Number | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Observation Domain ID | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
func (*MessageHeader) Decode ¶
func (m *MessageHeader) Decode(r *reader.Reader) error
Decode : A method to parse MessageHeader
func (*MessageHeader) String ¶
func (m *MessageHeader) String() string
type RawMessageUDP ¶
type RawMessageUDP struct {
// contains filtered or unexported fields
}
type TemplateFieldSpecifier ¶
type TemplateFieldSpecifier struct { Key iedb.ElementKey Length uint16 Name string Type string Dtype iedb.DataType }
TemplateFieldSpecifier : RFC 7011 - 3.2. Field Specifier Format
0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |0| Information Element ident. | Field Length | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |1| Information Element ident. | Field Length | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Enterprise Number | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
type TemplateHeader ¶
TemplateHeader : RFC 7011 - 3.4.1 Template Record Format [Set ID == 2] 0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Template ID (> 255) | Field Count | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
OptionTemplateHeader : RFC 7011 - 3.4.2.2 Option Template Record Format [Set ID == 3] 0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Template ID (> 255) | Field Count | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Scope Field Count | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
type TemplateMapKey ¶
func NewTemplateMapKey ¶
func NewTemplateMapKey(AgentID string, LocalPort int, DomainID uint32, SetID uint16) TemplateMapKey
type TemplateRecord ¶
type TemplateRecord struct { DomainID uint32 SetID uint16 Header TemplateHeader FieldRecord []TemplateFieldSpecifier ScopeFieldRecord []TemplateFieldSpecifier }
TemplateRecord : This is an Exmaple 0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Set ID = 2 | Length | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Template ID = 256 | Field Count = N | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |1| Information Element id. 1.1 | Field Length 1.1 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Enterprise Number 1.1 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |0| Information Element id. 1.2 | Field Length 1.2 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | ... | ... | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |1| Information Element id. 1.N | Field Length 1.N | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Enterprise Number 1.N | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Template ID = 257 | Field Count = M | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |0| Information Element id. 2.1 | Field Length 2.1 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |1| Information Element id. 2.2 | Field Length 2.2 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Enterprise Number 2.2 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | ... | ... | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |1| Information Element id. 2.M | Field Length 2.M | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Enterprise Number 2.M | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Padding (opt) | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ OptionTemplate Example : RFC 7011 - 3.4.2.2 Option Template Record Format
0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Set ID = 3 | Length | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Template ID = 258 | Field Count = N + M | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Scope Field Count = N |0| Scope 1 Infor. Element id. | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Scope 1 Field Length |0| Scope 2 Infor. Element id. | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Scope 2 Field Length | ... | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | ... |1| Scope N Infor. Element id. | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Scope N Field Length | Scope N Enterprise Number ... +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ ... Scope N Enterprise Number |1| Option 1 Infor. Element id. | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Option 1 Field Length | Option 1 Enterprise Number ... +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ ... Option 1 Enterprise Number | ... | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | ... |0| Option M Infor. Element id. | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Option M Field Length | Padding (optional) | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
The example shows an Options Template Set with mixed IANA-assigned and enterprise-specific Information Elements. It consists of a Set Header, an Options Template Header, and several Field Specifiers.
func FetchTemplateMap ¶
func FetchTemplateMapByKey ¶
func FetchTemplateMapByKey(key TemplateMapKey) (TemplateRecord, error)
func (*TemplateRecord) Decode ¶
func (t *TemplateRecord) Decode(r *reader.Reader, m *MessageHeader, s *FlowSetHeader) error
Decode : This is a method to decode template and option template set
func (*TemplateRecord) String ¶
func (t *TemplateRecord) String() string