diff options
Diffstat (limited to 'binapigen/vppapi')
-rw-r--r-- | binapigen/vppapi/api_schema.go | 16 | ||||
-rw-r--r-- | binapigen/vppapi/integration_test.go | 2 | ||||
-rw-r--r-- | binapigen/vppapi/parse_json.go | 48 | ||||
-rw-r--r-- | binapigen/vppapi/testdata/ip.api.json | 3096 | ||||
-rw-r--r-- | binapigen/vppapi/testdata/union.api.json | 231 | ||||
-rw-r--r-- | binapigen/vppapi/util.go | 23 | ||||
-rw-r--r-- | binapigen/vppapi/vppapi.go | 25 | ||||
-rw-r--r-- | binapigen/vppapi/vppapi_test.go | 2 |
8 files changed, 2526 insertions, 917 deletions
diff --git a/binapigen/vppapi/api_schema.go b/binapigen/vppapi/api_schema.go index 7eceab3..4dd0ac9 100644 --- a/binapigen/vppapi/api_schema.go +++ b/binapigen/vppapi/api_schema.go @@ -24,10 +24,11 @@ type ( Options map[string]string `json:",omitempty"` Imports []string `json:",omitempty"` - AliasTypes []AliasType `json:",omitempty"` - EnumTypes []EnumType `json:",omitempty"` - StructTypes []StructType `json:",omitempty"` - UnionTypes []UnionType `json:",omitempty"` + AliasTypes []AliasType `json:",omitempty"` + EnumTypes []EnumType `json:",omitempty"` + EnumflagTypes []EnumType `json:",omitempty"` + StructTypes []StructType `json:",omitempty"` + UnionTypes []UnionType `json:",omitempty"` Messages []Message `json:",omitempty"` Service *Service `json:",omitempty"` @@ -61,9 +62,10 @@ type ( } Message struct { - Name string - Fields []Field - CRC string + Name string + Fields []Field + CRC string + Options map[string]string } Field struct { diff --git a/binapigen/vppapi/integration_test.go b/binapigen/vppapi/integration_test.go index 9d619b8..c3df45c 100644 --- a/binapigen/vppapi/integration_test.go +++ b/binapigen/vppapi/integration_test.go @@ -20,7 +20,7 @@ import ( "encoding/json" "testing" - "git.fd.io/govpp.git/binapigen/vppapi" + "go.fd.io/govpp/binapigen/vppapi" ) func TestParse(t *testing.T) { diff --git a/binapigen/vppapi/parse_json.go b/binapigen/vppapi/parse_json.go index d14865c..ed7bcad 100644 --- a/binapigen/vppapi/parse_json.go +++ b/binapigen/vppapi/parse_json.go @@ -41,14 +41,16 @@ const ( fileMessages = "messages" fileUnions = "unions" fileEnums = "enums" + fileEnumflags = "enumflags" fileAliases = "aliases" fileServices = "services" fileImports = "imports" // type keys - messageCrc = "crc" - enumType = "enumtype" - aliasLength = "length" - aliasType = "type" + messageCrc = "crc" + messageOptions = "options" + enumType = "enumtype" + aliasLength = "length" + aliasType = "type" // service serviceReply = "reply" serviceStream = "stream" @@ -129,6 +131,20 @@ func parseJSON(data []byte) (module *File, err error) { module.EnumTypes = append(module.EnumTypes, *enum) } + // parse enumflags types + enumflagsNode := jsonRoot.Map(fileEnumflags) + module.EnumflagTypes = make([]EnumType, 0) + for i := 0; i < enumflagsNode.Len(); i++ { + enumflag, err := parseEnum(enumflagsNode.At(i)) + if err != nil { + return nil, err + } + if exists(enumflag.Name) { + continue + } + module.EnumflagTypes = append(module.EnumflagTypes, *enumflag) + } + // parse alias types aliasesNode := jsonRoot.Map(fileAliases) if aliasesNode.GetType() == jsongo.TypeMap { @@ -360,10 +376,30 @@ func parseMessage(msgNode *jsongo.Node) (*Message, error) { if !ok { return nil, fmt.Errorf("message crc invalid or missing") } + var msgOpts map[string]string + msgOptsNode := msgNode.At(msgNode.Len() - 1).Map(messageOptions) + if msgOptsNode.GetType() == jsongo.TypeMap { + msgOpts = make(map[string]string) + for _, opt := range msgOptsNode.GetKeys() { + if _, ok := opt.(string); !ok { + logf("invalid message option key, expected string") + continue + } + msgOpts[opt.(string)] = "" + if msgOptsNode.At(opt).Get() != nil { + if optMsgStr, ok := msgOptsNode.At(opt).Get().(string); ok { + msgOpts[opt.(string)] = optMsgStr + } else { + logf("invalid message option value, expected string") + } + } + } + } msg := Message{ - Name: msgName, - CRC: msgCRC, + Name: msgName, + CRC: msgCRC, + Options: msgOpts, } // loop through message fields, skip first (name) and last (crc) diff --git a/binapigen/vppapi/testdata/ip.api.json b/binapigen/vppapi/testdata/ip.api.json index 530b6d6..32be996 100644 --- a/binapigen/vppapi/testdata/ip.api.json +++ b/binapigen/vppapi/testdata/ip.api.json @@ -1,633 +1,594 @@ { - "services": [ - { - "ip_source_and_port_range_check_add_del": { - "reply": "ip_source_and_port_range_check_add_del_reply" - } - }, - { - "ip6_fib_dump": { - "reply": "ip6_fib_details", - "stream": true - } - }, - { - "want_ip6_nd_events": { - "reply": "want_ip6_nd_events_reply" - } - }, - { - "ip_punt_police": { - "reply": "ip_punt_police_reply" - } - }, - { - "set_arp_neighbor_limit": { - "reply": "set_arp_neighbor_limit_reply" - } - }, - { - "ip6nd_proxy_add_del": { - "reply": "ip6nd_proxy_add_del_reply" - } - }, - { - "ioam_disable": { - "reply": "ioam_disable_reply" - } - }, - { - "ip_table_add_del": { - "reply": "ip_table_add_del_reply" - } - }, - { - "ip_neighbor_dump": { - "reply": "ip_neighbor_details", - "stream": true - } - }, - { - "ip4_arp_event": { - "reply": null - } - }, - { - "ip_punt_redirect": { - "reply": "ip_punt_redirect_reply" - } - }, - { - "sw_interface_ip6nd_ra_prefix": { - "reply": "sw_interface_ip6nd_ra_prefix_reply" - } - }, - { - "reset_fib": { - "reply": "reset_fib_reply" - } - }, - { - "ip6_mfib_dump": { - "reply": "ip6_mfib_details", - "stream": true - } - }, - { - "sw_interface_ip6nd_ra_config": { - "reply": "sw_interface_ip6nd_ra_config_reply" - } - }, - { - "sw_interface_ip6_enable_disable": { - "reply": "sw_interface_ip6_enable_disable_reply" - } - }, - { - "sw_interface_ip6_set_link_local_address": { - "reply": "sw_interface_ip6_set_link_local_address_reply" - } - }, - { - "mfib_signal_dump": { - "reply": "mfib_signal_details", - "stream": true - } - }, - { - "ip_container_proxy_add_del": { - "reply": "ip_container_proxy_add_del_reply" - } - }, - { - "ip_mfib_dump": { - "reply": "ip_mfib_details", - "stream": true - } - }, - { - "ip_address_dump": { - "reply": "ip_address_details", - "stream": true - } - }, - { - "ip_dump": { - "reply": "ip_details", - "stream": true - } - }, - { - "ip_neighbor_add_del": { - "reply": "ip_neighbor_add_del_reply" - } - }, - { - "proxy_arp_intfc_enable_disable": { - "reply": "proxy_arp_intfc_enable_disable_reply" - } - }, - { - "proxy_arp_add_del": { - "reply": "proxy_arp_add_del_reply" - } - }, - { - "ip_add_del_route": { - "reply": "ip_add_del_route_reply" - } - }, - { - "ip6nd_proxy_dump": { - "reply": "ip6nd_proxy_details", - "stream": true - } - }, - { - "ip_fib_dump": { - "reply": "ip_fib_details", - "stream": true - } - }, - { - "want_ip4_arp_events": { - "reply": "want_ip4_arp_events_reply" - } - }, - { - "ioam_enable": { - "reply": "ioam_enable_reply" - } - }, - { - "ip6_nd_event": { - "reply": null - } - }, - { - "ip_mroute_add_del": { - "reply": "ip_mroute_add_del_reply" - } - }, - { - "ip_source_and_port_range_check_interface_add_del": { - "reply": "ip_source_and_port_range_check_interface_add_del_reply" - } - }, - { - "set_ip_flow_hash": { - "reply": "set_ip_flow_hash_reply" - } - } - ], - "vl_api_version": "0xb395c625", - "enums": [], - "messages": [ + "types": [ [ - "ip_table_add_del", + "address", [ - "u16", - "_vl_msg_id" + "vl_api_address_family_t", + "af" ], [ - "u32", - "client_index" - ], - [ - "u32", - "context" - ], + "vl_api_address_union_t", + "un" + ] + ], + [ + "prefix", [ - "u32", - "table_id" + "vl_api_address_t", + "address" ], [ "u8", - "is_ipv6" - ], + "len" + ] + ], + [ + "ip4_address_and_mask", [ - "u8", - "is_add" + "vl_api_ip4_address_t", + "addr" ], [ - "u8", - "name", - 64 - ], - { - "crc": "0x0240c89d" - } + "vl_api_ip4_address_t", + "mask" + ] ], [ - "ip_table_add_del_reply", + "ip6_address_and_mask", [ - "u16", - "_vl_msg_id" + "vl_api_ip6_address_t", + "addr" ], [ - "u32", - "context" - ], - [ - "i32", - "retval" - ], - { - "crc": "0xe8d4e804" - } + "vl_api_ip6_address_t", + "mask" + ] ], [ - "ip_fib_dump", + "mprefix", [ - "u16", - "_vl_msg_id" + "vl_api_address_family_t", + "af" ], [ - "u32", - "client_index" + "u16", + "grp_address_length" ], [ - "u32", - "context" + "vl_api_address_union_t", + "grp_address" ], - { - "crc": "0x51077d14" - } + [ + "vl_api_address_union_t", + "src_address" + ] ], [ - "ip_fib_details", + "ip6_prefix", [ - "u16", - "_vl_msg_id" + "vl_api_ip6_address_t", + "address" ], [ - "u32", - "context" - ], + "u8", + "len" + ] + ], + [ + "ip4_prefix", [ - "u32", - "table_id" + "vl_api_ip4_address_t", + "address" ], [ "u8", - "table_name", - 64 - ], + "len" + ] + ], + [ + "prefix_matcher", [ "u8", - "address_length" + "le" ], [ "u8", - "address", - 4 + "ge" + ] + ], + [ + "fib_mpls_label", + [ + "u8", + "is_uniform" ], [ "u32", - "count" + "label" ], [ - "vl_api_fib_path_t", - "path", - 0, - "count" + "u8", + "ttl" ], - { - "crc": "0x99dfd73b" - } + [ + "u8", + "exp" + ] ], [ - "ip6_fib_dump", + "fib_path_nh", [ - "u16", - "_vl_msg_id" + "vl_api_address_union_t", + "address" ], [ "u32", - "client_index" + "via_label" ], [ "u32", - "context" + "obj_id" ], - { - "crc": "0x51077d14" - } + [ + "u32", + "classify_table_index" + ] ], [ - "ip6_fib_details", + "fib_path", [ - "u16", - "_vl_msg_id" + "u32", + "sw_if_index" ], [ "u32", - "context" + "table_id" ], [ "u32", - "table_id" + "rpf_id" ], [ "u8", - "table_name", - 64 + "weight" ], [ "u8", - "address_length" + "preference" ], [ - "u8", - "address", - 16 + "vl_api_fib_path_type_t", + "type" ], [ - "u32", - "count" + "vl_api_fib_path_flags_t", + "flags" ], [ - "vl_api_fib_path_t", - "path", - 0, - "count" + "vl_api_fib_path_nh_proto_t", + "proto" ], - { - "crc": "0xabd0060e" - } - ], - [ - "ip_neighbor_dump", [ - "u16", - "_vl_msg_id" + "vl_api_fib_path_nh_t", + "nh" ], [ - "u32", - "client_index" + "u8", + "n_labels" ], [ - "u32", - "context" + "vl_api_fib_mpls_label_t", + "label_stack", + 16 + ] + ], + [ + "address", + [ + "vl_api_address_family_t", + "af" ], [ - "u32", - "sw_if_index" + "vl_api_address_union_t", + "un" + ] + ], + [ + "prefix", + [ + "vl_api_address_t", + "address" ], [ "u8", - "is_ipv6" + "len" + ] + ], + [ + "ip4_address_and_mask", + [ + "vl_api_ip4_address_t", + "addr" ], - { - "crc": "0x6b7bcd0a" - } + [ + "vl_api_ip4_address_t", + "mask" + ] ], [ - "ip_neighbor_details", + "ip6_address_and_mask", + [ + "vl_api_ip6_address_t", + "addr" + ], + [ + "vl_api_ip6_address_t", + "mask" + ] + ], + [ + "mprefix", + [ + "vl_api_address_family_t", + "af" + ], [ "u16", - "_vl_msg_id" + "grp_address_length" ], [ - "u32", - "context" + "vl_api_address_union_t", + "grp_address" ], [ - "u32", - "sw_if_index" + "vl_api_address_union_t", + "src_address" + ] + ], + [ + "ip6_prefix", + [ + "vl_api_ip6_address_t", + "address" ], [ "u8", - "is_static" + "len" + ] + ], + [ + "ip4_prefix", + [ + "vl_api_ip4_address_t", + "address" ], [ "u8", - "is_ipv6" + "len" + ] + ], + [ + "prefix_matcher", + [ + "u8", + "le" ], [ "u8", - "mac_address", - 6 + "ge" + ] + ], + [ + "fib_mpls_label", + [ + "u8", + "is_uniform" + ], + [ + "u32", + "label" ], [ "u8", - "ip_address", - 16 + "ttl" ], - { - "crc": "0x85e32a72" - } + [ + "u8", + "exp" + ] ], [ - "ip_neighbor_add_del", + "fib_path_nh", [ - "u16", - "_vl_msg_id" + "vl_api_address_union_t", + "address" ], [ "u32", - "client_index" + "via_label" ], [ "u32", - "context" + "obj_id" ], [ "u32", + "classify_table_index" + ] + ], + [ + "fib_path", + [ + "u32", "sw_if_index" ], [ - "u8", - "is_add" + "u32", + "table_id" ], [ - "u8", - "is_ipv6" + "u32", + "rpf_id" ], [ "u8", - "is_static" + "weight" ], [ "u8", - "is_no_adj_fib" + "preference" ], [ - "u8", - "mac_address", - 6 + "vl_api_fib_path_type_t", + "type" + ], + [ + "vl_api_fib_path_flags_t", + "flags" + ], + [ + "vl_api_fib_path_nh_proto_t", + "proto" + ], + [ + "vl_api_fib_path_nh_t", + "nh" ], [ "u8", - "dst_address", - 16 + "n_labels" ], - { - "crc": "0x4711eb25" - } + [ + "vl_api_fib_mpls_label_t", + "label_stack", + 16 + ] ], [ - "ip_neighbor_add_del_reply", + "address", [ - "u16", - "_vl_msg_id" + "vl_api_address_family_t", + "af" ], [ - "u32", - "context" - ], + "vl_api_address_union_t", + "un" + ] + ], + [ + "prefix", [ - "i32", - "retval" + "vl_api_address_t", + "address" ], - { - "crc": "0xe8d4e804" - } + [ + "u8", + "len" + ] ], [ - "set_ip_flow_hash", + "ip4_address_and_mask", [ - "u16", - "_vl_msg_id" + "vl_api_ip4_address_t", + "addr" ], [ - "u32", - "client_index" - ], + "vl_api_ip4_address_t", + "mask" + ] + ], + [ + "ip6_address_and_mask", [ - "u32", - "context" + "vl_api_ip6_address_t", + "addr" ], [ - "u32", - "vrf_id" + "vl_api_ip6_address_t", + "mask" + ] + ], + [ + "mprefix", + [ + "vl_api_address_family_t", + "af" ], [ - "u8", - "is_ipv6" + "u16", + "grp_address_length" ], [ - "u8", - "src" + "vl_api_address_union_t", + "grp_address" ], [ - "u8", - "dst" + "vl_api_address_union_t", + "src_address" + ] + ], + [ + "ip6_prefix", + [ + "vl_api_ip6_address_t", + "address" ], [ "u8", - "sport" + "len" + ] + ], + [ + "ip4_prefix", + [ + "vl_api_ip4_address_t", + "address" ], [ "u8", - "dport" - ], + "len" + ] + ], + [ + "prefix_matcher", [ "u8", - "proto" + "le" ], [ "u8", - "reverse" - ], - { - "crc": "0x32ebf737" - } + "ge" + ] ], [ - "set_ip_flow_hash_reply", + "mfib_path", [ - "u16", - "_vl_msg_id" + "vl_api_mfib_itf_flags_t", + "itf_flags" ], [ + "vl_api_fib_path_t", + "path" + ] + ], + [ + "ip_table", + [ "u32", - "context" + "table_id" ], [ - "i32", - "retval" + "bool", + "is_ip6" ], - { - "crc": "0xe8d4e804" - } + [ + "string", + "name", + 64 + ] ], [ - "sw_interface_ip6nd_ra_config", - [ - "u16", - "_vl_msg_id" - ], + "ip_route", [ "u32", - "client_index" + "table_id" ], [ "u32", - "context" + "stats_index" ], [ - "u32", - "sw_if_index" + "vl_api_prefix_t", + "prefix" ], [ "u8", - "suppress" + "n_paths" ], [ - "u8", - "managed" + "vl_api_fib_path_t", + "paths", + 0, + "n_paths" + ] + ], + [ + "ip_mroute", + [ + "u32", + "table_id" ], [ - "u8", - "other" + "vl_api_mfib_entry_flags_t", + "entry_flags" ], [ - "u8", - "ll_option" + "u32", + "rpf_id" ], [ - "u8", - "send_unicast" + "vl_api_mprefix_t", + "prefix" ], [ "u8", - "cease" + "n_paths" ], [ - "u8", - "is_no" + "vl_api_mfib_path_t", + "paths", + 0, + "n_paths" + ] + ], + [ + "punt_redirect", + [ + "vl_api_interface_index_t", + "rx_sw_if_index" ], [ - "u8", - "default_router" + "vl_api_interface_index_t", + "tx_sw_if_index" ], [ - "u32", - "max_interval" + "vl_api_address_t", + "nh" + ] + ] + ], + "messages": [ + [ + "ip_table_add_del", + [ + "u16", + "_vl_msg_id" ], [ "u32", - "min_interval" + "client_index" ], [ "u32", - "lifetime" + "context" ], [ - "u32", - "initial_count" + "bool", + "is_add", + { + "default": "true" + } ], [ - "u32", - "initial_interval" + "vl_api_ip_table_t", + "table" ], { - "crc": "0xc3f02daa" + "crc": "0x0ffdaec0" } ], [ - "sw_interface_ip6nd_ra_config_reply", + "ip_table_add_del_reply", [ "u16", "_vl_msg_id" @@ -645,7 +606,7 @@ } ], [ - "sw_interface_ip6nd_ra_prefix", + "ip_table_dump", [ "u16", "_vl_msg_id" @@ -658,57 +619,34 @@ "u32", "context" ], + { + "crc": "0x51077d14" + } + ], + [ + "ip_table_replace_begin", [ - "u32", - "sw_if_index" - ], - [ - "u8", - "address", - 16 - ], - [ - "u8", - "address_length" - ], - [ - "u8", - "use_default" - ], - [ - "u8", - "no_advertise" - ], - [ - "u8", - "off_link" - ], - [ - "u8", - "no_autoconfig" - ], - [ - "u8", - "no_onlink" + "u16", + "_vl_msg_id" ], [ - "u8", - "is_no" + "u32", + "client_index" ], [ "u32", - "val_lifetime" + "context" ], [ - "u32", - "pref_lifetime" + "vl_api_ip_table_t", + "table" ], { - "crc": "0xca763c9a" + "crc": "0xb9d2e09e" } ], [ - "sw_interface_ip6nd_ra_prefix_reply", + "ip_table_replace_begin_reply", [ "u16", "_vl_msg_id" @@ -726,7 +664,7 @@ } ], [ - "ip6nd_proxy_add_del", + "ip_table_replace_end", [ "u16", "_vl_msg_id" @@ -740,24 +678,15 @@ "context" ], [ - "u32", - "sw_if_index" - ], - [ - "u8", - "is_del" - ], - [ - "u8", - "address", - 16 + "vl_api_ip_table_t", + "table" ], { - "crc": "0xd95f0fa0" + "crc": "0xb9d2e09e" } ], [ - "ip6nd_proxy_add_del_reply", + "ip_table_replace_end_reply", [ "u16", "_vl_msg_id" @@ -775,7 +704,7 @@ } ], [ - "ip6nd_proxy_details", + "ip_table_flush", [ "u16", "_vl_msg_id" @@ -789,38 +718,51 @@ "context" ], [ + "vl_api_ip_table_t", + "table" + ], + { + "crc": "0xb9d2e09e" + } + ], + [ + "ip_table_flush_reply", + [ + "u16", + "_vl_msg_id" + ], + [ "u32", - "sw_if_index" + "context" ], [ - "u8", - "address", - 16 + "i32", + "retval" ], { - "crc": "0xd73bf1ab" + "crc": "0xe8d4e804" } ], [ - "ip6nd_proxy_dump", + "ip_table_details", [ "u16", "_vl_msg_id" ], [ "u32", - "client_index" + "context" ], [ - "u32", - "context" + "vl_api_ip_table_t", + "table" ], { - "crc": "0x51077d14" + "crc": "0xc79fca0f" } ], [ - "sw_interface_ip6_enable_disable", + "ip_route_add_del", [ "u16", "_vl_msg_id" @@ -834,19 +776,26 @@ "context" ], [ - "u32", - "sw_if_index" + "bool", + "is_add", + { + "default": "true" + } ], [ - "u8", - "enable" + "bool", + "is_multipath" + ], + [ + "vl_api_ip_route_t", + "route" ], { - "crc": "0xa36fadc0" + "crc": "0xc1ff832d" } ], [ - "sw_interface_ip6_enable_disable_reply", + "ip_route_add_del_reply", [ "u16", "_vl_msg_id" @@ -859,12 +808,16 @@ "i32", "retval" ], + [ + "u32", + "stats_index" + ], { - "crc": "0xe8d4e804" + "crc": "0x1992deab" } ], [ - "sw_interface_ip6_set_link_local_address", + "ip_route_dump", [ "u16", "_vl_msg_id" @@ -878,20 +831,15 @@ "context" ], [ - "u32", - "sw_if_index" - ], - [ - "u8", - "address", - 16 + "vl_api_ip_table_t", + "table" ], { - "crc": "0xd73bf1ab" + "crc": "0xb9d2e09e" } ], [ - "sw_interface_ip6_set_link_local_address_reply", + "ip_route_details", [ "u16", "_vl_msg_id" @@ -901,15 +849,15 @@ "context" ], [ - "i32", - "retval" + "vl_api_ip_route_t", + "route" ], { - "crc": "0xe8d4e804" + "crc": "0xd1ffaae1" } ], [ - "ip_add_del_route", + "ip_route_lookup", [ "u16", "_vl_msg_id" @@ -924,122 +872,146 @@ ], [ "u32", - "next_hop_sw_if_index" + "table_id" ], [ - "u32", - "table_id" + "u8", + "exact" ], [ - "u32", - "classify_table_index" + "vl_api_prefix_t", + "prefix" ], + { + "crc": "0xe2986185" + } + ], + [ + "ip_route_lookup_reply", [ - "u32", - "next_hop_table_id" + "u16", + "_vl_msg_id" ], [ "u32", - "next_hop_id" + "context" ], [ - "u8", - "is_add" + "i32", + "retval" ], [ - "u8", - "is_drop" + "vl_api_ip_route_t", + "route" ], + { + "crc": "0xae99de8e" + } + ], + [ + "set_ip_flow_hash", [ - "u8", - "is_unreach" + "u16", + "_vl_msg_id" ], [ - "u8", - "is_prohibit" + "u32", + "client_index" ], [ - "u8", - "is_ipv6" + "u32", + "context" ], [ - "u8", - "is_local" + "u32", + "vrf_id" ], [ - "u8", - "is_classify" + "bool", + "is_ipv6" ], [ - "u8", - "is_multipath" + "bool", + "src" ], [ - "u8", - "is_resolve_host" + "bool", + "dst" ], [ - "u8", - "is_resolve_attached" + "bool", + "sport" ], [ - "u8", - "is_dvr" + "bool", + "dport" ], [ - "u8", - "is_source_lookup" + "bool", + "proto" ], [ - "u8", - "is_udp_encap" + "bool", + "reverse" ], [ - "u8", - "next_hop_weight" + "bool", + "symmetric" ], + { + "crc": "0x084ee09e" + } + ], + [ + "set_ip_flow_hash_reply", [ - "u8", - "next_hop_preference" + "u16", + "_vl_msg_id" ], [ - "u8", - "next_hop_proto" + "u32", + "context" ], [ - "u8", - "dst_address_length" + "i32", + "retval" ], + { + "crc": "0xe8d4e804" + } + ], + [ + "set_ip_flow_hash_v2", [ - "u8", - "dst_address", - 16 + "u16", + "_vl_msg_id" ], [ - "u8", - "next_hop_address", - 16 + "u32", + "client_index" ], [ - "u8", - "next_hop_n_out_labels" + "u32", + "context" ], [ "u32", - "next_hop_via_label" + "table_id" ], [ - "u32", - "next_hop_out_label_stack", - 0, - "next_hop_n_out_labels" + "vl_api_address_family_t", + "af" + ], + [ + "vl_api_ip_flow_hash_config_t", + "flow_hash_config" ], { - "crc": "0xc85f8290" + "crc": "0x6d132100" } ], [ - "ip_add_del_route_reply", + "set_ip_flow_hash_v2_reply", [ "u16", "_vl_msg_id" @@ -1057,7 +1029,7 @@ } ], [ - "ip_mroute_add_del", + "set_ip_flow_hash_router_id", [ "u16", "_vl_msg_id" @@ -1072,64 +1044,58 @@ ], [ "u32", - "next_hop_sw_if_index" - ], - [ - "u32", - "table_id" - ], - [ - "u32", - "entry_flags" + "router_id" ], + { + "crc": "0x03e4f48e" + } + ], + [ + "set_ip_flow_hash_router_id_reply", [ - "u32", - "itf_flags" + "u16", + "_vl_msg_id" ], [ "u32", - "rpf_id" + "context" ], [ - "u32", - "bier_imp" + "i32", + "retval" ], + { + "crc": "0xe8d4e804" + } + ], + [ + "sw_interface_ip6_enable_disable", [ "u16", - "grp_address_length" - ], - [ - "u8", - "next_hop_afi" - ], - [ - "u8", - "is_add" + "_vl_msg_id" ], [ - "u8", - "is_ipv6" + "u32", + "client_index" ], [ - "u8", - "is_local" + "u32", + "context" ], [ - "u8", - "grp_address", - 16 + "vl_api_interface_index_t", + "sw_if_index" ], [ - "u8", - "src_address", - 16 + "bool", + "enable" ], { - "crc": "0xc37112f7" + "crc": "0xae6cfcfb" } ], [ - "ip_mroute_add_del_reply", + "sw_interface_ip6_enable_disable_reply", [ "u16", "_vl_msg_id" @@ -1147,7 +1113,7 @@ } ], [ - "ip_mfib_dump", + "ip_mtable_dump", [ "u16", "_vl_msg_id" @@ -1165,57 +1131,84 @@ } ], [ - "ip_mfib_details", + "ip_mtable_details", [ "u16", "_vl_msg_id" ], [ "u32", - "context" + "client_index" ], [ "u32", - "table_id" + "context" + ], + [ + "vl_api_ip_table_t", + "table" + ], + { + "crc": "0xb9d2e09e" + } + ], + [ + "ip_mroute_add_del", + [ + "u16", + "_vl_msg_id" ], [ "u32", - "entry_flags" + "client_index" ], [ "u32", - "rpf_id" + "context" ], [ - "u8", - "address_length" + "bool", + "is_add", + { + "default": "true" + } ], [ - "u8", - "grp_address", - 4 + "bool", + "is_multipath" ], [ - "u8", - "src_address", - 4 + "vl_api_ip_mroute_t", + "route" + ], + { + "crc": "0x0dd7e790" + } + ], + [ + "ip_mroute_add_del_reply", + [ + "u16", + "_vl_msg_id" ], [ "u32", - "count" + "context" ], [ - "vl_api_fib_path_t", - "path", - 0, - "count" + "i32", + "retval" + ], + [ + "u32", + "stats_index" ], { - "crc": "0x5e530d5e" + "crc": "0x1992deab" } ], [ - "ip6_mfib_dump", + "ip_mroute_dump", [ "u16", "_vl_msg_id" @@ -1228,12 +1221,16 @@ "u32", "context" ], + [ + "vl_api_ip_table_t", + "table" + ], { - "crc": "0x51077d14" + "crc": "0xb9d2e09e" } ], [ - "ip6_mfib_details", + "ip_mroute_details", [ "u16", "_vl_msg_id" @@ -1243,39 +1240,37 @@ "context" ], [ - "u32", - "table_id" - ], - [ - "u8", - "address_length" + "vl_api_ip_mroute_t", + "route" ], + { + "crc": "0xc5cb23fc" + } + ], + [ + "ip_address_details", [ - "u8", - "grp_address", - 16 + "u16", + "_vl_msg_id" ], [ - "u8", - "src_address", - 16 + "u32", + "context" ], [ - "u32", - "count" + "vl_api_interface_index_t", + "sw_if_index" ], [ - "vl_api_fib_path_t", - "path", - 0, - "count" + "vl_api_address_with_prefix_t", + "prefix" ], { - "crc": "0xe02dcb4b" + "crc": "0xb1199745" } ], [ - "ip_address_details", + "ip_address_dump", [ "u16", "_vl_msg_id" @@ -1289,28 +1284,41 @@ "context" ], [ - "u8", - "ip", - 16 + "vl_api_interface_index_t", + "sw_if_index" ], [ - "u8", - "prefix_length" + "bool", + "is_ipv6" + ], + { + "crc": "0x2d033de4" + } + ], + [ + "ip_unnumbered_details", + [ + "u16", + "_vl_msg_id" ], [ "u32", + "context" + ], + [ + "vl_api_interface_index_t", "sw_if_index" ], [ - "u8", - "is_ipv6" + "vl_api_interface_index_t", + "ip_sw_if_index" ], { - "crc": "0xbc7442f2" + "crc": "0xaa12a483" } ], [ - "ip_address_dump", + "ip_unnumbered_dump", [ "u16", "_vl_msg_id" @@ -1324,15 +1332,14 @@ "context" ], [ - "u32", - "sw_if_index" - ], - [ - "u8", - "is_ipv6" + "vl_api_interface_index_t", + "sw_if_index", + { + "default": 4294967295 + } ], { - "crc": "0x6b7bcd0a" + "crc": "0xf9e6675e" } ], [ @@ -1343,18 +1350,18 @@ ], [ "u32", - "sw_if_index" + "context" ], [ - "u32", - "context" + "vl_api_interface_index_t", + "sw_if_index" ], [ - "u8", + "bool", "is_ipv6" ], { - "crc": "0x452ffc5a" + "crc": "0xeb152d07" } ], [ @@ -1372,11 +1379,11 @@ "context" ], [ - "u8", + "bool", "is_ipv6" ], { - "crc": "0xde883da4" + "crc": "0x98d231ca" } ], [ @@ -1405,14 +1412,10 @@ ], [ "u32", - "client_index" - ], - [ - "u32", "context" ], [ - "u32", + "vl_api_interface_index_t", "sw_if_index" ], [ @@ -1420,18 +1423,8 @@ "table_id" ], [ - "u16", - "grp_address_len" - ], - [ - "u8", - "grp_address", - 16 - ], - [ - "u8", - "src_address", - 16 + "vl_api_mprefix_t", + "prefix" ], [ "u16", @@ -1443,7 +1436,7 @@ 256 ], { - "crc": "0x791bbeab" + "crc": "0x64398a9a" } ], [ @@ -1465,15 +1458,18 @@ "policer_index" ], [ - "u8", - "is_add" + "bool", + "is_add", + { + "default": "true" + } ], [ - "u8", + "bool", "is_ip6" ], { - "crc": "0x38691592" + "crc": "0xdb867cea" } ], [ @@ -1509,28 +1505,18 @@ "context" ], [ - "u32", - "rx_sw_if_index" + "vl_api_punt_redirect_t", + "punt" ], [ - "u32", - "tx_sw_if_index" - ], - [ - "u8", - "is_add" - ], - [ - "u8", - "is_ip6" - ], - [ - "u8", - "nh", - 16 + "bool", + "is_add", + { + "default": "true" + } ], { - "crc": "0x996b6603" + "crc": "0xa9a5592c" } ], [ @@ -1552,7 +1538,7 @@ } ], [ - "ip_container_proxy_add_del", + "ip_punt_redirect_dump", [ "u16", "_vl_msg_id" @@ -1566,28 +1552,66 @@ "context" ], [ - "u8", - "ip", - 16 + "vl_api_interface_index_t", + "sw_if_index" ], [ - "u8", - "is_ip4" + "bool", + "is_ipv6" ], + { + "crc": "0x2d033de4" + } + ], + [ + "ip_punt_redirect_details", [ - "u8", - "plen" + "u16", + "_vl_msg_id" + ], + [ + "u32", + "context" + ], + [ + "vl_api_punt_redirect_t", + "punt" + ], + { + "crc": "0x3924f5d3" + } + ], + [ + "ip_container_proxy_add_del", + [ + "u16", + "_vl_msg_id" ], [ "u32", + "client_index" + ], + [ + "u32", + "context" + ], + [ + "vl_api_prefix_t", + "pfx" + ], + [ + "vl_api_interface_index_t", "sw_if_index" ], [ - "u8", - "is_add" + "bool", + "is_add", + { + "default": "true" + } ], { - "crc": "0x0a355d39" + "crc": "0x91189f40" } ], [ @@ -1609,7 +1633,7 @@ } ], [ - "ip_source_and_port_range_check_add_del", + "ip_container_proxy_dump", [ "u16", "_vl_msg_id" @@ -1622,22 +1646,56 @@ "u32", "context" ], + { + "crc": "0x51077d14" + } + ], + [ + "ip_container_proxy_details", [ - "u8", - "is_ipv6" + "u16", + "_vl_msg_id" ], [ - "u8", - "is_add" + "u32", + "context" ], [ - "u8", - "mask_length" + "vl_api_interface_index_t", + "sw_if_index" ], [ - "u8", - "address", - 16 + "vl_api_prefix_t", + "prefix" + ], + { + "crc": "0x0ee460e8" + } + ], + [ + "ip_source_and_port_range_check_add_del", + [ + "u16", + "_vl_msg_id" + ], + [ + "u32", + "client_index" + ], + [ + "u32", + "context" + ], + [ + "bool", + "is_add", + { + "default": "true" + } + ], + [ + "vl_api_prefix_t", + "prefix" ], [ "u8", @@ -1658,7 +1716,7 @@ "vrf_id" ], { - "crc": "0x03d6b03a" + "crc": "0x8bfc76f2" } ], [ @@ -1694,11 +1752,14 @@ "context" ], [ - "u8", - "is_add" + "bool", + "is_add", + { + "default": "true" + } ], [ - "u32", + "vl_api_interface_index_t", "sw_if_index" ], [ @@ -1718,7 +1779,7 @@ "udp_out_vrf_id" ], { - "crc": "0x6966bc44" + "crc": "0xe1ba8987" } ], [ @@ -1740,7 +1801,7 @@ } ], [ - "want_ip4_arp_events", + "sw_interface_ip6_set_link_local_address", [ "u16", "_vl_msg_id" @@ -1754,23 +1815,19 @@ "context" ], [ - "u8", - "enable_disable" + "vl_api_interface_index_t", + "sw_if_index" ], [ - "u32", - "pid" - ], - [ - "u32", - "address" + "vl_api_ip6_address_t", + "ip" ], { - "crc": "0x77e06379" + "crc": "0x2931d9fa" } ], [ - "want_ip4_arp_events_reply", + "sw_interface_ip6_set_link_local_address_reply", [ "u16", "_vl_msg_id" @@ -1788,7 +1845,7 @@ } ], [ - "ip4_arp_event", + "sw_interface_ip6_get_link_local_address", [ "u16", "_vl_msg_id" @@ -1799,31 +1856,40 @@ ], [ "u32", - "address" + "context" ], [ - "u32", - "pid" + "vl_api_interface_index_t", + "sw_if_index" + ], + { + "crc": "0xf9e6675e" + } + ], + [ + "sw_interface_ip6_get_link_local_address_reply", + [ + "u16", + "_vl_msg_id" ], [ "u32", - "sw_if_index" + "context" ], [ - "u8", - "new_mac", - 6 + "i32", + "retval" ], [ - "u8", - "mac_ip" + "vl_api_ip6_address_t", + "ip" ], { - "crc": "0xef7235f7" + "crc": "0xd16b7130" } ], [ - "want_ip6_nd_events", + "ioam_enable", [ "u16", "_vl_msg_id" @@ -1837,24 +1903,35 @@ "context" ], [ - "u8", - "enable_disable" + "u16", + "id" ], [ - "u32", - "pid" + "bool", + "seqno" ], [ - "u8", - "address", - 16 + "bool", + "analyse" + ], + [ + "bool", + "pot_enable" + ], + [ + "bool", + "trace_enable" + ], + [ + "u32", + "node_id" ], { - "crc": "0x1cf65fbb" + "crc": "0x51ccd868" } ], [ - "want_ip6_nd_events_reply", + "ioam_enable_reply", [ "u16", "_vl_msg_id" @@ -1872,7 +1949,7 @@ } ], [ - "ip6_nd_event", + "ioam_disable", [ "u16", "_vl_msg_id" @@ -1883,32 +1960,36 @@ ], [ "u32", - "pid" + "context" ], [ - "u32", - "sw_if_index" + "u16", + "id" ], + { + "crc": "0x6b16a45e" + } + ], + [ + "ioam_disable_reply", [ - "u8", - "address", - 16 + "u16", + "_vl_msg_id" ], [ - "u8", - "new_mac", - 6 + "u32", + "context" ], [ - "u8", - "mac_ip" + "i32", + "retval" ], { - "crc": "0x96ab2fdd" + "crc": "0xe8d4e804" } ], [ - "proxy_arp_add_del", + "ip_reassembly_set", [ "u16", "_vl_msg_id" @@ -1923,28 +2004,34 @@ ], [ "u32", - "vrf_id" + "timeout_ms" ], [ - "u8", - "is_add" + "u32", + "max_reassemblies" ], [ - "u8", - "low_address", - 4 + "u32", + "max_reassembly_length" ], [ - "u8", - "hi_address", - 4 + "u32", + "expire_walk_interval_ms" + ], + [ + "bool", + "is_ip6" + ], + [ + "vl_api_ip_reass_type_t", + "type" ], { - "crc": "0xc2442918" + "crc": "0x16467d25" } ], [ - "proxy_arp_add_del_reply", + "ip_reassembly_set_reply", [ "u16", "_vl_msg_id" @@ -1962,7 +2049,7 @@ } ], [ - "proxy_arp_intfc_enable_disable", + "ip_reassembly_get", [ "u16", "_vl_msg_id" @@ -1976,19 +2063,19 @@ "context" ], [ - "u32", - "sw_if_index" + "bool", + "is_ip6" ], [ - "u8", - "enable_disable" + "vl_api_ip_reass_type_t", + "type" ], { - "crc": "0x69d24598" + "crc": "0xea13ff63" } ], [ - "proxy_arp_intfc_enable_disable_reply", + "ip_reassembly_get_reply", [ "u16", "_vl_msg_id" @@ -2001,12 +2088,32 @@ "i32", "retval" ], + [ + "u32", + "timeout_ms" + ], + [ + "u32", + "max_reassemblies" + ], + [ + "u32", + "max_reassembly_length" + ], + [ + "u32", + "expire_walk_interval_ms" + ], + [ + "bool", + "is_ip6" + ], { - "crc": "0xe8d4e804" + "crc": "0xd5eb8d34" } ], [ - "reset_fib", + "ip_reassembly_enable_disable", [ "u16", "_vl_msg_id" @@ -2020,19 +2127,27 @@ "context" ], [ - "u32", - "vrf_id" + "vl_api_interface_index_t", + "sw_if_index" ], [ - "u8", - "is_ipv6" + "bool", + "enable_ip4" + ], + [ + "bool", + "enable_ip6" + ], + [ + "vl_api_ip_reass_type_t", + "type" ], { - "crc": "0x8553ebd9" + "crc": "0x885c85a6" } ], [ - "reset_fib_reply", + "ip_reassembly_enable_disable_reply", [ "u16", "_vl_msg_id" @@ -2048,199 +2163,1416 @@ { "crc": "0xe8d4e804" } + ] + ], + "unions": [ + [ + "address_union", + [ + "vl_api_ip4_address_t", + "ip4" + ], + [ + "vl_api_ip6_address_t", + "ip6" + ] ], [ - "set_arp_neighbor_limit", + "address_union", [ - "u16", - "_vl_msg_id" + "vl_api_ip4_address_t", + "ip4" ], [ - "u32", - "client_index" + "vl_api_ip6_address_t", + "ip6" + ] + ], + [ + "address_union", + [ + "vl_api_ip4_address_t", + "ip4" ], [ - "u32", - "context" + "vl_api_ip6_address_t", + "ip6" + ] + ] + ], + "enums": [ + [ + "if_status_flags", + [ + "IF_STATUS_API_FLAG_ADMIN_UP", + 1 ], [ - "u8", - "is_ipv6" + "IF_STATUS_API_FLAG_LINK_UP", + 2 ], + { + "enumtype": "u32" + } + ], + [ + "mtu_proto", [ - "u32", - "arp_neighbor_limit" + "MTU_PROTO_API_L3", + 0 + ], + [ + "MTU_PROTO_API_IP4", + 1 + ], + [ + "MTU_PROTO_API_IP6", + 2 + ], + [ + "MTU_PROTO_API_MPLS", + 3 ], { - "crc": "0x97d01fd6" + "enumtype": "u32" } ], [ - "set_arp_neighbor_limit_reply", + "link_duplex", [ - "u16", - "_vl_msg_id" + "LINK_DUPLEX_API_UNKNOWN", + 0 ], [ - "u32", - "context" + "LINK_DUPLEX_API_HALF", + 1 ], [ - "i32", - "retval" + "LINK_DUPLEX_API_FULL", + 2 ], { - "crc": "0xe8d4e804" + "enumtype": "u32" } ], [ - "ioam_enable", + "sub_if_flags", [ - "u16", - "_vl_msg_id" + "SUB_IF_API_FLAG_NO_TAGS", + 1 ], [ - "u32", - "client_index" + "SUB_IF_API_FLAG_ONE_TAG", + 2 ], [ - "u32", - "context" + "SUB_IF_API_FLAG_TWO_TAGS", + 4 ], [ - "u16", - "id" + "SUB_IF_API_FLAG_DOT1AD", + 8 ], [ - "u8", - "seqno" + "SUB_IF_API_FLAG_EXACT_MATCH", + 16 ], [ - "u8", - "analyse" + "SUB_IF_API_FLAG_DEFAULT", + 32 ], [ - "u8", - "pot_enable" + "SUB_IF_API_FLAG_OUTER_VLAN_ID_ANY", + 64 ], [ - "u8", - "trace_enable" + "SUB_IF_API_FLAG_INNER_VLAN_ID_ANY", + 128 ], [ - "u32", - "node_id" + "SUB_IF_API_FLAG_MASK_VNET", + 254 + ], + [ + "SUB_IF_API_FLAG_DOT1AH", + 256 ], { - "crc": "0x9392e032" + "enumtype": "u32" } ], [ - "ioam_enable_reply", + "rx_mode", [ - "u16", - "_vl_msg_id" + "RX_MODE_API_UNKNOWN", + 0 ], [ - "u32", - "context" + "RX_MODE_API_POLLING", + 1 ], [ - "i32", - "retval" + "RX_MODE_API_INTERRUPT", + 2 + ], + [ + "RX_MODE_API_ADAPTIVE", + 3 + ], + [ + "RX_MODE_API_DEFAULT", + 4 ], { - "crc": "0xe8d4e804" + "enumtype": "u32" } ], [ - "ioam_disable", + "if_type", [ - "u16", - "_vl_msg_id" + "IF_API_TYPE_HARDWARE", + 0 ], [ - "u32", - "client_index" + "IF_API_TYPE_SUB", + 1 ], [ - "u32", - "context" + "IF_API_TYPE_P2P", + 2 ], [ - "u16", - "id" + "IF_API_TYPE_PIPE", + 3 ], { - "crc": "0x6b16a45e" + "enumtype": "u32" } ], [ - "ioam_disable_reply", + "address_family", [ - "u16", - "_vl_msg_id" + "ADDRESS_IP4", + 0 ], [ - "u32", - "context" + "ADDRESS_IP6", + 1 + ], + { + "enumtype": "u8" + } + ], + [ + "ip_feature_location", + [ + "IP_API_FEATURE_INPUT", + 0 ], [ - "i32", - "retval" + "IP_API_FEATURE_OUTPUT", + 1 + ], + [ + "IP_API_FEATURE_LOCAL", + 2 + ], + [ + "IP_API_FEATURE_PUNT", + 3 + ], + [ + "IP_API_FEATURE_DROP", + 4 ], { - "crc": "0xe8d4e804" + "enumtype": "u8" } - ] - ], - "types": [ + ], [ - "fib_path", + "ip_ecn", [ - "u32", - "sw_if_index" + "IP_API_ECN_NONE", + 0 ], [ - "u32", - "table_id" + "IP_API_ECN_ECT0", + 1 ], [ - "u8", - "weight" + "IP_API_ECN_ECT1", + 2 ], [ - "u8", - "preference" + "IP_API_ECN_CE", + 3 ], + { + "enumtype": "u8" + } + ], + [ + "ip_dscp", [ - "u8", - "is_local" + "IP_API_DSCP_CS0", + 0 ], [ - "u8", - "is_drop" + "IP_API_DSCP_CS1", + 8 ], [ - "u8", - "is_unreach" + "IP_API_DSCP_AF11", + 10 ], [ - "u8", - "is_prohibit" + "IP_API_DSCP_AF12", + 12 ], [ - "u8", - "afi" + "IP_API_DSCP_AF13", + 14 ], [ - "u8", - "next_hop", + "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 + ], + { + "enumtype": "u8" + } + ], + [ + "ip_proto", + [ + "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_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 + ], + [ + "IP_API_PROTO_RESERVED", + 255 + ], + { + "enumtype": "u8" + } + ], + [ + "fib_path_nh_proto", + [ + "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 + ], + { + "enumtype": "u32" + } + ], + [ + "fib_path_flags", + [ + "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 + ], + { + "enumtype": "u32" + } + ], + [ + "fib_path_type", + [ + "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 + ], + { + "enumtype": "u32" + } + ], + [ + "address_family", + [ + "ADDRESS_IP4", + 0 + ], + [ + "ADDRESS_IP6", + 1 + ], + { + "enumtype": "u8" + } + ], + [ + "ip_feature_location", + [ + "IP_API_FEATURE_INPUT", + 0 + ], + [ + "IP_API_FEATURE_OUTPUT", + 1 + ], + [ + "IP_API_FEATURE_LOCAL", + 2 + ], + [ + "IP_API_FEATURE_PUNT", + 3 + ], + [ + "IP_API_FEATURE_DROP", + 4 + ], + { + "enumtype": "u8" + } + ], + [ + "ip_ecn", + [ + "IP_API_ECN_NONE", + 0 + ], + [ + "IP_API_ECN_ECT0", + 1 + ], + [ + "IP_API_ECN_ECT1", + 2 + ], + [ + "IP_API_ECN_CE", + 3 + ], + { + "enumtype": "u8" + } + ], + [ + "ip_dscp", + [ + "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 + ], + { + "enumtype": "u8" + } + ], + [ + "ip_proto", + [ + "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_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 + ], + [ + "IP_API_PROTO_RESERVED", + 255 + ], + { + "enumtype": "u8" + } + ], + [ + "fib_path_nh_proto", + [ + "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 + ], + { + "enumtype": "u32" + } + ], + [ + "fib_path_flags", + [ + "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 + ], + { + "enumtype": "u32" + } + ], + [ + "fib_path_type", + [ + "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 + ], + { + "enumtype": "u32" + } + ], + [ + "address_family", + [ + "ADDRESS_IP4", + 0 + ], + [ + "ADDRESS_IP6", + 1 + ], + { + "enumtype": "u8" + } + ], + [ + "ip_feature_location", + [ + "IP_API_FEATURE_INPUT", + 0 + ], + [ + "IP_API_FEATURE_OUTPUT", + 1 + ], + [ + "IP_API_FEATURE_LOCAL", + 2 + ], + [ + "IP_API_FEATURE_PUNT", + 3 + ], + [ + "IP_API_FEATURE_DROP", + 4 + ], + { + "enumtype": "u8" + } + ], + [ + "ip_ecn", + [ + "IP_API_ECN_NONE", + 0 + ], + [ + "IP_API_ECN_ECT0", + 1 + ], + [ + "IP_API_ECN_ECT1", + 2 + ], + [ + "IP_API_ECN_CE", + 3 + ], + { + "enumtype": "u8" + } + ], + [ + "ip_dscp", + [ + "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 + ], + { + "enumtype": "u8" + } + ], + [ + "ip_proto", + [ + "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_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 + ], + [ + "IP_API_PROTO_RESERVED", + 255 + ], + { + "enumtype": "u8" + } + ], + [ + "mfib_entry_flags", + [ + "MFIB_API_ENTRY_FLAG_NONE", + 0 + ], + [ + "MFIB_API_ENTRY_FLAG_SIGNAL", + 1 + ], + [ + "MFIB_API_ENTRY_FLAG_DROP", + 2 + ], + [ + "MFIB_API_ENTRY_FLAG_CONNECTED", + 4 + ], + [ + "MFIB_API_ENTRY_FLAG_ACCEPT_ALL_ITF", + 8 + ], + { + "enumtype": "u32" + } + ], + [ + "mfib_itf_flags", + [ + "MFIB_API_ITF_FLAG_NONE", + 0 + ], + [ + "MFIB_API_ITF_FLAG_NEGATE_SIGNAL", + 1 + ], + [ + "MFIB_API_ITF_FLAG_ACCEPT", + 2 + ], + [ + "MFIB_API_ITF_FLAG_FORWARD", + 4 + ], + [ + "MFIB_API_ITF_FLAG_SIGNAL_PRESENT", + 8 + ], + [ + "MFIB_API_ITF_FLAG_DONT_PRESERVE", + 16 + ], + { + "enumtype": "u32" + } + ], + [ + "if_status_flags", + [ + "IF_STATUS_API_FLAG_ADMIN_UP", + 1 + ], + [ + "IF_STATUS_API_FLAG_LINK_UP", + 2 + ], + { + "enumtype": "u32" + } + ], + [ + "mtu_proto", + [ + "MTU_PROTO_API_L3", + 0 + ], + [ + "MTU_PROTO_API_IP4", + 1 + ], + [ + "MTU_PROTO_API_IP6", + 2 + ], + [ + "MTU_PROTO_API_MPLS", + 3 + ], + { + "enumtype": "u32" + } + ], + [ + "link_duplex", + [ + "LINK_DUPLEX_API_UNKNOWN", + 0 + ], + [ + "LINK_DUPLEX_API_HALF", + 1 + ], + [ + "LINK_DUPLEX_API_FULL", + 2 + ], + { + "enumtype": "u32" + } + ], + [ + "sub_if_flags", + [ + "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 + ], + { + "enumtype": "u32" + } + ], + [ + "rx_mode", + [ + "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 + ], + { + "enumtype": "u32" + } + ], + [ + "if_type", + [ + "IF_API_TYPE_HARDWARE", + 0 + ], + [ + "IF_API_TYPE_SUB", + 1 + ], + [ + "IF_API_TYPE_P2P", + 2 + ], + [ + "IF_API_TYPE_PIPE", + 3 + ], + { + "enumtype": "u32" + } + ], + [ + "ip_reass_type", + [ + "IP_REASS_TYPE_FULL", + 0 + ], + [ + "IP_REASS_TYPE_SHALLOW_VIRTUAL", + 1 + ], + { + "enumtype": "u32" + } + ] + ], + "enumflags": [ + [ + "ip_flow_hash_config", + [ + "IP_API_FLOW_HASH_SRC_IP", + 1 + ], + [ + "IP_API_FLOW_HASH_DST_IP", + 2 + ], + [ + "IP_API_FLOW_HASH_SRC_PORT", + 4 + ], + [ + "IP_API_FLOW_HASH_DST_PORT", + 8 + ], + [ + "IP_API_FLOW_HASH_PROTO", 16 ], + [ + "IP_API_FLOW_HASH_REVERSE", + 32 + ], + [ + "IP_API_FLOW_HASH_SYMETRIC", + 64 + ], + [ + "IP_API_FLOW_HASH_FLOW_LABEL", + 128 + ], { - "crc": "0xcd899e0a" + "enumtype": "u32" } ] - ] + ], + "services": { + "ip_table_add_del": { + "reply": "ip_table_add_del_reply" + }, + "ip_table_dump": { + "reply": "ip_table_details", + "stream": true + }, + "ip_table_replace_begin": { + "reply": "ip_table_replace_begin_reply" + }, + "ip_table_replace_end": { + "reply": "ip_table_replace_end_reply" + }, + "ip_table_flush": { + "reply": "ip_table_flush_reply" + }, + "ip_route_add_del": { + "reply": "ip_route_add_del_reply" + }, + "ip_route_dump": { + "reply": "ip_route_details", + "stream": true + }, + "ip_route_lookup": { + "reply": "ip_route_lookup_reply" + }, + "set_ip_flow_hash": { + "reply": "set_ip_flow_hash_reply" + }, + "set_ip_flow_hash_v2": { + "reply": "set_ip_flow_hash_v2_reply" + }, + "set_ip_flow_hash_router_id": { + "reply": "set_ip_flow_hash_router_id_reply" + }, + "sw_interface_ip6_enable_disable": { + "reply": "sw_interface_ip6_enable_disable_reply" + }, + "ip_mtable_dump": { + "reply": "ip_mtable_details", + "stream": true + }, + "ip_mroute_add_del": { + "reply": "ip_mroute_add_del_reply" + }, + "ip_mroute_dump": { + "reply": "ip_mroute_details", + "stream": true + }, + "ip_address_dump": { + "reply": "ip_address_details", + "stream": true + }, + "ip_unnumbered_dump": { + "reply": "ip_unnumbered_details", + "stream": true + }, + "ip_dump": { + "reply": "ip_details", + "stream": true + }, + "mfib_signal_dump": { + "reply": "mfib_signal_details", + "stream": true + }, + "ip_punt_police": { + "reply": "ip_punt_police_reply" + }, + "ip_punt_redirect": { + "reply": "ip_punt_redirect_reply" + }, + "ip_punt_redirect_dump": { + "reply": "ip_punt_redirect_details", + "stream": true + }, + "ip_container_proxy_add_del": { + "reply": "ip_container_proxy_add_del_reply" + }, + "ip_container_proxy_dump": { + "reply": "ip_container_proxy_details", + "stream": true + }, + "ip_source_and_port_range_check_add_del": { + "reply": "ip_source_and_port_range_check_add_del_reply" + }, + "ip_source_and_port_range_check_interface_add_del": { + "reply": "ip_source_and_port_range_check_interface_add_del_reply" + }, + "sw_interface_ip6_set_link_local_address": { + "reply": "sw_interface_ip6_set_link_local_address_reply" + }, + "sw_interface_ip6_get_link_local_address": { + "reply": "sw_interface_ip6_get_link_local_address_reply" + }, + "ioam_enable": { + "reply": "ioam_enable_reply" + }, + "ioam_disable": { + "reply": "ioam_disable_reply" + }, + "ip_reassembly_set": { + "reply": "ip_reassembly_set_reply" + }, + "ip_reassembly_get": { + "reply": "ip_reassembly_get_reply" + }, + "ip_reassembly_enable_disable": { + "reply": "ip_reassembly_enable_disable_reply" + } + }, + "options": { + "version": "3.0.3" + }, + "aliases": { + "interface_index": { + "type": "u32" + }, + "ip4_address": { + "type": "u8", + "length": 4 + }, + "ip6_address": { + "type": "u8", + "length": 16 + }, + "address_with_prefix": { + "type": "vl_api_prefix_t" + }, + "ip4_address_with_prefix": { + "type": "vl_api_ip4_prefix_t" + }, + "ip6_address_with_prefix": { + "type": "vl_api_ip6_prefix_t" + }, + "mac_address": { + "type": "u8", + "length": 6 + } + }, + "vl_api_version": "0xf2f5f4e" } diff --git a/binapigen/vppapi/testdata/union.api.json b/binapigen/vppapi/testdata/union.api.json new file mode 100644 index 0000000..0811f22 --- /dev/null +++ b/binapigen/vppapi/testdata/union.api.json @@ -0,0 +1,231 @@ +{ + "services": [], + "vl_api_version": "0x1db2ece9", + "enums": [ + [ + "enum1", + [ + "ENUM_1_VALUE_1", + 1 + ], + [ + "ENUM_1_VALUE_2", + 2 + ], + { + "enumtype": "u16" + } + ], + [ + "enum2", + [ + "ENUM_2_VALUE_1", + 10 + ], + [ + "ENUM_2_VALUE_2", + 20 + ], + { + "enumtype": "u32" + } + ] + ], + "messages": [], + "types": [ + [ + "type1", + [ + "u8", + "field1", + 16 + ], + [ + "u8", + "field2", + 16 + ] + ], + [ + "type2", + [ + "u16", + "field1" + ], + [ + "u32", + "field2" + ], + [ + "u32", + "field3" + ] + ], + [ + "type3", + [ + "u8", + "field1", + 64 + ] + ], + [ + "type4", + [ + "u8", + "field1" + ], + [ + "u8", + "field2", + 16 + ] + ], + [ + "type5", + [ + "u32", + "field1" + ], + [ + "union5", + "field2" + ] + ], + [ + "type6", + [ + "u16", + "field1" + ], + [ + "u32", + "field2" + ], + [ + "type4", + "field3" + ], + [ + "u16", + "field4" + ], + [ + "u32", + "field5" + ], + [ + "u32", + "field6" + ] + ], + [ + "complex_type", + [ + "u32", + "field1" + ], + [ + "u8", + "field2" + ], + [ + "u8", + "field3" + ], + [ + "u32", + "field4" + ], + [ + "type5", + "field5" + ], + [ + "type6", + "field6" + ] + ] + ], + "unions": [ + [ + "union1", + [ + "vl_api_alias1_t", + "alias1" + ], + [ + "vl_api_alias2_t", + "alias2" + ] + ], + [ + "union2", + [ + "vl_api_enum1_t", + "enum1" + ], + [ + "vl_api_enum2_t", + "enum2" + ] + ], + [ + "union3", + [ + "vl_api_type1_t", + "type1" + ], + [ + "vl_api_type2_t", + "type2" + ] + ], + [ + "union4", + [ + "vl_api_union1_t", + "union1" + ], + [ + "vl_api_union2_t", + "union2" + ] + ], + [ + "union5", + [ + "vl_api_type1_t", + "type1" + ], + [ + "vl_api_type3_t", + "type3" + ] + ], + [ + "union6", + [ + "vl_api_type1_t", + "type1" + ], + [ + "vl_api_complex_type_t", + "type3" + ] + ] + ], + "aliases": { + "alias1": { + "type": "u8", + "length": 4 + }, + "alias2": { + "type": "u8", + "length": 16 + }, + "alias3": { + "type": "u32" + } + } +} diff --git a/binapigen/vppapi/util.go b/binapigen/vppapi/util.go index 87f2e55..1374bb9 100644 --- a/binapigen/vppapi/util.go +++ b/binapigen/vppapi/util.go @@ -26,7 +26,9 @@ import ( ) const ( - VPPVersionEnvVar = "VPP_VERSION" + VPPVersionEnvVar = "VPP_VERSION" + VPPDirEnvVar = "VPP_DIR" + versionScriptPath = "./src/scripts/version" ) // ResolveVPPVersion resolves version of the VPP for target directory. @@ -35,17 +37,17 @@ const ( func ResolveVPPVersion(apidir string) string { // check env variable override if ver := os.Getenv(VPPVersionEnvVar); ver != "" { - logrus.Debugf("VPP version was manually set to %q via %s env var", ver, VPPVersionEnvVar) + logrus.Infof("VPP version was manually set to %q via %s env var", ver, VPPVersionEnvVar) return ver } // assuming VPP package is installed - if path.Clean(apidir) == DefaultDir { + if _, err := exec.LookPath("vpp"); err == nil { version, err := GetVPPVersionInstalled() if err != nil { logrus.Warnf("resolving VPP version from installed package failed: %v", err) } else { - logrus.Debugf("resolved VPP version from installed package: %v", version) + logrus.Infof("resolved VPP version from installed package: %v", version) return version } } @@ -60,7 +62,7 @@ func ResolveVPPVersion(apidir string) string { if err != nil { logrus.Warnf("resolving VPP version from version script failed: %v", err) } else { - logrus.Debugf("resolved VPP version from version script: %v", version) + logrus.Infof("resolved VPP version from version script: %v", version) return version } } @@ -85,14 +87,13 @@ func GetVPPVersionInstalled() (string, error) { return strings.TrimSpace(string(out)), nil } -const versionScriptPath = "./src/scripts/version" - // GetVPPVersionRepo retrieves VPP version using script in repo directory. func GetVPPVersionRepo(repoDir string) (string, error) { - if _, err := os.Stat(versionScriptPath); err != nil { + scriptPath := path.Join(repoDir, versionScriptPath) + if _, err := os.Stat(scriptPath); err != nil { return "", err } - cmd := exec.Command(versionScriptPath) + cmd := exec.Command(scriptPath) cmd.Dir = repoDir out, err := cmd.CombinedOutput() if err != nil { @@ -102,6 +103,10 @@ func GetVPPVersionRepo(repoDir string) (string, error) { } func findGitRepoRootDir(dir string) (string, error) { + if conf := os.Getenv(VPPDirEnvVar); conf != "" { + logrus.Infof("VPP directory was manually set to %q via %s env var", conf, VPPDirEnvVar) + return conf, nil + } cmd := exec.Command("git", "rev-parse", "--show-toplevel") cmd.Dir = dir out, err := cmd.CombinedOutput() diff --git a/binapigen/vppapi/vppapi.go b/binapigen/vppapi/vppapi.go index 665fa81..b54d287 100644 --- a/binapigen/vppapi/vppapi.go +++ b/binapigen/vppapi/vppapi.go @@ -24,6 +24,9 @@ import ( const ( // DefaultDir is default location of API files. DefaultDir = "/usr/share/vpp/api" + + // APIFileExtension is a VPP API file extension suffix + APIFileExtension = ".api.json" ) // FindFiles finds API files located in dir or in a nested directory that is not nested deeper than deep. @@ -40,7 +43,7 @@ func FindFiles(dir string, deep int) (files []string, err error) { } else { files = append(files, nested...) } - } else if !e.IsDir() && strings.HasSuffix(e.Name(), ".api.json") { + } else if !e.IsDir() && strings.HasSuffix(e.Name(), APIFileExtension) { files = append(files, filepath.Join(dir, e.Name())) } } @@ -54,13 +57,13 @@ func Parse() ([]*File, error) { // ParseDir finds and parses API files in given directory and returns parsed files. // Supports API files in JSON format (.api.json) only. -func ParseDir(apidir string) ([]*File, error) { - list, err := FindFiles(apidir, 1) +func ParseDir(apiDir string) ([]*File, error) { + list, err := FindFiles(apiDir, 1) if err != nil { return nil, err } - logf("found %d files in API dir %q", len(list), apidir) + logf("found %d files in API dir %q", len(list), apiDir) var files []*File for _, file := range list { @@ -74,17 +77,17 @@ func ParseDir(apidir string) ([]*File, error) { } // ParseFile parses API file and returns File. -func ParseFile(apifile string) (*File, error) { - if !strings.HasSuffix(apifile, ".api.json") { - return nil, fmt.Errorf("unsupported file format: %q", apifile) +func ParseFile(apiFile string) (*File, error) { + if !strings.HasSuffix(apiFile, APIFileExtension) { + return nil, fmt.Errorf("unsupported file format: %q", apiFile) } - data, err := ioutil.ReadFile(apifile) + data, err := ioutil.ReadFile(apiFile) if err != nil { - return nil, fmt.Errorf("reading file %s failed: %v", apifile, err) + return nil, fmt.Errorf("reading file %s failed: %v", apiFile, err) } - base := filepath.Base(apifile) + base := filepath.Base(apiFile) name := base[:strings.Index(base, ".")] logf("parsing file %q", base) @@ -94,7 +97,7 @@ func ParseFile(apifile string) (*File, error) { return nil, fmt.Errorf("parsing file %s failed: %v", base, err) } module.Name = name - module.Path = apifile + module.Path = apiFile return module, nil } diff --git a/binapigen/vppapi/vppapi_test.go b/binapigen/vppapi/vppapi_test.go index 027cc1f..a555d9f 100644 --- a/binapigen/vppapi/vppapi_test.go +++ b/binapigen/vppapi/vppapi_test.go @@ -27,7 +27,7 @@ func TestGetInputFiles(t *testing.T) { result, err := FindFiles("testdata", 1) Expect(err).ShouldNot(HaveOccurred()) - Expect(result).To(HaveLen(5)) + Expect(result).To(HaveLen(6)) for _, file := range result { Expect(file).To(BeAnExistingFile()) } |