Rename IPv4 netlib functions and files to make room in the namespace for corresponding IPv6 functions and files

This commit is contained in:
Gregory Nutt 2015-01-18 14:17:00 -06:00
parent 4eceae4e32
commit 953c0fb069
26 changed files with 134 additions and 115 deletions

View File

@ -118,17 +118,17 @@ printf("NET1: Configuring %s\n", CONFIG_EXAMPLES_BRIDGE_NET1_IFNAME);
#else
addr.s_addr = HTONL(CONFIG_EXAMPLES_BRIDGE_NET1_IPADDR);
#endif
netlib_sethostaddr(CONFIG_EXAMPLES_BRIDGE_NET1_IFNAME, &addr);
netlib_set_ipv4addr(CONFIG_EXAMPLES_BRIDGE_NET1_IFNAME, &addr);
/* Set up the default router address */
addr.s_addr = HTONL(CONFIG_EXAMPLES_BRIDGE_NET1_DRIPADDR);
netlib_setdraddr(CONFIG_EXAMPLES_BRIDGE_NET1_IFNAME, &addr);
netlib_set_dripv4addr(CONFIG_EXAMPLES_BRIDGE_NET1_IFNAME, &addr);
/* Setup the subnet mask */
addr.s_addr = HTONL(CONFIG_EXAMPLES_BRIDGE_NET1_NETMASK);
netlib_setnetmask(CONFIG_EXAMPLES_BRIDGE_NET1_IFNAME, &addr);
netlib_set_ipv4netmask(CONFIG_EXAMPLES_BRIDGE_NET1_IFNAME, &addr);
#ifdef CONFIG_EXAMPLES_BRIDGE_NET1_DHCPC
/* Set up the resolver */
@ -159,16 +159,16 @@ printf("NET1: Configuring %s\n", CONFIG_EXAMPLES_BRIDGE_NET1_IFNAME);
return ERROR;
}
netlib_sethostaddr(CONFIG_EXAMPLES_BRIDGE_NET1_IFNAME, &ds.ipaddr);
netlib_set_ipv4addr(CONFIG_EXAMPLES_BRIDGE_NET1_IFNAME, &ds.ipaddr);
if (ds.netmask.s_addr != 0)
{
netlib_setnetmask(CONFIG_EXAMPLES_BRIDGE_NET1_IFNAME, &ds.netmask);
netlib_set_ipv4netmask(CONFIG_EXAMPLES_BRIDGE_NET1_IFNAME, &ds.netmask);
}
if (ds.default_router.s_addr != 0)
{
netlib_setdraddr(CONFIG_EXAMPLES_BRIDGE_NET1_IFNAME, &ds.default_router);
netlib_set_dripv4addr(CONFIG_EXAMPLES_BRIDGE_NET1_IFNAME, &ds.default_router);
}
if (ds.dnsaddr.s_addr != 0)
@ -243,17 +243,17 @@ printf("NET2: Configuring %s\n", CONFIG_EXAMPLES_BRIDGE_NET2_IFNAME);
#else
addr.s_addr = HTONL(CONFIG_EXAMPLES_BRIDGE_NET2_IPADDR);
#endif
netlib_sethostaddr(CONFIG_EXAMPLES_BRIDGE_NET2_IFNAME, &addr);
netlib_set_ipv4addr(CONFIG_EXAMPLES_BRIDGE_NET2_IFNAME, &addr);
/* Set up the default router address */
addr.s_addr = HTONL(CONFIG_EXAMPLES_BRIDGE_NET2_DRIPADDR);
netlib_setdraddr(CONFIG_EXAMPLES_BRIDGE_NET2_IFNAME, &addr);
netlib_set_dripv4addr(CONFIG_EXAMPLES_BRIDGE_NET2_IFNAME, &addr);
/* Setup the subnet mask */
addr.s_addr = HTONL(CONFIG_EXAMPLES_BRIDGE_NET2_NETMASK);
netlib_setnetmask(CONFIG_EXAMPLES_BRIDGE_NET2_IFNAME, &addr);
netlib_set_ipv4netmask(CONFIG_EXAMPLES_BRIDGE_NET2_IFNAME, &addr);
#ifdef CONFIG_EXAMPLES_BRIDGE_NET2_DHCPC
/* Set up the resolver */
@ -284,16 +284,16 @@ printf("NET2: Configuring %s\n", CONFIG_EXAMPLES_BRIDGE_NET2_IFNAME);
return ERROR;
}
netlib_sethostaddr(CONFIG_EXAMPLES_BRIDGE_NET2_IFNAME, &ds.ipaddr);
netlib_set_ipv4addr(CONFIG_EXAMPLES_BRIDGE_NET2_IFNAME, &ds.ipaddr);
if (ds.netmask.s_addr != 0)
{
netlib_setnetmask(CONFIG_EXAMPLES_BRIDGE_NET2_IFNAME, &ds.netmask);
netlib_set_ipv4netmask(CONFIG_EXAMPLES_BRIDGE_NET2_IFNAME, &ds.netmask);
}
if (ds.default_router.s_addr != 0)
{
netlib_setdraddr(CONFIG_EXAMPLES_BRIDGE_NET2_IFNAME, &ds.default_router);
netlib_set_dripv4addr(CONFIG_EXAMPLES_BRIDGE_NET2_IFNAME, &ds.default_router);
}
if (ds.dnsaddr.s_addr != 0)

View File

@ -115,17 +115,17 @@ int dhcpd_main(int argc, char *argv[])
/* Set up our host address */
addr.s_addr = HTONL(CONFIG_EXAMPLES_DHCPD_IPADDR);
netlib_sethostaddr("eth0", &addr);
netlib_set_ipv4addr("eth0", &addr);
/* Set up the default router address */
addr.s_addr = HTONL(CONFIG_EXAMPLES_DHCPD_DRIPADDR);
netlib_setdraddr("eth0", &addr);
netlib_set_dripv4addr("eth0", &addr);
/* Setup the subnet mask */
addr.s_addr = HTONL(CONFIG_EXAMPLES_DHCPD_NETMASK);
netlib_setnetmask("eth0", &addr);
netlib_set_ipv4netmask("eth0", &addr);
/* Then start the server */

View File

@ -123,17 +123,17 @@ int discover_main(int argc, char *argv[])
#else
addr.s_addr = HTONL(CONFIG_EXAMPLES_DISCOVER_IPADDR);
#endif
netlib_sethostaddr("eth0", &addr);
netlib_set_ipv4addr("eth0", &addr);
/* Set up the default router address */
addr.s_addr = HTONL(CONFIG_EXAMPLES_DISCOVER_DRIPADDR);
netlib_setdraddr("eth0", &addr);
netlib_set_dripv4addr("eth0", &addr);
/* Setup the subnet mask */
addr.s_addr = HTONL(CONFIG_EXAMPLES_DISCOVER_NETMASK);
netlib_setnetmask("eth0", &addr);
netlib_set_ipv4netmask("eth0", &addr);
#ifdef CONFIG_EXAMPLES_DISCOVER_DHCPC
/* Set up the resolver */
@ -157,16 +157,16 @@ int discover_main(int argc, char *argv[])
{
struct dhcpc_state ds;
(void)dhcpc_request(handle, &ds);
netlib_sethostaddr("eth0", &ds.ipaddr);
netlib_set_ipv4addr("eth0", &ds.ipaddr);
if (ds.netmask.s_addr != 0)
{
netlib_setnetmask("eth0", &ds.netmask);
netlib_set_ipv4netmask("eth0", &ds.netmask);
}
if (ds.default_router.s_addr != 0)
{
netlib_setdraddr("eth0", &ds.default_router);
netlib_set_dripv4addr("eth0", &ds.default_router);
}
if (ds.dnsaddr.s_addr != 0)

View File

@ -103,17 +103,17 @@ static void fptd_netinit(void)
/* Set up our host address */
addr.s_addr = HTONL(CONFIG_EXAMPLES_FTPD_IPADDR);
netlib_sethostaddr("eth0", &addr);
netlib_set_ipv4addr("eth0", &addr);
/* Set up the default router address */
addr.s_addr = HTONL(CONFIG_EXAMPLES_FTPD_DRIPADDR);
netlib_setdraddr("eth0", &addr);
netlib_set_dripv4addr("eth0", &addr);
/* Setup the subnet mask */
addr.s_addr = HTONL(CONFIG_EXAMPLES_FTPD_NETMASK);
netlib_setnetmask("eth0", &addr);
netlib_set_ipv4netmask("eth0", &addr);
#endif /* CONFIG_EXAMPLES_FTPD_NONETINIT */
}

View File

@ -111,17 +111,17 @@ int igmp_main(int argc, char *argv[])
/* Set up our host address */
addr.s_addr = HTONL(CONFIG_EXAMPLES_IGMP_IPADDR);
netlib_sethostaddr("eth0", &addr);
netlib_set_ipv4addr("eth0", &addr);
/* Set up the default router address */
addr.s_addr = HTONL(CONFIG_EXAMPLES_IGMP_DRIPADDR);
netlib_setdraddr("eth0", &addr);
netlib_set_dripv4addr("eth0", &addr);
/* Setup the subnet mask */
addr.s_addr = HTONL(CONFIG_EXAMPLES_IGMP_NETMASK);
netlib_setnetmask("eth0", &addr);
netlib_set_ipv4netmask("eth0", &addr);
/* Not much of a test for now */
/* Join the group */

View File

@ -93,17 +93,17 @@ int nettest_main(int argc, char *argv[])
/* Set up our host address */
addr.s_addr = HTONL(CONFIG_EXAMPLES_NETTEST_IPADDR);
netlib_sethostaddr("eth0", &addr);
netlib_set_ipv4addr("eth0", &addr);
/* Set up the default router address */
addr.s_addr = HTONL(CONFIG_EXAMPLES_NETTEST_DRIPADDR);
netlib_setdraddr("eth0", &addr);
netlib_set_dripv4addr("eth0", &addr);
/* Setup the subnet mask */
addr.s_addr = HTONL(CONFIG_EXAMPLES_NETTEST_NETMASK);
netlib_setnetmask("eth0", &addr);
netlib_set_ipv4netmask("eth0", &addr);
#ifdef CONFIG_EXAMPLES_NETTEST_SERVER
recv_server();

View File

@ -312,17 +312,17 @@ static void net_configure(void)
/* Set up our host address */
addr.s_addr = HTONL(CONFIG_EXAMPLES_POLL_IPADDR);
netlib_sethostaddr("eth0", &addr);
netlib_set_ipv4addr("eth0", &addr);
/* Set up the default router address */
addr.s_addr = HTONL(CONFIG_EXAMPLES_POLL_DRIPADDR);
netlib_setdraddr("eth0", &addr);
netlib_set_dripv4addr("eth0", &addr);
/* Setup the subnet mask */
addr.s_addr = HTONL(CONFIG_EXAMPLES_POLL_NETMASK);
netlib_setnetmask("eth0", &addr);
netlib_set_ipv4netmask("eth0", &addr);
}
/****************************************************************************

View File

@ -106,17 +106,17 @@ static void net_configure(void)
/* Set up our host address */
addr.s_addr = HTONL(CONFIG_EXAMPLES_POLL_IPADDR);
netlib_sethostaddr("eth0", &addr);
netlib_set_ipv4addr("eth0", &addr);
/* Set up the default router address */
addr.s_addr = HTONL(CONFIG_EXAMPLES_POLL_DRIPADDR);
netlib_setdraddr("eth0", &addr);
netlib_set_dripv4addr("eth0", &addr);
/* Setup the subnet mask */
addr.s_addr = HTONL(CONFIG_EXAMPLES_POLL_NETMASK);
netlib_setnetmask("eth0", &addr);
netlib_set_ipv4netmask("eth0", &addr);
}
/****************************************************************************

View File

@ -138,17 +138,17 @@ int sendmail_main(int argc, char *argv[])
/* Set up our host address */
addr.s_addr = HTONL(CONFIG_EXAMPLES_SENDMAIL_IPADDR);
netlib_sethostaddr("eth0", &addr);
netlib_set_ipv4addr("eth0", &addr);
/* Set up the default router address */
addr.s_addr = HTONL(CONFIG_EXAMPLES_SENDMAIL_DRIPADDR);
netlib_setdraddr("eth0", &addr);
netlib_set_dripv4addr("eth0", &addr);
/* Setup the subnet mask */
addr.s_addr = HTONL(CONFIG_EXAMPLES_SENDMAIL_NETMASK);
netlib_setnetmask("eth0", &addr);
netlib_set_ipv4netmask("eth0", &addr);
/* Then send the mail */

View File

@ -131,17 +131,17 @@ static int tcpecho_netsetup()
#else
addr.s_addr = HTONL(CONFIG_EXAMPLES_TCPECHO_IPADDR);
#endif
netlib_sethostaddr("eth0", &addr);
netlib_set_ipv4addr("eth0", &addr);
/* Set up the default router address */
addr.s_addr = HTONL(CONFIG_EXAMPLES_TCPECHO_DRIPADDR);
netlib_setdraddr("eth0", &addr);
netlib_set_dripv4addr("eth0", &addr);
/* Setup the subnet mask */
addr.s_addr = HTONL(CONFIG_EXAMPLES_TCPECHO_NETMASK);
netlib_setnetmask("eth0", &addr);
netlib_set_ipv4netmask("eth0", &addr);
#ifdef CONFIG_EXAMPLES_TCPECHO_DHCPC
/* Set up the resolver */
@ -170,16 +170,16 @@ static int tcpecho_netsetup()
return ERROR;
}
netlib_sethostaddr("eth0", &ds.ipaddr);
netlib_set_ipv4addr("eth0", &ds.ipaddr);
if (ds.netmask.s_addr != 0)
{
netlib_setnetmask("eth0", &ds.netmask);
netlib_set_ipv4netmask("eth0", &ds.netmask);
}
if (ds.default_router.s_addr != 0)
{
netlib_setdraddr("eth0", &ds.default_router);
netlib_set_dripv4addr("eth0", &ds.default_router);
}
if (ds.dnsaddr.s_addr != 0)

View File

@ -207,17 +207,17 @@ static void telnetd_netinit(void)
/* Set up our host address */
addr.s_addr = HTONL(CONFIG_EXAMPLES_TELNETD_IPADDR);
netlib_sethostaddr("eth0", &addr);
netlib_set_ipv4addr("eth0", &addr);
/* Set up the default router address */
addr.s_addr = HTONL(CONFIG_EXAMPLES_TELNETD_DRIPADDR);
netlib_setdraddr("eth0", &addr);
netlib_set_dripv4addr("eth0", &addr);
/* Setup the subnet mask */
addr.s_addr = HTONL(CONFIG_EXAMPLES_TELNETD_NETMASK);
netlib_setnetmask("eth0", &addr);
netlib_set_ipv4netmask("eth0", &addr);
}
/****************************************************************************

View File

@ -204,17 +204,17 @@ int thttp_main(int argc, char *argv[])
printf("Setup network addresses\n");
addr.s_addr = HTONL(CONFIG_THTTPD_IPADDR);
netlib_sethostaddr(NET_DEVNAME, &addr);
netlib_set_ipv4addr(NET_DEVNAME, &addr);
/* Set up the default router address */
addr.s_addr = HTONL(CONFIG_EXAMPLES_THTTPD_DRIPADDR);
netlib_setdraddr(NET_DEVNAME, &addr);
netlib_set_dripv4addr(NET_DEVNAME, &addr);
/* Setup the subnet mask */
addr.s_addr = HTONL(CONFIG_EXAMPLES_THTTPD_NETMASK);
netlib_setnetmask(NET_DEVNAME, &addr);
netlib_set_ipv4netmask(NET_DEVNAME, &addr);
/* Initialize the NXFLAT binary loader */

View File

@ -75,17 +75,17 @@ int udp_main(int argc, char *argv[])
/* Set up our host address */
addr.s_addr = HTONL(CONFIG_EXAMPLES_UDP_IPADDR);
netlib_sethostaddr("eth0", &addr);
netlib_set_ipv4addr("eth0", &addr);
/* Set up the default router address */
addr.s_addr = HTONL(CONFIG_EXAMPLES_UDP_DRIPADDR);
netlib_setdraddr("eth0", &addr);
netlib_set_dripv4addr("eth0", &addr);
/* Setup the subnet mask */
addr.s_addr = HTONL(CONFIG_EXAMPLES_UDP_NETMASK);
netlib_setnetmask("eth0", &addr);
netlib_set_ipv4netmask("eth0", &addr);
#ifdef CONFIG_EXAMPLES_UDP_SERVER
recv_server();

View File

@ -129,17 +129,17 @@ int webserver_main(int argc, char *argv[])
#else
addr.s_addr = HTONL(CONFIG_EXAMPLES_WEBSERVER_IPADDR);
#endif
netlib_sethostaddr("eth0", &addr);
netlib_set_ipv4addr("eth0", &addr);
/* Set up the default router address */
addr.s_addr = HTONL(CONFIG_EXAMPLES_WEBSERVER_DRIPADDR);
netlib_setdraddr("eth0", &addr);
netlib_set_dripv4addr("eth0", &addr);
/* Setup the subnet mask */
addr.s_addr = HTONL(CONFIG_EXAMPLES_WEBSERVER_NETMASK);
netlib_setnetmask("eth0", &addr);
netlib_set_ipv4netmask("eth0", &addr);
#ifdef CONFIG_EXAMPLES_WEBSERVER_DHCPC
/* Set up the resolver */
@ -163,16 +163,16 @@ int webserver_main(int argc, char *argv[])
{
struct dhcpc_state ds;
(void)dhcpc_request(handle, &ds);
netlib_sethostaddr("eth0", &ds.ipaddr);
netlib_set_ipv4addr("eth0", &ds.ipaddr);
if (ds.netmask.s_addr != 0)
{
netlib_setnetmask("eth0", &ds.netmask);
netlib_set_ipv4netmask("eth0", &ds.netmask);
}
if (ds.default_router.s_addr != 0)
{
netlib_setdraddr("eth0", &ds.default_router);
netlib_set_dripv4addr("eth0", &ds.default_router);
}
if (ds.dnsaddr.s_addr != 0)

View File

@ -133,17 +133,17 @@ int wget_main(int argc, char *argv[])
/* Set up our host address */
addr.s_addr = HTONL(CONFIG_EXAMPLES_WGET_IPADDR);
netlib_sethostaddr("eth0", &addr);
netlib_set_ipv4addr("eth0", &addr);
/* Set up the default router address */
addr.s_addr = HTONL(CONFIG_EXAMPLES_WGET_DRIPADDR);
netlib_setdraddr("eth0", &addr);
netlib_set_dripv4addr("eth0", &addr);
/* Setup the subnet mask */
addr.s_addr = HTONL(CONFIG_EXAMPLES_WGET_NETMASK);
netlib_setnetmask("eth0", &addr);
netlib_set_ipv4netmask("eth0", &addr);
/* Then start the server */

View File

@ -296,17 +296,17 @@ static int xmlrpc_netinit(void)
#else
addr.s_addr = HTONL(CONFIG_EXAMPLES_XMLRPC_IPADDR);
#endif
netlib_sethostaddr("eth0", &addr);
netlib_set_ipv4addr("eth0", &addr);
/* Set up the default router address */
addr.s_addr = HTONL(CONFIG_EXAMPLES_XMLRPC_DRIPADDR);
netlib_setdraddr("eth0", &addr);
netlib_set_dripv4addr("eth0", &addr);
/* Setup the subnet mask */
addr.s_addr = HTONL(CONFIG_EXAMPLES_XMLRPC_NETMASK);
netlib_setnetmask("eth0", &addr);
netlib_set_ipv4netmask("eth0", &addr);
#ifdef CONFIG_EXAMPLES_XMLRPC_DHCPC
/* Set up the resolver */
@ -331,16 +331,16 @@ static int xmlrpc_netinit(void)
{
struct dhcpc_state ds;
(void)dhcpc_request(handle, &ds);
netlib_sethostaddr("eth0", &ds.ipaddr);
netlib_set_ipv4addr("eth0", &ds.ipaddr);
if (ds.netmask.s_addr != 0)
{
netlib_setnetmask("eth0", &ds.netmask);
netlib_set_ipv4netmask("eth0", &ds.netmask);
}
if (ds.default_router.s_addr != 0)
{
netlib_setdraddr("eth0", &ds.default_router);
netlib_set_dripv4addr("eth0", &ds.default_router);
}
if (ds.dnsaddr.s_addr != 0)

View File

@ -112,16 +112,18 @@ int netlib_getmacaddr(FAR const char *ifname, uint8_t *macaddr);
/* IP address support */
#ifdef CONFIG_NET_IPv4
int netlib_get_ipv4addr(FAR const char *ifname, FAR struct in_addr *addr);
int netlib_set_ipv4addr(FAR const char *ifname, FAR const struct in_addr *addr);
int netlib_set_dripv4addr(FAR const char *ifname, FAR const struct in_addr *addr);
int netlib_set_ipv4netmask(FAR const char *ifname, FAR const struct in_addr *addr);
#endif
#ifdef CONFIG_NET_IPv6
int netlib_gethostaddr(FAR const char *ifname, struct in6_addr *addr);
int netlib_sethostaddr(FAR const char *ifname, const struct in6_addr *addr);
int netlib_setdraddr(FAR const char *ifname, const struct in6_addr *addr);
int netlib_setnetmask(FAR const char *ifname, const struct in6_addr *addr);
#else
int netlib_gethostaddr(FAR const char *ifname, struct in_addr *addr);
int netlib_sethostaddr(FAR const char *ifname, const struct in_addr *addr);
int netlib_setdraddr(FAR const char *ifname, const struct in_addr *addr);
int netlib_setnetmask(FAR const char *ifname, const struct in_addr *addr);
int netlib_get_ipv6addr(FAR const char *ifname, FAR struct in6_addr *addr);
int netlib_set_ipv6addr(FAR const char *ifname, FAR const struct in6_addr *addr);
int netlib_set_dripv6addr(FAR const char *ifname, FAR const struct in6_addr *addr);
int netlib_set_ipv6netmask(FAR const char *ifname, FAR const struct in6_addr *addr);
#endif
/* HTTP support */

View File

@ -447,7 +447,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_gethostaddr("eth0", &oldaddr);
netlib_get_ipv4addr("eth0", &oldaddr);
/* Loop until we receive the lease (or an error occurs) */
@ -456,7 +456,7 @@ int dhcpc_request(void *handle, struct dhcpc_state *presult)
/* Set the IP address to INADDR_ANY. */
newaddr.s_addr = INADDR_ANY;
(void)netlib_sethostaddr("eth0", &newaddr);
(void)netlib_set_ipv4addr("eth0", &newaddr);
/* Loop sending DISCOVER until we receive an OFFER from a DHCP
* server. We will lock on to the first OFFER and decline any
@ -495,7 +495,7 @@ int dhcpc_request(void *handle, struct dhcpc_state *presult)
* out of the loop.
*/
(void)netlib_sethostaddr("eth0", &presult->ipaddr);
(void)netlib_set_ipv4addr("eth0", &presult->ipaddr);
state = STATE_HAVE_OFFER;
}
}
@ -587,7 +587,7 @@ int dhcpc_request(void *handle, struct dhcpc_state *presult)
{
/* An error other than a timeout was received */
(void)netlib_sethostaddr("eth0", &oldaddr);
(void)netlib_set_ipv4addr("eth0", &oldaddr);
return ERROR;
}
}

View File

@ -1,7 +1,7 @@
############################################################################
# apps/netutils/netlib/Makefile
#
# Copyright (C) 2011-2012, 2014 Gregory Nutt. All rights reserved.
# Copyright (C) 2011-2012, 2014-2015 Gregory Nutt. All rights reserved.
# Author: Gregory Nutt <gnutt@nuttx.org>
#
# Redistribution and use in source and binary forms, with or without
@ -40,10 +40,21 @@ include $(APPDIR)/Make.defs
# UIP Library
ASRCS =
CSRCS = netlib.c netlib_sethostaddr.c netlib_gethostaddr.c
CSRCS += netlib_setdraddr.c netlib_setnetmask.c netlib_parsehttpurl.c
CSRCS = netlib.c netlib_parsehttpurl.c
CSRCS += netlib_setifstatus.c netlib_getifstatus.c
# IP address support
ifeq ($(CONFIG_NET_IPv4),y)
CSRCS += netlib_setipv4addr.c netlib_getipv4addr.c
CSRCS += netlib_setdripv4addr.c netlib_setipv4netmask.c
endif
ifeq ($(CONFIG_NET_IPv6),y)
CSRCS += netlib_setipv6addr.c netlib_getipv6addr.c
CSRCS += netlib_setdripv6addr.c netlib_setipv6netmask.c
endif
# These require TCP support
ifeq ($(CONFIG_NET_TCP),y)

View File

@ -1,5 +1,5 @@
/****************************************************************************
* netutils/netlib/netlib_getifflag.c
* netutils/netlib/netlib_getifstatus.c
*
* Copyright (C) 2007-2009, 2011, 2014 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>

View File

@ -1,5 +1,5 @@
/****************************************************************************
* netutils/netlib/netlib_gethostaddr.c
* netutils/netlib/netlib_getipv4addr.c
*
* Copyright (C) 2007-2009, 2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
@ -61,7 +61,7 @@
****************************************************************************/
/****************************************************************************
* Name: netlib_gethostaddr
* Name: netlib_get_ipv4addr
*
* Description:
* Get the network driver IP address
@ -76,9 +76,9 @@
****************************************************************************/
#ifdef CONFIG_NET_IPv6
int netlib_gethostaddr(const char *ifname, struct in6_addr *addr)
int netlib_get_ipv4addr(const char *ifname, struct in6_addr *addr)
#else
int netlib_gethostaddr(const char *ifname, struct in_addr *addr)
int netlib_get_ipv4addr(const char *ifname, struct in_addr *addr)
#endif
{
int ret = ERROR;

View File

@ -1,5 +1,5 @@
/****************************************************************************
* netutils/netlib/netlib_setdraddr.c
* netutils/netlib/netlib_setdripv4addr.c
*
* Copyright (C) 2007-2009, 2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
@ -57,7 +57,7 @@
****************************************************************************/
/****************************************************************************
* Name: netlib_setdraddr
* Name: netlib_set_dripv4addr
*
* Description:
* Set the default router IP address
@ -72,9 +72,9 @@
****************************************************************************/
#ifdef CONFIG_NET_IPv6
int netlib_setdraddr(const char *ifname, const struct in6_addr *addr)
int netlib_set_dripv4addr(const char *ifname, const struct in6_addr *addr)
#else
int netlib_setdraddr(const char *ifname, const struct in_addr *addr)
int netlib_set_dripv4addr(const char *ifname, const struct in_addr *addr)
#endif
{
int ret = ERROR;

View File

@ -1,5 +1,5 @@
/****************************************************************************
* netutils/netlib/netlib_sethostaddr.c
* netutils/netlib/netlib_setipv4addr.c
*
* Copyright (C) 2007-2009, 2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
@ -57,7 +57,7 @@
****************************************************************************/
/****************************************************************************
* Name: netlib_sethostaddr
* Name: netlib_set_ipv4addr
*
* Description:
* Set the network driver IP address
@ -72,9 +72,9 @@
****************************************************************************/
#ifdef CONFIG_NET_IPv6
int netlib_sethostaddr(const char *ifname, const struct in6_addr *addr)
int netlib_set_ipv4addr(const char *ifname, const struct in6_addr *addr)
#else
int netlib_sethostaddr(const char *ifname, const struct in_addr *addr)
int netlib_set_ipv4addr(const char *ifname, const struct in_addr *addr)
#endif
{
int ret = ERROR;

View File

@ -1,5 +1,5 @@
/****************************************************************************
* netutils/netlib/netlib_setnetmask.c
* netutils/netlib/netlib_setipv4netmask.c
*
* Copyright (C) 2007-2009, 2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
@ -56,7 +56,7 @@
****************************************************************************/
/****************************************************************************
* Name: netlib_setnetmask
* Name: netlib_set_ipv4netmask
*
* Description:
* Set the netmask
@ -71,9 +71,9 @@
****************************************************************************/
#ifdef CONFIG_NET_IPv6
int netlib_setnetmask(const char *ifname, const struct in6_addr *addr)
int netlib_set_ipv4netmask(const char *ifname, const struct in6_addr *addr)
#else
int netlib_setnetmask(const char *ifname, const struct in_addr *addr)
int netlib_set_ipv4netmask(const char *ifname, const struct in_addr *addr)
#endif
{
int ret = ERROR;

View File

@ -732,7 +732,7 @@ int cmd_ifconfig(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
gip = addr.s_addr = inet_addr(hostip);
}
netlib_sethostaddr(intf, &addr);
netlib_set_ipv4addr(intf, &addr);
/* Set gateway */
@ -755,7 +755,7 @@ int cmd_ifconfig(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
addr.s_addr = gip;
}
netlib_setdraddr(intf, &addr);
netlib_set_dripv4addr(intf, &addr);
/* Set network mask */
@ -770,7 +770,7 @@ int cmd_ifconfig(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
addr.s_addr = inet_addr("255.255.255.0");
}
netlib_setnetmask(intf, &addr);
netlib_set_ipv4netmask(intf, &addr);
#if defined(CONFIG_NSH_DHCPC) || defined(CONFIG_NSH_DNS)
if (dns)
@ -808,16 +808,16 @@ int cmd_ifconfig(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
struct dhcpc_state ds;
(void)dhcpc_request(handle, &ds);
netlib_sethostaddr("eth0", &ds.ipaddr);
netlib_set_ipv4addr("eth0", &ds.ipaddr);
if (ds.netmask.s_addr != 0)
{
netlib_setnetmask("eth0", &ds.netmask);
netlib_set_ipv4netmask("eth0", &ds.netmask);
}
if (ds.default_router.s_addr != 0)
{
netlib_setdraddr("eth0", &ds.default_router);
netlib_set_dripv4addr("eth0", &ds.default_router);
}
if (ds.dnsaddr.s_addr != 0)

View File

@ -1,7 +1,7 @@
/****************************************************************************
* apps/nshlib/nsh_netinit.c
*
* Copyright (C) 2010-2012, 2014 Gregory Nutt. All rights reserved.
* Copyright (C) 2010-2012, 2014-2015 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* This is influenced by similar logic from uIP:
@ -184,6 +184,7 @@ static void nsh_netinit_configure(void)
netlib_setmacaddr(NET_DEVNAME, mac);
#endif
#ifdef CONFIG_NET_IPv4
/* Set up our host address */
#if !defined(CONFIG_NSH_DHCPC)
@ -191,17 +192,22 @@ static void nsh_netinit_configure(void)
#else
addr.s_addr = 0;
#endif
netlib_sethostaddr(NET_DEVNAME, &addr);
netlib_set_ipv4addr(NET_DEVNAME, &addr);
/* Set up the default router address */
addr.s_addr = HTONL(CONFIG_NSH_DRIPADDR);
netlib_setdraddr(NET_DEVNAME, &addr);
netlib_set_dripv4addr(NET_DEVNAME, &addr);
/* Setup the subnet mask */
addr.s_addr = HTONL(CONFIG_NSH_NETMASK);
netlib_setnetmask(NET_DEVNAME, &addr);
netlib_set_ipv4netmask(NET_DEVNAME, &addr);
#endif
#ifdef CONFIG_NET_IPv6
# warning Missing logic
#endif
#if defined(CONFIG_NSH_DHCPC) || defined(CONFIG_NSH_DNS)
/* Set up the resolver */
@ -230,16 +236,16 @@ static void nsh_netinit_configure(void)
{
struct dhcpc_state ds;
(void)dhcpc_request(handle, &ds);
netlib_sethostaddr(NET_DEVNAME, &ds.ipaddr);
netlib_set_ipv4addr(NET_DEVNAME, &ds.ipaddr);
if (ds.netmask.s_addr != 0)
{
netlib_setnetmask(NET_DEVNAME, &ds.netmask);
netlib_set_ipv4netmask(NET_DEVNAME, &ds.netmask);
}
if (ds.default_router.s_addr != 0)
{
netlib_setdraddr(NET_DEVNAME, &ds.default_router);
netlib_set_dripv4addr(NET_DEVNAME, &ds.default_router);
}
if (ds.dnsaddr.s_addr != 0)