int main(int argc, char **argv) { char *signatures = NULL; char *timeout = NULL; char *tp = NULL; char *targets = NULL; char *gw_addr = NULL; char *loiface = NULL; char *nt_mask = NULL; int exit_code = 1; if (get_option("version", NULL, argc, argv) != NULL) { printf("pig v%s\n", PIG_VERSION); return 0; } if (argc > 1) { signatures = get_option("signatures", NULL, argc, argv); if (signatures == NULL) { printf("pig ERROR: --signatures option is missing.\n"); return 1; } gw_addr = get_option("gateway", NULL, argc, argv); if (gw_addr == NULL) { printf("pig ERROR: --gateway option is missing.\n"); return 1; } nt_mask = get_option("net-mask", NULL, argc, argv); if (nt_mask == NULL) { printf("pig ERROR: --net-mask option is missing.\n"); return 1; } loiface = get_option("lo-iface", NULL, argc, argv); if (loiface == NULL) { printf("pig ERROR: --lo-iface option is missing.\n"); return 1; } timeout = get_option("timeout", NULL, argc, argv); if (timeout != NULL) { for (tp = timeout; *tp != 0; tp++) { if (!isdigit(*tp)) { printf("pig ERROR: an invalid timeout value was supplied.\n"); return 1; } } } should_be_quiet = (get_option("no-echo", NULL, argc, argv) != NULL); targets = get_option("targets", NULL, argc, argv); signal(SIGINT, sigint_watchdog); signal(SIGTERM, sigint_watchdog); srand(time(0)); exit_code = run_pig_run(signatures, targets, timeout, get_option("single-test", NULL, argc, argv), gw_addr, nt_mask, loiface); if (!should_be_quiet && exit_code == 0) { printf("\npig INFO: exiting... please wait...\npig INFO: pig has gone.\n"); } } else { printf("usage: %s --signatures=file.0,file.1,(...),file.n --gateway=<gateway address> --net-mask=<network mask> --lo-iface=<network interface> [--timeout=<in msecs> --no-echo --targets=n.n.n.n,n.*.*.*,n.n.n.n/n]\n", argv[0]); } return exit_code; }
int main(int argc, char **argv) { int exit_code = 1; register_options(argc, argv); if (get_option("version", NULL) != NULL) { printf("pig v%s\n", PIG_VERSION); return 0; } if (argc > 1) { signal(SIGINT, pktcrafter_sigint_watchdog); signal(SIGTERM, pktcrafter_sigint_watchdog); exit_code = run_pig_run(); } else { exit_code = pktcraft_help(); } return exit_code; }