diff options
26 files changed, 134 insertions, 115 deletions
diff --git a/apps/examples/bridge/bridge_main.c b/apps/examples/bridge/bridge_main.c index f296db8999..c7b48ace63 100644 --- a/apps/examples/bridge/bridge_main.c +++ b/apps/examples/bridge/bridge_main.c @@ -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) diff --git a/apps/examples/dhcpd/target.c b/apps/examples/dhcpd/target.c index b34ec9b698..ca3228e50b 100644 --- a/apps/examples/dhcpd/target.c +++ b/apps/examples/dhcpd/target.c @@ -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 */ diff --git a/apps/examples/discover/discover_main.c b/apps/examples/discover/discover_main.c index d79cf8542c..534fccf782 100644 --- a/apps/examples/discover/discover_main.c +++ b/apps/examples/discover/discover_main.c @@ -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) diff --git a/apps/examples/ftpd/ftpd_main.c b/apps/examples/ftpd/ftpd_main.c index d53456e52a..009a691af5 100644 --- a/apps/examples/ftpd/ftpd_main.c +++ b/apps/examples/ftpd/ftpd_main.c @@ -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 */ } diff --git a/apps/examples/igmp/igmp.c b/apps/examples/igmp/igmp.c index 32879f046b..26b82478c2 100644 --- a/apps/examples/igmp/igmp.c +++ b/apps/examples/igmp/igmp.c @@ -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 */ diff --git a/apps/examples/nettest/nettest.c b/apps/examples/nettest/nettest.c index 0c890e5ced..00642faaca 100644 --- a/apps/examples/nettest/nettest.c +++ b/apps/examples/nettest/nettest.c @@ -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(); diff --git a/apps/examples/poll/net_listener.c b/apps/examples/poll/net_listener.c index 996e63c3bc..ce068585a3 100644 --- a/apps/examples/poll/net_listener.c +++ b/apps/examples/poll/net_listener.c @@ -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); } /**************************************************************************** diff --git a/apps/examples/poll/net_reader.c b/apps/examples/poll/net_reader.c index d50181bf75..8597acdab5 100644 --- a/apps/examples/poll/net_reader.c +++ b/apps/examples/poll/net_reader.c @@ -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); } /**************************************************************************** diff --git a/apps/examples/sendmail/target.c b/apps/examples/sendmail/target.c index 0dadf75b22..981f2b2632 100644 --- a/apps/examples/sendmail/target.c +++ b/apps/examples/sendmail/target.c @@ -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 */ diff --git a/apps/examples/tcpecho/tcpecho_main.c b/apps/examples/tcpecho/tcpecho_main.c index 34ca3c0638..62dae4963b 100644 --- a/apps/examples/tcpecho/tcpecho_main.c +++ b/apps/examples/tcpecho/tcpecho_main.c @@ -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) diff --git a/apps/examples/telnetd/telnetd.c b/apps/examples/telnetd/telnetd.c index acba8238a9..19ad354138 100644 --- a/apps/examples/telnetd/telnetd.c +++ b/apps/examples/telnetd/telnetd.c @@ -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); } /**************************************************************************** diff --git a/apps/examples/thttpd/thttpd_main.c b/apps/examples/thttpd/thttpd_main.c index 89677f8556..3e9662ae7b 100644 --- a/apps/examples/thttpd/thttpd_main.c +++ b/apps/examples/thttpd/thttpd_main.c @@ -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 */ diff --git a/apps/examples/udp/target.c b/apps/examples/udp/target.c index 72ca05d177..8b72978f3b 100644 --- a/apps/examples/udp/target.c +++ b/apps/examples/udp/target.c @@ -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(); diff --git a/apps/examples/webserver/webserver_main.c b/apps/examples/webserver/webserver_main.c index f9c029325f..a56bc08b3a 100644 --- a/apps/examples/webserver/webserver_main.c +++ b/apps/examples/webserver/webserver_main.c @@ -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) diff --git a/apps/examples/wget/target.c b/apps/examples/wget/target.c index 9b9cfc8137..a80a110fe0 100644 --- a/apps/examples/wget/target.c +++ b/apps/examples/wget/target.c @@ -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 */ diff --git a/apps/examples/xmlrpc/xmlrpc_main.c b/apps/examples/xmlrpc/xmlrpc_main.c index a93c89fc70..c31e2a61b6 100644 --- a/apps/examples/xmlrpc/xmlrpc_main.c +++ b/apps/examples/xmlrpc/xmlrpc_main.c @@ -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) diff --git a/apps/include/netutils/netlib.h b/apps/include/netutils/netlib.h index fbff2af1e7..882de51f5d 100644 --- a/apps/include/netutils/netlib.h +++ b/apps/include/netutils/netlib.h @@ -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 */ diff --git a/apps/netutils/dhcpc/dhcpc.c b/apps/netutils/dhcpc/dhcpc.c index 1b75cde9b0..b6e0c6b14a 100644 --- a/apps/netutils/dhcpc/dhcpc.c +++ b/apps/netutils/dhcpc/dhcpc.c @@ -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; } } diff --git a/apps/netutils/netlib/Makefile b/apps/netutils/netlib/Makefile index 9710702baa..aff9c5bcd7 100644 --- a/apps/netutils/netlib/Makefile +++ b/apps/netutils/netlib/Makefile @@ -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) diff --git a/apps/netutils/netlib/netlib_getifstatus.c b/apps/netutils/netlib/netlib_getifstatus.c index ae0c760fc7..8521b781b0 100644 --- a/apps/netutils/netlib/netlib_getifstatus.c +++ b/apps/netutils/netlib/netlib_getifstatus.c @@ -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> diff --git a/apps/netutils/netlib/netlib_gethostaddr.c b/apps/netutils/netlib/netlib_getipv4addr.c index 8d9e848183..bfdad5d989 100644 --- a/apps/netutils/netlib/netlib_gethostaddr.c +++ b/apps/netutils/netlib/netlib_getipv4addr.c @@ -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; diff --git a/apps/netutils/netlib/netlib_setdraddr.c b/apps/netutils/netlib/netlib_setdripv4addr.c index 19b636ce5d..b6b54f6db0 100644 --- a/apps/netutils/netlib/netlib_setdraddr.c +++ b/apps/netutils/netlib/netlib_setdripv4addr.c @@ -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; diff --git a/apps/netutils/netlib/netlib_sethostaddr.c b/apps/netutils/netlib/netlib_setipv4addr.c index a0f76cb27f..6da53447c4 100644 --- a/apps/netutils/netlib/netlib_sethostaddr.c +++ b/apps/netutils/netlib/netlib_setipv4addr.c @@ -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; diff --git a/apps/netutils/netlib/netlib_setnetmask.c b/apps/netutils/netlib/netlib_setipv4netmask.c index 45d4dee251..972c8e233f 100644 --- a/apps/netutils/netlib/netlib_setnetmask.c +++ b/apps/netutils/netlib/netlib_setipv4netmask.c @@ -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; diff --git a/apps/nshlib/nsh_netcmds.c b/apps/nshlib/nsh_netcmds.c index 7b902f9b58..4c99fac637 100644 --- a/apps/nshlib/nsh_netcmds.c +++ b/apps/nshlib/nsh_netcmds.c @@ -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) diff --git a/apps/nshlib/nsh_netinit.c b/apps/nshlib/nsh_netinit.c index 16fc78eb60..5581ef5cd6 100644 --- a/apps/nshlib/nsh_netinit.c +++ b/apps/nshlib/nsh_netinit.c @@ -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) |