diff options
author | Ondrej Fabry <ofabry@cisco.com> | 2020-06-23 14:10:53 +0200 |
---|---|---|
committer | Ondrej Fabry <ofabry@cisco.com> | 2020-06-24 08:17:33 +0200 |
commit | ceed73403bdb61387d04be8b47183e9c4a970749 (patch) | |
tree | 3f48a49051672efb44945b279b9f69693bc48540 /examples | |
parent | 94620e85f0bdbb054af07ce3670fadc1f76cfdf0 (diff) |
Fix codec fallback and generate type imports
Change-Id: Idd76c7f19d952939caf153928ac60175845078ff
Signed-off-by: Ondrej Fabry <ofabry@cisco.com>
Diffstat (limited to 'examples')
-rw-r--r-- | examples/binapi/acl/acl.ba.go | 737 | ||||
-rw-r--r-- | examples/binapi/af_packet/af_packet.ba.go | 226 | ||||
-rw-r--r-- | examples/binapi/fib_types/fib_types.ba.go | 317 | ||||
-rw-r--r-- | examples/binapi/gen.go | 2 | ||||
-rw-r--r-- | examples/binapi/interface_types/interface_types.ba.go | 266 | ||||
-rw-r--r-- | examples/binapi/interfaces/interfaces.ba.go | 726 | ||||
-rw-r--r-- | examples/binapi/interfaces/interfaces_rpc.ba.go | 20 | ||||
-rw-r--r-- | examples/binapi/ip/ip.ba.go | 1298 | ||||
-rw-r--r-- | examples/binapi/ip/ip_rpc.ba.go | 14 | ||||
-rw-r--r-- | examples/binapi/ip_types/ip_types.ba.go | 39 | ||||
-rw-r--r-- | examples/binapi/memclnt/memclnt.ba.go | 6 | ||||
-rw-r--r-- | examples/binapi/memif/memif.ba.go | 226 | ||||
-rw-r--r-- | examples/binapi/sr/sr.ba.go | 688 | ||||
-rw-r--r-- | examples/binapi/vpe/vpe.ba.go | 158 | ||||
-rw-r--r-- | examples/simple-client/simple_client.go | 8 | ||||
-rw-r--r-- | examples/union-example/union_example.go | 2 |
16 files changed, 1897 insertions, 2836 deletions
diff --git a/examples/binapi/acl/acl.ba.go b/examples/binapi/acl/acl.ba.go index b42fb5f..604b352 100644 --- a/examples/binapi/acl/acl.ba.go +++ b/examples/binapi/acl/acl.ba.go @@ -1,15 +1,18 @@ // Code generated by GoVPP's binapi-generator. DO NOT EDIT. // versions: -// binapi-generator: v0.4.0-alpha-1-g435c3f4-dirty -// VPP: 20.01-45~g7a071e370~b63 +// binapi-generator: v0.4.0-dev +// VPP: 20.05-release // source: /usr/share/vpp/api/plugins/acl.api.json /* -Package acl contains generated code for VPP binary API defined by acl.api (version 1.0.1). +Package acl contains generated code for VPP API file acl.api (2.0.0). It consists of: + 7 aliases + 11 enums 38 messages - 2 types + 8 types + 1 union */ package acl @@ -24,6 +27,9 @@ import ( api "git.fd.io/govpp.git/api" codec "git.fd.io/govpp.git/codec" struc "github.com/lunixbochs/struc" + + interface_types "git.fd.io/govpp.git/examples/binapi/interface_types" + ip_types "git.fd.io/govpp.git/examples/binapi/ip_types" ) // This is a compile-time assertion to ensure that this generated file @@ -36,53 +42,127 @@ const ( // ModuleName is the name of this module. ModuleName = "acl" // APIVersion is the API version of this module. - APIVersion = "1.0.1" + APIVersion = "2.0.0" // VersionCrc is the CRC of this module. - VersionCrc = 0x11c5c1e5 + VersionCrc = 0x68c4cb37 +) + +// ACLAction represents VPP binary API enum 'acl_action'. +type ACLAction uint8 + +const ( + ACL_ACTION_API_DENY ACLAction = 0 + ACL_ACTION_API_PERMIT ACLAction = 1 + ACL_ACTION_API_PERMIT_REFLECT ACLAction = 2 +) + +var ( + ACLAction_name = map[uint8]string{ + 0: "ACL_ACTION_API_DENY", + 1: "ACL_ACTION_API_PERMIT", + 2: "ACL_ACTION_API_PERMIT_REFLECT", + } + ACLAction_value = map[string]uint8{ + "ACL_ACTION_API_DENY": 0, + "ACL_ACTION_API_PERMIT": 1, + "ACL_ACTION_API_PERMIT_REFLECT": 2, + } ) +func (x ACLAction) String() string { + s, ok := ACLAction_name[uint8(x)] + if ok { + return s + } + return "ACLAction(" + strconv.Itoa(int(x)) + ")" +} + +type AddressFamily = ip_types.AddressFamily + +type IfStatusFlags = interface_types.IfStatusFlags + +type IfType = interface_types.IfType + +type IPDscp = ip_types.IPDscp + +type IPEcn = ip_types.IPEcn + +type IPProto = ip_types.IPProto + +type LinkDuplex = interface_types.LinkDuplex + +type MtuProto = interface_types.MtuProto + +type RxMode = interface_types.RxMode + +type SubIfFlags = interface_types.SubIfFlags + +type AddressWithPrefix = ip_types.AddressWithPrefix + +type InterfaceIndex = interface_types.InterfaceIndex + +type IP4Address = ip_types.IP4Address + +type IP4AddressWithPrefix = ip_types.IP4AddressWithPrefix + +type IP6Address = ip_types.IP6Address + +type IP6AddressWithPrefix = ip_types.IP6AddressWithPrefix + +// MacAddress represents VPP binary API alias 'mac_address'. +type MacAddress [6]uint8 + // ACLRule represents VPP binary API type 'acl_rule'. type ACLRule struct { - IsPermit uint8 `binapi:"u8,name=is_permit" json:"is_permit,omitempty"` - IsIPv6 uint8 `binapi:"u8,name=is_ipv6" json:"is_ipv6,omitempty"` - SrcIPAddr []byte `binapi:"u8[16],name=src_ip_addr" json:"src_ip_addr,omitempty" struc:"[16]byte"` - SrcIPPrefixLen uint8 `binapi:"u8,name=src_ip_prefix_len" json:"src_ip_prefix_len,omitempty"` - DstIPAddr []byte `binapi:"u8[16],name=dst_ip_addr" json:"dst_ip_addr,omitempty" struc:"[16]byte"` - DstIPPrefixLen uint8 `binapi:"u8,name=dst_ip_prefix_len" json:"dst_ip_prefix_len,omitempty"` - Proto uint8 `binapi:"u8,name=proto" json:"proto,omitempty"` - SrcportOrIcmptypeFirst uint16 `binapi:"u16,name=srcport_or_icmptype_first" json:"srcport_or_icmptype_first,omitempty"` - SrcportOrIcmptypeLast uint16 `binapi:"u16,name=srcport_or_icmptype_last" json:"srcport_or_icmptype_last,omitempty"` - DstportOrIcmpcodeFirst uint16 `binapi:"u16,name=dstport_or_icmpcode_first" json:"dstport_or_icmpcode_first,omitempty"` - DstportOrIcmpcodeLast uint16 `binapi:"u16,name=dstport_or_icmpcode_last" json:"dstport_or_icmpcode_last,omitempty"` - TCPFlagsMask uint8 `binapi:"u8,name=tcp_flags_mask" json:"tcp_flags_mask,omitempty"` - TCPFlagsValue uint8 `binapi:"u8,name=tcp_flags_value" json:"tcp_flags_value,omitempty"` + IsPermit ACLAction `binapi:"acl_action,name=is_permit" json:"is_permit,omitempty"` + SrcPrefix Prefix `binapi:"prefix,name=src_prefix" json:"src_prefix,omitempty"` + DstPrefix Prefix `binapi:"prefix,name=dst_prefix" json:"dst_prefix,omitempty"` + Proto IPProto `binapi:"ip_proto,name=proto" json:"proto,omitempty"` + SrcportOrIcmptypeFirst uint16 `binapi:"u16,name=srcport_or_icmptype_first" json:"srcport_or_icmptype_first,omitempty"` + SrcportOrIcmptypeLast uint16 `binapi:"u16,name=srcport_or_icmptype_last" json:"srcport_or_icmptype_last,omitempty"` + DstportOrIcmpcodeFirst uint16 `binapi:"u16,name=dstport_or_icmpcode_first" json:"dstport_or_icmpcode_first,omitempty"` + DstportOrIcmpcodeLast uint16 `binapi:"u16,name=dstport_or_icmpcode_last" json:"dstport_or_icmpcode_last,omitempty"` + TCPFlagsMask uint8 `binapi:"u8,name=tcp_flags_mask" json:"tcp_flags_mask,omitempty"` + TCPFlagsValue uint8 `binapi:"u8,name=tcp_flags_value" json:"tcp_flags_value,omitempty"` } func (*ACLRule) GetTypeName() string { return "acl_rule" } +type Address = ip_types.Address + +type IP4Prefix = ip_types.IP4Prefix + +type IP6Prefix = ip_types.IP6Prefix + // MacipACLRule represents VPP binary API type 'macip_acl_rule'. type MacipACLRule struct { - IsPermit uint8 `binapi:"u8,name=is_permit" json:"is_permit,omitempty"` - IsIPv6 uint8 `binapi:"u8,name=is_ipv6" json:"is_ipv6,omitempty"` - SrcMac []byte `binapi:"u8[6],name=src_mac" json:"src_mac,omitempty" struc:"[6]byte"` - SrcMacMask []byte `binapi:"u8[6],name=src_mac_mask" json:"src_mac_mask,omitempty" struc:"[6]byte"` - SrcIPAddr []byte `binapi:"u8[16],name=src_ip_addr" json:"src_ip_addr,omitempty" struc:"[16]byte"` - SrcIPPrefixLen uint8 `binapi:"u8,name=src_ip_prefix_len" json:"src_ip_prefix_len,omitempty"` + IsPermit ACLAction `binapi:"acl_action,name=is_permit" json:"is_permit,omitempty"` + SrcMac MacAddress `binapi:"mac_address,name=src_mac" json:"src_mac,omitempty"` + SrcMacMask MacAddress `binapi:"mac_address,name=src_mac_mask" json:"src_mac_mask,omitempty"` + SrcPrefix Prefix `binapi:"prefix,name=src_prefix" json:"src_prefix,omitempty"` } func (*MacipACLRule) GetTypeName() string { return "macip_acl_rule" } +type Mprefix = ip_types.Mprefix + +type Prefix = ip_types.Prefix + +type PrefixMatcher = ip_types.PrefixMatcher + +type AddressUnion = ip_types.AddressUnion + // ACLAddReplace represents VPP binary API message 'acl_add_replace'. type ACLAddReplace struct { ACLIndex uint32 `binapi:"u32,name=acl_index" json:"acl_index,omitempty"` - Tag []byte `binapi:"u8[64],name=tag" json:"tag,omitempty" struc:"[64]byte"` + Tag string `binapi:"string[64],name=tag" json:"tag,omitempty" struc:"[64]byte"` Count uint32 `binapi:"u32,name=count" json:"count,omitempty" struc:"sizeof=R"` R []ACLRule `binapi:"acl_rule[count],name=r" json:"r,omitempty"` } func (m *ACLAddReplace) Reset() { *m = ACLAddReplace{} } func (*ACLAddReplace) GetMessageName() string { return "acl_add_replace" } -func (*ACLAddReplace) GetCrcString() string { return "13bc8539" } +func (*ACLAddReplace) GetCrcString() string { return "1cabdeab" } func (*ACLAddReplace) GetMessageType() api.MessageType { return api.RequestMessage } func (m *ACLAddReplace) Size() int { @@ -105,15 +185,21 @@ func (m *ACLAddReplace) Size() int { } // field[2] s1.IsPermit size += 1 - // field[2] s1.IsIPv6 + // field[2] s1.SrcPrefix + // field[3] s1.SrcPrefix.Address + // field[4] s1.SrcPrefix.Address.Af size += 1 - // field[2] s1.SrcIPAddr + // field[4] s1.SrcPrefix.Address.Un size += 16 - // field[2] s1.SrcIPPrefixLen + // field[3] s1.SrcPrefix.Len + size += 1 + // field[2] s1.DstPrefix + // field[3] s1.DstPrefix.Address + // field[4] s1.DstPrefix.Address.Af size += 1 - // field[2] s1.DstIPAddr + // field[4] s1.DstPrefix.Address.Un size += 16 - // field[2] s1.DstIPPrefixLen + // field[3] s1.DstPrefix.Len size += 1 // field[2] s1.Proto size += 1 @@ -147,14 +233,8 @@ func (m *ACLAddReplace) Marshal(b []byte) ([]byte, error) { o.PutUint32(buf[pos:pos+4], uint32(m.ACLIndex)) pos += 4 // field[1] m.Tag - for i := 0; i < 64; i++ { - var x uint8 - if i < len(m.Tag) { - x = uint8(m.Tag[i]) - } - buf[pos] = uint8(x) - pos += 1 - } + copy(buf[pos:pos+64], m.Tag) + pos += 64 // field[1] m.Count o.PutUint32(buf[pos:pos+4], uint32(len(m.R))) pos += 4 @@ -167,32 +247,27 @@ func (m *ACLAddReplace) Marshal(b []byte) ([]byte, error) { // field[2] v1.IsPermit buf[pos] = uint8(v1.IsPermit) pos += 1 - // field[2] v1.IsIPv6 - buf[pos] = uint8(v1.IsIPv6) + // field[2] v1.SrcPrefix + // field[3] v1.SrcPrefix.Address + // field[4] v1.SrcPrefix.Address.Af + buf[pos] = uint8(v1.SrcPrefix.Address.Af) pos += 1 - // field[2] v1.SrcIPAddr - for i := 0; i < 16; i++ { - var x uint8 - if i < len(v1.SrcIPAddr) { - x = uint8(v1.SrcIPAddr[i]) - } - buf[pos] = uint8(x) - pos += 1 - } - // field[2] v1.SrcIPPrefixLen - buf[pos] = uint8(v1.SrcIPPrefixLen) + // field[4] v1.SrcPrefix.Address.Un + copy(buf[pos:pos+16], v1.SrcPrefix.Address.Un.XXX_UnionData[:]) + pos += 16 + // field[3] v1.SrcPrefix.Len + buf[pos] = uint8(v1.SrcPrefix.Len) pos += 1 - // field[2] v1.DstIPAddr - for i := 0; i < 16; i++ { - var x uint8 - if i < len(v1.DstIPAddr) { - x = uint8(v1.DstIPAddr[i]) - } - buf[pos] = uint8(x) - pos += 1 - } - // field[2] v1.DstIPPrefixLen - buf[pos] = uint8(v1.DstIPPrefixLen) + // field[2] v1.DstPrefix + // field[3] v1.DstPrefix.Address + // field[4] v1.DstPrefix.Address.Af + buf[pos] = uint8(v1.DstPrefix.Address.Af) + pos += 1 + // field[4] v1.DstPrefix.Address.Un + copy(buf[pos:pos+16], v1.DstPrefix.Address.Un.XXX_UnionData[:]) + pos += 16 + // field[3] v1.DstPrefix.Len + buf[pos] = uint8(v1.DstPrefix.Len) pos += 1 // field[2] v1.Proto buf[pos] = uint8(v1.Proto) @@ -227,10 +302,10 @@ func (m *ACLAddReplace) Unmarshal(tmp []byte) error { m.ACLIndex = uint32(o.Uint32(tmp[pos : pos+4])) pos += 4 // field[1] m.Tag - m.Tag = make([]uint8, 64) - for i := 0; i < len(m.Tag); i++ { - m.Tag[i] = uint8(tmp[pos]) - pos += 1 + { + nul := bytes.Index(tmp[pos:pos+64], []byte{0x00}) + m.Tag = codec.DecodeString(tmp[pos : pos+nul]) + pos += 64 } // field[1] m.Count m.Count = uint32(o.Uint32(tmp[pos : pos+4])) @@ -239,31 +314,32 @@ func (m *ACLAddReplace) Unmarshal(tmp []byte) error { m.R = make([]ACLRule, int(m.Count)) for j1 := 0; j1 < int(m.Count); j1++ { // field[2] m.R[j1].IsPermit - m.R[j1].IsPermit = uint8(tmp[pos]) + m.R[j1].IsPermit = ACLAction(tmp[pos]) pos += 1 - // field[2] m.R[j1].IsIPv6 - m.R[j1].IsIPv6 = uint8(tmp[pos]) + // field[2] m.R[j1].SrcPrefix + // field[3] m.R[j1].SrcPrefix.Address + // field[4] m.R[j1].SrcPrefix.Address.Af + m.R[j1].SrcPrefix.Address.Af = AddressFamily(tmp[pos]) pos += 1 - // field[2] m.R[j1].SrcIPAddr - m.R[j1].SrcIPAddr = make([]uint8, 16) - for i := 0; i < len(m.R[j1].SrcIPAddr); i++ { - m.R[j1].SrcIPAddr[i] = uint8(tmp[pos]) - pos += 1 - } - // field[2] m.R[j1].SrcIPPrefixLen - m.R[j1].SrcIPPrefixLen = uint8(tmp[pos]) + // field[4] m.R[j1].SrcPrefix.Address.Un + copy(m.R[j1].SrcPrefix.Address.Un.XXX_UnionData[:], tmp[pos:pos+16]) + pos += 16 + // field[3] m.R[j1].SrcPrefix.Len + m.R[j1].SrcPrefix.Len = uint8(tmp[pos]) pos += 1 - // field[2] m.R[j1].DstIPAddr - m.R[j1].DstIPAddr = make([]uint8, 16) - for i := 0; i < len(m.R[j1].DstIPAddr); i++ { - m.R[j1].DstIPAddr[i] = uint8(tmp[pos]) - pos += 1 - } - // field[2] m.R[j1].DstIPPrefixLen - m.R[j1].DstIPPrefixLen = uint8(tmp[pos]) + // field[2] m.R[j1].DstPrefix + // field[3] m.R[j1].DstPrefix.Address + // field[4] m.R[j1].DstPrefix.Address.Af + m.R[j1].DstPrefix.Address.Af = AddressFamily(tmp[pos]) + pos += 1 + // field[4] m.R[j1].DstPrefix.Address.Un + copy(m.R[j1].DstPrefix.Address.Un.XXX_UnionData[:], tmp[pos:pos+16]) + pos += 16 + // field[3] m.R[j1].DstPrefix.Len + m.R[j1].DstPrefix.Len = uint8(tmp[pos]) pos += 1 // field[2] m.R[j1].Proto - m.R[j1].Proto = uint8(tmp[pos]) + m.R[j1].Proto = IPProto(tmp[pos]) pos += 1 // field[2] m.R[j1].SrcportOrIcmptypeFirst m.R[j1].SrcportOrIcmptypeFirst = uint16(o.Uint16(tmp[pos : pos+2])) @@ -437,14 +513,14 @@ func (m *ACLDelReply) Unmarshal(tmp []byte) error { // ACLDetails represents VPP binary API message 'acl_details'. type ACLDetails struct { ACLIndex uint32 `binapi:"u32,name=acl_index" json:"acl_index,omitempty"` - Tag []byte `binapi:"u8[64],name=tag" json:"tag,omitempty" struc:"[64]byte"` + Tag string `binapi:"string[64],name=tag" json:"tag,omitempty" struc:"[64]byte"` Count uint32 `binapi:"u32,name=count" json:"count,omitempty" struc:"sizeof=R"` R []ACLRule `binapi:"acl_rule[count],name=r" json:"r,omitempty"` } func (m *ACLDetails) Reset() { *m = ACLDetails{} } func (*ACLDetails) GetMessageName() string { return "acl_details" } -func (*ACLDetails) GetCrcString() string { return "f89d7a88" } +func (*ACLDetails) GetCrcString() string { return "7a97f21c" } func (*ACLDetails) GetMessageType() api.MessageType { return api.ReplyMessage } func (m *ACLDetails) Size() int { @@ -467,15 +543,21 @@ func (m *ACLDetails) Size() int { } // field[2] s1.IsPermit size += 1 - // field[2] s1.IsIPv6 + // field[2] s1.SrcPrefix + // field[3] s1.SrcPrefix.Address + // field[4] s1.SrcPrefix.Address.Af size += 1 - // field[2] s1.SrcIPAddr + // field[4] s1.SrcPrefix.Address.Un size += 16 - // field[2] s1.SrcIPPrefixLen + // field[3] s1.SrcPrefix.Len size += 1 - // field[2] s1.DstIPAddr + // field[2] s1.DstPrefix + // field[3] s1.DstPrefix.Address + // field[4] s1.DstPrefix.Address.Af + size += 1 + // field[4] s1.DstPrefix.Address.Un size += 16 - // field[2] s1.DstIPPrefixLen + // field[3] s1.DstPrefix.Len size += 1 // field[2] s1.Proto size += 1 @@ -509,14 +591,8 @@ func (m *ACLDetails) Marshal(b []byte) ([]byte, error) { o.PutUint32(buf[pos:pos+4], uint32(m.ACLIndex)) pos += 4 // field[1] m.Tag - for i := 0; i < 64; i++ { - var x uint8 - if i < len(m.Tag) { - x = uint8(m.Tag[i]) - } - buf[pos] = uint8(x) - pos += 1 - } + copy(buf[pos:pos+64], m.Tag) + pos += 64 // field[1] m.Count o.PutUint32(buf[pos:pos+4], uint32(len(m.R))) pos += 4 @@ -529,32 +605,27 @@ func (m *ACLDetails) Marshal(b []byte) ([]byte, error) { // field[2] v1.IsPermit buf[pos] = uint8(v1.IsPermit) pos += 1 - // field[2] v1.IsIPv6 - buf[pos] = uint8(v1.IsIPv6) + // field[2] v1.SrcPrefix + // field[3] v1.SrcPrefix.Address + // field[4] v1.SrcPrefix.Address.Af + buf[pos] = uint8(v1.SrcPrefix.Address.Af) pos += 1 - // field[2] v1.SrcIPAddr - for i := 0; i < 16; i++ { - var x uint8 - if i < len(v1.SrcIPAddr) { - x = uint8(v1.SrcIPAddr[i]) - } - buf[pos] = uint8(x) - pos += 1 - } - // field[2] v1.SrcIPPrefixLen - buf[pos] = uint8(v1.SrcIPPrefixLen) + // field[4] v1.SrcPrefix.Address.Un + copy(buf[pos:pos+16], v1.SrcPrefix.Address.Un.XXX_UnionData[:]) + pos += 16 + // field[3] v1.SrcPrefix.Len + buf[pos] = uint8(v1.SrcPrefix.Len) pos += 1 - // field[2] v1.DstIPAddr - for i := 0; i < 16; i++ { - var x uint8 - if i < len(v1.DstIPAddr) { - x = uint8(v1.DstIPAddr[i]) - } - buf[pos] = uint8(x) - pos += 1 - } - // field[2] v1.DstIPPrefixLen - buf[pos] = uint8(v1.DstIPPrefixLen) + // field[2] v1.DstPrefix + // field[3] v1.DstPrefix.Address + // field[4] v1.DstPrefix.Address.Af + buf[pos] = uint8(v1.DstPrefix.Address.Af) + pos += 1 + // field[4] v1.DstPrefix.Address.Un + copy(buf[pos:pos+16], v1.DstPrefix.Address.Un.XXX_UnionData[:]) + pos += 16 + // field[3] v1.DstPrefix.Len + buf[pos] = uint8(v1.DstPrefix.Len) pos += 1 // field[2] v1.Proto buf[pos] = uint8(v1.Proto) @@ -589,10 +660,10 @@ func (m *ACLDetails) Unmarshal(tmp []byte) error { m.ACLIndex = uint32(o.Uint32(tmp[pos : pos+4])) pos += 4 // field[1] m.Tag - m.Tag = make([]uint8, 64) - for i := 0; i < len(m.Tag); i++ { - m.Tag[i] = uint8(tmp[pos]) - pos += 1 + { + nul := bytes.Index(tmp[pos:pos+64], []byte{0x00}) + m.Tag = codec.DecodeString(tmp[pos : pos+nul]) + pos += 64 } // field[1] m.Count m.Count = uint32(o.Uint32(tmp[pos : pos+4])) @@ -601,31 +672,32 @@ func (m *ACLDetails) Unmarshal(tmp []byte) error { m.R = make([]ACLRule, int(m.Count)) for j1 := 0; j1 < int(m.Count); j1++ { // field[2] m.R[j1].IsPermit - m.R[j1].IsPermit = uint8(tmp[pos]) + m.R[j1].IsPermit = ACLAction(tmp[pos]) pos += 1 - // field[2] m.R[j1].IsIPv6 - m.R[j1].IsIPv6 = uint8(tmp[pos]) + // field[2] m.R[j1].SrcPrefix + // field[3] m.R[j1].SrcPrefix.Address + // field[4] m.R[j1].SrcPrefix.Address.Af + m.R[j1].SrcPrefix.Address.Af = AddressFamily(tmp[pos]) pos += 1 - // field[2] m.R[j1].SrcIPAddr - m.R[j1].SrcIPAddr = make([]uint8, 16) - for i := 0; i < len(m.R[j1].SrcIPAddr); i++ { - m.R[j1].SrcIPAddr[i] = uint8(tmp[pos]) - pos += 1 - } - // field[2] m.R[j1].SrcIPPrefixLen - m.R[j1].SrcIPPrefixLen = uint8(tmp[pos]) + // field[4] m.R[j1].SrcPrefix.Address.Un + copy(m.R[j1].SrcPrefix.Address.Un.XXX_UnionData[:], tmp[pos:pos+16]) + pos += 16 + // field[3] m.R[j1].SrcPrefix.Len + m.R[j1].SrcPrefix.Len = uint8(tmp[pos]) pos += 1 - // field[2] m.R[j1].DstIPAddr - m.R[j1].DstIPAddr = make([]uint8, 16) - for i := 0; i < len(m.R[j1].DstIPAddr); i++ { - m.R[j1].DstIPAddr[i] = uint8(tmp[pos]) - pos += 1 - } - // field[2] m.R[j1].DstIPPrefixLen - m.R[j1].DstIPPrefixLen = uint8(tmp[pos]) + // field[2] m.R[j1].DstPrefix + // field[3] m.R[j1].DstPrefix.Address + // field[4] m.R[j1].DstPrefix.Address.Af + m.R[j1].DstPrefix.Address.Af = AddressFamily(tmp[pos]) + pos += 1 + // field[4] m.R[j1].DstPrefix.Address.Un + copy(m.R[j1].DstPrefix.Address.Un.XXX_UnionData[:], tmp[pos:pos+16]) + pos += 16 + // field[3] m.R[j1].DstPrefix.Len + m.R[j1].DstPrefix.Len = uint8(tmp[pos]) pos += 1 // field[2] m.R[j1].Proto - m.R[j1].Proto = uint8(tmp[pos]) + m.R[j1].Proto = IPProto(tmp[pos]) pos += 1 // field[2] m.R[j1].SrcportOrIcmptypeFirst m.R[j1].SrcportOrIcmptypeFirst = uint16(o.Uint16(tmp[pos : pos+2])) @@ -697,15 +769,15 @@ func (m *ACLDump) Unmarshal(tmp []byte) error { // ACLInterfaceAddDel represents VPP binary API message 'acl_interface_add_del'. type ACLInterfaceAddDel struct { - IsAdd uint8 `binapi:"u8,name=is_add" json:"is_add,omitempty"` - IsInput uint8 `binapi:"u8,name=is_input" json:"is_input,omitempty"` - SwIfIndex uint32 `binapi:"u32,name=sw_if_index" json:"sw_if_index,omitempty"` - ACLIndex uint32 `binapi:"u32,name=acl_index" json:"acl_index,omitempty"` + IsAdd bool `binapi:"bool,name=is_add,default=true" json:"is_add,omitempty"` + IsInput bool `binapi:"bool,name=is_input" json:"is_input,omitempty"` + SwIfIndex InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + ACLIndex uint32 `binapi:"u32,name=acl_index" json:"acl_index,omitempty"` } func (m *ACLInterfaceAddDel) Reset() { *m = ACLInterfaceAddDel{} } func (*ACLInterfaceAddDel) GetMessageName() string { return "acl_interface_add_del" } -func (*ACLInterfaceAddDel) GetCrcString() string { return "0b2aedd1" } +func (*ACLInterfaceAddDel) GetCrcString() string { return "4b54bebd" } func (*ACLInterfaceAddDel) GetMessageType() api.MessageType { return api.RequestMessage } func (m *ACLInterfaceAddDel) Size() int { @@ -735,10 +807,14 @@ func (m *ACLInterfaceAddDel) Marshal(b []byte) ([]byte, error) { buf = b } // field[1] m.IsAdd - buf[pos] = uint8(m.IsAdd) + if m.IsAdd { + buf[pos] = 1 + } pos += 1 // field[1] m.IsInput - buf[pos] = uint8(m.IsInput) + if m.IsInput { + buf[pos] = 1 + } pos += 1 // field[1] m.SwIfIndex o.PutUint32(buf[pos:pos+4], uint32(m.SwIfIndex)) @@ -754,13 +830,13 @@ func (m *ACLInterfaceAddDel) Unmarshal(tmp []byte) error { pos := 0 _ = pos // field[1] m.IsAdd - m.IsAdd = uint8(tmp[pos]) + m.IsAdd = tmp[pos] != 0 pos += 1 // field[1] m.IsInput - m.IsInput = uint8(tmp[pos]) + m.IsInput = tmp[pos] != 0 pos += 1 // field[1] m.SwIfIndex - m.SwIfIndex = uint32(o.Uint32(tmp[pos : pos+4])) + m.SwIfIndex = InterfaceIndex(o.Uint32(tmp[pos : pos+4])) pos += 4 // field[1] m.ACLIndex m.ACLIndex = uint32(o.Uint32(tmp[pos : pos+4])) @@ -816,17 +892,17 @@ func (m *ACLInterfaceAddDelReply) Unmarshal(tmp []byte) error { // ACLInterfaceEtypeWhitelistDetails represents VPP binary API message 'acl_interface_etype_whitelist_details'. type ACLInterfaceEtypeWhitelistDetails struct { - SwIfIndex uint32 `binapi:"u32,name=sw_if_index" json:"sw_if_index,omitempty"` - Count uint8 `binapi:"u8,name=count" json:"count,omitempty" struc:"sizeof=Whitelist"` - NInput uint8 `binapi:"u8,name=n_input" json:"n_input,omitempty"` - Whitelist []uint16 `binapi:"u16[count],name=whitelist" json:"whitelist,omitempty"` + SwIfIndex InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + Count uint8 `binapi:"u8,name=count" json:"count,omitempty" struc:"sizeof=Whitelist"` + NInput uint8 `binapi:"u8,name=n_input" json:"n_input,omitempty"` + Whitelist []uint16 `binapi:"u16[count],name=whitelist" json:"whitelist,omitempty"` } func (m *ACLInterfaceEtypeWhitelistDetails) Reset() { *m = ACLInterfaceEtypeWhitelistDetails{} } func (*ACLInterfaceEtypeWhitelistDetails) GetMessageName() string { return "acl_interface_etype_whitelist_details" } -func (*ACLInterfaceEtypeWhitelistDetails) GetCrcString() string { return "6a5d4e81" } +func (*ACLInterfaceEtypeWhitelistDetails) GetCrcString() string { return "cc2bfded" } func (*ACLInterfaceEtypeWhitelistDetails) GetMessageType() api.MessageType { return api.ReplyMessage } func (m *ACLInterfaceEtypeWhitelistDetails) Size() int { @@ -881,7 +957,7 @@ func (m *ACLInterfaceEtypeWhitelistDetails) Unmarshal(tmp []byte) error { pos := 0 _ = pos // field[1] m.SwIfIndex - m.SwIfIndex = uint32(o.Uint32(tmp[pos : pos+4])) + m.SwIfIndex = InterfaceIndex(o.Uint32(tmp[pos : pos+4])) pos += 4 // field[1] m.Count m.Count = uint8(tmp[pos]) @@ -900,14 +976,14 @@ func (m *ACLInterfaceEtypeWhitelistDetails) Unmarshal(tmp []byte) error { // ACLInterfaceEtypeWhitelistDump represents VPP binary API message 'acl_interface_etype_whitelist_dump'. type ACLInterfaceEtypeWhitelistDump struct { - SwIfIndex uint32 `binapi:"u32,name=sw_if_index" json:"sw_if_index,omitempty"` + SwIfIndex InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` } func (m *ACLInterfaceEtypeWhitelistDump) Reset() { *m = ACLInterfaceEtypeWhitelistDump{} } func (*ACLInterfaceEtypeWhitelistDump) GetMessageName() string { return "acl_interface_etype_whitelist_dump" } -func (*ACLInterfaceEtypeWhitelistDump) GetCrcString() string { return "529cb13f" } +func (*ACLInterfaceEtypeWhitelistDump) GetCrcString() string { return "f9e6675e" } func (*ACLInterfaceEtypeWhitelistDump) GetMessageType() api.MessageType { return api.RequestMessage } func (m *ACLInterfaceEtypeWhitelistDump) Size() int { @@ -941,22 +1017,22 @@ func (m *ACLInterfaceEtypeWhitelistDump) Unmarshal(tmp []byte) error { pos := 0 _ = pos // field[1] m.SwIfIndex - m.SwIfIndex = uint32(o.Uint32(tmp[pos : pos+4])) + m.SwIfIndex = InterfaceIndex(o.Uint32(tmp[pos : pos+4])) pos += 4 return nil } // ACLInterfaceListDetails represents VPP binary API message 'acl_interface_list_details'. type ACLInterfaceListDetails struct { - SwIfIndex uint32 `binapi:"u32,name=sw_if_index" json:"sw_if_index,omitempty"` - Count uint8 `binapi:"u8,name=count" json:"count,omitempty" struc:"sizeof=Acls"` - NInput uint8 `binapi:"u8,name=n_input" json:"n_input,omitempty"` - Acls []uint32 `binapi:"u32[count],name=acls" json:"acls,omitempty"` + SwIfIndex InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + Count uint8 `binapi:"u8,name=count" json:"count,omitempty" struc:"sizeof=Acls"` + NInput uint8 `binapi:"u8,name=n_input" json:"n_input,omitempty"` + Acls []uint32 `binapi:"u32[count],name=acls" json:"acls,omitempty"` } func (m *ACLInterfaceListDetails) Reset() { *m = ACLInterfaceListDetails{} } func (*ACLInterfaceListDetails) GetMessageName() string { return "acl_interface_list_details" } -func (*ACLInterfaceListDetails) GetCrcString() string { return "d5e80809" } +func (*ACLInterfaceListDetails) GetCrcString() string { return "e695d256" } func (*ACLInterfaceListDetails) GetMessageType() api.MessageType { return api.ReplyMessage } func (m *ACLInterfaceListDetails) Size() int { @@ -1011,7 +1087,7 @@ func (m *ACLInterfaceListDetails) Unmarshal(tmp []byte) error { pos := 0 _ = pos // field[1] m.SwIfIndex - m.SwIfIndex = uint32(o.Uint32(tmp[pos : pos+4])) + m.SwIfIndex = InterfaceIndex(o.Uint32(tmp[pos : pos+4])) pos += 4 // field[1] m.Count m.Count = uint8(tmp[pos]) @@ -1030,12 +1106,12 @@ func (m *ACLInterfaceListDetails) Unmarshal(tmp []byte) error { // ACLInterfaceListDump represents VPP binary API message 'acl_interface_list_dump'. type ACLInterfaceListDump struct { - SwIfIndex uint32 `binapi:"u32,name=sw_if_index" json:"sw_if_index,omitempty"` + SwIfIndex InterfaceIndex `binapi:"interface_index,name=sw_if_index,default=4294967295" json:"sw_if_index,omitempty"` } func (m *ACLInterfaceListDump) Reset() { *m = ACLInterfaceListDump{} } func (*ACLInterfaceListDump) GetMessageName() string { return "acl_interface_list_dump" } -func (*ACLInterfaceListDump) GetCrcString() string { return "529cb13f" } +func (*ACLInterfaceListDump) GetCrcString() string { return "f9e6675e" } func (*ACLInterfaceListDump) GetMessageType() api.MessageType { return api.RequestMessage } func (m *ACLInterfaceListDump) Size() int { @@ -1069,22 +1145,22 @@ func (m *ACLInterfaceListDump) Unmarshal(tmp []byte) error { pos := 0 _ = pos // field[1] m.SwIfIndex - m.SwIfIndex = uint32(o.Uint32(tmp[pos : pos+4])) + m.SwIfIndex = InterfaceIndex(o.Uint32(tmp[pos : pos+4])) pos += 4 return nil } // ACLInterfaceSetACLList represents VPP binary API message 'acl_interface_set_acl_list'. type ACLInterfaceSetACLList struct { - SwIfIndex uint32 `binapi:"u32,name=sw_if_index" json:"sw_if_index,omitempty"` - Count uint8 `binapi:"u8,name=count" json:"count,omitempty" struc:"sizeof=Acls"` - NInput uint8 `binapi:"u8,name=n_input" json:"n_input,omitempty"` - Acls []uint32 `binapi:"u32[count],name=acls" json:"acls,omitempty"` + SwIfIndex InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + Count uint8 `binapi:"u8,name=count" json:"count,omitempty" struc:"sizeof=Acls"` + NInput uint8 `binapi:"u8,name=n_input" json:"n_input,omitempty"` + Acls []uint32 `binapi:"u32[count],name=acls" json:"acls,omitempty"` } func (m *ACLInterfaceSetACLList) Reset() { *m = ACLInterfaceSetACLList{} } func (*ACLInterfaceSetACLList) GetMessageName() string { return "acl_interface_set_acl_list" } -func (*ACLInterfaceSetACLList) GetCrcString() string { return "8baece38" } +func (*ACLInterfaceSetACLList) GetCrcString() string { return "473982bd" } func (*ACLInterfaceSetACLList) GetMessageType() api.MessageType { return api.RequestMessage } func (m *ACLInterfaceSetACLList) Size() int { @@ -1139,7 +1215,7 @@ func (m *ACLInterfaceSetACLList) Unmarshal(tmp []byte) error { pos := 0 _ = pos // field[1] m.SwIfIndex - m.SwIfIndex = uint32(o.Uint32(tmp[pos : pos+4])) + m.SwIfIndex = InterfaceIndex(o.Uint32(tmp[pos : pos+4])) pos += 4 // field[1] m.Count m.Count = uint8(tmp[pos]) @@ -1206,17 +1282,17 @@ func (m *ACLInterfaceSetACLListReply) Unmarshal(tmp []byte) error { // ACLInterfaceSetEtypeWhitelist represents VPP binary API message 'acl_interface_set_etype_whitelist'. type ACLInterfaceSetEtypeWhitelist struct { - SwIfIndex uint32 `binapi:"u32,name=sw_if_index" json:"sw_if_index,omitempty"` - Count uint8 `binapi:"u8,name=count" json:"count,omitempty" struc:"sizeof=Whitelist"` - NInput uint8 `binapi:"u8,name=n_input" json:"n_input,omitempty"` - Whitelist []uint16 `binapi:"u16[count],name=whitelist" json:"whitelist,omitempty"` + SwIfIndex InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + Count uint8 `binapi:"u8,name=count" json:"count,omitempty" struc:"sizeof=Whitelist"` + NInput uint8 `binapi:"u8,name=n_input" json:"n_input,omitempty"` + Whitelist []uint16 `binapi:"u16[count],name=whitelist" json:"whitelist,omitempty"` } func (m *ACLInterfaceSetEtypeWhitelist) Reset() { *m = ACLInterfaceSetEtypeWhitelist{} } func (*ACLInterfaceSetEtypeWhitelist) GetMessageName() string { return "acl_interface_set_etype_whitelist" } -func (*ACLInterfaceSetEtypeWhitelist) GetCrcString() string { return "f515efc5" } +func (*ACLInterfaceSetEtypeWhitelist) GetCrcString() string { return "3f5c2d2d" } func (*ACLInterfaceSetEtypeWhitelist) GetMessageType() api.MessageType { return api.RequestMessage } func (m *ACLInterfaceSetEtypeWhitelist) Size() int { @@ -1271,7 +1347,7 @@ func (m *ACLInterfaceSetEtypeWhitelist) Unmarshal(tmp []byte) error { pos := 0 _ = pos // field[1] m.SwIfIndex - m.SwIfIndex = uint32(o.Uint32(tmp[pos : pos+4])) + m.SwIfIndex = InterfaceIndex(o.Uint32(tmp[pos : pos+4])) pos += 4 // field[1] m.Count m.Count = uint8(tmp[pos]) @@ -1713,14 +1789,14 @@ func (m *ACLStatsIntfCountersEnableReply) Unmarshal(tmp []byte) error { // MacipACLAdd represents VPP binary API message 'macip_acl_add'. type MacipACLAdd struct { - Tag []byte `binapi:"u8[64],name=tag" json:"tag,omitempty" struc:"[64]byte"` + Tag string `binapi:"string[64],name=tag" json:"tag,omitempty" struc:"[64]byte"` Count uint32 `binapi:"u32,name=count" json:"count,omitempty" struc:"sizeof=R"` R []MacipACLRule `binapi:"macip_acl_rule[count],name=r" json:"r,omitempty"` } func (m *MacipACLAdd) Reset() { *m = MacipACLAdd{} } func (*MacipACLAdd) GetMessageName() string { return "macip_acl_add" } -func (*MacipACLAdd) GetCrcString() string { return "0c680ca5" } +func (*MacipACLAdd) GetCrcString() string { return "d648fd0a" } func (*MacipACLAdd) GetMessageType() api.MessageType { return api.RequestMessage } func (m *MacipACLAdd) Size() int { @@ -1741,15 +1817,17 @@ func (m *MacipACLAdd) Size() int { } // field[2] s1.IsPermit size += 1 - // field[2] s1.IsIPv6 - size += 1 // field[2] s1.SrcMac size += 6 // field[2] s1.SrcMacMask size += 6 - // field[2] s1.SrcIPAddr + // field[2] s1.SrcPrefix + // field[3] s1.SrcPrefix.Address + // field[4] s1.SrcPrefix.Address.Af + size += 1 + // field[4] s1.SrcPrefix.Address.Un size += 16 - // field[2] s1.SrcIPPrefixLen + // field[3] s1.SrcPrefix.Len size += 1 } return size @@ -1766,14 +1844,8 @@ func (m *MacipACLAdd) Marshal(b []byte) ([]byte, error) { buf = b } // field[1] m.Tag - for i := 0; i < 64; i++ { - var x uint8 - if i < len(m.Tag) { - x = uint8(m.Tag[i]) - } - buf[pos] = uint8(x) - pos += 1 - } + copy(buf[pos:pos+64], m.Tag) + pos += 64 // field[1] m.Count o.PutUint32(buf[pos:pos+4], uint32(len(m.R))) pos += 4 @@ -1786,9 +1858,6 @@ func (m *MacipACLAdd) Marshal(b []byte) ([]byte, error) { // field[2] v1.IsPermit buf[pos] = uint8(v1.IsPermit) pos += 1 - // field[2] v1.IsIPv6 - buf[pos] = uint8(v1.IsIPv6) - pos += 1 // field[2] v1.SrcMac for i := 0; i < 6; i++ { var x uint8 @@ -1807,17 +1876,16 @@ func (m *MacipACLAdd) Marshal(b []byte) ([]byte, error) { buf[pos] = uint8(x) pos += 1 } - // field[2] v1.SrcIPAddr - for i := 0; i < 16; i++ { - var x uint8 - if i < len(v1.SrcIPAddr) { - x = uint8(v1.SrcIPAddr[i]) - } - buf[pos] = uint8(x) - pos += 1 - } - // field[2] v1.SrcIPPrefixLen - buf[pos] = uint8(v1.SrcIPPrefixLen) + // field[2] v1.SrcPrefix + // field[3] v1.SrcPrefix.Address + // field[4] v1.SrcPrefix.Address.Af + buf[pos] = uint8(v1.SrcPrefix.Address.Af) + pos += 1 + // field[4] v1.SrcPrefix.Address.Un + copy(buf[pos:pos+16], v1.SrcPrefix.Address.Un.XXX_UnionData[:]) + pos += 16 + // field[3] v1.SrcPrefix.Len + buf[pos] = uint8(v1.SrcPrefix.Len) pos += 1 } return buf, nil @@ -1828,10 +1896,10 @@ func (m *MacipACLAdd) Unmarshal(tmp []byte) error { pos := 0 _ = pos // field[1] m.Tag - m.Tag = make([]uint8, 64) - for i := 0; i < len(m.Tag); i++ { - m.Tag[i] = uint8(tmp[pos]) - pos += 1 + { + nul := bytes.Index(tmp[pos:pos+64], []byte{0x00}) + m.Tag = codec.DecodeString(tmp[pos : pos+nul]) + pos += 64 } // field[1] m.Count m.Count = uint32(o.Uint32(tmp[pos : pos+4])) @@ -1840,31 +1908,28 @@ func (m *MacipACLAdd) Unmarshal(tmp []byte) error { m.R = make([]MacipACLRule, int(m.Count)) for j1 := 0; j1 < int(m.Count); j1++ { // field[2] m.R[j1].IsPermit - m.R[j1].IsPermit = uint8(tmp[pos]) - pos += 1 - // field[2] m.R[j1].IsIPv6 - m.R[j1].IsIPv6 = uint8(tmp[pos]) + m.R[j1].IsPermit = ACLAction(tmp[pos]) pos += 1 // field[2] m.R[j1].SrcMac - m.R[j1].SrcMac = make([]uint8, 6) for i := 0; i < len(m.R[j1].SrcMac); i++ { m.R[j1].SrcMac[i] = uint8(tmp[pos]) pos += 1 } // field[2] m.R[j1].SrcMacMask - m.R[j1].SrcMacMask = make([]uint8, 6) for i := 0; i < len(m.R[j1].SrcMacMask); i++ { m.R[j1].SrcMacMask[i] = uint8(tmp[pos]) pos += 1 } - // field[2] m.R[j1].SrcIPAddr - m.R[j1].SrcIPAddr = make([]uint8, 16) - for i := 0; i < len(m.R[j1].SrcIPAddr); i++ { - m.R[j1].SrcIPAddr[i] = uint8(tmp[pos]) - pos += 1 - } - // field[2] m.R[j1].SrcIPPrefixLen - m.R[j1].SrcIPPrefixLen = uint8(tmp[pos]) + // field[2] m.R[j1].SrcPrefix + // field[3] m.R[j1].SrcPrefix.Address + // field[4] m.R[j1].SrcPrefix.Address.Af + m.R[j1].SrcPrefix.Address.Af = AddressFamily(tmp[pos]) + pos += 1 + // field[4] m.R[j1].SrcPrefix.Address.Un + copy(m.R[j1].SrcPrefix.Address.Un.XXX_UnionData[:], tmp[pos:pos+16]) + pos += 16 + // field[3] m.R[j1].SrcPrefix.Len + m.R[j1].SrcPrefix.Len = uint8(tmp[pos]) pos += 1 } return nil @@ -1872,15 +1937,15 @@ func (m *MacipACLAdd) Unmarshal(tmp []byte) error { // MacipACLAddReplace represents VPP binary API message 'macip_acl_add_replace'. type MacipACLAddReplace struct { - ACLIndex uint32 `binapi:"u32,name=acl_index" json:"acl_index,omitempty"` - Tag []byte `binapi:"u8[64],name=tag" json:"tag,omitempty" struc:"[64]byte"` + ACLIndex uint32 `binapi:"u32,name=acl_index,default=4.294967295e+09" json:"acl_index,omitempty"` + Tag string `binapi:"string[64],name=tag" json:"tag,omitempty" struc:"[64]byte"` Count uint32 `binapi:"u32,name=count" json:"count,omitempty" struc:"sizeof=R"` R []MacipACLRule `binapi:"macip_acl_rule[count],name=r" json:"r,omitempty"` } func (m *MacipACLAddReplace) Reset() { *m = MacipACLAddReplace{} } func (*MacipACLAddReplace) GetMessageName() string { return "macip_acl_add_replace" } -func (*MacipACLAddReplace) GetCrcString() string { return "d3d313e7" } +func (*MacipACLAddReplace) GetCrcString() string { return "e34402a7" } func (*MacipACLAddReplace) GetMessageType() api.MessageType { return api.RequestMessage } func (m *MacipACLAddReplace) Size() int { @@ -1903,15 +1968,17 @@ func (m *MacipACLAddReplace) Size() int { } // field[2] s1.IsPermit size += 1 - // field[2] s1.IsIPv6 - size += 1 // field[2] s1.SrcMac size += 6 // field[2] s1.SrcMacMask size += 6 - // field[2] s1.SrcIPAddr + // field[2] s1.SrcPrefix + // field[3] s1.SrcPrefix.Address + // field[4] s1.SrcPrefix.Address.Af + size += 1 + // field[4] s1.SrcPrefix.Address.Un size += 16 - // field[2] s1.SrcIPPrefixLen + // field[3] s1.SrcPrefix.Len size += 1 } return size @@ -1931,14 +1998,8 @@ func (m *MacipACLAddReplace) Marshal(b []byte) ([]byte, error) { o.PutUint32(buf[pos:pos+4], uint32(m.ACLIndex)) pos += 4 // field[1] m.Tag - for i := 0; i < 64; i++ { - var x uint8 - if i < len(m.Tag) { - x = uint8(m.Tag[i]) - } - buf[pos] = uint8(x) - pos += 1 - } + copy(buf[pos:pos+64], m.Tag) + pos += 64 // field[1] m.Count o.PutUint32(buf[pos:pos+4], uint32(len(m.R))) pos += 4 @@ -1951,9 +2012,6 @@ func (m *MacipACLAddReplace) Marshal(b []byte) ([]byte, error) { // field[2] v1.IsPermit buf[pos] = uint8(v1.IsPermit) pos += 1 - // field[2] v1.IsIPv6 - buf[pos] = uint8(v1.IsIPv6) - pos += 1 // field[2] v1.SrcMac for i := 0; i < 6; i++ { var x uint8 @@ -1972,17 +2030,16 @@ func (m *MacipACLAddReplace) Marshal(b []byte) ([]byte, error) { buf[pos] = uint8(x) pos += 1 } - // field[2] v1.SrcIPAddr - for i := 0; i < 16; i++ { - var x uint8 - if i < len(v1.SrcIPAddr) { - x = uint8(v1.SrcIPAddr[i]) - } - buf[pos] = uint8(x) - pos += 1 - } - // field[2] v1.SrcIPPrefixLen - buf[pos] = uint8(v1.SrcIPPrefixLen) + // field[2] v1.SrcPrefix + // field[3] v1.SrcPrefix.Address + // field[4] v1.SrcPrefix.Address.Af + buf[pos] = uint8(v1.SrcPrefix.Address.Af) + pos += 1 + // field[4] v1.SrcPrefix.Address.Un + copy(buf[pos:pos+16], v1.SrcPrefix.Address.Un.XXX_UnionData[:]) + pos += 16 + // field[3] v1.SrcPrefix.Len + buf[pos] = uint8(v1.SrcPrefix.Len) pos += 1 } return buf, nil @@ -1996,10 +2053,10 @@ func (m *MacipACLAddReplace) Unmarshal(tmp []byte) error { m.ACLIndex = uint32(o.Uint32(tmp[pos : pos+4])) pos += 4 // field[1] m.Tag - m.Tag = make([]uint8, 64) - for i := 0; i < len(m.Tag); i++ { - m.Tag[i] = uint8(tmp[pos]) - pos += 1 + { + nul := bytes.Index(tmp[pos:pos+64], []byte{0x00}) + m.Tag = codec.DecodeString(tmp[pos : pos+nul]) + pos += 64 } // field[1] m.Count m.Count = uint32(o.Uint32(tmp[pos : pos+4])) @@ -2008,31 +2065,28 @@ func (m *MacipACLAddReplace) Unmarshal(tmp []byte) error { m.R = make([]MacipACLRule, int(m.Count)) for j1 := 0; j1 < int(m.Count); j1++ { // field[2] m.R[j1].IsPermit - m.R[j1].IsPermit = uint8(tmp[pos]) - pos += 1 - // field[2] m.R[j1].IsIPv6 - m.R[j1].IsIPv6 = uint8(tmp[pos]) + m.R[j1].IsPermit = ACLAction(tmp[pos]) pos += 1 // field[2] m.R[j1].SrcMac - m.R[j1].SrcMac = make([]uint8, 6) for i := 0; i < len(m.R[j1].SrcMac); i++ { m.R[j1].SrcMac[i] = uint8(tmp[pos]) pos += 1 } // field[2] m.R[j1].SrcMacMask - m.R[j1].SrcMacMask = make([]uint8, 6) for i := 0; i < len(m.R[j1].SrcMacMask); i++ { m.R[j1].SrcMacMask[i] = uint8(tmp[pos]) pos += 1 } - // field[2] m.R[j1].SrcIPAddr - m.R[j1].SrcIPAddr = make([]uint8, 16) - for i := 0; i < len(m.R[j1].SrcIPAddr); i++ { - m.R[j1].SrcIPAddr[i] = uint8(tmp[pos]) - pos += 1 - } - // field[2] m.R[j1].SrcIPPrefixLen - m.R[j1].SrcIPPrefixLen = uint8(tmp[pos]) + // field[2] m.R[j1].SrcPrefix + // field[3] m.R[j1].SrcPrefix.Address + // field[4] m.R[j1].SrcPrefix.Address.Af + m.R[j1].SrcPrefix.Address.Af = AddressFamily(tmp[pos]) + pos += 1 + // field[4] m.R[j1].SrcPrefix.Address.Un + copy(m.R[j1].SrcPrefix.Address.Un.XXX_UnionData[:], tmp[pos:pos+16]) + pos += 16 + // field[3] m.R[j1].SrcPrefix.Len + m.R[j1].SrcPrefix.Len = uint8(tmp[pos]) pos += 1 } return nil @@ -2243,14 +2297,14 @@ func (m *MacipACLDelReply) Unmarshal(tmp []byte) error { // MacipACLDetails represents VPP binary API message 'macip_acl_details'. type MacipACLDetails struct { ACLIndex uint32 `binapi:"u32,name=acl_index" json:"acl_index,omitempty"` - Tag []byte `binapi:"u8[64],name=tag" json:"tag,omitempty" struc:"[64]byte"` + Tag string `binapi:"string[64],name=tag" json:"tag,omitempty" struc:"[64]byte"` Count uint32 `binapi:"u32,name=count" json:"count,omitempty" struc:"sizeof=R"` R []MacipACLRule `binapi:"macip_acl_rule[count],name=r" json:"r,omitempty"` } func (m *MacipACLDetails) Reset() { *m = MacipACLDetails{} } func (*MacipACLDetails) GetMessageName() string { return "macip_acl_details" } -func (*MacipACLDetails) GetCrcString() string { return "e164e69a" } +func (*MacipACLDetails) GetCrcString() string { return "57c7482f" } func (*MacipACLDetails) GetMessageType() api.MessageType { return api.ReplyMessage } func (m *MacipACLDetails) Size() int { @@ -2273,15 +2327,17 @@ func (m *MacipACLDetails) Size() int { } // field[2] s1.IsPermit size += 1 - // field[2] s1.IsIPv6 - size += 1 // field[2] s1.SrcMac size += 6 // field[2] s1.SrcMacMask size += 6 - // field[2] s1.SrcIPAddr + // field[2] s1.SrcPrefix + // field[3] s1.SrcPrefix.Address + // field[4] s1.SrcPrefix.Address.Af + size += 1 + // field[4] s1.SrcPrefix.Address.Un size += 16 - // field[2] s1.SrcIPPrefixLen + // field[3] s1.SrcPrefix.Len size += 1 } return size @@ -2301,14 +2357,8 @@ func (m *MacipACLDetails) Marshal(b []byte) ([]byte, error) { o.PutUint32(buf[pos:pos+4], uint32(m.ACLIndex)) pos += 4 // field[1] m.Tag - for i := 0; i < 64; i++ { - var x uint8 - if i < len(m.Tag) { - x = uint8(m.Tag[i]) - } - buf[pos] = uint8(x) - pos += 1 - } + copy(buf[pos:pos+64], m.Tag) + pos += 64 // field[1] m.Count o.PutUint32(buf[pos:pos+4], uint32(len(m.R))) pos += 4 @@ -2321,9 +2371,6 @@ func (m *MacipACLDetails) Marshal(b []byte) ([]byte, error) { // field[2] v1.IsPermit buf[pos] = uint8(v1.IsPermit) pos += 1 - // field[2] v1.IsIPv6 - buf[pos] = uint8(v1.IsIPv6) - pos += 1 // field[2] v1.SrcMac for i := 0; i < 6; i++ { var x uint8 @@ -2342,17 +2389,16 @@ func (m *MacipACLDetails) Marshal(b []byte) ([]byte, error) { buf[pos] = uint8(x) pos += 1 } - // field[2] v1.SrcIPAddr - for i := 0; i < 16; i++ { - var x uint8 - if i < len(v1.SrcIPAddr) { - x = uint8(v1.SrcIPAddr[i]) - } - buf[pos] = uint8(x) - pos += 1 - } - // field[2] v1.SrcIPPrefixLen - buf[pos] = uint8(v1.SrcIPPrefixLen) + // field[2] v1.SrcPrefix + // field[3] v1.SrcPrefix.Address + // field[4] v1.SrcPrefix.Address.Af + buf[pos] = uint8(v1.SrcPrefix.Address.Af) + pos += 1 + // field[4] v1.SrcPrefix.Address.Un + copy(buf[pos:pos+16], v1.SrcPrefix.Address.Un.XXX_UnionData[:]) + pos += 16 + // field[3] v1.SrcPrefix.Len + buf[pos] = uint8(v1.SrcPrefix.Len) pos += 1 } return buf, nil @@ -2366,10 +2412,10 @@ func (m *MacipACLDetails) Unmarshal(tmp []byte) error { m.ACLIndex = uint32(o.Uint32(tmp[pos : pos+4])) pos += 4 // field[1] m.Tag - m.Tag = make([]uint8, 64) - for i := 0; i < len(m.Tag); i++ { - m.Tag[i] = uint8(tmp[pos]) - pos += 1 + { + nul := bytes.Index(tmp[pos:pos+64], []byte{0x00}) + m.Tag = codec.DecodeString(tmp[pos : pos+nul]) + pos += 64 } // field[1] m.Count m.Count = uint32(o.Uint32(tmp[pos : pos+4])) @@ -2378,31 +2424,28 @@ func (m *MacipACLDetails) Unmarshal(tmp []byte) error { m.R = make([]MacipACLRule, int(m.Count)) for j1 := 0; j1 < int(m.Count); j1++ { // field[2] m.R[j1].IsPermit - m.R[j1].IsPermit = uint8(tmp[pos]) - pos += 1 - // field[2] m.R[j1].IsIPv6 - m.R[j1].IsIPv6 = uint8(tmp[pos]) + m.R[j1].IsPermit = ACLAction(tmp[pos]) pos += 1 // field[2] m.R[j1].SrcMac - m.R[j1].SrcMac = make([]uint8, 6) for i := 0; i < len(m.R[j1].SrcMac); i++ { m.R[j1].SrcMac[i] = uint8(tmp[pos]) pos += 1 } // field[2] m.R[j1].SrcMacMask - m.R[j1].SrcMacMask = make([]uint8, 6) for i := 0; i < len(m.R[j1].SrcMacMask); i++ { m.R[j1].SrcMacMask[i] = uint8(tmp[pos]) pos += 1 } - // field[2] m.R[j1].SrcIPAddr - m.R[j1].SrcIPAddr = make([]uint8, 16) - for i := 0; i < len(m.R[j1].SrcIPAddr); i++ { - m.R[j1].SrcIPAddr[i] = uint8(tmp[pos]) - pos += 1 - } - // field[2] m.R[j1].SrcIPPrefixLen - m.R[j1].SrcIPPrefixLen = uint8(tmp[pos]) + // field[2] m.R[j1].SrcPrefix + // field[3] m.R[j1].SrcPrefix.Address + // field[4] m.R[j1].SrcPrefix.Address.Af + m.R[j1].SrcPrefix.Address.Af = AddressFamily(tmp[pos]) + pos += 1 + // field[4] m.R[j1].SrcPrefix.Address.Un + copy(m.R[j1].SrcPrefix.Address.Un.XXX_UnionData[:], tmp[pos:pos+16]) + pos += 16 + // field[3] m.R[j1].SrcPrefix.Len + m.R[j1].SrcPrefix.Len = uint8(tmp[pos]) pos += 1 } return nil @@ -2410,7 +2453,7 @@ func (m *MacipACLDetails) Unmarshal(tmp []byte) error { // MacipACLDump represents VPP binary API message 'macip_acl_dump'. type MacipACLDump struct { - ACLIndex uint32 `binapi:"u32,name=acl_index" json:"acl_index,omitempty"` + ACLIndex uint32 `binapi:"u32,name=acl_index,default=4.294967295e+09" json:"acl_index,omitempty"` } func (m *MacipACLDump) Reset() { *m = MacipACLDump{} } @@ -2456,14 +2499,14 @@ func (m *MacipACLDump) Unmarshal(tmp []byte) error { // MacipACLInterfaceAddDel represents VPP binary API message 'macip_acl_interface_add_del'. type MacipACLInterfaceAddDel struct { - IsAdd uint8 `binapi:"u8,name=is_add" json:"is_add,omitempty"` - SwIfIndex uint32 `binapi:"u32,name=sw_if_index" json:"sw_if_index,omitempty"` - ACLIndex uint32 `binapi:"u32,name=acl_index" json:"acl_index,omitempty"` + IsAdd bool `binapi:"bool,name=is_add,default=true" json:"is_add,omitempty"` + SwIfIndex InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + ACLIndex uint32 `binapi:"u32,name=acl_index" json:"acl_index,omitempty"` } func (m *MacipACLInterfaceAddDel) Reset() { *m = MacipACLInterfaceAddDel{} } func (*MacipACLInterfaceAddDel) GetMessageName() string { return "macip_acl_interface_add_del" } -func (*MacipACLInterfaceAddDel) GetCrcString() string { return "6a6be97c" } +func (*MacipACLInterfaceAddDel) GetCrcString() string { return "4b8690b1" } func (*MacipACLInterfaceAddDel) GetMessageType() api.MessageType { return api.RequestMessage } func (m *MacipACLInterfaceAddDel) Size() int { @@ -2491,7 +2534,9 @@ func (m *MacipACLInterfaceAddDel) Marshal(b []byte) ([]byte, error) { buf = b } // field[1] m.IsAdd - buf[pos] = uint8(m.IsAdd) + if m.IsAdd { + buf[pos] = 1 + } pos += 1 // field[1] m.SwIfIndex o.PutUint32(buf[pos:pos+4], uint32(m.SwIfIndex)) @@ -2507,10 +2552,10 @@ func (m *MacipACLInterfaceAddDel) Unmarshal(tmp []byte) error { pos := 0 _ = pos // field[1] m.IsAdd - m.IsAdd = uint8(tmp[pos]) + m.IsAdd = tmp[pos] != 0 pos += 1 // field[1] m.SwIfIndex - m.SwIfIndex = uint32(o.Uint32(tmp[pos : pos+4])) + m.SwIfIndex = InterfaceIndex(o.Uint32(tmp[pos : pos+4])) pos += 4 // field[1] m.ACLIndex m.ACLIndex = uint32(o.Uint32(tmp[pos : pos+4])) @@ -2668,16 +2713,16 @@ func (m *MacipACLInterfaceGetReply) Unmarshal(tmp []byte) error { // MacipACLInterfaceListDetails represents VPP binary API message 'macip_acl_interface_list_details'. type MacipACLInterfaceListDetails struct { - SwIfIndex uint32 `binapi:"u32,name=sw_if_index" json:"sw_if_index,omitempty"` - Count uint8 `binapi:"u8,name=count" json:"count,omitempty" struc:"sizeof=Acls"` - Acls []uint32 `binapi:"u32[count],name=acls" json:"acls,omitempty"` + SwIfIndex InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + Count uint8 `binapi:"u8,name=count" json:"count,omitempty" struc:"sizeof=Acls"` + Acls []uint32 `binapi:"u32[count],name=acls" json:"acls,omitempty"` } func (m *MacipACLInterfaceListDetails) Reset() { *m = MacipACLInterfaceListDetails{} } func (*MacipACLInterfaceListDetails) GetMessageName() string { return "macip_acl_interface_list_details" } -func (*MacipACLInterfaceListDetails) GetCrcString() string { return "29783fa0" } +func (*MacipACLInterfaceListDetails) GetCrcString() string { return "a0c5d56d" } func (*MacipACLInterfaceListDetails) GetMessageType() api.MessageType { return api.ReplyMessage } func (m *MacipACLInterfaceListDetails) Size() int { @@ -2727,7 +2772,7 @@ func (m *MacipACLInterfaceListDetails) Unmarshal(tmp []byte) error { pos := 0 _ = pos // field[1] m.SwIfIndex - m.SwIfIndex = uint32(o.Uint32(tmp[pos : pos+4])) + m.SwIfIndex = InterfaceIndex(o.Uint32(tmp[pos : pos+4])) pos += 4 // field[1] m.Count m.Count = uint8(tmp[pos]) @@ -2743,12 +2788,12 @@ func (m *MacipACLInterfaceListDetails) Unmarshal(tmp []byte) error { // MacipACLInterfaceListDump represents VPP binary API message 'macip_acl_interface_list_dump'. type MacipACLInterfaceListDump struct { - SwIfIndex uint32 `binapi:"u32,name=sw_if_index" json:"sw_if_index,omitempty"` + SwIfIndex InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` } func (m *MacipACLInterfaceListDump) Reset() { *m = MacipACLInterfaceListDump{} } func (*MacipACLInterfaceListDump) GetMessageName() string { return "macip_acl_interface_list_dump" } -func (*MacipACLInterfaceListDump) GetCrcString() string { return "529cb13f" } +func (*MacipACLInterfaceListDump) GetCrcString() string { return "f9e6675e" } func (*MacipACLInterfaceListDump) GetMessageType() api.MessageType { return api.RequestMessage } func (m *MacipACLInterfaceListDump) Size() int { @@ -2782,7 +2827,7 @@ func (m *MacipACLInterfaceListDump) Unmarshal(tmp []byte) error { pos := 0 _ = pos // field[1] m.SwIfIndex - m.SwIfIndex = uint32(o.Uint32(tmp[pos : pos+4])) + m.SwIfIndex = InterfaceIndex(o.Uint32(tmp[pos : pos+4])) pos += 4 return nil } diff --git a/examples/binapi/af_packet/af_packet.ba.go b/examples/binapi/af_packet/af_packet.ba.go index ab57c62..d2cc52b 100644 --- a/examples/binapi/af_packet/af_packet.ba.go +++ b/examples/binapi/af_packet/af_packet.ba.go @@ -1,11 +1,11 @@ // Code generated by GoVPP's binapi-generator. DO NOT EDIT. // versions: -// binapi-generator: v0.4.0-alpha-1-g435c3f4-dirty -// VPP: 20.01-45~g7a071e370~b63 +// binapi-generator: v0.4.0-dev +// VPP: 20.05-release // source: /usr/share/vpp/api/core/af_packet.api.json /* -Package af_packet contains generated code for VPP binary API defined by af_packet.api (version 2.0.0). +Package af_packet contains generated code for VPP API file af_packet.api (2.0.0). It consists of: 2 aliases @@ -25,6 +25,8 @@ import ( api "git.fd.io/govpp.git/api" codec "git.fd.io/govpp.git/codec" struc "github.com/lunixbochs/struc" + + interface_types "git.fd.io/govpp.git/examples/binapi/interface_types" ) // This is a compile-time assertion to ensure that this generated file @@ -39,224 +41,22 @@ const ( // APIVersion is the API version of this module. APIVersion = "2.0.0" // VersionCrc is the CRC of this module. - VersionCrc = 0xba745e20 -) - -// IfStatusFlags represents VPP binary API enum 'if_status_flags'. -type IfStatusFlags uint32 - -const ( - IF_STATUS_API_FLAG_ADMIN_UP IfStatusFlags = 1 - IF_STATUS_API_FLAG_LINK_UP IfStatusFlags = 2 + VersionCrc = 0xe0b6c022 ) -var ( - IfStatusFlags_name = map[uint32]string{ - 1: "IF_STATUS_API_FLAG_ADMIN_UP", - 2: "IF_STATUS_API_FLAG_LINK_UP", - } - IfStatusFlags_value = map[string]uint32{ - "IF_STATUS_API_FLAG_ADMIN_UP": 1, - "IF_STATUS_API_FLAG_LINK_UP": 2, - } -) +type IfStatusFlags = interface_types.IfStatusFlags -func (x IfStatusFlags) String() string { - s, ok := IfStatusFlags_name[uint32(x)] - if ok { - return s - } - return "IfStatusFlags(" + strconv.Itoa(int(x)) + ")" -} +type IfType = interface_types.IfType -// IfType represents VPP binary API enum 'if_type'. -type IfType uint32 +type LinkDuplex = interface_types.LinkDuplex -const ( - IF_API_TYPE_HARDWARE IfType = 1 - IF_API_TYPE_SUB IfType = 2 - IF_API_TYPE_P2P IfType = 3 - IF_API_TYPE_PIPE IfType = 4 -) +type MtuProto = interface_types.MtuProto -var ( - IfType_name = map[uint32]string{ - 1: "IF_API_TYPE_HARDWARE", - 2: "IF_API_TYPE_SUB", - 3: "IF_API_TYPE_P2P", - 4: "IF_API_TYPE_PIPE", - } - IfType_value = map[string]uint32{ - "IF_API_TYPE_HARDWARE": 1, - "IF_API_TYPE_SUB": 2, - "IF_API_TYPE_P2P": 3, - "IF_API_TYPE_PIPE": 4, - } -) +type RxMode = interface_types.RxMode -func (x IfType) String() string { - s, ok := IfType_name[uint32(x)] - if ok { - return s - } - return "IfType(" + strconv.Itoa(int(x)) + ")" -} - -// LinkDuplex represents VPP binary API enum 'link_duplex'. -type LinkDuplex uint32 - -const ( - LINK_DUPLEX_API_UNKNOWN LinkDuplex = 0 - LINK_DUPLEX_API_HALF LinkDuplex = 1 - LINK_DUPLEX_API_FULL LinkDuplex = 2 -) - -var ( - LinkDuplex_name = map[uint32]string{ - 0: "LINK_DUPLEX_API_UNKNOWN", - 1: "LINK_DUPLEX_API_HALF", - 2: "LINK_DUPLEX_API_FULL", - } - LinkDuplex_value = map[string]uint32{ - "LINK_DUPLEX_API_UNKNOWN": 0, - "LINK_DUPLEX_API_HALF": 1, - "LINK_DUPLEX_API_FULL": 2, - } -) - -func (x LinkDuplex) String() string { - s, ok := LinkDuplex_name[uint32(x)] - if ok { - return s - } - return "LinkDuplex(" + strconv.Itoa(int(x)) + ")" -} - -// MtuProto represents VPP binary API enum 'mtu_proto'. -type MtuProto uint32 - -const ( - MTU_PROTO_API_L3 MtuProto = 1 - MTU_PROTO_API_IP4 MtuProto = 2 - MTU_PROTO_API_IP6 MtuProto = 3 - MTU_PROTO_API_MPLS MtuProto = 4 - MTU_PROTO_API_N MtuProto = 5 -) - -var ( - MtuProto_name = map[uint32]string{ - 1: "MTU_PROTO_API_L3", - 2: "MTU_PROTO_API_IP4", - 3: "MTU_PROTO_API_IP6", - 4: "MTU_PROTO_API_MPLS", - 5: "MTU_PROTO_API_N", - } - MtuProto_value = map[string]uint32{ - "MTU_PROTO_API_L3": 1, - "MTU_PROTO_API_IP4": 2, - "MTU_PROTO_API_IP6": 3, - "MTU_PROTO_API_MPLS": 4, - "MTU_PROTO_API_N": 5, - } -) - -func (x MtuProto) String() string { - s, ok := MtuProto_name[uint32(x)] - if ok { - return s - } - return "MtuProto(" + strconv.Itoa(int(x)) + ")" -} - -// RxMode represents VPP binary API enum 'rx_mode'. -type RxMode uint32 - -const ( - RX_MODE_API_UNKNOWN RxMode = 0 - RX_MODE_API_POLLING RxMode = 1 - RX_MODE_API_INTERRUPT RxMode = 2 - RX_MODE_API_ADAPTIVE RxMode = 3 - RX_MODE_API_DEFAULT RxMode = 4 -) - -var ( - RxMode_name = map[uint32]string{ - 0: "RX_MODE_API_UNKNOWN", - 1: "RX_MODE_API_POLLING", - 2: "RX_MODE_API_INTERRUPT", - 3: "RX_MODE_API_ADAPTIVE", - 4: "RX_MODE_API_DEFAULT", - } - RxMode_value = map[string]uint32{ - "RX_MODE_API_UNKNOWN": 0, - "RX_MODE_API_POLLING": 1, - "RX_MODE_API_INTERRUPT": 2, - "RX_MODE_API_ADAPTIVE": 3, - "RX_MODE_API_DEFAULT": 4, - } -) - -func (x RxMode) String() string { - s, ok := RxMode_name[uint32(x)] - if ok { - return s - } - return "RxMode(" + strconv.Itoa(int(x)) + ")" -} - -// SubIfFlags represents VPP binary API enum 'sub_if_flags'. -type SubIfFlags uint32 - -const ( - SUB_IF_API_FLAG_NO_TAGS SubIfFlags = 1 - SUB_IF_API_FLAG_ONE_TAG SubIfFlags = 2 - SUB_IF_API_FLAG_TWO_TAGS SubIfFlags = 4 - SUB_IF_API_FLAG_DOT1AD SubIfFlags = 8 - SUB_IF_API_FLAG_EXACT_MATCH SubIfFlags = 16 - SUB_IF_API_FLAG_DEFAULT SubIfFlags = 32 - SUB_IF_API_FLAG_OUTER_VLAN_ID_ANY SubIfFlags = 64 - SUB_IF_API_FLAG_INNER_VLAN_ID_ANY SubIfFlags = 128 - SUB_IF_API_FLAG_MASK_VNET SubIfFlags = 254 - SUB_IF_API_FLAG_DOT1AH SubIfFlags = 256 -) - -var ( - SubIfFlags_name = map[uint32]string{ - 1: "SUB_IF_API_FLAG_NO_TAGS", - 2: "SUB_IF_API_FLAG_ONE_TAG", - 4: "SUB_IF_API_FLAG_TWO_TAGS", - 8: "SUB_IF_API_FLAG_DOT1AD", - 16: "SUB_IF_API_FLAG_EXACT_MATCH", - 32: "SUB_IF_API_FLAG_DEFAULT", - 64: "SUB_IF_API_FLAG_OUTER_VLAN_ID_ANY", - 128: "SUB_IF_API_FLAG_INNER_VLAN_ID_ANY", - 254: "SUB_IF_API_FLAG_MASK_VNET", - 256: "SUB_IF_API_FLAG_DOT1AH", - } - SubIfFlags_value = map[string]uint32{ - "SUB_IF_API_FLAG_NO_TAGS": 1, - "SUB_IF_API_FLAG_ONE_TAG": 2, - "SUB_IF_API_FLAG_TWO_TAGS": 4, - "SUB_IF_API_FLAG_DOT1AD": 8, - "SUB_IF_API_FLAG_EXACT_MATCH": 16, - "SUB_IF_API_FLAG_DEFAULT": 32, - "SUB_IF_API_FLAG_OUTER_VLAN_ID_ANY": 64, - "SUB_IF_API_FLAG_INNER_VLAN_ID_ANY": 128, - "SUB_IF_API_FLAG_MASK_VNET": 254, - "SUB_IF_API_FLAG_DOT1AH": 256, - } -) - -func (x SubIfFlags) String() string { - s, ok := SubIfFlags_name[uint32(x)] - if ok { - return s - } - return "SubIfFlags(" + strconv.Itoa(int(x)) + ")" -} +type SubIfFlags = interface_types.SubIfFlags -// InterfaceIndex represents VPP binary API alias 'interface_index'. -type InterfaceIndex uint32 +type InterfaceIndex = interface_types.InterfaceIndex // MacAddress represents VPP binary API alias 'mac_address'. type MacAddress [6]uint8 diff --git a/examples/binapi/fib_types/fib_types.ba.go b/examples/binapi/fib_types/fib_types.ba.go index dd725b6..1d824e5 100644 --- a/examples/binapi/fib_types/fib_types.ba.go +++ b/examples/binapi/fib_types/fib_types.ba.go @@ -1,11 +1,11 @@ // Code generated by GoVPP's binapi-generator. DO NOT EDIT. // versions: -// binapi-generator: v0.4.0-alpha-1-g435c3f4-dirty -// VPP: 20.01-45~g7a071e370~b63 +// binapi-generator: v0.4.0-dev +// VPP: 20.05-release // source: /usr/share/vpp/api/core/fib_types.api.json /* -Package fib_types contains generated code for VPP binary API defined by fib_types.api (version 2.0.0). +Package fib_types contains generated code for VPP API file fib_types.api (2.0.0). It consists of: 5 aliases @@ -26,6 +26,8 @@ import ( api "git.fd.io/govpp.git/api" codec "git.fd.io/govpp.git/codec" struc "github.com/lunixbochs/struc" + + ip_types "git.fd.io/govpp.git/examples/binapi/ip_types" ) // This is a compile-time assertion to ensure that this generated file @@ -40,35 +42,10 @@ const ( // APIVersion is the API version of this module. APIVersion = "2.0.0" // VersionCrc is the CRC of this module. - VersionCrc = 0x57387845 -) - -// AddressFamily represents VPP binary API enum 'address_family'. -type AddressFamily uint32 - -const ( - ADDRESS_IP4 AddressFamily = 0 - ADDRESS_IP6 AddressFamily = 1 -) - -var ( - AddressFamily_name = map[uint32]string{ - 0: "ADDRESS_IP4", - 1: "ADDRESS_IP6", - } - AddressFamily_value = map[string]uint32{ - "ADDRESS_IP4": 0, - "ADDRESS_IP6": 1, - } + VersionCrc = 0xd6a5938 ) -func (x AddressFamily) String() string { - s, ok := AddressFamily_name[uint32(x)] - if ok { - return s - } - return "AddressFamily(" + strconv.Itoa(int(x)) + ")" -} +type AddressFamily = ip_types.AddressFamily // FibPathFlags represents VPP binary API enum 'fib_path_flags'. type FibPathFlags uint32 @@ -193,202 +170,23 @@ func (x FibPathType) String() string { return "FibPathType(" + strconv.Itoa(int(x)) + ")" } -// IPDscp represents VPP binary API enum 'ip_dscp'. -type IPDscp uint8 +type IPDscp = ip_types.IPDscp -const ( - IP_API_DSCP_CS0 IPDscp = 0 - IP_API_DSCP_CS1 IPDscp = 8 - IP_API_DSCP_AF11 IPDscp = 10 - IP_API_DSCP_AF12 IPDscp = 12 - IP_API_DSCP_AF13 IPDscp = 14 - IP_API_DSCP_CS2 IPDscp = 16 - IP_API_DSCP_AF21 IPDscp = 18 - IP_API_DSCP_AF22 IPDscp = 20 - IP_API_DSCP_AF23 IPDscp = 22 - IP_API_DSCP_CS3 IPDscp = 24 - IP_API_DSCP_AF31 IPDscp = 26 - IP_API_DSCP_AF32 IPDscp = 28 - IP_API_DSCP_AF33 IPDscp = 30 - IP_API_DSCP_CS4 IPDscp = 32 - IP_API_DSCP_AF41 IPDscp = 34 - IP_API_DSCP_AF42 IPDscp = 36 - IP_API_DSCP_AF43 IPDscp = 38 - IP_API_DSCP_CS5 IPDscp = 40 - IP_API_DSCP_EF IPDscp = 46 - IP_API_DSCP_CS6 IPDscp = 48 - IP_API_DSCP_CS7 IPDscp = 50 -) +type IPEcn = ip_types.IPEcn -var ( - IPDscp_name = map[uint8]string{ - 0: "IP_API_DSCP_CS0", - 8: "IP_API_DSCP_CS1", - 10: "IP_API_DSCP_AF11", - 12: "IP_API_DSCP_AF12", - 14: "IP_API_DSCP_AF13", - 16: "IP_API_DSCP_CS2", - 18: "IP_API_DSCP_AF21", - 20: "IP_API_DSCP_AF22", - 22: "IP_API_DSCP_AF23", - 24: "IP_API_DSCP_CS3", - 26: "IP_API_DSCP_AF31", - 28: "IP_API_DSCP_AF32", - 30: "IP_API_DSCP_AF33", - 32: "IP_API_DSCP_CS4", - 34: "IP_API_DSCP_AF41", - 36: "IP_API_DSCP_AF42", - 38: "IP_API_DSCP_AF43", - 40: "IP_API_DSCP_CS5", - 46: "IP_API_DSCP_EF", - 48: "IP_API_DSCP_CS6", - 50: "IP_API_DSCP_CS7", - } - IPDscp_value = map[string]uint8{ - "IP_API_DSCP_CS0": 0, - "IP_API_DSCP_CS1": 8, - "IP_API_DSCP_AF11": 10, - "IP_API_DSCP_AF12": 12, - "IP_API_DSCP_AF13": 14, - "IP_API_DSCP_CS2": 16, - "IP_API_DSCP_AF21": 18, - "IP_API_DSCP_AF22": 20, - "IP_API_DSCP_AF23": 22, - "IP_API_DSCP_CS3": 24, - "IP_API_DSCP_AF31": 26, - "IP_API_DSCP_AF32": 28, - "IP_API_DSCP_AF33": 30, - "IP_API_DSCP_CS4": 32, - "IP_API_DSCP_AF41": 34, - "IP_API_DSCP_AF42": 36, - "IP_API_DSCP_AF43": 38, - "IP_API_DSCP_CS5": 40, - "IP_API_DSCP_EF": 46, - "IP_API_DSCP_CS6": 48, - "IP_API_DSCP_CS7": 50, - } -) +type IPProto = ip_types.IPProto -func (x IPDscp) String() string { - s, ok := IPDscp_name[uint8(x)] - if ok { - return s - } - return "IPDscp(" + strconv.Itoa(int(x)) + ")" -} +type AddressWithPrefix = ip_types.AddressWithPrefix -// IPEcn represents VPP binary API enum 'ip_ecn'. -type IPEcn uint8 +type IP4Address = ip_types.IP4Address -const ( - IP_API_ECN_NONE IPEcn = 0 - IP_API_ECN_ECT0 IPEcn = 1 - IP_API_ECN_ECT1 IPEcn = 2 - IP_API_ECN_CE IPEcn = 3 -) +type IP4AddressWithPrefix = ip_types.IP4AddressWithPrefix -var ( - IPEcn_name = map[uint8]string{ - 0: "IP_API_ECN_NONE", - 1: "IP_API_ECN_ECT0", - 2: "IP_API_ECN_ECT1", - 3: "IP_API_ECN_CE", - } - IPEcn_value = map[string]uint8{ - "IP_API_ECN_NONE": 0, - "IP_API_ECN_ECT0": 1, - "IP_API_ECN_ECT1": 2, - "IP_API_ECN_CE": 3, - } -) +type IP6Address = ip_types.IP6Address -func (x IPEcn) String() string { - s, ok := IPEcn_name[uint8(x)] - if ok { - return s - } - return "IPEcn(" + strconv.Itoa(int(x)) + ")" -} +type IP6AddressWithPrefix = ip_types.IP6AddressWithPrefix -// IPProto represents VPP binary API enum 'ip_proto'. -type IPProto uint32 - -const ( - IP_API_PROTO_HOPOPT IPProto = 0 - IP_API_PROTO_ICMP IPProto = 1 - IP_API_PROTO_IGMP IPProto = 2 - IP_API_PROTO_TCP IPProto = 6 - IP_API_PROTO_UDP IPProto = 17 - IP_API_PROTO_GRE IPProto = 47 - IP_API_PROTO_AH IPProto = 50 - IP_API_PROTO_ESP IPProto = 51 - IP_API_PROTO_EIGRP IPProto = 88 - IP_API_PROTO_OSPF IPProto = 89 - IP_API_PROTO_SCTP IPProto = 132 - IP_API_PROTO_RESERVED IPProto = 255 -) - -var ( - IPProto_name = map[uint32]string{ - 0: "IP_API_PROTO_HOPOPT", - 1: "IP_API_PROTO_ICMP", - 2: "IP_API_PROTO_IGMP", - 6: "IP_API_PROTO_TCP", - 17: "IP_API_PROTO_UDP", - 47: "IP_API_PROTO_GRE", - 50: "IP_API_PROTO_AH", - 51: "IP_API_PROTO_ESP", - 88: "IP_API_PROTO_EIGRP", - 89: "IP_API_PROTO_OSPF", - 132: "IP_API_PROTO_SCTP", - 255: "IP_API_PROTO_RESERVED", - } - IPProto_value = map[string]uint32{ - "IP_API_PROTO_HOPOPT": 0, - "IP_API_PROTO_ICMP": 1, - "IP_API_PROTO_IGMP": 2, - "IP_API_PROTO_TCP": 6, - "IP_API_PROTO_UDP": 17, - "IP_API_PROTO_GRE": 47, - "IP_API_PROTO_AH": 50, - "IP_API_PROTO_ESP": 51, - "IP_API_PROTO_EIGRP": 88, - "IP_API_PROTO_OSPF": 89, - "IP_API_PROTO_SCTP": 132, - "IP_API_PROTO_RESERVED": 255, - } -) - -func (x IPProto) String() string { - s, ok := IPProto_name[uint32(x)] - if ok { - return s - } - return "IPProto(" + strconv.Itoa(int(x)) + ")" -} - -// AddressWithPrefix represents VPP binary API alias 'address_with_prefix'. -type AddressWithPrefix Prefix - -// IP4Address represents VPP binary API alias 'ip4_address'. -type IP4Address [4]uint8 - -// IP4AddressWithPrefix represents VPP binary API alias 'ip4_address_with_prefix'. -type IP4AddressWithPrefix IP4Prefix - -// IP6Address represents VPP binary API alias 'ip6_address'. -type IP6Address [16]uint8 - -// IP6AddressWithPrefix represents VPP binary API alias 'ip6_address_with_prefix'. -type IP6AddressWithPrefix IP6Prefix - -// Address represents VPP binary API type 'address'. -type Address struct { - Af AddressFamily `binapi:"address_family,name=af" json:"af,omitempty"` - Un AddressUnion `binapi:"address_union,name=un" json:"un,omitempty"` -} - -func (*Address) GetTypeName() string { return "address" } +type Address = ip_types.Address // FibMplsLabel represents VPP binary API type 'fib_mpls_label'. type FibMplsLabel struct { @@ -427,88 +225,17 @@ type FibPathNh struct { func (*FibPathNh) GetTypeName() string { return "fib_path_nh" } -// IP4Prefix represents VPP binary API type 'ip4_prefix'. -type IP4Prefix struct { - Address IP4Address `binapi:"ip4_address,name=address" json:"address,omitempty"` - Len uint8 `binapi:"u8,name=len" json:"len,omitempty"` -} - -func (*IP4Prefix) GetTypeName() string { return "ip4_prefix" } - -// IP6Prefix represents VPP binary API type 'ip6_prefix'. -type IP6Prefix struct { - Address IP6Address `binapi:"ip6_address,name=address" json:"address,omitempty"` - Len uint8 `binapi:"u8,name=len" json:"len,omitempty"` -} - -func (*IP6Prefix) GetTypeName() string { return "ip6_prefix" } - -// Mprefix represents VPP binary API type 'mprefix'. -type Mprefix struct { - Af AddressFamily `binapi:"address_family,name=af" json:"af,omitempty"` - GrpAddressLength uint16 `binapi:"u16,name=grp_address_length" json:"grp_address_length,omitempty"` - GrpAddress AddressUnion `binapi:"address_union,name=grp_address" json:"grp_address,omitempty"` - SrcAddress AddressUnion `binapi:"address_union,name=src_address" json:"src_address,omitempty"` -} - -func (*Mprefix) GetTypeName() string { return "mprefix" } +type IP4Prefix = ip_types.IP4Prefix -// Prefix represents VPP binary API type 'prefix'. -type Prefix struct { - Address Address `binapi:"address,name=address" json:"address,omitempty"` - Len uint8 `binapi:"u8,name=len" json:"len,omitempty"` -} - -func (*Prefix) GetTypeName() string { return "prefix" } +type IP6Prefix = ip_types.IP6Prefix -// PrefixMatcher represents VPP binary API type 'prefix_matcher'. -type PrefixMatcher struct { - Le uint8 `binapi:"u8,name=le" json:"le,omitempty"` - Ge uint8 `binapi:"u8,name=ge" json:"ge,omitempty"` -} +type Mprefix = ip_types.Mprefix -func (*PrefixMatcher) GetTypeName() string { return "prefix_matcher" } - -// AddressUnion represents VPP binary API union 'address_union'. -type AddressUnion struct { - XXX_UnionData [16]byte -} +type Prefix = ip_types.Prefix -func (*AddressUnion) GetTypeName() string { return "address_union" } +type PrefixMatcher = ip_types.PrefixMatcher -func AddressUnionIP4(a IP4Address) (u AddressUnion) { - u.SetIP4(a) - return -} -func (u *AddressUnion) SetIP4(a IP4Address) { - var b = new(bytes.Buffer) - if err := struc.Pack(b, &a); err != nil { - return - } - copy(u.XXX_UnionData[:], b.Bytes()) -} -func (u *AddressUnion) GetIP4() (a IP4Address) { - var b = bytes.NewReader(u.XXX_UnionData[:]) - struc.Unpack(b, &a) - return -} - -func AddressUnionIP6(a IP6Address) (u AddressUnion) { - u.SetIP6(a) - return -} -func (u *AddressUnion) SetIP6(a IP6Address) { - var b = new(bytes.Buffer) - if err := struc.Pack(b, &a); err != nil { - return - } - copy(u.XXX_UnionData[:], b.Bytes()) -} -func (u *AddressUnion) GetIP6() (a IP6Address) { - var b = bytes.NewReader(u.XXX_UnionData[:]) - struc.Unpack(b, &a) - return -} +type AddressUnion = ip_types.AddressUnion // Reference imports to suppress errors if they are not otherwise used. var _ = api.RegisterMessage diff --git a/examples/binapi/gen.go b/examples/binapi/gen.go index a19ca34..7849d8d 100644 --- a/examples/binapi/gen.go +++ b/examples/binapi/gen.go @@ -2,4 +2,4 @@ package binapi // Generate Go code from the VPP APIs located in the /usr/share/vpp/api directory. -//go:generate binapi-generator --import-prefix=git.fd.io/govpp.git/examples/binapi af_packet interface ip memclnt vpe sr acl memif ip_types fib_types +//go:generate binapi-generator --import-types=false af_packet interface interface_types ip memclnt vpe sr acl memif ip_types fib_types diff --git a/examples/binapi/interface_types/interface_types.ba.go b/examples/binapi/interface_types/interface_types.ba.go new file mode 100644 index 0000000..0191e5f --- /dev/null +++ b/examples/binapi/interface_types/interface_types.ba.go @@ -0,0 +1,266 @@ +// Code generated by GoVPP's binapi-generator. DO NOT EDIT. +// versions: +// binapi-generator: v0.4.0-dev +// VPP: 20.05-release +// source: /usr/share/vpp/api/core/interface_types.api.json + +/* +Package interface_types contains generated code for VPP API file interface_types.api (). + +It consists of: + 1 alias + 6 enums +*/ +package interface_types + +import ( + "bytes" + "context" + "encoding/binary" + "io" + "math" + "strconv" + + api "git.fd.io/govpp.git/api" + codec "git.fd.io/govpp.git/codec" + struc "github.com/lunixbochs/struc" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the GoVPP api package it is being compiled against. +// A compilation error at this line likely means your copy of the +// GoVPP api package needs to be updated. +const _ = api.GoVppAPIPackageIsVersion2 // please upgrade the GoVPP api package + +const ( + // ModuleName is the name of this module. + ModuleName = "interface_types" + // APIVersion is the API version of this module. + APIVersion = "" + // VersionCrc is the CRC of this module. + VersionCrc = 0x23822dac +) + +// IfStatusFlags represents VPP binary API enum 'if_status_flags'. +type IfStatusFlags uint32 + +const ( + IF_STATUS_API_FLAG_ADMIN_UP IfStatusFlags = 1 + IF_STATUS_API_FLAG_LINK_UP IfStatusFlags = 2 +) + +var ( + IfStatusFlags_name = map[uint32]string{ + 1: "IF_STATUS_API_FLAG_ADMIN_UP", + 2: "IF_STATUS_API_FLAG_LINK_UP", + } + IfStatusFlags_value = map[string]uint32{ + "IF_STATUS_API_FLAG_ADMIN_UP": 1, + "IF_STATUS_API_FLAG_LINK_UP": 2, + } +) + +func (x IfStatusFlags) String() string { + s, ok := IfStatusFlags_name[uint32(x)] + if ok { + return s + } + return "IfStatusFlags(" + strconv.Itoa(int(x)) + ")" +} + +// IfType represents VPP binary API enum 'if_type'. +type IfType uint32 + +const ( + IF_API_TYPE_HARDWARE IfType = 0 + IF_API_TYPE_SUB IfType = 1 + IF_API_TYPE_P2P IfType = 2 + IF_API_TYPE_PIPE IfType = 3 +) + +var ( + IfType_name = map[uint32]string{ + 0: "IF_API_TYPE_HARDWARE", + 1: "IF_API_TYPE_SUB", + 2: "IF_API_TYPE_P2P", + 3: "IF_API_TYPE_PIPE", + } + IfType_value = map[string]uint32{ + "IF_API_TYPE_HARDWARE": 0, + "IF_API_TYPE_SUB": 1, + "IF_API_TYPE_P2P": 2, + "IF_API_TYPE_PIPE": 3, + } +) + +func (x IfType) String() string { + s, ok := IfType_name[uint32(x)] + if ok { + return s + } + return "IfType(" + strconv.Itoa(int(x)) + ")" +} + +// LinkDuplex represents VPP binary API enum 'link_duplex'. +type LinkDuplex uint32 + +const ( + LINK_DUPLEX_API_UNKNOWN LinkDuplex = 0 + LINK_DUPLEX_API_HALF LinkDuplex = 1 + LINK_DUPLEX_API_FULL LinkDuplex = 2 +) + +var ( + LinkDuplex_name = map[uint32]string{ + 0: "LINK_DUPLEX_API_UNKNOWN", + 1: "LINK_DUPLEX_API_HALF", + 2: "LINK_DUPLEX_API_FULL", + } + LinkDuplex_value = map[string]uint32{ + "LINK_DUPLEX_API_UNKNOWN": 0, + "LINK_DUPLEX_API_HALF": 1, + "LINK_DUPLEX_API_FULL": 2, + } +) + +func (x LinkDuplex) String() string { + s, ok := LinkDuplex_name[uint32(x)] + if ok { + return s + } + return "LinkDuplex(" + strconv.Itoa(int(x)) + ")" +} + +// MtuProto represents VPP binary API enum 'mtu_proto'. +type MtuProto uint32 + +const ( + MTU_PROTO_API_L3 MtuProto = 0 + MTU_PROTO_API_IP4 MtuProto = 1 + MTU_PROTO_API_IP6 MtuProto = 2 + MTU_PROTO_API_MPLS MtuProto = 3 +) + +var ( + MtuProto_name = map[uint32]string{ + 0: "MTU_PROTO_API_L3", + 1: "MTU_PROTO_API_IP4", + 2: "MTU_PROTO_API_IP6", + 3: "MTU_PROTO_API_MPLS", + } + MtuProto_value = map[string]uint32{ + "MTU_PROTO_API_L3": 0, + "MTU_PROTO_API_IP4": 1, + "MTU_PROTO_API_IP6": 2, + "MTU_PROTO_API_MPLS": 3, + } +) + +func (x MtuProto) String() string { + s, ok := MtuProto_name[uint32(x)] + if ok { + return s + } + return "MtuProto(" + strconv.Itoa(int(x)) + ")" +} + +// RxMode represents VPP binary API enum 'rx_mode'. +type RxMode uint32 + +const ( + RX_MODE_API_UNKNOWN RxMode = 0 + RX_MODE_API_POLLING RxMode = 1 + RX_MODE_API_INTERRUPT RxMode = 2 + RX_MODE_API_ADAPTIVE RxMode = 3 + RX_MODE_API_DEFAULT RxMode = 4 +) + +var ( + RxMode_name = map[uint32]string{ + 0: "RX_MODE_API_UNKNOWN", + 1: "RX_MODE_API_POLLING", + 2: "RX_MODE_API_INTERRUPT", + 3: "RX_MODE_API_ADAPTIVE", + 4: "RX_MODE_API_DEFAULT", + } + RxMode_value = map[string]uint32{ + "RX_MODE_API_UNKNOWN": 0, + "RX_MODE_API_POLLING": 1, + "RX_MODE_API_INTERRUPT": 2, + "RX_MODE_API_ADAPTIVE": 3, + "RX_MODE_API_DEFAULT": 4, + } +) + +func (x RxMode) String() string { + s, ok := RxMode_name[uint32(x)] + if ok { + return s + } + return "RxMode(" + strconv.Itoa(int(x)) + ")" +} + +// SubIfFlags represents VPP binary API enum 'sub_if_flags'. +type SubIfFlags uint32 + +const ( + SUB_IF_API_FLAG_NO_TAGS SubIfFlags = 1 + SUB_IF_API_FLAG_ONE_TAG SubIfFlags = 2 + SUB_IF_API_FLAG_TWO_TAGS SubIfFlags = 4 + SUB_IF_API_FLAG_DOT1AD SubIfFlags = 8 + SUB_IF_API_FLAG_EXACT_MATCH SubIfFlags = 16 + SUB_IF_API_FLAG_DEFAULT SubIfFlags = 32 + SUB_IF_API_FLAG_OUTER_VLAN_ID_ANY SubIfFlags = 64 + SUB_IF_API_FLAG_INNER_VLAN_ID_ANY SubIfFlags = 128 + SUB_IF_API_FLAG_MASK_VNET SubIfFlags = 254 + SUB_IF_API_FLAG_DOT1AH SubIfFlags = 256 +) + +var ( + SubIfFlags_name = map[uint32]string{ + 1: "SUB_IF_API_FLAG_NO_TAGS", + 2: "SUB_IF_API_FLAG_ONE_TAG", + 4: "SUB_IF_API_FLAG_TWO_TAGS", + 8: "SUB_IF_API_FLAG_DOT1AD", + 16: "SUB_IF_API_FLAG_EXACT_MATCH", + 32: "SUB_IF_API_FLAG_DEFAULT", + 64: "SUB_IF_API_FLAG_OUTER_VLAN_ID_ANY", + 128: "SUB_IF_API_FLAG_INNER_VLAN_ID_ANY", + 254: "SUB_IF_API_FLAG_MASK_VNET", + 256: "SUB_IF_API_FLAG_DOT1AH", + } + SubIfFlags_value = map[string]uint32{ + "SUB_IF_API_FLAG_NO_TAGS": 1, + "SUB_IF_API_FLAG_ONE_TAG": 2, + "SUB_IF_API_FLAG_TWO_TAGS": 4, + "SUB_IF_API_FLAG_DOT1AD": 8, + "SUB_IF_API_FLAG_EXACT_MATCH": 16, + "SUB_IF_API_FLAG_DEFAULT": 32, + "SUB_IF_API_FLAG_OUTER_VLAN_ID_ANY": 64, + "SUB_IF_API_FLAG_INNER_VLAN_ID_ANY": 128, + "SUB_IF_API_FLAG_MASK_VNET": 254, + "SUB_IF_API_FLAG_DOT1AH": 256, + } +) + +func (x SubIfFlags) String() string { + s, ok := SubIfFlags_name[uint32(x)] + if ok { + return s + } + return "SubIfFlags(" + strconv.Itoa(int(x)) + ")" +} + +// InterfaceIndex represents VPP binary API alias 'interface_index'. +type InterfaceIndex uint32 + +// Reference imports to suppress errors if they are not otherwise used. +var _ = api.RegisterMessage +var _ = codec.DecodeString +var _ = bytes.NewBuffer +var _ = context.Background +var _ = io.Copy +var _ = strconv.Itoa +var _ = struc.Pack +var _ = binary.BigEndian +var _ = math.Float32bits diff --git a/examples/binapi/interfaces/interfaces.ba.go b/examples/binapi/interfaces/interfaces.ba.go index 82e8f3c..fea1079 100644 --- a/examples/binapi/interfaces/interfaces.ba.go +++ b/examples/binapi/interfaces/interfaces.ba.go @@ -1,16 +1,16 @@ // Code generated by GoVPP's binapi-generator. DO NOT EDIT. // versions: -// binapi-generator: v0.4.0-alpha-1-g435c3f4-dirty -// VPP: 20.01-45~g7a071e370~b63 +// binapi-generator: v0.4.0-dev +// VPP: 20.05-release // source: /usr/share/vpp/api/core/interface.api.json /* -Package interfaces contains generated code for VPP binary API defined by interface.api (version 3.2.2). +Package interfaces contains generated code for VPP API file interface.api (3.2.2). It consists of: 7 aliases 10 enums - 53 messages + 57 messages 6 types 1 union */ @@ -27,6 +27,9 @@ import ( api "git.fd.io/govpp.git/api" codec "git.fd.io/govpp.git/codec" struc "github.com/lunixbochs/struc" + + interface_types "git.fd.io/govpp.git/examples/binapi/interface_types" + ip_types "git.fd.io/govpp.git/examples/binapi/ip_types" ) // This is a compile-time assertion to ensure that this generated file @@ -41,534 +44,57 @@ const ( // APIVersion is the API version of this module. APIVersion = "3.2.2" // VersionCrc is the CRC of this module. - VersionCrc = 0xfebc3ffa + VersionCrc = 0x58d4cf5a ) -// AddressFamily represents VPP binary API enum 'address_family'. -type AddressFamily uint32 +type AddressFamily = ip_types.AddressFamily -const ( - ADDRESS_IP4 AddressFamily = 0 - ADDRESS_IP6 AddressFamily = 1 -) +type IfStatusFlags = interface_types.IfStatusFlags -var ( - AddressFamily_name = map[uint32]string{ - 0: "ADDRESS_IP4", - 1: "ADDRESS_IP6", - } - AddressFamily_value = map[string]uint32{ - "ADDRESS_IP4": 0, - "ADDRESS_IP6": 1, - } -) +type IfType = interface_types.IfType -func (x AddressFamily) String() string { - s, ok := AddressFamily_name[uint32(x)] - if ok { - return s - } - return "AddressFamily(" + strconv.Itoa(int(x)) + ")" -} +type IPDscp = ip_types.IPDscp -// IfStatusFlags represents VPP binary API enum 'if_status_flags'. -type IfStatusFlags uint32 +type IPEcn = ip_types.IPEcn -const ( - IF_STATUS_API_FLAG_ADMIN_UP IfStatusFlags = 1 - IF_STATUS_API_FLAG_LINK_UP IfStatusFlags = 2 -) +type IPProto = ip_types.IPProto -var ( - IfStatusFlags_name = map[uint32]string{ - 1: "IF_STATUS_API_FLAG_ADMIN_UP", - 2: "IF_STATUS_API_FLAG_LINK_UP", - } - IfStatusFlags_value = map[string]uint32{ - "IF_STATUS_API_FLAG_ADMIN_UP": 1, - "IF_STATUS_API_FLAG_LINK_UP": 2, - } -) +type LinkDuplex = interface_types.LinkDuplex -func (x IfStatusFlags) String() string { - s, ok := IfStatusFlags_name[uint32(x)] - if ok { - return s - } - return "IfStatusFlags(" + strconv.Itoa(int(x)) + ")" -} +type MtuProto = interface_types.MtuProto -// IfType represents VPP binary API enum 'if_type'. -type IfType uint32 +type RxMode = interface_types.RxMode -const ( - IF_API_TYPE_HARDWARE IfType = 1 - IF_API_TYPE_SUB IfType = 2 - IF_API_TYPE_P2P IfType = 3 - IF_API_TYPE_PIPE IfType = 4 -) +type SubIfFlags = interface_types.SubIfFlags -var ( - IfType_name = map[uint32]string{ - 1: "IF_API_TYPE_HARDWARE", - 2: "IF_API_TYPE_SUB", - 3: "IF_API_TYPE_P2P", - 4: "IF_API_TYPE_PIPE", - } - IfType_value = map[string]uint32{ - "IF_API_TYPE_HARDWARE": 1, - "IF_API_TYPE_SUB": 2, - "IF_API_TYPE_P2P": 3, - "IF_API_TYPE_PIPE": 4, - } -) - -func (x IfType) String() string { - s, ok := IfType_name[uint32(x)] - if ok { - return s - } - return "IfType(" + strconv.Itoa(int(x)) + ")" -} +type AddressWithPrefix = ip_types.AddressWithPrefix -// IPDscp represents VPP binary API enum 'ip_dscp'. -type IPDscp uint8 - -const ( - IP_API_DSCP_CS0 IPDscp = 0 - IP_API_DSCP_CS1 IPDscp = 8 - IP_API_DSCP_AF11 IPDscp = 10 - IP_API_DSCP_AF12 IPDscp = 12 - IP_API_DSCP_AF13 IPDscp = 14 - IP_API_DSCP_CS2 IPDscp = 16 - IP_API_DSCP_AF21 IPDscp = 18 - IP_API_DSCP_AF22 IPDscp = 20 - IP_API_DSCP_AF23 IPDscp = 22 - IP_API_DSCP_CS3 IPDscp = 24 - IP_API_DSCP_AF31 IPDscp = 26 - IP_API_DSCP_AF32 IPDscp = 28 - IP_API_DSCP_AF33 IPDscp = 30 - IP_API_DSCP_CS4 IPDscp = 32 - IP_API_DSCP_AF41 IPDscp = 34 - IP_API_DSCP_AF42 IPDscp = 36 - IP_API_DSCP_AF43 IPDscp = 38 - IP_API_DSCP_CS5 IPDscp = 40 - IP_API_DSCP_EF IPDscp = 46 - IP_API_DSCP_CS6 IPDscp = 48 - IP_API_DSCP_CS7 IPDscp = 50 -) +type InterfaceIndex = interface_types.InterfaceIndex -var ( - IPDscp_name = map[uint8]string{ - 0: "IP_API_DSCP_CS0", - 8: "IP_API_DSCP_CS1", - 10: "IP_API_DSCP_AF11", - 12: "IP_API_DSCP_AF12", - 14: "IP_API_DSCP_AF13", - 16: "IP_API_DSCP_CS2", - 18: "IP_API_DSCP_AF21", - 20: "IP_API_DSCP_AF22", - 22: "IP_API_DSCP_AF23", - 24: "IP_API_DSCP_CS3", - 26: "IP_API_DSCP_AF31", - 28: "IP_API_DSCP_AF32", - 30: "IP_API_DSCP_AF33", - 32: "IP_API_DSCP_CS4", - 34: "IP_API_DSCP_AF41", - 36: "IP_API_DSCP_AF42", - 38: "IP_API_DSCP_AF43", - 40: "IP_API_DSCP_CS5", - 46: "IP_API_DSCP_EF", - 48: "IP_API_DSCP_CS6", - 50: "IP_API_DSCP_CS7", - } - IPDscp_value = map[string]uint8{ - "IP_API_DSCP_CS0": 0, - "IP_API_DSCP_CS1": 8, - "IP_API_DSCP_AF11": 10, - "IP_API_DSCP_AF12": 12, - "IP_API_DSCP_AF13": 14, - "IP_API_DSCP_CS2": 16, - "IP_API_DSCP_AF21": 18, - "IP_API_DSCP_AF22": 20, - "IP_API_DSCP_AF23": 22, - "IP_API_DSCP_CS3": 24, - "IP_API_DSCP_AF31": 26, - "IP_API_DSCP_AF32": 28, - "IP_API_DSCP_AF33": 30, - "IP_API_DSCP_CS4": 32, - "IP_API_DSCP_AF41": 34, - "IP_API_DSCP_AF42": 36, - "IP_API_DSCP_AF43": 38, - "IP_API_DSCP_CS5": 40, - "IP_API_DSCP_EF": 46, - "IP_API_DSCP_CS6": 48, - "IP_API_DSCP_CS7": 50, - } -) +type IP4Address = ip_types.IP4Address -func (x IPDscp) String() string { - s, ok := IPDscp_name[uint8(x)] - if ok { - return s - } - return "IPDscp(" + strconv.Itoa(int(x)) + ")" -} +type IP4AddressWithPrefix = ip_types.IP4AddressWithPrefix -// IPEcn represents VPP binary API enum 'ip_ecn'. -type IPEcn uint8 +type IP6Address = ip_types.IP6Address -const ( - IP_API_ECN_NONE IPEcn = 0 - IP_API_ECN_ECT0 IPEcn = 1 - IP_API_ECN_ECT1 IPEcn = 2 - IP_API_ECN_CE IPEcn = 3 -) - -var ( - IPEcn_name = map[uint8]string{ - 0: "IP_API_ECN_NONE", - 1: "IP_API_ECN_ECT0", - 2: "IP_API_ECN_ECT1", - 3: "IP_API_ECN_CE", - } - IPEcn_value = map[string]uint8{ - "IP_API_ECN_NONE": 0, - "IP_API_ECN_ECT0": 1, - "IP_API_ECN_ECT1": 2, - "IP_API_ECN_CE": 3, - } -) - -func (x IPEcn) String() string { - s, ok := IPEcn_name[uint8(x)] - if ok { - return s - } - return "IPEcn(" + strconv.Itoa(int(x)) + ")" -} - -// IPProto represents VPP binary API enum 'ip_proto'. -type IPProto uint32 - -const ( - IP_API_PROTO_HOPOPT IPProto = 0 - IP_API_PROTO_ICMP IPProto = 1 - IP_API_PROTO_IGMP IPProto = 2 - IP_API_PROTO_TCP IPProto = 6 - IP_API_PROTO_UDP IPProto = 17 - IP_API_PROTO_GRE IPProto = 47 - IP_API_PROTO_AH IPProto = 50 - IP_API_PROTO_ESP IPProto = 51 - IP_API_PROTO_EIGRP IPProto = 88 - IP_API_PROTO_OSPF IPProto = 89 - IP_API_PROTO_SCTP IPProto = 132 - IP_API_PROTO_RESERVED IPProto = 255 -) - -var ( - IPProto_name = map[uint32]string{ - 0: "IP_API_PROTO_HOPOPT", - 1: "IP_API_PROTO_ICMP", - 2: "IP_API_PROTO_IGMP", - 6: "IP_API_PROTO_TCP", - 17: "IP_API_PROTO_UDP", - 47: "IP_API_PROTO_GRE", - 50: "IP_API_PROTO_AH", - 51: "IP_API_PROTO_ESP", - 88: "IP_API_PROTO_EIGRP", - 89: "IP_API_PROTO_OSPF", - 132: "IP_API_PROTO_SCTP", - 255: "IP_API_PROTO_RESERVED", - } - IPProto_value = map[string]uint32{ - "IP_API_PROTO_HOPOPT": 0, - "IP_API_PROTO_ICMP": 1, - "IP_API_PROTO_IGMP": 2, - "IP_API_PROTO_TCP": 6, - "IP_API_PROTO_UDP": 17, - "IP_API_PROTO_GRE": 47, - "IP_API_PROTO_AH": 50, - "IP_API_PROTO_ESP": 51, - "IP_API_PROTO_EIGRP": 88, - "IP_API_PROTO_OSPF": 89, - "IP_API_PROTO_SCTP": 132, - "IP_API_PROTO_RESERVED": 255, - } -) - -func (x IPProto) String() string { - s, ok := IPProto_name[uint32(x)] - if ok { - return s - } - return "IPProto(" + strconv.Itoa(int(x)) + ")" -} - -// LinkDuplex represents VPP binary API enum 'link_duplex'. -type LinkDuplex uint32 - -const ( - LINK_DUPLEX_API_UNKNOWN LinkDuplex = 0 - LINK_DUPLEX_API_HALF LinkDuplex = 1 - LINK_DUPLEX_API_FULL LinkDuplex = 2 -) - -var ( - LinkDuplex_name = map[uint32]string{ - 0: "LINK_DUPLEX_API_UNKNOWN", - 1: "LINK_DUPLEX_API_HALF", - 2: "LINK_DUPLEX_API_FULL", - } - LinkDuplex_value = map[string]uint32{ - "LINK_DUPLEX_API_UNKNOWN": 0, - "LINK_DUPLEX_API_HALF": 1, - "LINK_DUPLEX_API_FULL": 2, - } -) - -func (x LinkDuplex) String() string { - s, ok := LinkDuplex_name[uint32(x)] - if ok { - return s - } - return "LinkDuplex(" + strconv.Itoa(int(x)) + ")" -} - -// MtuProto represents VPP binary API enum 'mtu_proto'. -type MtuProto uint32 - -const ( - MTU_PROTO_API_L3 MtuProto = 1 - MTU_PROTO_API_IP4 MtuProto = 2 - MTU_PROTO_API_IP6 MtuProto = 3 - MTU_PROTO_API_MPLS MtuProto = 4 - MTU_PROTO_API_N MtuProto = 5 -) - -var ( - MtuProto_name = map[uint32]string{ - 1: "MTU_PROTO_API_L3", - 2: "MTU_PROTO_API_IP4", - 3: "MTU_PROTO_API_IP6", - 4: "MTU_PROTO_API_MPLS", - 5: "MTU_PROTO_API_N", - } - MtuProto_value = map[string]uint32{ - "MTU_PROTO_API_L3": 1, - "MTU_PROTO_API_IP4": 2, - "MTU_PROTO_API_IP6": 3, - "MTU_PROTO_API_MPLS": 4, - "MTU_PROTO_API_N": 5, - } -) - -func (x MtuProto) String() string { - s, ok := MtuProto_name[uint32(x)] - if ok { - return s - } - return "MtuProto(" + strconv.Itoa(int(x)) + ")" -} - -// RxMode represents VPP binary API enum 'rx_mode'. -type RxMode uint32 - -const ( - RX_MODE_API_UNKNOWN RxMode = 0 - RX_MODE_API_POLLING RxMode = 1 - RX_MODE_API_INTERRUPT RxMode = 2 - RX_MODE_API_ADAPTIVE RxMode = 3 - RX_MODE_API_DEFAULT RxMode = 4 -) - -var ( - RxMode_name = map[uint32]string{ - 0: "RX_MODE_API_UNKNOWN", - 1: "RX_MODE_API_POLLING", - 2: "RX_MODE_API_INTERRUPT", - 3: "RX_MODE_API_ADAPTIVE", - 4: "RX_MODE_API_DEFAULT", - } - RxMode_value = map[string]uint32{ - "RX_MODE_API_UNKNOWN": 0, - "RX_MODE_API_POLLING": 1, - "RX_MODE_API_INTERRUPT": 2, - "RX_MODE_API_ADAPTIVE": 3, - "RX_MODE_API_DEFAULT": 4, - } -) - -func (x RxMode) String() string { - s, ok := RxMode_name[uint32(x)] - if ok { - return s - } - return "RxMode(" + strconv.Itoa(int(x)) + ")" -} - -// SubIfFlags represents VPP binary API enum 'sub_if_flags'. -type SubIfFlags uint32 - -const ( - SUB_IF_API_FLAG_NO_TAGS SubIfFlags = 1 - SUB_IF_API_FLAG_ONE_TAG SubIfFlags = 2 - SUB_IF_API_FLAG_TWO_TAGS SubIfFlags = 4 - SUB_IF_API_FLAG_DOT1AD SubIfFlags = 8 - SUB_IF_API_FLAG_EXACT_MATCH SubIfFlags = 16 - SUB_IF_API_FLAG_DEFAULT SubIfFlags = 32 - SUB_IF_API_FLAG_OUTER_VLAN_ID_ANY SubIfFlags = 64 - SUB_IF_API_FLAG_INNER_VLAN_ID_ANY SubIfFlags = 128 - SUB_IF_API_FLAG_MASK_VNET SubIfFlags = 254 - SUB_IF_API_FLAG_DOT1AH SubIfFlags = 256 -) - -var ( - SubIfFlags_name = map[uint32]string{ - 1: "SUB_IF_API_FLAG_NO_TAGS", - 2: "SUB_IF_API_FLAG_ONE_TAG", - 4: "SUB_IF_API_FLAG_TWO_TAGS", - 8: "SUB_IF_API_FLAG_DOT1AD", - 16: "SUB_IF_API_FLAG_EXACT_MATCH", - 32: "SUB_IF_API_FLAG_DEFAULT", - 64: "SUB_IF_API_FLAG_OUTER_VLAN_ID_ANY", - 128: "SUB_IF_API_FLAG_INNER_VLAN_ID_ANY", - 254: "SUB_IF_API_FLAG_MASK_VNET", - 256: "SUB_IF_API_FLAG_DOT1AH", - } - SubIfFlags_value = map[string]uint32{ - "SUB_IF_API_FLAG_NO_TAGS": 1, - "SUB_IF_API_FLAG_ONE_TAG": 2, - "SUB_IF_API_FLAG_TWO_TAGS": 4, - "SUB_IF_API_FLAG_DOT1AD": 8, - "SUB_IF_API_FLAG_EXACT_MATCH": 16, - "SUB_IF_API_FLAG_DEFAULT": 32, - "SUB_IF_API_FLAG_OUTER_VLAN_ID_ANY": 64, - "SUB_IF_API_FLAG_INNER_VLAN_ID_ANY": 128, - "SUB_IF_API_FLAG_MASK_VNET": 254, - "SUB_IF_API_FLAG_DOT1AH": 256, - } -) - -func (x SubIfFlags) String() string { - s, ok := SubIfFlags_name[uint32(x)] - if ok { - return s - } - return "SubIfFlags(" + strconv.Itoa(int(x)) + ")" -} - -// AddressWithPrefix represents VPP binary API alias 'address_with_prefix'. -type AddressWithPrefix Prefix - -// InterfaceIndex represents VPP binary API alias 'interface_index'. -type InterfaceIndex uint32 - -// IP4Address represents VPP binary API alias 'ip4_address'. -type IP4Address [4]uint8 - -// IP4AddressWithPrefix represents VPP binary API alias 'ip4_address_with_prefix'. -type IP4AddressWithPrefix IP4Prefix - -// IP6Address represents VPP binary API alias 'ip6_address'. -type IP6Address [16]uint8 - -// IP6AddressWithPrefix represents VPP binary API alias 'ip6_address_with_prefix'. -type IP6AddressWithPrefix IP6Prefix +type IP6AddressWithPrefix = ip_types.IP6AddressWithPrefix // MacAddress represents VPP binary API alias 'mac_address'. type MacAddress [6]uint8 -// Address represents VPP binary API type 'address'. -type Address struct { - Af AddressFamily `binapi:"address_family,name=af" json:"af,omitempty"` - Un AddressUnion `binapi:"address_union,name=un" json:"un,omitempty"` -} - -func (*Address) GetTypeName() string { return "address" } - -// IP4Prefix represents VPP binary API type 'ip4_prefix'. -type IP4Prefix struct { - Address IP4Address `binapi:"ip4_address,name=address" json:"address,omitempty"` - Len uint8 `binapi:"u8,name=len" json:"len,omitempty"` -} - -func (*IP4Prefix) GetTypeName() string { return "ip4_prefix" } - -// IP6Prefix represents VPP binary API type 'ip6_prefix'. -type IP6Prefix struct { - Address IP6Address `binapi:"ip6_address,name=address" json:"address,omitempty"` - Len uint8 `binapi:"u8,name=len" json:"len,omitempty"` -} - -func (*IP6Prefix) GetTypeName() string { return "ip6_prefix" } - -// Mprefix represents VPP binary API type 'mprefix'. -type Mprefix struct { - Af AddressFamily `binapi:"address_family,name=af" json:"af,omitempty"` - GrpAddressLength uint16 `binapi:"u16,name=grp_address_length" json:"grp_address_length,omitempty"` - GrpAddress AddressUnion `binapi:"address_union,name=grp_address" json:"grp_address,omitempty"` - SrcAddress AddressUnion `binapi:"address_union,name=src_address" json:"src_address,omitempty"` -} - -func (*Mprefix) GetTypeName() string { return "mprefix" } - -// Prefix represents VPP binary API type 'prefix'. -type Prefix struct { - Address Address `binapi:"address,name=address" json:"address,omitempty"` - Len uint8 `binapi:"u8,name=len" json:"len,omitempty"` -} +type Address = ip_types.Address -func (*Prefix) GetTypeName() string { return "prefix" } +type IP4Prefix = ip_types.IP4Prefix -// PrefixMatcher represents VPP binary API type 'prefix_matcher'. -type PrefixMatcher struct { - Le uint8 `binapi:"u8,name=le" json:"le,omitempty"` - Ge uint8 `binapi:"u8,name=ge" json:"ge,omitempty"` -} - -func (*PrefixMatcher) GetTypeName() string { return "prefix_matcher" } +type IP6Prefix = ip_types.IP6Prefix -// AddressUnion represents VPP binary API union 'address_union'. -type AddressUnion struct { - XXX_UnionData [16]byte -} +type Mprefix = ip_types.Mprefix -func (*AddressUnion) GetTypeName() string { return "address_union" } +type Prefix = ip_types.Prefix -func AddressUnionIP4(a IP4Address) (u AddressUnion) { - u.SetIP4(a) - return -} -func (u *AddressUnion) SetIP4(a IP4Address) { - var b = new(bytes.Buffer) - if err := struc.Pack(b, &a); err != nil { - return - } - copy(u.XXX_UnionData[:], b.Bytes()) -} -func (u *AddressUnion) GetIP4() (a IP4Address) { - var b = bytes.NewReader(u.XXX_UnionData[:]) - struc.Unpack(b, &a) - return -} +type PrefixMatcher = ip_types.PrefixMatcher -func AddressUnionIP6(a IP6Address) (u AddressUnion) { - u.SetIP6(a) - return -} -func (u *AddressUnion) SetIP6(a IP6Address) { - var b = new(bytes.Buffer) - if err := struc.Pack(b, &a); err != nil { - return - } - copy(u.XXX_UnionData[:], b.Bytes()) -} -func (u *AddressUnion) GetIP6() (a IP6Address) { - var b = bytes.NewReader(u.XXX_UnionData[:]) - struc.Unpack(b, &a) - return -} +type AddressUnion = ip_types.AddressUnion // CollectDetailedInterfaceStats represents VPP binary API message 'collect_detailed_interface_stats'. type CollectDetailedInterfaceStats struct { @@ -1575,7 +1101,7 @@ func (m *SwInterfaceAddDelAddress) Size() int { // field[1] m.Prefix // field[2] m.Prefix.Address // field[3] m.Prefix.Address.Af - size += 4 + size += 1 // field[3] m.Prefix.Address.Un size += 16 // field[2] m.Prefix.Len @@ -1609,8 +1135,8 @@ func (m *SwInterfaceAddDelAddress) Marshal(b []byte) ([]byte, error) { // field[1] m.Prefix // field[2] m.Prefix.Address // field[3] m.Prefix.Address.Af - o.PutUint32(buf[pos:pos+4], uint32(m.Prefix.Address.Af)) - pos += 4 + buf[pos] = uint8(m.Prefix.Address.Af) + pos += 1 // field[3] m.Prefix.Address.Un copy(buf[pos:pos+16], m.Prefix.Address.Un.XXX_UnionData[:]) pos += 16 @@ -1636,8 +1162,8 @@ func (m *SwInterfaceAddDelAddress) Unmarshal(tmp []byte) error { // field[1] m.Prefix // field[2] m.Prefix.Address // field[3] m.Prefix.Address.Af - m.Prefix.Address.Af = AddressFamily(o.Uint32(tmp[pos : pos+4])) - pos += 4 + m.Prefix.Address.Af = AddressFamily(tmp[pos]) + pos += 1 // field[3] m.Prefix.Address.Un copy(m.Prefix.Address.Un.XXX_UnionData[:], tmp[pos:pos+16]) pos += 16 @@ -1817,6 +1343,178 @@ func (m *SwInterfaceAddDelMacAddressReply) Unmarshal(tmp []byte) error { return nil } +// SwInterfaceAddressReplaceBegin represents VPP binary API message 'sw_interface_address_replace_begin'. +type SwInterfaceAddressReplaceBegin struct{} + +func (m *SwInterfaceAddressReplaceBegin) Reset() { *m = SwInterfaceAddressReplaceBegin{} } +func (*SwInterfaceAddressReplaceBegin) GetMessageName() string { + return "sw_interface_address_replace_begin" +} +func (*SwInterfaceAddressReplaceBegin) GetCrcString() string { return "51077d14" } +func (*SwInterfaceAddressReplaceBegin) GetMessageType() api.MessageType { return api.RequestMessage } + +func (m *SwInterfaceAddressReplaceBegin) Size() int { + if m == nil { + return 0 + } + var size int + return size +} +func (m *SwInterfaceAddressReplaceBegin) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + return buf, nil +} +func (m *SwInterfaceAddressReplaceBegin) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + return nil +} + +// SwInterfaceAddressReplaceBeginReply represents VPP binary API message 'sw_interface_address_replace_begin_reply'. +type SwInterfaceAddressReplaceBeginReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *SwInterfaceAddressReplaceBeginReply) Reset() { *m = SwInterfaceAddressReplaceBeginReply{} } +func (*SwInterfaceAddressReplaceBeginReply) GetMessageName() string { + return "sw_interface_address_replace_begin_reply" +} +func (*SwInterfaceAddressReplaceBeginReply) GetCrcString() string { return "e8d4e804" } +func (*SwInterfaceAddressReplaceBeginReply) GetMessageType() api.MessageType { return api.ReplyMessage } + +func (m *SwInterfaceAddressReplaceBeginReply) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.Retval + size += 4 + return size +} +func (m *SwInterfaceAddressReplaceBeginReply) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.Retval + o.PutUint32(buf[pos:pos+4], uint32(m.Retval)) + pos += 4 + return buf, nil +} +func (m *SwInterfaceAddressReplaceBeginReply) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.Retval + m.Retval = int32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + return nil +} + +// SwInterfaceAddressReplaceEnd represents VPP binary API message 'sw_interface_address_replace_end'. +type SwInterfaceAddressReplaceEnd struct{} + +func (m *SwInterfaceAddressReplaceEnd) Reset() { *m = SwInterfaceAddressReplaceEnd{} } +func (*SwInterfaceAddressReplaceEnd) GetMessageName() string { + return "sw_interface_address_replace_end" +} +func (*SwInterfaceAddressReplaceEnd) GetCrcString() string { return "51077d14" } +func (*SwInterfaceAddressReplaceEnd) GetMessageType() api.MessageType { return api.RequestMessage } + +func (m *SwInterfaceAddressReplaceEnd) Size() int { + if m == nil { + return 0 + } + var size int + return size +} +func (m *SwInterfaceAddressReplaceEnd) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + return buf, nil +} +func (m *SwInterfaceAddressReplaceEnd) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + return nil +} + +// SwInterfaceAddressReplaceEndReply represents VPP binary API message 'sw_interface_address_replace_end_reply'. +type SwInterfaceAddressReplaceEndReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` +} + +func (m *SwInterfaceAddressReplaceEndReply) Reset() { *m = SwInterfaceAddressReplaceEndReply{} } +func (*SwInterfaceAddressReplaceEndReply) GetMessageName() string { + return "sw_interface_address_replace_end_reply" +} +func (*SwInterfaceAddressReplaceEndReply) GetCrcString() string { return "e8d4e804" } +func (*SwInterfaceAddressReplaceEndReply) GetMessageType() api.MessageType { return api.ReplyMessage } + +func (m *SwInterfaceAddressReplaceEndReply) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.Retval + size += 4 + return size +} +func (m *SwInterfaceAddressReplaceEndReply) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.Retval + o.PutUint32(buf[pos:pos+4], uint32(m.Retval)) + pos += 4 + return buf, nil +} +func (m *SwInterfaceAddressReplaceEndReply) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.Retval + m.Retval = int32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + return nil +} + // SwInterfaceClearStats represents VPP binary API message 'sw_interface_clear_stats'. type SwInterfaceClearStats struct { SwIfIndex InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` @@ -3857,6 +3555,10 @@ func file_interfaces_binapi_init() { api.RegisterMessage((*SwInterfaceAddDelAddressReply)(nil), "interface.SwInterfaceAddDelAddressReply") api.RegisterMessage((*SwInterfaceAddDelMacAddress)(nil), "interface.SwInterfaceAddDelMacAddress") api.RegisterMessage((*SwInterfaceAddDelMacAddressReply)(nil), "interface.SwInterfaceAddDelMacAddressReply") + api.RegisterMessage((*SwInterfaceAddressReplaceBegin)(nil), "interface.SwInterfaceAddressReplaceBegin") + api.RegisterMessage((*SwInterfaceAddressReplaceBeginReply)(nil), "interface.SwInterfaceAddressReplaceBeginReply") + api.RegisterMessage((*SwInterfaceAddressReplaceEnd)(nil), "interface.SwInterfaceAddressReplaceEnd") + api.RegisterMessage((*SwInterfaceAddressReplaceEndReply)(nil), "interface.SwInterfaceAddressReplaceEndReply") api.RegisterMessage((*SwInterfaceClearStats)(nil), "interface.SwInterfaceClearStats") api.RegisterMessage((*SwInterfaceClearStatsReply)(nil), "interface.SwInterfaceClearStatsReply") api.RegisterMessage((*SwInterfaceDetails)(nil), "interface.SwInterfaceDetails") @@ -3915,6 +3617,10 @@ func AllMessages() []api.Message { (*SwInterfaceAddDelAddressReply)(nil), (*SwInterfaceAddDelMacAddress)(nil), (*SwInterfaceAddDelMacAddressReply)(nil), + (*SwInterfaceAddressReplaceBegin)(nil), + (*SwInterfaceAddressReplaceBeginReply)(nil), + (*SwInterfaceAddressReplaceEnd)(nil), + (*SwInterfaceAddressReplaceEndReply)(nil), (*SwInterfaceClearStats)(nil), (*SwInterfaceClearStatsReply)(nil), (*SwInterfaceDetails)(nil), diff --git a/examples/binapi/interfaces/interfaces_rpc.ba.go b/examples/binapi/interfaces/interfaces_rpc.ba.go index e30aed9..a7235a8 100644 --- a/examples/binapi/interfaces/interfaces_rpc.ba.go +++ b/examples/binapi/interfaces/interfaces_rpc.ba.go @@ -24,6 +24,8 @@ type RPCService interface { InterfaceNameRenumber(ctx context.Context, in *InterfaceNameRenumber) (*InterfaceNameRenumberReply, error) SwInterfaceAddDelAddress(ctx context.Context, in *SwInterfaceAddDelAddress) (*SwInterfaceAddDelAddressReply, error) SwInterfaceAddDelMacAddress(ctx context.Context, in *SwInterfaceAddDelMacAddress) (*SwInterfaceAddDelMacAddressReply, error) + SwInterfaceAddressReplaceBegin(ctx context.Context, in *SwInterfaceAddressReplaceBegin) (*SwInterfaceAddressReplaceBeginReply, error) + SwInterfaceAddressReplaceEnd(ctx context.Context, in *SwInterfaceAddressReplaceEnd) (*SwInterfaceAddressReplaceEndReply, error) SwInterfaceClearStats(ctx context.Context, in *SwInterfaceClearStats) (*SwInterfaceClearStatsReply, error) SwInterfaceGetMacAddress(ctx context.Context, in *SwInterfaceGetMacAddress) (*SwInterfaceGetMacAddressReply, error) SwInterfaceGetTable(ctx context.Context, in *SwInterfaceGetTable) (*SwInterfaceGetTableReply, error) @@ -198,6 +200,24 @@ func (c *serviceClient) SwInterfaceAddDelMacAddress(ctx context.Context, in *SwI return out, nil } +func (c *serviceClient) SwInterfaceAddressReplaceBegin(ctx context.Context, in *SwInterfaceAddressReplaceBegin) (*SwInterfaceAddressReplaceBeginReply, error) { + out := new(SwInterfaceAddressReplaceBeginReply) + err := c.ch.SendRequest(in).ReceiveReply(out) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *serviceClient) SwInterfaceAddressReplaceEnd(ctx context.Context, in *SwInterfaceAddressReplaceEnd) (*SwInterfaceAddressReplaceEndReply, error) { + out := new(SwInterfaceAddressReplaceEndReply) + err := c.ch.SendRequest(in).ReceiveReply(out) + if err != nil { + return nil, err + } + return out, nil +} + func (c *serviceClient) SwInterfaceClearStats(ctx context.Context, in *SwInterfaceClearStats) (*SwInterfaceClearStatsReply, error) { out := new(SwInterfaceClearStatsReply) err := c.ch.SendRequest(in).ReceiveReply(out) diff --git a/examples/binapi/ip/ip.ba.go b/examples/binapi/ip/ip.ba.go index b15a489..183ed99 100644 --- a/examples/binapi/ip/ip.ba.go +++ b/examples/binapi/ip/ip.ba.go @@ -1,11 +1,11 @@ // Code generated by GoVPP's binapi-generator. DO NOT EDIT. // versions: -// binapi-generator: v0.4.0-alpha-1-g435c3f4-dirty -// VPP: 20.01-45~g7a071e370~b63 +// binapi-generator: v0.4.0-dev +// VPP: 20.05-release // source: /usr/share/vpp/api/core/ip.api.json /* -Package ip contains generated code for VPP binary API defined by ip.api (version 3.0.1). +Package ip contains generated code for VPP API file ip.api (3.0.1). It consists of: 7 aliases @@ -27,6 +27,9 @@ import ( api "git.fd.io/govpp.git/api" codec "git.fd.io/govpp.git/codec" struc "github.com/lunixbochs/struc" + + fib_types "git.fd.io/govpp.git/examples/binapi/fib_types" + interface_types "git.fd.io/govpp.git/examples/binapi/interface_types" ) // This is a compile-time assertion to ensure that this generated file @@ -41,392 +44,26 @@ const ( // APIVersion is the API version of this module. APIVersion = "3.0.1" // VersionCrc is the CRC of this module. - VersionCrc = 0xfc3fea46 -) - -// AddressFamily represents VPP binary API enum 'address_family'. -type AddressFamily uint32 - -const ( - ADDRESS_IP4 AddressFamily = 0 - ADDRESS_IP6 AddressFamily = 1 -) - -var ( - AddressFamily_name = map[uint32]string{ - 0: "ADDRESS_IP4", - 1: "ADDRESS_IP6", - } - AddressFamily_value = map[string]uint32{ - "ADDRESS_IP4": 0, - "ADDRESS_IP6": 1, - } -) - -func (x AddressFamily) String() string { - s, ok := AddressFamily_name[uint32(x)] - if ok { - return s - } - return "AddressFamily(" + strconv.Itoa(int(x)) + ")" -} - -// FibPathFlags represents VPP binary API enum 'fib_path_flags'. -type FibPathFlags uint32 - -const ( - FIB_API_PATH_FLAG_NONE FibPathFlags = 0 - FIB_API_PATH_FLAG_RESOLVE_VIA_ATTACHED FibPathFlags = 1 - FIB_API_PATH_FLAG_RESOLVE_VIA_HOST FibPathFlags = 2 - FIB_API_PATH_FLAG_POP_PW_CW FibPathFlags = 4 -) - -var ( - FibPathFlags_name = map[uint32]string{ - 0: "FIB_API_PATH_FLAG_NONE", - 1: "FIB_API_PATH_FLAG_RESOLVE_VIA_ATTACHED", - 2: "FIB_API_PATH_FLAG_RESOLVE_VIA_HOST", - 4: "FIB_API_PATH_FLAG_POP_PW_CW", - } - FibPathFlags_value = map[string]uint32{ - "FIB_API_PATH_FLAG_NONE": 0, - "FIB_API_PATH_FLAG_RESOLVE_VIA_ATTACHED": 1, - "FIB_API_PATH_FLAG_RESOLVE_VIA_HOST": 2, - "FIB_API_PATH_FLAG_POP_PW_CW": 4, - } -) - -func (x FibPathFlags) String() string { - s, ok := FibPathFlags_name[uint32(x)] - if ok { - return s - } - return "FibPathFlags(" + strconv.Itoa(int(x)) + ")" -} - -// FibPathNhProto represents VPP binary API enum 'fib_path_nh_proto'. -type FibPathNhProto uint32 - -const ( - FIB_API_PATH_NH_PROTO_IP4 FibPathNhProto = 0 - FIB_API_PATH_NH_PROTO_IP6 FibPathNhProto = 1 - FIB_API_PATH_NH_PROTO_MPLS FibPathNhProto = 2 - FIB_API_PATH_NH_PROTO_ETHERNET FibPathNhProto = 3 - FIB_API_PATH_NH_PROTO_BIER FibPathNhProto = 4 -) - -var ( - FibPathNhProto_name = map[uint32]string{ - 0: "FIB_API_PATH_NH_PROTO_IP4", - 1: "FIB_API_PATH_NH_PROTO_IP6", - 2: "FIB_API_PATH_NH_PROTO_MPLS", - 3: "FIB_API_PATH_NH_PROTO_ETHERNET", - 4: "FIB_API_PATH_NH_PROTO_BIER", - } - FibPathNhProto_value = map[string]uint32{ - "FIB_API_PATH_NH_PROTO_IP4": 0, - "FIB_API_PATH_NH_PROTO_IP6": 1, - "FIB_API_PATH_NH_PROTO_MPLS": 2, - "FIB_API_PATH_NH_PROTO_ETHERNET": 3, - "FIB_API_PATH_NH_PROTO_BIER": 4, - } -) - -func (x FibPathNhProto) String() string { - s, ok := FibPathNhProto_name[uint32(x)] - if ok { - return s - } - return "FibPathNhProto(" + strconv.Itoa(int(x)) + ")" -} - -// FibPathType represents VPP binary API enum 'fib_path_type'. -type FibPathType uint32 - -const ( - FIB_API_PATH_TYPE_NORMAL FibPathType = 0 - FIB_API_PATH_TYPE_LOCAL FibPathType = 1 - FIB_API_PATH_TYPE_DROP FibPathType = 2 - FIB_API_PATH_TYPE_UDP_ENCAP FibPathType = 3 - FIB_API_PATH_TYPE_BIER_IMP FibPathType = 4 - FIB_API_PATH_TYPE_ICMP_UNREACH FibPathType = 5 - FIB_API_PATH_TYPE_ICMP_PROHIBIT FibPathType = 6 - FIB_API_PATH_TYPE_SOURCE_LOOKUP FibPathType = 7 - FIB_API_PATH_TYPE_DVR FibPathType = 8 - FIB_API_PATH_TYPE_INTERFACE_RX FibPathType = 9 - FIB_API_PATH_TYPE_CLASSIFY FibPathType = 10 + VersionCrc = 0x765d74b1 ) -var ( - FibPathType_name = map[uint32]string{ - 0: "FIB_API_PATH_TYPE_NORMAL", - 1: "FIB_API_PATH_TYPE_LOCAL", - 2: "FIB_API_PATH_TYPE_DROP", - 3: "FIB_API_PATH_TYPE_UDP_ENCAP", - 4: "FIB_API_PATH_TYPE_BIER_IMP", - 5: "FIB_API_PATH_TYPE_ICMP_UNREACH", - 6: "FIB_API_PATH_TYPE_ICMP_PROHIBIT", - 7: "FIB_API_PATH_TYPE_SOURCE_LOOKUP", - 8: "FIB_API_PATH_TYPE_DVR", - 9: "FIB_API_PATH_TYPE_INTERFACE_RX", - 10: "FIB_API_PATH_TYPE_CLASSIFY", - } - FibPathType_value = map[string]uint32{ - "FIB_API_PATH_TYPE_NORMAL": 0, - "FIB_API_PATH_TYPE_LOCAL": 1, - "FIB_API_PATH_TYPE_DROP": 2, - "FIB_API_PATH_TYPE_UDP_ENCAP": 3, - "FIB_API_PATH_TYPE_BIER_IMP": 4, - "FIB_API_PATH_TYPE_ICMP_UNREACH": 5, - "FIB_API_PATH_TYPE_ICMP_PROHIBIT": 6, - "FIB_API_PATH_TYPE_SOURCE_LOOKUP": 7, - "FIB_API_PATH_TYPE_DVR": 8, - "FIB_API_PATH_TYPE_INTERFACE_RX": 9, - "FIB_API_PATH_TYPE_CLASSIFY": 10, - } -) +type AddressFamily = fib_types.AddressFamily -func (x FibPathType) String() string { - s, ok := FibPathType_name[uint32(x)] - if ok { - return s - } - return "FibPathType(" + strconv.Itoa(int(x)) + ")" -} +type FibPathFlags = fib_types.FibPathFlags -// IfStatusFlags represents VPP binary API enum 'if_status_flags'. -type IfStatusFlags uint32 - -const ( - IF_STATUS_API_FLAG_ADMIN_UP IfStatusFlags = 1 - IF_STATUS_API_FLAG_LINK_UP IfStatusFlags = 2 -) +type FibPathNhProto = fib_types.FibPathNhProto -var ( - IfStatusFlags_name = map[uint32]string{ - 1: "IF_STATUS_API_FLAG_ADMIN_UP", - 2: "IF_STATUS_API_FLAG_LINK_UP", - } - IfStatusFlags_value = map[string]uint32{ - "IF_STATUS_API_FLAG_ADMIN_UP": 1, - "IF_STATUS_API_FLAG_LINK_UP": 2, - } -) +type FibPathType = fib_types.FibPathType -func (x IfStatusFlags) String() string { - s, ok := IfStatusFlags_name[uint32(x)] - if ok { - return s - } - return "IfStatusFlags(" + strconv.Itoa(int(x)) + ")" -} +type IfStatusFlags = interface_types.IfStatusFlags -// IfType represents VPP binary API enum 'if_type'. -type IfType uint32 +type IfType = interface_types.IfType -const ( - IF_API_TYPE_HARDWARE IfType = 1 - IF_API_TYPE_SUB IfType = 2 - IF_API_TYPE_P2P IfType = 3 - IF_API_TYPE_PIPE IfType = 4 -) +type IPDscp = fib_types.IPDscp -var ( - IfType_name = map[uint32]string{ - 1: "IF_API_TYPE_HARDWARE", - 2: "IF_API_TYPE_SUB", - 3: "IF_API_TYPE_P2P", - 4: "IF_API_TYPE_PIPE", - } - IfType_value = map[string]uint32{ - "IF_API_TYPE_HARDWARE": 1, - "IF_API_TYPE_SUB": 2, - "IF_API_TYPE_P2P": 3, - "IF_API_TYPE_PIPE": 4, - } -) - -func (x IfType) String() string { - s, ok := IfType_name[uint32(x)] - if ok { - return s - } - return "IfType(" + strconv.Itoa(int(x)) + ")" -} - -// IPDscp represents VPP binary API enum 'ip_dscp'. -type IPDscp uint8 - -const ( - IP_API_DSCP_CS0 IPDscp = 0 - IP_API_DSCP_CS1 IPDscp = 8 - IP_API_DSCP_AF11 IPDscp = 10 - IP_API_DSCP_AF12 IPDscp = 12 - IP_API_DSCP_AF13 IPDscp = 14 - IP_API_DSCP_CS2 IPDscp = 16 - IP_API_DSCP_AF21 IPDscp = 18 - IP_API_DSCP_AF22 IPDscp = 20 - IP_API_DSCP_AF23 IPDscp = 22 - IP_API_DSCP_CS3 IPDscp = 24 - IP_API_DSCP_AF31 IPDscp = 26 - IP_API_DSCP_AF32 IPDscp = 28 - IP_API_DSCP_AF33 IPDscp = 30 - IP_API_DSCP_CS4 IPDscp = 32 - IP_API_DSCP_AF41 IPDscp = 34 - IP_API_DSCP_AF42 IPDscp = 36 - IP_API_DSCP_AF43 IPDscp = 38 - IP_API_DSCP_CS5 IPDscp = 40 - IP_API_DSCP_EF IPDscp = 46 - IP_API_DSCP_CS6 IPDscp = 48 - IP_API_DSCP_CS7 IPDscp = 50 -) - -var ( - IPDscp_name = map[uint8]string{ - 0: "IP_API_DSCP_CS0", - 8: "IP_API_DSCP_CS1", - 10: "IP_API_DSCP_AF11", - 12: "IP_API_DSCP_AF12", - 14: "IP_API_DSCP_AF13", - 16: "IP_API_DSCP_CS2", - 18: "IP_API_DSCP_AF21", - 20: "IP_API_DSCP_AF22", - 22: "IP_API_DSCP_AF23", - 24: "IP_API_DSCP_CS3", - 26: "IP_API_DSCP_AF31", - 28: "IP_API_DSCP_AF32", - 30: "IP_API_DSCP_AF33", - 32: "IP_API_DSCP_CS4", - 34: "IP_API_DSCP_AF41", - 36: "IP_API_DSCP_AF42", - 38: "IP_API_DSCP_AF43", - 40: "IP_API_DSCP_CS5", - 46: "IP_API_DSCP_EF", - 48: "IP_API_DSCP_CS6", - 50: "IP_API_DSCP_CS7", - } - IPDscp_value = map[string]uint8{ - "IP_API_DSCP_CS0": 0, - "IP_API_DSCP_CS1": 8, - "IP_API_DSCP_AF11": 10, - "IP_API_DSCP_AF12": 12, - "IP_API_DSCP_AF13": 14, - "IP_API_DSCP_CS2": 16, - "IP_API_DSCP_AF21": 18, - "IP_API_DSCP_AF22": 20, - "IP_API_DSCP_AF23": 22, - "IP_API_DSCP_CS3": 24, - "IP_API_DSCP_AF31": 26, - "IP_API_DSCP_AF32": 28, - "IP_API_DSCP_AF33": 30, - "IP_API_DSCP_CS4": 32, - "IP_API_DSCP_AF41": 34, - "IP_API_DSCP_AF42": 36, - "IP_API_DSCP_AF43": 38, - "IP_API_DSCP_CS5": 40, - "IP_API_DSCP_EF": 46, - "IP_API_DSCP_CS6": 48, - "IP_API_DSCP_CS7": 50, - } -) - -func (x IPDscp) String() string { - s, ok := IPDscp_name[uint8(x)] - if ok { - return s - } - return "IPDscp(" + strconv.Itoa(int(x)) + ")" -} +type IPEcn = fib_types.IPEcn -// IPEcn represents VPP binary API enum 'ip_ecn'. -type IPEcn uint8 - -const ( - IP_API_ECN_NONE IPEcn = 0 - IP_API_ECN_ECT0 IPEcn = 1 - IP_API_ECN_ECT1 IPEcn = 2 - IP_API_ECN_CE IPEcn = 3 -) - -var ( - IPEcn_name = map[uint8]string{ - 0: "IP_API_ECN_NONE", - 1: "IP_API_ECN_ECT0", - 2: "IP_API_ECN_ECT1", - 3: "IP_API_ECN_CE", - } - IPEcn_value = map[string]uint8{ - "IP_API_ECN_NONE": 0, - "IP_API_ECN_ECT0": 1, - "IP_API_ECN_ECT1": 2, - "IP_API_ECN_CE": 3, - } -) - -func (x IPEcn) String() string { - s, ok := IPEcn_name[uint8(x)] - if ok { - return s - } - return "IPEcn(" + strconv.Itoa(int(x)) + ")" -} - -// IPProto represents VPP binary API enum 'ip_proto'. -type IPProto uint32 - -const ( - IP_API_PROTO_HOPOPT IPProto = 0 - IP_API_PROTO_ICMP IPProto = 1 - IP_API_PROTO_IGMP IPProto = 2 - IP_API_PROTO_TCP IPProto = 6 - IP_API_PROTO_UDP IPProto = 17 - IP_API_PROTO_GRE IPProto = 47 - IP_API_PROTO_AH IPProto = 50 - IP_API_PROTO_ESP IPProto = 51 - IP_API_PROTO_EIGRP IPProto = 88 - IP_API_PROTO_OSPF IPProto = 89 - IP_API_PROTO_SCTP IPProto = 132 - IP_API_PROTO_RESERVED IPProto = 255 -) - -var ( - IPProto_name = map[uint32]string{ - 0: "IP_API_PROTO_HOPOPT", - 1: "IP_API_PROTO_ICMP", - 2: "IP_API_PROTO_IGMP", - 6: "IP_API_PROTO_TCP", - 17: "IP_API_PROTO_UDP", - 47: "IP_API_PROTO_GRE", - 50: "IP_API_PROTO_AH", - 51: "IP_API_PROTO_ESP", - 88: "IP_API_PROTO_EIGRP", - 89: "IP_API_PROTO_OSPF", - 132: "IP_API_PROTO_SCTP", - 255: "IP_API_PROTO_RESERVED", - } - IPProto_value = map[string]uint32{ - "IP_API_PROTO_HOPOPT": 0, - "IP_API_PROTO_ICMP": 1, - "IP_API_PROTO_IGMP": 2, - "IP_API_PROTO_TCP": 6, - "IP_API_PROTO_UDP": 17, - "IP_API_PROTO_GRE": 47, - "IP_API_PROTO_AH": 50, - "IP_API_PROTO_ESP": 51, - "IP_API_PROTO_EIGRP": 88, - "IP_API_PROTO_OSPF": 89, - "IP_API_PROTO_SCTP": 132, - "IP_API_PROTO_RESERVED": 255, - } -) - -func (x IPProto) String() string { - s, ok := IPProto_name[uint32(x)] - if ok { - return s - } - return "IPProto(" + strconv.Itoa(int(x)) + ")" -} +type IPProto = fib_types.IPProto // IPReassType represents VPP binary API enum 'ip_reass_type'. type IPReassType uint32 @@ -455,35 +92,7 @@ func (x IPReassType) String() string { return "IPReassType(" + strconv.Itoa(int(x)) + ")" } -// LinkDuplex represents VPP binary API enum 'link_duplex'. -type LinkDuplex uint32 - -const ( - LINK_DUPLEX_API_UNKNOWN LinkDuplex = 0 - LINK_DUPLEX_API_HALF LinkDuplex = 1 - LINK_DUPLEX_API_FULL LinkDuplex = 2 -) - -var ( - LinkDuplex_name = map[uint32]string{ - 0: "LINK_DUPLEX_API_UNKNOWN", - 1: "LINK_DUPLEX_API_HALF", - 2: "LINK_DUPLEX_API_FULL", - } - LinkDuplex_value = map[string]uint32{ - "LINK_DUPLEX_API_UNKNOWN": 0, - "LINK_DUPLEX_API_HALF": 1, - "LINK_DUPLEX_API_FULL": 2, - } -) - -func (x LinkDuplex) String() string { - s, ok := LinkDuplex_name[uint32(x)] - if ok { - return s - } - return "LinkDuplex(" + strconv.Itoa(int(x)) + ")" -} +type LinkDuplex = interface_types.LinkDuplex // MfibItfFlags represents VPP binary API enum 'mfib_itf_flags'. type MfibItfFlags uint32 @@ -524,210 +133,38 @@ func (x MfibItfFlags) String() string { return "MfibItfFlags(" + strconv.Itoa(int(x)) + ")" } -// MtuProto represents VPP binary API enum 'mtu_proto'. -type MtuProto uint32 +type MtuProto = interface_types.MtuProto -const ( - MTU_PROTO_API_L3 MtuProto = 1 - MTU_PROTO_API_IP4 MtuProto = 2 - MTU_PROTO_API_IP6 MtuProto = 3 - MTU_PROTO_API_MPLS MtuProto = 4 - MTU_PROTO_API_N MtuProto = 5 -) +type RxMode = interface_types.RxMode -var ( - MtuProto_name = map[uint32]string{ - 1: "MTU_PROTO_API_L3", - 2: "MTU_PROTO_API_IP4", - 3: "MTU_PROTO_API_IP6", - 4: "MTU_PROTO_API_MPLS", - 5: "MTU_PROTO_API_N", - } - MtuProto_value = map[string]uint32{ - "MTU_PROTO_API_L3": 1, - "MTU_PROTO_API_IP4": 2, - "MTU_PROTO_API_IP6": 3, - "MTU_PROTO_API_MPLS": 4, - "MTU_PROTO_API_N": 5, - } -) +type SubIfFlags = interface_types.SubIfFlags -func (x MtuProto) String() string { - s, ok := MtuProto_name[uint32(x)] - if ok { - return s - } - return "MtuProto(" + strconv.Itoa(int(x)) + ")" -} - -// RxMode represents VPP binary API enum 'rx_mode'. -type RxMode uint32 - -const ( - RX_MODE_API_UNKNOWN RxMode = 0 - RX_MODE_API_POLLING RxMode = 1 - RX_MODE_API_INTERRUPT RxMode = 2 - RX_MODE_API_ADAPTIVE RxMode = 3 - RX_MODE_API_DEFAULT RxMode = 4 -) - -var ( - RxMode_name = map[uint32]string{ - 0: "RX_MODE_API_UNKNOWN", - 1: "RX_MODE_API_POLLING", - 2: "RX_MODE_API_INTERRUPT", - 3: "RX_MODE_API_ADAPTIVE", - 4: "RX_MODE_API_DEFAULT", - } - RxMode_value = map[string]uint32{ - "RX_MODE_API_UNKNOWN": 0, - "RX_MODE_API_POLLING": 1, - "RX_MODE_API_INTERRUPT": 2, - "RX_MODE_API_ADAPTIVE": 3, - "RX_MODE_API_DEFAULT": 4, - } -) - -func (x RxMode) String() string { - s, ok := RxMode_name[uint32(x)] - if ok { - return s - } - return "RxMode(" + strconv.Itoa(int(x)) + ")" -} - -// SubIfFlags represents VPP binary API enum 'sub_if_flags'. -type SubIfFlags uint32 - -const ( - SUB_IF_API_FLAG_NO_TAGS SubIfFlags = 1 - SUB_IF_API_FLAG_ONE_TAG SubIfFlags = 2 - SUB_IF_API_FLAG_TWO_TAGS SubIfFlags = 4 - SUB_IF_API_FLAG_DOT1AD SubIfFlags = 8 - SUB_IF_API_FLAG_EXACT_MATCH SubIfFlags = 16 - SUB_IF_API_FLAG_DEFAULT SubIfFlags = 32 - SUB_IF_API_FLAG_OUTER_VLAN_ID_ANY SubIfFlags = 64 - SUB_IF_API_FLAG_INNER_VLAN_ID_ANY SubIfFlags = 128 - SUB_IF_API_FLAG_MASK_VNET SubIfFlags = 254 - SUB_IF_API_FLAG_DOT1AH SubIfFlags = 256 -) +type AddressWithPrefix = fib_types.AddressWithPrefix -var ( - SubIfFlags_name = map[uint32]string{ - 1: "SUB_IF_API_FLAG_NO_TAGS", - 2: "SUB_IF_API_FLAG_ONE_TAG", - 4: "SUB_IF_API_FLAG_TWO_TAGS", - 8: "SUB_IF_API_FLAG_DOT1AD", - 16: "SUB_IF_API_FLAG_EXACT_MATCH", - 32: "SUB_IF_API_FLAG_DEFAULT", - 64: "SUB_IF_API_FLAG_OUTER_VLAN_ID_ANY", - 128: "SUB_IF_API_FLAG_INNER_VLAN_ID_ANY", - 254: "SUB_IF_API_FLAG_MASK_VNET", - 256: "SUB_IF_API_FLAG_DOT1AH", - } - SubIfFlags_value = map[string]uint32{ - "SUB_IF_API_FLAG_NO_TAGS": 1, - "SUB_IF_API_FLAG_ONE_TAG": 2, - "SUB_IF_API_FLAG_TWO_TAGS": 4, - "SUB_IF_API_FLAG_DOT1AD": 8, - "SUB_IF_API_FLAG_EXACT_MATCH": 16, - "SUB_IF_API_FLAG_DEFAULT": 32, - "SUB_IF_API_FLAG_OUTER_VLAN_ID_ANY": 64, - "SUB_IF_API_FLAG_INNER_VLAN_ID_ANY": 128, - "SUB_IF_API_FLAG_MASK_VNET": 254, - "SUB_IF_API_FLAG_DOT1AH": 256, - } -) +type InterfaceIndex = interface_types.InterfaceIndex -func (x SubIfFlags) String() string { - s, ok := SubIfFlags_name[uint32(x)] - if ok { - return s - } - return "SubIfFlags(" + strconv.Itoa(int(x)) + ")" -} - -// AddressWithPrefix represents VPP binary API alias 'address_with_prefix'. -type AddressWithPrefix Prefix - -// InterfaceIndex represents VPP binary API alias 'interface_index'. -type InterfaceIndex uint32 +type IP4Address = fib_types.IP4Address -// IP4Address represents VPP binary API alias 'ip4_address'. -type IP4Address [4]uint8 +type IP4AddressWithPrefix = fib_types.IP4AddressWithPrefix -// IP4AddressWithPrefix represents VPP binary API alias 'ip4_address_with_prefix'. -type IP4AddressWithPrefix IP4Prefix +type IP6Address = fib_types.IP6Address -// IP6Address represents VPP binary API alias 'ip6_address'. -type IP6Address [16]uint8 - -// IP6AddressWithPrefix represents VPP binary API alias 'ip6_address_with_prefix'. -type IP6AddressWithPrefix IP6Prefix +type IP6AddressWithPrefix = fib_types.IP6AddressWithPrefix // MacAddress represents VPP binary API alias 'mac_address'. type MacAddress [6]uint8 -// Address represents VPP binary API type 'address'. -type Address struct { - Af AddressFamily `binapi:"address_family,name=af" json:"af,omitempty"` - Un AddressUnion `binapi:"address_union,name=un" json:"un,omitempty"` -} +type Address = fib_types.Address -func (*Address) GetTypeName() string { return "address" } +type FibMplsLabel = fib_types.FibMplsLabel -// FibMplsLabel represents VPP binary API type 'fib_mpls_label'. -type FibMplsLabel struct { - IsUniform uint8 `binapi:"u8,name=is_uniform" json:"is_uniform,omitempty"` - Label uint32 `binapi:"u32,name=label" json:"label,omitempty"` - TTL uint8 `binapi:"u8,name=ttl" json:"ttl,omitempty"` - Exp uint8 `binapi:"u8,name=exp" json:"exp,omitempty"` -} - -func (*FibMplsLabel) GetTypeName() string { return "fib_mpls_label" } - -// FibPath represents VPP binary API type 'fib_path'. -type FibPath struct { - SwIfIndex uint32 `binapi:"u32,name=sw_if_index" json:"sw_if_index,omitempty"` - TableID uint32 `binapi:"u32,name=table_id" json:"table_id,omitempty"` - RpfID uint32 `binapi:"u32,name=rpf_id" json:"rpf_id,omitempty"` - Weight uint8 `binapi:"u8,name=weight" json:"weight,omitempty"` - Preference uint8 `binapi:"u8,name=preference" json:"preference,omitempty"` - Type FibPathType `binapi:"fib_path_type,name=type" json:"type,omitempty"` - Flags FibPathFlags `binapi:"fib_path_flags,name=flags" json:"flags,omitempty"` - Proto FibPathNhProto `binapi:"fib_path_nh_proto,name=proto" json:"proto,omitempty"` - Nh FibPathNh `binapi:"fib_path_nh,name=nh" json:"nh,omitempty"` - NLabels uint8 `binapi:"u8,name=n_labels" json:"n_labels,omitempty"` - LabelStack [16]FibMplsLabel `binapi:"fib_mpls_label[16],name=label_stack" json:"label_stack,omitempty" struc:"[16]FibMplsLabel"` -} - -func (*FibPath) GetTypeName() string { return "fib_path" } - -// FibPathNh represents VPP binary API type 'fib_path_nh'. -type FibPathNh struct { - Address AddressUnion `binapi:"address_union,name=address" json:"address,omitempty"` - ViaLabel uint32 `binapi:"u32,name=via_label" json:"via_label,omitempty"` - ObjID uint32 `binapi:"u32,name=obj_id" json:"obj_id,omitempty"` - ClassifyTableIndex uint32 `binapi:"u32,name=classify_table_index" json:"classify_table_index,omitempty"` -} - -func (*FibPathNh) GetTypeName() string { return "fib_path_nh" } - -// IP4Prefix represents VPP binary API type 'ip4_prefix'. -type IP4Prefix struct { - Address IP4Address `binapi:"ip4_address,name=address" json:"address,omitempty"` - Len uint8 `binapi:"u8,name=len" json:"len,omitempty"` -} +type FibPath = fib_types.FibPath -func (*IP4Prefix) GetTypeName() string { return "ip4_prefix" } +type FibPathNh = fib_types.FibPathNh -// IP6Prefix represents VPP binary API type 'ip6_prefix'. -type IP6Prefix struct { - Address IP6Address `binapi:"ip6_address,name=address" json:"address,omitempty"` - Len uint8 `binapi:"u8,name=len" json:"len,omitempty"` -} +type IP4Prefix = fib_types.IP4Prefix -func (*IP6Prefix) GetTypeName() string { return "ip6_prefix" } +type IP6Prefix = fib_types.IP6Prefix // IPMroute represents VPP binary API type 'ip_mroute'. type IPMroute struct { @@ -769,31 +206,11 @@ type MfibPath struct { func (*MfibPath) GetTypeName() string { return "mfib_path" } -// Mprefix represents VPP binary API type 'mprefix'. -type Mprefix struct { - Af AddressFamily `binapi:"address_family,name=af" json:"af,omitempty"` - GrpAddressLength uint16 `binapi:"u16,name=grp_address_length" json:"grp_address_length,omitempty"` - GrpAddress AddressUnion `binapi:"address_union,name=grp_address" json:"grp_address,omitempty"` - SrcAddress AddressUnion `binapi:"address_union,name=src_address" json:"src_address,omitempty"` -} - -func (*Mprefix) GetTypeName() string { return "mprefix" } +type Mprefix = fib_types.Mprefix -// Prefix represents VPP binary API type 'prefix'. -type Prefix struct { - Address Address `binapi:"address,name=address" json:"address,omitempty"` - Len uint8 `binapi:"u8,name=len" json:"len,omitempty"` -} - -func (*Prefix) GetTypeName() string { return "prefix" } +type Prefix = fib_types.Prefix -// PrefixMatcher represents VPP binary API type 'prefix_matcher'. -type PrefixMatcher struct { - Le uint8 `binapi:"u8,name=le" json:"le,omitempty"` - Ge uint8 `binapi:"u8,name=ge" json:"ge,omitempty"` -} - -func (*PrefixMatcher) GetTypeName() string { return "prefix_matcher" } +type PrefixMatcher = fib_types.PrefixMatcher // PuntRedirect represents VPP binary API type 'punt_redirect'. type PuntRedirect struct { @@ -804,46 +221,7 @@ type PuntRedirect struct { func (*PuntRedirect) GetTypeName() string { return "punt_redirect" } -// AddressUnion represents VPP binary API union 'address_union'. -type AddressUnion struct { - XXX_UnionData [16]byte -} - -func (*AddressUnion) GetTypeName() string { return "address_union" } - -func AddressUnionIP4(a IP4Address) (u AddressUnion) { - u.SetIP4(a) - return -} -func (u *AddressUnion) SetIP4(a IP4Address) { - var b = new(bytes.Buffer) - if err := struc.Pack(b, &a); err != nil { - return - } - copy(u.XXX_UnionData[:], b.Bytes()) -} -func (u *AddressUnion) GetIP4() (a IP4Address) { - var b = bytes.NewReader(u.XXX_UnionData[:]) - struc.Unpack(b, &a) - return -} - -func AddressUnionIP6(a IP6Address) (u AddressUnion) { - u.SetIP6(a) - return -} -func (u *AddressUnion) SetIP6(a IP6Address) { - var b = new(bytes.Buffer) - if err := struc.Pack(b, &a); err != nil { - return - } - copy(u.XXX_UnionData[:], b.Bytes()) -} -func (u *AddressUnion) GetIP6() (a IP6Address) { - var b = bytes.NewReader(u.XXX_UnionData[:]) - struc.Unpack(b, &a) - return -} +type AddressUnion = fib_types.AddressUnion // IoamDisable represents VPP binary API message 'ioam_disable'. type IoamDisable struct { @@ -1103,7 +481,7 @@ func (m *IPAddressDetails) Size() int { // field[1] m.Prefix // field[2] m.Prefix.Address // field[3] m.Prefix.Address.Af - size += 4 + size += 1 // field[3] m.Prefix.Address.Un size += 16 // field[2] m.Prefix.Len @@ -1127,8 +505,8 @@ func (m *IPAddressDetails) Marshal(b []byte) ([]byte, error) { // field[1] m.Prefix // field[2] m.Prefix.Address // field[3] m.Prefix.Address.Af - o.PutUint32(buf[pos:pos+4], uint32(m.Prefix.Address.Af)) - pos += 4 + buf[pos] = uint8(m.Prefix.Address.Af) + pos += 1 // field[3] m.Prefix.Address.Un copy(buf[pos:pos+16], m.Prefix.Address.Un.XXX_UnionData[:]) pos += 16 @@ -1148,8 +526,8 @@ func (m *IPAddressDetails) Unmarshal(tmp []byte) error { // field[1] m.Prefix // field[2] m.Prefix.Address // field[3] m.Prefix.Address.Af - m.Prefix.Address.Af = AddressFamily(o.Uint32(tmp[pos : pos+4])) - pos += 4 + m.Prefix.Address.Af = AddressFamily(tmp[pos]) + pos += 1 // field[3] m.Prefix.Address.Un copy(m.Prefix.Address.Un.XXX_UnionData[:], tmp[pos:pos+16]) pos += 16 @@ -1236,7 +614,7 @@ func (m *IPContainerProxyAddDel) Size() int { // field[1] m.Pfx // field[2] m.Pfx.Address // field[3] m.Pfx.Address.Af - size += 4 + size += 1 // field[3] m.Pfx.Address.Un size += 16 // field[2] m.Pfx.Len @@ -1261,8 +639,8 @@ func (m *IPContainerProxyAddDel) Marshal(b []byte) ([]byte, error) { // field[1] m.Pfx // field[2] m.Pfx.Address // field[3] m.Pfx.Address.Af - o.PutUint32(buf[pos:pos+4], uint32(m.Pfx.Address.Af)) - pos += 4 + buf[pos] = uint8(m.Pfx.Address.Af) + pos += 1 // field[3] m.Pfx.Address.Un copy(buf[pos:pos+16], m.Pfx.Address.Un.XXX_UnionData[:]) pos += 16 @@ -1287,8 +665,8 @@ func (m *IPContainerProxyAddDel) Unmarshal(tmp []byte) error { // field[1] m.Pfx // field[2] m.Pfx.Address // field[3] m.Pfx.Address.Af - m.Pfx.Address.Af = AddressFamily(o.Uint32(tmp[pos : pos+4])) - pos += 4 + m.Pfx.Address.Af = AddressFamily(tmp[pos]) + pos += 1 // field[3] m.Pfx.Address.Un copy(m.Pfx.Address.Un.XXX_UnionData[:], tmp[pos:pos+16]) pos += 16 @@ -1373,7 +751,7 @@ func (m *IPContainerProxyDetails) Size() int { // field[1] m.Prefix // field[2] m.Prefix.Address // field[3] m.Prefix.Address.Af - size += 4 + size += 1 // field[3] m.Prefix.Address.Un size += 16 // field[2] m.Prefix.Len @@ -1397,8 +775,8 @@ func (m *IPContainerProxyDetails) Marshal(b []byte) ([]byte, error) { // field[1] m.Prefix // field[2] m.Prefix.Address // field[3] m.Prefix.Address.Af - o.PutUint32(buf[pos:pos+4], uint32(m.Prefix.Address.Af)) - pos += 4 + buf[pos] = uint8(m.Prefix.Address.Af) + pos += 1 // field[3] m.Prefix.Address.Un copy(buf[pos:pos+16], m.Prefix.Address.Un.XXX_UnionData[:]) pos += 16 @@ -1418,8 +796,8 @@ func (m *IPContainerProxyDetails) Unmarshal(tmp []byte) error { // field[1] m.Prefix // field[2] m.Prefix.Address // field[3] m.Prefix.Address.Af - m.Prefix.Address.Af = AddressFamily(o.Uint32(tmp[pos : pos+4])) - pos += 4 + m.Prefix.Address.Af = AddressFamily(tmp[pos]) + pos += 1 // field[3] m.Prefix.Address.Un copy(m.Prefix.Address.Un.XXX_UnionData[:], tmp[pos:pos+16]) pos += 16 @@ -1600,7 +978,7 @@ func (m *IPMrouteAddDel) Size() int { size += 4 // field[2] m.Route.Prefix // field[3] m.Route.Prefix.Af - size += 4 + size += 1 // field[3] m.Route.Prefix.GrpAddressLength size += 2 // field[3] m.Route.Prefix.GrpAddress @@ -1698,8 +1076,8 @@ func (m *IPMrouteAddDel) Marshal(b []byte) ([]byte, error) { pos += 4 // field[2] m.Route.Prefix // field[3] m.Route.Prefix.Af - o.PutUint32(buf[pos:pos+4], uint32(m.Route.Prefix.Af)) - pos += 4 + buf[pos] = uint8(m.Route.Prefix.Af) + pos += 1 // field[3] m.Route.Prefix.GrpAddressLength o.PutUint16(buf[pos:pos+2], uint16(m.Route.Prefix.GrpAddressLength)) pos += 2 @@ -1807,8 +1185,8 @@ func (m *IPMrouteAddDel) Unmarshal(tmp []byte) error { pos += 4 // field[2] m.Route.Prefix // field[3] m.Route.Prefix.Af - m.Route.Prefix.Af = AddressFamily(o.Uint32(tmp[pos : pos+4])) - pos += 4 + m.Route.Prefix.Af = AddressFamily(tmp[pos]) + pos += 1 // field[3] m.Route.Prefix.GrpAddressLength m.Route.Prefix.GrpAddressLength = uint16(o.Uint16(tmp[pos : pos+2])) pos += 2 @@ -1966,7 +1344,7 @@ func (m *IPMrouteDetails) Size() int { size += 4 // field[2] m.Route.Prefix // field[3] m.Route.Prefix.Af - size += 4 + size += 1 // field[3] m.Route.Prefix.GrpAddressLength size += 2 // field[3] m.Route.Prefix.GrpAddress @@ -2054,8 +1432,8 @@ func (m *IPMrouteDetails) Marshal(b []byte) ([]byte, error) { pos += 4 // field[2] m.Route.Prefix // field[3] m.Route.Prefix.Af - o.PutUint32(buf[pos:pos+4], uint32(m.Route.Prefix.Af)) - pos += 4 + buf[pos] = uint8(m.Route.Prefix.Af) + pos += 1 // field[3] m.Route.Prefix.GrpAddressLength o.PutUint16(buf[pos:pos+2], uint16(m.Route.Prefix.GrpAddressLength)) pos += 2 @@ -2157,8 +1535,8 @@ func (m *IPMrouteDetails) Unmarshal(tmp []byte) error { pos += 4 // field[2] m.Route.Prefix // field[3] m.Route.Prefix.Af - m.Route.Prefix.Af = AddressFamily(o.Uint32(tmp[pos : pos+4])) - pos += 4 + m.Route.Prefix.Af = AddressFamily(tmp[pos]) + pos += 1 // field[3] m.Route.Prefix.GrpAddressLength m.Route.Prefix.GrpAddressLength = uint16(o.Uint16(tmp[pos : pos+2])) pos += 2 @@ -2550,7 +1928,7 @@ func (m *IPPuntRedirect) Size() int { size += 4 // field[2] m.Punt.Nh // field[3] m.Punt.Nh.Af - size += 4 + size += 1 // field[3] m.Punt.Nh.Un size += 16 // field[1] m.IsAdd @@ -2577,8 +1955,8 @@ func (m *IPPuntRedirect) Marshal(b []byte) ([]byte, error) { pos += 4 // field[2] m.Punt.Nh // field[3] m.Punt.Nh.Af - o.PutUint32(buf[pos:pos+4], uint32(m.Punt.Nh.Af)) - pos += 4 + buf[pos] = uint8(m.Punt.Nh.Af) + pos += 1 // field[3] m.Punt.Nh.Un copy(buf[pos:pos+16], m.Punt.Nh.Un.XXX_UnionData[:]) pos += 16 @@ -2603,8 +1981,8 @@ func (m *IPPuntRedirect) Unmarshal(tmp []byte) error { pos += 4 // field[2] m.Punt.Nh // field[3] m.Punt.Nh.Af - m.Punt.Nh.Af = AddressFamily(o.Uint32(tmp[pos : pos+4])) - pos += 4 + m.Punt.Nh.Af = AddressFamily(tmp[pos]) + pos += 1 // field[3] m.Punt.Nh.Un copy(m.Punt.Nh.Un.XXX_UnionData[:], tmp[pos:pos+16]) pos += 16 @@ -2636,7 +2014,7 @@ func (m *IPPuntRedirectDetails) Size() int { size += 4 // field[2] m.Punt.Nh // field[3] m.Punt.Nh.Af - size += 4 + size += 1 // field[3] m.Punt.Nh.Un size += 16 return size @@ -2661,8 +2039,8 @@ func (m *IPPuntRedirectDetails) Marshal(b []byte) ([]byte, error) { pos += 4 // field[2] m.Punt.Nh // field[3] m.Punt.Nh.Af - o.PutUint32(buf[pos:pos+4], uint32(m.Punt.Nh.Af)) - pos += 4 + buf[pos] = uint8(m.Punt.Nh.Af) + pos += 1 // field[3] m.Punt.Nh.Un copy(buf[pos:pos+16], m.Punt.Nh.Un.XXX_UnionData[:]) pos += 16 @@ -2682,8 +2060,8 @@ func (m *IPPuntRedirectDetails) Unmarshal(tmp []byte) error { pos += 4 // field[2] m.Punt.Nh // field[3] m.Punt.Nh.Af - m.Punt.Nh.Af = AddressFamily(o.Uint32(tmp[pos : pos+4])) - pos += 4 + m.Punt.Nh.Af = AddressFamily(tmp[pos]) + pos += 1 // field[3] m.Punt.Nh.Un copy(m.Punt.Nh.Un.XXX_UnionData[:], tmp[pos:pos+16]) pos += 16 @@ -3236,7 +2614,7 @@ func (m *IPRouteAddDel) Size() int { // field[2] m.Route.Prefix // field[3] m.Route.Prefix.Address // field[4] m.Route.Prefix.Address.Af - size += 4 + size += 1 // field[4] m.Route.Prefix.Address.Un size += 16 // field[3] m.Route.Prefix.Len @@ -3327,8 +2705,8 @@ func (m *IPRouteAddDel) Marshal(b []byte) ([]byte, error) { // field[2] m.Route.Prefix // field[3] m.Route.Prefix.Address // field[4] m.Route.Prefix.Address.Af - o.PutUint32(buf[pos:pos+4], uint32(m.Route.Prefix.Address.Af)) - pos += 4 + buf[pos] = uint8(m.Route.Prefix.Address.Af) + pos += 1 // field[4] m.Route.Prefix.Address.Un copy(buf[pos:pos+16], m.Route.Prefix.Address.Un.XXX_UnionData[:]) pos += 16 @@ -3427,8 +2805,8 @@ func (m *IPRouteAddDel) Unmarshal(tmp []byte) error { // field[2] m.Route.Prefix // field[3] m.Route.Prefix.Address // field[4] m.Route.Prefix.Address.Af - m.Route.Prefix.Address.Af = AddressFamily(o.Uint32(tmp[pos : pos+4])) - pos += 4 + m.Route.Prefix.Address.Af = AddressFamily(tmp[pos]) + pos += 1 // field[4] m.Route.Prefix.Address.Un copy(m.Route.Prefix.Address.Un.XXX_UnionData[:], tmp[pos:pos+16]) pos += 16 @@ -3578,7 +2956,7 @@ func (m *IPRouteDetails) Size() int { // field[2] m.Route.Prefix // field[3] m.Route.Prefix.Address // field[4] m.Route.Prefix.Address.Af - size += 4 + size += 1 // field[4] m.Route.Prefix.Address.Un size += 16 // field[3] m.Route.Prefix.Len @@ -3659,8 +3037,8 @@ func (m *IPRouteDetails) Marshal(b []byte) ([]byte, error) { // field[2] m.Route.Prefix // field[3] m.Route.Prefix.Address // field[4] m.Route.Prefix.Address.Af - o.PutUint32(buf[pos:pos+4], uint32(m.Route.Prefix.Address.Af)) - pos += 4 + buf[pos] = uint8(m.Route.Prefix.Address.Af) + pos += 1 // field[4] m.Route.Prefix.Address.Un copy(buf[pos:pos+16], m.Route.Prefix.Address.Un.XXX_UnionData[:]) pos += 16 @@ -3753,8 +3131,8 @@ func (m *IPRouteDetails) Unmarshal(tmp []byte) error { // field[2] m.Route.Prefix // field[3] m.Route.Prefix.Address // field[4] m.Route.Prefix.Address.Af - m.Route.Prefix.Address.Af = AddressFamily(o.Uint32(tmp[pos : pos+4])) - pos += 4 + m.Route.Prefix.Address.Af = AddressFamily(tmp[pos]) + pos += 1 // field[4] m.Route.Prefix.Address.Un copy(m.Route.Prefix.Address.Un.XXX_UnionData[:], tmp[pos:pos+16]) pos += 16 @@ -3896,6 +3274,372 @@ func (m *IPRouteDump) Unmarshal(tmp []byte) error { return nil } +// IPRouteLookup represents VPP binary API message 'ip_route_lookup'. +type IPRouteLookup struct { + TableID uint32 `binapi:"u32,name=table_id" json:"table_id,omitempty"` + Exact uint8 `binapi:"u8,name=exact" json:"exact,omitempty"` + Prefix Prefix `binapi:"prefix,name=prefix" json:"prefix,omitempty"` +} + +func (m *IPRouteLookup) Reset() { *m = IPRouteLookup{} } +func (*IPRouteLookup) GetMessageName() string { return "ip_route_lookup" } +func (*IPRouteLookup) GetCrcString() string { return "e2986185" } +func (*IPRouteLookup) GetMessageType() api.MessageType { return api.RequestMessage } + +func (m *IPRouteLookup) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.TableID + size += 4 + // field[1] m.Exact + size += 1 + // field[1] m.Prefix + // field[2] m.Prefix.Address + // field[3] m.Prefix.Address.Af + size += 1 + // field[3] m.Prefix.Address.Un + size += 16 + // field[2] m.Prefix.Len + size += 1 + return size +} +func (m *IPRouteLookup) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.TableID + o.PutUint32(buf[pos:pos+4], uint32(m.TableID)) + pos += 4 + // field[1] m.Exact + buf[pos] = uint8(m.Exact) + pos += 1 + // field[1] m.Prefix + // field[2] m.Prefix.Address + // field[3] m.Prefix.Address.Af + buf[pos] = uint8(m.Prefix.Address.Af) + pos += 1 + // field[3] m.Prefix.Address.Un + copy(buf[pos:pos+16], m.Prefix.Address.Un.XXX_UnionData[:]) + pos += 16 + // field[2] m.Prefix.Len + buf[pos] = uint8(m.Prefix.Len) + pos += 1 + return buf, nil +} +func (m *IPRouteLookup) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.TableID + m.TableID = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.Exact + m.Exact = uint8(tmp[pos]) + pos += 1 + // field[1] m.Prefix + // field[2] m.Prefix.Address + // field[3] m.Prefix.Address.Af + m.Prefix.Address.Af = AddressFamily(tmp[pos]) + pos += 1 + // field[3] m.Prefix.Address.Un + copy(m.Prefix.Address.Un.XXX_UnionData[:], tmp[pos:pos+16]) + pos += 16 + // field[2] m.Prefix.Len + m.Prefix.Len = uint8(tmp[pos]) + pos += 1 + return nil +} + +// IPRouteLookupReply represents VPP binary API message 'ip_route_lookup_reply'. +type IPRouteLookupReply struct { + Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` + Route IPRoute `binapi:"ip_route,name=route" json:"route,omitempty"` +} + +func (m *IPRouteLookupReply) Reset() { *m = IPRouteLookupReply{} } +func (*IPRouteLookupReply) GetMessageName() string { return "ip_route_lookup_reply" } +func (*IPRouteLookupReply) GetCrcString() string { return "ae99de8e" } +func (*IPRouteLookupReply) GetMessageType() api.MessageType { return api.ReplyMessage } + +func (m *IPRouteLookupReply) Size() int { + if m == nil { + return 0 + } + var size int + // field[1] m.Retval + size += 4 + // field[1] m.Route + // field[2] m.Route.TableID + size += 4 + // field[2] m.Route.StatsIndex + size += 4 + // field[2] m.Route.Prefix + // field[3] m.Route.Prefix.Address + // field[4] m.Route.Prefix.Address.Af + size += 1 + // field[4] m.Route.Prefix.Address.Un + size += 16 + // field[3] m.Route.Prefix.Len + size += 1 + // field[2] m.Route.NPaths + size += 1 + // field[2] m.Route.Paths + for j2 := 0; j2 < len(m.Route.Paths); j2++ { + var s2 FibPath + _ = s2 + if j2 < len(m.Route.Paths) { + s2 = m.Route.Paths[j2] + } + // field[3] s2.SwIfIndex + size += 4 + // field[3] s2.TableID + size += 4 + // field[3] s2.RpfID + size += 4 + // field[3] s2.Weight + size += 1 + // field[3] s2.Preference + size += 1 + // field[3] s2.Type + size += 4 + // field[3] s2.Flags + size += 4 + // field[3] s2.Proto + size += 4 + // field[3] s2.Nh + // field[4] s2.Nh.Address + size += 16 + // field[4] s2.Nh.ViaLabel + size += 4 + // field[4] s2.Nh.ObjID + size += 4 + // field[4] s2.Nh.ClassifyTableIndex + size += 4 + // field[3] s2.NLabels + size += 1 + // field[3] s2.LabelStack + for j3 := 0; j3 < 16; j3++ { + var s3 FibMplsLabel + _ = s3 + if j3 < len(s2.LabelStack) { + s3 = s2.LabelStack[j3] + } + // field[4] s3.IsUniform + size += 1 + // field[4] s3.Label + size += 4 + // field[4] s3.TTL + size += 1 + // field[4] s3.Exp + size += 1 + } + } + return size +} +func (m *IPRouteLookupReply) Marshal(b []byte) ([]byte, error) { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + var buf []byte + if b == nil { + buf = make([]byte, m.Size()) + } else { + buf = b + } + // field[1] m.Retval + o.PutUint32(buf[pos:pos+4], uint32(m.Retval)) + pos += 4 + // field[1] m.Route + // field[2] m.Route.TableID + o.PutUint32(buf[pos:pos+4], uint32(m.Route.TableID)) + pos += 4 + // field[2] m.Route.StatsIndex + o.PutUint32(buf[pos:pos+4], uint32(m.Route.StatsIndex)) + pos += 4 + // field[2] m.Route.Prefix + // field[3] m.Route.Prefix.Address + // field[4] m.Route.Prefix.Address.Af + buf[pos] = uint8(m.Route.Prefix.Address.Af) + pos += 1 + // field[4] m.Route.Prefix.Address.Un + copy(buf[pos:pos+16], m.Route.Prefix.Address.Un.XXX_UnionData[:]) + pos += 16 + // field[3] m.Route.Prefix.Len + buf[pos] = uint8(m.Route.Prefix.Len) + pos += 1 + // field[2] m.Route.NPaths + buf[pos] = uint8(len(m.Route.Paths)) + pos += 1 + // field[2] m.Route.Paths + for j2 := 0; j2 < len(m.Route.Paths); j2++ { + var v2 FibPath + if j2 < len(m.Route.Paths) { + v2 = m.Route.Paths[j2] + } + // field[3] v2.SwIfIndex + o.PutUint32(buf[pos:pos+4], uint32(v2.SwIfIndex)) + pos += 4 + // field[3] v2.TableID + o.PutUint32(buf[pos:pos+4], uint32(v2.TableID)) + pos += 4 + // field[3] v2.RpfID + o.PutUint32(buf[pos:pos+4], uint32(v2.RpfID)) + pos += 4 + // field[3] v2.Weight + buf[pos] = uint8(v2.Weight) + pos += 1 + // field[3] v2.Preference + buf[pos] = uint8(v2.Preference) + pos += 1 + // field[3] v2.Type + o.PutUint32(buf[pos:pos+4], uint32(v2.Type)) + pos += 4 + // field[3] v2.Flags + o.PutUint32(buf[pos:pos+4], uint32(v2.Flags)) + pos += 4 + // field[3] v2.Proto + o.PutUint32(buf[pos:pos+4], uint32(v2.Proto)) + pos += 4 + // field[3] v2.Nh + // field[4] v2.Nh.Address + copy(buf[pos:pos+16], v2.Nh.Address.XXX_UnionData[:]) + pos += 16 + // field[4] v2.Nh.ViaLabel + o.PutUint32(buf[pos:pos+4], uint32(v2.Nh.ViaLabel)) + pos += 4 + // field[4] v2.Nh.ObjID + o.PutUint32(buf[pos:pos+4], uint32(v2.Nh.ObjID)) + pos += 4 + // field[4] v2.Nh.ClassifyTableIndex + o.PutUint32(buf[pos:pos+4], uint32(v2.Nh.ClassifyTableIndex)) + pos += 4 + // field[3] v2.NLabels + buf[pos] = uint8(v2.NLabels) + pos += 1 + // field[3] v2.LabelStack + for j3 := 0; j3 < 16; j3++ { + var v3 FibMplsLabel + if j3 < len(v2.LabelStack) { + v3 = v2.LabelStack[j3] + } + // field[4] v3.IsUniform + buf[pos] = uint8(v3.IsUniform) + pos += 1 + // field[4] v3.Label + o.PutUint32(buf[pos:pos+4], uint32(v3.Label)) + pos += 4 + // field[4] v3.TTL + buf[pos] = uint8(v3.TTL) + pos += 1 + // field[4] v3.Exp + buf[pos] = uint8(v3.Exp) + pos += 1 + } + } + return buf, nil +} +func (m *IPRouteLookupReply) Unmarshal(tmp []byte) error { + o := binary.BigEndian + _ = o + pos := 0 + _ = pos + // field[1] m.Retval + m.Retval = int32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[1] m.Route + // field[2] m.Route.TableID + m.Route.TableID = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[2] m.Route.StatsIndex + m.Route.StatsIndex = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[2] m.Route.Prefix + // field[3] m.Route.Prefix.Address + // field[4] m.Route.Prefix.Address.Af + m.Route.Prefix.Address.Af = AddressFamily(tmp[pos]) + pos += 1 + // field[4] m.Route.Prefix.Address.Un + copy(m.Route.Prefix.Address.Un.XXX_UnionData[:], tmp[pos:pos+16]) + pos += 16 + // field[3] m.Route.Prefix.Len + m.Route.Prefix.Len = uint8(tmp[pos]) + pos += 1 + // field[2] m.Route.NPaths + m.Route.NPaths = uint8(tmp[pos]) + pos += 1 + // field[2] m.Route.Paths + m.Route.Paths = make([]FibPath, int(m.Route.NPaths)) + for j2 := 0; j2 < int(m.Route.NPaths); j2++ { + // field[3] m.Route.Paths[j2].SwIfIndex + m.Route.Paths[j2].SwIfIndex = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[3] m.Route.Paths[j2].TableID + m.Route.Paths[j2].TableID = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[3] m.Route.Paths[j2].RpfID + m.Route.Paths[j2].RpfID = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[3] m.Route.Paths[j2].Weight + m.Route.Paths[j2].Weight = uint8(tmp[pos]) + pos += 1 + // field[3] m.Route.Paths[j2].Preference + m.Route.Paths[j2].Preference = uint8(tmp[pos]) + pos += 1 + // field[3] m.Route.Paths[j2].Type + m.Route.Paths[j2].Type = FibPathType(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[3] m.Route.Paths[j2].Flags + m.Route.Paths[j2].Flags = FibPathFlags(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[3] m.Route.Paths[j2].Proto + m.Route.Paths[j2].Proto = FibPathNhProto(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[3] m.Route.Paths[j2].Nh + // field[4] m.Route.Paths[j2].Nh.Address + copy(m.Route.Paths[j2].Nh.Address.XXX_UnionData[:], tmp[pos:pos+16]) + pos += 16 + // field[4] m.Route.Paths[j2].Nh.ViaLabel + m.Route.Paths[j2].Nh.ViaLabel = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[4] m.Route.Paths[j2].Nh.ObjID + m.Route.Paths[j2].Nh.ObjID = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[4] m.Route.Paths[j2].Nh.ClassifyTableIndex + m.Route.Paths[j2].Nh.ClassifyTableIndex = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[3] m.Route.Paths[j2].NLabels + m.Route.Paths[j2].NLabels = uint8(tmp[pos]) + pos += 1 + // field[3] m.Route.Paths[j2].LabelStack + for j3 := 0; j3 < 16; j3++ { + // field[4] m.Route.Paths[j2].LabelStack[j3].IsUniform + m.Route.Paths[j2].LabelStack[j3].IsUniform = uint8(tmp[pos]) + pos += 1 + // field[4] m.Route.Paths[j2].LabelStack[j3].Label + m.Route.Paths[j2].LabelStack[j3].Label = uint32(o.Uint32(tmp[pos : pos+4])) + pos += 4 + // field[4] m.Route.Paths[j2].LabelStack[j3].TTL + m.Route.Paths[j2].LabelStack[j3].TTL = uint8(tmp[pos]) + pos += 1 + // field[4] m.Route.Paths[j2].LabelStack[j3].Exp + m.Route.Paths[j2].LabelStack[j3].Exp = uint8(tmp[pos]) + pos += 1 + } + } + return nil +} + // IPSourceAndPortRangeCheckAddDel represents VPP binary API message 'ip_source_and_port_range_check_add_del'. type IPSourceAndPortRangeCheckAddDel struct { IsAdd bool `binapi:"bool,name=is_add,default=true" json:"is_add,omitempty"` @@ -3923,7 +3667,7 @@ func (m *IPSourceAndPortRangeCheckAddDel) Size() int { // field[1] m.Prefix // field[2] m.Prefix.Address // field[3] m.Prefix.Address.Af - size += 4 + size += 1 // field[3] m.Prefix.Address.Un size += 16 // field[2] m.Prefix.Len @@ -3957,8 +3701,8 @@ func (m *IPSourceAndPortRangeCheckAddDel) Marshal(b []byte) ([]byte, error) { // field[1] m.Prefix // field[2] m.Prefix.Address // field[3] m.Prefix.Address.Af - o.PutUint32(buf[pos:pos+4], uint32(m.Prefix.Address.Af)) - pos += 4 + buf[pos] = uint8(m.Prefix.Address.Af) + pos += 1 // field[3] m.Prefix.Address.Un copy(buf[pos:pos+16], m.Prefix.Address.Un.XXX_UnionData[:]) pos += 16 @@ -4002,8 +3746,8 @@ func (m *IPSourceAndPortRangeCheckAddDel) Unmarshal(tmp []byte) error { // field[1] m.Prefix // field[2] m.Prefix.Address // field[3] m.Prefix.Address.Af - m.Prefix.Address.Af = AddressFamily(o.Uint32(tmp[pos : pos+4])) - pos += 4 + m.Prefix.Address.Af = AddressFamily(tmp[pos]) + pos += 1 // field[3] m.Prefix.Address.Un copy(m.Prefix.Address.Un.XXX_UnionData[:], tmp[pos:pos+16]) pos += 16 @@ -4232,124 +3976,6 @@ func (m *IPSourceAndPortRangeCheckInterfaceAddDelReply) Unmarshal(tmp []byte) er return nil } -// IPSourceCheckInterfaceAddDel represents VPP binary API message 'ip_source_check_interface_add_del'. -type IPSourceCheckInterfaceAddDel struct { - IsAdd bool `binapi:"bool,name=is_add,default=true" json:"is_add,omitempty"` - Loose bool `binapi:"bool,name=loose" json:"loose,omitempty"` - SwIfIndex InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` -} - -func (m *IPSourceCheckInterfaceAddDel) Reset() { *m = IPSourceCheckInterfaceAddDel{} } -func (*IPSourceCheckInterfaceAddDel) GetMessageName() string { - return "ip_source_check_interface_add_del" -} -func (*IPSourceCheckInterfaceAddDel) GetCrcString() string { return "6612356b" } -func (*IPSourceCheckInterfaceAddDel) GetMessageType() api.MessageType { return api.RequestMessage } - -func (m *IPSourceCheckInterfaceAddDel) Size() int { - if m == nil { - return 0 - } - var size int - // field[1] m.IsAdd - size += 1 - // field[1] m.Loose - size += 1 - // field[1] m.SwIfIndex - size += 4 - return size -} -func (m *IPSourceCheckInterfaceAddDel) Marshal(b []byte) ([]byte, error) { - o := binary.BigEndian - _ = o - pos := 0 - _ = pos - var buf []byte - if b == nil { - buf = make([]byte, m.Size()) - } else { - buf = b - } - // field[1] m.IsAdd - if m.IsAdd { - buf[pos] = 1 - } - pos += 1 - // field[1] m.Loose - if m.Loose { - buf[pos] = 1 - } - pos += 1 - // field[1] m.SwIfIndex - o.PutUint32(buf[pos:pos+4], uint32(m.SwIfIndex)) - pos += 4 - return buf, nil -} -func (m *IPSourceCheckInterfaceAddDel) Unmarshal(tmp []byte) error { - o := binary.BigEndian - _ = o - pos := 0 - _ = pos - // field[1] m.IsAdd - m.IsAdd = tmp[pos] != 0 - pos += 1 - // field[1] m.Loose - m.Loose = tmp[pos] != 0 - pos += 1 - // field[1] m.SwIfIndex - m.SwIfIndex = InterfaceIndex(o.Uint32(tmp[pos : pos+4])) - pos += 4 - return nil -} - -// IPSourceCheckInterfaceAddDelReply represents VPP binary API message 'ip_source_check_interface_add_del_reply'. -type IPSourceCheckInterfaceAddDelReply struct { - Retval int32 `binapi:"i32,name=retval" json:"retval,omitempty"` -} - -func (m *IPSourceCheckInterfaceAddDelReply) Reset() { *m = IPSourceCheckInterfaceAddDelReply{} } -func (*IPSourceCheckInterfaceAddDelReply) GetMessageName() string { - return "ip_source_check_interface_add_del_reply" -} -func (*IPSourceCheckInterfaceAddDelReply) GetCrcString() string { return "e8d4e804" } -func (*IPSourceCheckInterfaceAddDelReply) GetMessageType() api.MessageType { return api.ReplyMessage } - -func (m *IPSourceCheckInterfaceAddDelReply) Size() int { - if m == nil { - return 0 - } - var size int - // field[1] m.Retval - size += 4 - return size -} -func (m *IPSourceCheckInterfaceAddDelReply) Marshal(b []byte) ([]byte, error) { - o := binary.BigEndian - _ = o - pos := 0 - _ = pos - var buf []byte - if b == nil { - buf = make([]byte, m.Size()) - } else { - buf = b - } - // field[1] m.Retval - o.PutUint32(buf[pos:pos+4], uint32(m.Retval)) - pos += 4 - return buf, nil -} -func (m *IPSourceCheckInterfaceAddDelReply) Unmarshal(tmp []byte) error { - o := binary.BigEndian - _ = o - pos := 0 - _ = pos - // field[1] m.Retval - m.Retval = int32(o.Uint32(tmp[pos : pos+4])) - pos += 4 - return nil -} - // IPTableAddDel represents VPP binary API message 'ip_table_add_del'. type IPTableAddDel struct { IsAdd bool `binapi:"bool,name=is_add,default=true" json:"is_add,omitempty"` @@ -4988,7 +4614,7 @@ func (m *IPUnnumberedDetails) Unmarshal(tmp []byte) error { // IPUnnumberedDump represents VPP binary API message 'ip_unnumbered_dump'. type IPUnnumberedDump struct { - SwIfIndex InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + SwIfIndex InterfaceIndex `binapi:"interface_index,name=sw_if_index,default=4294967295" json:"sw_if_index,omitempty"` } func (m *IPUnnumberedDump) Reset() { *m = IPUnnumberedDump{} } @@ -5057,7 +4683,7 @@ func (m *MfibSignalDetails) Size() int { size += 4 // field[1] m.Prefix // field[2] m.Prefix.Af - size += 4 + size += 1 // field[2] m.Prefix.GrpAddressLength size += 2 // field[2] m.Prefix.GrpAddress @@ -5089,8 +4715,8 @@ func (m *MfibSignalDetails) Marshal(b []byte) ([]byte, error) { pos += 4 // field[1] m.Prefix // field[2] m.Prefix.Af - o.PutUint32(buf[pos:pos+4], uint32(m.Prefix.Af)) - pos += 4 + buf[pos] = uint8(m.Prefix.Af) + pos += 1 // field[2] m.Prefix.GrpAddressLength o.PutUint16(buf[pos:pos+2], uint16(m.Prefix.GrpAddressLength)) pos += 2 @@ -5127,8 +4753,8 @@ func (m *MfibSignalDetails) Unmarshal(tmp []byte) error { pos += 4 // field[1] m.Prefix // field[2] m.Prefix.Af - m.Prefix.Af = AddressFamily(o.Uint32(tmp[pos : pos+4])) - pos += 4 + m.Prefix.Af = AddressFamily(tmp[pos]) + pos += 1 // field[2] m.Prefix.GrpAddressLength m.Prefix.GrpAddressLength = uint16(o.Uint16(tmp[pos : pos+2])) pos += 2 @@ -5624,12 +5250,12 @@ func file_ip_binapi_init() { api.RegisterMessage((*IPRouteAddDelReply)(nil), "ip.IPRouteAddDelReply") api.RegisterMessage((*IPRouteDetails)(nil), "ip.IPRouteDetails") api.RegisterMessage((*IPRouteDump)(nil), "ip.IPRouteDump") + api.RegisterMessage((*IPRouteLookup)(nil), "ip.IPRouteLookup") + api.RegisterMessage((*IPRouteLookupReply)(nil), "ip.IPRouteLookupReply") api.RegisterMessage((*IPSourceAndPortRangeCheckAddDel)(nil), "ip.IPSourceAndPortRangeCheckAddDel") api.RegisterMessage((*IPSourceAndPortRangeCheckAddDelReply)(nil), "ip.IPSourceAndPortRangeCheckAddDelReply") api.RegisterMessage((*IPSourceAndPortRangeCheckInterfaceAddDel)(nil), "ip.IPSourceAndPortRangeCheckInterfaceAddDel") api.RegisterMessage((*IPSourceAndPortRangeCheckInterfaceAddDelReply)(nil), "ip.IPSourceAndPortRangeCheckInterfaceAddDelReply") - api.RegisterMessage((*IPSourceCheckInterfaceAddDel)(nil), "ip.IPSourceCheckInterfaceAddDel") - api.RegisterMessage((*IPSourceCheckInterfaceAddDelReply)(nil), "ip.IPSourceCheckInterfaceAddDelReply") api.RegisterMessage((*IPTableAddDel)(nil), "ip.IPTableAddDel") api.RegisterMessage((*IPTableAddDelReply)(nil), "ip.IPTableAddDelReply") api.RegisterMessage((*IPTableDetails)(nil), "ip.IPTableDetails") @@ -5689,12 +5315,12 @@ func AllMessages() []api.Message { (*IPRouteAddDelReply)(nil), (*IPRouteDetails)(nil), (*IPRouteDump)(nil), + (*IPRouteLookup)(nil), + (*IPRouteLookupReply)(nil), (*IPSourceAndPortRangeCheckAddDel)(nil), (*IPSourceAndPortRangeCheckAddDelReply)(nil), (*IPSourceAndPortRangeCheckInterfaceAddDel)(nil), (*IPSourceAndPortRangeCheckInterfaceAddDelReply)(nil), - (*IPSourceCheckInterfaceAddDel)(nil), - (*IPSourceCheckInterfaceAddDelReply)(nil), (*IPTableAddDel)(nil), (*IPTableAddDelReply)(nil), (*IPTableDetails)(nil), diff --git a/examples/binapi/ip/ip_rpc.ba.go b/examples/binapi/ip/ip_rpc.ba.go index e0580d5..d1bbd08 100644 --- a/examples/binapi/ip/ip_rpc.ba.go +++ b/examples/binapi/ip/ip_rpc.ba.go @@ -31,9 +31,9 @@ type RPCService interface { IPReassemblyGet(ctx context.Context, in *IPReassemblyGet) (*IPReassemblyGetReply, error) IPReassemblySet(ctx context.Context, in *IPReassemblySet) (*IPReassemblySetReply, error) IPRouteAddDel(ctx context.Context, in *IPRouteAddDel) (*IPRouteAddDelReply, error) + IPRouteLookup(ctx context.Context, in *IPRouteLookup) (*IPRouteLookupReply, error) IPSourceAndPortRangeCheckAddDel(ctx context.Context, in *IPSourceAndPortRangeCheckAddDel) (*IPSourceAndPortRangeCheckAddDelReply, error) IPSourceAndPortRangeCheckInterfaceAddDel(ctx context.Context, in *IPSourceAndPortRangeCheckInterfaceAddDel) (*IPSourceAndPortRangeCheckInterfaceAddDelReply, error) - IPSourceCheckInterfaceAddDel(ctx context.Context, in *IPSourceCheckInterfaceAddDel) (*IPSourceCheckInterfaceAddDelReply, error) IPTableAddDel(ctx context.Context, in *IPTableAddDel) (*IPTableAddDelReply, error) IPTableFlush(ctx context.Context, in *IPTableFlush) (*IPTableFlushReply, error) IPTableReplaceBegin(ctx context.Context, in *IPTableReplaceBegin) (*IPTableReplaceBeginReply, error) @@ -401,8 +401,8 @@ func (c *serviceClient) IPRouteAddDel(ctx context.Context, in *IPRouteAddDel) (* return out, nil } -func (c *serviceClient) IPSourceAndPortRangeCheckAddDel(ctx context.Context, in *IPSourceAndPortRangeCheckAddDel) (*IPSourceAndPortRangeCheckAddDelReply, error) { - out := new(IPSourceAndPortRangeCheckAddDelReply) +func (c *serviceClient) IPRouteLookup(ctx context.Context, in *IPRouteLookup) (*IPRouteLookupReply, error) { + out := new(IPRouteLookupReply) err := c.ch.SendRequest(in).ReceiveReply(out) if err != nil { return nil, err @@ -410,8 +410,8 @@ func (c *serviceClient) IPSourceAndPortRangeCheckAddDel(ctx context.Context, in return out, nil } -func (c *serviceClient) IPSourceAndPortRangeCheckInterfaceAddDel(ctx context.Context, in *IPSourceAndPortRangeCheckInterfaceAddDel) (*IPSourceAndPortRangeCheckInterfaceAddDelReply, error) { - out := new(IPSourceAndPortRangeCheckInterfaceAddDelReply) +func (c *serviceClient) IPSourceAndPortRangeCheckAddDel(ctx context.Context, in *IPSourceAndPortRangeCheckAddDel) (*IPSourceAndPortRangeCheckAddDelReply, error) { + out := new(IPSourceAndPortRangeCheckAddDelReply) err := c.ch.SendRequest(in).ReceiveReply(out) if err != nil { return nil, err @@ -419,8 +419,8 @@ func (c *serviceClient) IPSourceAndPortRangeCheckInterfaceAddDel(ctx context.Con return out, nil } -func (c *serviceClient) IPSourceCheckInterfaceAddDel(ctx context.Context, in *IPSourceCheckInterfaceAddDel) (*IPSourceCheckInterfaceAddDelReply, error) { - out := new(IPSourceCheckInterfaceAddDelReply) +func (c *serviceClient) IPSourceAndPortRangeCheckInterfaceAddDel(ctx context.Context, in *IPSourceAndPortRangeCheckInterfaceAddDel) (*IPSourceAndPortRangeCheckInterfaceAddDelReply, error) { + out := new(IPSourceAndPortRangeCheckInterfaceAddDelReply) err := c.ch.SendRequest(in).ReceiveReply(out) if err != nil { return nil, err diff --git a/examples/binapi/ip_types/ip_types.ba.go b/examples/binapi/ip_types/ip_types.ba.go index 9335060..23ae315 100644 --- a/examples/binapi/ip_types/ip_types.ba.go +++ b/examples/binapi/ip_types/ip_types.ba.go @@ -1,11 +1,11 @@ // Code generated by GoVPP's binapi-generator. DO NOT EDIT. // versions: -// binapi-generator: v0.4.0-alpha-1-g435c3f4-dirty -// VPP: 20.01-45~g7a071e370~b63 +// binapi-generator: v0.4.0-dev +// VPP: 20.05-release // source: /usr/share/vpp/api/core/ip_types.api.json /* -Package ip_types contains generated code for VPP binary API defined by ip_types.api (version 3.0.0). +Package ip_types contains generated code for VPP API file ip_types.api (3.0.0). It consists of: 5 aliases @@ -40,11 +40,11 @@ const ( // APIVersion is the API version of this module. APIVersion = "3.0.0" // VersionCrc is the CRC of this module. - VersionCrc = 0x80424562 + VersionCrc = 0x9cb1c2e2 ) // AddressFamily represents VPP binary API enum 'address_family'. -type AddressFamily uint32 +type AddressFamily uint8 const ( ADDRESS_IP4 AddressFamily = 0 @@ -52,18 +52,18 @@ const ( ) var ( - AddressFamily_name = map[uint32]string{ + AddressFamily_name = map[uint8]string{ 0: "ADDRESS_IP4", 1: "ADDRESS_IP6", } - AddressFamily_value = map[string]uint32{ + AddressFamily_value = map[string]uint8{ "ADDRESS_IP4": 0, "ADDRESS_IP6": 1, } ) func (x AddressFamily) String() string { - s, ok := AddressFamily_name[uint32(x)] + s, ok := AddressFamily_name[uint8(x)] if ok { return s } @@ -188,7 +188,7 @@ func (x IPEcn) String() string { } // IPProto represents VPP binary API enum 'ip_proto'. -type IPProto uint32 +type IPProto uint8 const ( IP_API_PROTO_HOPOPT IPProto = 0 @@ -197,8 +197,9 @@ const ( IP_API_PROTO_TCP IPProto = 6 IP_API_PROTO_UDP IPProto = 17 IP_API_PROTO_GRE IPProto = 47 - IP_API_PROTO_AH IPProto = 50 - IP_API_PROTO_ESP IPProto = 51 + IP_API_PROTO_ESP IPProto = 50 + IP_API_PROTO_AH IPProto = 51 + IP_API_PROTO_ICMP6 IPProto = 58 IP_API_PROTO_EIGRP IPProto = 88 IP_API_PROTO_OSPF IPProto = 89 IP_API_PROTO_SCTP IPProto = 132 @@ -206,29 +207,31 @@ const ( ) var ( - IPProto_name = map[uint32]string{ + IPProto_name = map[uint8]string{ 0: "IP_API_PROTO_HOPOPT", 1: "IP_API_PROTO_ICMP", 2: "IP_API_PROTO_IGMP", 6: "IP_API_PROTO_TCP", 17: "IP_API_PROTO_UDP", 47: "IP_API_PROTO_GRE", - 50: "IP_API_PROTO_AH", - 51: "IP_API_PROTO_ESP", + 50: "IP_API_PROTO_ESP", + 51: "IP_API_PROTO_AH", + 58: "IP_API_PROTO_ICMP6", 88: "IP_API_PROTO_EIGRP", 89: "IP_API_PROTO_OSPF", 132: "IP_API_PROTO_SCTP", 255: "IP_API_PROTO_RESERVED", } - IPProto_value = map[string]uint32{ + IPProto_value = map[string]uint8{ "IP_API_PROTO_HOPOPT": 0, "IP_API_PROTO_ICMP": 1, "IP_API_PROTO_IGMP": 2, "IP_API_PROTO_TCP": 6, "IP_API_PROTO_UDP": 17, "IP_API_PROTO_GRE": 47, - "IP_API_PROTO_AH": 50, - "IP_API_PROTO_ESP": 51, + "IP_API_PROTO_ESP": 50, + "IP_API_PROTO_AH": 51, + "IP_API_PROTO_ICMP6": 58, "IP_API_PROTO_EIGRP": 88, "IP_API_PROTO_OSPF": 89, "IP_API_PROTO_SCTP": 132, @@ -237,7 +240,7 @@ var ( ) func (x IPProto) String() string { - s, ok := IPProto_name[uint32(x)] + s, ok := IPProto_name[uint8(x)] if ok { return s } diff --git a/examples/binapi/memclnt/memclnt.ba.go b/examples/binapi/memclnt/memclnt.ba.go index c6b1256..d57cc6c 100644 --- a/examples/binapi/memclnt/memclnt.ba.go +++ b/examples/binapi/memclnt/memclnt.ba.go @@ -1,11 +1,11 @@ // Code generated by GoVPP's binapi-generator. DO NOT EDIT. // versions: -// binapi-generator: v0.4.0-alpha-1-g435c3f4-dirty -// VPP: 20.01-45~g7a071e370~b63 +// binapi-generator: v0.4.0-dev +// VPP: 20.05-release // source: /usr/share/vpp/api/core/memclnt.api.json /* -Package memclnt contains generated code for VPP binary API defined by memclnt.api (version 2.1.0). +Package memclnt contains generated code for VPP API file memclnt.api (2.1.0). It consists of: 22 messages diff --git a/examples/binapi/memif/memif.ba.go b/examples/binapi/memif/memif.ba.go index 60aadf3..4fe2f75 100644 --- a/examples/binapi/memif/memif.ba.go +++ b/examples/binapi/memif/memif.ba.go @@ -1,11 +1,11 @@ // Code generated by GoVPP's binapi-generator. DO NOT EDIT. // versions: -// binapi-generator: v0.4.0-alpha-1-g435c3f4-dirty -// VPP: 20.01-45~g7a071e370~b63 +// binapi-generator: v0.4.0-dev +// VPP: 20.05-release // source: /usr/share/vpp/api/plugins/memif.api.json /* -Package memif contains generated code for VPP binary API defined by memif.api (version 3.0.0). +Package memif contains generated code for VPP API file memif.api (3.0.0). It consists of: 2 aliases @@ -25,6 +25,8 @@ import ( api "git.fd.io/govpp.git/api" codec "git.fd.io/govpp.git/codec" struc "github.com/lunixbochs/struc" + + interface_types "git.fd.io/govpp.git/examples/binapi/interface_types" ) // This is a compile-time assertion to ensure that this generated file @@ -39,98 +41,14 @@ const ( // APIVersion is the API version of this module. APIVersion = "3.0.0" // VersionCrc is the CRC of this module. - VersionCrc = 0x88dc56c9 -) - -// IfStatusFlags represents VPP binary API enum 'if_status_flags'. -type IfStatusFlags uint32 - -const ( - IF_STATUS_API_FLAG_ADMIN_UP IfStatusFlags = 1 - IF_STATUS_API_FLAG_LINK_UP IfStatusFlags = 2 -) - -var ( - IfStatusFlags_name = map[uint32]string{ - 1: "IF_STATUS_API_FLAG_ADMIN_UP", - 2: "IF_STATUS_API_FLAG_LINK_UP", - } - IfStatusFlags_value = map[string]uint32{ - "IF_STATUS_API_FLAG_ADMIN_UP": 1, - "IF_STATUS_API_FLAG_LINK_UP": 2, - } -) - -func (x IfStatusFlags) String() string { - s, ok := IfStatusFlags_name[uint32(x)] - if ok { - return s - } - return "IfStatusFlags(" + strconv.Itoa(int(x)) + ")" -} - -// IfType represents VPP binary API enum 'if_type'. -type IfType uint32 - -const ( - IF_API_TYPE_HARDWARE IfType = 1 - IF_API_TYPE_SUB IfType = 2 - IF_API_TYPE_P2P IfType = 3 - IF_API_TYPE_PIPE IfType = 4 -) - -var ( - IfType_name = map[uint32]string{ - 1: "IF_API_TYPE_HARDWARE", - 2: "IF_API_TYPE_SUB", - 3: "IF_API_TYPE_P2P", - 4: "IF_API_TYPE_PIPE", - } - IfType_value = map[string]uint32{ - "IF_API_TYPE_HARDWARE": 1, - "IF_API_TYPE_SUB": 2, - "IF_API_TYPE_P2P": 3, - "IF_API_TYPE_PIPE": 4, - } + VersionCrc = 0x1a1c95b8 ) -func (x IfType) String() string { - s, ok := IfType_name[uint32(x)] - if ok { - return s - } - return "IfType(" + strconv.Itoa(int(x)) + ")" -} - -// LinkDuplex represents VPP binary API enum 'link_duplex'. -type LinkDuplex uint32 - -const ( - LINK_DUPLEX_API_UNKNOWN LinkDuplex = 0 - LINK_DUPLEX_API_HALF LinkDuplex = 1 - LINK_DUPLEX_API_FULL LinkDuplex = 2 -) +type IfStatusFlags = interface_types.IfStatusFlags -var ( - LinkDuplex_name = map[uint32]string{ - 0: "LINK_DUPLEX_API_UNKNOWN", - 1: "LINK_DUPLEX_API_HALF", - 2: "LINK_DUPLEX_API_FULL", - } - LinkDuplex_value = map[string]uint32{ - "LINK_DUPLEX_API_UNKNOWN": 0, - "LINK_DUPLEX_API_HALF": 1, - "LINK_DUPLEX_API_FULL": 2, - } -) +type IfType = interface_types.IfType -func (x LinkDuplex) String() string { - s, ok := LinkDuplex_name[uint32(x)] - if ok { - return s - } - return "LinkDuplex(" + strconv.Itoa(int(x)) + ")" -} +type LinkDuplex = interface_types.LinkDuplex // MemifMode represents VPP binary API enum 'memif_mode'. type MemifMode uint32 @@ -189,131 +107,13 @@ func (x MemifRole) String() string { return "MemifRole(" + strconv.Itoa(int(x)) + ")" } -// MtuProto represents VPP binary API enum 'mtu_proto'. -type MtuProto uint32 +type MtuProto = interface_types.MtuProto -const ( - MTU_PROTO_API_L3 MtuProto = 1 - MTU_PROTO_API_IP4 MtuProto = 2 - MTU_PROTO_API_IP6 MtuProto = 3 - MTU_PROTO_API_MPLS MtuProto = 4 - MTU_PROTO_API_N MtuProto = 5 -) - -var ( - MtuProto_name = map[uint32]string{ - 1: "MTU_PROTO_API_L3", - 2: "MTU_PROTO_API_IP4", - 3: "MTU_PROTO_API_IP6", - 4: "MTU_PROTO_API_MPLS", - 5: "MTU_PROTO_API_N", - } - MtuProto_value = map[string]uint32{ - "MTU_PROTO_API_L3": 1, - "MTU_PROTO_API_IP4": 2, - "MTU_PROTO_API_IP6": 3, - "MTU_PROTO_API_MPLS": 4, - "MTU_PROTO_API_N": 5, - } -) - -func (x MtuProto) String() string { - s, ok := MtuProto_name[uint32(x)] - if ok { - return s - } - return "MtuProto(" + strconv.Itoa(int(x)) + ")" -} - -// RxMode represents VPP binary API enum 'rx_mode'. -type RxMode uint32 - -const ( - RX_MODE_API_UNKNOWN RxMode = 0 - RX_MODE_API_POLLING RxMode = 1 - RX_MODE_API_INTERRUPT RxMode = 2 - RX_MODE_API_ADAPTIVE RxMode = 3 - RX_MODE_API_DEFAULT RxMode = 4 -) +type RxMode = interface_types.RxMode -var ( - RxMode_name = map[uint32]string{ - 0: "RX_MODE_API_UNKNOWN", - 1: "RX_MODE_API_POLLING", - 2: "RX_MODE_API_INTERRUPT", - 3: "RX_MODE_API_ADAPTIVE", - 4: "RX_MODE_API_DEFAULT", - } - RxMode_value = map[string]uint32{ - "RX_MODE_API_UNKNOWN": 0, - "RX_MODE_API_POLLING": 1, - "RX_MODE_API_INTERRUPT": 2, - "RX_MODE_API_ADAPTIVE": 3, - "RX_MODE_API_DEFAULT": 4, - } -) - -func (x RxMode) String() string { - s, ok := RxMode_name[uint32(x)] - if ok { - return s - } - return "RxMode(" + strconv.Itoa(int(x)) + ")" -} - -// SubIfFlags represents VPP binary API enum 'sub_if_flags'. -type SubIfFlags uint32 - -const ( - SUB_IF_API_FLAG_NO_TAGS SubIfFlags = 1 - SUB_IF_API_FLAG_ONE_TAG SubIfFlags = 2 - SUB_IF_API_FLAG_TWO_TAGS SubIfFlags = 4 - SUB_IF_API_FLAG_DOT1AD SubIfFlags = 8 - SUB_IF_API_FLAG_EXACT_MATCH SubIfFlags = 16 - SUB_IF_API_FLAG_DEFAULT SubIfFlags = 32 - SUB_IF_API_FLAG_OUTER_VLAN_ID_ANY SubIfFlags = 64 - SUB_IF_API_FLAG_INNER_VLAN_ID_ANY SubIfFlags = 128 - SUB_IF_API_FLAG_MASK_VNET SubIfFlags = 254 - SUB_IF_API_FLAG_DOT1AH SubIfFlags = 256 -) - -var ( - SubIfFlags_name = map[uint32]string{ - 1: "SUB_IF_API_FLAG_NO_TAGS", - 2: "SUB_IF_API_FLAG_ONE_TAG", - 4: "SUB_IF_API_FLAG_TWO_TAGS", - 8: "SUB_IF_API_FLAG_DOT1AD", - 16: "SUB_IF_API_FLAG_EXACT_MATCH", - 32: "SUB_IF_API_FLAG_DEFAULT", - 64: "SUB_IF_API_FLAG_OUTER_VLAN_ID_ANY", - 128: "SUB_IF_API_FLAG_INNER_VLAN_ID_ANY", - 254: "SUB_IF_API_FLAG_MASK_VNET", - 256: "SUB_IF_API_FLAG_DOT1AH", - } - SubIfFlags_value = map[string]uint32{ - "SUB_IF_API_FLAG_NO_TAGS": 1, - "SUB_IF_API_FLAG_ONE_TAG": 2, - "SUB_IF_API_FLAG_TWO_TAGS": 4, - "SUB_IF_API_FLAG_DOT1AD": 8, - "SUB_IF_API_FLAG_EXACT_MATCH": 16, - "SUB_IF_API_FLAG_DEFAULT": 32, - "SUB_IF_API_FLAG_OUTER_VLAN_ID_ANY": 64, - "SUB_IF_API_FLAG_INNER_VLAN_ID_ANY": 128, - "SUB_IF_API_FLAG_MASK_VNET": 254, - "SUB_IF_API_FLAG_DOT1AH": 256, - } -) - -func (x SubIfFlags) String() string { - s, ok := SubIfFlags_name[uint32(x)] - if ok { - return s - } - return "SubIfFlags(" + strconv.Itoa(int(x)) + ")" -} +type SubIfFlags = interface_types.SubIfFlags -// InterfaceIndex represents VPP binary API alias 'interface_index'. -type InterfaceIndex uint32 +type InterfaceIndex = interface_types.InterfaceIndex // MacAddress represents VPP binary API alias 'mac_address'. type MacAddress [6]uint8 diff --git a/examples/binapi/sr/sr.ba.go b/examples/binapi/sr/sr.ba.go index b870456..336cfe2 100644 --- a/examples/binapi/sr/sr.ba.go +++ b/examples/binapi/sr/sr.ba.go @@ -1,15 +1,18 @@ // Code generated by GoVPP's binapi-generator. DO NOT EDIT. // versions: -// binapi-generator: v0.4.0-alpha-1-g435c3f4-dirty -// VPP: 20.01-45~g7a071e370~b63 +// binapi-generator: v0.4.0-dev +// VPP: 20.05-release // source: /usr/share/vpp/api/core/sr.api.json /* -Package sr contains generated code for VPP binary API defined by sr.api (version 1.2.0). +Package sr contains generated code for VPP API file sr.api (2.0.0). It consists of: + 6 aliases + 13 enums 20 messages - 3 types + 7 types + 1 union */ package sr @@ -24,6 +27,9 @@ import ( api "git.fd.io/govpp.git/api" codec "git.fd.io/govpp.git/codec" struc "github.com/lunixbochs/struc" + + interface_types "git.fd.io/govpp.git/examples/binapi/interface_types" + ip_types "git.fd.io/govpp.git/examples/binapi/ip_types" ) // This is a compile-time assertion to ensure that this generated file @@ -36,50 +42,195 @@ const ( // ModuleName is the name of this module. ModuleName = "sr" // APIVersion is the API version of this module. - APIVersion = "1.2.0" + APIVersion = "2.0.0" // VersionCrc is the CRC of this module. - VersionCrc = 0xbf277f96 + VersionCrc = 0xd85c77ca +) + +type AddressFamily = ip_types.AddressFamily + +type IfStatusFlags = interface_types.IfStatusFlags + +type IfType = interface_types.IfType + +type IPDscp = ip_types.IPDscp + +type IPEcn = ip_types.IPEcn + +type IPProto = ip_types.IPProto + +type LinkDuplex = interface_types.LinkDuplex + +type MtuProto = interface_types.MtuProto + +type RxMode = interface_types.RxMode + +// SrBehavior represents VPP binary API enum 'sr_behavior'. +type SrBehavior uint8 + +const ( + SR_BEHAVIOR_API_END SrBehavior = 1 + SR_BEHAVIOR_API_X SrBehavior = 2 + SR_BEHAVIOR_API_T SrBehavior = 3 + SR_BEHAVIOR_API_D_FIRST SrBehavior = 4 + SR_BEHAVIOR_API_DX2 SrBehavior = 5 + SR_BEHAVIOR_API_DX6 SrBehavior = 6 + SR_BEHAVIOR_API_DX4 SrBehavior = 7 + SR_BEHAVIOR_API_DT6 SrBehavior = 8 + SR_BEHAVIOR_API_DT4 SrBehavior = 9 + SR_BEHAVIOR_API_LAST SrBehavior = 10 ) -// SrIP6Address represents VPP binary API type 'sr_ip6_address'. -type SrIP6Address struct { - Data []byte `binapi:"u8[16],name=data" json:"data,omitempty" struc:"[16]byte"` +var ( + SrBehavior_name = map[uint8]string{ + 1: "SR_BEHAVIOR_API_END", + 2: "SR_BEHAVIOR_API_X", + 3: "SR_BEHAVIOR_API_T", + 4: "SR_BEHAVIOR_API_D_FIRST", + 5: "SR_BEHAVIOR_API_DX2", + 6: "SR_BEHAVIOR_API_DX6", + 7: "SR_BEHAVIOR_API_DX4", + 8: "SR_BEHAVIOR_API_DT6", + 9: "SR_BEHAVIOR_API_DT4", + 10: "SR_BEHAVIOR_API_LAST", + } + SrBehavior_value = map[string]uint8{ + "SR_BEHAVIOR_API_END": 1, + "SR_BEHAVIOR_API_X": 2, + "SR_BEHAVIOR_API_T": 3, + "SR_BEHAVIOR_API_D_FIRST": 4, + "SR_BEHAVIOR_API_DX2": 5, + "SR_BEHAVIOR_API_DX6": 6, + "SR_BEHAVIOR_API_DX4": 7, + "SR_BEHAVIOR_API_DT6": 8, + "SR_BEHAVIOR_API_DT4": 9, + "SR_BEHAVIOR_API_LAST": 10, + } +) + +func (x SrBehavior) String() string { + s, ok := SrBehavior_name[uint8(x)] + if ok { + return s + } + return "SrBehavior(" + strconv.Itoa(int(x)) + ")" } -func (*SrIP6Address) GetTypeName() string { return "sr_ip6_address" } +// SrPolicyOp represents VPP binary API enum 'sr_policy_op'. +type SrPolicyOp uint8 -// Srv6Sid represents VPP binary API type 'srv6_sid'. -type Srv6Sid struct { - Addr []byte `binapi:"u8[16],name=addr" json:"addr,omitempty" struc:"[16]byte"` +const ( + SR_POLICY_OP_API_NONE SrPolicyOp = 0 + SR_POLICY_OP_API_ADD SrPolicyOp = 1 + SR_POLICY_OP_API_DEL SrPolicyOp = 2 + SR_POLICY_OP_API_MOD SrPolicyOp = 3 +) + +var ( + SrPolicyOp_name = map[uint8]string{ + 0: "SR_POLICY_OP_API_NONE", + 1: "SR_POLICY_OP_API_ADD", + 2: "SR_POLICY_OP_API_DEL", + 3: "SR_POLICY_OP_API_MOD", + } + SrPolicyOp_value = map[string]uint8{ + "SR_POLICY_OP_API_NONE": 0, + "SR_POLICY_OP_API_ADD": 1, + "SR_POLICY_OP_API_DEL": 2, + "SR_POLICY_OP_API_MOD": 3, + } +) + +func (x SrPolicyOp) String() string { + s, ok := SrPolicyOp_name[uint8(x)] + if ok { + return s + } + return "SrPolicyOp(" + strconv.Itoa(int(x)) + ")" } -func (*Srv6Sid) GetTypeName() string { return "srv6_sid" } +// SrSteer represents VPP binary API enum 'sr_steer'. +type SrSteer uint8 + +const ( + SR_STEER_API_L2 SrSteer = 2 + SR_STEER_API_IPV4 SrSteer = 4 + SR_STEER_API_IPV6 SrSteer = 6 +) + +var ( + SrSteer_name = map[uint8]string{ + 2: "SR_STEER_API_L2", + 4: "SR_STEER_API_IPV4", + 6: "SR_STEER_API_IPV6", + } + SrSteer_value = map[string]uint8{ + "SR_STEER_API_L2": 2, + "SR_STEER_API_IPV4": 4, + "SR_STEER_API_IPV6": 6, + } +) + +func (x SrSteer) String() string { + s, ok := SrSteer_name[uint8(x)] + if ok { + return s + } + return "SrSteer(" + strconv.Itoa(int(x)) + ")" +} + +type SubIfFlags = interface_types.SubIfFlags + +type AddressWithPrefix = ip_types.AddressWithPrefix + +type InterfaceIndex = interface_types.InterfaceIndex + +type IP4Address = ip_types.IP4Address + +type IP4AddressWithPrefix = ip_types.IP4AddressWithPrefix + +type IP6Address = ip_types.IP6Address + +type IP6AddressWithPrefix = ip_types.IP6AddressWithPrefix + +type Address = ip_types.Address + +type IP4Prefix = ip_types.IP4Prefix + +type IP6Prefix = ip_types.IP6Prefix + +type Mprefix = ip_types.Mprefix + +type Prefix = ip_types.Prefix + +type PrefixMatcher = ip_types.PrefixMatcher // Srv6SidList represents VPP binary API type 'srv6_sid_list'. type Srv6SidList struct { - NumSids uint8 `binapi:"u8,name=num_sids" json:"num_sids,omitempty"` - Weight uint32 `binapi:"u32,name=weight" json:"weight,omitempty"` - Sids [16]Srv6Sid `binapi:"srv6_sid[16],name=sids" json:"sids,omitempty" struc:"[16]Srv6Sid"` + NumSids uint8 `binapi:"u8,name=num_sids" json:"num_sids,omitempty"` + Weight uint32 `binapi:"u32,name=weight" json:"weight,omitempty"` + Sids [16]IP6Address `binapi:"ip6_address[16],name=sids" json:"sids,omitempty" struc:"[16]IP6Address"` } func (*Srv6SidList) GetTypeName() string { return "srv6_sid_list" } +type AddressUnion = ip_types.AddressUnion + // SrLocalsidAddDel represents VPP binary API message 'sr_localsid_add_del'. type SrLocalsidAddDel struct { - IsDel uint8 `binapi:"u8,name=is_del" json:"is_del,omitempty"` - Localsid Srv6Sid `binapi:"srv6_sid,name=localsid" json:"localsid,omitempty"` - EndPsp uint8 `binapi:"u8,name=end_psp" json:"end_psp,omitempty"` - Behavior uint8 `binapi:"u8,name=behavior" json:"behavior,omitempty"` - SwIfIndex uint32 `binapi:"u32,name=sw_if_index" json:"sw_if_index,omitempty"` - VlanIndex uint32 `binapi:"u32,name=vlan_index" json:"vlan_index,omitempty"` - FibTable uint32 `binapi:"u32,name=fib_table" json:"fib_table,omitempty"` - NhAddr6 []byte `binapi:"u8[16],name=nh_addr6" json:"nh_addr6,omitempty" struc:"[16]byte"` - NhAddr4 []byte `binapi:"u8[4],name=nh_addr4" json:"nh_addr4,omitempty" struc:"[4]byte"` + IsDel bool `binapi:"bool,name=is_del,default=false" json:"is_del,omitempty"` + Localsid IP6Address `binapi:"ip6_address,name=localsid" json:"localsid,omitempty"` + EndPsp bool `binapi:"bool,name=end_psp" json:"end_psp,omitempty"` + Behavior SrBehavior `binapi:"sr_behavior,name=behavior" json:"behavior,omitempty"` + SwIfIndex InterfaceIndex `binapi:"interface_index,name=sw_if_index,default=4294967295" json:"sw_if_index,omitempty"` + VlanIndex uint32 `binapi:"u32,name=vlan_index" json:"vlan_index,omitempty"` + FibTable uint32 `binapi:"u32,name=fib_table" json:"fib_table,omitempty"` + NhAddr Address `binapi:"address,name=nh_addr" json:"nh_addr,omitempty"` } func (m *SrLocalsidAddDel) Reset() { *m = SrLocalsidAddDel{} } func (*SrLocalsidAddDel) GetMessageName() string { return "sr_localsid_add_del" } -func (*SrLocalsidAddDel) GetCrcString() string { return "b30489eb" } +func (*SrLocalsidAddDel) GetCrcString() string { return "26fa3309" } func (*SrLocalsidAddDel) GetMessageType() api.MessageType { return api.RequestMessage } func (m *SrLocalsidAddDel) Size() int { @@ -90,7 +241,6 @@ func (m *SrLocalsidAddDel) Size() int { // field[1] m.IsDel size += 1 // field[1] m.Localsid - // field[2] m.Localsid.Addr size += 16 // field[1] m.EndPsp size += 1 @@ -102,10 +252,11 @@ func (m *SrLocalsidAddDel) Size() int { size += 4 // field[1] m.FibTable size += 4 - // field[1] m.NhAddr6 + // field[1] m.NhAddr + // field[2] m.NhAddr.Af + size += 1 + // field[2] m.NhAddr.Un size += 16 - // field[1] m.NhAddr4 - size += 4 return size } func (m *SrLocalsidAddDel) Marshal(b []byte) ([]byte, error) { @@ -120,20 +271,23 @@ func (m *SrLocalsidAddDel) Marshal(b []byte) ([]byte, error) { buf = b } // field[1] m.IsDel - buf[pos] = uint8(m.IsDel) + if m.IsDel { + buf[pos] = 1 + } pos += 1 // field[1] m.Localsid - // field[2] m.Localsid.Addr for i := 0; i < 16; i++ { var x uint8 - if i < len(m.Localsid.Addr) { - x = uint8(m.Localsid.Addr[i]) + if i < len(m.Localsid) { + x = uint8(m.Localsid[i]) } buf[pos] = uint8(x) pos += 1 } // field[1] m.EndPsp - buf[pos] = uint8(m.EndPsp) + if m.EndPsp { + buf[pos] = 1 + } pos += 1 // field[1] m.Behavior buf[pos] = uint8(m.Behavior) @@ -147,24 +301,13 @@ func (m *SrLocalsidAddDel) Marshal(b []byte) ([]byte, error) { // field[1] m.FibTable o.PutUint32(buf[pos:pos+4], uint32(m.FibTable)) pos += 4 - // field[1] m.NhAddr6 - for i := 0; i < 16; i++ { - var x uint8 - if i < len(m.NhAddr6) { - x = uint8(m.NhAddr6[i]) - } - buf[pos] = uint8(x) - pos += 1 - } - // field[1] m.NhAddr4 - for i := 0; i < 4; i++ { - var x uint8 - if i < len(m.NhAddr4) { - x = uint8(m.NhAddr4[i]) - } - buf[pos] = uint8(x) - pos += 1 - } + // field[1] m.NhAddr + // field[2] m.NhAddr.Af + buf[pos] = uint8(m.NhAddr.Af) + pos += 1 + // field[2] m.NhAddr.Un + copy(buf[pos:pos+16], m.NhAddr.Un.XXX_UnionData[:]) + pos += 16 return buf, nil } func (m *SrLocalsidAddDel) Unmarshal(tmp []byte) error { @@ -173,23 +316,21 @@ func (m *SrLocalsidAddDel) Unmarshal(tmp []byte) error { pos := 0 _ = pos // field[1] m.IsDel - m.IsDel = uint8(tmp[pos]) + m.IsDel = tmp[pos] != 0 pos += 1 // field[1] m.Localsid - // field[2] m.Localsid.Addr - m.Localsid.Addr = make([]uint8, 16) - for i := 0; i < len(m.Localsid.Addr); i++ { - m.Localsid.Addr[i] = uint8(tmp[pos]) + for i := 0; i < len(m.Localsid); i++ { + m.Localsid[i] = uint8(tmp[pos]) pos += 1 } // field[1] m.EndPsp - m.EndPsp = uint8(tmp[pos]) + m.EndPsp = tmp[pos] != 0 pos += 1 // field[1] m.Behavior - m.Behavior = uint8(tmp[pos]) + m.Behavior = SrBehavior(tmp[pos]) pos += 1 // field[1] m.SwIfIndex - m.SwIfIndex = uint32(o.Uint32(tmp[pos : pos+4])) + m.SwIfIndex = InterfaceIndex(o.Uint32(tmp[pos : pos+4])) pos += 4 // field[1] m.VlanIndex m.VlanIndex = uint32(o.Uint32(tmp[pos : pos+4])) @@ -197,18 +338,13 @@ func (m *SrLocalsidAddDel) Unmarshal(tmp []byte) error { // field[1] m.FibTable m.FibTable = uint32(o.Uint32(tmp[pos : pos+4])) pos += 4 - // field[1] m.NhAddr6 - m.NhAddr6 = make([]uint8, 16) - for i := 0; i < len(m.NhAddr6); i++ { - m.NhAddr6[i] = uint8(tmp[pos]) - pos += 1 - } - // field[1] m.NhAddr4 - m.NhAddr4 = make([]uint8, 4) - for i := 0; i < len(m.NhAddr4); i++ { - m.NhAddr4[i] = uint8(tmp[pos]) - pos += 1 - } + // field[1] m.NhAddr + // field[2] m.NhAddr.Af + m.NhAddr.Af = AddressFamily(tmp[pos]) + pos += 1 + // field[2] m.NhAddr.Un + copy(m.NhAddr.Un.XXX_UnionData[:], tmp[pos:pos+16]) + pos += 16 return nil } @@ -260,19 +396,18 @@ func (m *SrLocalsidAddDelReply) Unmarshal(tmp []byte) error { // SrLocalsidsDetails represents VPP binary API message 'sr_localsids_details'. type SrLocalsidsDetails struct { - Addr Srv6Sid `binapi:"srv6_sid,name=addr" json:"addr,omitempty"` - EndPsp uint8 `binapi:"u8,name=end_psp" json:"end_psp,omitempty"` - Behavior uint16 `binapi:"u16,name=behavior" json:"behavior,omitempty"` - FibTable uint32 `binapi:"u32,name=fib_table" json:"fib_table,omitempty"` - VlanIndex uint32 `binapi:"u32,name=vlan_index" json:"vlan_index,omitempty"` - XconnectNhAddr6 []byte `binapi:"u8[16],name=xconnect_nh_addr6" json:"xconnect_nh_addr6,omitempty" struc:"[16]byte"` - XconnectNhAddr4 []byte `binapi:"u8[4],name=xconnect_nh_addr4" json:"xconnect_nh_addr4,omitempty" struc:"[4]byte"` - XconnectIfaceOrVrfTable uint32 `binapi:"u32,name=xconnect_iface_or_vrf_table" json:"xconnect_iface_or_vrf_table,omitempty"` + Addr IP6Address `binapi:"ip6_address,name=addr" json:"addr,omitempty"` + EndPsp bool `binapi:"bool,name=end_psp" json:"end_psp,omitempty"` + Behavior SrBehavior `binapi:"sr_behavior,name=behavior" json:"behavior,omitempty"` + FibTable uint32 `binapi:"u32,name=fib_table" json:"fib_table,omitempty"` + VlanIndex uint32 `binapi:"u32,name=vlan_index" json:"vlan_index,omitempty"` + XconnectNhAddr Address `binapi:"address,name=xconnect_nh_addr" json:"xconnect_nh_addr,omitempty"` + XconnectIfaceOrVrfTable uint32 `binapi:"u32,name=xconnect_iface_or_vrf_table" json:"xconnect_iface_or_vrf_table,omitempty"` } func (m *SrLocalsidsDetails) Reset() { *m = SrLocalsidsDetails{} } func (*SrLocalsidsDetails) GetMessageName() string { return "sr_localsids_details" } -func (*SrLocalsidsDetails) GetCrcString() string { return "0791babc" } +func (*SrLocalsidsDetails) GetCrcString() string { return "6a6c0265" } func (*SrLocalsidsDetails) GetMessageType() api.MessageType { return api.ReplyMessage } func (m *SrLocalsidsDetails) Size() int { @@ -281,20 +416,20 @@ func (m *SrLocalsidsDetails) Size() int { } var size int // field[1] m.Addr - // field[2] m.Addr.Addr size += 16 // field[1] m.EndPsp size += 1 // field[1] m.Behavior - size += 2 + size += 1 // field[1] m.FibTable size += 4 // field[1] m.VlanIndex size += 4 - // field[1] m.XconnectNhAddr6 + // field[1] m.XconnectNhAddr + // field[2] m.XconnectNhAddr.Af + size += 1 + // field[2] m.XconnectNhAddr.Un size += 16 - // field[1] m.XconnectNhAddr4 - size += 4 // field[1] m.XconnectIfaceOrVrfTable size += 4 return size @@ -311,45 +446,35 @@ func (m *SrLocalsidsDetails) Marshal(b []byte) ([]byte, error) { 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]) + if i < len(m.Addr) { + x = uint8(m.Addr[i]) } buf[pos] = uint8(x) pos += 1 } // field[1] m.EndPsp - buf[pos] = uint8(m.EndPsp) + if m.EndPsp { + buf[pos] = 1 + } pos += 1 // field[1] m.Behavior - o.PutUint16(buf[pos:pos+2], uint16(m.Behavior)) - pos += 2 + buf[pos] = uint8(m.Behavior) + pos += 1 // 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.XconnectNhAddr + // field[2] m.XconnectNhAddr.Af + buf[pos] = uint8(m.XconnectNhAddr.Af) + pos += 1 + // field[2] m.XconnectNhAddr.Un + copy(buf[pos:pos+16], m.XconnectNhAddr.Un.XXX_UnionData[:]) + pos += 16 // field[1] m.XconnectIfaceOrVrfTable o.PutUint32(buf[pos:pos+4], uint32(m.XconnectIfaceOrVrfTable)) pos += 4 @@ -361,36 +486,29 @@ func (m *SrLocalsidsDetails) Unmarshal(tmp []byte) error { 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]) + for i := 0; i < len(m.Addr); i++ { + m.Addr[i] = uint8(tmp[pos]) pos += 1 } // field[1] m.EndPsp - m.EndPsp = uint8(tmp[pos]) + m.EndPsp = tmp[pos] != 0 pos += 1 // field[1] m.Behavior - m.Behavior = uint16(o.Uint16(tmp[pos : pos+2])) - pos += 2 + m.Behavior = SrBehavior(tmp[pos]) + pos += 1 // 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.XconnectNhAddr + // field[2] m.XconnectNhAddr.Af + m.XconnectNhAddr.Af = AddressFamily(tmp[pos]) + pos += 1 + // field[2] m.XconnectNhAddr.Un + copy(m.XconnectNhAddr.Un.XXX_UnionData[:], tmp[pos:pos+16]) + pos += 16 // field[1] m.XconnectIfaceOrVrfTable m.XconnectIfaceOrVrfTable = uint32(o.Uint32(tmp[pos : pos+4])) pos += 4 @@ -435,9 +553,9 @@ func (m *SrLocalsidsDump) Unmarshal(tmp []byte) error { // SrPoliciesDetails represents VPP binary API message 'sr_policies_details'. type SrPoliciesDetails struct { - Bsid Srv6Sid `binapi:"srv6_sid,name=bsid" json:"bsid,omitempty"` - Type uint8 `binapi:"u8,name=type" json:"type,omitempty"` - IsEncap uint8 `binapi:"u8,name=is_encap" json:"is_encap,omitempty"` + Bsid IP6Address `binapi:"ip6_address,name=bsid" json:"bsid,omitempty"` + IsSpray bool `binapi:"bool,name=is_spray" json:"is_spray,omitempty"` + IsEncap bool `binapi:"bool,name=is_encap" json:"is_encap,omitempty"` FibTable uint32 `binapi:"u32,name=fib_table" json:"fib_table,omitempty"` NumSidLists uint8 `binapi:"u8,name=num_sid_lists" json:"num_sid_lists,omitempty" struc:"sizeof=SidLists"` SidLists []Srv6SidList `binapi:"srv6_sid_list[num_sid_lists],name=sid_lists" json:"sid_lists,omitempty"` @@ -445,7 +563,7 @@ type SrPoliciesDetails struct { func (m *SrPoliciesDetails) Reset() { *m = SrPoliciesDetails{} } func (*SrPoliciesDetails) GetMessageName() string { return "sr_policies_details" } -func (*SrPoliciesDetails) GetCrcString() string { return "5087f460" } +func (*SrPoliciesDetails) GetCrcString() string { return "07ec2d93" } func (*SrPoliciesDetails) GetMessageType() api.MessageType { return api.ReplyMessage } func (m *SrPoliciesDetails) Size() int { @@ -454,9 +572,8 @@ func (m *SrPoliciesDetails) Size() int { } var size int // field[1] m.Bsid - // field[2] m.Bsid.Addr size += 16 - // field[1] m.Type + // field[1] m.IsSpray size += 1 // field[1] m.IsEncap size += 1 @@ -477,12 +594,11 @@ func (m *SrPoliciesDetails) Size() int { size += 4 // field[2] s1.Sids for j2 := 0; j2 < 16; j2++ { - var s2 Srv6Sid + var s2 IP6Address _ = s2 if j2 < len(s1.Sids) { s2 = s1.Sids[j2] } - // field[3] s2.Addr size += 16 } } @@ -500,20 +616,23 @@ func (m *SrPoliciesDetails) Marshal(b []byte) ([]byte, error) { buf = b } // field[1] m.Bsid - // field[2] m.Bsid.Addr for i := 0; i < 16; i++ { var x uint8 - if i < len(m.Bsid.Addr) { - x = uint8(m.Bsid.Addr[i]) + if i < len(m.Bsid) { + x = uint8(m.Bsid[i]) } buf[pos] = uint8(x) pos += 1 } - // field[1] m.Type - buf[pos] = uint8(m.Type) + // field[1] m.IsSpray + if m.IsSpray { + buf[pos] = 1 + } pos += 1 // field[1] m.IsEncap - buf[pos] = uint8(m.IsEncap) + if m.IsEncap { + buf[pos] = 1 + } pos += 1 // field[1] m.FibTable o.PutUint32(buf[pos:pos+4], uint32(m.FibTable)) @@ -535,15 +654,14 @@ func (m *SrPoliciesDetails) Marshal(b []byte) ([]byte, error) { pos += 4 // field[2] v1.Sids for j2 := 0; j2 < 16; j2++ { - var v2 Srv6Sid + var v2 IP6Address if j2 < len(v1.Sids) { v2 = v1.Sids[j2] } - // field[3] v2.Addr for i := 0; i < 16; i++ { var x uint8 - if i < len(v2.Addr) { - x = uint8(v2.Addr[i]) + if i < len(v2) { + x = uint8(v2[i]) } buf[pos] = uint8(x) pos += 1 @@ -558,17 +676,15 @@ func (m *SrPoliciesDetails) Unmarshal(tmp []byte) error { pos := 0 _ = pos // field[1] m.Bsid - // field[2] m.Bsid.Addr - m.Bsid.Addr = make([]uint8, 16) - for i := 0; i < len(m.Bsid.Addr); i++ { - m.Bsid.Addr[i] = uint8(tmp[pos]) + for i := 0; i < len(m.Bsid); i++ { + m.Bsid[i] = uint8(tmp[pos]) pos += 1 } - // field[1] m.Type - m.Type = uint8(tmp[pos]) + // field[1] m.IsSpray + m.IsSpray = tmp[pos] != 0 pos += 1 // field[1] m.IsEncap - m.IsEncap = uint8(tmp[pos]) + m.IsEncap = tmp[pos] != 0 pos += 1 // field[1] m.FibTable m.FibTable = uint32(o.Uint32(tmp[pos : pos+4])) @@ -587,10 +703,8 @@ func (m *SrPoliciesDetails) Unmarshal(tmp []byte) error { pos += 4 // field[2] m.SidLists[j1].Sids for j2 := 0; j2 < 16; j2++ { - // field[3] m.SidLists[j1].Sids[j2].Addr - m.SidLists[j1].Sids[j2].Addr = make([]uint8, 16) - for i := 0; i < len(m.SidLists[j1].Sids[j2].Addr); i++ { - m.SidLists[j1].Sids[j2].Addr[i] = uint8(tmp[pos]) + for i := 0; i < len(m.SidLists[j1].Sids[j2]); i++ { + m.SidLists[j1].Sids[j2][i] = uint8(tmp[pos]) pos += 1 } } @@ -636,17 +750,17 @@ func (m *SrPoliciesDump) Unmarshal(tmp []byte) error { // SrPolicyAdd represents VPP binary API message 'sr_policy_add'. type SrPolicyAdd struct { - BsidAddr []byte `binapi:"u8[16],name=bsid_addr" json:"bsid_addr,omitempty" struc:"[16]byte"` + BsidAddr IP6Address `binapi:"ip6_address,name=bsid_addr" json:"bsid_addr,omitempty"` Weight uint32 `binapi:"u32,name=weight" json:"weight,omitempty"` - IsEncap uint8 `binapi:"u8,name=is_encap" json:"is_encap,omitempty"` - Type uint8 `binapi:"u8,name=type" json:"type,omitempty"` + IsEncap bool `binapi:"bool,name=is_encap" json:"is_encap,omitempty"` + IsSpray bool `binapi:"bool,name=is_spray" json:"is_spray,omitempty"` FibTable uint32 `binapi:"u32,name=fib_table" json:"fib_table,omitempty"` Sids Srv6SidList `binapi:"srv6_sid_list,name=sids" json:"sids,omitempty"` } func (m *SrPolicyAdd) Reset() { *m = SrPolicyAdd{} } func (*SrPolicyAdd) GetMessageName() string { return "sr_policy_add" } -func (*SrPolicyAdd) GetCrcString() string { return "4b6e2484" } +func (*SrPolicyAdd) GetCrcString() string { return "ec79ee6a" } func (*SrPolicyAdd) GetMessageType() api.MessageType { return api.RequestMessage } func (m *SrPolicyAdd) Size() int { @@ -660,7 +774,7 @@ func (m *SrPolicyAdd) Size() int { size += 4 // field[1] m.IsEncap size += 1 - // field[1] m.Type + // field[1] m.IsSpray size += 1 // field[1] m.FibTable size += 4 @@ -671,12 +785,11 @@ func (m *SrPolicyAdd) Size() int { size += 4 // field[2] m.Sids.Sids for j2 := 0; j2 < 16; j2++ { - var s2 Srv6Sid + var s2 IP6Address _ = s2 if j2 < len(m.Sids.Sids) { s2 = m.Sids.Sids[j2] } - // field[3] s2.Addr size += 16 } return size @@ -705,10 +818,14 @@ func (m *SrPolicyAdd) Marshal(b []byte) ([]byte, error) { o.PutUint32(buf[pos:pos+4], uint32(m.Weight)) pos += 4 // field[1] m.IsEncap - buf[pos] = uint8(m.IsEncap) + if m.IsEncap { + buf[pos] = 1 + } pos += 1 - // field[1] m.Type - buf[pos] = uint8(m.Type) + // field[1] m.IsSpray + if m.IsSpray { + buf[pos] = 1 + } pos += 1 // field[1] m.FibTable o.PutUint32(buf[pos:pos+4], uint32(m.FibTable)) @@ -722,15 +839,14 @@ func (m *SrPolicyAdd) Marshal(b []byte) ([]byte, error) { pos += 4 // field[2] m.Sids.Sids for j2 := 0; j2 < 16; j2++ { - var v2 Srv6Sid + var v2 IP6Address if j2 < len(m.Sids.Sids) { v2 = m.Sids.Sids[j2] } - // field[3] v2.Addr for i := 0; i < 16; i++ { var x uint8 - if i < len(v2.Addr) { - x = uint8(v2.Addr[i]) + if i < len(v2) { + x = uint8(v2[i]) } buf[pos] = uint8(x) pos += 1 @@ -744,7 +860,6 @@ func (m *SrPolicyAdd) Unmarshal(tmp []byte) error { pos := 0 _ = pos // field[1] m.BsidAddr - m.BsidAddr = make([]uint8, 16) for i := 0; i < len(m.BsidAddr); i++ { m.BsidAddr[i] = uint8(tmp[pos]) pos += 1 @@ -753,10 +868,10 @@ func (m *SrPolicyAdd) Unmarshal(tmp []byte) error { m.Weight = uint32(o.Uint32(tmp[pos : pos+4])) pos += 4 // field[1] m.IsEncap - m.IsEncap = uint8(tmp[pos]) + m.IsEncap = tmp[pos] != 0 pos += 1 - // field[1] m.Type - m.Type = uint8(tmp[pos]) + // field[1] m.IsSpray + m.IsSpray = tmp[pos] != 0 pos += 1 // field[1] m.FibTable m.FibTable = uint32(o.Uint32(tmp[pos : pos+4])) @@ -770,10 +885,8 @@ func (m *SrPolicyAdd) Unmarshal(tmp []byte) error { pos += 4 // field[2] m.Sids.Sids for j2 := 0; j2 < 16; j2++ { - // field[3] m.Sids.Sids[j2].Addr - m.Sids.Sids[j2].Addr = make([]uint8, 16) - for i := 0; i < len(m.Sids.Sids[j2].Addr); i++ { - m.Sids.Sids[j2].Addr[i] = uint8(tmp[pos]) + for i := 0; i < len(m.Sids.Sids[j2]); i++ { + m.Sids.Sids[j2][i] = uint8(tmp[pos]) pos += 1 } } @@ -828,13 +941,13 @@ func (m *SrPolicyAddReply) Unmarshal(tmp []byte) error { // SrPolicyDel represents VPP binary API message 'sr_policy_del'. type SrPolicyDel struct { - BsidAddr Srv6Sid `binapi:"srv6_sid,name=bsid_addr" json:"bsid_addr,omitempty"` - SrPolicyIndex uint32 `binapi:"u32,name=sr_policy_index" json:"sr_policy_index,omitempty"` + BsidAddr IP6Address `binapi:"ip6_address,name=bsid_addr" json:"bsid_addr,omitempty"` + SrPolicyIndex uint32 `binapi:"u32,name=sr_policy_index" json:"sr_policy_index,omitempty"` } func (m *SrPolicyDel) Reset() { *m = SrPolicyDel{} } func (*SrPolicyDel) GetMessageName() string { return "sr_policy_del" } -func (*SrPolicyDel) GetCrcString() string { return "e4133171" } +func (*SrPolicyDel) GetCrcString() string { return "cb4d48d5" } func (*SrPolicyDel) GetMessageType() api.MessageType { return api.RequestMessage } func (m *SrPolicyDel) Size() int { @@ -843,7 +956,6 @@ func (m *SrPolicyDel) Size() int { } var size int // field[1] m.BsidAddr - // field[2] m.BsidAddr.Addr size += 16 // field[1] m.SrPolicyIndex size += 4 @@ -861,11 +973,10 @@ func (m *SrPolicyDel) Marshal(b []byte) ([]byte, error) { buf = b } // field[1] m.BsidAddr - // field[2] m.BsidAddr.Addr for i := 0; i < 16; i++ { var x uint8 - if i < len(m.BsidAddr.Addr) { - x = uint8(m.BsidAddr.Addr[i]) + if i < len(m.BsidAddr) { + x = uint8(m.BsidAddr[i]) } buf[pos] = uint8(x) pos += 1 @@ -881,10 +992,8 @@ func (m *SrPolicyDel) Unmarshal(tmp []byte) error { pos := 0 _ = pos // field[1] m.BsidAddr - // field[2] m.BsidAddr.Addr - m.BsidAddr.Addr = make([]uint8, 16) - for i := 0; i < len(m.BsidAddr.Addr); i++ { - m.BsidAddr.Addr[i] = uint8(tmp[pos]) + for i := 0; i < len(m.BsidAddr); i++ { + m.BsidAddr[i] = uint8(tmp[pos]) pos += 1 } // field[1] m.SrPolicyIndex @@ -941,10 +1050,10 @@ func (m *SrPolicyDelReply) Unmarshal(tmp []byte) error { // SrPolicyMod represents VPP binary API message 'sr_policy_mod'. type SrPolicyMod struct { - BsidAddr []byte `binapi:"u8[16],name=bsid_addr" json:"bsid_addr,omitempty" struc:"[16]byte"` + BsidAddr IP6Address `binapi:"ip6_address,name=bsid_addr" json:"bsid_addr,omitempty"` SrPolicyIndex uint32 `binapi:"u32,name=sr_policy_index" json:"sr_policy_index,omitempty"` FibTable uint32 `binapi:"u32,name=fib_table" json:"fib_table,omitempty"` - Operation uint8 `binapi:"u8,name=operation" json:"operation,omitempty"` + Operation SrPolicyOp `binapi:"sr_policy_op,name=operation" json:"operation,omitempty"` SlIndex uint32 `binapi:"u32,name=sl_index" json:"sl_index,omitempty"` Weight uint32 `binapi:"u32,name=weight" json:"weight,omitempty"` Sids Srv6SidList `binapi:"srv6_sid_list,name=sids" json:"sids,omitempty"` @@ -952,7 +1061,7 @@ type SrPolicyMod struct { func (m *SrPolicyMod) Reset() { *m = SrPolicyMod{} } func (*SrPolicyMod) GetMessageName() string { return "sr_policy_mod" } -func (*SrPolicyMod) GetCrcString() string { return "c1dfaee0" } +func (*SrPolicyMod) GetCrcString() string { return "e531a102" } func (*SrPolicyMod) GetMessageType() api.MessageType { return api.RequestMessage } func (m *SrPolicyMod) Size() int { @@ -979,12 +1088,11 @@ func (m *SrPolicyMod) Size() int { size += 4 // field[2] m.Sids.Sids for j2 := 0; j2 < 16; j2++ { - var s2 Srv6Sid + var s2 IP6Address _ = s2 if j2 < len(m.Sids.Sids) { s2 = m.Sids.Sids[j2] } - // field[3] s2.Addr size += 16 } return size @@ -1033,15 +1141,14 @@ func (m *SrPolicyMod) Marshal(b []byte) ([]byte, error) { pos += 4 // field[2] m.Sids.Sids for j2 := 0; j2 < 16; j2++ { - var v2 Srv6Sid + var v2 IP6Address if j2 < len(m.Sids.Sids) { v2 = m.Sids.Sids[j2] } - // field[3] v2.Addr for i := 0; i < 16; i++ { var x uint8 - if i < len(v2.Addr) { - x = uint8(v2.Addr[i]) + if i < len(v2) { + x = uint8(v2[i]) } buf[pos] = uint8(x) pos += 1 @@ -1055,7 +1162,6 @@ func (m *SrPolicyMod) Unmarshal(tmp []byte) error { pos := 0 _ = pos // field[1] m.BsidAddr - m.BsidAddr = make([]uint8, 16) for i := 0; i < len(m.BsidAddr); i++ { m.BsidAddr[i] = uint8(tmp[pos]) pos += 1 @@ -1067,7 +1173,7 @@ func (m *SrPolicyMod) Unmarshal(tmp []byte) error { m.FibTable = uint32(o.Uint32(tmp[pos : pos+4])) pos += 4 // field[1] m.Operation - m.Operation = uint8(tmp[pos]) + m.Operation = SrPolicyOp(tmp[pos]) pos += 1 // field[1] m.SlIndex m.SlIndex = uint32(o.Uint32(tmp[pos : pos+4])) @@ -1084,10 +1190,8 @@ func (m *SrPolicyMod) Unmarshal(tmp []byte) error { pos += 4 // field[2] m.Sids.Sids for j2 := 0; j2 < 16; j2++ { - // field[3] m.Sids.Sids[j2].Addr - m.Sids.Sids[j2].Addr = make([]uint8, 16) - for i := 0; i < len(m.Sids.Sids[j2].Addr); i++ { - m.Sids.Sids[j2].Addr[i] = uint8(tmp[pos]) + for i := 0; i < len(m.Sids.Sids[j2]); i++ { + m.Sids.Sids[j2][i] = uint8(tmp[pos]) pos += 1 } } @@ -1234,12 +1338,12 @@ func (m *SrSetEncapHopLimitReply) Unmarshal(tmp []byte) error { // SrSetEncapSource represents VPP binary API message 'sr_set_encap_source'. type SrSetEncapSource struct { - EncapsSource []byte `binapi:"u8[16],name=encaps_source" json:"encaps_source,omitempty" struc:"[16]byte"` + EncapsSource IP6Address `binapi:"ip6_address,name=encaps_source" json:"encaps_source,omitempty"` } func (m *SrSetEncapSource) Reset() { *m = SrSetEncapSource{} } func (*SrSetEncapSource) GetMessageName() string { return "sr_set_encap_source" } -func (*SrSetEncapSource) GetCrcString() string { return "d05bb4de" } +func (*SrSetEncapSource) GetCrcString() string { return "d3bad5e1" } func (*SrSetEncapSource) GetMessageType() api.MessageType { return api.RequestMessage } func (m *SrSetEncapSource) Size() int { @@ -1279,7 +1383,6 @@ func (m *SrSetEncapSource) Unmarshal(tmp []byte) error { pos := 0 _ = pos // field[1] m.EncapsSource - m.EncapsSource = make([]uint8, 16) for i := 0; i < len(m.EncapsSource); i++ { m.EncapsSource[i] = uint8(tmp[pos]) pos += 1 @@ -1335,19 +1438,18 @@ func (m *SrSetEncapSourceReply) Unmarshal(tmp []byte) error { // SrSteeringAddDel represents VPP binary API message 'sr_steering_add_del'. type SrSteeringAddDel struct { - IsDel uint8 `binapi:"u8,name=is_del" json:"is_del,omitempty"` - BsidAddr []byte `binapi:"u8[16],name=bsid_addr" json:"bsid_addr,omitempty" struc:"[16]byte"` - SrPolicyIndex uint32 `binapi:"u32,name=sr_policy_index" json:"sr_policy_index,omitempty"` - TableID uint32 `binapi:"u32,name=table_id" json:"table_id,omitempty"` - PrefixAddr []byte `binapi:"u8[16],name=prefix_addr" json:"prefix_addr,omitempty" struc:"[16]byte"` - MaskWidth uint32 `binapi:"u32,name=mask_width" json:"mask_width,omitempty"` - SwIfIndex uint32 `binapi:"u32,name=sw_if_index" json:"sw_if_index,omitempty"` - TrafficType uint8 `binapi:"u8,name=traffic_type" json:"traffic_type,omitempty"` + IsDel bool `binapi:"bool,name=is_del,default=false" json:"is_del,omitempty"` + BsidAddr IP6Address `binapi:"ip6_address,name=bsid_addr" json:"bsid_addr,omitempty"` + SrPolicyIndex uint32 `binapi:"u32,name=sr_policy_index" json:"sr_policy_index,omitempty"` + TableID uint32 `binapi:"u32,name=table_id" json:"table_id,omitempty"` + Prefix Prefix `binapi:"prefix,name=prefix" json:"prefix,omitempty"` + SwIfIndex InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + TrafficType SrSteer `binapi:"sr_steer,name=traffic_type" json:"traffic_type,omitempty"` } func (m *SrSteeringAddDel) Reset() { *m = SrSteeringAddDel{} } func (*SrSteeringAddDel) GetMessageName() string { return "sr_steering_add_del" } -func (*SrSteeringAddDel) GetCrcString() string { return "28b5dcab" } +func (*SrSteeringAddDel) GetCrcString() string { return "3711dace" } func (*SrSteeringAddDel) GetMessageType() api.MessageType { return api.RequestMessage } func (m *SrSteeringAddDel) Size() int { @@ -1363,10 +1465,14 @@ func (m *SrSteeringAddDel) Size() int { size += 4 // field[1] m.TableID size += 4 - // field[1] m.PrefixAddr + // field[1] m.Prefix + // field[2] m.Prefix.Address + // field[3] m.Prefix.Address.Af + size += 1 + // field[3] m.Prefix.Address.Un size += 16 - // field[1] m.MaskWidth - size += 4 + // field[2] m.Prefix.Len + size += 1 // field[1] m.SwIfIndex size += 4 // field[1] m.TrafficType @@ -1385,7 +1491,9 @@ func (m *SrSteeringAddDel) Marshal(b []byte) ([]byte, error) { buf = b } // field[1] m.IsDel - buf[pos] = uint8(m.IsDel) + if m.IsDel { + buf[pos] = 1 + } pos += 1 // field[1] m.BsidAddr for i := 0; i < 16; i++ { @@ -1402,18 +1510,17 @@ func (m *SrSteeringAddDel) Marshal(b []byte) ([]byte, error) { // field[1] m.TableID o.PutUint32(buf[pos:pos+4], uint32(m.TableID)) pos += 4 - // field[1] m.PrefixAddr - for i := 0; i < 16; i++ { - var x uint8 - if i < len(m.PrefixAddr) { - x = uint8(m.PrefixAddr[i]) - } - buf[pos] = uint8(x) - pos += 1 - } - // field[1] m.MaskWidth - o.PutUint32(buf[pos:pos+4], uint32(m.MaskWidth)) - pos += 4 + // field[1] m.Prefix + // field[2] m.Prefix.Address + // field[3] m.Prefix.Address.Af + buf[pos] = uint8(m.Prefix.Address.Af) + pos += 1 + // field[3] m.Prefix.Address.Un + copy(buf[pos:pos+16], m.Prefix.Address.Un.XXX_UnionData[:]) + pos += 16 + // field[2] m.Prefix.Len + buf[pos] = uint8(m.Prefix.Len) + pos += 1 // field[1] m.SwIfIndex o.PutUint32(buf[pos:pos+4], uint32(m.SwIfIndex)) pos += 4 @@ -1428,10 +1535,9 @@ func (m *SrSteeringAddDel) Unmarshal(tmp []byte) error { pos := 0 _ = pos // field[1] m.IsDel - m.IsDel = uint8(tmp[pos]) + m.IsDel = tmp[pos] != 0 pos += 1 // field[1] m.BsidAddr - m.BsidAddr = make([]uint8, 16) for i := 0; i < len(m.BsidAddr); i++ { m.BsidAddr[i] = uint8(tmp[pos]) pos += 1 @@ -1442,20 +1548,22 @@ func (m *SrSteeringAddDel) Unmarshal(tmp []byte) error { // field[1] m.TableID m.TableID = uint32(o.Uint32(tmp[pos : pos+4])) pos += 4 - // field[1] m.PrefixAddr - m.PrefixAddr = make([]uint8, 16) - for i := 0; i < len(m.PrefixAddr); i++ { - m.PrefixAddr[i] = uint8(tmp[pos]) - pos += 1 - } - // field[1] m.MaskWidth - m.MaskWidth = uint32(o.Uint32(tmp[pos : pos+4])) - pos += 4 + // field[1] m.Prefix + // field[2] m.Prefix.Address + // field[3] m.Prefix.Address.Af + m.Prefix.Address.Af = AddressFamily(tmp[pos]) + pos += 1 + // field[3] m.Prefix.Address.Un + copy(m.Prefix.Address.Un.XXX_UnionData[:], tmp[pos:pos+16]) + pos += 16 + // field[2] m.Prefix.Len + m.Prefix.Len = uint8(tmp[pos]) + pos += 1 // field[1] m.SwIfIndex - m.SwIfIndex = uint32(o.Uint32(tmp[pos : pos+4])) + m.SwIfIndex = InterfaceIndex(o.Uint32(tmp[pos : pos+4])) pos += 4 // field[1] m.TrafficType - m.TrafficType = uint8(tmp[pos]) + m.TrafficType = SrSteer(tmp[pos]) pos += 1 return nil } @@ -1508,17 +1616,16 @@ func (m *SrSteeringAddDelReply) Unmarshal(tmp []byte) error { // SrSteeringPolDetails represents VPP binary API message 'sr_steering_pol_details'. type SrSteeringPolDetails struct { - TrafficType uint8 `binapi:"u8,name=traffic_type" json:"traffic_type,omitempty"` - FibTable uint32 `binapi:"u32,name=fib_table" json:"fib_table,omitempty"` - PrefixAddr []byte `binapi:"u8[16],name=prefix_addr" json:"prefix_addr,omitempty" struc:"[16]byte"` - MaskWidth uint32 `binapi:"u32,name=mask_width" json:"mask_width,omitempty"` - SwIfIndex uint32 `binapi:"u32,name=sw_if_index" json:"sw_if_index,omitempty"` - Bsid Srv6Sid `binapi:"srv6_sid,name=bsid" json:"bsid,omitempty"` + TrafficType SrSteer `binapi:"sr_steer,name=traffic_type" json:"traffic_type,omitempty"` + FibTable uint32 `binapi:"u32,name=fib_table" json:"fib_table,omitempty"` + Prefix Prefix `binapi:"prefix,name=prefix" json:"prefix,omitempty"` + SwIfIndex InterfaceIndex `binapi:"interface_index,name=sw_if_index" json:"sw_if_index,omitempty"` + Bsid IP6Address `binapi:"ip6_address,name=bsid" json:"bsid,omitempty"` } func (m *SrSteeringPolDetails) Reset() { *m = SrSteeringPolDetails{} } func (*SrSteeringPolDetails) GetMessageName() string { return "sr_steering_pol_details" } -func (*SrSteeringPolDetails) GetCrcString() string { return "5627d483" } +func (*SrSteeringPolDetails) GetCrcString() string { return "1c1ee786" } func (*SrSteeringPolDetails) GetMessageType() api.MessageType { return api.ReplyMessage } func (m *SrSteeringPolDetails) Size() int { @@ -1530,14 +1637,17 @@ func (m *SrSteeringPolDetails) Size() int { size += 1 // field[1] m.FibTable size += 4 - // field[1] m.PrefixAddr + // field[1] m.Prefix + // field[2] m.Prefix.Address + // field[3] m.Prefix.Address.Af + size += 1 + // field[3] m.Prefix.Address.Un size += 16 - // field[1] m.MaskWidth - size += 4 + // field[2] m.Prefix.Len + size += 1 // field[1] m.SwIfIndex size += 4 // field[1] m.Bsid - // field[2] m.Bsid.Addr size += 16 return size } @@ -1558,27 +1668,25 @@ func (m *SrSteeringPolDetails) Marshal(b []byte) ([]byte, error) { // field[1] m.FibTable o.PutUint32(buf[pos:pos+4], uint32(m.FibTable)) pos += 4 - // field[1] m.PrefixAddr - for i := 0; i < 16; i++ { - var x uint8 - if i < len(m.PrefixAddr) { - x = uint8(m.PrefixAddr[i]) - } - buf[pos] = uint8(x) - pos += 1 - } - // field[1] m.MaskWidth - o.PutUint32(buf[pos:pos+4], uint32(m.MaskWidth)) - pos += 4 + // field[1] m.Prefix + // field[2] m.Prefix.Address + // field[3] m.Prefix.Address.Af + buf[pos] = uint8(m.Prefix.Address.Af) + pos += 1 + // field[3] m.Prefix.Address.Un + copy(buf[pos:pos+16], m.Prefix.Address.Un.XXX_UnionData[:]) + pos += 16 + // field[2] m.Prefix.Len + buf[pos] = uint8(m.Prefix.Len) + pos += 1 // field[1] m.SwIfIndex o.PutUint32(buf[pos:pos+4], uint32(m.SwIfIndex)) pos += 4 // field[1] m.Bsid - // field[2] m.Bsid.Addr for i := 0; i < 16; i++ { var x uint8 - if i < len(m.Bsid.Addr) { - x = uint8(m.Bsid.Addr[i]) + if i < len(m.Bsid) { + x = uint8(m.Bsid[i]) } buf[pos] = uint8(x) pos += 1 @@ -1591,28 +1699,28 @@ func (m *SrSteeringPolDetails) Unmarshal(tmp []byte) error { pos := 0 _ = pos // field[1] m.TrafficType - m.TrafficType = uint8(tmp[pos]) + m.TrafficType = SrSteer(tmp[pos]) pos += 1 // field[1] m.FibTable m.FibTable = uint32(o.Uint32(tmp[pos : pos+4])) pos += 4 - // field[1] m.PrefixAddr - m.PrefixAddr = make([]uint8, 16) - for i := 0; i < len(m.PrefixAddr); i++ { - m.PrefixAddr[i] = uint8(tmp[pos]) - pos += 1 - } - // field[1] m.MaskWidth - m.MaskWidth = uint32(o.Uint32(tmp[pos : pos+4])) - pos += 4 + // field[1] m.Prefix + // field[2] m.Prefix.Address + // field[3] m.Prefix.Address.Af + m.Prefix.Address.Af = AddressFamily(tmp[pos]) + pos += 1 + // field[3] m.Prefix.Address.Un + copy(m.Prefix.Address.Un.XXX_UnionData[:], tmp[pos:pos+16]) + pos += 16 + // field[2] m.Prefix.Len + m.Prefix.Len = uint8(tmp[pos]) + pos += 1 // field[1] m.SwIfIndex - m.SwIfIndex = uint32(o.Uint32(tmp[pos : pos+4])) + m.SwIfIndex = InterfaceIndex(o.Uint32(tmp[pos : pos+4])) pos += 4 // field[1] m.Bsid - // field[2] m.Bsid.Addr - m.Bsid.Addr = make([]uint8, 16) - for i := 0; i < len(m.Bsid.Addr); i++ { - m.Bsid.Addr[i] = uint8(tmp[pos]) + for i := 0; i < len(m.Bsid); i++ { + m.Bsid[i] = uint8(tmp[pos]) pos += 1 } return nil diff --git a/examples/binapi/vpe/vpe.ba.go b/examples/binapi/vpe/vpe.ba.go index 4c00c86..b682d9f 100644 --- a/examples/binapi/vpe/vpe.ba.go +++ b/examples/binapi/vpe/vpe.ba.go @@ -1,11 +1,11 @@ // Code generated by GoVPP's binapi-generator. DO NOT EDIT. // versions: -// binapi-generator: v0.4.0-alpha-1-g435c3f4-dirty -// VPP: 20.01-45~g7a071e370~b63 +// binapi-generator: v0.4.0-dev +// VPP: 20.05-release // source: /usr/share/vpp/api/core/vpe.api.json /* -Package vpe contains generated code for VPP binary API defined by vpe.api (version 1.6.0). +Package vpe contains generated code for VPP API file vpe.api (1.6.1). It consists of: 2 aliases @@ -38,9 +38,9 @@ const ( // ModuleName is the name of this module. ModuleName = "vpe" // APIVersion is the API version of this module. - APIVersion = "1.6.0" + APIVersion = "1.6.1" // VersionCrc is the CRC of this module. - VersionCrc = 0xc6c0bcf6 + VersionCrc = 0xbd2c94f4 ) // LogLevel represents VPP binary API enum 'log_level'. @@ -100,8 +100,8 @@ type Timestamp float64 // ThreadData represents VPP binary API type 'thread_data'. type ThreadData struct { ID uint32 `binapi:"u32,name=id" json:"id,omitempty"` - Name []byte `binapi:"u8[64],name=name" json:"name,omitempty" struc:"[64]byte"` - Type []byte `binapi:"u8[64],name=type" json:"type,omitempty" struc:"[64]byte"` + Name string `binapi:"string[64],name=name" json:"name,omitempty" struc:"[64]byte"` + Type string `binapi:"string[64],name=type" json:"type,omitempty" struc:"[64]byte"` PID uint32 `binapi:"u32,name=pid" json:"pid,omitempty"` CPUID uint32 `binapi:"u32,name=cpu_id" json:"cpu_id,omitempty"` Core uint32 `binapi:"u32,name=core" json:"core,omitempty"` @@ -123,13 +123,13 @@ func (*Version) GetTypeName() string { return "version" } // AddNodeNext represents VPP binary API message 'add_node_next'. type AddNodeNext struct { - NodeName []byte `binapi:"u8[64],name=node_name" json:"node_name,omitempty" struc:"[64]byte"` - NextName []byte `binapi:"u8[64],name=next_name" json:"next_name,omitempty" struc:"[64]byte"` + NodeName string `binapi:"string[64],name=node_name" json:"node_name,omitempty" struc:"[64]byte"` + NextName string `binapi:"string[64],name=next_name" json:"next_name,omitempty" struc:"[64]byte"` } func (m *AddNodeNext) Reset() { *m = AddNodeNext{} } func (*AddNodeNext) GetMessageName() string { return "add_node_next" } -func (*AddNodeNext) GetCrcString() string { return "9ab92f7a" } +func (*AddNodeNext) GetCrcString() string { return "2457116d" } func (*AddNodeNext) GetMessageType() api.MessageType { return api.RequestMessage } func (m *AddNodeNext) Size() int { @@ -155,23 +155,11 @@ func (m *AddNodeNext) Marshal(b []byte) ([]byte, error) { buf = b } // field[1] m.NodeName - for i := 0; i < 64; i++ { - var x uint8 - if i < len(m.NodeName) { - x = uint8(m.NodeName[i]) - } - buf[pos] = uint8(x) - pos += 1 - } + copy(buf[pos:pos+64], m.NodeName) + pos += 64 // field[1] m.NextName - for i := 0; i < 64; i++ { - var x uint8 - if i < len(m.NextName) { - x = uint8(m.NextName[i]) - } - buf[pos] = uint8(x) - pos += 1 - } + copy(buf[pos:pos+64], m.NextName) + pos += 64 return buf, nil } func (m *AddNodeNext) Unmarshal(tmp []byte) error { @@ -180,16 +168,16 @@ func (m *AddNodeNext) Unmarshal(tmp []byte) error { pos := 0 _ = pos // field[1] m.NodeName - m.NodeName = make([]uint8, 64) - for i := 0; i < len(m.NodeName); i++ { - m.NodeName[i] = uint8(tmp[pos]) - pos += 1 + { + nul := bytes.Index(tmp[pos:pos+64], []byte{0x00}) + m.NodeName = codec.DecodeString(tmp[pos : pos+nul]) + pos += 64 } // field[1] m.NextName - m.NextName = make([]uint8, 64) - for i := 0; i < len(m.NextName); i++ { - m.NextName[i] = uint8(tmp[pos]) - pos += 1 + { + nul := bytes.Index(tmp[pos:pos+64], []byte{0x00}) + m.NextName = codec.DecodeString(tmp[pos : pos+nul]) + pos += 64 } return nil } @@ -769,13 +757,13 @@ func (m *GetF64IncrementByOneReply) Unmarshal(tmp []byte) error { // GetNextIndex represents VPP binary API message 'get_next_index'. type GetNextIndex struct { - NodeName []byte `binapi:"u8[64],name=node_name" json:"node_name,omitempty" struc:"[64]byte"` - NextName []byte `binapi:"u8[64],name=next_name" json:"next_name,omitempty" struc:"[64]byte"` + NodeName string `binapi:"string[64],name=node_name" json:"node_name,omitempty" struc:"[64]byte"` + NextName string `binapi:"string[64],name=next_name" json:"next_name,omitempty" struc:"[64]byte"` } func (m *GetNextIndex) Reset() { *m = GetNextIndex{} } func (*GetNextIndex) GetMessageName() string { return "get_next_index" } -func (*GetNextIndex) GetCrcString() string { return "9ab92f7a" } +func (*GetNextIndex) GetCrcString() string { return "2457116d" } func (*GetNextIndex) GetMessageType() api.MessageType { return api.RequestMessage } func (m *GetNextIndex) Size() int { @@ -801,23 +789,11 @@ func (m *GetNextIndex) Marshal(b []byte) ([]byte, error) { buf = b } // field[1] m.NodeName - for i := 0; i < 64; i++ { - var x uint8 - if i < len(m.NodeName) { - x = uint8(m.NodeName[i]) - } - buf[pos] = uint8(x) - pos += 1 - } + copy(buf[pos:pos+64], m.NodeName) + pos += 64 // field[1] m.NextName - for i := 0; i < 64; i++ { - var x uint8 - if i < len(m.NextName) { - x = uint8(m.NextName[i]) - } - buf[pos] = uint8(x) - pos += 1 - } + copy(buf[pos:pos+64], m.NextName) + pos += 64 return buf, nil } func (m *GetNextIndex) Unmarshal(tmp []byte) error { @@ -826,16 +802,16 @@ func (m *GetNextIndex) Unmarshal(tmp []byte) error { pos := 0 _ = pos // field[1] m.NodeName - m.NodeName = make([]uint8, 64) - for i := 0; i < len(m.NodeName); i++ { - m.NodeName[i] = uint8(tmp[pos]) - pos += 1 + { + nul := bytes.Index(tmp[pos:pos+64], []byte{0x00}) + m.NodeName = codec.DecodeString(tmp[pos : pos+nul]) + pos += 64 } // field[1] m.NextName - m.NextName = make([]uint8, 64) - for i := 0; i < len(m.NextName); i++ { - m.NextName[i] = uint8(tmp[pos]) - pos += 1 + { + nul := bytes.Index(tmp[pos:pos+64], []byte{0x00}) + m.NextName = codec.DecodeString(tmp[pos : pos+nul]) + pos += 64 } return nil } @@ -988,12 +964,12 @@ func (m *GetNodeGraphReply) Unmarshal(tmp []byte) error { // GetNodeIndex represents VPP binary API message 'get_node_index'. type GetNodeIndex struct { - NodeName []byte `binapi:"u8[64],name=node_name" json:"node_name,omitempty" struc:"[64]byte"` + NodeName string `binapi:"string[64],name=node_name" json:"node_name,omitempty" struc:"[64]byte"` } func (m *GetNodeIndex) Reset() { *m = GetNodeIndex{} } func (*GetNodeIndex) GetMessageName() string { return "get_node_index" } -func (*GetNodeIndex) GetCrcString() string { return "6c9a495d" } +func (*GetNodeIndex) GetCrcString() string { return "f1984c64" } func (*GetNodeIndex) GetMessageType() api.MessageType { return api.RequestMessage } func (m *GetNodeIndex) Size() int { @@ -1017,14 +993,8 @@ func (m *GetNodeIndex) Marshal(b []byte) ([]byte, error) { buf = b } // field[1] m.NodeName - for i := 0; i < 64; i++ { - var x uint8 - if i < len(m.NodeName) { - x = uint8(m.NodeName[i]) - } - buf[pos] = uint8(x) - pos += 1 - } + copy(buf[pos:pos+64], m.NodeName) + pos += 64 return buf, nil } func (m *GetNodeIndex) Unmarshal(tmp []byte) error { @@ -1033,10 +1003,10 @@ func (m *GetNodeIndex) Unmarshal(tmp []byte) error { pos := 0 _ = pos // field[1] m.NodeName - m.NodeName = make([]uint8, 64) - for i := 0; i < len(m.NodeName); i++ { - m.NodeName[i] = uint8(tmp[pos]) - pos += 1 + { + nul := bytes.Index(tmp[pos:pos+64], []byte{0x00}) + m.NodeName = codec.DecodeString(tmp[pos : pos+nul]) + pos += 64 } return nil } @@ -1266,7 +1236,7 @@ type ShowThreadsReply struct { func (m *ShowThreadsReply) Reset() { *m = ShowThreadsReply{} } func (*ShowThreadsReply) GetMessageName() string { return "show_threads_reply" } -func (*ShowThreadsReply) GetCrcString() string { return "f5e0b66f" } +func (*ShowThreadsReply) GetCrcString() string { return "efd78e83" } func (*ShowThreadsReply) GetMessageType() api.MessageType { return api.ReplyMessage } func (m *ShowThreadsReply) Size() int { @@ -1329,23 +1299,11 @@ func (m *ShowThreadsReply) Marshal(b []byte) ([]byte, error) { o.PutUint32(buf[pos:pos+4], uint32(v1.ID)) pos += 4 // field[2] v1.Name - for i := 0; i < 64; i++ { - var x uint8 - if i < len(v1.Name) { - x = uint8(v1.Name[i]) - } - buf[pos] = uint8(x) - pos += 1 - } + copy(buf[pos:pos+64], v1.Name) + pos += 64 // field[2] v1.Type - for i := 0; i < 64; i++ { - var x uint8 - if i < len(v1.Type) { - x = uint8(v1.Type[i]) - } - buf[pos] = uint8(x) - pos += 1 - } + copy(buf[pos:pos+64], v1.Type) + pos += 64 // field[2] v1.PID o.PutUint32(buf[pos:pos+4], uint32(v1.PID)) pos += 4 @@ -1379,16 +1337,16 @@ func (m *ShowThreadsReply) Unmarshal(tmp []byte) error { m.ThreadData[j1].ID = uint32(o.Uint32(tmp[pos : pos+4])) pos += 4 // field[2] m.ThreadData[j1].Name - m.ThreadData[j1].Name = make([]uint8, 64) - for i := 0; i < len(m.ThreadData[j1].Name); i++ { - m.ThreadData[j1].Name[i] = uint8(tmp[pos]) - pos += 1 + { + nul := bytes.Index(tmp[pos:pos+64], []byte{0x00}) + m.ThreadData[j1].Name = codec.DecodeString(tmp[pos : pos+nul]) + pos += 64 } // field[2] m.ThreadData[j1].Type - m.ThreadData[j1].Type = make([]uint8, 64) - for i := 0; i < len(m.ThreadData[j1].Type); i++ { - m.ThreadData[j1].Type[i] = uint8(tmp[pos]) - pos += 1 + { + nul := bytes.Index(tmp[pos:pos+64], []byte{0x00}) + m.ThreadData[j1].Type = codec.DecodeString(tmp[pos : pos+nul]) + pos += 64 } // field[2] m.ThreadData[j1].PID m.ThreadData[j1].PID = uint32(o.Uint32(tmp[pos : pos+4])) diff --git a/examples/simple-client/simple_client.go b/examples/simple-client/simple_client.go index 0017eac..096c222 100644 --- a/examples/simple-client/simple_client.go +++ b/examples/simple-client/simple_client.go @@ -27,8 +27,10 @@ import ( "git.fd.io/govpp.git/adapter/socketclient" "git.fd.io/govpp.git/api" "git.fd.io/govpp.git/core" + "git.fd.io/govpp.git/examples/binapi/interface_types" "git.fd.io/govpp.git/examples/binapi/interfaces" "git.fd.io/govpp.git/examples/binapi/ip" + "git.fd.io/govpp.git/examples/binapi/ip_types" "git.fd.io/govpp.git/examples/binapi/vpe" ) @@ -166,8 +168,8 @@ func addIPAddress(ch api.Channel, index interfaces.InterfaceIndex) { IsAdd: true, Prefix: interfaces.AddressWithPrefix{ Address: interfaces.Address{ - Af: interfaces.ADDRESS_IP4, - Un: interfaces.AddressUnionIP4(interfaces.IP4Address{10, 10, 0, uint8(index)}), + Af: ip_types.ADDRESS_IP4, + Un: ip_types.AddressUnionIP4(interfaces.IP4Address{10, 10, 0, uint8(index)}), }, Len: 32, }, @@ -244,7 +246,7 @@ func interfaceNotifications(ch api.Channel, index interfaces.InterfaceIndex) { // generate some events in VPP err = ch.SendRequest(&interfaces.SwInterfaceSetFlags{ SwIfIndex: index, - Flags: interfaces.IF_STATUS_API_FLAG_ADMIN_UP, + Flags: interface_types.IF_STATUS_API_FLAG_ADMIN_UP, }).ReceiveReply(&interfaces.SwInterfaceSetFlagsReply{}) if err != nil { logError(err, "setting interface flags") diff --git a/examples/union-example/union_example.go b/examples/union-example/union_example.go index 9993ee1..6d4619d 100644 --- a/examples/union-example/union_example.go +++ b/examples/union-example/union_example.go @@ -53,7 +53,7 @@ func constructExample() { } func encodingExample() { - var c codec.MsgCodec + var c = codec.DefaultCodec // encode this message var msg = ip.IPPuntRedirect{ |