forked from CiscoDevNet/bigmuddy-network-telemetry-pipeline
-
Notifications
You must be signed in to change notification settings - Fork 0
/
encap.go
42 lines (36 loc) · 994 Bytes
/
encap.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
//
// February 2016, cisco
//
// Copyright (c) 2016 by cisco Systems, Inc.
// All rights reserved.
//
//
// Encap factory
package main
import (
"fmt"
)
type encapParser interface {
//
// nextBlockBuffer, nextBlock
// Based on the current state, provide the next fixed length
// buffer to read. Note this type of encap works for encoding
// where the length of the header or payload to collect next
// is known a priori (typical of TLV encoding).
//
nextBlockBuffer() (error, *[]byte)
nextBlock(nextBlock []byte, source msgproducer) (error, []dataMsg)
}
//
// Fetch and an encapParser for type (encap) corresponding to the
// encap, and indicate which pipeline node (name), and external
// producer involved (producer).
func getNewEncapParser(name string, encap string, msgproducer msgproducer) (
error, encapParser) {
switch encap {
case "st":
err, p := getNewEncapSTParser(name, msgproducer)
return err, p
}
return fmt.Errorf("ENCAP: failed to produce parser"), nil
}