| 3583 | } |
| 3584 | |
| 3585 | static uint32_t |
| 3586 | parse_table_action_nat(char **tokens, |
| 3587 | uint32_t n_tokens, |
| 3588 | struct table_rule_action *a) |
| 3589 | { |
| 3590 | if ((n_tokens < 4) || |
| 3591 | strcmp(tokens[0], "nat")) |
| 3592 | return 0; |
| 3593 | |
| 3594 | if (strcmp(tokens[1], "ipv4") == 0) { |
| 3595 | struct in_addr addr; |
| 3596 | uint16_t port; |
| 3597 | |
| 3598 | if (parse_ipv4_addr(tokens[2], &addr) || |
| 3599 | parser_read_uint16(&port, tokens[3])) |
| 3600 | return 0; |
| 3601 | |
| 3602 | a->nat.ip_version = 1; |
| 3603 | a->nat.addr.ipv4 = rte_be_to_cpu_32(addr.s_addr); |
| 3604 | a->nat.port = port; |
| 3605 | a->action_mask |= 1 << RTE_TABLE_ACTION_NAT; |
| 3606 | return 4; |
| 3607 | } |
| 3608 | |
| 3609 | if (strcmp(tokens[1], "ipv6") == 0) { |
| 3610 | struct in6_addr addr; |
| 3611 | uint16_t port; |
| 3612 | |
| 3613 | if (parse_ipv6_addr(tokens[2], &addr) || |
| 3614 | parser_read_uint16(&port, tokens[3])) |
| 3615 | return 0; |
| 3616 | |
| 3617 | a->nat.ip_version = 0; |
| 3618 | memcpy(a->nat.addr.ipv6, addr.s6_addr, 16); |
| 3619 | a->nat.port = port; |
| 3620 | a->action_mask |= 1 << RTE_TABLE_ACTION_NAT; |
| 3621 | return 4; |
| 3622 | } |
| 3623 | |
| 3624 | return 0; |
| 3625 | } |
| 3626 | |
| 3627 | static uint32_t |
| 3628 | parse_table_action_ttl(char **tokens, |
no test coverage detected