summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVadim Kochan <vadim4j@gmail.com>2016-12-21 20:33:33 +0200
committerTobias Klauser <tklauser@distanz.ch>2017-01-05 10:35:05 +0100
commit39b95ab409445ee761811e909a1742ad4985ff87 (patch)
tree5aca6a49531c707081c7d01bcda47c72ddb96805
parent6a573b22bdafe25d3341a8e20f7916b219042f7a (diff)
man: trafgen: Add short description about field offset usage
Add short note about field offset syntax with an example. Signed-off-by: Vadim Kochan <vadim4j@gmail.com> Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
-rw-r--r--trafgen.844
1 files changed, 44 insertions, 0 deletions
diff --git a/trafgen.8 b/trafgen.8
index 62716bb..e09b7a0 100644
--- a/trafgen.8
+++ b/trafgen.8
@@ -329,6 +329,50 @@ Example of using dynamic functions:
.in -4
.sp
+Fields might be further manipulated with a function at a specific offset:
+.sp
+.in +4
+<field>[<index>] | <field>[<index>:<length>]
+.sp
+.in +4
+<index> - relative field offset with range 0..<field.len> - 1
+.sp
+<length> - length/size of the value which will be set; either 1, 2 or 4 bytes (default: 1)
+.in -4
+.sp
+The <index> starts from the field's first byte in network order.
+.sp
+The syntax is similar to the one used in pcap filters (man pcap-filter) for
+matching header field at a specified offset.
+.sp
+Examples of using field offset (showing the effect in a shortenet output from
+netsniff-ng):
+.sp
+.in +4
+1) trafgen -o lo --cpus 1 -n 3 '{ eth(da=11:22:33:44:55:66, da[0]=dinc()), tcp() }'
+
+.in +4
+[ Eth MAC (00:00:00:00:00:00 => 11:22:33:44:55:66)
+
+[ Eth MAC (00:00:00:00:00:00 => 12:22:33:44:55:66)
+
+[ Eth MAC (00:00:00:00:00:00 => 13:22:33:44:55:66)
+.in -4
+
+2) trafgen -o lo --cpus 1 -n 3 '{ ipv4(da=1.2.3.4, da[0]=dinc()), tcp() }'
+
+.in +4
+[ IPv4 Addr (127.0.0.1 => 1.2.3.4)
+
+[ IPv4 Addr (127.0.0.1 => 2.2.3.4)
+
+[ IPv4 Addr (127.0.0.1 => 3.2.3.4)
+.in -4
+
+.in -4
+.in -4
+
+.sp
All required lower layer headers will be filled automatically if they were not
specified by the user. The headers will be filled in the order they were
specified. Each header will be filled with some mimimum required set of fields.