Add help text for ifconfig

Chris Johns chrisj at rtems.org
Thu Oct 31 23:03:38 UTC 2013


On 31/10/2013 2:48 am, Ralf Kirchner wrote:
> This patch adds a simple help text to the ifconfig shall command. The help text gets displayed with the following commands:
> ifconfig --help
> ifconfig -help
> help ifconfig
>

I have the attached patch to add help I was sitting on.

Chris
-------------- next part --------------
diff --git a/cpukit/libmisc/shell/main_ifconfig.c b/cpukit/libmisc/shell/main_ifconfig.c
index d81d8b0..80e643a 100644
--- a/cpukit/libmisc/shell/main_ifconfig.c
+++ b/cpukit/libmisc/shell/main_ifconfig.c
@@ -89,15 +89,17 @@ static int rtems_shell_main_ifconfig(
 
   while(argc > cur_idx) {
     if (strcmp(argv[cur_idx], "up") == 0) {
-      f_up = 1;
       if (f_down != 0) {
         printf("Can't make interface up and down\n");
+        return -1;
       }
+      f_up = 1;
     } else if(strcmp(argv[cur_idx], "down") == 0) {
-      f_down = 1;
       if (f_up != 0) {
         printf("Can't make interface up and down\n");
-        }
+        return -1;
+      }
+      f_down = 1;
     } else if(strcmp(argv[cur_idx], "netmask") == 0) {
       if ((cur_idx + 1) >= argc) {
         printf("No netmask address\n");
@@ -229,7 +231,18 @@ static int rtems_shell_main_ifconfig(
 
 rtems_shell_cmd_t rtems_shell_IFCONFIG_Command = {
   "ifconfig",                                      /* name */
-  "TBD",                                           /* usage */
+  "ifconfig [iface]" \
+  "ifconfig iface [options] | addr\n" \
+  "  options: iface \n" \
+  "   iface: name of the interface\n" \
+  "   up: bring the interface up\n" \
+  "   down: take the interface down\n" \
+  "   netmask addr: network mask\n" \
+  "   netmask: network mask\n" \
+  "   broadcast: boardcast address\n" \
+  "   pointopoint: destination address for a PTP link\n" \
+  "\n" \
+  "   addr: IP address",
   "network",                                       /* topic */
   rtems_shell_main_ifconfig,                       /* command */
   NULL,                                            /* alias */


More information about the devel mailing list