* fill the interface structure. We do not check the name as we can * create interfaces dynamically, so checking them at insert time * makes relatively little sense. * Interface names containing '*', '?', or '[' are assumed to be shell * patterns which match interfaces. */
| 3422 | * patterns which match interfaces. |
| 3423 | */ |
| 3424 | static void |
| 3425 | fill_iface(ipfw_insn_if *cmd, char *arg, int cblen, struct tidx *tstate) |
| 3426 | { |
| 3427 | char *p; |
| 3428 | uint16_t uidx; |
| 3429 | |
| 3430 | cmd->name[0] = '\0'; |
| 3431 | cmd->o.len |= F_INSN_SIZE(ipfw_insn_if); |
| 3432 | |
| 3433 | CHECK_CMDLEN; |
| 3434 | |
| 3435 | /* Parse the interface or address */ |
| 3436 | if (strcmp(arg, "any") == 0) |
| 3437 | cmd->o.len = 0; /* effectively ignore this command */ |
| 3438 | else if (strncmp(arg, "table(", 6) == 0) { |
| 3439 | if ((p = strchr(arg + 6, ')')) == NULL) |
| 3440 | errx(EX_DATAERR, "forgotten parenthesis: '%s'", arg); |
| 3441 | *p = '\0'; |
| 3442 | p = strchr(arg + 6, ','); |
| 3443 | if (p) |
| 3444 | *p++ = '\0'; |
| 3445 | if ((uidx = pack_table(tstate, arg + 6)) == 0) |
| 3446 | errx(EX_DATAERR, "Invalid table name: %s", arg + 6); |
| 3447 | |
| 3448 | cmd->name[0] = '\1'; /* Special value indicating table */ |
| 3449 | cmd->p.kidx = uidx; |
| 3450 | } else if (!isdigit(*arg)) { |
| 3451 | strlcpy(cmd->name, arg, sizeof(cmd->name)); |
| 3452 | cmd->p.glob = strpbrk(arg, "*?[") != NULL ? 1 : 0; |
| 3453 | } else if (!inet_aton(arg, &cmd->p.ip)) |
| 3454 | errx(EX_DATAERR, "bad ip address ``%s''", arg); |
| 3455 | } |
| 3456 | |
| 3457 | static void |
| 3458 | get_mac_addr_mask(const char *p, uint8_t *addr, uint8_t *mask) |
no test coverage detected