| 1443 | "pipeline <pipeline_name> selector <selector_name> group member add <file_name>"; |
| 1444 | |
| 1445 | static void |
| 1446 | cmd_pipeline_selector_group_member_add(char **tokens, |
| 1447 | uint32_t n_tokens, |
| 1448 | char *out, |
| 1449 | size_t out_size, |
| 1450 | void *obj __rte_unused) |
| 1451 | { |
| 1452 | struct rte_swx_ctl_pipeline *ctl; |
| 1453 | char *pipeline_name, *selector_name, *file_name; |
| 1454 | FILE *file = NULL; |
| 1455 | uint32_t file_line_number = 0; |
| 1456 | int status; |
| 1457 | |
| 1458 | if (n_tokens != 8) { |
| 1459 | snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]); |
| 1460 | return; |
| 1461 | } |
| 1462 | |
| 1463 | pipeline_name = tokens[1]; |
| 1464 | ctl = rte_swx_ctl_pipeline_find(pipeline_name); |
| 1465 | if (!ctl) { |
| 1466 | snprintf(out, out_size, MSG_ARG_INVALID, "pipeline_name"); |
| 1467 | return; |
| 1468 | } |
| 1469 | |
| 1470 | if (strcmp(tokens[2], "selector") != 0) { |
| 1471 | snprintf(out, out_size, MSG_ARG_NOT_FOUND, "selector"); |
| 1472 | return; |
| 1473 | } |
| 1474 | |
| 1475 | selector_name = tokens[3]; |
| 1476 | |
| 1477 | if (strcmp(tokens[4], "group") || |
| 1478 | strcmp(tokens[5], "member") || |
| 1479 | strcmp(tokens[6], "add")) { |
| 1480 | snprintf(out, out_size, MSG_ARG_NOT_FOUND, "group member add"); |
| 1481 | return; |
| 1482 | } |
| 1483 | |
| 1484 | file_name = tokens[7]; |
| 1485 | file = fopen(file_name, "r"); |
| 1486 | if (!file) { |
| 1487 | snprintf(out, out_size, "Cannot open file %s.\n", file_name); |
| 1488 | return; |
| 1489 | } |
| 1490 | |
| 1491 | status = pipeline_selector_group_members_add(ctl, |
| 1492 | selector_name, |
| 1493 | file, |
| 1494 | &file_line_number); |
| 1495 | if (status) |
| 1496 | snprintf(out, out_size, "Invalid entry in file %s at line %u\n", |
| 1497 | file_name, |
| 1498 | file_line_number); |
| 1499 | |
| 1500 | fclose(file); |
| 1501 | } |
| 1502 |
no test coverage detected