[netsniff-ng] [PATCH 4/7] trafgen: proto: Add proto field only setters/getters

2016-12-17 Thread Vadim Kochan
Add proto_field_xxx functions to set/get value via specified proto_field only. It is good to have such API in case if application needs to set/get value for some custom proto_field instance. Signed-off-by: Vadim Kochan --- trafgen_proto.c | 46

[netsniff-ng] [PATCH 3/7] trafgen: proto: Rename proto_field_xxx -> proto_hdr_field_xxx

2016-12-17 Thread Vadim Kochan
Rename all proto_field_xxx(...) functions to proto_hdr_field(...). It is good for 2 reasons: 1) proto_hdr_field_xxx naming is more consistent as it is related to proto_hdr API. 2) It makes possible to introduce proto_field_xxx API which will operate only with struct

[netsniff-ng] [PATCH 2/7] trafgen: proto: Change __proto_field_set_bytes(...) to take field

2016-12-17 Thread Vadim Kochan
Change __proto_field_set_bytes(...) function to take struct proto_field instead of do looup by hdr & fid. It is needed to able use this function with some custom modified struct proto_field (len, pkt_offset). Signed-off-by: Vadim Kochan --- trafgen_proto.c | 50

[netsniff-ng] [PATCH 0/7] trafgen: Allow set proto field value at specific offset

2016-12-17 Thread Vadim Kochan
Extend field expression with the following syntax: [] | [:] which allows to specify value or function at specified offset relative to the field's offset within a header. The trick to implement this was to use copies of proto_field instances in the packet_dyn->fields array which allows to

[netsniff-ng] [PATCH 1/7] trafgen: parser: Rename field_expr -> field_value_expr rule

2016-12-17 Thread Vadim Kochan
Rename field_expr rule to field_value_expr to indicate the rule relates to field value part in case if there will be added field_expr rule to indicate field expression syntax. Signed-off-by: Vadim Kochan --- trafgen_parser.y | 30 +++--- 1 file

[netsniff-ng] [PATCH 6/7] trafgen: parser: Allow to set value/func at field offset

2016-12-17 Thread Vadim Kochan
Extend proto field expression to: proto_field[{index}:{len}] = {func} which allows to specify function/value on the part of the field via index and value length (default is 1 - 1 byte). This rule is optional. It was needed to keep of proto_field's copies in packet_dyn->fields instead of

[netsniff-ng] [PATCH 5/7] trafgen: parser: Parse IPv6 address by strict match pattern

2016-12-17 Thread Vadim Kochan
Used IPv6 pattern from nftables project to match valid only IPv6 address to do not mess with MAC or other syntax patterns with ':' symbol. Signed-off-by: Vadim Kochan --- trafgen_lexer.l | 51 +++ trafgen_parser.y | 2 +- 2

[netsniff-ng] [PATCH 7/7] man: trafgen: Add short description about field offset using

2016-12-17 Thread Vadim Kochan
Add short note about field offset syntax with an example. Signed-off-by: Vadim Kochan --- trafgen.8 | 25 + 1 file changed, 25 insertions(+) diff --git a/trafgen.8 b/trafgen.8 index 62716bb..c58d429 100644 --- a/trafgen.8 +++ b/trafgen.8 @@ -329,6

[netsniff-ng] [PATCH v4] flowtop: Move & refactor walk_processes(...) to proc.c

2016-12-17 Thread Vadim Kochan
Add proc_find_by_inode(...) in proc.c which finds pid by inode & gets processe's command line and use it in the flowtop.c instead of walk_processes(...). Signed-off-by: Vadim Kochan --- v2: 1) Remove sys/stat.h & dirent.h from flowtop.c includes. 2) Add static to