diff options
author | Ole Troan <ot@cisco.com> | 2019-09-04 09:12:29 +0200 |
---|---|---|
committer | Dave Barach <openvpp@barachs.net> | 2019-09-16 12:23:27 +0000 |
commit | 33a58171e5995d9e649b414bfc77f2aab26e4c58 (patch) | |
tree | 85e072422b46ef44bbefbdf49231da507ec99536 /src | |
parent | 1292d19c79c2fd4f09ffcc43ebf39f5d9d485c35 (diff) |
api: autogenerate api trace print/endian
In addition to the external vppapitrace tool, VPP itself supports dumping of API trace files.
In two formats, "custom-dump" and "dump". "dump" gives a human friendly list,
and "custom-dump" is meant to give a list of commands that can be fed to VAT.
This patch only deals with "dump".
Prior to this fix, auto-generation was only done for the basic types.
This fix adds support for any type, including lists, and supports pretty-printing
of enums, strings, IP addresses, MAC addresses and so on.
Usage: api trace dump <api-trace-file>
For example
Change-Id: I4e485680e6dcfce7489299ae6cf31d835071ac40
---------- trace 48 -----------
vl_api_sw_interface_set_flags_t:
_vl_msg_id: 75
client_index: 0
context: 10
sw_if_index: 1
flags: IF_STATUS_API_FLAG_ADMIN_UP
---------- trace 49 -----------
vl_api_sw_interface_add_del_address_t:
_vl_msg_id: 88
client_index: 0
context: 11
sw_if_index: 1
is_add: 1
del_all: 0
prefix: 172.16.1.1/24
---------- trace 51 -----------
vl_api_cli_inband_t:
_vl_msg_id: 819
client_index: 0
context: 13
cmd: packet-generator capture pg0 pcap /tmp/vpp-unittest-TestMAP-YhcmDX/pg0_out.pcap disable
---------- trace 58 -----------
vl_api_ip_neighbor_add_del_t:
_vl_msg_id: 199
client_index: 0
context: 20
is_add: 1
neighbor:
sw_if_index: 2
flags: IP_API_NEIGHBOR_FLAG_NONE
mac_address: 0202.0000.ff02
ip_address: fd01:2::2
Signed-off-by: Ole Troan <ot@cisco.com>
Change-Id: I5556d06008de2762e7c2d35a8b0963ae670b3db1
Type: fix
Signed-off-by: Ole Troan <ot@cisco.com>
Signed-off-by: Ole Troan <ot@cisco.com>
Signed-off-by: Ole Troan <ot@cisco.com>
Signed-off-by: Ole Troan <ot@cisco.com>
Signed-off-by: Ole Troan <ot@cisco.com>
Signed-off-by: Ole Troan <ot@cisco.com>
Signed-off-by: Ole Troan <ot@cisco.com>
Signed-off-by: Ole Troan <ot@cisco.com>
Diffstat (limited to 'src')
34 files changed, 987 insertions, 395 deletions
diff --git a/src/examples/sample-plugin/sample/sample.api b/src/examples/sample-plugin/sample/sample.api index 00472493e72..404a8375e5f 100644 --- a/src/examples/sample-plugin/sample/sample.api +++ b/src/examples/sample-plugin/sample/sample.api @@ -17,7 +17,7 @@ /* Define a simple binary API to control the feature */ option version = "0.1.0"; -import "../../vnet/interface_types.api"; +import "vnet/interface_types.api"; autoreply define sample_macswap_enable_disable { /* Client identifier, set from api_main.my_client_index */ diff --git a/src/plugins/abf/abf_all_api_h.h b/src/plugins/abf/abf_all_api_h.h index 146896491ee..702c975bce8 100644 --- a/src/plugins/abf/abf_all_api_h.h +++ b/src/plugins/abf/abf_all_api_h.h @@ -13,4 +13,9 @@ * limitations under the License. */ /* Include the generated file, see BUILT_SOURCES in Makefile.am */ + +#ifdef vl_printfun +#include <vnet/format_fns.h> +#endif + #include <abf/abf.api.h> diff --git a/src/plugins/acl/CMakeLists.txt b/src/plugins/acl/CMakeLists.txt index 803c8f97eba..0977129bafd 100644 --- a/src/plugins/acl/CMakeLists.txt +++ b/src/plugins/acl/CMakeLists.txt @@ -24,6 +24,7 @@ add_vpp_plugin(acl API_FILES acl.api + acl_types.api API_TEST_SOURCES acl_test.c diff --git a/src/plugins/acl/acl_all_api_h.h b/src/plugins/acl/acl_all_api_h.h index cb781cfd286..2a9d25d0bce 100644 --- a/src/plugins/acl/acl_all_api_h.h +++ b/src/plugins/acl/acl_all_api_h.h @@ -13,9 +13,9 @@ * limitations under the License. */ /* Include the generated file, see BUILT_SOURCES in Makefile.am */ -#include <acl/acl.api.h> #ifdef vl_printfun #include <acl/manual_fns.h> #endif +#include <acl/acl.api.h> diff --git a/src/plugins/acl/manual_fns.h b/src/plugins/acl/manual_fns.h index bc0ad92f3f1..c81bd3d3b8d 100644 --- a/src/plugins/acl/manual_fns.h +++ b/src/plugins/acl/manual_fns.h @@ -121,6 +121,59 @@ format_acl_action(u8 *s, u8 action) } static inline void * +vl_api_acl_rule_t_print (vl_api_acl_rule_t * a, void *handle) +{ + u8 *s; + + s = format (0, " %s ", a->is_ipv6 ? "ipv6" : "ipv4"); + s = format_acl_action (s, a->is_permit); + s = format (s, " \\\n"); + + if (a->is_ipv6) + s = format (s, " src %U/%d dst %U/%d \\\n", + format_ip6_address, a->src_ip_addr, a->src_ip_prefix_len, + format_ip6_address, a->dst_ip_addr, a->dst_ip_prefix_len); + else + s = format (s, " src %U/%d dst %U/%d \\\n", + format_ip4_address, a->src_ip_addr, a->src_ip_prefix_len, + format_ip4_address, a->dst_ip_addr, a->dst_ip_prefix_len); + s = format (s, " proto %d \\\n", a->proto); + s = format (s, " sport %d-%d dport %d-%d \\\n", + clib_net_to_host_u16 (a->srcport_or_icmptype_first), + clib_net_to_host_u16 (a->srcport_or_icmptype_last), + clib_net_to_host_u16 (a->dstport_or_icmpcode_first), + clib_net_to_host_u16 (a->dstport_or_icmpcode_last)); + + s = format (s, " tcpflags %u mask %u, \\", + a->tcp_flags_value, a->tcp_flags_mask); + PRINT_S; + return handle; +} + +static inline void * +vl_api_macip_acl_rule_t_print (vl_api_macip_acl_rule_t * a, void *handle) +{ + u8 *s; + + s = format (0, " %s %s \\\n", a->is_ipv6 ? "ipv6" : "ipv4", + a->is_permit ? "permit" : "deny"); + + s = format (s, " src mac %U mask %U \\\n", + format_ethernet_address, a->src_mac, + format_ethernet_address, a->src_mac_mask); + + if (a->is_ipv6) + s = format (s, " src ip %U/%d, \\", + format_ip6_address, a->src_ip_addr, a->src_ip_prefix_len); + else + s = format (s, " src ip %U/%d, \\", + format_ip4_address, a->src_ip_addr, a->src_ip_prefix_len); + + PRINT_S; + return handle; +} + +static inline void * vl_api_acl_add_replace_t_print (vl_api_acl_add_replace_t * a, void *handle) { u8 *s = 0; diff --git a/src/plugins/gbp/gbp_all_api_h.h b/src/plugins/gbp/gbp_all_api_h.h index dd78bc1d3ab..f90c36e554e 100644 --- a/src/plugins/gbp/gbp_all_api_h.h +++ b/src/plugins/gbp/gbp_all_api_h.h @@ -13,6 +13,11 @@ * limitations under the License. */ /* Include the generated file, see BUILT_SOURCES in Makefile.am */ + +#ifdef vl_printfun +#include <vnet/format_fns.h> +#endif + #include <gbp/gbp.api.h> #ifdef vl_printfun diff --git a/src/plugins/igmp/igmp_all_api_h.h b/src/plugins/igmp/igmp_all_api_h.h index 4f17a461414..9b552566a27 100644 --- a/src/plugins/igmp/igmp_all_api_h.h +++ b/src/plugins/igmp/igmp_all_api_h.h @@ -15,6 +15,10 @@ *------------------------------------------------------------------ */ +#ifdef vl_printfun +#include <vnet/format_fns.h> +#endif + #include <igmp/igmp.api.h> /* diff --git a/src/plugins/l3xc/l3xc_all_api_h.h b/src/plugins/l3xc/l3xc_all_api_h.h index ca53dbcde45..5152e2de1c3 100644 --- a/src/plugins/l3xc/l3xc_all_api_h.h +++ b/src/plugins/l3xc/l3xc_all_api_h.h @@ -13,4 +13,9 @@ * limitations under the License. */ /* Include the generated file, see BUILT_SOURCES in Makefile.am */ + +#ifdef vl_printfun +#include <vnet/format_fns.h> +#endif + #include <l3xc/l3xc.api.h> diff --git a/src/plugins/lb/lb_all_api_h.h b/src/plugins/lb/lb_all_api_h.h index 6d830d710d2..6afc0f35908 100644 --- a/src/plugins/lb/lb_all_api_h.h +++ b/src/plugins/lb/lb_all_api_h.h @@ -16,4 +16,9 @@ * limitations under the License. */ /* Include the generated file, see BUILT_SOURCES in Makefile.am */ + +#ifdef vl_printfun +#include <vnet/format_fns.h> +#endif + #include <lb/lb.api.h> diff --git a/src/plugins/lb/lb_test.c b/src/plugins/lb/lb_test.c index 1edabb51f86..3da7eb04ffb 100644 --- a/src/plugins/lb/lb_test.c +++ b/src/plugins/lb/lb_test.c @@ -84,6 +84,7 @@ typedef enum { /* instantiate all the print functions we know about */ #define vl_print(handle, ...) #define vl_printfun +#include <vnet/format_fns.h> #include <lb/lb.api.h> #undef vl_printfun diff --git a/src/plugins/map/map_all_api_h.h b/src/plugins/map/map_all_api_h.h index 4fb3e199bb2..c622bec170b 100644 --- a/src/plugins/map/map_all_api_h.h +++ b/src/plugins/map/map_all_api_h.h @@ -16,4 +16,9 @@ * limitations under the License. */ /* Include the generated file, see BUILT_SOURCES in Makefile.am */ + +#ifdef vl_printfun +#include <vnet/format_fns.h> +#endif + #include <map/map.api.h> diff --git a/src/plugins/map/map_api.c b/src/plugins/map/map_api.c index 5f2e1f82696..654e1793064 100644 --- a/src/plugins/map/map_api.c +++ b/src/plugins/map/map_api.c @@ -17,6 +17,7 @@ *------------------------------------------------------------------ */ +#include <vnet/ip/ip_types_api.h> #include <map/map.h> #include <map/map_msg_enum.h> #include <vnet/ip/ip.h> diff --git a/src/plugins/memif/memif_all_api_h.h b/src/plugins/memif/memif_all_api_h.h index 9729ec16239..b4a93724848 100644 --- a/src/plugins/memif/memif_all_api_h.h +++ b/src/plugins/memif/memif_all_api_h.h @@ -15,4 +15,8 @@ * limitations under the License. */ /* Include the generated file, see BUILT_SOURCES in Makefile.am */ + +#ifdef vl_printfun +#include <vnet/format_fns.h> +#endif #include <memif/memif.api.h> diff --git a/src/plugins/nat/nat_all_api_h.h b/src/plugins/nat/nat_all_api_h.h index acd9ba1cac9..f011a089b09 100644 --- a/src/plugins/nat/nat_all_api_h.h +++ b/src/plugins/nat/nat_all_api_h.h @@ -16,4 +16,9 @@ * limitations under the License. */ /* Include the generated file, see BUILT_SOURCES in Makefile.am */ + +#ifdef vl_printfun +#include <vnet/format_fns.h> +#endif + #include <nat/nat.api.h> diff --git a/src/plugins/svs/svs_all_api_h.h b/src/plugins/svs/svs_all_api_h.h index dff1657468f..cdec36e0e17 100644 --- a/src/plugins/svs/svs_all_api_h.h +++ b/src/plugins/svs/svs_all_api_h.h @@ -14,4 +14,8 @@ */ /* Include the generated file, see BUILT_SOURCES in Makefile.am */ +#ifdef vl_printfun +#include <vnet/format_fns.h> +#endif + #include <svs/svs.api.h> diff --git a/src/tools/vppapigen/vppapigen.py b/src/tools/vppapigen/vppapigen.py index 2a939647c67..fa7e47afb73 100755 --- a/src/tools/vppapigen/vppapigen.py +++ b/src/tools/vppapigen/vppapigen.py @@ -8,6 +8,7 @@ import keyword import logging import binascii import os +import sys log = logging.getLogger('vppapigen') @@ -78,6 +79,16 @@ class VPPAPILexer(object): t_ignore_LINE_COMMENT = '//.*' + def t_FALSE(self, t): + r'false' + t.value = False + return t + + def t_TRUE(self, t): + r'false' + t.value = True + return t + def t_NUM(self, t): r'0[xX][0-9a-fA-F]+|-?\d+\.?\d*' base = 16 if t.value.startswith('0x') else 10 @@ -150,6 +161,14 @@ class Typedef(): self.manual_print = True elif f == 'manual_endian': self.manual_endian = True + for b in block: + # Tag length field of a VLA + if isinstance(b, Array): + if b.lengthfield: + for b2 in block: + if b2.fieldname == b.lengthfield: + b2.vla_len = True + global_type_add(name, self) self.vla = False @@ -176,10 +195,18 @@ class Typedef(): class Using(): - def __init__(self, name, alias): + def __init__(self, name, flags, alias): self.name = name self.vla = False + self.manual_print = False + self.manual_endian = False + for f in flags: + if f == 'manual_print': + self.manual_print = True + elif f == 'manual_endian': + self.manual_endian = True + if isinstance(alias, Array): a = {'type': alias.fieldtype, 'length': alias.length} @@ -194,11 +221,20 @@ class Using(): class Union(): - def __init__(self, name, block): + def __init__(self, name, flags, block): self.type = 'Union' self.manual_print = False self.manual_endian = False self.name = name + + self.manual_print = False + self.manual_endian = False + for f in flags: + if f == 'manual_print': + self.manual_print = True + elif f == 'manual_endian': + self.manual_endian = True + self.block = block self.crc = str(block).encode() global_type_add(name, self) @@ -250,6 +286,12 @@ class Define(): 'VLA field "{}" must be the last ' 'field in message "{}"' .format(b.fieldname, name)) + # Tag length field of a VLA + if isinstance(b, Array): + if b.lengthfield: + for b2 in block: + if b2.fieldname == b.lengthfield: + b2.vla_len = True def __repr__(self): return self.name + str(self.flags) + str(self.block) @@ -298,8 +340,10 @@ class Import(): class Option(): - def __init__(self, option): + def __init__(self, option, value): + self.type = 'Option' self.option = option + self.value = value self.crc = str(option).encode() def __repr__(self): @@ -524,9 +568,17 @@ class VPPAPIParser(object): '''typedef : TYPEDEF ID '{' block_statements_opt '}' ';' ''' p[0] = Typedef(p[2], [], p[4]) + def p_typedef_flist(self, p): + '''typedef : flist TYPEDEF ID '{' block_statements_opt '}' ';' ''' + p[0] = Typedef(p[3], p[1], p[5]) + def p_typedef_alias(self, p): '''typedef : TYPEDEF declaration ''' - p[0] = Using(p[2].fieldname, p[2]) + p[0] = Using(p[2].fieldname, [], p[2]) + + def p_typedef_alias_flist(self, p): + '''typedef : flist TYPEDEF declaration ''' + p[0] = Using(p[3].fieldname, p[1], p[3]) def p_block_statements_opt(self, p): '''block_statements_opt : block_statements ''' @@ -620,7 +672,7 @@ class VPPAPIParser(object): def p_option(self, p): '''option : OPTION ID '=' assignee ';' ''' - p[0] = Option([p[1], p[2], p[4]]) + p[0] = Option(p[2], p[4]) def p_assignee(self, p): '''assignee : NUM @@ -653,7 +705,11 @@ class VPPAPIParser(object): def p_union(self, p): '''union : UNION ID '{' block_statements_opt '}' ';' ''' - p[0] = Union(p[2], p[4]) + p[0] = Union(p[2], [], p[4]) + + def p_union_flist(self, p): + '''union : flist UNION ID '{' block_statements_opt '}' ';' ''' + p[0] = Union(p[3], p[1], p[5]) # Error rule for syntax errors def p_error(self, p): @@ -716,7 +772,7 @@ class VPPAPI(object): isinstance(o, Union)): s['types'].append(o) elif isinstance(o, Using): - s['Alias'][o.name] = o.alias + s['Alias'][o.name] = o else: if tname not in s: raise ValueError('Unknown class type: {} {}' @@ -802,6 +858,7 @@ class VPPAPI(object): isinstance(o, Using)): continue if isinstance(o, Import): + result.append(o) self.process_imports(o.result, True, result) else: result.append(o) @@ -894,8 +951,12 @@ def main(): # Build a list of objects. Hash of lists. result = [] - parser.process_imports(parsed_objects, False, result) - s = parser.process(result) + + if args.output_module == 'C': + s = parser.process(parsed_objects) + else: + parser.process_imports(parsed_objects, False, result) + s = parser.process(result) # Add msg_id field s['Define'] = add_msg_id(s['Define']) diff --git a/src/tools/vppapigen/vppapigen_c.py b/src/tools/vppapigen/vppapigen_c.py index c1bc11d4a12..d6cdda8baac 100644 --- a/src/tools/vppapigen/vppapigen_c.py +++ b/src/tools/vppapigen/vppapigen_c.py @@ -2,6 +2,8 @@ import datetime import os import time +import sys +from io import StringIO datestring = datetime.datetime.utcfromtimestamp( int(os.environ.get('SOURCE_DATE_EPOCH', time.time()))) @@ -86,16 +88,6 @@ def msg_name_crc_list(s, suffix): return output -def duplicate_wrapper_head(name): - s = "#ifndef _vl_api_defined_%s\n" % name - s += "#define _vl_api_defined_%s\n" % name - return s - - -def duplicate_wrapper_tail(): - return '#endif\n\n' - - def api2c(fieldtype): mappingtable = {'string': 'vl_api_string_t', } if fieldtype in mappingtable: @@ -111,22 +103,20 @@ def typedefs(objs, aliases, filename): /****** Typedefs ******/ #ifdef vl_typedefs -#ifndef included_{module} -#define included_{module} +#ifndef included_{module}_typedef +#define included_{module}_typedef ''' output = output.format(module=name) for k, v in aliases.items(): - output += duplicate_wrapper_head(k) - if 'length' in v: - output += 'typedef %s vl_api_%s_t[%s];\n' % (v['type'], k, v['length']) + if 'length' in v.alias: + output += ('typedef %s vl_api_%s_t[%s];\n' + % (v.alias['type'], k, v.alias['length'])) else: - output += 'typedef %s vl_api_%s_t;\n' % (v['type'], k) - output += duplicate_wrapper_tail() + output += 'typedef %s vl_api_%s_t;\n' % (v.alias['type'], k) for o in objs: tname = o.__class__.__name__ - output += duplicate_wrapper_head(o.name) if tname == 'Enum': if o.enumtype == 'u32': output += "typedef enum {\n" @@ -140,33 +130,43 @@ def typedefs(objs, aliases, filename): size1 = 'sizeof(vl_api_%s_t)' % o.name size2 = 'sizeof(%s)' % o.enumtype err_str = 'size of API enum %s is wrong' % o.name - output += 'STATIC_ASSERT(%s == %s, "%s");\n' % (size1, size2, err_str) + output += ('STATIC_ASSERT(%s == %s, "%s");\n' + % (size1, size2, err_str)) else: if tname == 'Union': output += "typedef VL_API_PACKED(union _vl_api_%s {\n" % o.name else: - output += "typedef VL_API_PACKED(struct _vl_api_%s {\n" % o.name + output += ("typedef VL_API_PACKED(struct _vl_api_%s {\n" + % o.name) for b in o.block: + if b.type == 'Option': + continue if b.type == 'Field': - output += " %s %s;\n" % (api2c(b.fieldtype), b.fieldname) + output += " %s %s;\n" % (api2c(b.fieldtype), + b.fieldname) elif b.type == 'Array': if b.lengthfield: - output += " %s %s[0];\n" % (api2c(b.fieldtype), b.fieldname) + output += " %s %s[0];\n" % (api2c(b.fieldtype), + b.fieldname) else: # Fixed length strings decay to nul terminated u8 if b.fieldtype == 'string': if b.modern_vla: - output += ' {} {};\n'.format(api2c(b.fieldtype), b.fieldname) + output += (' {} {};\n' + .format(api2c(b.fieldtype), + b.fieldname)) else: - output += ' u8 {}[{}];\n'.format(b.fieldname, b.length) + output += (' u8 {}[{}];\n' + .format(b.fieldname, b.length)) else: - output += " %s %s[%s];\n" % (api2c(b.fieldtype), b.fieldname, - b.length) + output += (" %s %s[%s];\n" % + (api2c(b.fieldtype), b.fieldname, + b.length)) else: - raise ValueError("Error in processing array type %s" % b) + raise ValueError("Error in processing type {} for {}" + .format(b, o.name)) output += '}) vl_api_%s_t;\n' % o.name - output += duplicate_wrapper_tail() output += "\n#endif" output += "\n#endif\n\n" @@ -175,6 +175,7 @@ def typedefs(objs, aliases, filename): format_strings = {'u8': '%u', + 'bool': '%u', 'i8': '%d', 'u16': '%u', 'i16': '%d', @@ -182,13 +183,136 @@ format_strings = {'u8': '%u', 'i32': '%ld', 'u64': '%llu', 'i64': '%llu', - 'f64': '%.2f', } + 'f64': '%.2f'} + +noprint_fields = {'_vl_msg_id': None, + 'client_index': None, + 'context': None} + + +class Printfun(): + _dispatch = {} + + def __init__(self, stream): + self.stream = stream + + def print_string(self, o, stream): + write = stream.write + if o.modern_vla: + write(' if (vl_api_string_len(&a->{f}) > 0) {{\n' + .format(f=o.fieldname)) + write(' s = format(s, "\\n%U{f}: %.*s", ' + 'format_white_space, indent, ' + 'vl_api_string_len(&a->{f}) - 1, ' + 'vl_api_from_api_string(&a->{f}));\n'.format(f=o.fieldname)) + write(' } else {\n') + write(' s = format(s, "\\n%U{f}:", ' + 'format_white_space, indent);\n'.format(f=o.fieldname)) + write(' }\n') + else: + write(' s = format(s, "\\n%U{f}: %s", ' + 'format_white_space, indent, a->{f});\n' + .format(f=o.fieldname)) + + def print_field(self, o, stream): + write = stream.write + if o.fieldname in noprint_fields: + return + if o.fieldtype in format_strings: + f = format_strings[o.fieldtype] + write(' s = format(s, "\\n%U{n}: {f}", ' + 'format_white_space, indent, a->{n});\n' + .format(n=o.fieldname, f=f)) + else: + write(' s = format(s, "\\n%U{n}: %U", ' + 'format_white_space, indent, ' + 'format_{t}, &a->{n}, indent);\n' + .format(n=o.fieldname, t=o.fieldtype)) + _dispatch['Field'] = print_field -def printfun(objs): - output = '''\ + def print_array(self, o, stream): + write = stream.write + + forloop = '''\ + for (i = 0; i < {lfield}; i++) {{ + s = format(s, "\\n%U{n}: %U", + format_white_space, indent, format_{t}, &a->{n}[i], indent); + }} +''' + + forloop_format = '''\ + for (i = 0; i < {lfield}; i++) {{ + s = format(s, "\\n%U{n}: {t}", + format_white_space, indent, a->{n}[i]); + }} +''' + + if o.fieldtype == 'string': + return self.print_string(o, stream) + + if o.fieldtype == 'u8': + if o.lengthfield: + write(' s = format(s, "\\n%U{n}: %U", format_white_space, ' + 'indent, format_hex_bytes, a->{n}, a->{lfield});\n' + .format(n=o.fieldname, lfield=o.lengthfield)) + else: + write(' s = format(s, "\\n%U{n}: %U", format_white_space, ' + 'indent, format_hex_bytes, a, {lfield});\n' + .format(n=o.fieldname, lfield=o.length)) + return + + lfield = 'a->' + o.lengthfield if o.lengthfield else o.length + if o.fieldtype in format_strings: + write(forloop_format.format(lfield=lfield, + t=format_strings[o.fieldtype], + n=o.fieldname)) + else: + write(forloop.format(lfield=lfield, t=o.fieldtype, n=o.fieldname)) + + _dispatch['Array'] = print_array + + def print_alias(self, k, v, stream): + write = stream.write + if ('length' in v.alias and v.alias['length'] and + v.alias['type'] == 'u8'): + write(' return format(s, "%U", format_hex_bytes, a, {});\n' + .format(v.alias['length'])) + elif v.alias['type'] in format_strings: + write(' return format(s, "{}", *a);\n' + .format(format_strings[v.alias['type']])) + else: + write(' return format(s, "{} (print not implemented)"' + .format(k)) + + def print_enum(self, o, stream): + write = stream.write + write(" switch(*a) {\n") + for b in o: + write(" case %s:\n" % b[1]) + write(' return format(s, "{}");\n'.format(b[0])) + write(' }\n') + + _dispatch['Enum'] = print_enum + + def print_obj(self, o, stream): + write = stream.write + + if o.type in self._dispatch: + self._dispatch[o.type](self, o, stream) + else: + write(' s = format(s, "\\n{} {} {} (print not implemented");\n' + .format(o.type, o.fieldtype, o.fieldname)) + + +def printfun(objs, stream, modulename): + write = stream.write + + h = '''\ /****** Print functions *****/ #ifdef vl_printfun +#ifndef included_{module}_printfun +#define included_{module}_printfun #ifdef LP64 #define _uword_fmt \"%lld\" @@ -199,32 +323,103 @@ def printfun(objs): #endif ''' + + signature = '''\ +static inline void *vl_api_{name}_t_print (vl_api_{name}_t *a, void *handle) +{{ + u8 *s = 0; + u32 indent __attribute__((unused)) = 2; + int i __attribute__((unused)); +''' + + h = h.format(module=modulename) + write(h) + + pp = Printfun(stream) + for t in objs: + if t.manual_print: + write("/***** manual: vl_api_%s_t_print *****/\n\n" % t.name) + continue + write(signature.format(name=t.name)) + write(' /* Message definition: vl_api_{}_t: */\n'.format(t.name)) + write(" s = format(s, \"vl_api_%s_t:\");\n" % t.name) + for o in t.block: + pp.print_obj(o, stream) + write(' vec_add1(s, 0);\n') + write(' vl_print (handle, (char *)s);\n') + write(' vec_free (s);\n') + write(' return handle;\n') + write('}\n\n') + + write("\n#endif") + write("\n#endif /* vl_printfun */\n") + + return '' + + +def printfun_types(objs, aliases, stream, modulename): + write = stream.write + pp = Printfun(stream) + + h = '''\ +/****** Print functions *****/ +#ifdef vl_printfun +#ifndef included_{module}_printfun_types +#define included_{module}_printfun_types + +''' + h = h.format(module=modulename) + write(h) + + signature = '''\ +static inline u8 *format_vl_api_{name}_t (u8 *s, va_list * args) +{{ + vl_api_{name}_t *a = va_arg (*args, vl_api_{name}_t *); + u32 indent __attribute__((unused)) = va_arg (*args, u32); + int i __attribute__((unused)); + indent += 2; +''' + + for k, v in aliases.items(): + if v.manual_print: + write("/***** manual: vl_api_%s_t_print *****/\n\n" % k) + continue + + write(signature.format(name=k)) + pp.print_alias(k, v, stream) + write('}\n\n') + for t in objs: if t.__class__.__name__ == 'Enum': + write(signature.format(name=t.name)) + pp.print_enum(t.block, stream) + write(' return s;\n') + write('}\n\n') continue + if t.manual_print: - output += "/***** manual: vl_api_%s_t_print *****/\n\n" % t.name + write("/***** manual: vl_api_%s_t_print *****/\n\n" % t.name) continue - output += duplicate_wrapper_head(t.name + '_t_print') - output += "static inline void *vl_api_%s_t_print (vl_api_%s_t *a," % \ - (t.name, t.name) - output += "void *handle)\n{\n" - output += " vl_print(handle, \"vl_api_%s_t:\\n\");\n" % t.name + write(signature.format(name=t.name)) for o in t.block: - if o.type != 'Field': - continue - if o.fieldtype in format_strings: - output += " vl_print(handle, \"%s: %s\\n\", a->%s);\n" % \ - (o.fieldname, format_strings[o.fieldtype], - o.fieldname) - - output += ' return handle;\n' - output += '}\n\n' - output += duplicate_wrapper_tail() + pp.print_obj(o, stream) + + write(' return s;\n') + write('}\n\n') + + write("\n#endif") + write("\n#endif /* vl_printfun_types */\n") - output += "\n#endif /* vl_printfun */\n" +def imports(imports): + output = '/* Imported API files */\n' + output += '#ifndef vl_api_version\n' + + for i in imports: + s = i.filename.replace('plugins/', '') + output += '#include <{}.h>\n'.format(s) + output += '#endif\n' return output @@ -239,11 +434,64 @@ endian_strings = { } -def endianfun(objs): +def endianfun_array(o): + forloop = '''\ + for (i = 0; i < {length}; i++) {{ + a->{name}[i] = {format}(a->{name}[i]); + }} +''' + + forloop_format = '''\ + for (i = 0; i < {length}; i++) {{ + {type}_endian(&a->{name}[i]); + }} +''' + + output = '' + if o.fieldtype == 'u8' or o.fieldtype == 'string': + output += ' /* a->{n} = a->{n} (no-op) */\n'.format(n=o.fieldname) + else: + lfield = 'a->' + o.lengthfield if o.lengthfield else o.length + if o.fieldtype in endian_strings: + output += (forloop + .format(length=lfield, + format=endian_strings[o.fieldtype], + name=o.fieldname)) + else: + output += (forloop_format + .format(length=lfield, type=o.fieldtype, + name=o.fieldname)) + return output + + +def endianfun_obj(o): + output = '' + if o.type == 'Array': + return endianfun_array(o) + elif o.type != 'Field': + output += (' s = format(s, "\\n{} {} {} (print not implemented");\n' + .format(o.type, o.fieldtype, o.fieldname)) + return output + if o.fieldtype in endian_strings: + output += (' a->{name} = {format}(a->{name});\n' + .format(name=o.fieldname, + format=endian_strings[o.fieldtype])) + elif o.fieldtype.startswith('vl_api_'): + output += (' {type}_endian(&a->{name});\n' + .format(type=o.fieldtype, name=o.fieldname)) + else: + output += ' /* a->{n} = a->{n} (no-op) */\n'.format(n=o.fieldname) + + return output + + +def endianfun(objs, aliases, modulename): output = '''\ /****** Endian swap functions *****/\n\ #ifdef vl_endianfun +#ifndef included_{module}_endianfun +#define included_{module}_endianfun #undef clib_net_to_host_uword #ifdef LP64 @@ -253,30 +501,55 @@ def endianfun(objs): #endif ''' + output = output.format(module=modulename) + + signature = '''\ +static inline void vl_api_{name}_t_endian (vl_api_{name}_t *a) +{{ + int i __attribute__((unused)); +''' + + for k, v in aliases.items(): + if v.manual_endian: + output += "/***** manual: vl_api_%s_t_endian *****/\n\n" % k + continue + + output += signature.format(name=k) + if ('length' in v.alias and v.alias['length'] and + v.alias['type'] == 'u8'): + output += (' /* a->{name} = a->{name} (no-op) */\n' + .format(name=k)) + elif v.alias['type'] in format_strings: + output += (' *a = {}(*a);\n' + .format(endian_strings[v.alias['type']])) + else: + output += ' /* Not Implemented yet {} */'.format(k) + output += '}\n\n' for t in objs: if t.__class__.__name__ == 'Enum': + output += signature.format(name=t.name) + if t.enumtype in endian_strings: + output += (' *a = {}(*a);\n' + .format(endian_strings[t.enumtype])) + else: + output += (' /* a->{name} = a->{name} (no-op) */\n' + .format(name=t.name)) + + output += '}\n\n' continue + if t.manual_endian: output += "/***** manual: vl_api_%s_t_endian *****/\n\n" % t.name continue - output += duplicate_wrapper_head(t.name + '_t_endian') - output += "static inline void vl_api_%s_t_endian (vl_api_%s_t *a)" % \ - (t.name, t.name) - output += "\n{\n" - for o in t.block: - if o.type != 'Field': - continue - if o.fieldtype in endian_strings: - output += " a->%s = %s(a->%s);\n" % \ - (o.fieldname, endian_strings[o.fieldtype], o.fieldname) - else: - output += " /* a->%s = a->%s (no-op) */\n" % \ - (o.fieldname, o.fieldname) + output += signature.format(name=t.name) + for o in t.block: + output += endianfun_obj(o) output += '}\n\n' - output += duplicate_wrapper_tail() + + output += "\n#endif" output += "\n#endif /* vl_endianfun */\n\n" return output @@ -304,16 +577,23 @@ def version_tuple(s, module): # Plugin entry point # def run(input_filename, s): + stream = StringIO() basename = os.path.basename(input_filename) filename, file_extension = os.path.splitext(basename) + modulename = filename.replace('.', '_') + output = top_boilerplate.format(datestring=datestring, input_filename=basename) + output += imports(s['Import']) output += msg_ids(s) output += msg_names(s) output += msg_name_crc_list(s, filename) - output += typedefs(s['types'] + s['Define'], s['Alias'], filename + file_extension) - output += printfun(s['types'] + s['Define']) - output += endianfun(s['types'] + s['Define']) + output += typedefs(s['types'] + s['Define'], s['Alias'], + filename + file_extension) + printfun_types(s['types'], s['Alias'], stream, modulename) + printfun(s['Define'], stream, modulename) + output += stream.getvalue() + output += endianfun(s['types'] + s['Define'], s['Alias'], modulename) output += version_tuple(s, basename) output += bottom_boilerplate.format(input_filename=basename, file_crc=s['file_crc']) diff --git a/src/tools/vppapigen/vppapigen_json.py b/src/tools/vppapigen/vppapigen_json.py index 124c0d3a0bd..ef1c9823c33 100644 --- a/src/tools/vppapigen/vppapigen_json.py +++ b/src/tools/vppapigen/vppapigen_json.py @@ -26,12 +26,14 @@ def walk_services(s): return r -def walk_defs(s, is_message = False): +def walk_defs(s, is_message=False): r = [] for t in s: d = [] d.append(t.name) for b in t.block: + if b.type == 'Option': + continue if b.type == 'Field': if b.limit: d.append([b.fieldtype, b.fieldname, b.limit]) @@ -39,7 +41,8 @@ def walk_defs(s, is_message = False): d.append([b.fieldtype, b.fieldname]) elif b.type == 'Array': if b.lengthfield: - d.append([b.fieldtype, b.fieldname, b.length, b.lengthfield]) + d.append([b.fieldtype, b.fieldname, + b.length, b.lengthfield]) else: d.append([b.fieldtype, b.fieldname, b.length]) elif b.type == 'Union': @@ -62,12 +65,15 @@ def walk_defs(s, is_message = False): def run(filename, s): j = {} - j['types'] = walk_defs([o for o in s['types'] if o.__class__.__name__ == 'Typedef']) + j['types'] = (walk_defs([o for o in s['types'] + if o.__class__.__name__ == 'Typedef'])) j['messages'] = walk_defs(s['Define'], True) - j['unions'] = walk_defs([o for o in s['types'] if o.__class__.__name__ == 'Union']) - j['enums'] = walk_enums([o for o in s['types'] if o.__class__.__name__ == 'Enum']) + j['unions'] = (walk_defs([o for o in s['types'] + if o.__class__.__name__ == 'Union'])) + j['enums'] = (walk_enums([o for o in s['types'] + if o.__class__.__name__ == 'Enum'])) j['services'] = walk_services(s['Service']) j['options'] = s['Option'] - j['aliases'] = s['Alias'] + j['aliases'] = {k: v.alias for k, v in s['Alias'].items()} j['vl_api_version'] = hex(s['file_crc']) return json.dumps(j, indent=4, separators=(',', ': ')) diff --git a/src/tools/vppapitrace/vppapitrace.py b/src/tools/vppapitrace/vppapitrace.py index 640b820d994..8089b3a2236 100755 --- a/src/tools/vppapitrace/vppapitrace.py +++ b/src/tools/vppapitrace/vppapitrace.py @@ -102,6 +102,7 @@ def unserialize_msgtbl(data, offset): def serialize_msgtbl(messages): offset = 0 + # XXX 100K? data = bytearray(100000) nmsg = len(messages) data = struct.pack(">I", nmsg) @@ -380,8 +381,8 @@ def generate(args): filename, file_extension = os.path.splitext(args.input) input_type = JSON if file_extension == '.json' else APITRACE - filename, file_extension = os.path.splitext(args.output) + if args.todump: output_type = DUMP else: @@ -395,7 +396,7 @@ def generate(args): if input_type == output_type: sys.exit("error: Nothing to convert between") - if input_type == JSON and output_type == APITRACE: + if input_type != JSON and output_type == APITRACE: sys.exit("error: Input file must be JSON file: {}".format(args.input)) messages, services = init_api(args.apidir) @@ -407,11 +408,11 @@ def generate(args): i += 1 n, result = json2apitrace(messages, args.input) + msgtbl = serialize_msgtbl(messages) + print('API messages: {}'.format(n)) - header = struct.pack(">IIB", n, len(messages), 0) + header = struct.pack(">IIB", n, len(msgtbl), 0) - i = 0 - msgtbl = serialize_msgtbl(messages) with open(args.output, 'wb') as outfile: outfile.write(header) outfile.write(msgtbl) diff --git a/src/vat/api_format.c b/src/vat/api_format.c index f8af24b0ea7..5823055221f 100644 --- a/src/vat/api_format.c +++ b/src/vat/api_format.c @@ -86,6 +86,8 @@ #define __plugin_msg_base 0 #include <vlibapi/vat_helper_macros.h> +#include <vnet/format_fns.h> + void vl_api_set_elog_main (elog_main_t * m); int vl_api_set_elog_trace_api_messages (int enable); diff --git a/src/vlibapi/api_shared.c b/src/vlibapi/api_shared.c index ce7c4aec712..1e7f5c420c6 100644 --- a/src/vlibapi/api_shared.c +++ b/src/vlibapi/api_shared.c @@ -249,7 +249,6 @@ vl_msg_api_trace_save (api_main_t * am, vl_api_trace_which_t which, FILE * fp) fh.wrapped = tp->wrapped; fh.nitems = clib_host_to_net_u32 (vec_len (tp->traces)); u8 *m = vl_api_serialize_message_table (am, 0); - clib_warning ("Message table length %d", vec_len (m)); fh.msgtbl_size = clib_host_to_net_u32 (vec_len (m)); if (fwrite (&fh, sizeof (fh), 1, fp) != 1) @@ -1059,7 +1058,8 @@ vl_msg_pop_heap (void *oldheap) int vl_api_to_api_string (u32 len, const char *buf, vl_api_string_t * str) { - clib_memcpy_fast (str->buf, buf, len); + if (len) + clib_memcpy_fast (str->buf, buf, len); str->length = htonl (len); return len + sizeof (u32); } @@ -1086,6 +1086,14 @@ vl_api_string_len (vl_api_string_t * astr) return clib_net_to_host_u32 (astr->length); } +u8 * +vl_api_format_string (u8 * s, va_list * args) +{ + vl_api_string_t *a = va_arg (*args, vl_api_string_t *); + vec_add (s, a->buf, clib_net_to_host_u32 (a->length)); + return s; +} + /* * Returns a new vector. Remember to free it after use. */ diff --git a/src/vlibapi/api_types.h b/src/vlibapi/api_types.h index 04f84a5f908..8cd47bb770f 100644 --- a/src/vlibapi/api_types.h +++ b/src/vlibapi/api_types.h @@ -21,7 +21,7 @@ #define included_api_types_h #include <stdbool.h> - +#include <stdarg.h> #include <vppinfra/types.h> #include <arpa/inet.h> #include <string.h> @@ -43,6 +43,7 @@ extern int vl_api_vec_to_api_string (const u8 *vec, vl_api_string_t * str); extern u8 * vl_api_from_api_string (vl_api_string_t * astr); extern u32 vl_api_string_len (vl_api_string_t * astr); extern u8 * vl_api_from_api_to_vec (vl_api_string_t *astr); +extern u8 *vl_api_format_string (u8 *s, va_list *args); #ifdef __cplusplus } diff --git a/src/vlibmemory/vlib_api_cli.c b/src/vlibmemory/vlib_api_cli.c index 0d5ce96fbdf..08db458612f 100755 --- a/src/vlibmemory/vlib_api_cli.c +++ b/src/vlibmemory/vlib_api_cli.c @@ -548,7 +548,8 @@ vl_msg_api_process_file (vlib_main_t * vm, u8 * filename, * Endian swap if needed. All msg data is supposed to be in * network byte order. */ - if ((which == DUMP && clib_arch_is_little_endian)) + if (((which == DUMP || which == CUSTOM_DUMP) + && clib_arch_is_little_endian)) { void (*endian_fp) (void *); if (msg_id >= vec_len (am->msg_endian_handlers) diff --git a/src/vnet/ethernet/ethernet_format_fns.h b/src/vnet/ethernet/ethernet_format_fns.h new file mode 100644 index 00000000000..17b5737913e --- /dev/null +++ b/src/vnet/ethernet/ethernet_format_fns.h @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2019 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef included_ethernet_format_fns_h +#define included_ethernet_format_fns_h + +static inline u8 * +format_vl_api_mac_address_t (u8 * s, va_list * args) +{ + u8 *a = va_arg (*args, u8 *); + return format (s, "%02x%02x.%02x%02x.%02x%02x", + a[0], a[1], a[2], a[3], a[4], a[5]); +} + +#endif diff --git a/src/vnet/ethernet/ethernet_types.api b/src/vnet/ethernet/ethernet_types.api index f945f20910f..1d6683ef398 100644 --- a/src/vnet/ethernet/ethernet_types.api +++ b/src/vnet/ethernet/ethernet_types.api @@ -14,4 +14,4 @@ * limitations under the License. */ -typedef u8 mac_address[6]; +manual_print typedef u8 mac_address[6]; diff --git a/src/vnet/format_fns.h b/src/vnet/format_fns.h new file mode 100644 index 00000000000..b88cb53f233 --- /dev/null +++ b/src/vnet/format_fns.h @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2019 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef included_format_fns_h +#define included_format_fns_h + +#include <vnet/ip/format.h> +#include <vnet/ip/ip_format_fns.h> +#include <vnet/ethernet/ethernet_format_fns.h> + +#endif diff --git a/src/vnet/interface_api.c b/src/vnet/interface_api.c index 3448c6037b7..687f599b616 100644 --- a/src/vnet/interface_api.c +++ b/src/vnet/interface_api.c @@ -166,8 +166,10 @@ vl_api_sw_interface_set_mtu_t_handler (vl_api_sw_interface_set_mtu_t * mp) VALIDATE_SW_IF_INDEX (mp); for (i = 0; i < VNET_N_MTU; i++) - per_protocol_mtu[i] = ntohl (mp->mtu[i]); - + { + per_protocol_mtu[i] = ntohl (mp->mtu[i]); + clib_warning ("MTU %u", per_protocol_mtu[i]); + } vnet_sw_interface_set_protocol_mtu (vnm, sw_if_index, per_protocol_mtu); BAD_SW_IF_INDEX_LABEL; diff --git a/src/vnet/ip/ip4_forward.c b/src/vnet/ip/ip4_forward.c index 3562f501bf7..2250e0385bc 100644 --- a/src/vnet/ip/ip4_forward.c +++ b/src/vnet/ip/ip4_forward.c @@ -736,9 +736,11 @@ ip4_add_del_interface_address_internal (vlib_main_t * vm, return clib_error_create - ("failed to add %U which conflicts with %U for interface %U", + ("failed to add %U on %U which conflicts with %U for interface %U", format_ip4_address_and_length, address, address_length, + format_vnet_sw_if_index_name, vnm, + sw_if_index, format_ip4_address_and_length, x, ia->address_length, format_vnet_sw_if_index_name, vnm, diff --git a/src/vnet/ip/ip_api.c b/src/vnet/ip/ip_api.c index fd4c1521a22..8dbd3e6ce12 100644 --- a/src/vnet/ip/ip_api.c +++ b/src/vnet/ip/ip_api.c @@ -66,6 +66,7 @@ #include <vlibapi/api_helper_macros.h> +#include <vnet/format_fns.h> #define foreach_ip_api_msg \ _(IP_TABLE_DUMP, ip_table_dump) \ diff --git a/src/vnet/ip/ip_format_fns.h b/src/vnet/ip/ip_format_fns.h new file mode 100644 index 00000000000..b24c59454d4 --- /dev/null +++ b/src/vnet/ip/ip_format_fns.h @@ -0,0 +1,86 @@ +/* + * Copyright (c) 2019 Cisco and/or its affiliates. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef included_ip_format_fns_h +#define included_ip_format_fns_h + +static inline u8 *format_vl_api_ip6_address_t (u8 * s, va_list * args); +static inline u8 *format_vl_api_ip4_address_t (u8 * s, va_list * args); + +#include <vnet/ip/format.h> +#define vl_typedefs +#include <vnet/ip/ip_types.api.h> + +static inline u8 * +format_vl_api_ip6_address_t (u8 * s, va_list * args) +{ + vl_api_ip6_address_t *a = va_arg (*args, vl_api_ip6_address_t *); + u32 indent __attribute__((unused)) = va_arg (*args, u32); + + return format (s, "%U", format_ip6_address, a); +} + +static inline u8 * +format_vl_api_ip6_prefix_t (u8 * s, va_list * args) +{ + vl_api_ip6_prefix_t *a = va_arg (*args, vl_api_ip6_prefix_t *); + u32 indent __attribute__((unused)) = va_arg (*args, u32); + + return format (s, "%U/%u", format_ip6_address, &a->address, a->len); +} + +static inline u8 * +format_vl_api_ip4_address_t (u8 * s, va_list * args) +{ + vl_api_ip4_address_t *a = va_arg (*args, vl_api_ip4_address_t *); + u32 indent __attribute__((unused)) = va_arg (*args, u32); + + return format (s, "%U", format_ip4_address, a); +} + +static inline u8 * +format_vl_api_ip4_prefix_t (u8 * s, va_list * args) +{ + vl_api_ip4_prefix_t *a = va_arg (*args, vl_api_ip4_prefix_t *); + u32 indent __attribute__((unused)) = va_arg (*args, u32); + + return format (s, "%U/%u", format_ip4_address, &a->address, a->len); +} + +static inline u8 * +format_vl_api_address_t (u8 * s, va_list * args) +{ + vl_api_address_t *a = va_arg (*args, vl_api_address_t *); + u32 indent __attribute__((unused)) = va_arg (*args, u32); + + switch (a->af) { + case ADDRESS_IP4: + return format(s, "%U", format_ip4_address, &a->un.ip4); + case ADDRESS_IP6: + return format(s, "%U", format_ip6_address, &a->un.ip6); + } + return format (s, ""); +} + +static inline u8 * +format_vl_api_prefix_t (u8 * s, va_list * args) +{ + vl_api_prefix_t *a = va_arg (*args, vl_api_prefix_t *); + u32 indent __attribute__((unused)) = va_arg (*args, u32); + + return format (s, "%U/%u", format_vl_api_address_t, &a->address, indent, a->len); +} + +#endif diff --git a/src/vnet/ip/ip_types.api b/src/vnet/ip/ip_types.api index af8f6231285..d9ad893412d 100644 --- a/src/vnet/ip/ip_types.api +++ b/src/vnet/ip/ip_types.api @@ -14,8 +14,9 @@ * limitations under the License. */ -typedef u8 ip4_address[4]; -typedef u8 ip6_address[16]; +option version = "3.0.0"; +manual_print typedef u8 ip4_address[4]; +manual_print typedef u8 ip6_address[16]; enum address_family { ADDRESS_IP4 = 0, @@ -80,12 +81,12 @@ union address_union { vl_api_ip6_address_t ip6; }; -typedef address { +manual_print typedef address { vl_api_address_family_t af; vl_api_address_union_t un; }; -typedef prefix { +manual_print typedef prefix { vl_api_address_t address; u8 len; }; @@ -97,12 +98,12 @@ typedef mprefix { vl_api_address_union_t src_address; }; -typedef ip6_prefix { +manual_print typedef ip6_prefix { vl_api_ip6_address_t address; u8 len; }; -typedef ip4_prefix { +manual_print typedef ip4_prefix { vl_api_ip4_address_t address; u8 len; }; diff --git a/src/vnet/vnet_all_api_h.h b/src/vnet/vnet_all_api_h.h index ad6dd6a8d79..83991106c8b 100644 --- a/src/vnet/vnet_all_api_h.h +++ b/src/vnet/vnet_all_api_h.h @@ -29,6 +29,10 @@ #include <vlibmemory/vl_memory_api_h.h> #endif /* included_from_layer_3 */ +#ifdef vl_printfun +#include <vnet/format_fns.h> +#endif + #include <vnet/bonding/bond.api.h> #include <vnet/devices/af_packet/af_packet.api.h> #include <vnet/devices/netmap/netmap.api.h> diff --git a/src/vpp-api/python/vpp_papi/vpp_serializer.py b/src/vpp-api/python/vpp_papi/vpp_serializer.py index ec6a06bb3d5..443dd83ba68 100644 --- a/src/vpp-api/python/vpp_papi/vpp_serializer.py +++ b/src/vpp-api/python/vpp_papi/vpp_serializer.py @@ -143,8 +143,8 @@ class String(object): return '', 0 p = BaseTypes('u8', length) x, size = p.unpack(data, offset + length_field_size) - x2 = x.split(b'\0', 1)[0] - return (x2.decode('utf8'), size + length_field_size) + #x2 = x.split(b'\0', 1)[0] + return (x.decode('ascii', errors='replace'), size + length_field_size) types = {'u8': BaseTypes('u8'), 'u16': BaseTypes('u16'), diff --git a/src/vpp/api/custom_dump.c b/src/vpp/api/custom_dump.c index a96ffd0cde0..36ffe5ef53d 100644 --- a/src/vpp/api/custom_dump.c +++ b/src/vpp/api/custom_dump.c @@ -53,6 +53,8 @@ #include <vnet/bonding/node.h> +#include <vnet/format_fns.h> + #define vl_typedefs /* define message structures */ #include <vpp/api/vpe_all_api_h.h> #undef vl_typedefs @@ -88,7 +90,7 @@ static void *vl_api_create_loopback_instance_t_print s = format (0, "SCRIPT: create_loopback "); s = format (s, "mac %U ", format_ethernet_address, &mp->mac_address); - s = format (s, "instance %d ", ntohl (mp->user_instance)); + s = format (s, "instance %d ", mp->user_instance); FINISH; } @@ -99,7 +101,7 @@ static void *vl_api_delete_loopback_t_print u8 *s; s = format (0, "SCRIPT: delete_loopback "); - s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index)); + s = format (s, "sw_if_index %d ", mp->sw_if_index); FINISH; } @@ -110,9 +112,9 @@ static void *vl_api_sw_interface_set_flags_t_print u8 *s; s = format (0, "SCRIPT: sw_interface_set_flags "); - s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index)); + s = format (s, "sw_if_index %d ", mp->sw_if_index); - if (ntohl (mp->flags) & IF_STATUS_API_FLAG_ADMIN_UP) + if ((mp->flags) & IF_STATUS_API_FLAG_ADMIN_UP) s = format (s, "admin-up "); else s = format (s, "admin-down "); @@ -127,13 +129,13 @@ __clib_unused u8 *s; s = format (0, "SCRIPT: sw_interface_set_rx_placement "); - s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index)); + s = format (s, "sw_if_index %d ", mp->sw_if_index); - s = format (s, "queue %d ", ntohl (mp->queue_id)); + s = format (s, "queue %d ", mp->queue_id); if (mp->is_main) s = format (s, "main "); else - s = format (s, "worker %d ", ntohl (mp->worker_id)); + s = format (s, "worker %d ", mp->worker_id); FINISH; } @@ -142,7 +144,7 @@ static void *vl_api_sw_interface_rx_placement_dump_t_print (vl_api_sw_interface_rx_placement_dump_t * mp, void *handle) { u8 *s; - u32 sw_if_index = ntohl (mp->sw_if_index); + u32 sw_if_index = (mp->sw_if_index); s = format (0, "SCRIPT: sw_interface_rx_placement_dump "); @@ -158,14 +160,14 @@ static void *vl_api_sw_interface_event_t_print u8 *s; s = format (0, "SCRIPT: sw_interface_event "); - s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index)); + s = format (s, "sw_if_index %d ", (mp->sw_if_index)); - if (ntohl (mp->flags) & IF_STATUS_API_FLAG_ADMIN_UP) + if ((mp->flags) & IF_STATUS_API_FLAG_ADMIN_UP) s = format (s, "admin-up "); else s = format (s, "admin-down "); - if (ntohl (mp->flags) & IF_STATUS_API_FLAG_LINK_UP) + if ((mp->flags) & IF_STATUS_API_FLAG_LINK_UP) s = format (s, "link-up"); else s = format (s, "link-down"); @@ -176,23 +178,15 @@ static void *vl_api_sw_interface_event_t_print FINISH; } + static void *vl_api_sw_interface_add_del_address_t_print (vl_api_sw_interface_add_del_address_t * mp, void *handle) { u8 *s; - ip46_address_t address; s = format (0, "SCRIPT: sw_interface_add_del_address "); - - s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index)); - - if (ip_address_decode (&mp->prefix.address, &address) == IP46_TYPE_IP6) - s = format (s, "%U/%d ", format_ip6_address, - (ip6_address_t *) & address.ip6, mp->prefix.len); - else - s = format (s, "%U/%d ", format_ip4_address, - (ip4_address_t *) & address.ip4, mp->prefix.len); - + s = format (s, "sw_if_index %d ", mp->sw_if_index); + s = format (s, "%U ", format_vl_api_prefix_t, &mp->prefix); if (mp->is_add == 0) s = format (s, "del "); if (mp->del_all) @@ -208,10 +202,10 @@ static void *vl_api_sw_interface_set_table_t_print s = format (0, "SCRIPT: sw_interface_set_table "); - s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index)); + s = format (s, "sw_if_index %d ", (mp->sw_if_index)); if (mp->vrf_id) - s = format (s, "vrf %d ", ntohl (mp->vrf_id)); + s = format (s, "vrf %d ", (mp->vrf_id)); if (mp->is_ipv6) s = format (s, "ipv6 "); @@ -226,7 +220,7 @@ static void *vl_api_sw_interface_set_mpls_enable_t_print s = format (0, "SCRIPT: sw_interface_set_mpls_enable "); - s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index)); + s = format (s, "sw_if_index %d ", (mp->sw_if_index)); if (mp->enable == 0) s = format (s, "disable"); @@ -241,7 +235,7 @@ static void *vl_api_sw_interface_set_vpath_t_print s = format (0, "SCRIPT: sw_interface_set_vpath "); - s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index)); + s = format (s, "sw_if_index %d ", (mp->sw_if_index)); if (mp->enable) s = format (s, "enable "); @@ -258,7 +252,7 @@ static void *vl_api_sw_interface_set_vxlan_bypass_t_print s = format (0, "SCRIPT: sw_interface_set_vxlan_bypass "); - s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index)); + s = format (s, "sw_if_index %d ", (mp->sw_if_index)); if (mp->is_ipv6) s = format (s, "ip6 "); @@ -278,7 +272,7 @@ static void *vl_api_sw_interface_set_geneve_bypass_t_print s = format (0, "SCRIPT: sw_interface_set_geneve_bypass "); - s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index)); + s = format (s, "sw_if_index %d ", (mp->sw_if_index)); if (mp->is_ipv6) s = format (s, "ip6 "); @@ -298,11 +292,11 @@ static void *vl_api_sw_interface_set_l2_xconnect_t_print s = format (0, "SCRIPT: sw_interface_set_l2_xconnect "); - s = format (s, "sw_if_index %d ", ntohl (mp->rx_sw_if_index)); + s = format (s, "sw_if_index %d ", (mp->rx_sw_if_index)); if (mp->enable) { - s = format (s, "tx_sw_if_index %d ", ntohl (mp->tx_sw_if_index)); + s = format (s, "tx_sw_if_index %d ", (mp->tx_sw_if_index)); } else s = format (s, "delete "); @@ -317,14 +311,14 @@ static void *vl_api_sw_interface_set_l2_bridge_t_print s = format (0, "SCRIPT: sw_interface_set_l2_bridge "); - s = format (s, "sw_if_index %d ", ntohl (mp->rx_sw_if_index)); + s = format (s, "sw_if_index %d ", (mp->rx_sw_if_index)); if (mp->enable) { - s = format (s, "bd_id %d shg %d ", ntohl (mp->bd_id), mp->shg); - if (L2_API_PORT_TYPE_BVI == ntohl (mp->port_type)) + s = format (s, "bd_id %d shg %d ", (mp->bd_id), mp->shg); + if (L2_API_PORT_TYPE_BVI == (mp->port_type)) s = format (s, "bvi "); - if (L2_API_PORT_TYPE_UU_FWD == ntohl (mp->port_type)) + if (L2_API_PORT_TYPE_UU_FWD == (mp->port_type)) s = format (s, "uu-fwd "); s = format (s, "enable"); } @@ -341,7 +335,7 @@ static void *vl_api_bridge_domain_add_del_t_print s = format (0, "SCRIPT: bridge_domain_add_del "); - s = format (s, "bd_id %d ", ntohl (mp->bd_id)); + s = format (s, "bd_id %d ", (mp->bd_id)); if (mp->is_add) { @@ -364,7 +358,7 @@ static void *vl_api_bridge_domain_set_mac_age_t_print s = format (0, "SCRIPT: bridge_domain_set_mac_age "); - s = format (s, "bd_id %d ", ntohl (mp->bd_id)); + s = format (s, "bd_id %d ", (mp->bd_id)); s = format (s, "mac-age %d", mp->mac_age); @@ -375,7 +369,7 @@ static void *vl_api_bridge_domain_dump_t_print (vl_api_bridge_domain_dump_t * mp, void *handle) { u8 *s; - u32 bd_id = ntohl (mp->bd_id); + u32 bd_id = (mp->bd_id); s = format (0, "SCRIPT: bridge_domain_dump "); @@ -400,7 +394,7 @@ static void *vl_api_l2fib_flush_bd_t_print (vl_api_l2fib_flush_bd_t * mp, void *handle) { u8 *s; - u32 bd_id = ntohl (mp->bd_id); + u32 bd_id = (mp->bd_id); s = format (0, "SCRIPT: l2fib_flush_bd "); s = format (s, "bd_id %d ", bd_id); @@ -412,7 +406,7 @@ static void *vl_api_l2fib_flush_int_t_print (vl_api_l2fib_flush_int_t * mp, void *handle) { u8 *s; - u32 sw_if_index = ntohl (mp->sw_if_index); + u32 sw_if_index = (mp->sw_if_index); s = format (0, "SCRIPT: l2fib_flush_int "); s = format (s, "sw_if_index %d ", sw_if_index); @@ -429,12 +423,12 @@ static void *vl_api_l2fib_add_del_t_print s = format (s, "mac %U ", format_ethernet_address, mp->mac); - s = format (s, "bd_id %d ", ntohl (mp->bd_id)); + s = format (s, "bd_id %d ", (mp->bd_id)); if (mp->is_add) { - s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index)); + s = format (s, "sw_if_index %d ", (mp->sw_if_index)); if (mp->static_mac) s = format (s, "%s", "static "); if (mp->filter_mac) @@ -454,11 +448,11 @@ static void * vl_api_l2_flags_t_print (vl_api_l2_flags_t * mp, void *handle) { u8 *s; - u32 flags = ntohl (mp->feature_bitmap); + u32 flags = (mp->feature_bitmap); s = format (0, "SCRIPT: l2_flags "); - s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index)); + s = format (s, "sw_if_index %d ", (mp->sw_if_index)); if (flags & L2_LEARN) s = format (s, "learn "); @@ -481,11 +475,11 @@ static void *vl_api_bridge_flags_t_print (vl_api_bridge_flags_t * mp, void *handle) { u8 *s; - u32 flags = ntohl (mp->flags); + u32 flags = (mp->flags); s = format (0, "SCRIPT: bridge_flags "); - s = format (s, "bd_id %d ", ntohl (mp->bd_id)); + s = format (s, "bd_id %d ", (mp->bd_id)); if (flags & BRIDGE_API_FLAG_LEARN) s = format (s, "learn "); @@ -510,7 +504,7 @@ static void *vl_api_bd_ip_mac_add_del_t_print u8 *s; s = format (0, "SCRIPT: bd_ip_mac_add_del "); - s = format (s, "bd_id %d ", ntohl (mp->entry.bd_id)); + s = format (s, "bd_id %d ", (mp->entry.bd_id)); s = format (s, "%U ", format_vl_api_address, &mp->entry.ip); s = format (s, "%U ", format_vl_api_mac_address, &mp->entry.mac); @@ -526,7 +520,7 @@ static void *vl_api_bd_ip_mac_flush_t_print u8 *s; s = format (0, "SCRIPT: bd_ip_mac_flush "); - s = format (s, "bd_id %d ", ntohl (mp->bd_id)); + s = format (s, "bd_id %d ", (mp->bd_id)); FINISH; } @@ -551,7 +545,7 @@ static void *vl_api_tap_create_v2_t_print clib_memset (null_mac, 0, sizeof (null_mac)); s = format (0, "SCRIPT: tap_create_v2 "); - s = format (s, "id %u ", ntohl (mp->id)); + s = format (s, "id %u ", (mp->id)); if (memcmp (mp->mac_address, null_mac, 6)) s = format (s, "mac-address %U ", format_ethernet_address, mp->mac_address); @@ -575,12 +569,12 @@ static void *vl_api_tap_create_v2_t_print if (mp->host_ip6_gw_set) s = format (s, "host-ip6-gw %U ", format_ip6_address, mp->host_ip6_addr); if (mp->tx_ring_sz) - s = format (s, "tx-ring-size %u ", ntohs (mp->tx_ring_sz)); + s = format (s, "tx-ring-size %u ", (mp->tx_ring_sz)); if (mp->rx_ring_sz) - s = format (s, "rx-ring-size %u ", ntohs (mp->rx_ring_sz)); + s = format (s, "rx-ring-size %u ", (mp->rx_ring_sz)); if (mp->host_mtu_set) - s = format (s, "host-mtu-size %u ", ntohl (mp->host_mtu_size)); - if (ntohl (mp->tap_flags) & 0x1) + s = format (s, "host-mtu-size %u ", (mp->host_mtu_size)); + if ((mp->tap_flags) & 0x1) s = format (s, "gso-enabled"); FINISH; } @@ -591,7 +585,7 @@ static void *vl_api_tap_delete_v2_t_print u8 *s; s = format (0, "SCRIPT: tap_delete_v2 "); - s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index)); + s = format (s, "sw_if_index %d ", (mp->sw_if_index)); FINISH; } @@ -616,7 +610,7 @@ __clib_unused clib_memset (null_mac, 0, sizeof (null_mac)); s = format (0, "SCRIPT: virtio_pci_create "); - s = format (s, "pci_addr %U ", format_vlib_pci_addr, ntohl (mp->pci_addr)); + s = format (s, "pci_addr %U ", format_vlib_pci_addr, (mp->pci_addr)); if (memcmp (mp->mac_address, null_mac, 6)) s = format (s, "mac-address %U ", format_ethernet_address, mp->mac_address); @@ -634,7 +628,7 @@ __clib_unused u8 *s; s = format (0, "SCRIPT: virtio_pci_delete "); - s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index)); + s = format (s, "sw_if_index %d ", (mp->sw_if_index)); FINISH; } @@ -669,7 +663,7 @@ static void *vl_api_bond_create_t_print if (mp->numa_only) s = format (s, "numa-only is set in lacp mode"); if (mp->id != ~0) - s = format (s, "id %u ", ntohl (mp->id)); + s = format (s, "id %u ", (mp->id)); FINISH; } @@ -679,7 +673,7 @@ static void *vl_api_bond_delete_t_print u8 *s; s = format (0, "SCRIPT: bond_delete "); - s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index)); + s = format (s, "sw_if_index %d ", (mp->sw_if_index)); FINISH; } @@ -690,8 +684,8 @@ static void *vl_api_bond_enslave_t_print u8 *s; s = format (0, "SCRIPT: bond_enslave "); - s = format (s, "bond_sw_if_index %u ", ntohl (mp->bond_sw_if_index)); - s = format (s, "sw_if_index %u ", ntohl (mp->sw_if_index)); + s = format (s, "bond_sw_if_index %u ", (mp->bond_sw_if_index)); + s = format (s, "sw_if_index %u ", (mp->sw_if_index)); if (mp->is_passive) s = format (s, "passive "); if (mp->is_long_timeout) @@ -718,7 +712,7 @@ static void *vl_api_bond_detach_slave_t_print u8 *s; s = format (0, "SCRIPT: bond_detach_slave "); - s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index)); + s = format (s, "sw_if_index %d ", (mp->sw_if_index)); FINISH; } @@ -739,7 +733,7 @@ static void *vl_api_sw_interface_slave_dump_t_print u8 *s; s = format (0, "SCRIPT: sw_interface_slave_dump "); - s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index)); + s = format (s, "sw_if_index %d ", (mp->sw_if_index)); FINISH; } @@ -773,8 +767,8 @@ static void *vl_api_mpls_route_add_del_t_print else s = format (s, "del "); - s = format (s, "table %d ", ntohl (mp->mr_route.mr_table_id)); - s = format (s, "%d ", ntohl (mp->mr_route.mr_label)); + s = format (s, "table %d ", (mp->mr_route.mr_table_id)); + s = format (s, "%d ", (mp->mr_route.mr_label)); if (mp->mr_route.mr_eos) s = format (s, "eos "); @@ -804,7 +798,7 @@ static void *vl_api_ip_table_add_del_t_print s = format (s, "del "); if (mp->table.is_ip6) s = format (s, "ip6 "); - s = format (s, "table %d ", ntohl (mp->table.table_id)); + s = format (s, "table %d ", (mp->table.table_id)); s = format (s, "%s ", mp->table.name); FINISH; @@ -820,7 +814,7 @@ static void *vl_api_mpls_table_add_del_t_print s = format (s, "add "); else s = format (s, "del "); - s = format (s, "table %d ", ntohl (mp->mt_table.mt_table_id)); + s = format (s, "table %d ", (mp->mt_table.mt_table_id)); FINISH; } @@ -836,7 +830,7 @@ static void *vl_api_proxy_arp_add_del_t_print format_vl_api_ip4_address, mp->proxy.low, format_vl_api_ip4_address, mp->proxy.hi); - s = format (s, "table %d ", ntohl (mp->proxy.table_id)); + s = format (s, "table %d ", (mp->proxy.table_id)); if (mp->is_add == 0) s = format (s, "del "); @@ -851,7 +845,7 @@ static void *vl_api_proxy_arp_intfc_enable_disable_t_print s = format (0, "SCRIPT: proxy_arp_intfc_enable_disable "); - s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index)); + s = format (s, "sw_if_index %d ", (mp->sw_if_index)); s = format (s, "enable %d ", mp->enable_disable); @@ -866,10 +860,9 @@ static void *vl_api_mpls_tunnel_add_del_t_print s = format (0, "SCRIPT: mpls_tunnel_add_del "); if (mp->mt_is_add == 0) - s = - format (s, "del sw_if_index %d ", ntohl (mp->mt_tunnel.mt_sw_if_index)); + s = format (s, "del sw_if_index %d ", (mp->mt_tunnel.mt_sw_if_index)); else - s = format (s, "sw_if_index %d ", ntohl (mp->mt_tunnel.mt_sw_if_index)); + s = format (s, "sw_if_index %d ", (mp->mt_tunnel.mt_sw_if_index)); if (mp->mt_tunnel.mt_l2_only) @@ -893,10 +886,10 @@ static void *vl_api_sr_mpls_policy_add_t_print s = format (0, "SCRIPT: sr_mpls_policy_add "); - s = format (s, "bsid %d ", ntohl (mp->bsid)); + s = format (s, "bsid %d ", (mp->bsid)); if (mp->weight != htonl ((u32) 1)) - s = format (s, "%d ", ntohl (mp->weight)); + s = format (s, "%d ", (mp->weight)); if (mp->type) s = format (s, "spray "); @@ -905,7 +898,7 @@ static void *vl_api_sr_mpls_policy_add_t_print { int i; for (i = 0; i < mp->n_segments; i++) - s = format (s, "next %d ", ntohl (mp->segments[i])); + s = format (s, "next %d ", (mp->segments[i])); } FINISH; @@ -918,7 +911,7 @@ static void *vl_api_sr_mpls_policy_del_t_print s = format (0, "SCRIPT: sr_mpls_policy_del "); - s = format (s, "bsid %d ", ntohl (mp->bsid)); + s = format (s, "bsid %d ", (mp->bsid)); FINISH; } @@ -930,9 +923,9 @@ static void *vl_api_sw_interface_set_unnumbered_t_print s = format (0, "SCRIPT: sw_interface_set_unnumbered "); - s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index)); + s = format (s, "sw_if_index %d ", (mp->sw_if_index)); - s = format (s, "unnum_if_index %d ", ntohl (mp->unnumbered_sw_if_index)); + s = format (s, "unnum_if_index %d ", (mp->unnumbered_sw_if_index)); if (mp->is_add == 0) s = format (s, "del "); @@ -947,12 +940,12 @@ static void *vl_api_ip_neighbor_add_del_t_print s = format (0, "SCRIPT: ip_neighbor_add_del "); - s = format (s, "sw_if_index %d ", ntohl (mp->neighbor.sw_if_index)); + s = format (s, "sw_if_index %d ", (mp->neighbor.sw_if_index)); - if (IP_API_NEIGHBOR_FLAG_STATIC & ntohl (mp->neighbor.flags)) + if (IP_API_NEIGHBOR_FLAG_STATIC & (mp->neighbor.flags)) s = format (s, "is_static "); - if (IP_API_NEIGHBOR_FLAG_NO_FIB_ENTRY & ntohl (mp->neighbor.flags)) + if (IP_API_NEIGHBOR_FLAG_NO_FIB_ENTRY & (mp->neighbor.flags)) s = format (s, "is_no_fib_entry "); s = format (s, "mac %U ", format_vl_api_mac_address, @@ -975,10 +968,10 @@ static void *vl_api_create_vlan_subif_t_print s = format (0, "SCRIPT: create_vlan_subif "); if (mp->sw_if_index) - s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index)); + s = format (s, "sw_if_index %d ", (mp->sw_if_index)); if (mp->vlan_id) - s = format (s, "vlan_id %d ", ntohl (mp->vlan_id)); + s = format (s, "vlan_id %d ", (mp->vlan_id)); FINISH; } @@ -1000,15 +993,15 @@ static void *vl_api_create_subif_t_print s = format (0, "SCRIPT: create_subif "); - s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index)); + s = format (s, "sw_if_index %d ", (mp->sw_if_index)); - s = format (s, "sub_id %d ", ntohl (mp->sub_id)); + s = format (s, "sub_id %d ", (mp->sub_id)); if (mp->outer_vlan_id) - s = format (s, "outer_vlan_id %d ", ntohs (mp->outer_vlan_id)); + s = format (s, "outer_vlan_id %d ", (mp->outer_vlan_id)); if (mp->inner_vlan_id) - s = format (s, "inner_vlan_id %d ", ntohs (mp->inner_vlan_id)); + s = format (s, "inner_vlan_id %d ", (mp->inner_vlan_id)); #define _(a,b) if (mp->sub_if_flags & (1 << a)) s = format (s, "%s ", b); foreach_create_subif_flag; @@ -1023,7 +1016,7 @@ static void *vl_api_delete_subif_t_print u8 *s; s = format (0, "SCRIPT: delete_subif "); - s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index)); + s = format (s, "sw_if_index %d ", (mp->sw_if_index)); FINISH; } @@ -1036,7 +1029,7 @@ vl_api_reset_fib_t_print (vl_api_reset_fib_t * mp, void *handle) s = format (0, "SCRIPT: reset_fib "); if (mp->vrf_id) - s = format (s, "vrf %d ", ntohl (mp->vrf_id)); + s = format (s, "vrf %d ", (mp->vrf_id)); if (mp->is_ipv6 != 0) s = format (s, "ipv6 "); @@ -1051,8 +1044,8 @@ static void *vl_api_dhcp_proxy_config_t_print s = format (0, "SCRIPT: dhcp_proxy_config_2 "); - s = format (s, "rx_vrf_id %d ", ntohl (mp->rx_vrf_id)); - s = format (s, "server_vrf_id %d ", ntohl (mp->server_vrf_id)); + s = format (s, "rx_vrf_id %d ", (mp->rx_vrf_id)); + s = format (s, "server_vrf_id %d ", (mp->server_vrf_id)); if (mp->is_ipv6) { @@ -1081,12 +1074,12 @@ static void *vl_api_dhcp_proxy_set_vss_t_print s = format (0, "SCRIPT: dhcp_proxy_set_vss "); - s = format (s, "tbl_id %d ", ntohl (mp->tbl_id)); + s = format (s, "tbl_id %d ", (mp->tbl_id)); if (mp->vss_type == VSS_TYPE_VPN_ID) { - s = format (s, "fib_id %d ", ntohl (mp->vpn_index)); - s = format (s, "oui %d ", ntohl (mp->oui)); + s = format (s, "fib_id %d ", (mp->vpn_index)); + s = format (s, "oui %d ", (mp->oui)); } else if (mp->vss_type == VSS_TYPE_ASCII) s = format (s, "vpn_ascii_id %s", mp->vpn_ascii_id); @@ -1107,13 +1100,13 @@ static void *vl_api_dhcp_client_config_t_print s = format (0, "SCRIPT: dhcp_client_config "); - s = format (s, "sw_if_index %d ", ntohl (mp->client.sw_if_index)); + s = format (s, "sw_if_index %d ", (mp->client.sw_if_index)); s = format (s, "hostname %s ", mp->client.hostname); s = format (s, "want_dhcp_event %d ", mp->client.want_dhcp_event); - s = format (s, "pid %d ", ntohl (mp->client.pid)); + s = format (s, "pid %d ", (mp->client.pid)); if (mp->is_add == 0) s = format (s, "del "); @@ -1129,7 +1122,7 @@ static void *vl_api_set_ip_flow_hash_t_print s = format (0, "SCRIPT: set_ip_flow_hash "); - s = format (s, "vrf_id %d ", ntohl (mp->vrf_id)); + s = format (s, "vrf_id %d ", (mp->vrf_id)); if (mp->src) s = format (s, "src "); @@ -1162,13 +1155,13 @@ static void *vl_api_sw_interface_ip6nd_ra_prefix_t_print s = format (0, "SCRIPT: sw_interface_ip6nd_ra_prefix "); - s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index)); + s = format (s, "sw_if_index %d ", (mp->sw_if_index)); s = format (s, "%U ", format_vl_api_prefix, &mp->prefix); - s = format (s, "val_life %d ", ntohl (mp->val_lifetime)); + s = format (s, "val_life %d ", (mp->val_lifetime)); - s = format (s, "pref_life %d ", ntohl (mp->pref_lifetime)); + s = format (s, "pref_life %d ", (mp->pref_lifetime)); if (mp->use_default) s = format (s, "def "); @@ -1198,17 +1191,17 @@ static void *vl_api_sw_interface_ip6nd_ra_config_t_print s = format (0, "SCRIPT: sw_interface_ip6nd_ra_config "); - s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index)); + s = format (s, "sw_if_index %d ", (mp->sw_if_index)); - s = format (s, "maxint %d ", ntohl (mp->max_interval)); + s = format (s, "maxint %d ", (mp->max_interval)); - s = format (s, "minint %d ", ntohl (mp->min_interval)); + s = format (s, "minint %d ", (mp->min_interval)); - s = format (s, "life %d ", ntohl (mp->lifetime)); + s = format (s, "life %d ", (mp->lifetime)); - s = format (s, "count %d ", ntohl (mp->initial_count)); + s = format (s, "count %d ", (mp->initial_count)); - s = format (s, "interval %d ", ntohl (mp->initial_interval)); + s = format (s, "interval %d ", (mp->initial_interval)); if (mp->suppress) s = format (s, "suppress "); @@ -1244,7 +1237,7 @@ static void *vl_api_set_arp_neighbor_limit_t_print s = format (0, "SCRIPT: set_arp_neighbor_limit "); - s = format (s, "arp_nbr_limit %d ", ntohl (mp->arp_neighbor_limit)); + s = format (s, "arp_nbr_limit %d ", (mp->arp_neighbor_limit)); if (mp->is_ipv6 != 0) s = format (s, "ipv6 "); @@ -1259,9 +1252,9 @@ static void *vl_api_l2_patch_add_del_t_print s = format (0, "SCRIPT: l2_patch_add_del "); - s = format (s, "rx_sw_if_index %d ", ntohl (mp->rx_sw_if_index)); + s = format (s, "rx_sw_if_index %d ", (mp->rx_sw_if_index)); - s = format (s, "tx_sw_if_index %d ", ntohl (mp->tx_sw_if_index)); + s = format (s, "tx_sw_if_index %d ", (mp->tx_sw_if_index)); if (mp->is_add == 0) s = format (s, "del "); @@ -1290,7 +1283,7 @@ static void *vl_api_sr_localsid_add_del_t_print "Address: %U\nBehavior: X (Endpoint with Layer-3 cross-connect)" "\nIface: %U\nNext hop: %U", format_ip6_address, (ip6_address_t *) mp->localsid.addr, - format_vnet_sw_if_index_name, vnm, ntohl (mp->sw_if_index), + format_vnet_sw_if_index_name, vnm, (mp->sw_if_index), format_ip6_address, (ip6_address_t *) mp->nh_addr6); s = format (s, (mp->end_psp ? "End.PSP: True" : "End.PSP: False")); break; @@ -1300,7 +1293,7 @@ static void *vl_api_sr_localsid_add_del_t_print "Address: %U\nBehavior: DX4 (Endpoint with decapsulation with IPv4 cross-connect)" "\nIface: %U\nNext hop: %U", format_ip6_address, (ip6_address_t *) mp->localsid.addr, - format_vnet_sw_if_index_name, vnm, ntohl (mp->sw_if_index), + format_vnet_sw_if_index_name, vnm, (mp->sw_if_index), format_ip4_address, (ip4_address_t *) mp->nh_addr4); break; case SR_BEHAVIOR_DX6: @@ -1309,7 +1302,7 @@ static void *vl_api_sr_localsid_add_del_t_print "Address: %U\nBehavior: DX6 (Endpoint with decapsulation with IPv6 cross-connect)" "\nIface: %UNext hop: %U", format_ip6_address, (ip6_address_t *) mp->localsid.addr, - format_vnet_sw_if_index_name, vnm, ntohl (mp->sw_if_index), + format_vnet_sw_if_index_name, vnm, (mp->sw_if_index), format_ip6_address, (ip6_address_t *) mp->nh_addr6); break; case SR_BEHAVIOR_DX2: @@ -1318,21 +1311,21 @@ static void *vl_api_sr_localsid_add_del_t_print "Address: %U\nBehavior: DX2 (Endpoint with decapulation and Layer-2 cross-connect)" "\nIface: %U", format_ip6_address, (ip6_address_t *) mp->localsid.addr, - format_vnet_sw_if_index_name, vnm, ntohl (mp->sw_if_index)); + format_vnet_sw_if_index_name, vnm, (mp->sw_if_index)); break; case SR_BEHAVIOR_DT6: s = format (s, "Address: %U\nBehavior: DT6 (Endpoint with decapsulation and specific IPv6 table lookup)" "\nTable: %u", format_ip6_address, - (ip6_address_t *) mp->localsid.addr, ntohl (mp->fib_table)); + (ip6_address_t *) mp->localsid.addr, (mp->fib_table)); break; case SR_BEHAVIOR_DT4: s = format (s, "Address: %U\nBehavior: DT4 (Endpoint with decapsulation and specific IPv4 table lookup)" "\nTable: %u", format_ip6_address, - (ip6_address_t *) mp->localsid.addr, ntohl (mp->fib_table)); + (ip6_address_t *) mp->localsid.addr, (mp->fib_table)); break; default: if (mp->behavior >= SR_BEHAVIOR_LAST) @@ -1361,15 +1354,15 @@ static void *vl_api_sr_steering_add_del_t_print switch (mp->traffic_type) { case SR_STEER_L2: - s = format (s, "Traffic type: L2 iface: %u", ntohl (mp->sw_if_index)); + s = format (s, "Traffic type: L2 iface: %u", (mp->sw_if_index)); break; case SR_STEER_IPV4: s = format (s, "Traffic type: IPv4 %U/%u", format_ip4_address, - (ip4_address_t *) mp->prefix_addr, ntohl (mp->mask_width)); + (ip4_address_t *) mp->prefix_addr, (mp->mask_width)); break; case SR_STEER_IPV6: s = format (s, "Traffic type: IPv6 %U/%u", format_ip6_address, - (ip6_address_t *) mp->prefix_addr, ntohl (mp->mask_width)); + (ip6_address_t *) mp->prefix_addr, (mp->mask_width)); break; default: s = format (s, "Traffic type: Unknown(%u)", mp->traffic_type); @@ -1378,9 +1371,9 @@ static void *vl_api_sr_steering_add_del_t_print s = format (s, "BindingSID: %U", format_ip6_address, (ip6_address_t *) mp->bsid_addr); - s = format (s, "SR Policy Index: %u", ntohl (mp->sr_policy_index)); + s = format (s, "SR Policy Index: %u", (mp->sr_policy_index)); - s = format (s, "FIB_table: %u", ntohl (mp->table_id)); + s = format (s, "FIB_table: %u", (mp->table_id)); FINISH; } @@ -1411,11 +1404,11 @@ static void *vl_api_sr_policy_add_t_print (mp->is_encap ? "Behavior: Encapsulation" : "Behavior: SRH insertion")); - s = format (s, "FIB_table: %u", ntohl (mp->fib_table)); + s = format (s, "FIB_table: %u", (mp->fib_table)); s = format (s, (mp->type ? "Type: Default" : "Type: Spray")); - s = format (s, "SID list weight: %u", ntohl (mp->weight)); + s = format (s, "SID list weight: %u", (mp->weight)); s = format (s, "{"); vec_foreach (seg, segments) @@ -1448,13 +1441,13 @@ static void *vl_api_sr_policy_mod_t_print s = format (s, "BSID: %U", format_ip6_address, (ip6_address_t *) mp->bsid_addr); - s = format (s, "SR Policy index: %u", ntohl (mp->sr_policy_index)); + s = format (s, "SR Policy index: %u", (mp->sr_policy_index)); s = format (s, "Operation: %u", mp->operation); - s = format (s, "SID list index: %u", ntohl (mp->sl_index)); + s = format (s, "SID list index: %u", (mp->sl_index)); - s = format (s, "SID list weight: %u", ntohl (mp->weight)); + s = format (s, "SID list weight: %u", (mp->weight)); s = format (s, "{"); vec_foreach (seg, segments) @@ -1486,23 +1479,22 @@ static void *vl_api_classify_add_del_table_t_print if (mp->is_add == 0) { - s = format (s, "table %d ", ntohl (mp->table_index)); + s = format (s, "table %d ", (mp->table_index)); s = format (s, "%s ", mp->del_chain ? "del-chain" : "del"); } else { - s = format (s, "nbuckets %d ", ntohl (mp->nbuckets)); - s = format (s, "memory_size %d ", ntohl (mp->memory_size)); - s = format (s, "skip %d ", ntohl (mp->skip_n_vectors)); - s = format (s, "match %d ", ntohl (mp->match_n_vectors)); - s = format (s, "next-table %d ", ntohl (mp->next_table_index)); - s = format (s, "miss-next %d ", ntohl (mp->miss_next_index)); - s = format (s, "current-data-flag %d ", ntohl (mp->current_data_flag)); + s = format (s, "nbuckets %d ", (mp->nbuckets)); + s = format (s, "memory_size %d ", (mp->memory_size)); + s = format (s, "skip %d ", (mp->skip_n_vectors)); + s = format (s, "match %d ", (mp->match_n_vectors)); + s = format (s, "next-table %d ", (mp->next_table_index)); + s = format (s, "miss-next %d ", (mp->miss_next_index)); + s = format (s, "current-data-flag %d ", (mp->current_data_flag)); if (mp->current_data_flag) - s = format (s, "current-data-offset %d ", - ntohl (mp->current_data_offset)); + s = format (s, "current-data-offset %d ", (mp->current_data_offset)); s = format (s, "mask hex "); - for (i = 0; i < ntohl (mp->match_n_vectors) * sizeof (u32x4); i++) + for (i = 0; i < (mp->match_n_vectors) * sizeof (u32x4); i++) s = format (s, "%02x", mp->mask[i]); vec_add1 (s, ' '); } @@ -1518,13 +1510,13 @@ static void *vl_api_classify_add_del_session_t_print s = format (0, "SCRIPT: classify_add_del_session "); - s = format (s, "table_index %d ", ntohl (mp->table_index)); - s = format (s, "hit_next_index %d ", ntohl (mp->hit_next_index)); - s = format (s, "opaque_index %d ", ntohl (mp->opaque_index)); - s = format (s, "advance %d ", ntohl (mp->advance)); + s = format (s, "table_index %d ", (mp->table_index)); + s = format (s, "hit_next_index %d ", (mp->hit_next_index)); + s = format (s, "opaque_index %d ", (mp->opaque_index)); + s = format (s, "advance %d ", (mp->advance)); s = format (s, "action %d ", mp->action); if (mp->action) - s = format (s, "metadata %d ", ntohl (mp->metadata)); + s = format (s, "metadata %d ", (mp->metadata)); if (mp->is_add == 0) s = format (s, "del "); @@ -1554,8 +1546,8 @@ static void *vl_api_classify_set_interface_ip_table_t_print if (mp->is_ipv6) s = format (s, "ipv6 "); - s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index)); - s = format (s, "table %d ", ntohl (mp->table_index)); + s = format (s, "sw_if_index %d ", (mp->sw_if_index)); + s = format (s, "table %d ", (mp->table_index)); FINISH; } @@ -1567,10 +1559,10 @@ static void *vl_api_classify_set_interface_l2_tables_t_print s = format (0, "SCRIPT: classify_set_interface_l2_tables "); - s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index)); - s = format (s, "ip4-table %d ", ntohl (mp->ip4_table_index)); - s = format (s, "ip6-table %d ", ntohl (mp->ip6_table_index)); - s = format (s, "other-table %d ", ntohl (mp->other_table_index)); + s = format (s, "sw_if_index %d ", (mp->sw_if_index)); + s = format (s, "ip4-table %d ", (mp->ip4_table_index)); + s = format (s, "ip6-table %d ", (mp->ip6_table_index)); + s = format (s, "other-table %d ", (mp->other_table_index)); s = format (s, "is-input %d ", mp->is_input); FINISH; @@ -1598,8 +1590,8 @@ static void *vl_api_l2tpv3_create_tunnel_t_print s = format (s, "client_address %U our_address %U ", format_ip6_address, (ip6_address_t *) (mp->client_address), format_ip6_address, (ip6_address_t *) (mp->our_address)); - s = format (s, "local_session_id %d ", ntohl (mp->local_session_id)); - s = format (s, "remote_session_id %d ", ntohl (mp->remote_session_id)); + s = format (s, "local_session_id %d ", (mp->local_session_id)); + s = format (s, "remote_session_id %d ", (mp->remote_session_id)); s = format (s, "local_cookie %lld ", clib_net_to_host_u64 (mp->local_cookie)); s = format (s, "remote_cookie %lld ", @@ -1617,7 +1609,7 @@ static void *vl_api_l2tpv3_set_tunnel_cookies_t_print s = format (0, "SCRIPT: l2tpv3_set_tunnel_cookies "); - s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index)); + s = format (s, "sw_if_index %d ", (mp->sw_if_index)); s = format (s, "new_local_cookie %llu ", clib_net_to_host_u64 (mp->new_local_cookie)); @@ -1635,7 +1627,7 @@ static void *vl_api_l2tpv3_interface_enable_disable_t_print s = format (0, "SCRIPT: l2tpv3_interface_enable_disable "); - s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index)); + s = format (s, "sw_if_index %d ", (mp->sw_if_index)); if (mp->enable_disable == 0) s = format (s, "del "); @@ -1698,16 +1690,16 @@ static void *vl_api_vxlan_add_del_tunnel_t_print &dst, IP46_TYPE_ANY); if (is_grp) - s = format (s, "mcast_sw_if_index %d ", ntohl (mp->mcast_sw_if_index)); + s = format (s, "mcast_sw_if_index %d ", (mp->mcast_sw_if_index)); if (mp->encap_vrf_id) - s = format (s, "encap-vrf-id %d ", ntohl (mp->encap_vrf_id)); + s = format (s, "encap-vrf-id %d ", (mp->encap_vrf_id)); - s = format (s, "decap-next %d ", ntohl (mp->decap_next_index)); + s = format (s, "decap-next %d ", (mp->decap_next_index)); - s = format (s, "vni %d ", ntohl (mp->vni)); + s = format (s, "vni %d ", (mp->vni)); - s = format (s, "instance %d ", ntohl (mp->instance)); + s = format (s, "instance %d ", (mp->instance)); if (mp->is_add == 0) s = format (s, "del "); @@ -1721,8 +1713,8 @@ static void *vl_api_vxlan_offload_rx_t_print u8 *s; s = format (0, "SCRIPT: vxlan_offload_rx "); - s = format (s, "hw hw_if_index %d ", ntohl (mp->hw_if_index)); - s = format (s, "rx sw_if_index %d ", ntohl (mp->sw_if_index)); + s = format (s, "hw hw_if_index %d ", (mp->hw_if_index)); + s = format (s, "rx sw_if_index %d ", (mp->sw_if_index)); if (!mp->enable) s = format (s, "del "); @@ -1736,7 +1728,7 @@ static void *vl_api_vxlan_tunnel_dump_t_print s = format (0, "SCRIPT: vxlan_tunnel_dump "); - s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index)); + s = format (s, "sw_if_index %d ", (mp->sw_if_index)); FINISH; } @@ -1752,14 +1744,13 @@ static void *vl_api_vxlan_gbp_tunnel_add_del_t_print else s = format (s, "del "); - s = format (s, "instance %d ", ntohl (mp->tunnel.instance)); + s = format (s, "instance %d ", (mp->tunnel.instance)); s = format (s, "src %U ", format_vl_api_address, &mp->tunnel.src); s = format (s, "dst %U ", format_vl_api_address, &mp->tunnel.dst); - s = - format (s, "mcast_sw_if_index %d ", ntohl (mp->tunnel.mcast_sw_if_index)); - s = format (s, "encap_table_id %d ", ntohl (mp->tunnel.encap_table_id)); - s = format (s, "vni %d ", ntohl (mp->tunnel.vni)); - s = format (s, "sw_if_index %d ", ntohl (mp->tunnel.sw_if_index)); + s = format (s, "mcast_sw_if_index %d ", (mp->tunnel.mcast_sw_if_index)); + s = format (s, "encap_table_id %d ", (mp->tunnel.encap_table_id)); + s = format (s, "vni %d ", (mp->tunnel.vni)); + s = format (s, "sw_if_index %d ", (mp->tunnel.sw_if_index)); FINISH; } @@ -1771,7 +1762,7 @@ static void *vl_api_vxlan_gbp_tunnel_dump_t_print s = format (0, "SCRIPT: vxlan_gbp_tunnel_dump "); - s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index)); + s = format (s, "sw_if_index %d ", (mp->sw_if_index)); FINISH; } @@ -1783,7 +1774,7 @@ static void *vl_api_sw_interface_set_vxlan_gbp_bypass_t_print s = format (0, "SCRIPT: sw_interface_set_vxlan_gbp_bypass "); - s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index)); + s = format (s, "sw_if_index %d ", (mp->sw_if_index)); s = format (s, "%s ", (mp->is_ipv6 != 0) ? "ipv6" : "ipv4"); s = format (s, "%s ", (mp->enable != 0) ? "enable" : "disable"); @@ -1807,14 +1798,14 @@ static void *vl_api_geneve_add_del_tunnel_t_print &remote, IP46_TYPE_ANY); if (is_grp) - s = format (s, "mcast_sw_if_index %d ", ntohl (mp->mcast_sw_if_index)); + s = format (s, "mcast_sw_if_index %d ", (mp->mcast_sw_if_index)); if (mp->encap_vrf_id) - s = format (s, "encap-vrf-id %d ", ntohl (mp->encap_vrf_id)); + s = format (s, "encap-vrf-id %d ", (mp->encap_vrf_id)); - s = format (s, "decap-next %d ", ntohl (mp->decap_next_index)); + s = format (s, "decap-next %d ", (mp->decap_next_index)); - s = format (s, "vni %d ", ntohl (mp->vni)); + s = format (s, "vni %d ", (mp->vni)); if (mp->is_add == 0) s = format (s, "del "); @@ -1829,7 +1820,7 @@ static void *vl_api_geneve_tunnel_dump_t_print s = format (0, "SCRIPT: geneve_tunnel_dump "); - s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index)); + s = format (s, "sw_if_index %d ", (mp->sw_if_index)); FINISH; } @@ -1844,16 +1835,16 @@ static void *vl_api_gre_tunnel_add_del_t_print s = format (s, "dst %U ", format_vl_api_address, &mp->tunnel.dst); s = format (s, "src %U ", format_vl_api_address, &mp->tunnel.src); - s = format (s, "instance %d ", ntohl (mp->tunnel.instance)); + s = format (s, "instance %d ", (mp->tunnel.instance)); if (mp->tunnel.type == GRE_API_TUNNEL_TYPE_TEB) s = format (s, "teb "); if (mp->tunnel.type == GRE_API_TUNNEL_TYPE_ERSPAN) - s = format (s, "erspan %d ", ntohs (mp->tunnel.session_id)); + s = format (s, "erspan %d ", (mp->tunnel.session_id)); if (mp->tunnel.outer_fib_id) - s = format (s, "outer-fib-id %d ", ntohl (mp->tunnel.outer_fib_id)); + s = format (s, "outer-fib-id %d ", (mp->tunnel.outer_fib_id)); if (mp->is_add == 0) s = format (s, "del "); @@ -1868,7 +1859,7 @@ static void *vl_api_gre_tunnel_dump_t_print s = format (0, "SCRIPT: gre_tunnel_dump "); - s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index)); + s = format (s, "sw_if_index %d ", (mp->sw_if_index)); FINISH; } @@ -1890,7 +1881,7 @@ static void *vl_api_l2_interface_efp_filter_t_print s = format (0, "SCRIPT: l2_interface_efp_filter "); - s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index)); + s = format (s, "sw_if_index %d ", (mp->sw_if_index)); if (mp->enable_disable) s = format (s, "enable "); else @@ -1906,11 +1897,11 @@ static void *vl_api_l2_interface_vlan_tag_rewrite_t_print s = format (0, "SCRIPT: l2_interface_vlan_tag_rewrite "); - s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index)); - s = format (s, "vtr_op %d ", ntohl (mp->vtr_op)); - s = format (s, "push_dot1q %d ", ntohl (mp->push_dot1q)); - s = format (s, "tag1 %d ", ntohl (mp->tag1)); - s = format (s, "tag2 %d ", ntohl (mp->tag2)); + s = format (s, "sw_if_index %d ", (mp->sw_if_index)); + s = format (s, "vtr_op %d ", (mp->vtr_op)); + s = format (s, "push_dot1q %d ", (mp->push_dot1q)); + s = format (s, "tag1 %d ", (mp->tag1)); + s = format (s, "tag2 %d ", (mp->tag2)); FINISH; } @@ -1926,7 +1917,7 @@ static void *vl_api_create_vhost_user_if_t_print if (mp->is_server) s = format (s, "server "); if (mp->renumber) - s = format (s, "renumber %d ", ntohl (mp->custom_dev_instance)); + s = format (s, "renumber %d ", (mp->custom_dev_instance)); if (mp->disable_mrg_rxbuf) s = format (s, "disable_mrg_rxbuf "); if (mp->disable_indirect_desc) @@ -1946,12 +1937,12 @@ static void *vl_api_modify_vhost_user_if_t_print s = format (0, "SCRIPT: modify_vhost_user_if "); - s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index)); + s = format (s, "sw_if_index %d ", (mp->sw_if_index)); s = format (s, "socket %s ", mp->sock_filename); if (mp->is_server) s = format (s, "server "); if (mp->renumber) - s = format (s, "renumber %d ", ntohl (mp->custom_dev_instance)); + s = format (s, "renumber %d ", (mp->custom_dev_instance)); if (mp->enable_gso) s = format (s, "gso"); @@ -1964,7 +1955,7 @@ static void *vl_api_delete_vhost_user_if_t_print u8 *s; s = format (0, "SCRIPT: delete_vhost_user_if "); - s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index)); + s = format (s, "sw_if_index %d ", (mp->sw_if_index)); FINISH; } @@ -2001,7 +1992,7 @@ static void *vl_api_l2_fib_table_dump_t_print s = format (0, "SCRIPT: l2_fib_table_dump "); - s = format (s, "bd_id %d ", ntohl (mp->bd_id)); + s = format (s, "bd_id %d ", (mp->bd_id)); FINISH; } @@ -2022,7 +2013,7 @@ static void *vl_api_want_interface_events_t_print u8 *s; s = format (0, "SCRIPT: want_interface_events pid %d enable %d ", - ntohl (mp->pid), ntohl (mp->enable_disable)); + (mp->pid), ntohl (mp->enable_disable)); FINISH; } @@ -2112,19 +2103,19 @@ static void *vl_api_vxlan_gpe_add_del_tunnel_t_print &remote, IP46_TYPE_ANY); if (is_grp) - s = format (s, "mcast_sw_if_index %d ", ntohl (mp->mcast_sw_if_index)); - s = format (s, "protocol %d ", ntohl (mp->protocol)); + s = format (s, "mcast_sw_if_index %d ", (mp->mcast_sw_if_index)); + s = format (s, "protocol %d ", (mp->protocol)); - s = format (s, "vni %d ", ntohl (mp->vni)); + s = format (s, "vni %d ", (mp->vni)); if (mp->is_add == 0) s = format (s, "del "); if (mp->encap_vrf_id) - s = format (s, "encap-vrf-id %d ", ntohl (mp->encap_vrf_id)); + s = format (s, "encap-vrf-id %d ", (mp->encap_vrf_id)); if (mp->decap_vrf_id) - s = format (s, "decap-vrf-id %d ", ntohl (mp->decap_vrf_id)); + s = format (s, "decap-vrf-id %d ", (mp->decap_vrf_id)); FINISH; } @@ -2136,7 +2127,7 @@ static void *vl_api_vxlan_gpe_tunnel_dump_t_print s = format (0, "SCRIPT: vxlan_gpe_tunnel_dump "); - s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index)); + s = format (s, "sw_if_index %d ", (mp->sw_if_index)); FINISH; } @@ -2148,10 +2139,9 @@ static void *vl_api_interface_name_renumber_t_print s = format (0, "SCRIPT: interface_renumber "); - s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index)); + s = format (s, "sw_if_index %d ", (mp->sw_if_index)); - s = format (s, "new_show_dev_instance %d ", - ntohl (mp->new_show_dev_instance)); + s = format (s, "new_show_dev_instance %d ", (mp->new_show_dev_instance)); FINISH; } @@ -2162,7 +2152,7 @@ static void *vl_api_ip_probe_neighbor_t_print u8 *s; s = format (0, "SCRIPT: ip_probe_neighbor "); - s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index)); + s = format (s, "sw_if_index %d ", (mp->sw_if_index)); s = format (s, "address %U ", format_vl_api_address, &mp->dst); FINISH; @@ -2205,8 +2195,7 @@ static void *vl_api_want_ip4_arp_events_t_print u8 *s; s = format (0, "SCRIPT: want_ip4_arp_events "); - s = format (s, "pid %d address %U ", ntohl (mp->pid), - format_ip4_address, mp->ip); + s = format (s, "pid %d address %U ", (mp->pid), format_ip4_address, mp->ip); if (mp->enable_disable == 0) s = format (s, "del "); @@ -2219,7 +2208,7 @@ static void *vl_api_want_ip6_nd_events_t_print u8 *s; s = format (0, "SCRIPT: want_ip6_nd_events "); - s = format (s, "pid %d address %U ", ntohl (mp->pid), + s = format (s, "pid %d address %U ", (mp->pid), format_vl_api_ip6_address, mp->ip); if (mp->enable_disable == 0) s = format (s, "del "); @@ -2233,7 +2222,7 @@ static void *vl_api_want_l2_macs_events_t_print u8 *s; s = format (0, "SCRIPT: want_l2_macs_events "); - s = format (s, "learn-limit %d ", ntohl (mp->learn_limit)); + s = format (s, "learn-limit %d ", (mp->learn_limit)); s = format (s, "scan-delay %d ", (u32) mp->scan_delay); s = format (s, "max-entries %d ", (u32) mp->max_macs_in_event * 10); if (mp->enable_disable == 0) @@ -2249,10 +2238,10 @@ static void *vl_api_input_acl_set_interface_t_print s = format (0, "SCRIPT: input_acl_set_interface "); - s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index)); - s = format (s, "ip4-table %d ", ntohl (mp->ip4_table_index)); - s = format (s, "ip6-table %d ", ntohl (mp->ip6_table_index)); - s = format (s, "l2-table %d ", ntohl (mp->l2_table_index)); + s = format (s, "sw_if_index %d ", (mp->sw_if_index)); + s = format (s, "ip4-table %d ", (mp->ip4_table_index)); + s = format (s, "ip6-table %d ", (mp->ip6_table_index)); + s = format (s, "l2-table %d ", (mp->l2_table_index)); if (mp->is_add == 0) s = format (s, "del "); @@ -2267,10 +2256,10 @@ static void *vl_api_output_acl_set_interface_t_print s = format (0, "SCRIPT: output_acl_set_interface "); - s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index)); - s = format (s, "ip4-table %d ", ntohl (mp->ip4_table_index)); - s = format (s, "ip6-table %d ", ntohl (mp->ip6_table_index)); - s = format (s, "l2-table %d ", ntohl (mp->l2_table_index)); + s = format (s, "sw_if_index %d ", (mp->sw_if_index)); + s = format (s, "ip4-table %d ", (mp->ip4_table_index)); + s = format (s, "ip6-table %d ", (mp->ip6_table_index)); + s = format (s, "l2-table %d ", (mp->l2_table_index)); if (mp->is_add == 0) s = format (s, "del "); @@ -2284,7 +2273,7 @@ static void *vl_api_ip_address_dump_t_print u8 *s; s = format (0, "SCRIPT: ip6_address_dump "); - s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index)); + s = format (s, "sw_if_index %d ", (mp->sw_if_index)); s = format (s, "is_ipv6 %d ", mp->is_ipv6 != 0); FINISH; @@ -2307,7 +2296,7 @@ static void *vl_api_cop_interface_enable_disable_t_print u8 *s; s = format (0, "SCRIPT: cop_interface_enable_disable "); - s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index)); + s = format (s, "sw_if_index %d ", (mp->sw_if_index)); if (mp->enable_disable) s = format (s, "enable "); else @@ -2322,8 +2311,8 @@ static void *vl_api_cop_whitelist_enable_disable_t_print u8 *s; s = format (0, "SCRIPT: cop_whitelist_enable_disable "); - s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index)); - s = format (s, "fib-id %d ", ntohl (mp->fib_id)); + s = format (s, "sw_if_index %d ", (mp->sw_if_index)); + s = format (s, "fib-id %d ", (mp->fib_id)); if (mp->ip4) s = format (s, "ip4 "); if (mp->ip6) @@ -2490,13 +2479,13 @@ static void *vl_api_policer_classify_set_interface_t_print u8 *s; s = format (0, "SCRIPT: policer_classify_set_interface "); - s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index)); + s = format (s, "sw_if_index %d ", (mp->sw_if_index)); if (mp->ip4_table_index != ~0) - s = format (s, "ip4-table %d ", ntohl (mp->ip4_table_index)); + s = format (s, "ip4-table %d ", (mp->ip4_table_index)); if (mp->ip6_table_index != ~0) - s = format (s, "ip6-table %d ", ntohl (mp->ip6_table_index)); + s = format (s, "ip6-table %d ", (mp->ip6_table_index)); if (mp->l2_table_index != ~0) - s = format (s, "l2-table %d ", ntohl (mp->l2_table_index)); + s = format (s, "l2-table %d ", (mp->l2_table_index)); if (mp->is_add == 0) s = format (s, "del "); @@ -2534,7 +2523,7 @@ static void *vl_api_sw_interface_clear_stats_t_print s = format (0, "SCRIPT: sw_interface_clear_stats "); if (mp->sw_if_index != ~0) - s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index)); + s = format (s, "sw_if_index %d ", (mp->sw_if_index)); FINISH; } @@ -2545,7 +2534,7 @@ static void *vl_api_mpls_tunnel_dump_t_print u8 *s; s = format (0, "SCRIPT: mpls_tunnel_dump "); - s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index)); + s = format (s, "sw_if_index %d ", (mp->sw_if_index)); FINISH; } @@ -2607,7 +2596,7 @@ static void *vl_api_classify_table_by_interface_t_print s = format (0, "SCRIPT: classify_table_by_interface "); if (mp->sw_if_index != ~0) - s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index)); + s = format (s, "sw_if_index %d ", (mp->sw_if_index)); FINISH; } @@ -2619,7 +2608,7 @@ static void *vl_api_classify_table_info_t_print s = format (0, "SCRIPT: classify_table_info "); if (mp->table_id != ~0) - s = format (s, "table_id %d ", ntohl (mp->table_id)); + s = format (s, "table_id %d ", (mp->table_id)); FINISH; } @@ -2631,7 +2620,7 @@ static void *vl_api_classify_session_dump_t_print s = format (0, "SCRIPT: classify_session_dump "); if (mp->table_id != ~0) - s = format (s, "table_id %d ", ntohl (mp->table_id)); + s = format (s, "table_id %d ", (mp->table_id)); FINISH; } @@ -2645,12 +2634,12 @@ static void *vl_api_set_ipfix_exporter_t_print s = format (s, "collector-address %U ", format_ip4_address, (ip4_address_t *) mp->collector_address); - s = format (s, "collector-port %d ", ntohs (mp->collector_port)); + s = format (s, "collector-port %d ", (mp->collector_port)); s = format (s, "src-address %U ", format_ip4_address, (ip4_address_t *) mp->src_address); - s = format (s, "vrf-id %d ", ntohl (mp->vrf_id)); - s = format (s, "path-mtu %d ", ntohl (mp->path_mtu)); - s = format (s, "template-interval %d ", ntohl (mp->template_interval)); + s = format (s, "vrf-id %d ", (mp->vrf_id)); + s = format (s, "path-mtu %d ", (mp->path_mtu)); + s = format (s, "template-interval %d ", (mp->template_interval)); s = format (s, "udp-checksum %d ", mp->udp_checksum); FINISH; @@ -2673,8 +2662,8 @@ static void *vl_api_set_ipfix_classify_stream_t_print s = format (0, "SCRIPT: set_ipfix_classify_stream "); - s = format (s, "domain-id %d ", ntohl (mp->domain_id)); - s = format (s, "src-port %d ", ntohs (mp->src_port)); + s = format (s, "domain-id %d ", (mp->domain_id)); + s = format (s, "src-port %d ", (mp->src_port)); FINISH; } @@ -2696,7 +2685,7 @@ static void *vl_api_ipfix_classify_table_add_del_t_print s = format (0, "SCRIPT: ipfix_classify_table_add_del "); - s = format (s, "table-id %d ", ntohl (mp->table_id)); + s = format (s, "table-id %d ", (mp->table_id)); s = format (s, "ip-version %d ", mp->ip_version); s = format (s, "transport-protocol %d ", mp->transport_protocol); @@ -2719,8 +2708,8 @@ static void *vl_api_sw_interface_span_enable_disable_t_print u8 *s; s = format (0, "SCRIPT: sw_interface_span_enable_disable "); - s = format (s, "src_sw_if_index %u ", ntohl (mp->sw_if_index_from)); - s = format (s, "dst_sw_if_index %u ", ntohl (mp->sw_if_index_to)); + s = format (s, "src_sw_if_index %u ", (mp->sw_if_index_from)); + s = format (s, "dst_sw_if_index %u ", (mp->sw_if_index_to)); if (mp->is_l2) s = format (s, "l2 "); @@ -2777,9 +2766,9 @@ static void *vl_api_pg_create_interface_t_print u8 *s; s = format (0, "SCRIPT: pg_create_interface "); - s = format (0, "if_id %d", ntohl (mp->interface_id)); + s = format (0, "if_id %d", (mp->interface_id)); s = format (0, "gso-enabled %u", mp->gso_enabled); - s = format (0, "gso-size %u", ntohl (mp->gso_size)); + s = format (0, "gso-size %u", (mp->gso_size)); FINISH; } @@ -2790,10 +2779,10 @@ static void *vl_api_pg_capture_t_print u8 *s; s = format (0, "SCRIPT: pg_capture "); - s = format (0, "if_id %d ", ntohl (mp->interface_id)); + s = format (0, "if_id %d ", (mp->interface_id)); s = format (0, "pcap %s", mp->pcap_file_name); if (mp->count != ~0) - s = format (s, "count %d ", ntohl (mp->count)); + s = format (s, "count %d ", (mp->count)); if (!mp->is_enabled) s = format (s, "disable"); @@ -2806,7 +2795,7 @@ static void *vl_api_pg_enable_disable_t_print u8 *s; s = format (0, "SCRIPT: pg_enable_disable "); - if (ntohl (mp->stream_name_length) > 0) + if ((mp->stream_name_length) > 0) s = format (s, "stream %s", mp->stream_name); if (!mp->is_enabled) s = format (s, "disable"); @@ -2828,7 +2817,7 @@ static void *vl_api_ip_source_and_port_range_check_add_del_t_print s = format (s, "range %d - %d ", mp->low_ports[i], mp->high_ports[i]); } - s = format (s, "vrf %d ", ntohl (mp->vrf_id)); + s = format (s, "vrf %d ", (mp->vrf_id)); if (mp->is_add == 0) s = format (s, "del "); @@ -2844,19 +2833,19 @@ static void *vl_api_ip_source_and_port_range_check_interface_add_del_t_print s = format (0, "SCRIPT: ip_source_and_port_range_check_interface_add_del "); - s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index)); + s = format (s, "sw_if_index %d ", (mp->sw_if_index)); if (mp->tcp_out_vrf_id != ~0) - s = format (s, "tcp-out-vrf %d ", ntohl (mp->tcp_out_vrf_id)); + s = format (s, "tcp-out-vrf %d ", (mp->tcp_out_vrf_id)); if (mp->udp_out_vrf_id != ~0) - s = format (s, "udp-out-vrf %d ", ntohl (mp->udp_out_vrf_id)); + s = format (s, "udp-out-vrf %d ", (mp->udp_out_vrf_id)); if (mp->tcp_in_vrf_id != ~0) - s = format (s, "tcp-in-vrf %d ", ntohl (mp->tcp_in_vrf_id)); + s = format (s, "tcp-in-vrf %d ", (mp->tcp_in_vrf_id)); if (mp->udp_in_vrf_id != ~0) - s = format (s, "udp-in-vrf %d ", ntohl (mp->udp_in_vrf_id)); + s = format (s, "udp-in-vrf %d ", (mp->udp_in_vrf_id)); if (mp->is_add == 0) s = format (s, "del "); @@ -2935,7 +2924,7 @@ static void *vl_api_lisp_add_del_remote_mapping_t_print s = format (s, "del-all "); s = format (s, "%s ", mp->is_add ? "add" : "del"); - s = format (s, "vni %d ", clib_net_to_host_u32 (mp->vni)); + s = format (s, "vni %d ", (mp->vni)); s = format (s, "eid %U ", format_lisp_flat_eid, mp->eid_type, mp->eid, mp->eid_len); @@ -2945,7 +2934,7 @@ static void *vl_api_lisp_add_del_remote_mapping_t_print s = format (s, "seid %U ", format_lisp_flat_eid, mp->eid_type, mp->seid, mp->seid_len); } - rloc_num = clib_net_to_host_u32 (mp->rloc_num); + rloc_num = (mp->rloc_num); if (0 == rloc_num) s = format (s, "action %d", mp->action); @@ -2961,7 +2950,7 @@ static void *vl_api_lisp_add_del_adjacency_t_print s = format (0, "SCRIPT: lisp_add_del_adjacency "); s = format (s, "%s ", mp->is_add ? "add" : "del"); - s = format (s, "vni %d ", clib_net_to_host_u32 (mp->vni)); + s = format (s, "vni %d ", (mp->vni)); s = format (s, "reid %U leid %U ", format_lisp_flat_eid, mp->eid_type, mp->reid, mp->reid_len, format_lisp_flat_eid, mp->eid_type, mp->leid, mp->leid_len); @@ -2994,10 +2983,8 @@ static void *vl_api_lisp_eid_table_add_del_map_t_print if (!mp->is_add) s = format (s, "del "); - s = format (s, "vni %d ", clib_net_to_host_u32 (mp->vni)); - s = format (s, "%s %d ", - mp->is_l2 ? "bd_index" : "vrf", - clib_net_to_host_u32 (mp->dp_table)); + s = format (s, "vni %d ", (mp->vni)); + s = format (s, "%s %d ", mp->is_l2 ? "bd_index" : "vrf", (mp->dp_table)); FINISH; } @@ -3011,7 +2998,7 @@ static void *vl_api_lisp_add_del_local_eid_t_print if (!mp->is_add) s = format (s, "del "); - s = format (s, "vni %d ", clib_net_to_host_u32 (mp->vni)); + s = format (s, "vni %d ", (mp->vni)); s = format (s, "eid %U ", format_lisp_flat_eid, mp->eid_type, mp->eid, mp->prefix_len); s = format (s, "locator-set %s ", mp->locator_set_name); @@ -3117,7 +3104,7 @@ static void *vl_api_lisp_locator_dump_t_print s = format (0, "SCRIPT: lisp_locator_dump "); if (mp->is_index_set) - s = format (s, "ls_index %d", clib_net_to_host_u32 (mp->ls_index)); + s = format (s, "ls_index %d", (mp->ls_index)); else s = format (s, "ls_name %s", mp->ls_name); @@ -3154,7 +3141,7 @@ static void *vl_api_lisp_eid_table_dump_t_print if (mp->eid_set) { - s = format (s, "vni %d ", clib_net_to_host_u32 (mp->vni)); + s = format (s, "vni %d ", (mp->vni)); s = format (s, "eid %U ", format_lisp_flat_eid, mp->eid_type, mp->eid, mp->prefix_length); switch (mp->filter) @@ -3204,7 +3191,7 @@ static void *vl_api_lisp_adjacencies_get_t_print u8 *s; s = format (0, "SCRIPT: lisp_adjacencies_get "); - s = format (s, "vni %d", clib_net_to_host_u32 (mp->vni)); + s = format (s, "vni %d", (mp->vni)); FINISH; } @@ -3241,11 +3228,11 @@ static void *vl_api_ipsec_tunnel_if_add_del_t_print s = format (s, "local-ip %U ", format_vl_api_address, &mp->remote_ip); s = format (s, "remote-ip %U ", format_vl_api_address, &mp->local_ip); - s = format (s, "tx-table-id %d ", ntohl (mp->tx_table_id)); + s = format (s, "tx-table-id %d ", (mp->tx_table_id)); - s = format (s, "local-spi %d ", ntohl (mp->local_spi)); + s = format (s, "local-spi %d ", (mp->local_spi)); - s = format (s, "remote-spi %d ", ntohl (mp->remote_spi)); + s = format (s, "remote-spi %d ", (mp->remote_spi)); s = format (s, "local-crypto-key-len %d ", mp->local_crypto_key_len); s = format (s, "local-crypto-key %U ", format_hex_bytes, @@ -3317,10 +3304,10 @@ static void *vl_api_ipsec_spd_entry_add_del_t_print s = format (0, "SCRIPT: ipsec_spd_entry "); s = format (s, "is_add %d spd_id %u priority %d is_outbound %d sa_id %u\n", mp->is_add, - ntohl (ep->spd_id), ntohl (ep->priority), ep->is_outbound, - ntohl (ep->sa_id)); + (ep->spd_id), ntohl (ep->priority), ep->is_outbound, + (ep->sa_id)); - policy_host_byte_order = ntohl (ep->policy); + policy_host_byte_order = (ep->policy); if (policy_host_byte_order < ARRAY_LEN (policy_strs)) str = policy_strs[policy_host_byte_order]; @@ -3340,10 +3327,10 @@ static void *vl_api_ipsec_spd_entry_add_del_t_print format_vl_api_address, &ep->local_address_stop); s = format (s, " remote_port_start %d remote_port_stop %d\n", - ntohs (ep->remote_port_start), ntohs (ep->remote_port_stop)); + (ep->remote_port_start), ntohs (ep->remote_port_stop)); s = format (s, " local_port_start %d local_port_stop %d ", - ntohs (ep->local_port_start), ntohs (ep->local_port_stop)); + (ep->local_port_start), ntohs (ep->local_port_stop)); FINISH; } @@ -3355,7 +3342,7 @@ static void *vl_api_ipsec_interface_add_del_spd_t_print s = format (0, "SCRIPT: ipsec_interface_add_del_spd "); s = format (s, "is_add %d sw_if_index %d spd_id %u ", - mp->is_add, ntohl (mp->sw_if_index), ntohl (mp->spd_id)); + mp->is_add, (mp->sw_if_index), ntohl (mp->spd_id)); FINISH; } @@ -3365,7 +3352,7 @@ static void *vl_api_ipsec_spd_add_del_t_print u8 *s; s = format (0, "SCRIPT: ipsec_spd_add_del "); - s = format (s, "spd_id %u is_add %d ", ntohl (mp->spd_id), mp->is_add); + s = format (s, "spd_id %u is_add %d ", (mp->spd_id), mp->is_add); FINISH; } @@ -3385,15 +3372,15 @@ static void *vl_api_ipsec_sad_entry_add_del_t_print s = format (0, "SCRIPT: ipsec_sad_entry_add_del is_add ", mp->is_add); - tmp = ntohl (ep->protocol); + tmp = (ep->protocol); if (tmp < ARRAY_LEN (proto_strs)) protocol_str = proto_strs[tmp]; - tmp = ntohl (ep->crypto_algorithm); + tmp = (ep->crypto_algorithm); if (tmp < ARRAY_LEN (algo_strs)) algo_str = algo_strs[tmp]; - tmp = ntohl (ep->integrity_algorithm); + tmp = (ep->integrity_algorithm); if (tmp < ARRAY_LEN (integ_strs)) integ_str = integ_strs[tmp]; @@ -3405,13 +3392,13 @@ static void *vl_api_ipsec_sad_entry_add_del_t_print s = format (s, " integ_key len %d value %U\n", ep->integrity_key.length, format_hex_bytes, ep->integrity_key.data, (int) (ep->integrity_key.length)); - s = format (s, " flags 0x%x ", ntohl (ep->flags)); + s = format (s, " flags 0x%x ", (ep->flags)); s = format (s, "tunnel_src %U tunnel_dst %U\n", format_vl_api_address, &ep->tunnel_src, format_vl_api_address, &ep->tunnel_dst); s = format (s, " tx_table_id %u salt %u ", - ntohl (ep->tx_table_id), ntohl (ep->salt)); + (ep->tx_table_id), ntohl (ep->salt)); FINISH; } @@ -3420,20 +3407,20 @@ static void *vl_api_l2_interface_pbb_tag_rewrite_t_print (vl_api_l2_interface_pbb_tag_rewrite_t * mp, void *handle) { u8 *s; - u32 vtr_op = ntohl (mp->vtr_op); + u32 vtr_op = (mp->vtr_op); s = format (0, "SCRIPT: l2_interface_pbb_tag_rewrite "); - s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index)); + s = format (s, "sw_if_index %d ", (mp->sw_if_index)); s = format (s, "vtr_op %d ", vtr_op); if (vtr_op != L2_VTR_DISABLED && vtr_op != L2_VTR_POP_2) { if (vtr_op == L2_VTR_TRANSLATE_2_2) - s = format (s, "%d ", ntohs (mp->outer_tag)); + s = format (s, "%d ", (mp->outer_tag)); s = format (s, "dmac %U ", format_ethernet_address, &mp->b_dmac); s = format (s, "smac %U ", format_ethernet_address, &mp->b_smac); - s = format (s, "sid %d ", ntohl (mp->i_sid)); - s = format (s, "vlanid %d ", ntohs (mp->b_vlanid)); + s = format (s, "sid %d ", (mp->i_sid)); + s = format (s, "vlanid %d ", (mp->b_vlanid)); } FINISH; } @@ -3444,11 +3431,11 @@ static void *vl_api_flow_classify_set_interface_t_print u8 *s; s = format (0, "SCRIPT: flow_classify_set_interface "); - s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index)); + s = format (s, "sw_if_index %d ", (mp->sw_if_index)); if (mp->ip4_table_index != ~0) - s = format (s, "ip4-table %d ", ntohl (mp->ip4_table_index)); + s = format (s, "ip4-table %d ", (mp->ip4_table_index)); if (mp->ip6_table_index != ~0) - s = format (s, "ip6-table %d ", ntohl (mp->ip6_table_index)); + s = format (s, "ip6-table %d ", (mp->ip6_table_index)); if (mp->is_add == 0) s = format (s, "del "); @@ -3462,7 +3449,7 @@ vl_api_set_punt_t_print (vl_api_set_punt_t * mp, void *handle) s = format (0, "SCRIPT: punt "); - switch (clib_net_to_host_u32 (mp->punt.type)) + switch (mp->punt.type) { case PUNT_API_TYPE_L4: s = format (s, "%U", format_vl_api_address_family, mp->punt.punt.l4.af); @@ -3470,8 +3457,11 @@ vl_api_set_punt_t_print (vl_api_set_punt_t * mp, void *handle) s = format (s, "protocol %d ", mp->punt.punt.l4.protocol); if (mp->punt.punt.l4.port != (u16) ~ 0) - s = format (s, "port %d ", ntohs (mp->punt.punt.l4.port)); + s = format (s, "port %d ", (mp->punt.punt.l4.port)); + break; + default: break; + } if (!mp->is_add) @@ -3555,7 +3545,7 @@ static void *vl_api_feature_enable_disable_t_print s = format (0, "SCRIPT: feature_enable_disable "); s = format (s, "arc_name %s ", mp->arc_name); s = format (s, "feature_name %s ", mp->feature_name); - s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index)); + s = format (s, "sw_if_index %d ", (mp->sw_if_index)); if (!mp->enable) s = format (s, "disable"); @@ -3568,7 +3558,7 @@ static void *vl_api_sw_interface_tag_add_del_t_print u8 *s; s = format (0, "SCRIPT: sw_interface_tag_add_del "); - s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index)); + s = format (s, "sw_if_index %d ", (mp->sw_if_index)); if (mp->is_add) s = format (s, "tag %s ", mp->tag); else @@ -3583,8 +3573,8 @@ static void *vl_api_hw_interface_set_mtu_t_print u8 *s; s = format (0, "SCRIPT: sw_interface_set_mtu "); - s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index)); - s = format (s, "tag %d ", ntohs (mp->mtu)); + s = format (s, "sw_if_index %d ", (mp->sw_if_index)); + s = format (s, "tag %d ", (mp->mtu)); FINISH; } @@ -3595,7 +3585,7 @@ static void *vl_api_p2p_ethernet_add_t_print u8 *s; s = format (0, "SCRIPT: p2p_ethernet_add "); - s = format (s, "sw_if_index %d ", ntohl (mp->parent_if_index)); + s = format (s, "sw_if_index %d ", (mp->parent_if_index)); s = format (s, "remote_mac %U ", format_ethernet_address, mp->remote_mac); FINISH; @@ -3607,7 +3597,7 @@ static void *vl_api_p2p_ethernet_del_t_print u8 *s; s = format (0, "SCRIPT: p2p_ethernet_del "); - s = format (s, "sw_if_index %d ", ntohl (mp->parent_if_index)); + s = format (s, "sw_if_index %d ", (mp->parent_if_index)); s = format (s, "remote_mac %U ", format_ethernet_address, mp->remote_mac); FINISH; @@ -3629,7 +3619,7 @@ static void *vl_api_tcp_configure_src_addresses_t_print format_ip4_address, (ip4_address_t *) mp->last_address); if (mp->vrf_id) - s = format (s, "vrf %d ", ntohl (mp->vrf_id)); + s = format (s, "vrf %d ", (mp->vrf_id)); FINISH; } @@ -3644,9 +3634,7 @@ static void *vl_api_app_namespace_add_del_t_print s = format (0, "SCRIPT: app_namespace_add_del "); s = format (s, "ns-id %s secret %lu sw_if_index %d ipv4_fib_id %d " "ipv6_fib_id %d", (char *) mp->namespace_id, mp->secret, - clib_net_to_host_u32 (mp->sw_if_index), - clib_net_to_host_u32 (mp->ip4_fib_id), - clib_net_to_host_u32 (mp->ip6_fib_id)); + (mp->sw_if_index), (mp->ip4_fib_id), (mp->ip6_fib_id)); FINISH; } @@ -3659,7 +3647,7 @@ static void *vl_api_sw_interface_set_lldp_t_print clib_memset (null_data, 0, sizeof (null_data)); s = format (0, "SCRIPT: sw_interface_set_lldp "); - s = format (s, "sw_if_index %d ", ntohl (mp->sw_if_index)); + s = format (s, "sw_if_index %d ", (mp->sw_if_index)); if (memcmp (mp->port_desc, null_data, sizeof (mp->port_desc))) s = format (s, "port_desc %s ", mp->port_desc); @@ -3686,8 +3674,8 @@ static void *vl_api_lldp_config_t_print s = format (0, "SCRIPT: lldp_config "); s = format (s, "system_name %s ", mp->system_name); - s = format (s, "tx_hold %d ", ntohl (mp->tx_hold)); - s = format (s, "tx_interval %d ", ntohl (mp->tx_interval)); + s = format (s, "tx_hold %d ", (mp->tx_hold)); + s = format (s, "tx_interval %d ", (mp->tx_interval)); FINISH; } @@ -3731,7 +3719,7 @@ static void *vl_api_qos_record_enable_disable_t_print u8 *s; s = format (0, "SCRIPT: qos_record_enable_disable "); - s = format (s, "sw_if_index %d ", ntohl (mp->record.sw_if_index)); + s = format (s, "sw_if_index %d ", (mp->record.sw_if_index)); s = format (s, "input_source %U ", format_qos_source, mp->record.input_source); |