| 2602 | } __rte_packed; |
| 2603 | |
| 2604 | static uint32_t |
| 2605 | parse_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) { |
no test coverage detected