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

Function parse_table_action_nat

dpdk/examples/ip_pipeline/cli.c:3585–3625  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3583}
3584
3585static uint32_t
3586parse_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
3627static uint32_t
3628parse_table_action_ttl(char **tokens,

Callers 1

parse_table_actionFunction · 0.85

Calls 5

strcmpFunction · 0.85
parse_ipv4_addrFunction · 0.70
parser_read_uint16Function · 0.70
parse_ipv6_addrFunction · 0.70
memcpyFunction · 0.50

Tested by

no test coverage detected