diff options
author | Vadim Kochan <vadim4j@gmail.com> | 2016-01-29 00:06:25 +0200 |
---|---|---|
committer | Tobias Klauser <tklauser@distanz.ch> | 2016-01-29 08:58:54 +0100 |
commit | be21df123309c83cd47a1fa5f2c0ee1cf4657810 (patch) | |
tree | 5330fb556f0f2825a4a5d4a174dc31951ba8fb98 /trafgen_lexer.l | |
parent | baf47305fabce02017642b0f43472ab5a4eaa533 (diff) |
trafgen: parser: Add syntax for IPv4 protocol generation
Add 'ip4(), ipv4()' function to build IPv4 header.
Fields supported:
ihl IPv4 header length (default 5 )
ver|version IPv4 version (default 4)
ttl Time To Live (TTL) field (default 0)
dscp DiffServ field (default 0)
ecn ECN bits (default 0)
tos TOS (DSCP + ECN) field (default 0)
len|length IPv4 header + payload length (calculated by default)
id Identifier (default 0)
flags Flags field (default 0)
frag Fragment offset (default 0)
csum IPv4 header checksum (calculated by default)
df Set DF (Dont Fragment) bit to 1 (default is 0)
mf Set MF (More Fragments) bit to 1 (default is 0)
sa|saddr IPv4 source address (default used from output device)
da|daddr IPv4 destination address (default 0.0.0.0)
proto IPv4 protocol id (default 0)
Example:
{ ip4(df, mf, frag=100, prot=0x1, ecn=2, dscp=20) }
{ ip4(da=1.1.1.1), ip4(sa=3.3.3.3, da=3.3.3.4) }
Last example generates IP-in-IP packet.
Signed-off-by: Vadim Kochan <vadim4j@gmail.com>
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Diffstat (limited to 'trafgen_lexer.l')
-rw-r--r-- | trafgen_lexer.l | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/trafgen_lexer.l b/trafgen_lexer.l index 5467c70..eeb252f 100644 --- a/trafgen_lexer.l +++ b/trafgen_lexer.l @@ -119,8 +119,23 @@ ip_addr ([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+) "htype" { return K_HTYPE; } "ptype" { return K_PTYPE; } +"ihl" { return K_IHL; } +"ver"|"version" { return K_VER; } +"ttl" { return K_TTL; } +"dscp" { return K_DSCP; } +"ecn" { return K_ECN; } +"tos" { return K_TOS; } +"len"|"length" { return K_LEN; } +"id" { return K_ID; } +"flags" { return K_FLAGS; } +"frag" { return K_FRAG; } +"csum" { return K_CSUM; } +"df" { return K_DF; } +"mf" { return K_MF; } + "eth" { return K_ETH; } "arp" { return K_ARP; } +"ip4"|"ipv4" { return K_IP4; } [ ]*"-"[ ]* { return '-'; } [ ]*"+"[ ]* { return '+'; } |