/* Format IP protocol. */ u8 * format_ip_protocol (u8 * s, va_list * args) { ip_protocol_t protocol = va_arg (*args, ip_protocol_t); ip_main_t * im = &ip_main; ip_protocol_info_t * pi = ip_get_protocol_info (im, protocol); if (pi) return format (s, "%s", pi->name); else return format (s, "unknown %d", protocol); }
static clib_error_t * udp_init (vlib_main_t * vm) { ip_main_t * im = &ip_main; ip_protocol_info_t * pi; clib_error_t * error; error = vlib_call_init_function (vm, ip_main_init); if (! error) { pi = ip_get_protocol_info (im, IP_PROTOCOL_UDP); pi->format_header = format_udp_header; pi->unformat_pg_edit = unformat_pg_udp_header; } return 0; }