From 76bd307a8ce82d839037c7437c0d181890adde02 Mon Sep 17 00:00:00 2001 From: Radoslav Bodo Date: Tue, 19 Jun 2018 21:57:37 +0200 Subject: trafgen: support ICMPv6 checksums Usage: csumicmp6(14, 54) Signed-off-by: Radoslav Bodo Signed-off-by: Tobias Klauser --- trafgen.c | 6 ++++++ trafgen_conf.h | 1 + trafgen_lexer.l | 1 + trafgen_parser.y | 5 ++++- 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/trafgen.c b/trafgen.c index d9e0e0e..e628646 100644 --- a/trafgen.c +++ b/trafgen.c @@ -376,6 +376,12 @@ static void apply_csum16(int id) (packets[id].len - csum->to), IPPROTO_TCP); break; + case CSUM_ICMP6: + sum = p6_csum((void *) packets[id].payload + csum->from, + packets[id].payload + csum->to, + (packets[id].len - csum->to), + IPPROTO_ICMPV6); + break; default: bug(); break; diff --git a/trafgen_conf.h b/trafgen_conf.h index fcbbb17..8a6e4d6 100644 --- a/trafgen_conf.h +++ b/trafgen_conf.h @@ -19,6 +19,7 @@ enum csum { CSUM_TCP, CSUM_UDP6, CSUM_TCP6, + CSUM_ICMP6, }; struct counter { diff --git a/trafgen_lexer.l b/trafgen_lexer.l index da072e1..a6d12c1 100644 --- a/trafgen_lexer.l +++ b/trafgen_lexer.l @@ -143,6 +143,7 @@ ip6_addr ({v680}|{v67}|{v66}|{v65}|{v64}|{v63}|{v62}|{v61}|{v60}) "csumtcp" { return K_CSUMTCP; } "csumudp6" { return K_CSUMUDP6; } "csumtcp6" { return K_CSUMTCP6; } +"csumicmp6" { return K_CSUMICMP6; } "drnd" { return K_DRND; } "dinc" { return K_DINC; } "ddec" { return K_DDEC; } diff --git a/trafgen_parser.y b/trafgen_parser.y index 40aa230..7fffdd9 100644 --- a/trafgen_parser.y +++ b/trafgen_parser.y @@ -276,6 +276,7 @@ static inline bool is_dynamic_csum(enum csum which) case CSUM_TCP: case CSUM_UDP6: case CSUM_TCP6: + case CSUM_ICMP6: return true; default: return false; @@ -515,7 +516,7 @@ static void proto_pop_sub_hdr(void) } %token K_COMMENT K_FILL K_RND K_SEQINC K_SEQDEC K_DRND K_DINC K_DDEC K_WHITE -%token K_CPU K_CSUMIP K_CSUMUDP K_CSUMTCP K_CSUMUDP6 K_CSUMTCP6 K_CONST8 K_CONST16 K_CONST32 K_CONST64 +%token K_CPU K_CSUMIP K_CSUMUDP K_CSUMTCP K_CSUMUDP6 K_CSUMTCP6 K_CSUMICMP6 K_CONST8 K_CONST16 K_CONST32 K_CONST64 %token K_DADDR K_SADDR K_ETYPE K_TYPE %token K_TIME K_PRIO @@ -721,6 +722,8 @@ csum { set_csum16($3, $5, CSUM_TCP6); } | K_CSUMUDP6 '(' number delimiter number ')' { set_csum16($3, $5, CSUM_UDP6); } + | K_CSUMICMP6 '(' number delimiter number ')' + { set_csum16($3, $5, CSUM_ICMP6); } ; seqinc -- cgit v1.2.3-54-g00ecf