summaryrefslogtreecommitdiff
path: root/trafgen_l3.c
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_l3.c
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_l3.c')
-rw-r--r--trafgen_l3.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/trafgen_l3.c b/trafgen_l3.c
index bce8ca9..4d67f58 100644
--- a/trafgen_l3.c
+++ b/trafgen_l3.c
@@ -38,8 +38,8 @@ static void ipv4_header_init(struct proto_hdr *hdr)
proto_header_fields_add(hdr, ipv4_fields, array_size(ipv4_fields));
- proto_field_set_default_u8(hdr, IP4_VER, 4);
- proto_field_set_default_u8(hdr, IP4_IHL, 5);
+ proto_hdr_field_set_default_u8(hdr, IP4_VER, 4);
+ proto_hdr_field_set_default_u8(hdr, IP4_IHL, 5);
}
static void ipv4_field_changed(struct proto_field *field)
@@ -61,14 +61,14 @@ static void ipv4_csum_update(struct proto_hdr *hdr)
if (hdr->is_csum_valid)
return;
- if (proto_field_is_set(hdr, IP4_CSUM))
+ if (proto_hdr_field_is_set(hdr, IP4_CSUM))
return;
pkt = packet_get(hdr->pkt_id);
- proto_field_set_default_u16(hdr, IP4_CSUM, 0);
+ proto_hdr_field_set_default_u16(hdr, IP4_CSUM, 0);
csum = htons(calc_csum(&pkt->payload[hdr->pkt_offset], hdr->len));
- proto_field_set_default_u16(hdr, IP4_CSUM, bswap_16(csum));
+ proto_hdr_field_set_default_u16(hdr, IP4_CSUM, bswap_16(csum));
hdr->is_csum_valid = true;
}
@@ -79,8 +79,8 @@ static void ipv4_packet_finish(struct proto_hdr *hdr)
uint16_t total_len;
total_len = pkt->len - hdr->pkt_offset;
- proto_field_set_default_be16(hdr, IP4_LEN, total_len);
- proto_field_set_default_dev_ipv4(hdr, IP4_SADDR);
+ proto_hdr_field_set_default_be16(hdr, IP4_LEN, total_len);
+ proto_hdr_field_set_default_dev_ipv4(hdr, IP4_SADDR);
ipv4_csum_update(hdr);
}
@@ -109,7 +109,7 @@ static void ipv4_set_next_proto(struct proto_hdr *hdr, enum proto_id pid)
bug();
}
- proto_field_set_default_u8(hdr, IP4_PROTO, ip_proto);
+ proto_hdr_field_set_default_u8(hdr, IP4_PROTO, ip_proto);
}
static const struct proto_ops ipv4_proto_ops = {
@@ -139,7 +139,7 @@ static void ipv6_header_init(struct proto_hdr *hdr)
proto_header_fields_add(hdr, ipv6_fields, array_size(ipv6_fields));
- proto_field_set_default_be32(hdr, IP6_VER, 6);
+ proto_hdr_field_set_default_be32(hdr, IP6_VER, 6);
}
static void ipv6_field_changed(struct proto_field *field)
@@ -159,8 +159,8 @@ static void ipv6_packet_finish(struct proto_hdr *hdr)
struct packet *pkt = current_packet();
uint16_t total_len = pkt->len - hdr->pkt_offset - IPV6_HDR_LEN;
- proto_field_set_default_be16(hdr, IP6_LEN, total_len);
- proto_field_set_default_dev_ipv6(hdr, IP6_SADDR);
+ proto_hdr_field_set_default_be16(hdr, IP6_LEN, total_len);
+ proto_hdr_field_set_default_dev_ipv6(hdr, IP6_SADDR);
}
static void ipv6_set_next_proto(struct proto_hdr *hdr, enum proto_id pid)
@@ -181,7 +181,7 @@ static void ipv6_set_next_proto(struct proto_hdr *hdr, enum proto_id pid)
bug();
}
- proto_field_set_default_u8(hdr, IP6_NEXT_HDR, ip_proto);
+ proto_hdr_field_set_default_u8(hdr, IP6_NEXT_HDR, ip_proto);
}
static const struct proto_ops ipv6_proto_ops = {