Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
nuttx-apps
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
f4grx
nuttx-apps
Commits
a274d423
Commit
a274d423
authored
10 years ago
by
Gregory Nutt
Browse files
Options
Downloads
Patches
Plain Diff
NSH: Networking features modified to handle the case of SLIP networks.
parent
e55af8e3
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
nshlib/nsh_netcmds.c
+16
-1
16 additions, 1 deletion
nshlib/nsh_netcmds.c
nshlib/nsh_netinit.c
+31
-11
31 additions, 11 deletions
nshlib/nsh_netinit.c
with
47 additions
and
12 deletions
nshlib/nsh_netcmds.c
+
16
−
1
View file @
a274d423
/****************************************************************************
* apps/nshlib/nsh_netcmds.c
*
* Copyright (C) 2007-2012 Gregory Nutt. All rights reserved.
* Copyright (C) 2007-2012
, 2014
Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
...
...
@@ -307,8 +307,12 @@ int ifconfig_callback(FAR struct uip_driver_s *dev, void *arg)
status
=
"DOWN"
;
}
#ifdef CONFIG_NET_ETHERNET
/* REVISIT: How will we handle Ethernet and SLIP networks together? */
nsh_output
(
vtbl
,
"%s
\t
HWaddr %s at %s
\n
"
,
dev
->
d_ifname
,
ether_ntoa
(
&
dev
->
d_mac
),
status
);
#endif
addr
.
s_addr
=
dev
->
d_ipaddr
;
nsh_output
(
vtbl
,
"
\t
IPaddr:%s "
,
inet_ntoa
(
addr
));
...
...
@@ -587,7 +591,9 @@ int cmd_ifconfig(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
FAR
char
*
gwip
=
NULL
;
FAR
char
*
mask
=
NULL
;
FAR
char
*
tmp
=
NULL
;
#ifndef CONFIG_NET_SLIP
FAR
char
*
hw
=
NULL
;
#endif
#if defined(CONFIG_NSH_DHCPC) || defined(CONFIG_NSH_DNS)
FAR
char
*
dns
=
NULL
;
#endif
...
...
@@ -656,6 +662,10 @@ int cmd_ifconfig(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
badarg
=
true
;
}
}
#ifndef CONFIG_NET_SLIP
/* REVISIT: How will we handle Ethernet and SLIP networks together? */
else
if
(
!
strcmp
(
tmp
,
"hw"
))
{
if
(
argc
-
1
>=
i
+
1
)
...
...
@@ -669,6 +679,8 @@ int cmd_ifconfig(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
badarg
=
true
;
}
}
#endif
#if defined(CONFIG_NSH_DHCPC) || defined(CONFIG_NSH_DNS)
else
if
(
!
strcmp
(
tmp
,
"dns"
))
{
...
...
@@ -693,13 +705,16 @@ int cmd_ifconfig(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
return
ERROR
;
}
#ifndef CONFIG_NET_SLIP
/* Set Hardware Ethernet MAC address */
/* REVISIT: How will we handle Ethernet and SLIP networks together? */
if
(
hw
)
{
ndbg
(
"HW MAC: %s
\n
"
,
hw
);
uip_setmacaddr
(
intf
,
mac
);
}
#endif
#if defined(CONFIG_NSH_DHCPC)
if
(
!
strcmp
(
hostip
,
"dhcp"
))
...
...
This diff is collapsed.
Click to expand it.
nshlib/nsh_netinit.c
+
31
−
11
View file @
a274d423
/****************************************************************************
* apps/nshlib/nsh_netinit.c
*
* Copyright (C) 2010-2012 Gregory Nutt. All rights reserved.
* Copyright (C) 2010-2012
, 2014
Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* This is influenced by similar logic from uIP:
...
...
@@ -64,6 +64,22 @@
# define CONFIG_NSH_DNSIPADDR CONFIG_NSH_DRIPADDR
#endif
/* SLIP-specific configuration
*
* REVISIT: How will we handle Ethernet and SLIP networks together? In the
* future, NSH will need to be extended to handle multiple networks with
* mixed transports.
*/
#ifdef CONFIG_NET_SLIP
# define NET_DEVNAME "sl0"
# ifndef CONFIG_NSH_NOMAC
# error "CONFIG_NSH_NOMAC must be defined for SLIP"
# endif
#else
# define NET_DEVNAME "eth0"
#endif
/****************************************************************************
* Private Types
****************************************************************************/
...
...
@@ -94,20 +110,20 @@ int nsh_netinit(void)
#if defined(CONFIG_NSH_DHCPC)
FAR
void
*
handle
;
#endif
#if defined(CONFIG_NSH_DHCPC) || defined(CONFIG_NSH_NOMAC)
#if
(
defined(CONFIG_NSH_DHCPC) || defined(CONFIG_NSH_NOMAC)
) && !defined(CONFIG_NET_SLIP)
uint8_t
mac
[
IFHWADDRLEN
];
#endif
/* Many embedded network interfaces must have a software assigned MAC */
#ifdef
CONFIG_NSH_NOMAC
#if
def
ined(
CONFIG_NSH_NOMAC
) && !defined(CONFIG_NET_SLIP)
mac
[
0
]
=
0x00
;
mac
[
1
]
=
0xe0
;
mac
[
2
]
=
0xde
;
mac
[
3
]
=
0xad
;
mac
[
4
]
=
0xbe
;
mac
[
5
]
=
0xef
;
uip_setmacaddr
(
"eth0"
,
mac
);
uip_setmacaddr
(
NET_DEVNAME
,
mac
);
#endif
/* Set up our host address */
...
...
@@ -117,17 +133,17 @@ int nsh_netinit(void)
#else
addr
.
s_addr
=
0
;
#endif
uip_sethostaddr
(
"eth0"
,
&
addr
);
uip_sethostaddr
(
NET_DEVNAME
,
&
addr
);
/* Set up the default router address */
addr
.
s_addr
=
HTONL
(
CONFIG_NSH_DRIPADDR
);
uip_setdraddr
(
"eth0"
,
&
addr
);
uip_setdraddr
(
NET_DEVNAME
,
&
addr
);
/* Setup the subnet mask */
addr
.
s_addr
=
HTONL
(
CONFIG_NSH_NETMASK
);
uip_setnetmask
(
"eth0"
,
&
addr
);
uip_setnetmask
(
NET_DEVNAME
,
&
addr
);
#if defined(CONFIG_NSH_DHCPC) || defined(CONFIG_NSH_DNS)
/* Set up the resolver */
...
...
@@ -142,7 +158,7 @@ int nsh_netinit(void)
#if defined(CONFIG_NSH_DHCPC)
/* Get the MAC address of the NIC */
uip_getmacaddr
(
"eth0"
,
mac
);
uip_getmacaddr
(
NET_DEVNAME
,
mac
);
/* Set up the DHCPC modules */
...
...
@@ -156,19 +172,23 @@ int nsh_netinit(void)
{
struct
dhcpc_state
ds
;
(
void
)
dhcpc_request
(
handle
,
&
ds
);
uip_sethostaddr
(
"eth0"
,
&
ds
.
ipaddr
);
uip_sethostaddr
(
NET_DEVNAME
,
&
ds
.
ipaddr
);
if
(
ds
.
netmask
.
s_addr
!=
0
)
{
uip_setnetmask
(
"eth0"
,
&
ds
.
netmask
);
uip_setnetmask
(
NET_DEVNAME
,
&
ds
.
netmask
);
}
if
(
ds
.
default_router
.
s_addr
!=
0
)
{
uip_setdraddr
(
"eth0"
,
&
ds
.
default_router
);
uip_setdraddr
(
NET_DEVNAME
,
&
ds
.
default_router
);
}
if
(
ds
.
dnsaddr
.
s_addr
!=
0
)
{
dns_setserver
(
&
ds
.
dnsaddr
);
}
dhcpc_close
(
handle
);
}
#endif
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment