Compiler warning fixes (mostly constness in dual-stack configurations)

This commit is contained in:
Dirk Ziegelmeier 2015-09-17 13:59:52 +02:00 committed by goldsimon
parent 726af89168
commit f62022cdf3
15 changed files with 87 additions and 72 deletions

View File

@ -1770,11 +1770,11 @@ lwip_netconn_do_join_leave_group(struct api_msg_msg *msg)
#if LWIP_IPV6 && LWIP_IPV6_MLD
if (PCB_ISIPV6(msg->conn->pcb.udp)) {
if (msg->msg.jl.join_or_leave == NETCONN_JOIN) {
msg->err = mld6_joingroup(ip_2_ip6(API_EXPR_REF(msg->msg.jl.netif_addr)),
ip_2_ip6(API_EXPR_REF(msg->msg.jl.multiaddr)));
msg->err = mld6_joingroup(ip_2_ip6_c(API_EXPR_REF(msg->msg.jl.netif_addr)),
ip_2_ip6_c(API_EXPR_REF(msg->msg.jl.multiaddr)));
} else {
msg->err = mld6_leavegroup(ip_2_ip6(API_EXPR_REF(msg->msg.jl.netif_addr)),
ip_2_ip6(API_EXPR_REF(msg->msg.jl.multiaddr)));
msg->err = mld6_leavegroup(ip_2_ip6_c(API_EXPR_REF(msg->msg.jl.netif_addr)),
ip_2_ip6_c(API_EXPR_REF(msg->msg.jl.multiaddr)));
}
}
else
@ -1782,11 +1782,11 @@ lwip_netconn_do_join_leave_group(struct api_msg_msg *msg)
{
#if LWIP_IGMP
if (msg->msg.jl.join_or_leave == NETCONN_JOIN) {
msg->err = igmp_joingroup(ip_2_ip4(API_EXPR_REF(msg->msg.jl.netif_addr)),
ip_2_ip4(API_EXPR_REF(msg->msg.jl.multiaddr)));
msg->err = igmp_joingroup(ip_2_ip4_c(API_EXPR_REF(msg->msg.jl.netif_addr)),
ip_2_ip4_c(API_EXPR_REF(msg->msg.jl.multiaddr)));
} else {
msg->err = igmp_leavegroup(ip_2_ip4(API_EXPR_REF(msg->msg.jl.netif_addr)),
ip_2_ip4(API_EXPR_REF(msg->msg.jl.multiaddr)));
msg->err = igmp_leavegroup(ip_2_ip4_c(API_EXPR_REF(msg->msg.jl.netif_addr)),
ip_2_ip4_c(API_EXPR_REF(msg->msg.jl.multiaddr)));
}
#endif /* LWIP_IGMP */
}

View File

@ -1597,7 +1597,7 @@ dhcp_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *addr,
#endif /* LWIP_IPV6 */
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("dhcp_recv(pbuf = %p) from DHCP server %"U16_F".%"U16_F".%"U16_F".%"U16_F" port %"U16_F"\n", (void*)p,
ip4_addr1_16(ip_2_ip4(addr)), ip4_addr2_16(ip_2_ip4(addr)), ip4_addr3_16(ip_2_ip4(addr)), ip4_addr4_16(ip_2_ip4(addr)), port));
ip4_addr1_16(ip_2_ip4_c(addr)), ip4_addr2_16(ip_2_ip4_c(addr)), ip4_addr3_16(ip_2_ip4_c(addr)), ip4_addr4_16(ip_2_ip4_c(addr)), port));
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("pbuf->len = %"U16_F"\n", p->len));
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE, ("pbuf->tot_len = %"U16_F"\n", p->tot_len));
/* prevent warnings about unused arguments */

View File

@ -431,7 +431,7 @@ dns_init(void)
* @param dnsserver IP address of the DNS server to set
*/
void
dns_setserver(u8_t numdns, ip_addr_t *dnsserver)
dns_setserver(u8_t numdns, const ip_addr_t *dnsserver)
{
if (numdns < DNS_MAX_SERVERS) {
if (dnsserver != NULL) {

View File

@ -40,6 +40,7 @@
#include "lwip/inet_chksum.h"
#include "lwip/def.h"
#include "lwip/ip_addr.h"
#include <stddef.h>
#include <string.h>
@ -385,7 +386,7 @@ ip_chksum_pseudo(struct pbuf *p, u8_t proto, u16_t proto_len,
{
#if LWIP_IPV6
if (IP_IS_V6(dest)) {
return ip6_chksum_pseudo(p, proto, proto_len, ip_2_ip6(src), ip_2_ip6(dest));
return ip6_chksum_pseudo(p, proto, proto_len, ip_2_ip6_c(src), ip_2_ip6_c(dest));
}
#endif /* LWIP_IPV6 */
#if LWIP_IPV4 && LWIP_IPV6
@ -393,7 +394,7 @@ ip_chksum_pseudo(struct pbuf *p, u8_t proto, u16_t proto_len,
#endif /* LWIP_IPV4 && LWIP_IPV6 */
#if LWIP_IPV4
{
return inet_chksum_pseudo(p, proto, proto_len, ip_2_ip4(src), ip_2_ip4(dest));
return inet_chksum_pseudo(p, proto, proto_len, ip_2_ip4_c(src), ip_2_ip4_c(dest));
}
#endif /* LWIP_IPV4 */
}
@ -532,7 +533,7 @@ ip_chksum_pseudo_partial(struct pbuf *p, u8_t proto, u16_t proto_len,
{
#if LWIP_IPV6
if (IP_IS_V6(dest)) {
return ip6_chksum_pseudo_partial(p, proto, proto_len, chksum_len, ip_2_ip6(src), ip_2_ip6(dest));
return ip6_chksum_pseudo_partial(p, proto, proto_len, chksum_len, ip_2_ip6_c(src), ip_2_ip6_c(dest));
}
#endif /* LWIP_IPV6 */
#if LWIP_IPV4 && LWIP_IPV6
@ -540,7 +541,7 @@ ip_chksum_pseudo_partial(struct pbuf *p, u8_t proto, u16_t proto_len,
#endif /* LWIP_IPV4 && LWIP_IPV6 */
#if LWIP_IPV4
{
return inet_chksum_pseudo_partial(p, proto, proto_len, chksum_len, ip_2_ip4(src), ip_2_ip4(dest));
return inet_chksum_pseudo_partial(p, proto, proto_len, chksum_len, ip_2_ip4_c(src), ip_2_ip4_c(dest));
}
#endif /* LWIP_IPV4 */
}

View File

@ -171,7 +171,7 @@ igmp_start(struct netif *netif)
{
struct igmp_group* group;
LWIP_DEBUGF(IGMP_DEBUG, ("igmp_start: starting IGMP processing on if %p\n", netif));
LWIP_DEBUGF(IGMP_DEBUG, ("igmp_start: starting IGMP processing on if %p\n", (void*)netif));
group = igmp_lookup_group(netif, &allsystems);
@ -183,7 +183,7 @@ igmp_start(struct netif *netif)
if (netif->igmp_mac_filter != NULL) {
LWIP_DEBUGF(IGMP_DEBUG, ("igmp_start: igmp_mac_filter(ADD "));
ip4_addr_debug_print_val(IGMP_DEBUG, allsystems);
LWIP_DEBUGF(IGMP_DEBUG, (") on if %p\n", netif));
LWIP_DEBUGF(IGMP_DEBUG, (") on if %p\n", (void*)netif));
netif->igmp_mac_filter(netif, &allsystems, IGMP_ADD_MAC_FILTER);
}
@ -222,7 +222,7 @@ igmp_stop(struct netif *netif)
if (netif->igmp_mac_filter != NULL) {
LWIP_DEBUGF(IGMP_DEBUG, ("igmp_stop: igmp_mac_filter(DEL "));
ip4_addr_debug_print(IGMP_DEBUG, &group->group_address);
LWIP_DEBUGF(IGMP_DEBUG, (") on if %p\n", netif));
LWIP_DEBUGF(IGMP_DEBUG, (") on if %p\n", (void*)netif));
netif->igmp_mac_filter(netif, &(group->group_address), IGMP_DEL_MAC_FILTER);
}
/* free group */
@ -247,7 +247,7 @@ igmp_report_groups(struct netif *netif)
{
struct igmp_group *group = igmp_group_list;
LWIP_DEBUGF(IGMP_DEBUG, ("igmp_report_groups: sending IGMP reports on if %p\n", netif));
LWIP_DEBUGF(IGMP_DEBUG, ("igmp_report_groups: sending IGMP reports on if %p\n", (void*)netif));
while (group != NULL) {
if ((group->netif == netif) && (!(ip4_addr_cmp(&(group->group_address), &allsystems)))) {
@ -319,7 +319,7 @@ igmp_lookup_group(struct netif *ifp, const ip4_addr_t *addr)
LWIP_DEBUGF(IGMP_DEBUG, ("igmp_lookup_group: %sallocated a new group with address ", (group?"":"impossible to ")));
ip4_addr_debug_print(IGMP_DEBUG, addr);
LWIP_DEBUGF(IGMP_DEBUG, (" on if %p\n", ifp));
LWIP_DEBUGF(IGMP_DEBUG, (" on if %p\n", (void*)ifp));
return group;
}
@ -385,7 +385,7 @@ igmp_input(struct pbuf *p, struct netif *inp, const ip4_addr_t *dest)
ip4_addr_debug_print(IGMP_DEBUG, &(ip4_current_header()->src));
LWIP_DEBUGF(IGMP_DEBUG, (" to address "));
ip4_addr_debug_print(IGMP_DEBUG, &(ip4_current_header()->dest));
LWIP_DEBUGF(IGMP_DEBUG, (" on if %p\n", inp));
LWIP_DEBUGF(IGMP_DEBUG, (" on if %p\n", (void*)inp));
/* Now calculate and check the checksum */
igmp = (struct igmp_msg *)p->payload;
@ -471,7 +471,7 @@ igmp_input(struct pbuf *p, struct netif *inp, const ip4_addr_t *dest)
}
default: {
LWIP_DEBUGF(IGMP_DEBUG, ("igmp_input: unexpected msg %d in state %d on group %p on if %p\n",
igmp->igmp_msgtype, group->group_state, &group, group->netif));
igmp->igmp_msgtype, group->group_state, (void*)&group, (void*)group->netif));
IGMP_STATS_INC(igmp.proterr);
break;
}
@ -521,7 +521,7 @@ igmp_joingroup(const ip4_addr_t *ifaddr, const ip4_addr_t *groupaddr)
if ((group->use==0) && (netif->igmp_mac_filter != NULL)) {
LWIP_DEBUGF(IGMP_DEBUG, ("igmp_joingroup: igmp_mac_filter(ADD "));
ip4_addr_debug_print(IGMP_DEBUG, groupaddr);
LWIP_DEBUGF(IGMP_DEBUG, (") on if %p\n", netif));
LWIP_DEBUGF(IGMP_DEBUG, (") on if %p\n", (void*)netif));
netif->igmp_mac_filter(netif, groupaddr, IGMP_ADD_MAC_FILTER);
}
@ -596,7 +596,7 @@ igmp_leavegroup(const ip4_addr_t *ifaddr, const ip4_addr_t *groupaddr)
if (netif->igmp_mac_filter != NULL) {
LWIP_DEBUGF(IGMP_DEBUG, ("igmp_leavegroup: igmp_mac_filter(DEL "));
ip4_addr_debug_print(IGMP_DEBUG, groupaddr);
LWIP_DEBUGF(IGMP_DEBUG, (") on if %p\n", netif));
LWIP_DEBUGF(IGMP_DEBUG, (") on if %p\n", (void*)netif));
netif->igmp_mac_filter(netif, groupaddr, IGMP_DEL_MAC_FILTER);
}
@ -659,7 +659,7 @@ igmp_timeout(struct igmp_group *group)
(!(ip4_addr_cmp(&(group->group_address), &allsystems)))) {
LWIP_DEBUGF(IGMP_DEBUG, ("igmp_timeout: report membership for group with address "));
ip4_addr_debug_print(IGMP_DEBUG, &(group->group_address));
LWIP_DEBUGF(IGMP_DEBUG, (" on if %p\n", group->netif));
LWIP_DEBUGF(IGMP_DEBUG, (" on if %p\n", (void*)group->netif));
IGMP_STATS_INC(igmp.tx_report);
igmp_send(group, IGMP_V2_MEMB_REPORT);

View File

@ -151,10 +151,10 @@ ethip6_output(struct netif *netif, struct pbuf *q, const ip6_addr_t *ip6addr)
/* Hash IP multicast address to MAC address.*/
dest.addr[0] = 0x33;
dest.addr[1] = 0x33;
dest.addr[2] = ((u8_t *)(&(ip6addr->addr[3])))[0];
dest.addr[3] = ((u8_t *)(&(ip6addr->addr[3])))[1];
dest.addr[4] = ((u8_t *)(&(ip6addr->addr[3])))[2];
dest.addr[5] = ((u8_t *)(&(ip6addr->addr[3])))[3];
dest.addr[2] = ((const u8_t *)(&(ip6addr->addr[3])))[0];
dest.addr[3] = ((const u8_t *)(&(ip6addr->addr[3])))[1];
dest.addr[4] = ((const u8_t *)(&(ip6addr->addr[3])))[2];
dest.addr[5] = ((const u8_t *)(&(ip6addr->addr[3])))[3];
/* Send out. */
return ethip6_send(netif, q, (struct eth_addr*)(netif->hwaddr), &dest);

View File

@ -269,7 +269,7 @@ ip6_reass(struct pbuf *p)
IP6_FRAG_STATS_INC(ip6_frag.recv);
LWIP_ASSERT("ip6_frag_hdr must be in the first pbuf, not chained",
(void*)ip6_current_header() == ((u8_t*)p->payload) - IP6_HLEN);
(const void*)ip6_current_header() == ((u8_t*)p->payload) - IP6_HLEN);
frag_hdr = (struct ip6_frag_hdr *) p->payload;
@ -281,7 +281,7 @@ ip6_reass(struct pbuf *p)
* Adjust for headers before Fragment Header.
* And finally adjust by Fragment Header length. */
len = ntohs(ip6_current_header()->_plen);
len -= (u16_t)(((u8_t*)p->payload - (u8_t*)ip6_current_header()) - IP6_HLEN);
len -= (u16_t)(((u8_t*)p->payload - (const u8_t*)ip6_current_header()) - IP6_HLEN);
len -= IP6_FRAG_HLEN;
/* Look for the datagram the fragment belongs to in the current datagram queue,

View File

@ -332,7 +332,7 @@ raw_sendto(struct raw_pcb *pcb, struct pbuf *p, const ip_addr_t *ipaddr)
/* If requested, based on the IPV6_CHECKSUM socket option per RFC3542,
compute the checksum and update the checksum in the payload. */
if (PCB_ISIPV6(pcb) && pcb->chksum_reqd) {
u16_t chksum = ip6_chksum_pseudo(p, pcb->protocol, p->tot_len, ip_2_ip6(src_ip), ip_2_ip6(dst_ip));
u16_t chksum = ip6_chksum_pseudo(p, pcb->protocol, p->tot_len, ip_2_ip6_c(src_ip), ip_2_ip6_c(dst_ip));
LWIP_ASSERT("Checksum must fit into first pbuf", p->len >= (pcb->chksum_offset + 2));
SMEMCPY(((u8_t *)p->payload) + pcb->chksum_offset, &chksum, sizeof(u16_t));
}

View File

@ -747,7 +747,7 @@ const struct mib_array_node mgmt = {
/* When using a private MIB, you have to create a file 'private_mib.h' that contains
* a 'struct mib_array_node mib_private' which contains your MIB. */
s32_t internet_ids[2] = { 2, 4 };
const struct mib_node* const internet_nodes[2] = { (struct mib_node*)&mgmt, (struct mib_node*)&mib_private };
const struct mib_node* const internet_nodes[2] = { (const struct mib_node*)&mgmt, (const struct mib_node*)&mib_private };
const struct mib_array_node internet = {
&noleafs_get_object_def,
&noleafs_get_value,

View File

@ -1806,7 +1806,7 @@ tcp_eff_send_mss_impl(u16_t sendmss, const ip_addr_t *dest
#endif /* LWIP_IPV4 */
{
/* First look in destination cache, to see if there is a Path MTU. */
mtu = nd6_get_destination_mtu(ip_2_ip6(dest), outif);
mtu = nd6_get_destination_mtu(ip_2_ip6_c(dest), outif);
}
#if LWIP_IPV4
else

View File

@ -158,7 +158,9 @@ udp_input(struct pbuf *p, struct netif *inp)
struct udp_pcb *uncon_pcb;
u16_t src, dest;
u8_t local_match;
#if LWIP_IPV4
u8_t broadcast;
#endif /* LWIP_IPV4 */
u8_t for_us;
LWIP_UNUSED_ARG(inp);
@ -181,8 +183,10 @@ udp_input(struct pbuf *p, struct netif *inp)
udphdr = (struct udp_hdr *)p->payload;
#if LWIP_IPV4
/* is broadcast packet ? */
broadcast = ip_addr_isbroadcast(ip_current_dest_addr(), ip_current_netif());
#endif /* LWIP_IPV4 */
LWIP_DEBUGF(UDP_DEBUG, ("udp_input: received datagram of length %"U16_F"\n", p->tot_len));
@ -653,7 +657,7 @@ udp_sendto_if_chksum(struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *dst_i
#if LWIP_IPV6
if (PCB_ISIPV6(pcb)) {
if (ip6_addr_isany(ip_2_ip6(&pcb->local_ip))) {
src_ip = ip6_2_ip(ip6_select_source_address(netif, ip_2_ip6(dst_ip)), &src_ip_tmp);
src_ip = ip6_2_ip(ip6_select_source_address(netif, ip_2_ip6_c(dst_ip)), &src_ip_tmp);
if (src_ip == NULL) {
/* No suitable source address was found. */
return ERR_RTE;

View File

@ -38,6 +38,8 @@
#if LWIP_DNS
#include "lwip/ip_addr.h"
#ifdef __cplusplus
extern "C" {
#endif
@ -88,7 +90,7 @@ typedef void (*dns_found_callback)(const char *name, ip_addr_t *ipaddr, void *ca
void dns_init(void);
void dns_tmr(void);
void dns_setserver(u8_t numdns, ip_addr_t *dnsserver);
void dns_setserver(u8_t numdns, const ip_addr_t *dnsserver);
ip_addr_t dns_getserver(u8_t numdns);
err_t dns_gethostbyname(const char *hostname, ip_addr_t *addr,
dns_found_callback found, void *callback_arg);

View File

@ -245,26 +245,26 @@ extern struct ip_globals ip_data;
#if LWIP_IPV4 && LWIP_IPV6
#define ip_output(isipv6, p, src, dest, ttl, tos, proto) \
((isipv6) ? \
ip6_output(p, ip_2_ip6(src), ip_2_ip6(dest), ttl, tos, proto) : \
ip4_output(p, ip_2_ip4(src), ip_2_ip4(dest), ttl, tos, proto))
ip6_output(p, ip_2_ip6_c(src), ip_2_ip6_c(dest), ttl, tos, proto) : \
ip4_output(p, ip_2_ip4_c(src), ip_2_ip4_c(dest), ttl, tos, proto))
#define ip_output_if(isipv6, p, src, dest, ttl, tos, proto, netif) \
((isipv6) ? \
ip6_output_if(p, ip_2_ip6(src), ip_2_ip6(dest), ttl, tos, proto, netif) : \
ip4_output_if(p, ip_2_ip4(src), ip_2_ip4(dest), ttl, tos, proto, netif))
ip6_output_if(p, ip_2_ip6_c(src), ip_2_ip6_c(dest), ttl, tos, proto, netif) : \
ip4_output_if(p, ip_2_ip4_c(src), ip_2_ip4_c(dest), ttl, tos, proto, netif))
#define ip_output_if_src(isipv6, p, src, dest, ttl, tos, proto, netif) \
((isipv6) ? \
ip6_output_if_src(p, ip_2_ip6(src), ip_2_ip6(dest), ttl, tos, proto, netif) : \
ip4_output_if_src(p, ip_2_ip4(src), ip_2_ip4(dest), ttl, tos, proto, netif))
ip6_output_if_src(p, ip_2_ip6_c(src), ip_2_ip6_c(dest), ttl, tos, proto, netif) : \
ip4_output_if_src(p, ip_2_ip4_c(src), ip_2_ip4_c(dest), ttl, tos, proto, netif))
#define ip_output_hinted(isipv6, p, src, dest, ttl, tos, proto, addr_hint) \
((isipv6) ? \
ip6_output_hinted(p, ip_2_ip6(src), ip_2_ip6(dest), ttl, tos, proto, addr_hint) : \
ip4_output_hinted(p, ip_2_ip4(src), ip_2_ip4(dest), ttl, tos, proto, addr_hint))
ip6_output_hinted(p, ip_2_ip6_c(src), ip_2_ip6_c(dest), ttl, tos, proto, addr_hint) : \
ip4_output_hinted(p, ip_2_ip4_c(src), ip_2_ip4_c(dest), ttl, tos, proto, addr_hint))
#define ip_route(isipv6, src, dest) \
((isipv6) ? \
ip6_route(ip_2_ip6(src), ip_2_ip6(dest)) : \
ip4_route_src(ip_2_ip4(dest), ip_2_ip4(src)))
ip6_route(ip_2_ip6_c(src), ip_2_ip6_c(dest)) : \
ip4_route_src(ip_2_ip4_c(dest), ip_2_ip4_c(src)))
#define ip_netif_get_local_ip(isipv6, netif, dest, storage) ((isipv6) ? \
ip6_2_ip(ip6_netif_get_local_ip(netif, ip_2_ip6(dest)), storage) : \
ip6_2_ip(ip6_netif_get_local_ip(netif, ip_2_ip6_c(dest)), storage) : \
ip4_2_ip(ip4_netif_get_local_ip(netif), storage))
#define ip_debug_print(is_ipv6, p) ((is_ipv6) ? ip6_debug_print(p) : ip4_debug_print(p))
#elif LWIP_IPV4 /* LWIP_IPV4 && LWIP_IPV6 */

View File

@ -76,11 +76,17 @@ ip_addr_t* ip6_2_ip(const ip6_addr_t *ip6addr, ip_addr_t* storage);
#ifdef LWIP_ALLOW_STATIC_FN_IN_HEADER
static ip6_addr_t* ip_2_ip6(const ip_addr_t *ipaddr)
{ if(ipaddr) { return (ip6_addr_t*)&((ipaddr)->addr.ip6); } return NULL; }
static const ip6_addr_t* ip_2_ip6(const ip_addr_t *ipaddr)
{ if(ipaddr) { return (const ip6_addr_t*)&((ipaddr)->addr.ip6); } return NULL; }
static ip4_addr_t* ip_2_ip4(const ip_addr_t *ipaddr)
{ if(ipaddr) { return (ip4_addr_t*)&((ipaddr)->addr.ip4); } return NULL; }
static const ip4_addr_t* ip_2_ip4_c(const ip_addr_t *ipaddr)
{ if(ipaddr) { return (const ip4_addr_t*)&((ipaddr)->addr.ip4); } return NULL; }
#else /* LWIP_ALLOW_STATIC_FN_IN_HEADER */
#define ip_2_ip6(ipaddr) ((ip6_addr_t*)(ipaddr))
#define ip_2_ip6_c(ipaddr) ((const ip6_addr_t*)(ipaddr))
#define ip_2_ip4(ipaddr) ((ip4_addr_t*)(ipaddr))
#define ip_2_ip4_c(ipaddr) ((const ip4_addr_t*)(ipaddr))
#endif /* LWIP_ALLOW_STATIC_FN_IN_HEADER */
#define IP_ADDR4(ipaddr,a,b,c,d) do { IP4_ADDR(ip_2_ip4(ipaddr),a,b,c,d); \
@ -100,11 +106,11 @@ static ip4_addr_t* ip_2_ip4(const ip_addr_t *ipaddr)
#define ip_addr_get_ip4_u32(ipaddr) (((ipaddr) && !IP_IS_V6(ipaddr)) ? \
ip4_addr_get_u32(ip_2_ip4(ipaddr)) : 0)
#define ip_addr_set(dest, src) do{if(IP_IS_V6(src)){ \
ip6_addr_set(ip_2_ip6(dest), ip_2_ip6(src)); IP_SET_TYPE(dest, IPADDR_TYPE_V6); }else{ \
ip4_addr_set(ip_2_ip4(dest), ip_2_ip4(src)); IP_SET_TYPE(dest, IPADDR_TYPE_V4); }}while(0)
ip6_addr_set(ip_2_ip6(dest), ip_2_ip6_c(src)); IP_SET_TYPE(dest, IPADDR_TYPE_V6); }else{ \
ip4_addr_set(ip_2_ip4(dest), ip_2_ip4_c(src)); IP_SET_TYPE(dest, IPADDR_TYPE_V4); }}while(0)
#define ip_addr_set_ipaddr(dest, src) do{if(IP_IS_V6(src)){ \
ip6_addr_set(ip_2_ip6(dest), ip_2_ip6(src)); IP_SET_TYPE(dest, IPADDR_TYPE_V6); }else{ \
ip4_addr_set(ip_2_ip4(dest), ip_2_ip4(src)); IP_SET_TYPE(dest, IPADDR_TYPE_V4); }}while(0)
ip6_addr_set(ip_2_ip6(dest), ip_2_ip6_c(src)); IP_SET_TYPE(dest, IPADDR_TYPE_V6); }else{ \
ip4_addr_set(ip_2_ip4(dest), ip_2_ip4_c(src)); IP_SET_TYPE(dest, IPADDR_TYPE_V4); }}while(0)
#define ip_addr_set_zero(ipaddr) do{ \
ip6_addr_set_zero(ip_2_ip6(ipaddr)); IP_SET_TYPE(ipaddr, 0); }while(0)
#define ip_addr_set_zero_ip6(ipaddr) do{ \
@ -125,11 +131,11 @@ static ip4_addr_t* ip_2_ip4(const ip_addr_t *ipaddr)
0 : \
ip4_addr_netcmp(ip_2_ip4(addr1), ip_2_ip4(addr2), mask))
#define ip_addr_cmp(addr1, addr2) ((IP_IS_V6_VAL(*(addr1)) != IP_IS_V6_VAL(*(addr2))) ? 0 : (IP_IS_V6_VAL(*(addr1)) ? \
ip6_addr_cmp(ip_2_ip6(addr1), ip_2_ip6(addr2)) : \
ip4_addr_cmp(ip_2_ip4(addr1), ip_2_ip4(addr2))))
ip6_addr_cmp(ip_2_ip6_c(addr1), ip_2_ip6_c(addr2)) : \
ip4_addr_cmp(ip_2_ip4_c(addr1), ip_2_ip4_c(addr2))))
#define ip_addr_isany(ipaddr) ((IP_IS_V6(ipaddr)) ? \
ip6_addr_isany(ip_2_ip6(ipaddr)) : \
ip4_addr_isany(ip_2_ip4(ipaddr)))
ip6_addr_isany(ip_2_ip6_c(ipaddr)) : \
ip4_addr_isany(ip_2_ip4_c(ipaddr)))
#define ip_addr_isany_val(ipaddr) ((IP_IS_V6_VAL(ipaddr)) ? \
ip6_addr_isany_val(*ip_2_ip6(&(ipaddr))) : \
ip4_addr_isany_val(*ip_2_ip4(&(ipaddr))))
@ -137,24 +143,24 @@ static ip4_addr_t* ip_2_ip4(const ip_addr_t *ipaddr)
0 : \
ip4_addr_isbroadcast(ip_2_ip4(ipaddr), netif))
#define ip_addr_ismulticast(ipaddr) ((IP_IS_V6(ipaddr)) ? \
ip6_addr_ismulticast(ip_2_ip6(ipaddr)) : \
ip4_addr_ismulticast(ip_2_ip4(ipaddr)))
ip6_addr_ismulticast(ip_2_ip6_c(ipaddr)) : \
ip4_addr_ismulticast(ip_2_ip4_c(ipaddr)))
#define ip_addr_isloopback(ipaddr) ((IP_IS_V6(ipaddr)) ? \
ip6_addr_isloopback(ip_2_ip6(ipaddr)) : \
ip4_addr_isloopback(ip_2_ip4(ipaddr)))
ip6_addr_isloopback(ip_2_ip6_c(ipaddr)) : \
ip4_addr_isloopback(ip_2_ip4_c(ipaddr)))
#define ip_addr_islinklocal(ipaddr) ((IP_IS_V6(ipaddr)) ? \
ip6_addr_islinklocal(ip_2_ip6(ipaddr)) : \
ip4_addr_islinklocal(ip_2_ip4(ipaddr)))
ip6_addr_islinklocal(ip_2_ip6_c(ipaddr)) : \
ip4_addr_islinklocal(ip_2_ip4_c(ipaddr)))
#define ip_addr_debug_print(debug, ipaddr) do { if(IP_IS_V6(ipaddr)) { \
ip6_addr_debug_print(debug, ip_2_ip6(ipaddr)); } else { \
ip4_addr_debug_print(debug, ip_2_ip4(ipaddr)); }}while(0)
ip6_addr_debug_print(debug, ip_2_ip6_c(ipaddr)); } else { \
ip4_addr_debug_print(debug, ip_2_ip4_c(ipaddr)); }}while(0)
#define ip_addr_debug_print_val(debug, ipaddr) do { if(IP_IS_V6_VAL(ipaddr)) { \
ip6_addr_debug_print_val(debug, *ip_2_ip6(&(ipaddr))); } else { \
ip4_addr_debug_print_val(debug, *ip_2_ip4(&(ipaddr))); }}while(0)
ip6_addr_debug_print_val(debug, *ip_2_ip6_c(&(ipaddr))); } else { \
ip4_addr_debug_print_val(debug, *ip_2_ip4_c(&(ipaddr))); }}while(0)
#define ipaddr_ntoa(addr) (((addr) == NULL) ? "NULL" : \
((IP_IS_V6(addr)) ? ip6addr_ntoa(ip_2_ip6(addr)) : ip4addr_ntoa(ip_2_ip4(addr))))
((IP_IS_V6(addr)) ? ip6addr_ntoa(ip_2_ip6_c(addr)) : ip4addr_ntoa(ip_2_ip4_c(addr))))
#define ipaddr_ntoa_r(addr, buf, buflen) (((addr) == NULL) ? "NULL" : \
((IP_IS_V6(addr)) ? ip6addr_ntoa_r(ip_2_ip6(addr), buf, buflen) : ip4addr_ntoa_r(ip_2_ip4(addr), buf, buflen)))
((IP_IS_V6(addr)) ? ip6addr_ntoa_r(ip_2_ip6_c(addr), buf, buflen) : ip4addr_ntoa_r(ip_2_ip4_c(addr), buf, buflen)))
int ipaddr_aton(const char *cp, ip_addr_t *addr);
#else /* LWIP_IPV4 && LWIP_IPV6 */
@ -171,6 +177,7 @@ typedef ip4_addr_t ip_addr_t;
#define IP_SET_TYPE(ipaddr, iptype)
#define ip4_2_ip(ipaddr, unused) (ipaddr)
#define ip_2_ip4(ipaddr) (ipaddr)
#define ip_2_ip4_c(ipaddr) (ipaddr)
#define IP_ADDR4(ipaddr,a,b,c,d) IP4_ADDR(ipaddr,a,b,c,d)
#define ip_addr_copy(dest, src) ip4_addr_copy(dest, src)
@ -201,13 +208,14 @@ typedef ip4_addr_t ip_addr_t;
#else /* LWIP_IPV4 */
typedef ip6_addr_t ip_addr_t;
#define IPADDR6_INIT(a, b, c, d) { a, b, c, d }
#define IPADDR6_INIT(a, b, c, d) { { a, b, c, d } }
#define IP_IS_V6_VAL(ipaddr) 1
#define IP_IS_V6(ipaddr) 1
#define IP_SET_TYPE_VAL(ipaddr, iptype)
#define IP_SET_TYPE(ipaddr, iptype)
#define ip6_2_ip(ipaddr, unused) (ipaddr)
#define ip_2_ip6(ipaddr) (ipaddr)
#define ip_2_ip6_c(ipaddr) (ipaddr)
#define IP_ADDR6(ipaddr,idx,a,b,c,d) IP6_ADDR(ipaddr,idx,a,b,c,d)
#define ip_addr_copy(dest, src) ip6_addr_copy(dest, src)
@ -250,8 +258,8 @@ extern const ip_addr_t ip_addr_broadcast;
/** IP4_ADDR_ can be used as a fixed/const ip4_addr_t
* for the wildcard and the broadcast address
*/
#define IP4_ADDR_ANY (ip_2_ip4(&ip_addr_any))
#define IP4_ADDR_BROADCAST (ip_2_ip4(&ip_addr_broadcast))
#define IP4_ADDR_ANY (ip_2_ip4_c(&ip_addr_any))
#define IP4_ADDR_BROADCAST (ip_2_ip4_c(&ip_addr_broadcast))
#endif /* LWIP_IPV4*/
@ -266,7 +274,7 @@ extern const ip_addr_t ip6_addr_any;
/** IP6_ADDR_ANY6 can be used as a fixed ip6_addr_t
* for the IPv6 wildcard address
*/
#define IP6_ADDR_ANY6 (ip_2_ip6(&ip6_addr_any))
#define IP6_ADDR_ANY6 (ip_2_ip6_c(&ip6_addr_any))
#if !LWIP_IPV4
/** Just a little upgrade-helper for IPv6-only configurations: */

View File

@ -1086,12 +1086,12 @@ int cdns(ppp_pcb *pcb, u32_t ns1, u32_t ns2) {
nsa = dns_getserver(0);
ip_addr_set_ip4_u32(&nsb, ns1);
if (ip_addr_cmp(&nsa, &nsb)) {
dns_setserver(0, (ip_addr_t*)IP_ADDR_ANY);
dns_setserver(0, IP_ADDR_ANY);
}
nsa = dns_getserver(1);
ip_addr_set_ip4_u32(&nsb, ns2);
if (ip_addr_cmp(&nsa, &nsb)) {
dns_setserver(1, (ip_addr_t*)IP_ADDR_ANY);
dns_setserver(1, IP_ADDR_ANY);
}
return 1;
}