summaryrefslogtreecommitdiff
path: root/trafgen_proto.h
diff options
context:
space:
mode:
authorVadim Kochan <vadim4j@gmail.com>2017-07-29 12:46:09 +0300
committerTobias Klauser <tklauser@distanz.ch>2017-08-10 09:03:46 +0200
commit439af62bca4794d78d53fb4634f560d6a75f0adb (patch)
tree346cc168c42bbe1d7f0eb6bd493d244016172a01 /trafgen_proto.h
parent19348cec323373d84674c1d2cf34315cbf47c80d (diff)
trafgen: Dump proto headers in *.cfg format
Added trafgen_dump.c module which dumps headers from packet in .cfg format. Packet is dumped if -o <file>.cfg was specified, it might be useful to specify *.pcap file as input and convert it into .cfg file to edit proto fields in human readable format. To make it possible several main changes were added: 1) packet id is embedded into struct packet.id, and it is updated on each realloc_packet() 2) Added new struct proto_hdr.get_next_proto callback to make possible apply fields of next header. 3) Added new dev_io ops for writting packets into .cfg file, to re-use common dev_io mechsnism for packets dumping. Before dump the default ETH_PROTO fields are applied as first header and then next proto_hdr is identified via .get_next_proto(...) callback. Meanwhile only eth, arp, vlan, ip4, udp, & tcp protos can be dissected into *.cfg format. 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.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/trafgen_proto.h b/trafgen_proto.h
index 36b8f2b..d756aca 100644
--- a/trafgen_proto.h
+++ b/trafgen_proto.h
@@ -49,6 +49,7 @@ struct proto_ops {
void (*packet_finish)(struct proto_hdr *hdr);
void (*packet_update)(struct proto_hdr *hdr);
void (*set_next_proto)(struct proto_hdr *hdr, enum proto_id pid);
+ enum proto_id (*get_next_proto)(struct proto_hdr *hdr);
};
struct proto_hdr {
@@ -101,11 +102,13 @@ struct proto_field {
extern void protos_init(struct dev_io *dev);
extern void proto_ops_register(const struct proto_ops *ops);
+struct proto_hdr *proto_packet_apply(enum proto_id pid, struct packet *pkt);
extern struct proto_hdr *proto_header_push(enum proto_id pid);
extern void proto_header_finish(struct proto_hdr *hdr);
extern void proto_packet_finish(void);
extern void proto_packet_update(uint32_t idx);
+extern enum proto_id proto_hdr_get_next_proto(struct proto_hdr *hdr);
extern struct packet *proto_hdr_packet(struct proto_hdr *hdr);
extern struct proto_hdr *proto_hdr_push_sub_header(struct proto_hdr *hdr, int id);
extern void proto_hdr_move_sub_header(struct proto_hdr *hdr, struct proto_hdr *from,
@@ -114,6 +117,7 @@ extern void proto_hdr_move_sub_header(struct proto_hdr *hdr, struct proto_hdr *f
extern struct proto_hdr *proto_lower_default_add(struct proto_hdr *hdr,
enum proto_id pid);
+extern struct proto_hdr *packet_last_header(struct packet *pkt);
extern struct proto_hdr *proto_lower_header(struct proto_hdr *hdr);
extern struct proto_hdr *proto_upper_header(struct proto_hdr *hdr);
extern uint8_t *proto_header_ptr(struct proto_hdr *hdr);
@@ -123,6 +127,7 @@ extern void proto_header_fields_add(struct proto_hdr *hdr,
size_t count);
extern bool proto_hdr_field_is_set(struct proto_hdr *hdr, uint32_t fid);
+extern uint8_t *proto_hdr_field_get_bytes(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, size_t len);
extern void proto_hdr_field_set_u8(struct proto_hdr *hdr, uint32_t fid, uint8_t val);
@@ -131,6 +136,7 @@ extern void proto_hdr_field_set_u16(struct proto_hdr *hdr, uint32_t fid, uint16_
extern uint16_t proto_hdr_field_get_u16(struct proto_hdr *hdr, uint32_t fid);
extern void proto_hdr_field_set_u32(struct proto_hdr *hdr, uint32_t fid, uint32_t val);
extern uint32_t proto_hdr_field_get_u32(struct proto_hdr *hdr, uint32_t fid);
+extern uint32_t proto_hdr_field_get_be32(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, size_t len);
@@ -172,6 +178,7 @@ extern void proto_field_set_u16(struct proto_field *field, uint16_t val);
extern uint16_t proto_field_get_u16(struct proto_field *field);
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 uint32_t proto_field_get_be32(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, size_t len);