#include <vnet/ip/punt.h>
#include <vnet/ip/ip_types_api.h>
-#include <vnet/vnet_msg_enum.h>
-
-#define vl_typedefs /* define message structures */
-#include <vnet/vnet_all_api_h.h>
-#undef vl_typedefs
-
-#define vl_endianfun /* define message structures */
-#include <vnet/vnet_all_api_h.h>
-#undef vl_endianfun
-
-/* instantiate all the print functions we know about */
-#define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__)
-#define vl_printfun
-#include <vnet/vnet_all_api_h.h>
-#undef vl_printfun
+#include <vnet/format_fns.h>
+#include <vnet/ip/punt.api_enum.h>
+#include <vnet/ip/punt.api_types.h>
+#define REPLY_MSG_ID_BASE punt_main.msg_id_base
#include <vlibapi/api_helper_macros.h>
-#define foreach_punt_api_msg \
-_(SET_PUNT, set_punt) \
-_(PUNT_SOCKET_REGISTER, punt_socket_register) \
-_(PUNT_SOCKET_DEREGISTER, punt_socket_deregister) \
-_(PUNT_SOCKET_DUMP, punt_socket_dump) \
-_(PUNT_REASON_DUMP, punt_reason_dump)
-
static int
vl_api_punt_type_decode (vl_api_punt_type_t in, punt_type_t * out)
{
int rv;
rv = ip_address_family_decode (in->af, &out->af);
- rv += ip_proto_decode (in->protocol, &out->protocol);
+ if (rv < 0)
+ return (rv);
+ rv = ip_proto_decode (in->protocol, &out->protocol);
+ if (rv < 0)
+ return (rv);
out->port = clib_net_to_host_u16 (in->port);
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);
+ if (rv < 0)
+ return (rv);
+ 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)
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);
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)
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);
char *p = vnet_punt_get_server_pathname ();
- /* *INDENT-OFF* */
REPLY_MACRO2 (VL_API_PUNT_SOCKET_REGISTER_REPLY,
({
memcpy ((char *) rmp->pathname, p, sizeof (rmp->pathname));
}));
- /* *INDENT-ON* */
}
typedef struct punt_socket_send_ctx_t_
return (WALK_STOP);
clib_memset (mp, 0, sizeof (*mp));
- mp->_vl_msg_id = ntohs (VL_API_PUNT_SOCKET_DETAILS);
+ mp->_vl_msg_id = ntohs (REPLY_MSG_ID_BASE + VL_API_PUNT_SOCKET_DETAILS);
mp->context = ctx->context;
vl_api_punt_encode (&pc->reg, &mp->punt);
memcpy (mp->pathname, pc->caddr.sun_path, sizeof (pc->caddr.sun_path));
{
vl_api_registration_t *reg;
u32 context;
+ u8 *name;
} punt_reason_dump_walk_ctx_t;
static int
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);
clib_memset (mp, 0, sizeof (*mp));
- mp->_vl_msg_id = ntohs (VL_API_PUNT_REASON_DETAILS);
+ mp->_vl_msg_id = ntohs (REPLY_MSG_ID_BASE + VL_API_PUNT_REASON_DETAILS);
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);
punt_reason_dump_walk_ctx_t ctx = {
.reg = reg,
.context = mp->context,
+ .name = vl_api_from_api_to_new_vec (mp, &mp->reason.name),
};
punt_reason_walk (punt_reason_dump_walk_cb, &ctx);
-}
-
-#define vl_msg_name_crc_list
-#include <vnet/ip/punt.api.h>
-#undef vl_msg_name_crc_list
-static void
-setup_message_id_table (api_main_t * am)
-{
-#define _(id,n,crc) vl_msg_api_add_msg_name_crc (am, #n "_" #crc, id);
- foreach_vl_msg_name_crc_punt;
-#undef _
+ vec_free (ctx.name);
}
+#include <vnet/ip/punt.api.c>
+
static clib_error_t *
punt_api_hookup (vlib_main_t * vm)
{
- api_main_t *am = &api_main;
-
-#define _(N,n) \
- vl_msg_api_set_handlers(VL_API_##N, #n, \
- vl_api_##n##_t_handler, \
- vl_noop_handler, \
- vl_api_##n##_t_endian, \
- vl_api_##n##_t_print, \
- sizeof(vl_api_##n##_t), 1);
- foreach_punt_api_msg;
-#undef _
-
/*
* Set up the (msg_name, crc, message-id) table
*/
- setup_message_id_table (am);
+ REPLY_MSG_ID_BASE = setup_message_id_table ();
return 0;
}