diff options
author | Florian Westphal <fw@strlen.de> | 2020-11-02 14:53:26 +0100 |
---|---|---|
committer | Florian Westphal <fw@strlen.de> | 2020-11-09 12:19:24 +0100 |
commit | 41158e0388ac56380fc0ee301f0d43f95ec43fab (patch) | |
tree | aa970b7dcf43bc7c1c150cc166701944602beb95 /src/parser_json.c | |
parent | 2a9aea6f2dfb6ee61528809af98860e06b38762b (diff) |
tcpopts: clean up parser -> tcpopt.c plumbing
tcpopt template mapping is asymmetric:
one mapping is to match dumped netlink exthdr expression to the original
tcp option template.
This struct is indexed by the raw, on-write kind/type number.
The other mapping maps parsed options to the tcp option template.
Remove the latter. The parser is changed to translate the textual
option name, e.g. "maxseg" to the on-wire number.
This avoids the second mapping, it will also allow to more easily
support raw option matching in a followup patch.
Signed-off-by: Florian Westphal <fw@strlen.de>
Diffstat (limited to 'src/parser_json.c')
-rw-r--r-- | src/parser_json.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/parser_json.c b/src/parser_json.c index 13623912..c68b64d9 100644 --- a/src/parser_json.c +++ b/src/parser_json.c @@ -458,9 +458,9 @@ static int json_parse_tcp_option_type(const char *name, int *val) { unsigned int i; - for (i = 0; i < array_size(tcpopthdr_protocols); i++) { - if (tcpopthdr_protocols[i] && - !strcmp(tcpopthdr_protocols[i]->name, name)) { + for (i = 0; i < array_size(tcpopt_protocols); i++) { + if (tcpopt_protocols[i] && + !strcmp(tcpopt_protocols[i]->name, name)) { if (val) *val = i; return 0; @@ -469,7 +469,7 @@ static int json_parse_tcp_option_type(const char *name, int *val) /* special case for sack0 - sack3 */ if (sscanf(name, "sack%u", &i) == 1 && i < 4) { if (val) - *val = TCPOPTHDR_SACK0 + i; + *val = TCPOPT_KIND_SACK + i; return 0; } return 1; @@ -478,7 +478,7 @@ static int json_parse_tcp_option_type(const char *name, int *val) static int json_parse_tcp_option_field(int type, const char *name, int *val) { unsigned int i; - const struct exthdr_desc *desc = tcpopthdr_protocols[type]; + const struct exthdr_desc *desc = tcpopt_protocols[type]; for (i = 0; i < array_size(desc->templates); i++) { if (desc->templates[i].token && |