summaryrefslogtreecommitdiff
path: root/trafgen_lexer.l
diff options
context:
space:
mode:
authorTobias Klauser <tklauser@distanz.ch>2016-02-01 15:56:10 +0100
committerTobias Klauser <tklauser@distanz.ch>2016-02-01 16:22:24 +0100
commitf26175af848bfb3faaedd98b402949e8bd7ab8bc (patch)
tree3901fb68dd629e08abc02b81349ff4cb6b26f213 /trafgen_lexer.l
parent0042946ef9e332e32af00a0fe0c6c7b6eec4b0e1 (diff)
trafgen: parser: Add TCP header generation function
Add a function 'tcp()' to generate TCP headers from the trafgen configuration language. Fields supported: sp|sport TCP source port (default 0) dp|dport TCP destination port (default 0) seq Sequence number (default: 0) aseq|ackseq Acknowledgement number (default 0) doff|hlen Header length/data offset (default: 5) cwr Congestion Window Reduced flag (default: 0) ece|ecn ECN-Echo flag (default: 0) urg Urgent flag (default: 0) ack Acknowledgement flag (default: 0) psh Push flag (default: 0) rst Reset flag (default: 0) syn Synchronize flag (default: 0) fin Finish flag (default: 0) win|window Receive window size (default: 0) csum Checksum field (calculated automatically) urgptr Urgent pointer (default: 0) Example (SYN on port 80/http): { tcp(dport=80, syn, window=5840) } Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Diffstat (limited to 'trafgen_lexer.l')
-rw-r--r--trafgen_lexer.l16
1 files changed, 16 insertions, 0 deletions
diff --git a/trafgen_lexer.l b/trafgen_lexer.l
index 5ab0815..83e7602 100644
--- a/trafgen_lexer.l
+++ b/trafgen_lexer.l
@@ -143,10 +143,26 @@ ip4_addr ([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)
"sp"|"sport" { return K_SPORT; }
"dp"|"dport" { return K_DPORT; }
+ /* TCP */
+"seq" { return K_SEQ; }
+"ackseq"|"aseq" { return K_ACK_SEQ; }
+"doff"|hlen { return K_DOFF; }
+"cwr" { return K_CWR; }
+"ece"|"ecn" { return K_ECE; }
+"urg" { return K_URG; }
+"ack" { return K_ACK; }
+"psh" { return K_PSH; }
+"rst" { return K_RST; }
+"syn" { return K_SYN; }
+"fin" { return K_FIN; }
+"win"|"window" { return K_WINDOW; }
+"urgptr" { return K_URG_PTR; }
+
"eth" { return K_ETH; }
"arp" { return K_ARP; }
"ip4"|"ipv4" { return K_IP4; }
"udp" { return K_UDP; }
+"tcp" { return K_TCP; }
[ ]*"-"[ ]* { return '-'; }
[ ]*"+"[ ]* { return '+'; }