Code Review
/
vpp.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
classify: vpp packet tracer support
[vpp.git]
/
src
/
vnet
/
pg
/
edit.c
diff --git
a/src/vnet/pg/edit.c
b/src/vnet/pg/edit.c
index
cb4d070
..
df057d2
100644
(file)
--- a/
src/vnet/pg/edit.c
+++ b/
src/vnet/pg/edit.c
@@
-138,11
+138,10
@@
unformat_pg_payload (unformat_input_t * input, va_list * args)
{
vec_resize (v, len);
for (i = 0; i < len; i++)
{
vec_resize (v, len);
for (i = 0; i < len; i++)
- v[i] = i;
+ v[i] = i
% len
;
}
else if (unformat (input, "hex 0x%U", unformat_hex_string, &v))
;
}
else if (unformat (input, "hex 0x%U", unformat_hex_string, &v))
;
-
else if (unformat (input, "%U", unformat_vlib_node, vm, &node_index))
{
pg_node_t *pn = pg_get_node (node_index);
else if (unformat (input, "%U", unformat_vlib_node, vm, &node_index))
{
pg_node_t *pn = pg_get_node (node_index);
@@
-156,21
+155,27
@@
unformat_pg_payload (unformat_input_t * input, va_list * args)
/* Length not including this payload. */
max_len = pg_edit_group_n_bytes (s, 0);
/* Length not including this payload. */
max_len = pg_edit_group_n_bytes (s, 0);
- if (max_len + vec_len (v) >= s->max_packet_bytes)
+
+ if (max_len >= s->max_packet_bytes)
+ {
+ /* no payload */
+ len = 0;
+ }
+ else
{
{
- if (s->max_packet_bytes >= max_len)
- _vec_len (v) = s->max_packet_bytes - max_len;
- else
- _vec_len (v) = 0;
+ /* make a bigger v to hold the data */
+ len = s->max_packet_bytes - max_len;
}
}
- e = pg_create_edit_group (s, sizeof (e[0]), vec_len (v), 0);
+ vec_resize (v, len);
+
+ e = pg_create_edit_group (s, sizeof (e[0]), len, 0);
e->type = PG_EDIT_FIXED;
e->type = PG_EDIT_FIXED;
- e->n_bits =
vec_len (v)
* BITS (v[0]);
+ e->n_bits =
len
* BITS (v[0]);
/* Least significant bit is at end of bitstream, since everything is always bigendian. */
/* Least significant bit is at end of bitstream, since everything is always bigendian. */
- e->lsb_bit_offset =
e->n_bits - BITS (v[0])
;
+ e->lsb_bit_offset =
len > 0 ? e->n_bits - BITS (v[0]) : 0
;
e->values[PG_EDIT_LO] = v;
e->values[PG_EDIT_LO] = v;