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_proto.h | |
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_proto.h')
-rw-r--r-- | trafgen_proto.h | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/trafgen_proto.h b/trafgen_proto.h index 56e7271..94eb4e7 100644 --- a/trafgen_proto.h +++ b/trafgen_proto.h @@ -108,7 +108,7 @@ extern void proto_header_fields_add(struct proto_hdr *hdr, extern bool proto_hdr_field_is_set(struct proto_hdr *hdr, uint32_t fid); extern void proto_hdr_field_set_bytes(struct proto_hdr *hdr, uint32_t fid, - const uint8_t *bytes); + const uint8_t *bytes, size_t len); extern void proto_hdr_field_set_u8(struct proto_hdr *hdr, uint32_t fid, uint8_t val); extern uint8_t proto_hdr_field_get_u8(struct proto_hdr *hdr, uint32_t fid); extern void proto_hdr_field_set_u16(struct proto_hdr *hdr, uint32_t fid, uint16_t val); @@ -117,7 +117,7 @@ extern void proto_hdr_field_set_u32(struct proto_hdr *hdr, uint32_t fid, uint32_ extern uint32_t proto_hdr_field_get_u32(struct proto_hdr *hdr, uint32_t fid); extern void proto_hdr_field_set_default_bytes(struct proto_hdr *hdr, uint32_t fid, - const uint8_t *bytes); + const uint8_t *bytes, size_t len); extern void proto_hdr_field_set_default_u8(struct proto_hdr *hdr, uint32_t fid, uint8_t val); extern void proto_hdr_field_set_default_u16(struct proto_hdr *hdr, uint32_t fid, @@ -155,7 +155,8 @@ extern void proto_field_set_u32(struct proto_field *field, uint32_t val); extern uint32_t proto_field_get_u32(struct proto_field *field); extern void proto_field_set_be16(struct proto_field *field, uint16_t val); extern void proto_field_set_be32(struct proto_field *field, uint32_t val); -extern void proto_field_set_bytes(struct proto_field *field, const uint8_t *bytes); +extern void proto_field_set_bytes(struct proto_field *field, const uint8_t *bytes, + size_t len); extern void proto_field_func_add(struct proto_field *field, struct proto_field_func *func); |