summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobias Klauser <tklauser@distanz.ch>2016-08-17 09:30:50 +0200
committerTobias Klauser <tklauser@distanz.ch>2016-09-15 18:27:39 +0200
commit93127b0f9515be4b8f1365d7670744fcac0ade16 (patch)
treec739141ea2fd70206ce0f443095ee76d5ed3e91f
parent857126daf5b96292be0fd924e8462b76177af025 (diff)
trafgen: proto: Initialize lower proto header pointer on declaration
Assign the pointer to the lower layer header on declaration instead of a separate line. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
-rw-r--r--trafgen_l2.c8
1 files changed, 2 insertions, 6 deletions
diff --git a/trafgen_l2.c b/trafgen_l2.c
index f09b2a6..866559c 100644
--- a/trafgen_l2.c
+++ b/trafgen_l2.c
@@ -67,11 +67,9 @@ static struct proto_field vlan_fields[] = {
static void vlan_header_init(struct proto_hdr *hdr)
{
- struct proto_hdr *lower;
+ struct proto_hdr *lower = proto_lower_default_add(hdr, PROTO_ETH);
uint16_t lower_etype = 0;
- lower = proto_lower_default_add(hdr, PROTO_ETH);
-
proto_header_fields_add(hdr, vlan_fields, array_size(vlan_fields));
if (lower->ops->id == PROTO_ETH)
@@ -110,9 +108,7 @@ static struct proto_field arp_fields[] = {
static void arp_header_init(struct proto_hdr *hdr)
{
- struct proto_hdr *lower;
-
- lower = proto_lower_default_add(hdr, PROTO_ETH);
+ struct proto_hdr *lower = proto_lower_default_add(hdr, PROTO_ETH);
if (lower->ops->id == PROTO_ETH) {
const uint8_t bcast[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };