Merged nuttx/apps into master
This commit is contained in:
commit
1ad991e803
@ -129,6 +129,12 @@ printf("NET1: Configuring %s\n", CONFIG_EXAMPLES_BRIDGE_NET1_IFNAME);
|
||||
addr.s_addr = HTONL(CONFIG_EXAMPLES_BRIDGE_NET1_NETMASK);
|
||||
netlib_set_ipv4netmask(CONFIG_EXAMPLES_BRIDGE_NET1_IFNAME, &addr);
|
||||
|
||||
/* New versions of netlib_set_ipvXaddr will not bring the network up,
|
||||
* So ensure the network is really up at this point.
|
||||
*/
|
||||
|
||||
netlib_ifup("eth0");
|
||||
|
||||
#ifdef CONFIG_EXAMPLES_BRIDGE_NET1_DHCPC
|
||||
/* Get the MAC address of the NIC */
|
||||
|
||||
@ -136,7 +142,7 @@ printf("NET1: Configuring %s\n", CONFIG_EXAMPLES_BRIDGE_NET1_IFNAME);
|
||||
|
||||
/* Set up the DHCPC modules */
|
||||
|
||||
handle = dhcpc_open(&mac, IFHWADDRLEN);
|
||||
handle = dhcpc_open("eth0", &mac, IFHWADDRLEN);
|
||||
|
||||
/* Get an IP address. Note: there is no logic here for renewing the address in this
|
||||
* example. The address should be renewed in ds.lease_time/2 seconds.
|
||||
|
@ -127,6 +127,12 @@ int dhcpd_main(int argc, char *argv[])
|
||||
addr.s_addr = HTONL(CONFIG_EXAMPLES_DHCPD_NETMASK);
|
||||
netlib_set_ipv4netmask("eth0", &addr);
|
||||
|
||||
/* New versions of netlib_set_ipvXaddr will not bring the network up,
|
||||
* So ensure the network is really up at this point.
|
||||
*/
|
||||
|
||||
netlib_ifup("eth0");
|
||||
|
||||
/* Then start the server */
|
||||
|
||||
dhcpd_run();
|
||||
|
@ -134,6 +134,12 @@ int discover_main(int argc, char *argv[])
|
||||
addr.s_addr = HTONL(CONFIG_EXAMPLES_DISCOVER_NETMASK);
|
||||
netlib_set_ipv4netmask("eth0", &addr);
|
||||
|
||||
/* New versions of netlib_set_ipvXaddr will not bring the network up,
|
||||
* So ensure the network is really up at this point.
|
||||
*/
|
||||
|
||||
netlib_ifup("eth0");
|
||||
|
||||
#ifdef CONFIG_EXAMPLES_DISCOVER_DHCPC
|
||||
/* Get the MAC address of the NIC */
|
||||
|
||||
@ -141,7 +147,7 @@ int discover_main(int argc, char *argv[])
|
||||
|
||||
/* Set up the DHCPC modules */
|
||||
|
||||
handle = dhcpc_open(&mac, IFHWADDRLEN);
|
||||
handle = dhcpc_open("eth0", &mac, IFHWADDRLEN);
|
||||
|
||||
/* Get an IP address. Note: there is no logic here for renewing the address in this
|
||||
* example. The address should be renewed in ds.lease_time/2 seconds.
|
||||
|
@ -114,6 +114,13 @@ static void fptd_netinit(void)
|
||||
|
||||
addr.s_addr = HTONL(CONFIG_EXAMPLES_FTPD_NETMASK);
|
||||
netlib_set_ipv4netmask("eth0", &addr);
|
||||
|
||||
/* New versions of netlib_set_ipvXaddr will not bring the network up,
|
||||
* So ensure the network is really up at this point.
|
||||
*/
|
||||
|
||||
netlib_ifup("eth0");
|
||||
|
||||
#endif /* CONFIG_EXAMPLES_FTPD_NONETINIT */
|
||||
}
|
||||
|
||||
|
@ -123,6 +123,12 @@ int igmp_main(int argc, char *argv[])
|
||||
addr.s_addr = HTONL(CONFIG_EXAMPLES_IGMP_NETMASK);
|
||||
netlib_set_ipv4netmask("eth0", &addr);
|
||||
|
||||
/* New versions of netlib_set_ipvXaddr will not bring the network up,
|
||||
* So ensure the network is really up at this point.
|
||||
*/
|
||||
|
||||
netlib_ifup("eth0");
|
||||
|
||||
/* Not much of a test for now */
|
||||
/* Join the group */
|
||||
|
||||
|
@ -159,6 +159,12 @@ static void netest_initialize(void)
|
||||
netlib_set_ipv6netmask("eth0",
|
||||
(FAR const struct in6_addr *)g_ipv6_netmask);
|
||||
|
||||
/* New versions of netlib_set_ipvXaddr will not bring the network up,
|
||||
* So ensure the network is really up at this point.
|
||||
*/
|
||||
|
||||
netlib_ifup("eth0");
|
||||
|
||||
#endif /* CONFIG_NET_ICMPv6_AUTOCONF */
|
||||
#else /* CONFIG_EXAMPLES_NETTEST_IPv6 */
|
||||
|
||||
|
@ -95,18 +95,17 @@ static struct mallinfo g_mmprevious;
|
||||
static struct mallinfo g_mmafter;
|
||||
|
||||
#ifndef CONFIG_DISABLE_ENVIRON
|
||||
const char g_var1_name[] = "Variable1";
|
||||
const char g_var1_value[] = "GoodValue1";
|
||||
const char g_var2_name[] = "Variable2";
|
||||
const char g_var2_value[] = "GoodValue2";
|
||||
const char g_var3_name[] = "Variable3";
|
||||
const char g_var3_value[] = "GoodValue3";
|
||||
static const char g_var1_name[] = "Variable1";
|
||||
static const char g_var1_value[] = "GoodValue1";
|
||||
static const char g_var2_name[] = "Variable2";
|
||||
static const char g_var2_value[] = "GoodValue2";
|
||||
static const char g_var3_name[] = "Variable3";
|
||||
static const char g_var3_value[] = "GoodValue3";
|
||||
|
||||
const char g_bad_value1[] = "BadValue1";
|
||||
const char g_bad_value2[] = "BadValue2";
|
||||
|
||||
const char g_putenv_value[] = "Variable1=BadValue3";
|
||||
static const char g_bad_value1[] = "BadValue1";
|
||||
static const char g_bad_value2[] = "BadValue2";
|
||||
|
||||
static const char g_putenv_value[] = "Variable1=BadValue3";
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
|
@ -63,10 +63,6 @@
|
||||
#define sched_lock()
|
||||
#define sched_unlock()
|
||||
|
||||
#ifndef NULL
|
||||
# define NULL (void*)0
|
||||
#endif
|
||||
|
||||
#ifndef MIN
|
||||
# define MIN(a,b) (((a) < (b)) ? (a) : (b))
|
||||
#endif
|
||||
@ -82,7 +78,7 @@ static time_t g_start_time;
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
void my_mdelay(unsigned int milliseconds)
|
||||
static void my_mdelay(unsigned int milliseconds)
|
||||
{
|
||||
volatile unsigned int i;
|
||||
volatile unsigned int j;
|
||||
@ -94,6 +90,7 @@ void my_mdelay(unsigned int milliseconds)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void *nuisance_func(void *parameter)
|
||||
{
|
||||
/* Synchronized start */
|
||||
@ -368,4 +365,4 @@ void sporadic_test(void)
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* CONFIG_SCHED_SPORADIC */
|
||||
#endif /* CONFIG_SCHED_SPORADIC */
|
||||
|
@ -325,6 +325,12 @@ static void net_configure(void)
|
||||
|
||||
addr.s_addr = HTONL(CONFIG_EXAMPLES_POLL_NETMASK);
|
||||
netlib_set_ipv4netmask("eth0", &addr);
|
||||
|
||||
/* New versions of netlib_set_ipvXaddr will not bring the network up,
|
||||
* So ensure the network is really up at this point.
|
||||
*/
|
||||
|
||||
netlib_ifup("eth0");
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
@ -118,6 +118,12 @@ static void net_configure(void)
|
||||
|
||||
addr.s_addr = HTONL(CONFIG_EXAMPLES_POLL_NETMASK);
|
||||
netlib_set_ipv4netmask("eth0", &addr);
|
||||
|
||||
/* New versions of netlib_set_ipvXaddr will not bring the network up,
|
||||
* So ensure the network is really up at this point.
|
||||
*/
|
||||
|
||||
netlib_ifup("eth0");
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
@ -150,6 +150,12 @@ int sendmail_main(int argc, char *argv[])
|
||||
addr.s_addr = HTONL(CONFIG_EXAMPLES_SENDMAIL_NETMASK);
|
||||
netlib_set_ipv4netmask("eth0", &addr);
|
||||
|
||||
/* New versions of netlib_set_ipvXaddr will not bring the network up,
|
||||
* So ensure the network is really up at this point.
|
||||
*/
|
||||
|
||||
netlib_ifup("eth0");
|
||||
|
||||
/* Then send the mail */
|
||||
|
||||
net_ipaddr(addr.s_addr, 127, 0, 0, 1);
|
||||
|
@ -143,6 +143,12 @@ static int tcpecho_netsetup()
|
||||
addr.s_addr = HTONL(CONFIG_EXAMPLES_TCPECHO_NETMASK);
|
||||
netlib_set_ipv4netmask("eth0", &addr);
|
||||
|
||||
/* New versions of netlib_set_ipvXaddr will not bring the network up,
|
||||
* So ensure the network is really up at this point.
|
||||
*/
|
||||
|
||||
netlib_ifup("eth0");
|
||||
|
||||
#ifdef CONFIG_EXAMPLES_TCPECHO_DHCPC
|
||||
/* Get the MAC address of the NIC */
|
||||
|
||||
@ -150,7 +156,7 @@ static int tcpecho_netsetup()
|
||||
|
||||
/* Set up the DHCPC modules */
|
||||
|
||||
handle = dhcpc_open(&mac, IFHWADDRLEN);
|
||||
handle = dhcpc_open("eth0", &mac, IFHWADDRLEN);
|
||||
|
||||
/* Get an IP address. Note: there is no logic here for renewing the address in this
|
||||
* example. The address should be renewed in ds.lease_time/2 seconds.
|
||||
|
@ -218,6 +218,12 @@ static void telnetd_netinit(void)
|
||||
|
||||
addr.s_addr = HTONL(CONFIG_EXAMPLES_TELNETD_NETMASK);
|
||||
netlib_set_ipv4netmask("eth0", &addr);
|
||||
|
||||
/* New versions of netlib_set_ipvXaddr will not bring the network up,
|
||||
* So ensure the network is really up at this point.
|
||||
*/
|
||||
|
||||
netlib_ifup("eth0");
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
@ -254,6 +254,12 @@ int thttp_main(int argc, char *argv[])
|
||||
addr.s_addr = HTONL(CONFIG_EXAMPLES_THTTPD_NETMASK);
|
||||
netlib_set_ipv4netmask(NET_DEVNAME, &addr);
|
||||
|
||||
/* New versions of netlib_set_ipvXaddr will not bring the network up,
|
||||
* So ensure the network is really up at this point.
|
||||
*/
|
||||
|
||||
netlib_ifup("eth0");
|
||||
|
||||
#ifdef CONFIG_THTTPD_NXFLAT
|
||||
/* Initialize the NXFLAT binary loader */
|
||||
|
||||
|
@ -160,6 +160,12 @@ int udp_main(int argc, char *argv[])
|
||||
|
||||
#endif /* CONFIG_EXAMPLES_UDP_IPv6 */
|
||||
|
||||
/* New versions of netlib_set_ipvXaddr will not bring the network up,
|
||||
* So ensure the network is really up at this point.
|
||||
*/
|
||||
|
||||
netlib_ifup("eth0");
|
||||
|
||||
#ifdef CONFIG_EXAMPLES_UDP_SERVER
|
||||
recv_server();
|
||||
#else
|
||||
|
@ -173,6 +173,13 @@ static void netest_initialize(void)
|
||||
netlib_set_ipv4netmask("eth0", &addr);
|
||||
|
||||
#endif /* CONFIG_EXAMPLES_UDPBLASTER_IPv6 */
|
||||
|
||||
/* New versions of netlib_set_ipvXaddr will not bring the network up,
|
||||
* So ensure the network is really up at this point.
|
||||
*/
|
||||
|
||||
netlib_ifup("eth0");
|
||||
|
||||
}
|
||||
#endif /*CONFIG_EXAMPLES_UDPBLASTER_INIT */
|
||||
|
||||
|
@ -140,6 +140,12 @@ int webserver_main(int argc, char *argv[])
|
||||
addr.s_addr = HTONL(CONFIG_EXAMPLES_WEBSERVER_NETMASK);
|
||||
netlib_set_ipv4netmask("eth0", &addr);
|
||||
|
||||
/* New versions of netlib_set_ipvXaddr will not bring the network up,
|
||||
* So ensure the network is really up at this point.
|
||||
*/
|
||||
|
||||
netlib_ifup("eth0");
|
||||
|
||||
#ifdef CONFIG_EXAMPLES_WEBSERVER_DHCPC
|
||||
/* Get the MAC address of the NIC */
|
||||
|
||||
@ -147,7 +153,7 @@ int webserver_main(int argc, char *argv[])
|
||||
|
||||
/* Set up the DHCPC modules */
|
||||
|
||||
handle = dhcpc_open(&mac, IFHWADDRLEN);
|
||||
handle = dhcpc_open("eth0", &mac, IFHWADDRLEN);
|
||||
|
||||
/* Get an IP address. Note: there is no logic here for renewing the address in this
|
||||
* example. The address should be renewed in ds.lease_time/2 seconds.
|
||||
|
@ -144,6 +144,12 @@ int wget_main(int argc, char *argv[])
|
||||
addr.s_addr = HTONL(CONFIG_EXAMPLES_WGET_NETMASK);
|
||||
netlib_set_ipv4netmask("eth0", &addr);
|
||||
|
||||
/* New versions of netlib_set_ipvXaddr will not bring the network up,
|
||||
* So ensure the network is really up at this point.
|
||||
*/
|
||||
|
||||
netlib_ifup("eth0");
|
||||
|
||||
/* Then start the server */
|
||||
|
||||
wget(CONFIG_EXAMPLES_WGET_URL, g_iobuffer, 512, callback, NULL);
|
||||
|
@ -308,6 +308,12 @@ static int xmlrpc_netinit(void)
|
||||
addr.s_addr = HTONL(CONFIG_EXAMPLES_XMLRPC_NETMASK);
|
||||
netlib_set_ipv4netmask("eth0", &addr);
|
||||
|
||||
/* New versions of netlib_set_ipvXaddr will not bring the network up,
|
||||
* So ensure the network is really up at this point.
|
||||
*/
|
||||
|
||||
netlib_ifup("eth0");
|
||||
|
||||
#ifdef CONFIG_EXAMPLES_XMLRPC_DHCPC
|
||||
/* Get the MAC address of the NIC */
|
||||
|
||||
@ -315,7 +321,7 @@ static int xmlrpc_netinit(void)
|
||||
|
||||
/* Set up the DHCPC modules */
|
||||
|
||||
handle = dhcpc_open(&mac, IFHWADDRLEN);
|
||||
handle = dhcpc_open("eth0", &mac, IFHWADDRLEN);
|
||||
|
||||
/* Get an IP address. Note: there is no logic here for renewing the address
|
||||
* in this example. The address should be renewed in ds.lease_time/2
|
||||
|
@ -75,8 +75,9 @@ extern "C"
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
FAR void *dhcpc_open(FAR const void *mac_addr, int mac_len);
|
||||
int dhcpc_request(FAR void *handle, FAR struct dhcpc_state *presult);
|
||||
FAR void *dhcpc_open(FAR const char *interface,
|
||||
FAR const void *mac_addr, int mac_len);
|
||||
int dhcpc_request(FAR void *handle, FAR struct dhcpc_state *presult);
|
||||
void dhcpc_close(FAR void *handle);
|
||||
|
||||
#undef EXTERN
|
||||
|
@ -12,12 +12,4 @@ config NETUTILS_DHCPC
|
||||
|
||||
if NETUTILS_DHCPC
|
||||
|
||||
config NETUTILS_DHCPC_DEVNAME
|
||||
string "DHCP device name"
|
||||
default "eth0" if !DRIVERS_IEEE80211
|
||||
default "wlan0" if DRIVERS_IEEE80211
|
||||
depends on NET_UDP && NET_BROADCAST && NET_IPv4
|
||||
---help---
|
||||
Specify the Ethernet or IEEE 802.15.4 device to use.
|
||||
|
||||
endif
|
||||
|
@ -63,11 +63,6 @@
|
||||
|
||||
/* Configuration */
|
||||
|
||||
#ifdef CONFIG_NETUTILS_DHCPC_DEVNAME
|
||||
# define DEVNAME CONFIG_NETUTILS_DHCPC_DEVNAME
|
||||
#else
|
||||
# define DEVNAME "eth0"
|
||||
#endif
|
||||
|
||||
/* DHCP Definitions */
|
||||
|
||||
@ -133,7 +128,8 @@ struct dhcp_msg
|
||||
|
||||
struct dhcpc_state_s
|
||||
{
|
||||
const void *ds_macaddr;
|
||||
FAR const char *interface;
|
||||
FAR const void *ds_macaddr;
|
||||
int ds_maclen;
|
||||
int sockfd;
|
||||
struct in_addr ipaddr;
|
||||
@ -156,7 +152,7 @@ static const uint8_t magic_cookie[4] = {99, 130, 83, 99};
|
||||
* Name: dhcpc_add<option>
|
||||
****************************************************************************/
|
||||
|
||||
static uint8_t *dhcpc_addmsgtype(uint8_t *optptr, uint8_t type)
|
||||
static FAR uint8_t *dhcpc_addmsgtype(FAR uint8_t *optptr, uint8_t type)
|
||||
{
|
||||
*optptr++ = DHCP_OPTION_MSG_TYPE;
|
||||
*optptr++ = 1;
|
||||
@ -164,7 +160,8 @@ static uint8_t *dhcpc_addmsgtype(uint8_t *optptr, uint8_t type)
|
||||
return optptr;
|
||||
}
|
||||
|
||||
static uint8_t *dhcpc_addserverid(struct in_addr *serverid, uint8_t *optptr)
|
||||
static FAR uint8_t *dhcpc_addserverid(FAR struct in_addr *serverid,
|
||||
FAR uint8_t *optptr)
|
||||
{
|
||||
*optptr++ = DHCP_OPTION_SERVER_ID;
|
||||
*optptr++ = 4;
|
||||
@ -172,7 +169,8 @@ static uint8_t *dhcpc_addserverid(struct in_addr *serverid, uint8_t *optptr)
|
||||
return optptr + 4;
|
||||
}
|
||||
|
||||
static uint8_t *dhcpc_addreqipaddr(struct in_addr *ipaddr, uint8_t *optptr)
|
||||
static FAR uint8_t *dhcpc_addreqipaddr(FAR struct in_addr *ipaddr,
|
||||
FAR uint8_t *optptr)
|
||||
{
|
||||
*optptr++ = DHCP_OPTION_REQ_IPADDR;
|
||||
*optptr++ = 4;
|
||||
@ -180,7 +178,7 @@ static uint8_t *dhcpc_addreqipaddr(struct in_addr *ipaddr, uint8_t *optptr)
|
||||
return optptr + 4;
|
||||
}
|
||||
|
||||
static uint8_t *dhcpc_addreqoptions(uint8_t *optptr)
|
||||
static FAR uint8_t *dhcpc_addreqoptions(FAR uint8_t *optptr)
|
||||
{
|
||||
*optptr++ = DHCP_OPTION_REQ_LIST;
|
||||
*optptr++ = 3;
|
||||
@ -190,7 +188,7 @@ static uint8_t *dhcpc_addreqoptions(uint8_t *optptr)
|
||||
return optptr;
|
||||
}
|
||||
|
||||
static uint8_t *dhcpc_addend(uint8_t *optptr)
|
||||
static FAR uint8_t *dhcpc_addend(FAR uint8_t *optptr)
|
||||
{
|
||||
*optptr++ = DHCP_OPTION_END;
|
||||
return optptr;
|
||||
@ -200,11 +198,11 @@ static uint8_t *dhcpc_addend(uint8_t *optptr)
|
||||
* Name: dhcpc_sendmsg
|
||||
****************************************************************************/
|
||||
|
||||
static int dhcpc_sendmsg(struct dhcpc_state_s *pdhcpc,
|
||||
struct dhcpc_state *presult, int msgtype)
|
||||
static int dhcpc_sendmsg(FAR struct dhcpc_state_s *pdhcpc,
|
||||
FAR struct dhcpc_state *presult, int msgtype)
|
||||
{
|
||||
struct sockaddr_in addr;
|
||||
uint8_t *pend;
|
||||
FAR uint8_t *pend;
|
||||
in_addr_t serverid = INADDR_BROADCAST;
|
||||
int len;
|
||||
|
||||
@ -273,9 +271,10 @@ static int dhcpc_sendmsg(struct dhcpc_state_s *pdhcpc,
|
||||
* Name: dhcpc_parseoptions
|
||||
****************************************************************************/
|
||||
|
||||
static uint8_t dhcpc_parseoptions(struct dhcpc_state *presult, uint8_t *optptr, int len)
|
||||
static uint8_t dhcpc_parseoptions(FAR struct dhcpc_state *presult,
|
||||
FAR uint8_t *optptr, int len)
|
||||
{
|
||||
uint8_t *end = optptr + len;
|
||||
FAR uint8_t *end = optptr + len;
|
||||
uint8_t type = 0;
|
||||
|
||||
while (optptr < end)
|
||||
@ -328,6 +327,7 @@ static uint8_t dhcpc_parseoptions(struct dhcpc_state *presult, uint8_t *optptr,
|
||||
|
||||
optptr += optptr[1] + 2;
|
||||
}
|
||||
|
||||
return type;
|
||||
}
|
||||
|
||||
@ -335,8 +335,8 @@ static uint8_t dhcpc_parseoptions(struct dhcpc_state *presult, uint8_t *optptr,
|
||||
* Name: dhcpc_parsemsg
|
||||
****************************************************************************/
|
||||
|
||||
static uint8_t dhcpc_parsemsg(struct dhcpc_state_s *pdhcpc, int buflen,
|
||||
struct dhcpc_state *presult)
|
||||
static uint8_t dhcpc_parsemsg(FAR struct dhcpc_state_s *pdhcpc, int buflen,
|
||||
FAR struct dhcpc_state *presult)
|
||||
{
|
||||
if (pdhcpc->packet.op == DHCP_REPLY &&
|
||||
memcmp(pdhcpc->packet.xid, xid, sizeof(xid)) == 0 &&
|
||||
@ -345,6 +345,7 @@ static uint8_t dhcpc_parsemsg(struct dhcpc_state_s *pdhcpc, int buflen,
|
||||
memcpy(&presult->ipaddr.s_addr, pdhcpc->packet.yiaddr, 4);
|
||||
return dhcpc_parseoptions(presult, &pdhcpc->packet.options[4], buflen);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -356,9 +357,10 @@ static uint8_t dhcpc_parsemsg(struct dhcpc_state_s *pdhcpc, int buflen,
|
||||
* Name: dhcpc_open
|
||||
****************************************************************************/
|
||||
|
||||
void *dhcpc_open(const void *macaddr, int maclen)
|
||||
FAR void *dhcpc_open(FAR const char *interface, FAR const void *macaddr,
|
||||
int maclen)
|
||||
{
|
||||
struct dhcpc_state_s *pdhcpc;
|
||||
FAR struct dhcpc_state_s *pdhcpc;
|
||||
struct sockaddr_in addr;
|
||||
struct timeval tv;
|
||||
int ret;
|
||||
@ -369,12 +371,13 @@ void *dhcpc_open(const void *macaddr, int maclen)
|
||||
|
||||
/* Allocate an internal DHCP structure */
|
||||
|
||||
pdhcpc = (struct dhcpc_state_s *)malloc(sizeof(struct dhcpc_state_s));
|
||||
pdhcpc = (FAR struct dhcpc_state_s *)malloc(sizeof(struct dhcpc_state_s));
|
||||
if (pdhcpc)
|
||||
{
|
||||
/* Initialize the allocated structure */
|
||||
|
||||
memset(pdhcpc, 0, sizeof(struct dhcpc_state_s));
|
||||
pdhcpc->interface = interface;
|
||||
pdhcpc->ds_macaddr = macaddr;
|
||||
pdhcpc->ds_maclen = maclen;
|
||||
|
||||
@ -418,14 +421,14 @@ void *dhcpc_open(const void *macaddr, int maclen)
|
||||
}
|
||||
}
|
||||
|
||||
return (void*)pdhcpc;
|
||||
return (FAR void *)pdhcpc;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: dhcpc_close
|
||||
****************************************************************************/
|
||||
|
||||
void dhcpc_close(void *handle)
|
||||
void dhcpc_close(FAR void *handle)
|
||||
{
|
||||
struct dhcpc_state_s *pdhcpc = (struct dhcpc_state_s *)handle;
|
||||
|
||||
@ -444,9 +447,9 @@ void dhcpc_close(void *handle)
|
||||
* Name: dhcpc_request
|
||||
****************************************************************************/
|
||||
|
||||
int dhcpc_request(void *handle, struct dhcpc_state *presult)
|
||||
int dhcpc_request(FAR void *handle, FAR struct dhcpc_state *presult)
|
||||
{
|
||||
struct dhcpc_state_s *pdhcpc = (struct dhcpc_state_s *)handle;
|
||||
FAR struct dhcpc_state_s *pdhcpc = (FAR struct dhcpc_state_s *)handle;
|
||||
struct in_addr oldaddr;
|
||||
struct in_addr newaddr;
|
||||
ssize_t result;
|
||||
@ -457,7 +460,7 @@ int dhcpc_request(void *handle, struct dhcpc_state *presult)
|
||||
/* Save the currently assigned IP address (should be INADDR_ANY) */
|
||||
|
||||
oldaddr.s_addr = 0;
|
||||
netlib_get_ipv4addr(DEVNAME, &oldaddr);
|
||||
netlib_get_ipv4addr(pdhcpc->interface, &oldaddr);
|
||||
|
||||
/* Loop until we receive the lease (or an error occurs) */
|
||||
|
||||
@ -466,7 +469,7 @@ int dhcpc_request(void *handle, struct dhcpc_state *presult)
|
||||
/* Set the IP address to INADDR_ANY. */
|
||||
|
||||
newaddr.s_addr = INADDR_ANY;
|
||||
(void)netlib_set_ipv4addr(DEVNAME, &newaddr);
|
||||
(void)netlib_set_ipv4addr(pdhcpc->interface, &newaddr);
|
||||
|
||||
/* Loop sending DISCOVER until we receive an OFFER from a DHCP
|
||||
* server. We will lock on to the first OFFER and decline any
|
||||
@ -506,7 +509,7 @@ int dhcpc_request(void *handle, struct dhcpc_state *presult)
|
||||
* out of the loop.
|
||||
*/
|
||||
|
||||
(void)netlib_set_ipv4addr(DEVNAME, &presult->ipaddr);
|
||||
(void)netlib_set_ipv4addr(pdhcpc->interface, &presult->ipaddr);
|
||||
state = STATE_HAVE_OFFER;
|
||||
}
|
||||
}
|
||||
@ -598,7 +601,7 @@ int dhcpc_request(void *handle, struct dhcpc_state *presult)
|
||||
{
|
||||
/* An error other than a timeout was received */
|
||||
|
||||
(void)netlib_set_ipv4addr(DEVNAME, &oldaddr);
|
||||
(void)netlib_set_ipv4addr(pdhcpc->interface, &oldaddr);
|
||||
return ERROR;
|
||||
}
|
||||
}
|
||||
|
@ -49,7 +49,7 @@
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
const char g_http[] = "http://";
|
||||
static const char g_http[] = "http://";
|
||||
#define HTTPLEN 7
|
||||
|
||||
/****************************************************************************
|
||||
|
@ -1063,7 +1063,7 @@ int cmd_ifconfig(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
|
||||
|
||||
/* Set up the DHCPC modules */
|
||||
|
||||
handle = dhcpc_open(&mac, IFHWADDRLEN);
|
||||
handle = dhcpc_open("eth0", &mac, IFHWADDRLEN);
|
||||
|
||||
/* Get an IP address. Note that there is no logic for renewing the IP
|
||||
* address in this example. The address should be renewed in
|
||||
|
@ -358,6 +358,12 @@ static void nsh_netinit_configure(void)
|
||||
netlib_set_ipv4dnsaddr(&addr);
|
||||
#endif
|
||||
|
||||
/* New versions of netlib_set_ipvXaddr will not bring the network up,
|
||||
* So ensure the network is really up at this point.
|
||||
*/
|
||||
|
||||
netlib_ifup("eth0");
|
||||
|
||||
#ifdef CONFIG_WIRELESS_WAPI
|
||||
/* Associate the wlan with an access point. */
|
||||
|
||||
@ -371,7 +377,7 @@ static void nsh_netinit_configure(void)
|
||||
|
||||
/* Set up the DHCPC modules */
|
||||
|
||||
handle = dhcpc_open(&mac, IFHWADDRLEN);
|
||||
handle = dhcpc_open(NET_DEVNAME, &mac, IFHWADDRLEN);
|
||||
|
||||
/* Get an IP address. Note that there is no logic for renewing the IP address in this
|
||||
* example. The address should be renewed in ds.lease_time/2 seconds.
|
||||
|
@ -132,12 +132,6 @@ struct cdcacm_state_s
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/* All global variables used by this add-on are packed into a structure in
|
||||
* order to avoid name collisions.
|
||||
*/
|
||||
|
||||
extern struct cdcacm_state_s g_cdcacm;
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
@ -58,7 +58,7 @@
|
||||
* order to avoid name collisions.
|
||||
*/
|
||||
|
||||
struct cdcacm_state_s g_cdcacm;
|
||||
static struct cdcacm_state_s g_cdcacm;
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
|
@ -78,10 +78,6 @@ struct cu_globals_s
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/* terminal state data */
|
||||
|
||||
extern struct cu_globals_s g_cu;
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
@ -76,14 +76,12 @@ enum parity_mode
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
static struct cu_globals_s g_cu;
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
/* terminal state data */
|
||||
|
||||
struct cu_globals_s g_cu;
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
@ -43,15 +43,67 @@
|
||||
|
||||
#include "i2ctool.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: arg_string
|
||||
****************************************************************************/
|
||||
|
||||
static int arg_string(FAR char **arg, FAR char **value)
|
||||
{
|
||||
FAR char *ptr = *arg;
|
||||
|
||||
if (ptr[2] == '\0')
|
||||
{
|
||||
*value = arg[1];
|
||||
return 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
*value = &ptr[2];
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: arg_decimal
|
||||
****************************************************************************/
|
||||
|
||||
static int arg_decimal(FAR char **arg, FAR long *value)
|
||||
{
|
||||
FAR char *string;
|
||||
int ret;
|
||||
|
||||
ret = arg_string(arg, &string);
|
||||
*value = strtol(string, NULL, 10);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: arg_hex
|
||||
****************************************************************************/
|
||||
|
||||
static int arg_hex(FAR char **arg, FAR long *value)
|
||||
{
|
||||
FAR char *string;
|
||||
int ret;
|
||||
|
||||
ret = arg_string(arg, &string);
|
||||
*value = strtol(string, NULL, 16);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: common_args
|
||||
* Name: i2ctool_common_args
|
||||
****************************************************************************/
|
||||
|
||||
int common_args(FAR struct i2ctool_s *i2ctool, FAR char **arg)
|
||||
int i2ctool_common_args(FAR struct i2ctool_s *i2ctool, FAR char **arg)
|
||||
{
|
||||
FAR char *ptr = *arg;
|
||||
long value;
|
||||
@ -148,50 +200,3 @@ out_of_range:
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: arg_string
|
||||
****************************************************************************/
|
||||
|
||||
int arg_string(FAR char **arg, FAR char **value)
|
||||
{
|
||||
FAR char *ptr = *arg;
|
||||
|
||||
if (ptr[2] == '\0')
|
||||
{
|
||||
*value = arg[1];
|
||||
return 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
*value = &ptr[2];
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: arg_decimal
|
||||
****************************************************************************/
|
||||
|
||||
int arg_decimal(FAR char **arg, FAR long *value)
|
||||
{
|
||||
FAR char *string;
|
||||
int ret;
|
||||
|
||||
ret = arg_string(arg, &string);
|
||||
*value = strtol(string, NULL, 10);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: arg_hex
|
||||
****************************************************************************/
|
||||
|
||||
int arg_hex(FAR char **arg, FAR long *value)
|
||||
{
|
||||
FAR char *string;
|
||||
int ret;
|
||||
|
||||
ret = arg_string(arg, &string);
|
||||
*value = strtol(string, NULL, 16);
|
||||
return ret;
|
||||
}
|
||||
|
@ -88,7 +88,7 @@ int i2ccmd_dev(FAR struct i2ctool_s *i2ctool, int argc, char **argv)
|
||||
|
||||
/* Otherwise, check for common options */
|
||||
|
||||
nargs = common_args(i2ctool, &argv[argndx]);
|
||||
nargs = i2ctool_common_args(i2ctool, &argv[argndx]);
|
||||
if (nargs < 0)
|
||||
{
|
||||
return ERROR;
|
||||
|
@ -79,7 +79,7 @@ int i2ccmd_get(FAR struct i2ctool_s *i2ctool, int argc, FAR char **argv)
|
||||
|
||||
/* Otherwise, check for common options */
|
||||
|
||||
nargs = common_args(i2ctool, &argv[argndx]);
|
||||
nargs = i2ctool_common_args(i2ctool, &argv[argndx]);
|
||||
if (nargs < 0)
|
||||
{
|
||||
return ERROR;
|
||||
|
@ -63,7 +63,7 @@ static int i2ccmd_unrecognized(FAR struct i2ctool_s *i2ctool, int argc, char **a
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
struct i2ctool_s g_i2ctool;
|
||||
static struct i2ctool_s g_i2ctool;
|
||||
|
||||
static const struct cmdmap_s g_i2ccmds[] =
|
||||
{
|
||||
@ -202,7 +202,8 @@ static int i2c_execute(FAR struct i2ctool_s *i2ctool, int argc, char *argv[])
|
||||
* Name: i2c_argument
|
||||
****************************************************************************/
|
||||
|
||||
FAR char *i2c_argument(FAR struct i2ctool_s *i2ctool, int argc, char *argv[], int *pindex)
|
||||
static FAR char *i2c_argument(FAR struct i2ctool_s *i2ctool,
|
||||
int argc, char *argv[], int *pindex)
|
||||
{
|
||||
FAR char *arg;
|
||||
int index = *pindex;
|
||||
@ -247,7 +248,7 @@ FAR char *i2c_argument(FAR struct i2ctool_s *i2ctool, int argc, char *argv[], in
|
||||
* Name: i2c_parse
|
||||
****************************************************************************/
|
||||
|
||||
int i2c_parse(FAR struct i2ctool_s *i2ctool, int argc, char *argv[])
|
||||
static int i2c_parse(FAR struct i2ctool_s *i2ctool, int argc, char *argv[])
|
||||
{
|
||||
FAR char *newargs[MAX_ARGUMENTS+2];
|
||||
FAR char *cmd;
|
||||
|
@ -79,7 +79,7 @@ int i2ccmd_set(FAR struct i2ctool_s *i2ctool, int argc, FAR char **argv)
|
||||
|
||||
/* Otherwise, check for common options */
|
||||
|
||||
nargs = common_args(i2ctool, &argv[argndx]);
|
||||
nargs = i2ctool_common_args(i2ctool, &argv[argndx]);
|
||||
if (nargs < 0)
|
||||
{
|
||||
return ERROR;
|
||||
|
@ -81,7 +81,7 @@ int i2ccmd_verf(FAR struct i2ctool_s *i2ctool, int argc, FAR char **argv)
|
||||
|
||||
/* Otherwise, check for common options */
|
||||
|
||||
nargs = common_args(i2ctool, &argv[argndx]);
|
||||
nargs = i2ctool_common_args(i2ctool, &argv[argndx]);
|
||||
if (nargs < 0)
|
||||
{
|
||||
return ERROR;
|
||||
|
@ -199,10 +199,7 @@ int i2ctool_set(FAR struct i2ctool_s *i2ctool, int fd, uint8_t regaddr,
|
||||
|
||||
/* Common logic */
|
||||
|
||||
int common_args(FAR struct i2ctool_s *i2ctool, FAR char **arg);
|
||||
int arg_string(FAR char **arg, FAR char **value);
|
||||
int arg_decimal(FAR char **arg, FAR long *value);
|
||||
int arg_hex(FAR char **arg, FAR long *value);
|
||||
int i2ctool_common_args(FAR struct i2ctool_s *i2ctool, FAR char **arg);
|
||||
|
||||
/* Driver access utilities */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user