diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2011-05-21 18:25:31 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2011-05-21 18:25:31 +0000 |
commit | 1d8f60792331e913c6c4cd3bf3d6b785359778ee (patch) | |
tree | be04cc8b489c7456c1a2d9f6caf82d34590d3d00 /apps/nshlib/nsh_netcmds.c | |
parent | da19497e87298884e6b7c23b2892bb25cb12ef82 (diff) | |
download | nuttx-1d8f60792331e913c6c4cd3bf3d6b785359778ee.tar.gz nuttx-1d8f60792331e913c6c4cd3bf3d6b785359778ee.tar.bz2 nuttx-1d8f60792331e913c6c4cd3bf3d6b785359778ee.zip |
Add E1000 PIC NIC driver from Yu Qiang
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3638 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'apps/nshlib/nsh_netcmds.c')
-rw-r--r-- | apps/nshlib/nsh_netcmds.c | 44 |
1 files changed, 42 insertions, 2 deletions
diff --git a/apps/nshlib/nsh_netcmds.c b/apps/nshlib/nsh_netcmds.c index 1bd1e93e4..6e210c020 100644 --- a/apps/nshlib/nsh_netcmds.c +++ b/apps/nshlib/nsh_netcmds.c @@ -466,8 +466,48 @@ int cmd_get(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) #ifndef CONFIG_NSH_DISABLE_IFCONFIG int cmd_ifconfig(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) { - netdev_foreach(ifconfig_callback, vtbl); - uip_statistics(vtbl); + struct in_addr addr; + in_addr_t ip; + + /* With one or no arguments, ifconfig simply shows the status of ethernet + * device: + * + * ifconfig + * ifconfig [nic_name] + */ + + if (argc <= 2) + { + netdev_foreach(ifconfig_callback, vtbl); + uip_statistics(vtbl); + return OK; + } + + /* If both the network interface name and an IP address are supplied as + * arguments, then ifconfig will set the address of the ethernet device: + * + * ifconfig nic_name ip_address + */ + + /* Set host ip address */ + + ip = addr.s_addr = inet_addr(argv[2]); + uip_sethostaddr(argv[1], &addr); + + /* Set gateway */ + + ip = NTOHL(ip); + ip &= ~0x000000ff; + ip |= 0x00000001; + + addr.s_addr = HTONL(ip); + uip_setdraddr(argv[1], &addr); + + /* Set netmask */ + + addr.s_addr = inet_addr("255.255.255.0"); + uip_setnetmask(argv[1], &addr); + return OK; } #endif |