doc: some improvements in astraceroute manpage
[netsniff-ng.git] / src / gremlin.c
blobc09b09a352596229c613d3e405f678e4e34bdaab
1 /*
2 * netsniff-ng - the packet sniffing beast
3 * By Daniel Borkmann <daniel@netsniff-ng.org>
4 * Copyright 2012 Daniel Borkmann <dborkma@tik.ee.ethz.ch>,
5 * Swiss federal institute of technology (ETH Zurich)
6 * Subject to the GPL, version 2.
7 */
9 #include <stdio.h>
10 #include <stdlib.h>
11 #include <getopt.h>
12 #include <ctype.h>
14 #include "xmalloc.h"
15 #include "die.h"
17 static const char *short_options = "vhm:b:";
19 static struct option long_options[] = {
20 {"mgmt", required_argument, 0, 'm'},
21 {"batch", required_argument, 0, 'b'},
22 {"version", no_argument, 0, 'v'},
23 {"help", no_argument, 0, 'h'},
24 {0, 0, 0, 0}
27 static void help(void)
29 printf("\ngremlin %s, a threaded packet beast with Cisco-cli\n",
30 VERSION_STRING);
31 printf("http://www.netsniff-ng.org\n\n");
32 printf("Usage: gremlin [options]\n");
33 printf("Options:\n");
34 printf(" -m|--mgmt <dev> Bound management netdev\n");
35 printf(" -b|--batch <file> Batch file to process\n");
36 printf(" -v|--version Print version\n");
37 printf(" -h|--help Print this help\n");
38 printf("\n");
39 printf("Examples:\n");
40 printf(" gremlin --mgmt eth5\n");
41 printf(" gremlin --batch cli-test.batch\n");
42 printf("\n");
43 printf("Note:\n");
44 printf(" gremlin uses parts of Herbert Haas' legendary Mausezahn\n");
45 printf(" traffic generator. Its backend was replaced for reasons of\n");
46 printf(" better performance and its functionality was extended.\n");
47 printf("\n");
48 printf("Please report bugs to <bugs@netsniff-ng.org>\n");
49 printf("Copyright (C) 2011-2012 Daniel Borkmann <dborkma@tik.ee.ethz.ch>,\n");
50 printf("Swiss federal institute of technology (ETH Zurich)\n");
51 printf("License: GNU GPL version 2\n");
52 printf("This is free software: you are free to change and redistribute it.\n");
53 printf("There is NO WARRANTY, to the extent permitted by law.\n\n");
54 die();
57 static void version(void)
59 printf("\ngremlin %s, a threaded packet beast with Cisco-cli\n",
60 VERSION_STRING);
61 printf("http://www.netsniff-ng.org\n\n");
62 printf("Please report bugs to <bugs@netsniff-ng.org>\n");
63 printf("Copyright (C) 2011-2012 Daniel Borkmann <dborkma@tik.ee.ethz.ch>,\n");
64 printf("Swiss federal institute of technology (ETH Zurich)\n");
65 printf("License: GNU GPL version 2\n");
66 printf("This is free software: you are free to change and redistribute it.\n");
67 printf("There is NO WARRANTY, to the extent permitted by law.\n\n");
68 die();
71 int main(int argc, char **argv)
73 int ret, c, opt_index;
74 char *file = NULL;
75 char *netdev = NULL;
77 if (argc == 1)
78 help();
80 while (argc > 2 && (c = getopt_long(argc, argv, short_options,
81 long_options, &opt_index)) != EOF) {
82 switch (c) {
83 case 'h':
84 help();
85 break;
86 case 'v':
87 version();
88 break;
89 case 'b':
90 file = xstrdup(optarg);
91 break;
92 case 'm':
93 netdev = xstrdup(optarg);
94 break;
95 case '?':
96 switch (optopt) {
97 case 'b':
98 case 'm':
99 panic("Option -%c requires an argument!\n",
100 optopt);
101 default:
102 if (isprint(optopt))
103 whine("Unknown option character "
104 "`0x%X\'!\n", optopt);
105 die();
107 default:
108 break;
112 if (!file && !netdev)
113 help();
115 /* XXX do stuff */
117 free(file);
118 free(netdev);
120 return ret;