diff options
author | Vadim Kochan <vadim4j@gmail.com> | 2017-06-01 13:12:26 +0300 |
---|---|---|
committer | Tobias Klauser <tklauser@distanz.ch> | 2017-06-02 09:15:17 +0200 |
commit | 906cb247a831e37665a19e2c6b41b7cfd4c6621b (patch) | |
tree | 41068841c4b503cc5c7724a4184093e1e0c08834 /trafgen_l2.c | |
parent | 83f11c231626f79433a021c526ffa1ac7521ae36 (diff) |
trafgen: proto: Allow to set field with variable length
It is quite tricky to set field value with a variable length
(i.e. DNS query name), to make it possible the field
needs to be added to header with 'len=0' in that case there
will be no any payload allocation, but only while setting the field
value the packet will be appended with a real length bytes and after
the field needs to be relocated to the right place.
Also add 'len' parameter to *_set_bytes(...) functoins to have better
control over it.
Signed-off-by: Vadim Kochan <vadim4j@gmail.com>
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Diffstat (limited to 'trafgen_l2.c')
-rw-r--r-- | trafgen_l2.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/trafgen_l2.c b/trafgen_l2.c index 5fc0a0d..427ff9b 100644 --- a/trafgen_l2.c +++ b/trafgen_l2.c @@ -69,7 +69,7 @@ static void pause_header_init(struct proto_hdr *hdr) struct proto_hdr *lower; lower = proto_lower_default_add(hdr, PROTO_ETH); - proto_hdr_field_set_default_bytes(lower, ETH_DST_ADDR, eth_dst); + proto_hdr_field_set_default_bytes(lower, ETH_DST_ADDR, eth_dst, 6); proto_header_fields_add(hdr, pause_fields, array_size(pause_fields)); proto_hdr_field_set_default_be16(hdr, PAUSE_OPCODE, 0x1); @@ -109,7 +109,7 @@ static void pfc_header_init(struct proto_hdr *hdr) struct proto_hdr *lower; lower = proto_lower_default_add(hdr, PROTO_ETH); - proto_hdr_field_set_default_bytes(lower, ETH_DST_ADDR, eth_dst); + proto_hdr_field_set_default_bytes(lower, ETH_DST_ADDR, eth_dst, 6); proto_header_fields_add(hdr, pfc_fields, array_size(pfc_fields)); proto_hdr_field_set_default_be16(hdr, PFC_OPCODE, 0x0101); @@ -180,7 +180,7 @@ static void arp_header_init(struct proto_hdr *hdr) if (lower->ops->id == PROTO_ETH) { const uint8_t bcast[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; - proto_hdr_field_set_default_bytes(lower, ETH_DST_ADDR, bcast); + proto_hdr_field_set_default_bytes(lower, ETH_DST_ADDR, bcast, 6); } proto_header_fields_add(hdr, arp_fields, array_size(arp_fields)); |