mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2026-11-09 20:45:41 +08:00
[net][sal][netdev] Add IPv6 option configuration and feature support in SAL and netdev
Signed-off-by: chenyong <1521761801@qq.com>
This commit is contained in:
1 parent
c574c49b2f
commit
7d2ffe63e9
14 files changed
+713
-99
No files matched your search
+24
-5
@@ -76,6 +76,25 @@ config RT_USING_NETDEV
|
||||
config NETDEV_USING_AUTO_DEFAULT
|
||||
bool "Enable default netdev automatic change features"
|
||||
default y
|
||||
|
||||
config NETDEV_USING_IPV6
|
||||
bool "Enable IPV6 protocol support"
|
||||
default n
|
||||
|
||||
config NETDEV_IPV4
|
||||
int
|
||||
default 1
|
||||
|
||||
config NETDEV_IPV6
|
||||
int
|
||||
default 1 if NETDEV_USING_IPV6
|
||||
default 0 if !NETDEV_USING_IPV6
|
||||
|
||||
config NETDEV_IPV6_SCOPES
|
||||
bool
|
||||
help
|
||||
Defined to synchronize the ip6_addr structure state
|
||||
default n
|
||||
endif
|
||||
|
||||
endmenu
|
||||
@@ -104,11 +123,11 @@ config RT_USING_LWIP
|
||||
endchoice
|
||||
|
||||
if (RT_USING_LWIP210 || RT_USING_LWIP202)
|
||||
if (!RT_USING_NETDEV || (RT_USING_NETDEV && NETDEV_IPV6))
|
||||
config RT_USING_LWIP_IPV6
|
||||
bool "IPV6 protocol"
|
||||
default n
|
||||
endif
|
||||
config RT_USING_LWIP_IPV6
|
||||
bool "IPV6 protocol"
|
||||
default n
|
||||
select NETDEV_USING_IPV6
|
||||
select NETDEV_IPV6_SCOPES if RT_USING_LWIP210
|
||||
endif
|
||||
|
||||
config RT_LWIP_IGMP
|
||||
|
||||
@@ -540,11 +540,12 @@ static int socketaddr_to_ipaddr_port(const struct sockaddr *sockaddr, ip_addr_t
|
||||
const struct sockaddr_in* sin = (const struct sockaddr_in*) (const void *) sockaddr;
|
||||
|
||||
#if NETDEV_IPV4 && NETDEV_IPV6
|
||||
(*addr).u_addr.ip4.addr = sin->sin_addr.s_addr;
|
||||
addr->u_addr.ip4.addr = sin->sin_addr.s_addr;
|
||||
addr->type = IPADDR_TYPE_V4;
|
||||
#elif NETDEV_IPV4
|
||||
(*addr).addr = sin->sin_addr.s_addr;
|
||||
addr->addr = sin->sin_addr.s_addr;
|
||||
#elif NETDEV_IPV6
|
||||
LOG_E("not support IPV6.");
|
||||
#error "not support IPV6."
|
||||
#endif /* NETDEV_IPV4 && NETDEV_IPV6 */
|
||||
|
||||
*port = (uint16_t) HTONS_PORT(sin->sin_port);
|
||||
@@ -1126,10 +1127,11 @@ struct hostent *at_gethostbyname(const char *name)
|
||||
|
||||
#if NETDEV_IPV4 && NETDEV_IPV6
|
||||
addr.u_addr.ip4.addr = ipstr_to_u32(ipstr);
|
||||
addr.type = IPADDR_TYPE_V4;
|
||||
#elif NETDEV_IPV4
|
||||
addr.addr = ipstr_to_u32(ipstr);
|
||||
#elif NETDEV_IPV6
|
||||
LOG_E("not support IPV6.");
|
||||
#error "not support IPV6."
|
||||
#endif /* NETDEV_IPV4 && NETDEV_IPV6 */
|
||||
|
||||
/* fill hostent structure */
|
||||
@@ -1202,7 +1204,7 @@ int at_getaddrinfo(const char *nodename, const char *servname,
|
||||
if ((hints != RT_NULL) && (hints->ai_flags & AI_NUMERICHOST))
|
||||
{
|
||||
/* no DNS lookup, just parse for an address string */
|
||||
if (!inet_aton(nodename, (ip4_addr_t * )&addr))
|
||||
if (!inet_aton(nodename, &addr))
|
||||
{
|
||||
return EAI_NONAME;
|
||||
}
|
||||
@@ -1240,7 +1242,7 @@ int at_getaddrinfo(const char *nodename, const char *servname,
|
||||
#elif NETDEV_IPV4
|
||||
addr.addr = ipstr_to_u32(ip_str);
|
||||
#elif NETDEV_IPV6
|
||||
LOG_E("not support IPV6.");
|
||||
#error "not support IPV6."
|
||||
#endif /* NETDEV_IPV4 && NETDEV_IPV6 */
|
||||
}
|
||||
}
|
||||
@@ -1275,10 +1277,11 @@ int at_getaddrinfo(const char *nodename, const char *servname,
|
||||
/* set up sockaddr */
|
||||
#if NETDEV_IPV4 && NETDEV_IPV6
|
||||
sa4->sin_addr.s_addr = addr.u_addr.ip4.addr;
|
||||
sa4->type = IPADDR_TYPE_V4;
|
||||
#elif NETDEV_IPV4
|
||||
sa4->sin_addr.s_addr = addr.addr;
|
||||
#elif NETDEV_IPV6
|
||||
LOG_E("not support IPV6.");
|
||||
#error "not support IPV6."
|
||||
#endif /* NETDEV_IPV4 && NETDEV_IPV6 */
|
||||
sa4->sin_family = AF_INET;
|
||||
sa4->sin_len = sizeof(struct sockaddr_in);
|
||||
|
||||
@@ -544,7 +544,7 @@ netif_set_ipaddr(struct netif *netif, const ip4_addr_t *ipaddr)
|
||||
|
||||
#ifdef RT_USING_NETDEV
|
||||
/* rt-thread sal network interface device set IP address operations */
|
||||
netdev_low_level_set_ipaddr(netdev_get_by_name(netif->name), (ip_addr_t *)ipaddr);
|
||||
netdev_low_level_set_ipaddr(netdev_get_by_name(netif->name), &netif->ip_addr);
|
||||
#endif /* RT_USING_NETDEV */
|
||||
}
|
||||
|
||||
@@ -579,7 +579,7 @@ netif_set_gw(struct netif *netif, const ip4_addr_t *gw)
|
||||
|
||||
#ifdef RT_USING_NETDEV
|
||||
/* rt_thread network interface device set gateway address */
|
||||
netdev_low_level_set_gw(netdev_get_by_name(netif->name), (ip_addr_t *)gw);
|
||||
netdev_low_level_set_gw(netdev_get_by_name(netif->name), &netif->gw);
|
||||
#endif /* RT_USING_NETDEV */
|
||||
}
|
||||
|
||||
@@ -610,7 +610,7 @@ netif_set_netmask(struct netif *netif, const ip4_addr_t *netmask)
|
||||
|
||||
#ifdef RT_USING_NETDEV
|
||||
/* rt-thread network interface device set netmask address */
|
||||
netdev_low_level_set_netmask(netdev_get_by_name(netif->name), (ip_addr_t *)netmask);
|
||||
netdev_low_level_set_netmask(netdev_get_by_name(netif->name), &netif->netmask);
|
||||
#endif /* RT_USING_NETDEV */
|
||||
}
|
||||
#endif /* LWIP_IPV4 */
|
||||
@@ -1241,6 +1241,11 @@ netif_create_ip6_linklocal_address(struct netif *netif, u8_t from_mac_48bit)
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef RT_USING_NETDEV
|
||||
/* rt-thread network interface device set ipv6 address */
|
||||
ip_addr_copy(netdev_get_by_name(netif->name)->ip6_addr[0], netif->ip6_addr[0]);
|
||||
#endif /* RT_USING_NETDEV */
|
||||
|
||||
/* Set address state. */
|
||||
#if LWIP_IPV6_DUP_DETECT_ATTEMPTS
|
||||
/* Will perform duplicate address detection (DAD). */
|
||||
@@ -1279,6 +1284,10 @@ netif_add_ip6_address(struct netif *netif, const ip6_addr_t *ip6addr, s8_t *chos
|
||||
for (i = 1; i < LWIP_IPV6_NUM_ADDRESSES; i++) {
|
||||
if (ip6_addr_isinvalid(netif_ip6_addr_state(netif, i))) {
|
||||
ip_addr_copy_from_ip6(netif->ip6_addr[i], *ip6addr);
|
||||
#ifdef RT_USING_NETDEV
|
||||
/* rt-thread network interface device set ipv6 address */
|
||||
ip_addr_copy(netdev_get_by_name(netif->name)->ip6_addr[i], netif->ip6_addr[i]);
|
||||
#endif /* RT_USING_NETDEV */
|
||||
netif_ip6_addr_set_state(netif, i, IP6_ADDR_TENTATIVE);
|
||||
if (chosen_idx != NULL) {
|
||||
*chosen_idx = i;
|
||||
|
||||
@@ -128,23 +128,23 @@ static int lwip_netdev_set_addr_info(struct netdev *netif, ip_addr_t *ip_addr, i
|
||||
{
|
||||
if (ip_addr && netmask && gw)
|
||||
{
|
||||
netif_set_addr((struct netif *)netif->user_data, ip_addr, netmask, gw);
|
||||
netif_set_addr((struct netif *)netif->user_data, ip_2_ip4(ip_addr), ip_2_ip4(netmask), ip_2_ip4(gw));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ip_addr)
|
||||
{
|
||||
netif_set_ipaddr((struct netif *)netif->user_data, ip_addr);
|
||||
netif_set_ipaddr((struct netif *)netif->user_data, ip_2_ip4(ip_addr));
|
||||
}
|
||||
|
||||
if (netmask)
|
||||
{
|
||||
netif_set_netmask((struct netif *)netif->user_data, netmask);
|
||||
netif_set_netmask((struct netif *)netif->user_data, ip_2_ip4(netmask));
|
||||
}
|
||||
|
||||
if (gw)
|
||||
{
|
||||
netif_set_gw((struct netif *)netif->user_data, gw);
|
||||
netif_set_gw((struct netif *)netif->user_data, ip_2_ip4(gw));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -491,7 +491,7 @@ netif_do_set_ipaddr(struct netif *netif, const ip4_addr_t *ipaddr, ip_addr_t *ol
|
||||
|
||||
#ifdef RT_USING_NETDEV
|
||||
/* rt-thread sal network interface device set IP address operations */
|
||||
netdev_low_level_set_ipaddr(netdev_get_by_name(netif->name), (ip_addr_t *)ipaddr);
|
||||
netdev_low_level_set_ipaddr(netdev_get_by_name(netif->name), &netif->ip_addr);
|
||||
#endif /* RT_USING_NETDEV */
|
||||
|
||||
return 1; /* address changed */
|
||||
@@ -557,7 +557,7 @@ netif_do_set_netmask(struct netif *netif, const ip4_addr_t *netmask, ip_addr_t *
|
||||
|
||||
#ifdef RT_USING_NETDEV
|
||||
/* rt-thread network interface device set netmask address */
|
||||
netdev_low_level_set_netmask(netdev_get_by_name(netif->name), (ip_addr_t *)netmask);
|
||||
netdev_low_level_set_netmask(netdev_get_by_name(netif->name), &netif->netmask);
|
||||
#endif /* RT_USING_NETDEV */
|
||||
|
||||
return 1; /* netmask changed */
|
||||
@@ -625,7 +625,7 @@ netif_do_set_gw(struct netif *netif, const ip4_addr_t *gw, ip_addr_t *old_gw)
|
||||
|
||||
#ifdef RT_USING_NETDEV
|
||||
/* rt_thread network interface device set gateway address */
|
||||
netdev_low_level_set_gw(netdev_get_by_name(netif->name), (ip_addr_t *)gw);
|
||||
netdev_low_level_set_gw(netdev_get_by_name(netif->name), &netif->gw);
|
||||
#endif /* RT_USING_NETDEV */
|
||||
|
||||
return 1; /* gateway changed */
|
||||
@@ -1586,6 +1586,11 @@ netif_create_ip6_linklocal_address(struct netif *netif, u8_t from_mac_48bit)
|
||||
* zone field, so this should not create any compatibility problems. */
|
||||
ip6_addr_assign_zone(ip_2_ip6(&netif->ip6_addr[0]), IP6_UNICAST, netif);
|
||||
|
||||
#ifdef RT_USING_NETDEV
|
||||
/* rt-thread network interface device set ipv6 address */
|
||||
ip_addr_copy(netdev_get_by_name(netif->name)->ip6_addr[0], netif->ip6_addr[0]);
|
||||
#endif /* RT_USING_NETDEV */
|
||||
|
||||
/* Set address state. */
|
||||
#if LWIP_IPV6_DUP_DETECT_ATTEMPTS
|
||||
/* Will perform duplicate address detection (DAD). */
|
||||
@@ -1629,6 +1634,10 @@ netif_add_ip6_address(struct netif *netif, const ip6_addr_t *ip6addr, s8_t *chos
|
||||
for (i = ip6_addr_islinklocal(ip6addr) ? 0 : 1; i < LWIP_IPV6_NUM_ADDRESSES; i++) {
|
||||
if (ip6_addr_isinvalid(netif_ip6_addr_state(netif, i))) {
|
||||
ip_addr_copy_from_ip6(netif->ip6_addr[i], *ip6addr);
|
||||
#ifdef RT_USING_NETDEV
|
||||
/* rt-thread network interface device set ipv6 address */
|
||||
ip_addr_copy(netdev_get_by_name(netif->name)->ip6_addr[i], netif->ip6_addr[i]);
|
||||
#endif /* RT_USING_NETDEV */
|
||||
ip6_addr_assign_zone(ip_2_ip6(&netif->ip6_addr[i]), IP6_UNICAST, netif);
|
||||
netif_ip6_addr_set_state(netif, i, IP6_ADDR_TENTATIVE);
|
||||
if (chosen_idx != NULL) {
|
||||
|
||||
@@ -129,23 +129,23 @@ static int lwip_netdev_set_addr_info(struct netdev *netif, ip_addr_t *ip_addr, i
|
||||
{
|
||||
if (ip_addr && netmask && gw)
|
||||
{
|
||||
netif_set_addr((struct netif *)netif->user_data, ip_addr, netmask, gw);
|
||||
netif_set_addr((struct netif *)netif->user_data, ip_2_ip4(ip_addr), ip_2_ip4(netmask), ip_2_ip4(gw));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ip_addr)
|
||||
{
|
||||
netif_set_ipaddr((struct netif *)netif->user_data, ip_addr);
|
||||
netif_set_ipaddr((struct netif *)netif->user_data, ip_2_ip4(ip_addr));
|
||||
}
|
||||
|
||||
if (netmask)
|
||||
{
|
||||
netif_set_netmask((struct netif *)netif->user_data, netmask);
|
||||
netif_set_netmask((struct netif *)netif->user_data, ip_2_ip4(netmask));
|
||||
}
|
||||
|
||||
if (gw)
|
||||
{
|
||||
netif_set_gw((struct netif *)netif->user_data, gw);
|
||||
netif_set_gw((struct netif *)netif->user_data, ip_2_ip4(gw));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@
|
||||
|
||||
#include "netif/lowpan6.h"
|
||||
|
||||
#if LWIP_IPV6
|
||||
#if LWIP_IPV6 && LWIP_6LOWPAN
|
||||
|
||||
#include "lwip/ip.h"
|
||||
#include "lwip/pbuf.h"
|
||||
|
||||
@@ -27,6 +27,13 @@ extern "C" {
|
||||
#define NETDEV_DNS_SERVERS_NUM 2U
|
||||
#endif
|
||||
|
||||
#if NETDEV_IPV6
|
||||
/* the maximum of dns server number supported */
|
||||
#ifndef NETDEV_IPV6_NUM_ADDRESSES
|
||||
#define NETDEV_IPV6_NUM_ADDRESSES 3U
|
||||
#endif
|
||||
#endif /* NETDEV_IPV6 */
|
||||
|
||||
/* whether the network interface device is 'up' (set by the network interface driver or application) */
|
||||
#define NETDEV_FLAG_UP 0x01U
|
||||
/* if set, the network interface device has broadcast capability, only supported in the 'lwIP' stack */
|
||||
@@ -78,6 +85,9 @@ struct netdev
|
||||
ip_addr_t ip_addr; /* IP address */
|
||||
ip_addr_t netmask; /* subnet mask */
|
||||
ip_addr_t gw; /* gateway */
|
||||
#if NETDEV_IPV6
|
||||
ip_addr_t ip6_addr[NETDEV_IPV6_NUM_ADDRESSES]; /* array of IPv6 addresses */
|
||||
#endif /* NETDEV_IPV6 */
|
||||
ip_addr_t dns_servers[NETDEV_DNS_SERVERS_NUM]; /* DNS server */
|
||||
uint8_t hwaddr_len; /* hardware address length */
|
||||
uint8_t hwaddr[NETDEV_HWADDR_MAX_LEN]; /* hardware address */
|
||||
@@ -163,6 +173,7 @@ int netdev_set_dns_server(struct netdev *netdev, uint8_t dns_num, const ip_addr_
|
||||
|
||||
/* Set network interface device callback, it can be called when the status or address changed */
|
||||
void netdev_set_status_callback(struct netdev *netdev, netdev_callback_fn status_callback);
|
||||
void netdev_set_addr_callback(struct netdev *netdev, netdev_callback_fn addr_callback);
|
||||
|
||||
/* Set network interface device status and address, this function can only be called in the network interface device driver */
|
||||
void netdev_low_level_set_ipaddr(struct netdev *netdev, const ip_addr_t *ipaddr);
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -58,9 +58,21 @@ int netdev_register(struct netdev *netdev, const char *name, void *user_data)
|
||||
ip_addr_set_zero(&(netdev->ip_addr));
|
||||
ip_addr_set_zero(&(netdev->netmask));
|
||||
ip_addr_set_zero(&(netdev->gw));
|
||||
|
||||
IP_SET_TYPE_VAL(netdev->ip_addr, IPADDR_TYPE_V4);
|
||||
IP_SET_TYPE_VAL(netdev->netmask, IPADDR_TYPE_V4);
|
||||
IP_SET_TYPE_VAL(netdev->gw, IPADDR_TYPE_V4);
|
||||
#if NETDEV_IPV6
|
||||
for (index = 0; index < NETDEV_IPV6_NUM_ADDRESSES; index++)
|
||||
{
|
||||
ip_addr_set_zero(&(netdev->ip6_addr[index]));
|
||||
IP_SET_TYPE_VAL(netdev->ip_addr, IPADDR_TYPE_V6);
|
||||
}
|
||||
#endif /* NETDEV_IPV6 */
|
||||
for (index = 0; index < NETDEV_DNS_SERVERS_NUM; index++)
|
||||
{
|
||||
ip_addr_set_zero(&(netdev->dns_servers[index]));
|
||||
IP_SET_TYPE_VAL(netdev->ip_addr, IPADDR_TYPE_V4);
|
||||
}
|
||||
netdev->status_callback = RT_NULL;
|
||||
netdev->addr_callback = RT_NULL;
|
||||
@@ -839,7 +851,7 @@ static void netdev_list_if(void)
|
||||
|
||||
rt_kprintf("network interface device: %s%s\n",
|
||||
netdev->name,
|
||||
(netdev == netdev_default)?" (Default)":"");
|
||||
(netdev == netdev_default) ? " (Default)" : "");
|
||||
rt_kprintf("MTU: %d\n", netdev->mtu);
|
||||
|
||||
/* 6 - MAC address, 8 - IEMI */
|
||||
@@ -881,6 +893,28 @@ static void netdev_list_if(void)
|
||||
rt_kprintf("gw address: %s\n", inet_ntoa(netdev->gw));
|
||||
rt_kprintf("net mask : %s\n", inet_ntoa(netdev->netmask));
|
||||
|
||||
#if NETDEV_IPV6
|
||||
{
|
||||
ip_addr_t *addr;
|
||||
int i;
|
||||
|
||||
addr = &netdev->ip6_addr[0];
|
||||
|
||||
if (!ip_addr_isany(addr))
|
||||
{
|
||||
rt_kprintf("ipv6 link-local: %s %s\n", inet_ntoa(*addr),
|
||||
!ip_addr_isany(addr) ? "VALID" : "INVALID");
|
||||
|
||||
for (i = 1; i < NETDEV_IPV6_NUM_ADDRESSES; i++)
|
||||
{
|
||||
addr = &netdev->ip6_addr[i];
|
||||
rt_kprintf("ipv6[%d] address: %s %s\n", i, inet_ntoa(*addr),
|
||||
!ip_addr_isany(addr) ? "VALID" : "INVALID");
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif /* NETDEV_IPV6 */
|
||||
|
||||
for (index = 0; index < NETDEV_DNS_SERVERS_NUM; index++)
|
||||
{
|
||||
rt_kprintf("dns server #%d: %s\n", index, inet_ntoa(netdev->dns_servers[index]));
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -25,6 +25,12 @@
|
||||
|
||||
#include <netdev.h>
|
||||
|
||||
#if (LWIP_VERSION < 0x2000000) && NETDEV_IPV6
|
||||
#error "The lwIP version is not support IPV6, please disable netdev IPV6 configuration "
|
||||
#elif (LWIP_VERSION > 0x2000000) && (NETDEV_IPV6 != LWIP_IPV6)
|
||||
#error "IPV6 configuration error, Please check and synchronize netdev and lwip IPV6 configuration."
|
||||
#endif
|
||||
|
||||
#if LWIP_VERSION < 0x2000000
|
||||
#define SELWAIT_T int
|
||||
#else
|
||||
@@ -308,7 +314,11 @@ static const struct sal_netdb_ops lwip_netdb_ops =
|
||||
static const struct sal_proto_family lwip_inet_family =
|
||||
{
|
||||
AF_INET,
|
||||
#if LWIP_VERSION > 0x2000000
|
||||
AF_INET6,
|
||||
#else
|
||||
AF_INET,
|
||||
#endif
|
||||
&lwip_socket_ops,
|
||||
&lwip_netdb_ops,
|
||||
};
|
||||
|
||||
@@ -157,6 +157,7 @@ struct sockaddr
|
||||
char sa_data[14];
|
||||
};
|
||||
|
||||
#if NETDEV_IPV4
|
||||
/* members are in network byte order */
|
||||
struct sockaddr_in
|
||||
{
|
||||
@@ -167,6 +168,19 @@ struct sockaddr_in
|
||||
#define SIN_ZERO_LEN 8
|
||||
char sin_zero[SIN_ZERO_LEN];
|
||||
};
|
||||
#endif /* NETDEV_IPV4 */
|
||||
|
||||
#if NETDEV_IPV6
|
||||
struct sockaddr_in6
|
||||
{
|
||||
uint8_t sin6_len; /* length of this structure */
|
||||
sa_family_t sin6_family; /* AF_INET6 */
|
||||
in_port_t sin6_port; /* Transport layer port # */
|
||||
uint32_t sin6_flowinfo; /* IPv6 flow information */
|
||||
struct in6_addr sin6_addr; /* IPv6 address */
|
||||
uint32_t sin6_scope_id; /* Set of interfaces for scope */
|
||||
};
|
||||
#endif /* NETDEV_IPV6 */
|
||||
|
||||
struct sockaddr_storage
|
||||
{
|
||||
@@ -174,9 +188,9 @@ struct sockaddr_storage
|
||||
sa_family_t ss_family;
|
||||
char s2_data1[2];
|
||||
uint32_t s2_data2[3];
|
||||
#if SAL_IPV6
|
||||
u32_t s2_data3[3];
|
||||
#endif /* SAL_IPV6 */
|
||||
#if NETDEV_IPV6
|
||||
uint32_t s2_data3[3];
|
||||
#endif /* NETDEV_IPV6 */
|
||||
};
|
||||
|
||||
int sal_accept(int socket, struct sockaddr *addr, socklen_t *addrlen);
|
||||
|
||||
@@ -549,12 +549,13 @@ static void sal_sockaddr_to_ipaddr(const struct sockaddr *name, ip_addr_t *local
|
||||
const struct sockaddr_in *svr_addr = (const struct sockaddr_in *) name;
|
||||
|
||||
#if NETDEV_IPV4 && NETDEV_IPV6
|
||||
(*local_ipaddr).u_addr.ip4.addr = svr_addr->sin_addr.s_addr;
|
||||
local_ipaddr->u_addr.ip4.addr = svr_addr->sin_addr.s_addr;
|
||||
local_ipaddr->type = IPADDR_TYPE_V4;
|
||||
#elif NETDEV_IPV4
|
||||
(*local_ipaddr).addr = svr_addr->sin_addr.s_addr;
|
||||
local_ipaddr->addr = svr_addr->sin_addr.s_addr;
|
||||
#elif NETDEV_IPV6
|
||||
LOG_E("not support IPV6");
|
||||
#endif /* SAL_IPV4 && SAL_IPV6*/
|
||||
#error "not only support IPV6"
|
||||
#endif /* NETDEV_IPV4 && NETDEV_IPV6*/
|
||||
}
|
||||
|
||||
int sal_bind(int socket, const struct sockaddr *name, socklen_t namelen)
|
||||
@@ -572,7 +573,7 @@ int sal_bind(int socket, const struct sockaddr *name, socklen_t namelen)
|
||||
sal_sockaddr_to_ipaddr(name, &input_ipaddr);
|
||||
|
||||
/* check input ipaddr is default netdev ipaddr */
|
||||
if (input_ipaddr.addr != INADDR_ANY)
|
||||
if (!ip_addr_isany_val(input_ipaddr))
|
||||
{
|
||||
struct sal_proto_family *input_pf = RT_NULL, *local_pf = RT_NULL;
|
||||
struct netdev *new_netdev = RT_NULL;
|
||||
|
||||
Reference in new issue
Block a user