Add short note about field offset syntax with an example.
Signed-off-by: Vadim Kochan <[email protected]>
---
v2:
Change commit messages and man file that field offset expression
is used with function expression, and added validation for it in trafgen
parser.
v3:
Add some examples with new field offset syntax.
Mention syntax was used from pcap filter.
trafgen.8 | 43 +++++++++++++++++++++++++++++++++++++++++++
1 file changed, 43 insertions(+)
diff --git a/trafgen.8 b/trafgen.8
index 62716bb..c633398 100644
--- a/trafgen.8
+++ b/trafgen.8
@@ -329,6 +329,49 @@ Example of using dynamic functions:
.in -4
.sp
+Field might be set with a function at a specific offset within a field:
+.sp
+.in +4
+<field>[<index>] | <field>[<index>:<length>]
+.sp
+.in +4
+<index> - relative field's offset with range 0..<field.len> - 1
+.sp
+<length> - length/size of the value which will be set - 1,2 or 4 bytes
(default: 1).
+.in -4
+.sp
+The <index> starts from the 1st field's byte in the network order.
+.sp
+The syntax is similar which is used in pcap filter (man pcap-filter) for
matching
+header field at a specified offset.
+.sp
+Examples of using field offset with a shortified output from netsniff-ng tool:
+.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.
--
2.10.2
--
You received this message because you are subscribed to the Google Groups
"netsniff-ng" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.