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

Function parse_match

dpdk/examples/ip_pipeline/cli.c:2604–2986  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2602} __rte_packed;
2603
2604static uint32_t
2605parse_match(char **tokens,
2606 uint32_t n_tokens,
2607 char *out,
2608 size_t out_size,
2609 struct table_rule_match *m)
2610{
2611 memset(m, 0, sizeof(*m));
2612
2613 if (n_tokens < 2)
2614 return 0;
2615
2616 if (strcmp(tokens[0], "match") != 0) {
2617 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "match");
2618 return 0;
2619 }
2620
2621 if (strcmp(tokens[1], "acl") == 0) {
2622 if (n_tokens < 14) {
2623 snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
2624 return 0;
2625 }
2626
2627 m->match_type = TABLE_ACL;
2628
2629 if (strcmp(tokens[2], "priority") != 0) {
2630 snprintf(out, out_size, MSG_ARG_NOT_FOUND, "priority");
2631 return 0;
2632 }
2633
2634 if (parser_read_uint32(&m->match.acl.priority,
2635 tokens[3]) != 0) {
2636 snprintf(out, out_size, MSG_ARG_INVALID, "priority");
2637 return 0;
2638 }
2639
2640 if (strcmp(tokens[4], "ipv4") == 0) {
2641 struct in_addr saddr, daddr;
2642
2643 m->match.acl.ip_version = 1;
2644
2645 if (parse_ipv4_addr(tokens[5], &saddr) != 0) {
2646 snprintf(out, out_size, MSG_ARG_INVALID, "sa");
2647 return 0;
2648 }
2649 m->match.acl.ipv4.sa = rte_be_to_cpu_32(saddr.s_addr);
2650
2651 if (parse_ipv4_addr(tokens[7], &daddr) != 0) {
2652 snprintf(out, out_size, MSG_ARG_INVALID, "da");
2653 return 0;
2654 }
2655 m->match.acl.ipv4.da = rte_be_to_cpu_32(daddr.s_addr);
2656 } else if (strcmp(tokens[4], "ipv6") == 0) {
2657 struct in6_addr saddr, daddr;
2658
2659 m->match.acl.ip_version = 0;
2660
2661 if (parse_ipv6_addr(tokens[5], &saddr) != 0) {

Calls 10

memsetFunction · 0.85
strcmpFunction · 0.85
snprintfFunction · 0.85
parser_read_uint32Function · 0.70
parse_ipv4_addrFunction · 0.70
parse_ipv6_addrFunction · 0.70
parser_read_uint16Function · 0.70
parser_read_uint8Function · 0.70
parse_hex_stringFunction · 0.70
memcpyFunction · 0.50

Tested by

no test coverage detected