fix: improve display

This commit is contained in:
Glenn Y. Rolland 2023-12-24 20:27:59 +01:00
parent 4542e6b11e
commit 25fd800a9e

View file

@ -30,18 +30,7 @@ struct igmp_extra {
{ 0, 0, 0, 0 },
};
void usage(char *name)
{
struct igmp_extra *pkt_ptr;
fprintf(stderr, "usage: %s -i ethdevice -g group -t version.packettype [-s ip:port] [-d ip:port]\n", name);
pkt_ptr = g_igmp_pkts;
fprintf(stderr,"\nAvailable packet types:\n");
while(pkt_ptr->igmp_version || pkt_ptr->igmp_tag){
fprintf(stderr," - %d.%s\n", pkt_ptr->igmp_version, pkt_ptr->igmp_tag);
pkt_ptr++;
}
}
void usage(char *);
int main(int argc, char **argv)
{
@ -80,7 +69,7 @@ int main(int argc, char **argv)
printf("IGMP packet generator\n\n");
printf("Parsing command line...\n");
/* Parsing command line */
while((c = getopt(argc, argv, "i:t:g:d:s:")) != EOF)
{
switch (c)
@ -365,4 +354,25 @@ int main(int argc, char **argv)
return (c == -1 ? EXIT_FAILURE : EXIT_SUCCESS);
}
void usage(char *name)
{
struct igmp_extra *pkt_ptr;
fprintf(stderr, "Usage: %s [options]\n", name);
fprintf(stderr, "\nOptions:\n");
fprintf(stderr, " -i <interface> Specify the network interface (e.g., eth0)\n");
fprintf(stderr, " -t <type> Specify the IGMP packet type and version (e.g., 1.query)\n");
fprintf(stderr, " -g <group> Specify the IGMP group (e.g., 224.0.0.1)\n");
fprintf(stderr, " -s <source> Specify the source IP and port (e.g., 192.168.1.1:1234)\n");
fprintf(stderr, " -d <destination> Specify the destination IP and port (e.g., 224.0.0.2:5678)\n");
fprintf(stderr, " -n <number> Specify delay between packets in seconds (optional)\n");
fprintf(stderr, "\nAvailable IGMP packet types:\n");
pkt_ptr = g_igmp_pkts;
while(pkt_ptr->igmp_version || pkt_ptr->igmp_tag){
fprintf(stderr," - %d.%s\n", pkt_ptr->igmp_version, pkt_ptr->igmp_tag);
pkt_ptr++;
}
}
// vim: ts=4 sts=4 sw=4 et