static void config_parse_label(u8* val) { u8* nxt; u32 i; /* Simplified handling for [mtu] signatures. */ if (mod_type == CF_MOD_MTU) { if (!*val) FATAL("Empty MTU label in line %u.\n", line_no); sig_flavor = DFL_ck_strdup(val); return; } if (*val == 'g') generic = 1; else if (*val == 's') generic = 0; else FATAL("Malformed class entry in line %u.", line_no); if (val[1] != ':') FATAL("Malformed class entry in line %u.", line_no); val += 2; nxt = val; while (isalnum(*nxt) || *nxt == '!') nxt++; if (nxt == val || *nxt != ':') FATAL("Malformed class entry in line %u.", line_no); if (*val == '!' && val[1] == ':') { sig_class = -1; } else { *nxt = 0; for (i = 0; i < class_cnt; i++) if (!strcasecmp((char*)val, (char*)fp_os_classes[i])) break; if (i == class_cnt) FATAL("Unknown class '%s' in line %u.", val, line_no); sig_class = i; } nxt++; val = nxt; while (isalnum(*nxt) || (*nxt && strchr(NAME_CHARS, *nxt))) nxt++; if (nxt == val || *nxt != ':') FATAL("Malformed name in line %u.", line_no); sig_name = lookup_name_id(val, nxt - val); if (nxt[1]) sig_flavor = DFL_ck_strdup(nxt + 1); else sig_flavor = NULL; label_id++; }
static u8* find_interface(int num) { char pcap_err[PCAP_ERRBUF_SIZE]; pcap_if_t *dev; if (pcap_findalldevs(&dev, pcap_err) == -1) printf("\n FATAL: pcap_findalldevs: %s\n", pcap_err); do { if (!num--) { u8* ret = DFL_ck_strdup((char*)dev->name); pcap_freealldevs(dev); return ret; } } while ((dev = dev->next)); printf("\n FATAL: Interface not found (use -L to list all)."); }