linux-cp: Only enable/disable the punt feature on the 0<->1 transition
[vpp.git] / src / vnet / hdlc / node.c
index 6b8c7c6..8bb6212 100644 (file)
@@ -139,8 +139,8 @@ hdlc_input (vlib_main_t * vm,
          b0 = vlib_get_buffer (vm, bi0);
          b1 = vlib_get_buffer (vm, bi1);
 
-         h0 = (void *) (b0->data + b0->current_data);
-         h1 = (void *) (b1->data + b1->current_data);
+         h0 = vlib_buffer_get_current (b0);
+         h1 = vlib_buffer_get_current (b1);
 
          protocol0 = h0->protocol;
          protocol1 = h1->protocol;
@@ -152,11 +152,8 @@ hdlc_input (vlib_main_t * vm,
          len0 += protocol0 == clib_host_to_net_u16 (HDLC_PROTOCOL_osi);
          len1 += protocol1 == clib_host_to_net_u16 (HDLC_PROTOCOL_osi);
 
-         b0->current_data += len0;
-         b1->current_data += len1;
-
-         b0->current_length -= len0;
-         b1->current_length -= len1;
+         vlib_buffer_advance (b0, len0);
+         vlib_buffer_advance (b1, len1);
 
          /* Index sparse array with network byte order. */
          sparse_vec_index2 (rt->next_by_protocol, protocol0, protocol1, &i0,
@@ -235,7 +232,7 @@ hdlc_input (vlib_main_t * vm,
 
          b0 = vlib_get_buffer (vm, bi0);
 
-         h0 = (void *) (b0->data + b0->current_data);
+         h0 = vlib_buffer_get_current (b0);
 
          protocol0 = h0->protocol;
 
@@ -243,8 +240,7 @@ hdlc_input (vlib_main_t * vm,
          len0 = sizeof (h0[0]);
          len0 += protocol0 == clib_host_to_net_u16 (HDLC_PROTOCOL_osi);
 
-         b0->current_data += len0;
-         b0->current_length -= len0;
+         vlib_buffer_advance (b0, len0);
 
          i0 = sparse_vec_index (rt->next_by_protocol, protocol0);
 
@@ -328,6 +324,17 @@ hdlc_input_runtime_init (vlib_main_t * vm)
   return 0;
 }
 
+static void
+hdlc_setup_node (vlib_main_t *vm, u32 node_index)
+{
+  vlib_node_t *n = vlib_get_node (vm, node_index);
+  pg_node_t *pn = pg_get_node (node_index);
+
+  n->format_buffer = format_hdlc_header_with_length;
+  n->unformat_buffer = unformat_hdlc_header;
+  pn->unformat_edit = unformat_pg_hdlc_header;
+}
+
 static clib_error_t *
 hdlc_input_init (vlib_main_t * vm)
 {