MCPcopy Create free account
hub / github.com/F-Stack/f-stack / fill_iface

Function fill_iface

tools/ipfw/ipfw2.c:3424–3455  ·  view source on GitHub ↗

* 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. */

Source from the content-addressed store, hash-verified

3422 * patterns which match interfaces.
3423 */
3424static void
3425fill_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
3457static void
3458get_mac_addr_mask(const char *p, uint8_t *addr, uint8_t *mask)

Callers 1

compile_ruleFunction · 0.85

Calls 8

strcmpFunction · 0.85
strncmpFunction · 0.85
strchrFunction · 0.85
pack_tableFunction · 0.85
isdigitFunction · 0.85
strpbrkFunction · 0.85
inet_atonFunction · 0.85
strlcpyFunction · 0.50

Tested by

no test coverage detected