Fix messages
authorJoseph C. Lehner <joseph.c.lehner@gmail.com>
Mon, 25 Jan 2016 14:03:58 +0000 (15:03 +0100)
committerJoseph C. Lehner <joseph.c.lehner@gmail.com>
Mon, 25 Jan 2016 14:08:52 +0000 (15:08 +0100)
main.c
nmrp.c

diff --git a/main.c b/main.c
index 7f9797c0e68ae0b49a9b8cb16c9db9154d1270e6..4d204111173a9857dd86a94b46a9595f113d68a1 100644 (file)
--- a/main.c
+++ b/main.c
@@ -27,7 +27,7 @@ void usage(FILE *fp)
        fprintf(fp,
                        "Usage: nmrp-flash [OPTIONS...]\n"
                        "\n"
-                       "Options:\n"
+                       "Options (-a, -i and -f are mandatory):\n"
                        " -a <ipaddr>     IP address to assign to target device\n"
                        " -f <firmware>   Firmware file\n"
                        " -i <interface>  Network interface directly connected to device\n"
@@ -36,10 +36,18 @@ void usage(FILE *fp)
                        " -t <timeout>    Timeout (in milliseconds) for regular messages\n"
                        " -T <timeout>    Time to wait after successfull TFTP upload\n"
                        " -p <port>       Port to use for TFTP upload\n"
+                       " -V              Print version and exit\n"
                        " -h              Show this screen\n"
                        "\n"
-                       "Options -a, -i and -f are mandatory!\n"
+                       "Example:\n"
                        "\n"
+                       "$ sudo nmrp-flash -a 192.168.1.254 -i eth0 -f firmware.bin\n"
+                       "\n"
+                       "nmrp-flash v%s, Copyright (C) 2016 Joseph C. Lehner\n"
+                       "nmrp-flash is free software, licensed under the GNU GPLv3.\n"
+                       "Source code at https://github.com/jclehner/nmrp-flash\n"
+                       "\n",
+                       NMRPD_VERSION
          );
 }
 
@@ -61,7 +69,7 @@ int main(int argc, char **argv)
 
        opterr = 0;
 
-       while ((c = getopt(argc, argv, "a:f:i:m:M:p:t:T:")) != -1) {
+       while ((c = getopt(argc, argv, "a:f:i:m:M:p:t:T:hV")) != -1) {
                max = 0xffffffff;
                switch (c) {
                        case 'a':
@@ -98,6 +106,9 @@ int main(int argc, char **argv)
                                }
 
                                break;
+                       case 'V':
+                               printf("nmrp-flash v%s\n", NMRPD_VERSION);
+                               return 0;
                        case 'h':
                                usage(stdout);
                                return 0;
@@ -112,5 +123,10 @@ int main(int argc, char **argv)
                return 1;
        }
 
+       if (geteuid() != 0) {
+               fprintf(stderr, "This program must be run as root!\n");
+               return 1;
+       }
+
        return nmrp_do(&args);
 }
diff --git a/nmrp.c b/nmrp.c
index 0b771307566231da8d4c9e7117914d3692178458..59d0abca9ebcfcbffd713e5510d9b6d78a87bde6 100644 (file)
--- a/nmrp.c
+++ b/nmrp.c
@@ -437,7 +437,7 @@ int nmrp_do(struct nmrpd_args *args)
 
                                expect = NMRP_C_TFTP_UL_REQ;
 
-                               printf("Configuration request received from "
+                               printf("Received configuration request from "
                                                "%02x:%02x:%02x:%02x:%02x:%02x.\n",
                                                rx.eh.ether_shost[0], rx.eh.ether_shost[1],
                                                rx.eh.ether_shost[2], rx.eh.ether_shost[3],