diff options
author | Vadim Kochan <vadim4j@gmail.com> | 2017-05-14 08:52:08 +0300 |
---|---|---|
committer | Tobias Klauser <tklauser@distanz.ch> | 2017-05-15 10:32:12 +0200 |
commit | b463e1f265628f97967a01ce0a2cf18afe7b7aa3 (patch) | |
tree | 66436f3bcfb429593e4ab8155b5e431027da2763 /trafgen_parser.y | |
parent | 5ca91a807a81db233e1b4443ea227bb1d0a7868f (diff) |
trafgen: parser: Use proto_field_set_xxx where it is possible
Use proto_field_set_xxx(field, ...) instead of
proto_hdr_field_set_xxx(hdr, fid, ...) to be more generic and do not
depend on 'hdr' variable.
Signed-off-by: Vadim Kochan <vadim4j@gmail.com>
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Diffstat (limited to 'trafgen_parser.y')
-rw-r--r-- | trafgen_parser.y | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/trafgen_parser.y b/trafgen_parser.y index 40cd311..5a61a3f 100644 --- a/trafgen_parser.y +++ b/trafgen_parser.y @@ -425,20 +425,19 @@ static void proto_field_expr_eval(void) if (field_expr.type & FIELD_EXPR_NUMB) { if (field->len == 1) - proto_hdr_field_set_u8(hdr, field->id, field_expr.val.number); + proto_field_set_u8(field, field_expr.val.number); else if (field->len == 2) - proto_hdr_field_set_be16(hdr, field->id, field_expr.val.number); + proto_field_set_be16(field, field_expr.val.number); else if (field->len == 4) - proto_hdr_field_set_be32(hdr, field->id, field_expr.val.number); + proto_field_set_be32(field, field_expr.val.number); else panic("Invalid value length %zu, can be 1,2 or 4\n", field->len); } else if (field_expr.type & FIELD_EXPR_MAC) { - proto_hdr_field_set_bytes(hdr, field->id, field_expr.val.mac); + proto_field_set_bytes(field, field_expr.val.mac); } else if (field_expr.type & FIELD_EXPR_IP4_ADDR) { - proto_hdr_field_set_u32(hdr, field->id, field_expr.val.ip4_addr.s_addr); + proto_field_set_u32(field, field_expr.val.ip4_addr.s_addr); } else if (field_expr.type & FIELD_EXPR_IP6_ADDR) { - proto_hdr_field_set_bytes(hdr, field->id, - (uint8_t *)&field_expr.val.ip6_addr.s6_addr); + proto_field_set_bytes(field, (uint8_t *)&field_expr.val.ip6_addr.s6_addr); } else if ((field_expr.type & FIELD_EXPR_INC) || (field_expr.type & FIELD_EXPR_RND)) { |