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

Function parse_sp4_tokens

dpdk/examples/ipsec-secgw/sp4.c:134–430  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

132
133
134void
135parse_sp4_tokens(char **tokens, uint32_t n_tokens,
136 struct parse_status *status)
137{
138 struct acl4_rules *rule_ipv4 = NULL;
139
140 uint32_t *ri = NULL; /* rule index */
141 uint32_t ti = 0; /* token index */
142 uint32_t tv;
143
144 uint32_t esp_p = 0;
145 uint32_t protect_p = 0;
146 uint32_t bypass_p = 0;
147 uint32_t discard_p = 0;
148 uint32_t pri_p = 0;
149 uint32_t src_p = 0;
150 uint32_t dst_p = 0;
151 uint32_t proto_p = 0;
152 uint32_t sport_p = 0;
153 uint32_t dport_p = 0;
154
155 if (strcmp(tokens[1], "in") == 0) {
156 ri = &nb_acl4_rules_in;
157
158 if (extend_sp_arr(&acl4_rules_in, nb_acl4_rules_in,
159 &sp_in_sz) < 0)
160 return;
161
162 rule_ipv4 = &acl4_rules_in[*ri];
163
164 } else if (strcmp(tokens[1], "out") == 0) {
165 ri = &nb_acl4_rules_out;
166
167 if (extend_sp_arr(&acl4_rules_out, nb_acl4_rules_out,
168 &sp_out_sz) < 0)
169 return;
170
171 rule_ipv4 = &acl4_rules_out[*ri];
172 } else {
173 APP_CHECK(0, status, "unrecognized input \"%s\", expect"
174 " \"in\" or \"out\"\n", tokens[ti]);
175 return;
176 }
177
178 rule_ipv4->data.category_mask = 1;
179
180 for (ti = 2; ti < n_tokens; ti++) {
181 if (strcmp(tokens[ti], "esp") == 0) {
182 /* currently do nothing */
183 APP_CHECK_PRESENCE(esp_p, tokens[ti], status);
184 if (status->status < 0)
185 return;
186 esp_p = 1;
187 continue;
188 }
189
190 if (strcmp(tokens[ti], "protect") == 0) {
191 APP_CHECK_PRESENCE(protect_p, tokens[ti], status);

Callers 1

Calls 4

strcmpFunction · 0.85
extend_sp_arrFunction · 0.70
parse_ipv4_addrFunction · 0.70
parse_rangeFunction · 0.70

Tested by

no test coverage detected