From 25fd800a9e42d095878d9a5b0b8913c2c2d17bbe Mon Sep 17 00:00:00 2001 From: Glenn Date: Sun, 24 Dec 2023 20:27:59 +0100 Subject: [PATCH] fix: improve display --- src/igmpgen.c | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/src/igmpgen.c b/src/igmpgen.c index af2bdad..333287c 100644 --- a/src/igmpgen.c +++ b/src/igmpgen.c @@ -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 Specify the network interface (e.g., eth0)\n"); + fprintf(stderr, " -t Specify the IGMP packet type and version (e.g., 1.query)\n"); + fprintf(stderr, " -g Specify the IGMP group (e.g., 224.0.0.1)\n"); + fprintf(stderr, " -s Specify the source IP and port (e.g., 192.168.1.1:1234)\n"); + fprintf(stderr, " -d Specify the destination IP and port (e.g., 224.0.0.2:5678)\n"); + fprintf(stderr, " -n 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