feat: prepare packet version/type argument handling

This commit is contained in:
Glenn Y. Rolland 2009-09-07 21:47:11 +02:00
parent 248f9e83d1
commit 7e60ac8b61

View file

@ -21,12 +21,13 @@ struct igmp_extra {
{ 2, "query", 0x11, 1, "224.0.0.1", 0 },
{ 2, "report", 0x16, 1, "224.0.0.2", 1 },
{ 2, "leave", 0x17, 1, "224.0.0.2", 0 },
/* Note: end of list (please keep) */
{ 0, 0, 0, 0 },
};
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)
@ -45,7 +46,7 @@ int main(int argc, char **argv)
printf("IGMP packet generator\n\n");
printf("Parsing command line...\n");
while((c = getopt(argc, argv, "i:")) != EOF)
while((c = getopt(argc, argv, "i:t:")) != EOF)
{
switch (c)
{
@ -53,7 +54,10 @@ int main(int argc, char **argv)
printf(" Net interface = [%s]\n", optarg);
device = optarg;
break;
case 't':
/* Packet version/type argument handling */
printf(" Packet version/type = [%s]\n", optarg);
break;
default:
usage(argv[0]);
exit(1);
@ -67,13 +71,11 @@ int main(int argc, char **argv)
printf("done\n");
/*
* Memory initialization
*/
/* Memory initialization */
printf("Initializing libnet context...");
netcontext = libnet_init(LIBNET_RAW4, device, neterr);
if (!netcontext){
fprintf(stderr,neterr);
fprintf(stderr, neterr);
exit(1);
}
libnet_clear_packet(netcontext);
@ -85,6 +87,7 @@ int main(int argc, char **argv)
printf("done\n");
/* Clean up and exit */
libnet_destroy(netcontext);
return 0;
}