* This one handles all table-related commands * ipfw table NAME create ... * ipfw table NAME modify ... * ipfw table {NAME | all} destroy * ipfw table NAME swap NAME * ipfw table NAME lock * ipfw table NAME unlock * ipfw table NAME add addr[/masklen] [value] * ipfw table NAME add [addr[/masklen] value] [addr[/masklen] value] .. * ipfw table NAME delete addr[/masklen] [addr[/mask
| 157 | * ipfw table {NAME | all} detail |
| 158 | */ |
| 159 | void |
| 160 | ipfw_table_handler(int ac, char *av[]) |
| 161 | { |
| 162 | int do_add, is_all; |
| 163 | int atomic, error, tcmd; |
| 164 | ipfw_xtable_info i; |
| 165 | ipfw_obj_header oh; |
| 166 | char *tablename; |
| 167 | uint8_t set; |
| 168 | void *arg; |
| 169 | |
| 170 | memset(&oh, 0, sizeof(oh)); |
| 171 | is_all = 0; |
| 172 | if (g_co.use_set != 0) |
| 173 | set = g_co.use_set - 1; |
| 174 | else |
| 175 | set = 0; |
| 176 | |
| 177 | ac--; av++; |
| 178 | NEED1("table needs name"); |
| 179 | tablename = *av; |
| 180 | |
| 181 | if (table_check_name(tablename) == 0) { |
| 182 | table_fill_ntlv(&oh.ntlv, *av, set, 1); |
| 183 | oh.idx = 1; |
| 184 | } else { |
| 185 | if (strcmp(tablename, "all") == 0) |
| 186 | is_all = 1; |
| 187 | else |
| 188 | errx(EX_USAGE, "table name %s is invalid", tablename); |
| 189 | } |
| 190 | ac--; av++; |
| 191 | NEED1("table needs command"); |
| 192 | |
| 193 | tcmd = get_token(tablecmds, *av, "table command"); |
| 194 | /* Check if atomic operation was requested */ |
| 195 | atomic = 0; |
| 196 | if (tcmd == TOK_ATOMIC) { |
| 197 | ac--; av++; |
| 198 | NEED1("atomic needs command"); |
| 199 | tcmd = get_token(tablecmds, *av, "table command"); |
| 200 | switch (tcmd) { |
| 201 | case TOK_ADD: |
| 202 | break; |
| 203 | default: |
| 204 | errx(EX_USAGE, "atomic is not compatible with %s", *av); |
| 205 | } |
| 206 | atomic = 1; |
| 207 | } |
| 208 | |
| 209 | switch (tcmd) { |
| 210 | case TOK_LIST: |
| 211 | case TOK_INFO: |
| 212 | case TOK_DETAIL: |
| 213 | case TOK_FLUSH: |
| 214 | case TOK_DESTROY: |
| 215 | break; |
| 216 | default: |
no test coverage detected