MCPcopy Create free account
hub / github.com/F-Stack/f-stack / parse_rt_tokens

Function parse_rt_tokens

dpdk/examples/ipsec-secgw/rt.c:39–122  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

37uint32_t nb_rt_ip6;
38
39void
40parse_rt_tokens(char **tokens, uint32_t n_tokens,
41 struct parse_status *status)
42{
43 uint32_t ti;
44 uint32_t *n_rts = NULL;
45 struct ip4_route *route_ipv4 = NULL;
46 struct ip6_route *route_ipv6 = NULL;
47
48 if (strcmp(tokens[0], "ipv4") == 0) {
49 n_rts = &nb_rt_ip4;
50 route_ipv4 = &rt_ip4[*n_rts];
51
52 APP_CHECK(*n_rts <= RT_IPV4_MAX_RULES - 1, status,
53 "too many rt rules, abort insertion\n");
54 if (status->status < 0)
55 return;
56
57 } else if (strcmp(tokens[0], "ipv6") == 0) {
58 n_rts = &nb_rt_ip6;
59 route_ipv6 = &rt_ip6[*n_rts];
60
61 APP_CHECK(*n_rts <= RT_IPV6_MAX_RULES - 1, status,
62 "too many rt rules, abort insertion\n");
63 if (status->status < 0)
64 return;
65 } else {
66 APP_CHECK(0, status, "unrecognized input \"%s\"",
67 tokens[0]);
68 return;
69 }
70
71 for (ti = 1; ti < n_tokens; ti++) {
72 if (strcmp(tokens[ti], "dst") == 0) {
73 INCREMENT_TOKEN_INDEX(ti, n_tokens, status);
74 if (status->status < 0)
75 return;
76
77 if (route_ipv4 != NULL) {
78 struct in_addr ip;
79 uint32_t depth = 0;
80
81 APP_CHECK(parse_ipv4_addr(tokens[ti],
82 &ip, &depth) == 0, status,
83 "unrecognized input \"%s\", "
84 "expect valid ipv4 addr",
85 tokens[ti]);
86 if (status->status < 0)
87 return;
88 route_ipv4->ip = rte_bswap32(
89 (uint32_t)ip.s_addr);
90 route_ipv4->depth = (uint8_t)depth;
91 } else {
92 struct in6_addr ip;
93 uint32_t depth;
94
95 APP_CHECK(parse_ipv6_addr(tokens[ti],
96 &ip, &depth) == 0, status,

Callers 1

Calls 4

strcmpFunction · 0.85
parse_ipv4_addrFunction · 0.70
parse_ipv6_addrFunction · 0.70
memcpyFunction · 0.50

Tested by

no test coverage detected