goflow2
goflow2 copied to clipboard
Problem with decoding of packet
I used next code: ` import ( "fmt" "github.com/netsampler/goflow2/decoders/netflow" )
...
b := bytes.NewBuffer(data)
templates := netflow.CreateTemplateSystem()
m, err := netflow.DecodeMessage(b, templates)
if err != nil {
return err
}
fmt.Println(m)
` After decoding I have next error: "No info template 257 found for and domain id 58"
How I can fix it?
Hi @gitchander
You are trying to decode a NetFlow/IPFIX packet for which you do not have the template.
This is how the protocol works: the templates indicate how long each field is in the data ensuring little repetition.
This error can be intercepted by checking errors.Is(netflow.ErrorTemplateNotFound).
Thanks for explaining! I have already fixed it.
I was able intercepted this error next way:
errTNF, ok := err.(*netflow.ErrorTemplateNotFound)
if ok {
fmt.Println(errTNF)
}
Next code is not worked:
v := &(netflow.ErrorTemplateNotFound{})
if errors.Is(err, v) {
// not intercepted
}