| 899 | "pipeline <pipeline_name> table <table_name> add <file_name>\n"; |
| 900 | |
| 901 | static void |
| 902 | cmd_pipeline_table_add(char **tokens, |
| 903 | uint32_t n_tokens, |
| 904 | char *out, |
| 905 | size_t out_size, |
| 906 | void *obj __rte_unused) |
| 907 | { |
| 908 | struct rte_swx_ctl_pipeline *ctl; |
| 909 | char *pipeline_name, *table_name, *file_name; |
| 910 | FILE *file = NULL; |
| 911 | uint32_t file_line_number = 0; |
| 912 | int status; |
| 913 | |
| 914 | if (n_tokens != 6) { |
| 915 | snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]); |
| 916 | return; |
| 917 | } |
| 918 | |
| 919 | pipeline_name = tokens[1]; |
| 920 | ctl = rte_swx_ctl_pipeline_find(pipeline_name); |
| 921 | if (!ctl) { |
| 922 | snprintf(out, out_size, MSG_ARG_INVALID, "pipeline_name"); |
| 923 | return; |
| 924 | } |
| 925 | |
| 926 | table_name = tokens[3]; |
| 927 | |
| 928 | file_name = tokens[5]; |
| 929 | file = fopen(file_name, "r"); |
| 930 | if (!file) { |
| 931 | snprintf(out, out_size, "Cannot open file %s.\n", file_name); |
| 932 | return; |
| 933 | } |
| 934 | |
| 935 | status = pipeline_table_entries_add(ctl, |
| 936 | table_name, |
| 937 | file, |
| 938 | &file_line_number); |
| 939 | if (status) |
| 940 | snprintf(out, out_size, "Invalid entry in file %s at line %u\n", |
| 941 | file_name, |
| 942 | file_line_number); |
| 943 | |
| 944 | fclose(file); |
| 945 | } |
| 946 | |
| 947 | static int |
| 948 | pipeline_table_entries_delete(struct rte_swx_ctl_pipeline *p, |
no test coverage detected