- buf = make([]byte, m.Size())
- } else {
- buf = b
- }
- // field[1] m.Addr
- // field[2] m.Addr.Addr
- for i := 0; i < 16; i++ {
- var x uint8
- if i < len(m.Addr.Addr) {
- x = uint8(m.Addr.Addr[i])
- }
- buf[pos] = uint8(x)
- pos += 1
- }
- // field[1] m.EndPsp
- buf[pos] = uint8(m.EndPsp)
- pos += 1
- // field[1] m.Behavior
- o.PutUint16(buf[pos:pos+2], uint16(m.Behavior))
- pos += 2
- // field[1] m.FibTable
- o.PutUint32(buf[pos:pos+4], uint32(m.FibTable))
- pos += 4
- // field[1] m.VlanIndex
- o.PutUint32(buf[pos:pos+4], uint32(m.VlanIndex))
- pos += 4
- // field[1] m.XconnectNhAddr6
- for i := 0; i < 16; i++ {
- var x uint8
- if i < len(m.XconnectNhAddr6) {
- x = uint8(m.XconnectNhAddr6[i])
- }
- buf[pos] = uint8(x)
- pos += 1
- }
- // field[1] m.XconnectNhAddr4
- for i := 0; i < 4; i++ {
- var x uint8
- if i < len(m.XconnectNhAddr4) {
- x = uint8(m.XconnectNhAddr4[i])
- }
- buf[pos] = uint8(x)
- pos += 1
- }
- // field[1] m.XconnectIfaceOrVrfTable
- o.PutUint32(buf[pos:pos+4], uint32(m.XconnectIfaceOrVrfTable))
- pos += 4
- return buf, nil
-}
-func (m *SrLocalsidsDetails) Unmarshal(tmp []byte) error {
- o := binary.BigEndian
- _ = o
- pos := 0
- _ = pos
- // field[1] m.Addr
- // field[2] m.Addr.Addr
- m.Addr.Addr = make([]uint8, 16)
- for i := 0; i < len(m.Addr.Addr); i++ {
- m.Addr.Addr[i] = uint8(tmp[pos])
- pos += 1
- }
- // field[1] m.EndPsp
- m.EndPsp = uint8(tmp[pos])
- pos += 1
- // field[1] m.Behavior
- m.Behavior = uint16(o.Uint16(tmp[pos : pos+2]))
- pos += 2
- // field[1] m.FibTable
- m.FibTable = uint32(o.Uint32(tmp[pos : pos+4]))
- pos += 4
- // field[1] m.VlanIndex
- m.VlanIndex = uint32(o.Uint32(tmp[pos : pos+4]))
- pos += 4
- // field[1] m.XconnectNhAddr6
- m.XconnectNhAddr6 = make([]uint8, 16)
- for i := 0; i < len(m.XconnectNhAddr6); i++ {
- m.XconnectNhAddr6[i] = uint8(tmp[pos])
- pos += 1
- }
- // field[1] m.XconnectNhAddr4
- m.XconnectNhAddr4 = make([]uint8, 4)
- for i := 0; i < len(m.XconnectNhAddr4); i++ {
- m.XconnectNhAddr4[i] = uint8(tmp[pos])
- pos += 1
- }
- // field[1] m.XconnectIfaceOrVrfTable
- m.XconnectIfaceOrVrfTable = uint32(o.Uint32(tmp[pos : pos+4]))
- pos += 4
+ b = make([]byte, m.Size())
+ }
+ buf := codec.NewBuffer(b)
+ buf.EncodeBytes(m.Addr.Addr, 16)
+ buf.EncodeUint8(m.EndPsp)
+ buf.EncodeUint16(m.Behavior)
+ buf.EncodeUint32(m.FibTable)
+ buf.EncodeUint32(m.VlanIndex)
+ buf.EncodeBytes(m.XconnectNhAddr6, 16)
+ buf.EncodeBytes(m.XconnectNhAddr4, 4)
+ buf.EncodeUint32(m.XconnectIfaceOrVrfTable)
+ return buf.Bytes(), nil
+}
+func (m *SrLocalsidsDetails) Unmarshal(b []byte) error {
+ buf := codec.NewBuffer(b)
+ m.Addr.Addr = make([]byte, 16)
+ copy(m.Addr.Addr, buf.DecodeBytes(len(m.Addr.Addr)))
+ m.EndPsp = buf.DecodeUint8()
+ m.Behavior = buf.DecodeUint16()
+ m.FibTable = buf.DecodeUint32()
+ m.VlanIndex = buf.DecodeUint32()
+ m.XconnectNhAddr6 = make([]byte, 16)
+ copy(m.XconnectNhAddr6, buf.DecodeBytes(len(m.XconnectNhAddr6)))
+ m.XconnectNhAddr4 = make([]byte, 4)
+ copy(m.XconnectNhAddr4, buf.DecodeBytes(len(m.XconnectNhAddr4)))
+ m.XconnectIfaceOrVrfTable = buf.DecodeUint32()