On Sat, Jun 27, 2015 at 04:57:10AM +0300, Vadim Kochan wrote:
> Hi,
>
> This is the 1-st "try" version of how I see the protocol generation API for
> the
> trafgen util as mz replacement (at least for better performance).
>
> I am sending this just because to get your feedback about conceptual idea,
> and as soon as I got some basic working version I decided to share the
> code just to get know if I am moving in the right direction.
>
> Added high-level command line protocol packet building intreface,
> which allows to specify protocol parameters to build the header and
> payload.
>
> Each protocol is represented by proto_gen struct which is responsible
> only for providing field info (size, data) by name to trafgen's
> low level packet generation layer.
>
> All packet generation routine is performed by the generic code in
> trafgen.c which parses the command line, obtains proto name, param=value
> list and calls the specific protocol handler to get protocol field info
> by name, so the TX routine remains the same.
>
> The command line syntax looks like:
>
> trafgen/trafgen --dev lo eth da = AA:BB:CC:DD:EE:FF sa=11:22:33:44:55:66,
> arp op=rep tip=192.168.1.1 -n 1
>
> so the first is proto name and after there are param value pairs which
> are separated by space, in case if there are multiple protocols
> specified - their should be separated by "," after last param value of
> the previous protocol.
>
> I think the picture will be more clear after adding IP protocol with checksum
> handling.
>
> Vadim Kochan (6):
> trafgen: Move ctx struct to separated header
> str: Add converting cmdline args vector to str
> trafgen: Export packet manipulation funcs for proto gen
> trafgen: Add helper to get current packet
> str: Add funcs for converting hex string to bytes
> trafgen: Add basic protocol generation feature
>
> layer2_gen.c | 248 +++++++++++++++++++++++++++++++++++++++++++++++++++++
> net_utils.c | 41 +++++++++
> net_utils.h | 7 ++
> netsniff-ng.c | 18 +---
> proto_gen.c | 115 +++++++++++++++++++++++++
> proto_gen.h | 72 ++++++++++++++++
> str.c | 87 +++++++++++++++++++
> str.h | 2 +
> trafgen.c | 255
> ++++++++++++++++++++++++++++++++++++++++++++++++++-----
> trafgen.h | 21 +++++
> trafgen/Makefile | 3 +
> trafgen_conf.h | 7 ++
> trafgen_parser.y | 13 ++-
> 13 files changed, 849 insertions(+), 40 deletions(-)
> create mode 100644 layer2_gen.c
> create mode 100644 net_utils.c
> create mode 100644 net_utils.h
> create mode 100644 proto_gen.c
> create mode 100644 proto_gen.h
> create mode 100644 trafgen.h
>
> --
> 2.4.2
>
Well, you may find some unused things but this is because they might be
used later or this is because I forgot to clean them.
Also I just checked that in the eth print_help callback there is wrong
command line example (mz-like style) which is not used in the
code, thats because in the beginning I tried to follow mz style.
So if you want better cleaner code I will prepare, since I continue
to work with adding missed things like:
- getting default devices parameters from ctx in case if src mac/ip
address is not specified;
- IPv4 protocl support where it will be nedeed to consider payload
(next layer protocol) data to generate checksum opcodes;
BTW I am not sure if the 'struct proto_gen' is a good name, may be
'packet_gen' is better.
Regards,
--
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.