The interior node is neither pipelined nor dual-looped, because
it would be very unusual to see more than one CDP packet in
- a given input frame. So, it's a very simple / straighforward
+ a given input frame. So, it's a very simple / straightforward
example.
*/
f64 poll_time_remaining;
uword event_type, *event_data = 0;
- /* So we can send events to the cdp process */
- cm->cdp_process_node_index = cdp_process_node.index;
-
- /* Dynamically register the cdp input node with the snap classifier */
- snap_register_input_protocol (vm, "cdp-input", 0xC /* ieee_oui, Cisco */ ,
- 0x2000 /* protocol CDP */ ,
- cdp_input_node.index);
-
- snap_register_input_protocol (vm, "cdp-input", 0xC /* ieee_oui, Cisco */ ,
- 0x2004 /* protocol CDP */ ,
- cdp_input_node.index);
-
-#if 0 /* retain for reference */
- /* with the hdlc classifier */
- hdlc_register_input_protocol (vm, HDLC_PROTOCOL_cdp, cdp_input_node.index);
-#endif
-
- /* with ethernet input (for SRP) */
- ethernet_register_input_type (vm, ETHERNET_TYPE_CDP /* CDP */ ,
- cdp_input_node.index);
-
- /* Start w/ cdp effectively disabled */
+ /* Start w/ cdp disabled */
poll_time_remaining = 86400.0;
while (1)
break;
case CDP_EVENT_ENABLE:
+ if (!cm->cdp_protocol_registered)
+ {
+ /*
+ * Dynamically register the cdp input node
+ * with the snap classifier
+ */
+ snap_register_input_protocol (vm, "cdp-input",
+ 0xC /* ieee_oui, Cisco */ ,
+ 0x2000 /* protocol CDP */ ,
+ cdp_input_node.index);
+
+ snap_register_input_protocol (vm, "cdp-input",
+ 0xC /* ieee_oui, Cisco */ ,
+ 0x2004 /* protocol CDP */ ,
+ cdp_input_node.index);
+#if 0
+ /*
+ * Keep this code for reference...
+ * Register with the hdlc classifier
+ */
+ hdlc_register_input_protocol (vm, HDLC_PROTOCOL_cdp,
+ cdp_input_node.index);
+#endif
+ /* with ethernet input (for SRP) */
+ ethernet_register_input_type (vm, ETHERNET_TYPE_CDP /* CDP */ ,
+ cdp_input_node.index);
+ cm->cdp_protocol_registered = 1;
+ }
poll_time_remaining = 10.0;
break;
return 0;
}
-/*
- * cdp periodic node declaration
- */
-/* *INDENT-OFF* */
-VLIB_REGISTER_NODE (cdp_process_node) = {
- .function = cdp_process,
- .type = VLIB_NODE_TYPE_PROCESS,
- .name = "cdp-process",
-};
-/* *INDENT-ON* */
-
void
-vnet_cdp_node_reference (void)
+vnet_cdp_create_periodic_process (cdp_main_t * cmp)
{
+ /* Already created the process node? */
+ if (cmp->cdp_process_node_index > 0)
+ return;
+
+ /* No, create it now and make a note of the node index */
+ cmp->cdp_process_node_index = vlib_process_create
+ (cmp->vlib_main, "cdp-process",
+ cdp_process, 16 /* log2_n_stack_bytes */ );
}
/*