diff options
author | Vadim Kochan <vadim4j@gmail.com> | 2016-02-01 19:01:38 +0200 |
---|---|---|
committer | Tobias Klauser <tklauser@distanz.ch> | 2016-02-02 16:54:47 +0100 |
commit | 287e1d8899e2649395022b57230c1a93c125cc2c (patch) | |
tree | 11e5082db9fca5168089e4f958e8546c9a624f61 /trafgen_l4.c | |
parent | a7f35557331a283f4064c578f76be6330d54eaf4 (diff) |
trafgen: ipv4: Add setting next protocol id
Move setting lower protocol id field value from UDP & TCP
protocols to IPv4 only, so lower layer will know exactly value
to set in protocol id field.
Signed-off-by: Vadim Kochan <vadim4j@gmail.com>
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Diffstat (limited to 'trafgen_l4.c')
-rw-r--r-- | trafgen_l4.c | 16 |
1 files changed, 2 insertions, 14 deletions
diff --git a/trafgen_l4.c b/trafgen_l4.c index 1505b43..64aada4 100644 --- a/trafgen_l4.c +++ b/trafgen_l4.c @@ -43,12 +43,7 @@ static struct proto_field tcp_fields[] = { static void udp_header_init(struct proto_hdr *hdr) { - struct proto_hdr *lower; - - lower = proto_lower_default_add(hdr, PROTO_IP4); - - if (lower->id == PROTO_IP4) - proto_field_set_default_u8(lower, IP4_PROTO, IPPROTO_UDP); + proto_lower_default_add(hdr, PROTO_IP4); proto_header_fields_add(hdr, udp_fields, array_size(udp_fields)); } @@ -85,14 +80,7 @@ static struct proto_hdr udp_hdr = { static void tcp_header_init(struct proto_hdr *hdr) { - struct proto_hdr *lower; - - proto_lower_default_add(PROTO_IP4); - - lower = proto_current_header(); - - if (lower->id == PROTO_IP4) - proto_field_set_default_u8(lower, IP4_PROTO, IPPROTO_TCP); + proto_lower_default_add(hdr, PROTO_IP4); proto_header_fields_add(hdr, tcp_fields, array_size(tcp_fields)); |