Mercurial > ecos
changeset 1080:8e4712b0416d
* 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.
| author | jlarmour |
|---|---|
| date | Thu, 26 Jun 2003 05:29:44 +0000 |
| parents | b4dd94e7d372 |
| children | 006acfda1aae |
| files | packages/redboot/current/ChangeLog packages/redboot/current/doc/redboot_cmds.sgml packages/redboot/current/src/net/net_io.c |
| diffstat | 3 files changed, 43 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/packages/redboot/current/ChangeLog +++ b/packages/redboot/current/ChangeLog @@ -1,3 +1,15 @@ +2003-06-24 Jonathan Larmour <jifl@eCosCentric.com> + + * doc/redboot_cmds.sgml (IP): Clarify last change a bit and fix typos + and markup. + +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. + 2003-06-24 Jeroen Dobbelaere <jeroen.dobbelaere@acunia.com> 2003-06-24 Jonathan Larmour <jifl@eCosCentric.com>
--- a/packages/redboot/current/doc/redboot_cmds.sgml +++ b/packages/redboot/current/doc/redboot_cmds.sgml @@ -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_length>]] [-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,7 +866,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_length>]] [-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> @@ -922,7 +922,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> + <arg choice=opt>/<replaceable>netmask_length</replaceable></arg> </arg> <arg>-h <replaceable> server_IP_address</replaceable></arg> <arg>-d <replaceable> DNS_server_IP_address</replaceable></arg> @@ -947,9 +948,10 @@ DNS_server_IP_address</replaceable></arg <tbody> <row> <entry>-l <replaceable> -local_IP_address</replaceable></entry> +local_IP_address</replaceable><option>[<replaceable>/netmask_length</replaceable>]</option></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 +983,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 @@ -1015,6 +1017,13 @@ Change the default server address. RedBoot> <userinput>ip_address -h 192.168.1.104</userinput> IP: 192.168.1.31, Default server: 192.168.1.104, DNS server IP: 192.168.1.101 </screen> +</para> +<para> +Set the IP address to something new, with a 255.255.255.0 netmask +<screen> +RedBoot> <userinput>ip_address -l 192.168.1.32/24</userinput> +IP: 192.168.1.32, Default server: 192.168.1.104, DNS server IP: 192.168.1.101 +</screen> </para> </refsect1> </refentry>
--- a/packages/redboot/current/src/net/net_io.c +++ b/packages/redboot/current/src/net/net_io.c @@ -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))&0xffffffff); + 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;
