| 1095 | "pipeline <pipeline_name> table <table_name> default <file_name>\n"; |
| 1096 | |
| 1097 | static void |
| 1098 | cmd_pipeline_table_default(char **tokens, |
| 1099 | uint32_t n_tokens, |
| 1100 | char *out, |
| 1101 | size_t out_size, |
| 1102 | void *obj __rte_unused) |
| 1103 | { |
| 1104 | struct rte_swx_ctl_pipeline *ctl; |
| 1105 | char *pipeline_name, *table_name, *file_name; |
| 1106 | FILE *file = NULL; |
| 1107 | uint32_t file_line_number = 0; |
| 1108 | int status; |
| 1109 | |
| 1110 | if (n_tokens != 6) { |
| 1111 | snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]); |
| 1112 | return; |
| 1113 | } |
| 1114 | |
| 1115 | pipeline_name = tokens[1]; |
| 1116 | ctl = rte_swx_ctl_pipeline_find(pipeline_name); |
| 1117 | if (!ctl) { |
| 1118 | snprintf(out, out_size, MSG_ARG_INVALID, "pipeline_name"); |
| 1119 | return; |
| 1120 | } |
| 1121 | |
| 1122 | table_name = tokens[3]; |
| 1123 | |
| 1124 | file_name = tokens[5]; |
| 1125 | file = fopen(file_name, "r"); |
| 1126 | if (!file) { |
| 1127 | snprintf(out, out_size, "Cannot open file %s.\n", file_name); |
| 1128 | return; |
| 1129 | } |
| 1130 | |
| 1131 | status = pipeline_table_default_entry_add(ctl, |
| 1132 | table_name, |
| 1133 | file, |
| 1134 | &file_line_number); |
| 1135 | if (status) |
| 1136 | snprintf(out, out_size, "Invalid entry in file %s at line %u\n", |
| 1137 | file_name, |
| 1138 | file_line_number); |
| 1139 | |
| 1140 | fclose(file); |
| 1141 | } |
| 1142 | |
| 1143 | static const char cmd_pipeline_table_show_help[] = |
| 1144 | "pipeline <pipeline_name> table <table_name> show [filename]\n"; |
no test coverage detected