From e476a36e65cd8508c6473a19e497fb04487e2214 Mon Sep 17 00:00:00 2001 From: Vadim Kochan Date: Tue, 26 Jan 2016 22:24:59 +0200 Subject: trafgen: Add basic protocol generation logic Add new trafgen_proto.c module with basic protocol header fields generation logic. This will allow to support protocol specific keywords in the trafgen configuration language. Each protocol must implement struct proto_hdr and register it to the global proto list. Protocol headers consist of a set of fields, and each field must be described via struct proto_field by specifying unique id, length and offset (relative to the header start). Fields smaller than 8 bits can be described via left shift & mask. The following callbacks are invoked to perform special actions to build the header during parsing: 1) header_init - required fields must be added to the packet and initialized with default values. 2) header_finish - it is invoked when header is specified, all user specified fields are set. 3) packet_finish - callback is invoked from upper to lower header to calculate fields depending on upper layers such as total length or checksum. The protocol generation API provides convenience protocol field setters/getters to to be used in the parser while crafting the packet. Signed-off-by: Vadim Kochan [tk: wordsmithing on commit message, minor variable type changes] Signed-off-by: Tobias Klauser --- trafgen.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'trafgen.c') diff --git a/trafgen.c b/trafgen.c index c74a973..949f909 100644 --- a/trafgen.c +++ b/trafgen.c @@ -54,6 +54,7 @@ #include "timer.h" #include "ring_tx.h" #include "csum.h" +#include "trafgen_proto.h" #ifndef timeval_to_timespec #define timeval_to_timespec(tv, ts) { \ @@ -1215,6 +1216,8 @@ int main(int argc, char **argv) register_signal(SIGTERM, signal_handler); register_signal(SIGHUP, signal_handler); + protos_init(ctx.device); + if (prio_high) { set_proc_prio(-20); set_sched_status(SCHED_FIFO, sched_get_priority_max(SCHED_FIFO)); -- cgit v1.2.3-54-g00ecf