summaryrefslogtreecommitdiff
path: root/trafgen_parser.y
diff options
context:
space:
mode:
authorVadim Kochan <vadim4j@gmail.com>2016-12-18 11:52:46 +0200
committerTobias Klauser <tklauser@distanz.ch>2016-12-21 16:55:19 +0100
commitd552107f5ce59a69b43517e4327ed6a4903bf529 (patch)
tree9029444e423b2a4d3954de9ae23c1042cb4c9145 /trafgen_parser.y
parentd084e7ab35438619bfd414ab9a605c64e6e83817 (diff)
trafgen: proto: Rename proto_field_xxx -> proto_hdr_field_xxx
Rename all proto_field_xxx(...) functions to proto_hdr_field(...). It is good for 2 reasons: 1) proto_hdr_field_xxx naming is more consistent as it is related to proto_hdr API. 2) It makes possible to introduce proto_field_xxx API which will operate only with struct proto_field. 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.y64
1 files changed, 32 insertions, 32 deletions
diff --git a/trafgen_parser.y b/trafgen_parser.y
index 7e22a1d..bfeed2e 100644
--- a/trafgen_parser.y
+++ b/trafgen_parser.y
@@ -387,14 +387,14 @@ static void proto_add(enum proto_id pid)
static void proto_field_set(uint32_t fid)
{
- field_expr.field = proto_field_by_id(hdr, fid);
+ field_expr.field = proto_hdr_field_by_id(hdr, fid);
}
static void proto_field_func_setup(struct proto_field *field, struct proto_field_func *func)
{
struct packet_dyn *pkt_dyn;
- proto_field_func_add(field->hdr, field->id, func);
+ proto_hdr_field_func_add(field->hdr, field->id, func);
pkt_dyn = &packet_dyn[packetd_last];
pkt_dyn->flen++;
@@ -410,25 +410,25 @@ static void proto_field_expr_eval(void)
switch (field_expr.type) {
case FIELD_EXPR_NUMB:
if (field->len == 1)
- proto_field_set_u8(hdr, field->id, field_expr.val.number);
+ proto_hdr_field_set_u8(hdr, field->id, field_expr.val.number);
else if (field->len == 2)
- proto_field_set_be16(hdr, field->id, field_expr.val.number);
+ proto_hdr_field_set_be16(hdr, field->id, field_expr.val.number);
else if (field->len == 4)
- proto_field_set_be32(hdr, field->id, field_expr.val.number);
+ proto_hdr_field_set_be32(hdr, field->id, field_expr.val.number);
else
bug();
break;
case FIELD_EXPR_MAC:
- proto_field_set_bytes(hdr, field->id, field_expr.val.bytes);
+ proto_hdr_field_set_bytes(hdr, field->id, field_expr.val.bytes);
break;
case FIELD_EXPR_IP4_ADDR:
- proto_field_set_u32(hdr, field->id, field_expr.val.ip4_addr.s_addr);
+ proto_hdr_field_set_u32(hdr, field->id, field_expr.val.ip4_addr.s_addr);
break;
case FIELD_EXPR_IP6_ADDR:
- proto_field_set_bytes(hdr, field->id,
+ proto_hdr_field_set_bytes(hdr, field->id,
(uint8_t *)&field_expr.val.ip6_addr.s6_addr);
break;
@@ -878,9 +878,9 @@ vlan_expr
: vlan_field skip_white '=' skip_white field_value_expr
{ proto_field_expr_eval(); }
| K_1Q
- { proto_field_set_be16(hdr, VLAN_TPID, ETH_P_8021Q); }
+ { proto_hdr_field_set_be16(hdr, VLAN_TPID, ETH_P_8021Q); }
| K_1AD
- { proto_field_set_be16(hdr, VLAN_TPID, ETH_P_8021AD); }
+ { proto_hdr_field_set_be16(hdr, VLAN_TPID, ETH_P_8021AD); }
;
mpls_proto
@@ -945,13 +945,13 @@ arp_expr
{ proto_field_set(ARP_OPER);
proto_field_expr_eval(); }
| K_OPER skip_white '=' skip_white K_REQUEST
- { proto_field_set_be16(hdr, ARP_OPER, ARPOP_REQUEST); }
+ { proto_hdr_field_set_be16(hdr, ARP_OPER, ARPOP_REQUEST); }
| K_OPER skip_white '=' skip_white K_REPLY
- { proto_field_set_be16(hdr, ARP_OPER, ARPOP_REPLY); }
+ { proto_hdr_field_set_be16(hdr, ARP_OPER, ARPOP_REPLY); }
| K_REQUEST
- { proto_field_set_be16(hdr, ARP_OPER, ARPOP_REQUEST); }
+ { proto_hdr_field_set_be16(hdr, ARP_OPER, ARPOP_REQUEST); }
| K_REPLY
- { proto_field_set_be16(hdr, ARP_OPER, ARPOP_REPLY); }
+ { proto_hdr_field_set_be16(hdr, ARP_OPER, ARPOP_REPLY); }
;
arp
: K_ARP { proto_add(PROTO_ARP); }
@@ -987,8 +987,8 @@ ip4_field
ip4_expr
: ip4_field skip_white '=' skip_white field_value_expr
{ proto_field_expr_eval(); }
- | K_DF { proto_field_set_be16(hdr, IP4_DF, 1); }
- | K_MF { proto_field_set_be16(hdr, IP4_MF, 1); }
+ | K_DF { proto_hdr_field_set_be16(hdr, IP4_DF, 1); }
+ | K_MF { proto_hdr_field_set_be16(hdr, IP4_MF, 1); }
;
ip4
@@ -1053,11 +1053,11 @@ icmp4_expr
: icmp4_field skip_white '=' skip_white field_value_expr
{ proto_field_expr_eval(); }
| K_ECHO_REQUEST
- { proto_field_set_u8(hdr, ICMPV4_TYPE, ICMP_ECHO);
- proto_field_set_u8(hdr, ICMPV4_CODE, 0); }
+ { proto_hdr_field_set_u8(hdr, ICMPV4_TYPE, ICMP_ECHO);
+ proto_hdr_field_set_u8(hdr, ICMPV4_CODE, 0); }
| K_ECHO_REPLY
- { proto_field_set_u8(hdr, ICMPV4_TYPE, ICMP_ECHOREPLY);
- proto_field_set_u8(hdr, ICMPV4_CODE, 0); }
+ { proto_hdr_field_set_u8(hdr, ICMPV4_TYPE, ICMP_ECHOREPLY);
+ proto_hdr_field_set_u8(hdr, ICMPV4_CODE, 0); }
;
icmp4
@@ -1085,13 +1085,13 @@ icmp6_expr
{ proto_field_set(ICMPV6_TYPE);
proto_field_expr_eval(); }
| K_TYPE skip_white '=' K_ECHO_REQUEST
- { proto_field_set_u8(hdr, ICMPV6_TYPE, ICMPV6_ECHO_REQUEST); }
+ { proto_hdr_field_set_u8(hdr, ICMPV6_TYPE, ICMPV6_ECHO_REQUEST); }
| K_ECHO_REQUEST
- { proto_field_set_u8(hdr, ICMPV6_TYPE, ICMPV6_ECHO_REQUEST); }
+ { proto_hdr_field_set_u8(hdr, ICMPV6_TYPE, ICMPV6_ECHO_REQUEST); }
| K_TYPE skip_white '=' K_ECHO_REPLY
- { proto_field_set_u8(hdr, ICMPV6_TYPE, ICMPV6_ECHO_REPLY); }
+ { proto_hdr_field_set_u8(hdr, ICMPV6_TYPE, ICMPV6_ECHO_REPLY); }
| K_ECHO_REPLY
- { proto_field_set_u8(hdr, ICMPV6_TYPE, ICMPV6_ECHO_REPLY); }
+ { proto_hdr_field_set_u8(hdr, ICMPV6_TYPE, ICMPV6_ECHO_REPLY); }
;
icmp6
: K_ICMP6 { proto_add(PROTO_ICMP6); }
@@ -1147,14 +1147,14 @@ tcp_field
tcp_expr
: tcp_field skip_white '=' skip_white field_value_expr
{ proto_field_expr_eval(); }
- | K_CWR { proto_field_set_be16(hdr, TCP_CWR, 1); }
- | K_ECE { proto_field_set_be16(hdr, TCP_ECE, 1); }
- | K_URG { proto_field_set_be16(hdr, TCP_URG, 1); }
- | K_ACK { proto_field_set_be16(hdr, TCP_ACK, 1); }
- | K_PSH { proto_field_set_be16(hdr, TCP_PSH, 1); }
- | K_RST { proto_field_set_be16(hdr, TCP_RST, 1); }
- | K_SYN { proto_field_set_be16(hdr, TCP_SYN, 1); }
- | K_FIN { proto_field_set_be16(hdr, TCP_FIN, 1); }
+ | K_CWR { proto_hdr_field_set_be16(hdr, TCP_CWR, 1); }
+ | K_ECE { proto_hdr_field_set_be16(hdr, TCP_ECE, 1); }
+ | K_URG { proto_hdr_field_set_be16(hdr, TCP_URG, 1); }
+ | K_ACK { proto_hdr_field_set_be16(hdr, TCP_ACK, 1); }
+ | K_PSH { proto_hdr_field_set_be16(hdr, TCP_PSH, 1); }
+ | K_RST { proto_hdr_field_set_be16(hdr, TCP_RST, 1); }
+ | K_SYN { proto_hdr_field_set_be16(hdr, TCP_SYN, 1); }
+ | K_FIN { proto_hdr_field_set_be16(hdr, TCP_FIN, 1); }
;
tcp