aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZhiyong Yang <zhiyong.yang@intel.com>2019-05-28 01:26:05 -0400
committerZhiyong Yang <zhiyong.yang@intel.com>2019-05-28 01:54:47 -0400
commit21dc4ece174006a779436362b12d539a91404c8e (patch)
tree23dfb349a13ce2d1fd03e2737d5a1604883a729d
parentcbd0824d6cec24ea2502ffdcdb1666d090f848cf (diff)
hdlc_input: simplify code using existing functions
Change-Id: I527b7e43dfba05eab12591e193f07f5036e33f56 Signed-off-by: Zhiyong Yang <zhiyong.yang@intel.com>
-rw-r--r--src/vnet/hdlc/node.c16
1 files changed, 6 insertions, 10 deletions
diff --git a/src/vnet/hdlc/node.c b/src/vnet/hdlc/node.c
index 6b8c7c625d2..d36b09d4dcd 100644
--- a/src/vnet/hdlc/node.c
+++ b/src/vnet/hdlc/node.c
@@ -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);