X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvnet%2Fip%2Fpunt_api.c;h=077b1ac3a6941dd8ac2192ccfcaf6dcb98d53741;hb=2dbee9361e74d03727a8b618ba80a5e28c006011;hp=95fff714b46d89d013f17dc73a2e8e9414ba7b5a;hpb=50f0ac0f097e5495da1f2b1816106e3d420ff34b;p=vpp.git diff --git a/src/vnet/ip/punt_api.c b/src/vnet/ip/punt_api.c index 95fff714b46..077b1ac3a69 100644 --- a/src/vnet/ip/punt_api.c +++ b/src/vnet/ip/punt_api.c @@ -95,6 +95,18 @@ vl_api_punt_l4_decode (const vl_api_punt_l4_t * in, punt_l4_t * out) return (rv); } +static int +vl_api_punt_ip_proto_decode (const vl_api_punt_ip_proto_t * in, + punt_ip_proto_t * out) +{ + int rv; + + rv = ip_address_family_decode (in->af, &out->af); + rv += ip_proto_decode (in->protocol, &out->protocol); + + return (rv); +} + static int vl_api_punt_exception_decode (const vl_api_punt_exception_t * in, punt_exception_t * out) @@ -124,6 +136,9 @@ vl_api_punt_decode (const vl_api_punt_t * in, punt_reg_t * out) case PUNT_TYPE_EXCEPTION: return (vl_api_punt_exception_decode (&in->punt.exception, &out->punt.exception)); + case PUNT_TYPE_IP_PROTO: + return (vl_api_punt_ip_proto_decode (&in->punt.ip_proto, + &out->punt.ip_proto)); } return (-1); @@ -137,6 +152,14 @@ vl_api_punt_l4_encode (const punt_l4_t * in, vl_api_punt_l4_t * out) out->port = clib_net_to_host_u16 (in->port); } +static void +vl_api_punt_ip_proto_encode (const punt_ip_proto_t * in, + vl_api_punt_ip_proto_t * out) +{ + out->af = ip_address_family_encode (in->af); + out->protocol = ip_proto_encode (in->protocol); +} + static void vl_api_punt_exception_encode (const punt_exception_t * in, vl_api_punt_exception_t * out) @@ -154,6 +177,9 @@ vl_api_punt_encode (const punt_reg_t * in, vl_api_punt_t * out) case PUNT_TYPE_L4: vl_api_punt_l4_encode (&in->punt.l4, &out->punt.l4); break; + case PUNT_TYPE_IP_PROTO: + vl_api_punt_ip_proto_encode (&in->punt.ip_proto, &out->punt.ip_proto); + break; case PUNT_TYPE_EXCEPTION: vl_api_punt_exception_encode (&in->punt.exception, &out->punt.exception); @@ -295,6 +321,7 @@ typedef struct punt_reason_dump_walk_ctx_t_ { vl_api_registration_t *reg; u32 context; + u8 *name; } punt_reason_dump_walk_ctx_t; static int @@ -303,6 +330,14 @@ punt_reason_dump_walk_cb (vlib_punt_reason_t id, const u8 * name, void *args) punt_reason_dump_walk_ctx_t *ctx = args; vl_api_punt_reason_details_t *mp; + if (ctx->name) + { + /* user requested a specific punt-reason */ + if (vec_cmp (name, ctx->name)) + /* not the reasonn we're lookgin for */ + return 1; + } + mp = vl_msg_api_alloc (sizeof (*mp) + vec_len (name)); if (!mp) return (0); @@ -312,7 +347,7 @@ punt_reason_dump_walk_cb (vlib_punt_reason_t id, const u8 * name, void *args) mp->context = ctx->context; mp->reason.id = clib_host_to_net_u32 (id); - vl_api_to_api_string (vec_len (name), (char *) name, &mp->reason.name); + vl_api_vec_to_api_string (name, &mp->reason.name); vl_api_send_msg (ctx->reg, (u8 *) mp); @@ -331,9 +366,12 @@ vl_api_punt_reason_dump_t_handler (vl_api_punt_reason_dump_t * mp) punt_reason_dump_walk_ctx_t ctx = { .reg = reg, .context = mp->context, + .name = vl_api_from_api_to_new_vec (&mp->reason.name), }; punt_reason_walk (punt_reason_dump_walk_cb, &ctx); + + vec_free (ctx.name); } #define vl_msg_name_crc_list @@ -351,7 +389,7 @@ setup_message_id_table (api_main_t * am) static clib_error_t * punt_api_hookup (vlib_main_t * vm) { - api_main_t *am = &api_main; + api_main_t *am = vlibapi_get_main (); #define _(N,n) \ vl_msg_api_set_handlers(VL_API_##N, #n, \