This is the mail archive of the
ecos-patches@sources.redhat.com
mailing list for the eCos project.
Add ability to specify netmask to RedBoot ip_address command
- From: Ian Campbell <icampbell at arcom dot com>
- To: eCos Patches <ecos-patches at sources dot redhat dot com>
- Cc: David Vrabel <dvrabel at arcom dot com>
- Date: 20 May 2003 15:22:57 +0100
- Subject: Add ability to specify netmask to RedBoot ip_address command
- Organization: Arcom Controls Systems
Hi,
Attached is a patch made by my collegue David Vrabel to add the ability
to specify /netmask when setting the IP address via the ip_address
command.
I've had a go at the docs update, but I'm not sure how to specify a
optional part inside another optional part, as in [-l address[/mask]].
Nesting the <replaceable> tags didn't look right for some reason.
Cheers,
Ian.
2003-05-20 David Vrabel <dvrabel@arcom.com>
2003-05-20 Ian Campbell <icampbell@arcom.com>
* src/net/net_io.c: Add the ability to specify a netmask length to
the ip_address command
* doc/redboot_cmds.sgml: Document the above.
--
Ian Campbell
Design Engineer
Arcom Direct: +44 (0)1223 403 465
Clifton Road Phone: +44 (0)1223 411 200
Cambridge CB1 7EA E-Mail: icampbell@arcom.com
United Kingdom Web: http://www.arcom.com
________________________________________________________________________
This email has been scanned for all viruses by the MessageLabs Email
Security System. For more information on a proactive email security
service working around the clock, around the globe, visit
http://www.messagelabs.com
________________________________________________________________________
Index: packages/redboot/current/src/net/net_io.c
===================================================================
RCS file: /cvs/ecos/ecos/packages/redboot/current/src/net/net_io.c,v
retrieving revision 1.32
diff -u -B -p -r1.32 net_io.c
--- packages/redboot/current/src/net/net_io.c 20 Mar 2003 15:44:40 -0000 1.32
+++ packages/redboot/current/src/net/net_io.c 20 May 2003 13:32:54 -0000
@@ -781,7 +781,7 @@ net_init(void)
}
}
-static char usage[] = "[-l <local_ip_address>] [-h <server_address>]";
+static char usage[] = "[-l <local_ip_address>[/<mask len>]] [-h <server_address>]";
// Exported CLI function
static void do_ip_addr(int argc, char *argv[]);
@@ -818,6 +818,21 @@ do_ip_addr(int argc, char *argv[])
return;
}
if (ip_addr_set) {
+ char *slash_pos;
+ /* see if the (optional) mask length was given */
+ if( (slash_pos = strchr(ip_addr, '/')) ) {
+ int mask_len;
+ unsigned long mask;
+ *slash_pos = '\0';
+ slash_pos++;
+ if( !parse_num(slash_pos, &mask_len, 0, 0) || mask_len <= 0 || mask_len > 32 ) {
+ diag_printf("Invalid mask length: %s\n", slash_pos);
+ return;
+ }
+ mask = htonl(0xffffffff << (32-mask_len));
+ memcpy(&__local_ip_mask, &mask, 4);
+ }
+
if (!_gethostbyname(ip_addr, (in_addr_t *)&host)) {
diag_printf("Invalid local IP address: %s\n", ip_addr);
return;
Index: doc/redboot_cmds.sgml
===================================================================
RCS file: /cvs/ecos/ecos/packages/redboot/current/doc/redboot_cmds.sgml,v
retrieving revision 1.6
diff -u -b -B -w -p -u -r1.6 redboot_cmds.sgml
--- doc/redboot_cmds.sgml 4 Apr 2003 15:41:16 -0000 1.6
+++ doc/redboot_cmds.sgml 20 May 2003 14:14:14 -0000
@@ -128,7 +128,7 @@ Execute code at a location
Help about help?
help [<topic>]
Set/change IP addresses
- ip_address [-l <local_ip_address>] [-h <server_address>]
+ ip_address [-l <local_ip_address>[/<mask_lenght>]] [-h <server_address>]
Load a file
load [-r] [-v] [-d] [-c <channel>] [-h <host>] [-m {TFTP | HTTP | {x|y}MODEM | disk}]
[-b <base_address>] <file_name>
@@ -866,17 +866,22 @@ Execute code at a location
Help about help?
help [<topic>]
Set/change IP addresses
- ip_address [-l <local_ip_address>] [-h <server_address>]
+ ip_address [-l <local_ip_address>[/<mask_lenght>]] [-h <server_address>]
Load a file
load [-r] [-v] [-d] [-h <host>] [-m {TFTP | HTTP | {x|y}MODEM -c <channel_number>}]
[-b <base_address>] <file_name>
Compare two blocks of memory
mcmp -s <location> -d <location> -l <length> [-1|-2|-4]
Fill a block of memory with a pattern
@@ -922,7 +927,8 @@ Write raw data directly to FLASH
<refsynopsisdiv>
<cmdsynopsis>
<command>ip_address</command>
- <arg>-l <replaceable> local_IP_address</replaceable></arg>
+ <arg>-l <replaceable> local_IP_address</replaceable>
+ <replaceable>[/netmask_length]</replaceable> </arg>
<arg>-h <replaceable> server_IP_address</replaceable></arg>
<arg>-d <replaceable>
DNS_server_IP_address</replaceable></arg>
@@ -947,9 +953,10 @@ DNS_server_IP_address</replaceable></arg
<tbody>
<row>
<entry>-l <replaceable>
-local_IP_address</replaceable></entry>
+local_IP_address</replaceable> <replaceable>/netmask_length</replaceable></entry>
<entry>Numeric IP or DNS name</entry>
- <entry>The IP address RedBoot should use.</entry>
+ <entry>The IP address RedBoot should use, optionally
+with the network mask length.</entry>
<entry><emphasis>none</emphasis></entry>
</row>
<row>
@@ -981,7 +988,7 @@ if DNS support is enabled.
</para>
<para>
The <option>-l</option> option is used to set the IP address used by
-the target device.
+the target device. The network mask length can also be specified
</para>
<para>
The <option>-h</option> option is used to set the default server