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

Function parse_table_action_encap

dpdk/examples/ip_pipeline/cli.c:3231–3583  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3229}
3230
3231static uint32_t
3232parse_table_action_encap(char **tokens,
3233 uint32_t n_tokens,
3234 struct table_rule_action *a)
3235{
3236 if ((n_tokens == 0) || strcmp(tokens[0], "encap"))
3237 return 0;
3238
3239 tokens++;
3240 n_tokens--;
3241
3242 /* ether */
3243 if (n_tokens && (strcmp(tokens[0], "ether") == 0)) {
3244 if ((n_tokens < 3) ||
3245 parse_mac_addr(tokens[1], &a->encap.ether.ether.da) ||
3246 parse_mac_addr(tokens[2], &a->encap.ether.ether.sa))
3247 return 0;
3248
3249 a->encap.type = RTE_TABLE_ACTION_ENCAP_ETHER;
3250 a->action_mask |= 1 << RTE_TABLE_ACTION_ENCAP;
3251 return 1 + 3;
3252 }
3253
3254 /* vlan */
3255 if (n_tokens && (strcmp(tokens[0], "vlan") == 0)) {
3256 uint32_t pcp, dei, vid;
3257
3258 if ((n_tokens < 6) ||
3259 parse_mac_addr(tokens[1], &a->encap.vlan.ether.da) ||
3260 parse_mac_addr(tokens[2], &a->encap.vlan.ether.sa) ||
3261 parser_read_uint32(&pcp, tokens[3]) ||
3262 (pcp > 0x7) ||
3263 parser_read_uint32(&dei, tokens[4]) ||
3264 (dei > 0x1) ||
3265 parser_read_uint32(&vid, tokens[5]) ||
3266 (vid > 0xFFF))
3267 return 0;
3268
3269 a->encap.vlan.vlan.pcp = pcp & 0x7;
3270 a->encap.vlan.vlan.dei = dei & 0x1;
3271 a->encap.vlan.vlan.vid = vid & 0xFFF;
3272 a->encap.type = RTE_TABLE_ACTION_ENCAP_VLAN;
3273 a->action_mask |= 1 << RTE_TABLE_ACTION_ENCAP;
3274 return 1 + 6;
3275 }
3276
3277 /* qinq */
3278 if (n_tokens && (strcmp(tokens[0], "qinq") == 0)) {
3279 uint32_t svlan_pcp, svlan_dei, svlan_vid;
3280 uint32_t cvlan_pcp, cvlan_dei, cvlan_vid;
3281
3282 if ((n_tokens < 9) ||
3283 parse_mac_addr(tokens[1], &a->encap.qinq.ether.da) ||
3284 parse_mac_addr(tokens[2], &a->encap.qinq.ether.sa) ||
3285 parser_read_uint32(&svlan_pcp, tokens[3]) ||
3286 (svlan_pcp > 0x7) ||
3287 parser_read_uint32(&svlan_dei, tokens[4]) ||
3288 (svlan_dei > 0x1) ||

Callers 1

parse_table_actionFunction · 0.85

Calls 8

strcmpFunction · 0.85
parse_mac_addrFunction · 0.70
parser_read_uint32Function · 0.70
parser_read_uint16Function · 0.70
parse_ipv4_addrFunction · 0.70
parser_read_uint8Function · 0.70
parse_ipv6_addrFunction · 0.70
memcpyFunction · 0.50

Tested by

no test coverage detected