feat: prepare packet version/type argument handling
This commit is contained in:
parent
248f9e83d1
commit
7e60ac8b61
1 changed files with 11 additions and 8 deletions
|
@ -21,12 +21,13 @@ struct igmp_extra {
|
||||||
{ 2, "query", 0x11, 1, "224.0.0.1", 0 },
|
{ 2, "query", 0x11, 1, "224.0.0.1", 0 },
|
||||||
{ 2, "report", 0x16, 1, "224.0.0.2", 1 },
|
{ 2, "report", 0x16, 1, "224.0.0.2", 1 },
|
||||||
{ 2, "leave", 0x17, 1, "224.0.0.2", 0 },
|
{ 2, "leave", 0x17, 1, "224.0.0.2", 0 },
|
||||||
|
/* Note: end of list (please keep) */
|
||||||
{ 0, 0, 0, 0 },
|
{ 0, 0, 0, 0 },
|
||||||
};
|
};
|
||||||
|
|
||||||
void usage(char *name)
|
void usage(char *name)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "usage: %s -i ethdevice\n", name);
|
fprintf(stderr, "usage: %s -i ethdevice -t packet.version\n", name);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
|
@ -45,7 +46,7 @@ int main(int argc, char **argv)
|
||||||
printf("IGMP packet generator\n\n");
|
printf("IGMP packet generator\n\n");
|
||||||
|
|
||||||
printf("Parsing command line...\n");
|
printf("Parsing command line...\n");
|
||||||
while((c = getopt(argc, argv, "i:")) != EOF)
|
while((c = getopt(argc, argv, "i:t:")) != EOF)
|
||||||
{
|
{
|
||||||
switch (c)
|
switch (c)
|
||||||
{
|
{
|
||||||
|
@ -53,7 +54,10 @@ int main(int argc, char **argv)
|
||||||
printf(" Net interface = [%s]\n", optarg);
|
printf(" Net interface = [%s]\n", optarg);
|
||||||
device = optarg;
|
device = optarg;
|
||||||
break;
|
break;
|
||||||
|
case 't':
|
||||||
|
/* Packet version/type argument handling */
|
||||||
|
printf(" Packet version/type = [%s]\n", optarg);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
usage(argv[0]);
|
usage(argv[0]);
|
||||||
exit(1);
|
exit(1);
|
||||||
|
@ -67,13 +71,11 @@ int main(int argc, char **argv)
|
||||||
|
|
||||||
printf("done\n");
|
printf("done\n");
|
||||||
|
|
||||||
/*
|
/* Memory initialization */
|
||||||
* Memory initialization
|
|
||||||
*/
|
|
||||||
printf("Initializing libnet context...");
|
printf("Initializing libnet context...");
|
||||||
netcontext = libnet_init(LIBNET_RAW4, device, neterr);
|
netcontext = libnet_init(LIBNET_RAW4, device, neterr);
|
||||||
if (!netcontext){
|
if (!netcontext){
|
||||||
fprintf(stderr,neterr);
|
fprintf(stderr, neterr);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
libnet_clear_packet(netcontext);
|
libnet_clear_packet(netcontext);
|
||||||
|
@ -85,6 +87,7 @@ int main(int argc, char **argv)
|
||||||
|
|
||||||
printf("done\n");
|
printf("done\n");
|
||||||
|
|
||||||
|
/* Clean up and exit */
|
||||||
|
libnet_destroy(netcontext);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue