| 1237 | } |
| 1238 | |
| 1239 | static int |
| 1240 | nat_apply(void *data, |
| 1241 | struct rte_table_action_nat_params *p, |
| 1242 | struct rte_table_action_common_config *cfg) |
| 1243 | { |
| 1244 | int status; |
| 1245 | |
| 1246 | /* Check input arguments */ |
| 1247 | status = nat_apply_check(p, cfg); |
| 1248 | if (status) |
| 1249 | return status; |
| 1250 | |
| 1251 | /* Apply */ |
| 1252 | if (p->ip_version) { |
| 1253 | struct nat_ipv4_data *d = data; |
| 1254 | |
| 1255 | d->addr = rte_htonl(p->addr.ipv4); |
| 1256 | d->port = rte_htons(p->port); |
| 1257 | } else { |
| 1258 | struct nat_ipv6_data *d = data; |
| 1259 | |
| 1260 | memcpy(d->addr, p->addr.ipv6, sizeof(d->addr)); |
| 1261 | d->port = rte_htons(p->port); |
| 1262 | } |
| 1263 | |
| 1264 | return 0; |
| 1265 | } |
| 1266 | |
| 1267 | static __rte_always_inline uint16_t |
| 1268 | nat_ipv4_checksum_update(uint16_t cksum0, |
no test coverage detected