| 478 | |
| 479 | #ifdef FF_IPFW |
| 480 | static int |
| 481 | ipfw_pr_cfg_handler(struct ff_port_cfg *cur_port_cfg, struct ff_vlan_cfg *cur_vlan_cfg) |
| 482 | { |
| 483 | //vip cfg |
| 484 | int ret, nb_vip, i; |
| 485 | char *vip_addr_array[VIP_MAX_NUM], *vip_addr_mask_array[2], *vip_addr_str; |
| 486 | struct ff_ipfw_pr_cfg *vipfw_pr_cfg_p; |
| 487 | |
| 488 | if (cur_port_cfg) { |
| 489 | vip_addr_str = cur_port_cfg->pr_addr_str; |
| 490 | } else if (cur_vlan_cfg) { |
| 491 | vip_addr_str = cur_vlan_cfg->pr_addr_str; |
| 492 | } else { |
| 493 | fprintf(stdout, "ipfw_pr_cfg_handlercur_port_cfg and cur_vlan_cfg both NULL, not set vip_addr\n"); |
| 494 | return 1; |
| 495 | } |
| 496 | |
| 497 | ret = rte_strsplit(vip_addr_str, strlen(vip_addr_str), &vip_addr_array[0], VIP_MAX_NUM, ';'); |
| 498 | if (ret <= 0) { |
| 499 | fprintf(stdout, "ipfw_pr_cfg_handler nb_vip is 0, not set vip_addr or set invalid vip_addr %s\n", |
| 500 | vip_addr_str); |
| 501 | return 1; |
| 502 | } |
| 503 | |
| 504 | nb_vip = ret; |
| 505 | |
| 506 | vipfw_pr_cfg_p = (struct ff_ipfw_pr_cfg *)calloc(nb_vip, sizeof(struct ff_ipfw_pr_cfg)); |
| 507 | if (vipfw_pr_cfg_p == NULL) { |
| 508 | fprintf(stderr, "ipfw_pr_cfg_handler malloc failed\n"); |
| 509 | goto err; |
| 510 | } |
| 511 | |
| 512 | for (i = 0; i < nb_vip; i++) { |
| 513 | vip_addr_str = vip_addr_array[i]; |
| 514 | ret = rte_strsplit(vip_addr_str, strlen(vip_addr_str), &vip_addr_mask_array[0], 2, ' '); |
| 515 | if (ret != 2) { |
| 516 | fprintf(stdout, "ipfw_pr_cfg_handler addr and netmask format error %s\n", |
| 517 | vip_addr_str); |
| 518 | free(vipfw_pr_cfg_p); |
| 519 | return 1; |
| 520 | } |
| 521 | |
| 522 | vipfw_pr_cfg_p[i].addr = vip_addr_mask_array[0]; |
| 523 | vipfw_pr_cfg_p[i].netmask = vip_addr_mask_array[1]; |
| 524 | } |
| 525 | |
| 526 | if (cur_port_cfg) { |
| 527 | cur_port_cfg->nb_pr = nb_vip; |
| 528 | cur_port_cfg->pr_cfg = vipfw_pr_cfg_p; |
| 529 | } else if (cur_vlan_cfg) { |
| 530 | cur_vlan_cfg->nb_pr = nb_vip; |
| 531 | cur_vlan_cfg->pr_cfg = vipfw_pr_cfg_p; |
| 532 | } |
| 533 | |
| 534 | return 1; |
| 535 | |
| 536 | err: |
| 537 | return 0; |
no test coverage detected