40 #ifndef included_packet_generator_pg_edit_h 41 #define included_packet_generator_pg_edit_h 76 #define PG_EDIT_PACKET_LENGTH (-1) 98 #define pg_edit_init_bitfield(e,type,field,field_offset,field_n_bits) \ 102 ASSERT ((field_offset) < STRUCT_BITS_OF (type, field)); \ 105 _bo = STRUCT_OFFSET_OF (type, field); \ 108 _bo += ((STRUCT_BITS_OF (type, field) \ 109 - (field_offset) - 1) / BITS (u8)); \ 111 (e)->lsb_bit_offset = _bo * BITS (u8) + ((field_offset) % BITS (u8)); \ 112 (e)->n_bits = (field_n_bits); \ 116 #define pg_edit_init(e,type,field) \ 117 pg_edit_init_bitfield(e,type,field,0,STRUCT_BITS_OF(type,field)) 122 int i0, i1, n_bytes, n_bits_left;
130 if (n_bits_left > 0 && i1 != 0)
138 n_bytes += (n_bits_left /
BITS (
u8));
139 n_bytes += (n_bits_left %
BITS (
u8)) != 0;
184 for (i = 0; i < n; i++)
185 r = (r <<
BITS (v[i])) + v[
i];
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
sll srl srl sll sra u16x4 i
static void pg_edit_set_fixed(pg_edit_t *e, u64 value)
static void pg_edit_alloc_value(pg_edit_t *e, int i)
static void pg_edit_copy_type_and_values(pg_edit_t *dst, pg_edit_t *src)
uword unformat_pg_number(unformat_input_t *input, va_list *args)
static u64 pg_edit_get_value(pg_edit_t *e, int hi_or_lo)
static uword pg_edit_is_fixed_with_value(pg_edit_t *e, u64 value)
#define vec_free(V)
Free vector's memory (no header).
uword unformat_pg_edit(unformat_input_t *input, va_list *args)
void pg_edit_set_value(pg_edit_t *e, int hi_or_lo, u64 value)
static uword round_pow2(uword x, uword pow2)
uword unformat_pg_payload(unformat_input_t *input, va_list *args)
uword unformat_pg_interface(unformat_input_t *input, va_list *args)
static uword pg_edit_n_alloc_bytes(pg_edit_t *e)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
static void pg_edit_free(pg_edit_t *e)
CLIB vectors are ubiquitous dynamically resized arrays with by user defined "headers".