summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobias Klauser <tklauser@distanz.ch>2016-08-09 16:39:13 +0200
committerTobias Klauser <tklauser@distanz.ch>2016-08-09 16:39:13 +0200
commit66cf8073cb31cebf4532afec9b18556aff8088fb (patch)
tree9a115e013af449417261c5f12df1bf7cd1944dd7
parent4e47fd021a6945aa626eaef4446c5b547d8c2a85 (diff)
trafgen: proto: Make bytes pointer const in proto field set functions
Make the __proto_field_set_bytes() take a const uint8_t *bytes pointer and also changed all callers accordingly. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
-rw-r--r--trafgen_l2.c2
-rw-r--r--trafgen_proto.c9
-rw-r--r--trafgen_proto.h4
3 files changed, 9 insertions, 6 deletions
diff --git a/trafgen_l2.c b/trafgen_l2.c
index 316d236..2e411e6 100644
--- a/trafgen_l2.c
+++ b/trafgen_l2.c
@@ -115,7 +115,7 @@ static void arp_header_init(struct proto_hdr *hdr)
lower = proto_lower_default_add(hdr, PROTO_ETH);
if (lower->id == PROTO_ETH) {
- uint8_t bcast[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
+ const uint8_t bcast[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
proto_field_set_default_bytes(lower, ETH_DST_ADDR, bcast);
}
diff --git a/trafgen_proto.c b/trafgen_proto.c
index 8baacbe..4219794 100644
--- a/trafgen_proto.c
+++ b/trafgen_proto.c
@@ -171,7 +171,8 @@ set_proto:
}
static void __proto_field_set_bytes(struct proto_hdr *hdr, uint32_t fid,
- uint8_t *bytes, bool is_default, bool is_be)
+ const uint8_t *bytes, bool is_default,
+ bool is_be)
{
struct proto_field *field;
uint8_t *payload, *p8;
@@ -224,7 +225,8 @@ static void __proto_field_set_bytes(struct proto_hdr *hdr, uint32_t fid,
field->is_set = true;
}
-void proto_field_set_bytes(struct proto_hdr *hdr, uint32_t fid, uint8_t *bytes)
+void proto_field_set_bytes(struct proto_hdr *hdr, uint32_t fid,
+ const uint8_t *bytes)
{
__proto_field_set_bytes(hdr, fid, bytes, false, false);
}
@@ -273,7 +275,8 @@ uint32_t proto_field_get_u32(struct proto_hdr *hdr, uint32_t fid)
return field_unmask_and_unshift(field, be32_to_cpu(val));
}
-void proto_field_set_default_bytes(struct proto_hdr *hdr, uint32_t fid, uint8_t *bytes)
+void proto_field_set_default_bytes(struct proto_hdr *hdr, uint32_t fid,
+ const uint8_t *bytes)
{
__proto_field_set_bytes(hdr, fid, bytes, true, false);
}
diff --git a/trafgen_proto.h b/trafgen_proto.h
index a66f8d3..dbba700 100644
--- a/trafgen_proto.h
+++ b/trafgen_proto.h
@@ -77,7 +77,7 @@ extern void proto_header_fields_add(struct proto_hdr *hdr,
extern bool proto_field_is_set(struct proto_hdr *hdr, uint32_t fid);
extern void proto_field_set_bytes(struct proto_hdr *hdr, uint32_t fid,
- uint8_t *bytes);
+ const uint8_t *bytes);
extern void proto_field_set_u8(struct proto_hdr *hdr, uint32_t fid, uint8_t val);
extern uint8_t proto_field_get_u8(struct proto_hdr *hdr, uint32_t fid);
extern void proto_field_set_u16(struct proto_hdr *hdr, uint32_t fid, uint16_t val);
@@ -86,7 +86,7 @@ extern void proto_field_set_u32(struct proto_hdr *hdr, uint32_t fid, uint32_t va
extern uint32_t proto_field_get_u32(struct proto_hdr *hdr, uint32_t fid);
extern void proto_field_set_default_bytes(struct proto_hdr *hdr, uint32_t fid,
- uint8_t *bytes);
+ const uint8_t *bytes);
extern void proto_field_set_default_u8(struct proto_hdr *hdr, uint32_t fid,
uint8_t val);
extern void proto_field_set_default_u16(struct proto_hdr *hdr, uint32_t fid,