* Parse ClassBench input trace (test vectors and expected results) file. * Expected format: * \ * */
| 436 | * <src_port> <space> <dst_port> <space> <proto> |
| 437 | */ |
| 438 | static int |
| 439 | parse_cb_ipv4_trace(char *str, struct ipv4_5tuple *v) |
| 440 | { |
| 441 | int i; |
| 442 | char *s, *sp, *in[CB_TRC_NUM]; |
| 443 | static const char *dlm = " \t\n"; |
| 444 | |
| 445 | s = str; |
| 446 | for (i = 0; i != RTE_DIM(in); i++) { |
| 447 | in[i] = strtok_r(s, dlm, &sp); |
| 448 | if (in[i] == NULL) |
| 449 | return -EINVAL; |
| 450 | s = NULL; |
| 451 | } |
| 452 | |
| 453 | GET_CB_FIELD(in[CB_TRC_SRC_ADDR], v->ip_src, 0, UINT32_MAX, 0); |
| 454 | GET_CB_FIELD(in[CB_TRC_DST_ADDR], v->ip_dst, 0, UINT32_MAX, 0); |
| 455 | GET_CB_FIELD(in[CB_TRC_SRC_PORT], v->port_src, 0, UINT16_MAX, 0); |
| 456 | GET_CB_FIELD(in[CB_TRC_DST_PORT], v->port_dst, 0, UINT16_MAX, 0); |
| 457 | GET_CB_FIELD(in[CB_TRC_PROTO], v->proto, 0, UINT8_MAX, 0); |
| 458 | |
| 459 | /* convert to network byte order. */ |
| 460 | v->ip_src = rte_cpu_to_be_32(v->ip_src); |
| 461 | v->ip_dst = rte_cpu_to_be_32(v->ip_dst); |
| 462 | v->port_src = rte_cpu_to_be_16(v->port_src); |
| 463 | v->port_dst = rte_cpu_to_be_16(v->port_dst); |
| 464 | |
| 465 | return 0; |
| 466 | } |
| 467 | |
| 468 | static int |
| 469 | parse_cb_ipv6_addr_trace(const char *in, uint32_t v[IPV6_ADDR_U32]) |