diff --git a/protocols/isis/packet/csnp.go b/protocols/isis/packet/csnp.go index 40c121036b79c9d19378467b31b4f245288db1fd..58aa5ad2b8c120d92d0de88519d4395e06b37d33 100644 --- a/protocols/isis/packet/csnp.go +++ b/protocols/isis/packet/csnp.go @@ -7,6 +7,7 @@ import ( "sort" "github.com/bio-routing/bio-rd/protocols/isis/types" + "github.com/bio-routing/bio-rd/util/decode" "github.com/taktv6/tflow2/convert" ) @@ -129,7 +130,7 @@ func DecodeCSNP(buf *bytes.Buffer) (*CSNP, error) { &csnp.EndLSPID.PseudonodeID, } - err := decode(buf, fields) + err := decode.Decode(buf, fields) if err != nil { return nil, fmt.Errorf("Unable to decode fields: %v", err) } diff --git a/protocols/isis/packet/decoder.go b/protocols/isis/packet/decoder.go deleted file mode 100644 index 99e28cb33f33fbe2eab466792191dd2e094a1848..0000000000000000000000000000000000000000 --- a/protocols/isis/packet/decoder.go +++ /dev/null @@ -1,26 +0,0 @@ -package packet - -import ( - "bytes" - "encoding/binary" - "fmt" -) - -func decode(buf *bytes.Buffer, fields []interface{}) error { - var err error - for _, field := range fields { - switch field := field.(type) { - case *[6]byte: - _, err := buf.Read(field[:]) - if err != nil { - return fmt.Errorf("Unable to read from buffer: %v", err) - } - default: - err = binary.Read(buf, binary.BigEndian, field) - if err != nil { - return fmt.Errorf("Unable to read from buffer: %v", err) - } - } - } - return nil -} diff --git a/protocols/isis/packet/header.go b/protocols/isis/packet/header.go index 6269fe1c17b55e4f68d820fafec6e7400e82f1fe..ca627d2da1597c5069a8c4a774b51d931b2deb74 100644 --- a/protocols/isis/packet/header.go +++ b/protocols/isis/packet/header.go @@ -3,8 +3,11 @@ package packet import ( "bytes" "fmt" + + "github.com/bio-routing/bio-rd/util/decode" ) +// ISISHeader represents an ISIS header type ISISHeader struct { ProtoDiscriminator uint8 LengthIndicator uint8 @@ -15,18 +18,8 @@ type ISISHeader struct { MaxAreaAddresses uint8 } -func (h *ISISHeader) Serialize(buf *bytes.Buffer) { - buf.WriteByte(h.ProtoDiscriminator) - buf.WriteByte(h.LengthIndicator) - buf.WriteByte(h.ProtocolIDExtension) - buf.WriteByte(h.IDLength) - buf.WriteByte(h.PDUType) - buf.WriteByte(h.Version) - buf.WriteByte(0) // Reserved - buf.WriteByte(h.MaxAreaAddresses) -} - -func decodeHeader(buf *bytes.Buffer) (*ISISHeader, error) { +// DecodeHeader decodes an ISIS header +func DecodeHeader(buf *bytes.Buffer) (*ISISHeader, error) { h := &ISISHeader{} dsap := uint8(0) ssap := uint8(0) @@ -47,10 +40,22 @@ func decodeHeader(buf *bytes.Buffer) (*ISISHeader, error) { &h.MaxAreaAddresses, } - err := decode(buf, fields) + err := decode.Decode(buf, fields) if err != nil { return nil, fmt.Errorf("Unable to decode fields: %v", err) } return h, nil } + +// Serialize serializes an ISIS header +func (h *ISISHeader) Serialize(buf *bytes.Buffer) { + buf.WriteByte(h.ProtoDiscriminator) + buf.WriteByte(h.LengthIndicator) + buf.WriteByte(h.ProtocolIDExtension) + buf.WriteByte(h.IDLength) + buf.WriteByte(h.PDUType) + buf.WriteByte(h.Version) + buf.WriteByte(0) // Reserved + buf.WriteByte(h.MaxAreaAddresses) +} diff --git a/protocols/isis/packet/header_test.go b/protocols/isis/packet/header_test.go index 2d39eb688a0fcab0f9d5be0c55b463a7761b6340..9e4a04f835dd9333bd713689f3d36a95bea6d52a 100644 --- a/protocols/isis/packet/header_test.go +++ b/protocols/isis/packet/header_test.go @@ -7,7 +7,74 @@ import ( "github.com/stretchr/testify/assert" ) -func TestHeaderEncode(t *testing.T) { +func TestHeaderDecode(t *testing.T) { + tests := []struct { + name string + input []byte + wantFail bool + expected *ISISHeader + }{ + { + name: "Full", + input: []byte{ + 0, 0, 0, // SNAP + 0x83, + 27, + 0, + 0, + 16, + 1, + 0, + 0, + }, + wantFail: false, + expected: &ISISHeader{ + ProtoDiscriminator: 0x83, + LengthIndicator: 27, + ProtocolIDExtension: 0, + IDLength: 0, + PDUType: 16, + Version: 1, + MaxAreaAddresses: 0, + }, + }, + { + name: "Partial", + input: []byte{ + 0, 0, 0, // SNAP + 0x83, + 27, + 0, + 0, + 16, + 1, + 0, + }, + wantFail: true, + }, + } + + for _, test := range tests { + buf := bytes.NewBuffer(test.input) + hdr, err := DecodeHeader(buf) + if err != nil { + if test.wantFail { + continue + } + t.Errorf("Unexpected failure for test %q: %v", test.name, err) + continue + } + + if test.wantFail { + t.Errorf("Unexpected success for test %q", test.name) + continue + } + + assert.Equalf(t, test.expected, hdr, "Test %q", test.name) + } +} + +func TestHeaderSerialize(t *testing.T) { tests := []struct { name string input *ISISHeader diff --git a/protocols/isis/packet/hello.go b/protocols/isis/packet/hello.go index d40d4383ce4b9931843c27e2e06109f93cc3d544..07dc9dc5fbd860027b8d8aa3c843c26cf58ed9c3 100644 --- a/protocols/isis/packet/hello.go +++ b/protocols/isis/packet/hello.go @@ -5,9 +5,11 @@ import ( "fmt" "github.com/bio-routing/bio-rd/protocols/isis/types" + "github.com/bio-routing/bio-rd/util/decode" "github.com/taktv6/tflow2/convert" ) +// L2Hello represents a broadcast L2 hello type L2Hello struct { CircuitType uint8 SystemID [6]byte @@ -18,6 +20,7 @@ type L2Hello struct { TLVs []TLV } +// P2PHello represents a Point to Point Hello type P2PHello struct { CircuitType uint8 SystemID types.SystemID @@ -33,6 +36,7 @@ const ( L2CircuitType = 2 ) +// Serialize serializes a P2P Hello func (h *P2PHello) Serialize(buf *bytes.Buffer) { buf.WriteByte(h.CircuitType) buf.Write(h.SystemID[:]) @@ -45,7 +49,8 @@ func (h *P2PHello) Serialize(buf *bytes.Buffer) { } } -func decodeISISP2PHello(buf *bytes.Buffer) (*P2PHello, error) { +// DecodeP2PHello decodes a P2P Hello +func DecodeP2PHello(buf *bytes.Buffer) (*P2PHello, error) { pdu := &P2PHello{} fields := []interface{}{ @@ -56,7 +61,7 @@ func decodeISISP2PHello(buf *bytes.Buffer) (*P2PHello, error) { &pdu.LocalCircuitID, } - err := decode(buf, fields) + err := decode.Decode(buf, fields) if err != nil { return nil, fmt.Errorf("Unable to decode fields: %v", err) } @@ -70,7 +75,8 @@ func decodeISISP2PHello(buf *bytes.Buffer) (*P2PHello, error) { return pdu, nil } -func decodeISISL2Hello(buf *bytes.Buffer) (*L2Hello, error) { +// DecodeL2Hello decodes an ISIS broadcast L2 hello +func DecodeL2Hello(buf *bytes.Buffer) (*L2Hello, error) { pdu := &L2Hello{} reserved := uint8(0) fields := []interface{}{ @@ -83,7 +89,7 @@ func decodeISISL2Hello(buf *bytes.Buffer) (*L2Hello, error) { &pdu.DesignatedIS, } - err := decode(buf, fields) + err := decode.Decode(buf, fields) if err != nil { return nil, fmt.Errorf("Unable to decode fields: %v", err) } diff --git a/protocols/isis/packet/hello_test.go b/protocols/isis/packet/hello_test.go index 6996d3f9c91f5443f877f283d7e8e826630b35de..a7b224356995896160fe1abd816303ab86f75025 100644 --- a/protocols/isis/packet/hello_test.go +++ b/protocols/isis/packet/hello_test.go @@ -1,58 +1,169 @@ package packet import ( - /*"bytes" + "bytes" "testing" "github.com/bio-routing/bio-rd/protocols/isis/types" - "github.com/stretchr/testify/assert"*/ + "github.com/stretchr/testify/assert" ) -/*func TestDecodeISISHello(t *testing.T) { +func TestP2PHelloSerialize(t *testing.T) { + tests := []struct { + name string + input *P2PHello + expected []byte + }{ + { + name: "Full", + input: &P2PHello{ + CircuitType: 2, + SystemID: types.SystemID{1, 2, 3, 4, 5, 6}, + HoldingTimer: 27, + PDULength: 19, + LocalCircuitID: 1, + TLVs: []TLV{ + &AreaAddressesTLV{ + TLVType: 1, + TLVLength: 4, + AreaIDs: []types.AreaID{ + { + 1, 2, 3, + }, + }, + }, + }, + }, + expected: []byte{ + 2, // Circuit Type + 1, 2, 3, 4, 5, 6, // SystemID + 0, 27, // Holding Timer + 0, 19, // PDU Length + 1, // Local Circuits ID + 1, // Area addresses TLV + 4, // TLV Length + 3, // Area length + 1, 2, 3, // Area + }, + }, + } + + for _, test := range tests { + buf := bytes.NewBuffer(nil) + test.input.Serialize(buf) + + assert.Equalf(t, test.expected, buf.Bytes(), "Test %q", test.name) + } +} + +func TestDecodeP2PHello(t *testing.T) { tests := []struct { name string input []byte wantFail bool - expected *L2Hello + expected *P2PHello }{ { - name: "No TLVs", + name: "Full", input: []byte{ - 2, - 1, 2, 3, 4, 5, 6, - 0, 200, - 0, 18, - 150, - 0, - 1, 1, 1, 2, 2, 2, + 2, // Circuit Type + 1, 2, 3, 4, 5, 6, // SystemID + 0, 27, // Holding Timer + 0, 19, // PDU Length + 1, // Local Circuits ID + 1, // Area addresses TLV + 4, // TLV Length + 3, // Area length + 1, 2, 3, // Area }, - expected: &L2Hello{ - CircuitType: 2, - SystemID: [6]byte{1, 2, 3, 4, 5, 6}, - HoldingTimer: 200, - PDULength: 18, - Priority: 150, - DesignatedIS: [6]byte{1, 1, 1, 2, 2, 2}, - TLVs: []TLV{}, + wantFail: false, + expected: &P2PHello{ + CircuitType: 2, + SystemID: types.SystemID{1, 2, 3, 4, 5, 6}, + HoldingTimer: 27, + PDULength: 19, + LocalCircuitID: 1, + TLVs: []TLV{ + &AreaAddressesTLV{ + TLVType: 1, + TLVLength: 4, + AreaIDs: []types.AreaID{ + { + 1, 2, 3, + }, + }, + }, + }, + }, + }, + { + name: "Incomplete hello", + input: []byte{ + 2, // Circuit Type + 1, 2, 3, 4, 5, 6, // SystemID + 0, 27, // Holding Timer + 0, 19, // PDU Length }, + wantFail: true, }, { - name: "Unknown TLVs", + name: "Incomplete TLV", + input: []byte{ + 2, // Circuit Type + 1, 2, 3, 4, 5, 6, // SystemID + 0, 27, // Holding Timer + 0, 19, // PDU Length + 1, // Local Circuits ID + 1, // Area addresses TLV + 4, // TLV Length + }, + wantFail: true, + }, + } + + for _, test := range tests { + buf := bytes.NewBuffer(test.input) + pkt, err := DecodeP2PHello(buf) + if err != nil { + if test.wantFail { + continue + } + t.Errorf("Unexpected failure for test %q: %v", test.name, err) + continue + } + + if test.wantFail { + t.Errorf("Unexpected success for test %q", test.name) + continue + } + + assert.Equalf(t, test.expected, pkt, "Test %q", test.name) + } +} + +func TestDecodeISISHello(t *testing.T) { + tests := []struct { + name string + input []byte + wantFail bool + expected *L2Hello + }{ + { + name: "No TLVs", input: []byte{ 2, 1, 2, 3, 4, 5, 6, 0, 200, - 0, 22, + 0, 18, 150, 0, 1, 1, 1, 2, 2, 2, - 0, 2, 10, 10, }, expected: &L2Hello{ CircuitType: 2, SystemID: [6]byte{1, 2, 3, 4, 5, 6}, HoldingTimer: 200, - PDULength: 22, + PDULength: 18, Priority: 150, DesignatedIS: [6]byte{1, 1, 1, 2, 2, 2}, TLVs: []TLV{}, @@ -70,7 +181,7 @@ import ( 1, 1, 1, 2, 2, 2, 6, 6, - 2, 2, 2, 3, 3, 3, 3, + 2, 2, 2, 3, 3, 3, }, expected: &L2Hello{ CircuitType: 2, @@ -108,8 +219,8 @@ import ( 4, 10, 0, 0, 0, 1, - 6, - 49, 10, 0, 0, 20, 30, + 7, + 6, 49, 10, 0, 0, 20, 30, }, expected: &L2Hello{ CircuitType: 2, @@ -136,7 +247,7 @@ import ( }, &AreaAddressesTLV{ TLVType: 1, - TLVLength: 6, + TLVLength: 7, AreaIDs: []types.AreaID{ { 49, 10, 0, 0, 20, 30, @@ -150,7 +261,7 @@ import ( for _, test := range tests { buffer := bytes.NewBuffer(test.input) - pdu, err := decodeISISHello(buffer) + pdu, err := DecodeL2Hello(buffer) if err != nil { if test.wantFail { @@ -168,4 +279,4 @@ import ( assert.Equalf(t, test.expected, pdu, "Test: %q", test.name) } -}*/ +} diff --git a/protocols/isis/packet/isis.go b/protocols/isis/packet/isis.go index 1fd750bc9a339556325d3a29b3652a6b406b0c2f..71aee6ccc8a59f99f449413ed736081057bd7b06 100644 --- a/protocols/isis/packet/isis.go +++ b/protocols/isis/packet/isis.go @@ -18,18 +18,20 @@ const ( DOWN_STATE = 2 INITIALIZING_STATE = 1 - UP_STATE = 0 + UP_STATE = 0 ) +// ISISPacket represents an ISIS packet type ISISPacket struct { Header *ISISHeader Body interface{} } +// Decode decodes ISIS packets func Decode(buf *bytes.Buffer) (*ISISPacket, error) { pkt := &ISISPacket{} - hdr, err := decodeHeader(buf) + hdr, err := DecodeHeader(buf) if err != nil { return nil, fmt.Errorf("Unable to decode header: %v", err) } @@ -37,7 +39,7 @@ func Decode(buf *bytes.Buffer) (*ISISPacket, error) { switch pkt.Header.PDUType { case P2P_HELLO: - p2pHello, err := decodeISISP2PHello(buf) + p2pHello, err := DecodeP2PHello(buf) if err != nil { return nil, fmt.Errorf("Unable to decode P2P hello: %v", err) } diff --git a/protocols/isis/packet/lsp.go b/protocols/isis/packet/lsp.go index fe39fcb447ca73376e2458d6e0862cdcba50db32..d0c70ed13ecb9b53d8def682eac37587439737c5 100644 --- a/protocols/isis/packet/lsp.go +++ b/protocols/isis/packet/lsp.go @@ -6,6 +6,7 @@ import ( "github.com/FMNSSun/libhash/fletcher" "github.com/bio-routing/bio-rd/protocols/isis/types" + "github.com/bio-routing/bio-rd/util/decode" "github.com/taktv6/tflow2/convert" ) @@ -71,7 +72,7 @@ func DecodeLSPDU(buf *bytes.Buffer) (*LSPDU, error) { &pdu.TypeBlock, } - err := decode(buf, fields) + err := decode.Decode(buf, fields) if err != nil { return nil, fmt.Errorf("Unable to decode fields: %v", err) } diff --git a/protocols/isis/packet/lsp_entry.go b/protocols/isis/packet/lsp_entry.go index 054ed56a426d5d4dfef85a502c42e4d94141b2d8..8b4afa5554dbba46245ab2b010dafbc2ab282fe2 100644 --- a/protocols/isis/packet/lsp_entry.go +++ b/protocols/isis/packet/lsp_entry.go @@ -4,6 +4,7 @@ import ( "bytes" "fmt" + "github.com/bio-routing/bio-rd/util/decode" "github.com/taktv6/tflow2/convert" ) @@ -39,7 +40,7 @@ func decodeLSPEntry(buf *bytes.Buffer) (*LSPEntry, error) { &lspEntry.LSPID.PseudonodeID, } - err := decode(buf, fields) + err := decode.Decode(buf, fields) if err != nil { return nil, fmt.Errorf("Unable to decode fields: %v", err) } diff --git a/protocols/isis/packet/psnp.go b/protocols/isis/packet/psnp.go index 0b4ff6d8611c8f9934a4171fa32f4ff3961e3ff4..0299ade07ebbdc2e65b689e5e72e5392b705227a 100644 --- a/protocols/isis/packet/psnp.go +++ b/protocols/isis/packet/psnp.go @@ -6,6 +6,7 @@ import ( "math" "github.com/bio-routing/bio-rd/protocols/isis/types" + "github.com/bio-routing/bio-rd/util/decode" "github.com/taktv6/tflow2/convert" ) @@ -76,7 +77,7 @@ func DecodePSNP(buf *bytes.Buffer) (*PSNP, error) { &psnp.SourceID, } - err := decode(buf, fields) + err := decode.Decode(buf, fields) if err != nil { return nil, fmt.Errorf("Unable to decode fields: %v", err) } diff --git a/protocols/isis/packet/tlv.go b/protocols/isis/packet/tlv.go index 6a545c48009f4f1f656dd5df609f434c0c4b37b8..2b8becaf5f59bde7abbbdbbd448fcbd218697d02 100644 --- a/protocols/isis/packet/tlv.go +++ b/protocols/isis/packet/tlv.go @@ -3,6 +3,8 @@ package packet import ( "bytes" "fmt" + + "github.com/bio-routing/bio-rd/util/decode" ) // TLV is an interface that all TLVs must fulfill @@ -38,7 +40,7 @@ func readTLVs(buf *bytes.Buffer) ([]TLV, error) { length := buf.Len() read := uint16(0) for read < uint16(length) { - err = decode(buf, headFields) + err = decode.Decode(buf, headFields) if err != nil { return nil, fmt.Errorf("Unable to decode fields: %v", err) } @@ -47,10 +49,6 @@ func readTLVs(buf *bytes.Buffer) ([]TLV, error) { read += uint16(tlvLength) var tlv TLV - - fmt.Printf("Decode: TLV Type = %d\n", tlvType) - fmt.Printf("Length: %d\n", tlvLength) - switch tlvType { case DynamicHostNameTLVType: tlv, err = readDynamicHostnameTLV(buf, tlvType, tlvLength) @@ -64,6 +62,8 @@ func readTLVs(buf *bytes.Buffer) ([]TLV, error) { tlv, err = readAreaAddressesTLV(buf, tlvType, tlvLength) case P2PAdjacencyStateTLVType: tlv, _, err = readP2PAdjacencyStateTLV(buf, tlvType, tlvLength) + case ISNeighborsTLVType: + tlv, _, err = readISNeighborsTLV(buf, tlvType, tlvLength) default: tlv, err = readUnknownTLV(buf, tlvType, tlvLength) } diff --git a/protocols/isis/packet/tlv_checksum.go b/protocols/isis/packet/tlv_checksum.go index 946c7ce4fc45c0dedf22963ee9bbf43d4175a324..f3ef8b85b8ec7182d3d545e646e99476fb31ed19 100644 --- a/protocols/isis/packet/tlv_checksum.go +++ b/protocols/isis/packet/tlv_checksum.go @@ -4,6 +4,7 @@ import ( "bytes" "fmt" + "github.com/bio-routing/bio-rd/util/decode" "github.com/taktv6/tflow2/convert" ) @@ -41,7 +42,7 @@ func readChecksumTLV(buf *bytes.Buffer, tlvType uint8, tlvLength uint8) (*Checks &pdu.Checksum, } - err := decode(buf, fields) + err := decode.Decode(buf, fields) if err != nil { return nil, fmt.Errorf("Unable to decode fields: %v", err) } diff --git a/protocols/isis/packet/tlv_dynamic_hostname.go b/protocols/isis/packet/tlv_dynamic_hostname.go index 9921fe1e53e3a4a6690fd977216d68c05f046ac7..edc647e6a591198669464147876408615f397358 100644 --- a/protocols/isis/packet/tlv_dynamic_hostname.go +++ b/protocols/isis/packet/tlv_dynamic_hostname.go @@ -3,6 +3,8 @@ package packet import ( "bytes" "fmt" + + "github.com/bio-routing/bio-rd/util/decode" ) const DynamicHostNameTLVType = 137 @@ -40,7 +42,7 @@ func readDynamicHostnameTLV(buf *bytes.Buffer, tlvType uint8, tlvLength uint8) ( &pdu.Hostname, } - err := decode(buf, fields) + err := decode.Decode(buf, fields) if err != nil { return nil, fmt.Errorf("Unable to decode fields: %v", err) } diff --git a/protocols/isis/packet/tlv_ip_interface_address.go b/protocols/isis/packet/tlv_ip_interface_address.go index 9f3ca7888e3eb8ef71f1449a1fad4a6b92fd0adc..c2d5f4573093c226396fef8369544dcc5ef65b26 100644 --- a/protocols/isis/packet/tlv_ip_interface_address.go +++ b/protocols/isis/packet/tlv_ip_interface_address.go @@ -4,6 +4,7 @@ import ( "bytes" "fmt" + "github.com/bio-routing/bio-rd/util/decode" "github.com/taktv6/tflow2/convert" ) @@ -21,8 +22,8 @@ const ipv4AddressLength = 4 func NewIPInterfaceAddressTLV(addr uint32) IPInterfaceAddressTLV { return IPInterfaceAddressTLV{ - TLVType: IPInterfaceAddressTLVType, - TLVLength: 4, + TLVType: IPInterfaceAddressTLVType, + TLVLength: 4, IPv4Address: addr, } } @@ -37,7 +38,7 @@ func readIPInterfaceAddressTLV(buf *bytes.Buffer, tlvType uint8, tlvLength uint8 &pdu.IPv4Address, } - err := decode(buf, fields) + err := decode.Decode(buf, fields) if err != nil { return nil, 0, fmt.Errorf("Unable to decode fields: %v", err) } diff --git a/protocols/isis/packet/tlv_is_neighbors.go b/protocols/isis/packet/tlv_is_neighbors.go index 32fabb2f1f60010e1adfc239f940d55b973fe75a..96b260caaca5432c8f776c43f586d4f327a4d922 100644 --- a/protocols/isis/packet/tlv_is_neighbors.go +++ b/protocols/isis/packet/tlv_is_neighbors.go @@ -3,6 +3,8 @@ package packet import ( "bytes" "fmt" + + "github.com/bio-routing/bio-rd/util/decode" ) // ISNeighborsTLVType is the type value of an IS Neighbor TLV @@ -27,7 +29,7 @@ func readISNeighborsTLV(buf *bytes.Buffer, tlvType uint8, tlvLength uint8) (*ISN &pdu.NeighborSNPA, } - err := decode(buf, fields) + err := decode.Decode(buf, fields) if err != nil { return nil, 0, fmt.Errorf("Unable to decode fields: %v", err) } diff --git a/protocols/isis/packet/tlv_p2p_adj_state.go b/protocols/isis/packet/tlv_p2p_adj_state.go index 396a2ca7793707aedd9467719ceabd0a93f4043c..2e4ce589debcaca3a087e786432d140c5593fa3d 100644 --- a/protocols/isis/packet/tlv_p2p_adj_state.go +++ b/protocols/isis/packet/tlv_p2p_adj_state.go @@ -4,8 +4,9 @@ import ( "bytes" "fmt" - "github.com/taktv6/tflow2/convert" "github.com/bio-routing/bio-rd/protocols/isis/types" + "github.com/bio-routing/bio-rd/util/decode" + "github.com/taktv6/tflow2/convert" ) const P2PAdjacencyStateTLVType = 240 @@ -44,7 +45,7 @@ func readP2PAdjacencyStateTLV(buf *bytes.Buffer, tlvType uint8, tlvLength uint8) } } - err := decode(buf, fields) + err := decode.Decode(buf, fields) if err != nil { return nil, 0, fmt.Errorf("Unable to decode fields: %v", err) } diff --git a/protocols/isis/packet/tlv_protocols_supported.go b/protocols/isis/packet/tlv_protocols_supported.go index aa60c03bf9a728f889e09ee55b0757e15001a57a..20a30d12348362536f0bf0a0f7ea9bbba3afadae 100644 --- a/protocols/isis/packet/tlv_protocols_supported.go +++ b/protocols/isis/packet/tlv_protocols_supported.go @@ -3,6 +3,8 @@ package packet import ( "bytes" "fmt" + + "github.com/bio-routing/bio-rd/util/decode" ) // ProtocolsSupportedTLVType is the type value of an protocols supported TLV @@ -29,7 +31,7 @@ func readProtocolsSupportedTLV(buf *bytes.Buffer, tlvType uint8, tlvLength uint8 read := uint8(2) for i := uint8(0); i < tlvLength; i++ { - err := decode(buf, fields) + err := decode.Decode(buf, fields) if err != nil { return nil, 0, fmt.Errorf("Unable to decode fields: %v", err) }