MCPcopy Index your code
hub / github.com/Edgio/vflow / Decode

Method Decode

ipfix/decoder.go:105–136  ·  view source on GitHub ↗

Decode decodes the IPFIX raw data

(mem MemCache)

Source from the content-addressed store, hash-verified

103
104// Decode decodes the IPFIX raw data
105func (d *Decoder) Decode(mem MemCache) (*Message, error) {
106 var msg = new(Message)
107
108 // IPFIX Message Header decoding
109 if err := msg.Header.unmarshal(d.reader); err != nil {
110 return nil, err
111 }
112 // IPFIX Message Header validation
113 if err := msg.Header.validate(); err != nil {
114 return nil, err
115 }
116
117 // Add source IP address as Agent ID
118 msg.AgentID = d.raddr.String()
119
120 // In case there are multiple non-fatal errors, collect them and report all of them.
121 // The rest of the received sets will still be interpreted, until a fatal error is encountered.
122 // A non-fatal error is for example an illegal data record or unknown template id.
123 var decodeErrors []error
124 for d.reader.Len() > 4 {
125 if err := d.decodeSet(mem, msg); err != nil {
126 switch err.(type) {
127 case nonfatalError:
128 decodeErrors = append(decodeErrors, err)
129 default:
130 return nil, err
131 }
132 }
133 }
134
135 return msg, combineErrors(decodeErrors...)
136}
137
138// RFC 7011 - part 3.B IPFIX Message Format
139// +----------------------------------------------------+

Callers 12

netflowV5WorkerMethod · 0.95
ipfixWorkerMethod · 0.95
netflowV9WorkerMethod · 0.95
TestMemCacheRetrieveFunction · 0.95
TestDecodeNoDataFunction · 0.95
TestDecodeTemplateFunction · 0.95
TestDecodeOptsTemplateFunction · 0.95
BenchmarkDecodeTemplateFunction · 0.95
TestMultiMessageFunction · 0.95
TestDecodeDataTplFunction · 0.95

Calls 6

decodeSetMethod · 0.95
StringMethod · 0.80
LenMethod · 0.80
combineErrorsFunction · 0.70
unmarshalMethod · 0.45
validateMethod · 0.45

Tested by 9

TestMemCacheRetrieveFunction · 0.76
TestDecodeNoDataFunction · 0.76
TestDecodeTemplateFunction · 0.76
TestDecodeOptsTemplateFunction · 0.76
BenchmarkDecodeTemplateFunction · 0.76
TestMultiMessageFunction · 0.76
TestDecodeDataTplFunction · 0.76