mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-08-24 23:25:58 +00:00
Added some macros with extension "_val" that work on actual instances and leave away the "if != NULL" check to get rid of gcc "-Waddress" warnings in the core code at least (I might not have caught all of them, yet)
This commit is contained in:
parent
a81c7bf04b
commit
beabd3c6b7
|
@ -543,7 +543,7 @@ lwip_accept(int s, struct sockaddr *addr, socklen_t *addrlen)
|
|||
LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_accept(%d) returning new sock=%d", s, newsock));
|
||||
if (addr != NULL) {
|
||||
LWIP_DEBUGF(SOCKETS_DEBUG, (" addr="));
|
||||
ip_addr_debug_print(SOCKETS_DEBUG, &naddr);
|
||||
ip_addr_debug_print_val(SOCKETS_DEBUG, naddr);
|
||||
LWIP_DEBUGF(SOCKETS_DEBUG, (" port=%"U16_F"\n", port));
|
||||
}
|
||||
|
||||
|
@ -578,7 +578,7 @@ lwip_bind(int s, const struct sockaddr *name, socklen_t namelen)
|
|||
|
||||
SOCKADDR_TO_IPADDR_PORT(name, &local_addr, local_port);
|
||||
LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_bind(%d, addr=", s));
|
||||
ip_addr_debug_print(SOCKETS_DEBUG, &local_addr);
|
||||
ip_addr_debug_print_val(SOCKETS_DEBUG, local_addr);
|
||||
LWIP_DEBUGF(SOCKETS_DEBUG, (" port=%"U16_F")\n", local_port));
|
||||
|
||||
err = netconn_bind(sock->conn, &local_addr, local_port);
|
||||
|
@ -662,7 +662,7 @@ lwip_connect(int s, const struct sockaddr *name, socklen_t namelen)
|
|||
|
||||
SOCKADDR_TO_IPADDR_PORT(name, &remote_addr, remote_port);
|
||||
LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_connect(%d, addr=", s));
|
||||
ip_addr_debug_print(SOCKETS_DEBUG, &remote_addr);
|
||||
ip_addr_debug_print_val(SOCKETS_DEBUG, remote_addr);
|
||||
LWIP_DEBUGF(SOCKETS_DEBUG, (" port=%"U16_F")\n", remote_port));
|
||||
|
||||
err = netconn_connect(sock->conn, &remote_addr, remote_port);
|
||||
|
@ -1147,19 +1147,19 @@ lwip_selscan(int maxfdp1, fd_set *readset_in, fd_set *writeset_in, fd_set *excep
|
|||
/* ... then examine it: */
|
||||
/* See if netconn of this socket is ready for read */
|
||||
if (readset_in && FD_ISSET(i, readset_in) && ((lastdata != NULL) || (rcvevent > 0))) {
|
||||
FD_SET(i, &lreadset);
|
||||
FD_SET_VAL(i, lreadset);
|
||||
LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_selscan: fd=%d ready for reading\n", i));
|
||||
nready++;
|
||||
}
|
||||
/* See if netconn of this socket is ready for write */
|
||||
if (writeset_in && FD_ISSET(i, writeset_in) && (sendevent != 0)) {
|
||||
FD_SET(i, &lwriteset);
|
||||
FD_SET_VAL(i, lwriteset);
|
||||
LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_selscan: fd=%d ready for writing\n", i));
|
||||
nready++;
|
||||
}
|
||||
/* See if netconn of this socket had an error */
|
||||
if (exceptset_in && FD_ISSET(i, exceptset_in) && (errevent != 0)) {
|
||||
FD_SET(i, &lexceptset);
|
||||
FD_SET_VAL(i, lexceptset);
|
||||
LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_selscan: fd=%d ready for exception\n", i));
|
||||
nready++;
|
||||
}
|
||||
|
@ -1550,7 +1550,7 @@ lwip_getaddrname(int s, struct sockaddr *name, socklen_t *namelen, u8_t local)
|
|||
IPADDR_PORT_TO_SOCKADDR(&saddr, &naddr, port);
|
||||
|
||||
LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getaddrname(%d, addr=", s));
|
||||
ip_addr_debug_print(SOCKETS_DEBUG, &naddr);
|
||||
ip_addr_debug_print_val(SOCKETS_DEBUG, naddr);
|
||||
LWIP_DEBUGF(SOCKETS_DEBUG, (" port=%"U16_F")\n", port));
|
||||
|
||||
if (*namelen > saddr.sa.sa_len) {
|
||||
|
|
|
@ -199,7 +199,7 @@ tcpip_input(struct pbuf *p, struct netif *inp)
|
|||
#else /* LWIP_TCPIP_CORE_LOCKING_INPUT */
|
||||
struct tcpip_msg *msg;
|
||||
|
||||
if (!sys_mbox_valid(&mbox)) {
|
||||
if (!sys_mbox_valid_val(mbox)) {
|
||||
return ERR_VAL;
|
||||
}
|
||||
msg = (struct tcpip_msg *)memp_malloc(MEMP_TCPIP_MSG_INPKT);
|
||||
|
@ -240,7 +240,7 @@ tcpip_pppos_input(struct pbuf *p, struct netif *inp)
|
|||
#else /* LWIP_TCPIP_CORE_LOCKING_INPUT */
|
||||
struct tcpip_msg *msg;
|
||||
|
||||
if (!sys_mbox_valid(&mbox)) {
|
||||
if (!sys_mbox_valid_val(mbox)) {
|
||||
return ERR_VAL;
|
||||
}
|
||||
msg = (struct tcpip_msg *)memp_malloc(MEMP_TCPIP_MSG_INPKT);
|
||||
|
@ -276,7 +276,7 @@ tcpip_callback_with_block(tcpip_callback_fn function, void *ctx, u8_t block)
|
|||
{
|
||||
struct tcpip_msg *msg;
|
||||
|
||||
if (sys_mbox_valid(&mbox)) {
|
||||
if (sys_mbox_valid_val(mbox)) {
|
||||
msg = (struct tcpip_msg *)memp_malloc(MEMP_TCPIP_MSG_API);
|
||||
if (msg == NULL) {
|
||||
return ERR_MEM;
|
||||
|
@ -312,7 +312,7 @@ tcpip_timeout(u32_t msecs, sys_timeout_handler h, void *arg)
|
|||
{
|
||||
struct tcpip_msg *msg;
|
||||
|
||||
if (sys_mbox_valid(&mbox)) {
|
||||
if (sys_mbox_valid_val(mbox)) {
|
||||
msg = (struct tcpip_msg *)memp_malloc(MEMP_TCPIP_MSG_API);
|
||||
if (msg == NULL) {
|
||||
return ERR_MEM;
|
||||
|
@ -341,7 +341,7 @@ tcpip_untimeout(sys_timeout_handler h, void *arg)
|
|||
{
|
||||
struct tcpip_msg *msg;
|
||||
|
||||
if (sys_mbox_valid(&mbox)) {
|
||||
if (sys_mbox_valid_val(mbox)) {
|
||||
msg = (struct tcpip_msg *)memp_malloc(MEMP_TCPIP_MSG_API);
|
||||
if (msg == NULL) {
|
||||
return ERR_MEM;
|
||||
|
@ -375,7 +375,7 @@ tcpip_apimsg(struct api_msg *apimsg)
|
|||
apimsg->msg.err = ERR_VAL;
|
||||
#endif
|
||||
|
||||
if (sys_mbox_valid(&mbox)) {
|
||||
if (sys_mbox_valid_val(mbox)) {
|
||||
TCPIP_MSG_VAR_ALLOC(msg);
|
||||
TCPIP_MSG_VAR_REF(msg).type = TCPIP_MSG_API;
|
||||
TCPIP_MSG_VAR_REF(msg).msg.apimsg = apimsg;
|
||||
|
@ -408,7 +408,7 @@ tcpip_netifapi(struct netifapi_msg* netifapimsg)
|
|||
{
|
||||
TCPIP_MSG_VAR_DECLARE(msg);
|
||||
|
||||
if (sys_mbox_valid(&mbox)) {
|
||||
if (sys_mbox_valid_val(mbox)) {
|
||||
err_t err;
|
||||
TCPIP_MSG_VAR_ALLOC(msg);
|
||||
|
||||
|
@ -462,7 +462,7 @@ tcpip_pppapi(struct pppapi_msg* pppapimsg)
|
|||
{
|
||||
struct tcpip_msg msg;
|
||||
|
||||
if (sys_mbox_valid(&mbox)) {
|
||||
if (sys_mbox_valid_val(mbox)) {
|
||||
err_t err = sys_sem_new(&pppapimsg->msg.sem, 0);
|
||||
if (err != ERR_OK) {
|
||||
pppapimsg->msg.err = err;
|
||||
|
@ -538,7 +538,7 @@ void tcpip_callbackmsg_delete(struct tcpip_callback_msg* msg)
|
|||
err_t
|
||||
tcpip_trycallback(struct tcpip_callback_msg* msg)
|
||||
{
|
||||
if (!sys_mbox_valid(&mbox)) {
|
||||
if (!sys_mbox_valid_val(mbox)) {
|
||||
return ERR_VAL;
|
||||
}
|
||||
return sys_mbox_trypost(&mbox, msg);
|
||||
|
|
|
@ -1037,7 +1037,7 @@ dhcp_bind(struct netif *netif)
|
|||
|
||||
ip4_addr_copy(gw_addr, dhcp->offered_gw_addr);
|
||||
/* gateway address not given? */
|
||||
if (ip4_addr_isany(&gw_addr)) {
|
||||
if (ip4_addr_isany_val(gw_addr)) {
|
||||
/* copy network address */
|
||||
ip4_addr_get_network(&gw_addr, &dhcp->offered_ip_addr, &sn_mask);
|
||||
/* use first host address on network as gateway */
|
||||
|
|
|
@ -308,9 +308,9 @@ icmp_send_response(struct pbuf *p, u8_t type, u8_t code)
|
|||
|
||||
iphdr = (struct ip_hdr *)p->payload;
|
||||
LWIP_DEBUGF(ICMP_DEBUG, ("icmp_time_exceeded from "));
|
||||
ip4_addr_debug_print(ICMP_DEBUG, &(iphdr->src));
|
||||
ip4_addr_debug_print_val(ICMP_DEBUG, iphdr->src);
|
||||
LWIP_DEBUGF(ICMP_DEBUG, (" to "));
|
||||
ip4_addr_debug_print(ICMP_DEBUG, &(iphdr->dest));
|
||||
ip4_addr_debug_print_val(ICMP_DEBUG, iphdr->dest);
|
||||
LWIP_DEBUGF(ICMP_DEBUG, ("\n"));
|
||||
|
||||
icmphdr = (struct icmp_echo_hdr *)q->payload;
|
||||
|
|
|
@ -1421,7 +1421,7 @@ void snmp_insert_iprteidx_tree(u8_t dflt, struct netif *ni)
|
|||
/* route to the network address */
|
||||
ip4_addr_get_network(&dst, &ni->ip_addr, &ni->netmask);
|
||||
/* exclude 0.0.0.0 network (reserved for default rte) */
|
||||
if (!ip4_addr_isany(&dst)) {
|
||||
if (!ip4_addr_isany_val(dst)) {
|
||||
insert = 1;
|
||||
}
|
||||
}
|
||||
|
@ -1498,7 +1498,7 @@ void snmp_delete_iprteidx_tree(u8_t dflt, struct netif *ni)
|
|||
/* route to the network address */
|
||||
ip4_addr_get_network(&dst, &ni->ip_addr, &ni->netmask);
|
||||
/* exclude 0.0.0.0 network (reserved for default rte) */
|
||||
if (!ip4_addr_isany(&dst)) {
|
||||
if (!ip4_addr_isany_val(dst)) {
|
||||
del = 1;
|
||||
}
|
||||
}
|
||||
|
@ -3219,7 +3219,7 @@ ip_rteentry_get_value(struct obj_def *od, u16_t len, void *value)
|
|||
ident = od->id_inst_ptr;
|
||||
snmp_oidtoip(&ident[1], &dest);
|
||||
|
||||
if (ip4_addr_isany(&dest))
|
||||
if (ip4_addr_isany_val(dest))
|
||||
{
|
||||
/* ip_route() uses default netif for default route */
|
||||
netif = netif_default;
|
||||
|
@ -3244,7 +3244,7 @@ ip_rteentry_get_value(struct obj_def *od, u16_t len, void *value)
|
|||
{
|
||||
ip4_addr_t *dst = (ip4_addr_t*)value;
|
||||
|
||||
if (ip4_addr_isany(&dest))
|
||||
if (ip4_addr_isany_val(dest))
|
||||
{
|
||||
/* default rte has 0.0.0.0 dest */
|
||||
ip4_addr_set_zero(dst);
|
||||
|
@ -3267,7 +3267,7 @@ ip_rteentry_get_value(struct obj_def *od, u16_t len, void *value)
|
|||
{
|
||||
s32_t *sint_ptr = (s32_t*)value;
|
||||
|
||||
if (ip4_addr_isany(&dest))
|
||||
if (ip4_addr_isany_val(dest))
|
||||
{
|
||||
/* default rte has metric 1 */
|
||||
*sint_ptr = 1;
|
||||
|
@ -3293,7 +3293,7 @@ ip_rteentry_get_value(struct obj_def *od, u16_t len, void *value)
|
|||
{
|
||||
ip4_addr_t *dst = (ip4_addr_t*)value;
|
||||
|
||||
if (ip4_addr_isany(&dest))
|
||||
if (ip4_addr_isany_val(dest))
|
||||
{
|
||||
/* default rte: gateway */
|
||||
*dst = netif->gw;
|
||||
|
@ -3309,7 +3309,7 @@ ip_rteentry_get_value(struct obj_def *od, u16_t len, void *value)
|
|||
{
|
||||
s32_t *sint_ptr = (s32_t*)value;
|
||||
|
||||
if (ip4_addr_isany(&dest))
|
||||
if (ip4_addr_isany_val(dest))
|
||||
{
|
||||
/* default rte is indirect */
|
||||
*sint_ptr = 4;
|
||||
|
@ -3340,7 +3340,7 @@ ip_rteentry_get_value(struct obj_def *od, u16_t len, void *value)
|
|||
{
|
||||
ip4_addr_t *dst = (ip4_addr_t*)value;
|
||||
|
||||
if (ip4_addr_isany(&dest))
|
||||
if (ip4_addr_isany_val(dest))
|
||||
{
|
||||
/* default rte use 0.0.0.0 mask */
|
||||
ip4_addr_set_zero(dst);
|
||||
|
|
|
@ -244,7 +244,7 @@ snmp_send_trap(s8_t generic_trap, const struct snmp_obj_id *eoid, s32_t specific
|
|||
ip_route_get_local_ip(PCB_ISIPV6(trap_msg.pcb), &trap_msg.pcb->local_ip,
|
||||
&td->dip, dst_if, dst_ip, &dst_ip_storage);
|
||||
if ((dst_if != NULL) && (dst_ip != NULL)) {
|
||||
trap_msg.sip_raw_len = (IP_IS_V6_L(dst_ip) ? 16 : 4);
|
||||
trap_msg.sip_raw_len = (IP_IS_V6_VAL(dst_ip) ? 16 : 4);
|
||||
memcpy(trap_msg.sip_raw, dst_ip, trap_msg.sip_raw_len);
|
||||
trap_msg.gen_trap = generic_trap;
|
||||
trap_msg.spc_trap = specific_trap;
|
||||
|
|
|
@ -1845,7 +1845,7 @@ tcp_netif_ipv4_addr_changed_pcblist(const ip4_addr_t* old_addr, struct tcp_pcb*
|
|||
pcb = pcb_list;
|
||||
while (pcb != NULL) {
|
||||
/* PCB bound to current local interface address? */
|
||||
if (!IP_IS_V6_L(&pcb->local_ip) && ip4_addr_cmp(ip_2_ip4(&pcb->local_ip), old_addr)
|
||||
if (!IP_IS_V6_VAL(&pcb->local_ip) && ip4_addr_cmp(ip_2_ip4(&pcb->local_ip), old_addr)
|
||||
#if LWIP_AUTOIP
|
||||
/* connections to link-local addresses must persist (RFC3927 ch. 1.9) */
|
||||
&& !ip4_addr_islinklocal(ip_2_ip4(&pcb->local_ip))
|
||||
|
@ -1879,7 +1879,7 @@ void tcp_netif_ipv4_addr_changed(const ip4_addr_t* old_addr, const ip4_addr_t* n
|
|||
for (lpcb = tcp_listen_pcbs.listen_pcbs; lpcb != NULL; lpcb = next) {
|
||||
next = lpcb->next;
|
||||
/* Is this an IPv4 pcb? */
|
||||
if (!IP_IS_V6_L(&lpcb->local_ip)) {
|
||||
if (!IP_IS_V6_VAL(&lpcb->local_ip)) {
|
||||
/* PCB bound to current local interface address? */
|
||||
if ((!(ip4_addr_isany(ip_2_ip4(&lpcb->local_ip)))) &&
|
||||
(ip4_addr_cmp(ip_2_ip4(&lpcb->local_ip), old_addr))) {
|
||||
|
|
|
@ -1161,7 +1161,7 @@ void udp_netif_ipv4_addr_changed(const ip4_addr_t* old_addr, const ip4_addr_t* n
|
|||
if (!ip4_addr_isany(new_addr)) {
|
||||
for (upcb = udp_pcbs; upcb != NULL; upcb = upcb->next) {
|
||||
/* Is this an IPv4 pcb? */
|
||||
if (!IP_IS_V6_L(&upcb->local_ip)) {
|
||||
if (!IP_IS_V6_VAL(&upcb->local_ip)) {
|
||||
/* PCB bound to current local interface address? */
|
||||
if (!ip4_addr_isany(ip_2_ip4(&upcb->local_ip)) &&
|
||||
ip4_addr_cmp(ip_2_ip4(&upcb->local_ip), old_addr)) {
|
||||
|
|
|
@ -192,7 +192,8 @@ struct netif;
|
|||
(mask)->addr))
|
||||
#define ip4_addr_cmp(addr1, addr2) ((addr1)->addr == (addr2)->addr)
|
||||
|
||||
#define ip4_addr_isany(addr1) ((addr1) == NULL || (addr1)->addr == IPADDR_ANY)
|
||||
#define ip4_addr_isany_val(addr1) ((addr1).addr == IPADDR_ANY)
|
||||
#define ip4_addr_isany(addr1) ((addr1) == NULL || ip4_addr_isany_val(*(addr1)))
|
||||
|
||||
#define ip4_addr_isbroadcast(addr1, netif) ip4_addr_isbroadcast_u32((addr1)->addr, netif)
|
||||
u8_t ip4_addr_isbroadcast_u32(u32_t addr, const struct netif *netif);
|
||||
|
@ -204,12 +205,20 @@ u8_t ip4_addr_netmask_valid(u32_t netmask);
|
|||
|
||||
#define ip4_addr_islinklocal(addr1) (((addr1)->addr & PP_HTONL(0xffff0000UL)) == PP_HTONL(0xa9fe0000UL))
|
||||
|
||||
#define ip4_addr_debug_print_parts(debug, a, b, c, d) \
|
||||
LWIP_DEBUGF(debug, ("%" U16_F ".%" U16_F ".%" U16_F ".%" U16_F, a, b, c, d))
|
||||
#define ip4_addr_debug_print(debug, ipaddr) \
|
||||
LWIP_DEBUGF(debug, ("%" U16_F ".%" U16_F ".%" U16_F ".%" U16_F, \
|
||||
ip4_addr_debug_print_parts(debug, \
|
||||
ipaddr != NULL ? ip4_addr1_16(ipaddr) : 0, \
|
||||
ipaddr != NULL ? ip4_addr2_16(ipaddr) : 0, \
|
||||
ipaddr != NULL ? ip4_addr3_16(ipaddr) : 0, \
|
||||
ipaddr != NULL ? ip4_addr4_16(ipaddr) : 0))
|
||||
ipaddr != NULL ? ip4_addr4_16(ipaddr) : 0)
|
||||
#define ip4_addr_debug_print_val(debug, ipaddr) \
|
||||
ip4_addr_debug_print_parts(debug, \
|
||||
ip4_addr1_16(&(ipaddr)), \
|
||||
ip4_addr2_16(&(ipaddr)), \
|
||||
ip4_addr3_16(&(ipaddr)), \
|
||||
ip4_addr4_16(&(ipaddr)))
|
||||
|
||||
/* Get one byte from the 4-byte address */
|
||||
#define ip4_addr1(ipaddr) (((const u8_t*)(ipaddr))[0])
|
||||
|
|
|
@ -152,11 +152,11 @@ Little-endian version, stored in network order (no htonl). */
|
|||
|
||||
#define ip6_get_subnet_id(ip6addr) (htonl((ip6addr)->addr[2]) & 0x0000ffffUL)
|
||||
|
||||
#define ip6_addr_isany(ip6addr) (((ip6addr) == NULL) || \
|
||||
(((ip6addr)->addr[0] == 0) && \
|
||||
((ip6addr)->addr[1] == 0) && \
|
||||
((ip6addr)->addr[2] == 0) && \
|
||||
((ip6addr)->addr[3] == 0)))
|
||||
#define ip6_addr_isany_val(ip6addr) (((ip6addr).addr[0] == 0) && \
|
||||
((ip6addr).addr[1] == 0) && \
|
||||
((ip6addr).addr[2] == 0) && \
|
||||
((ip6addr).addr[3] == 0))
|
||||
#define ip6_addr_isany(ip6addr) (((ip6addr) == NULL) || ip6_addr_isany_val(*(ip6addr)))
|
||||
|
||||
#define ip6_addr_isloopback(ip6addr) (((ip6addr)->addr[0] == 0UL) && \
|
||||
((ip6addr)->addr[1] == 0UL) && \
|
||||
|
@ -251,8 +251,11 @@ Little-endian version, stored in network order (no htonl). */
|
|||
#define ip6_addr_ispreferred(addr_state) (addr_state == IP6_ADDR_PREFERRED)
|
||||
#define ip6_addr_isdeprecated(addr_state) (addr_state == IP6_ADDR_DEPRECATED)
|
||||
|
||||
#define ip6_addr_debug_print(debug, ipaddr) \
|
||||
#define ip6_addr_debug_print_parts(debug, ipaddr) \
|
||||
LWIP_DEBUGF(debug, ("%" X16_F ":%" X16_F ":%" X16_F ":%" X16_F ":%" X16_F ":%" X16_F ":%" X16_F ":%" X16_F, \
|
||||
a, b, c, d, e, f, g, h))
|
||||
#define ip6_addr_debug_print(debug, ipaddr) \
|
||||
ip6_addr_debug_print_parts(debug, \
|
||||
ipaddr != NULL ? IP6_ADDR_BLOCK1(ipaddr) : 0, \
|
||||
ipaddr != NULL ? IP6_ADDR_BLOCK2(ipaddr) : 0, \
|
||||
ipaddr != NULL ? IP6_ADDR_BLOCK3(ipaddr) : 0, \
|
||||
|
@ -260,7 +263,17 @@ Little-endian version, stored in network order (no htonl). */
|
|||
ipaddr != NULL ? IP6_ADDR_BLOCK5(ipaddr) : 0, \
|
||||
ipaddr != NULL ? IP6_ADDR_BLOCK6(ipaddr) : 0, \
|
||||
ipaddr != NULL ? IP6_ADDR_BLOCK7(ipaddr) : 0, \
|
||||
ipaddr != NULL ? IP6_ADDR_BLOCK8(ipaddr) : 0))
|
||||
ipaddr != NULL ? IP6_ADDR_BLOCK8(ipaddr) : 0)
|
||||
#define ip6_addr_debug_print_val(debug, ipaddr) \
|
||||
ip6_addr_debug_print_parts(debug, \
|
||||
IP6_ADDR_BLOCK1(&(ipaddr)), \
|
||||
IP6_ADDR_BLOCK2(&(ipaddr)), \
|
||||
IP6_ADDR_BLOCK3(&(ipaddr)), \
|
||||
IP6_ADDR_BLOCK4(&(ipaddr)), \
|
||||
IP6_ADDR_BLOCK5(&(ipaddr)), \
|
||||
IP6_ADDR_BLOCK6(&(ipaddr)), \
|
||||
IP6_ADDR_BLOCK7(&(ipaddr)), \
|
||||
IP6_ADDR_BLOCK8(&(ipaddr)))
|
||||
|
||||
#define IP6ADDR_STRLEN_MAX 46
|
||||
|
||||
|
|
|
@ -61,12 +61,12 @@ typedef struct _ip_addr {
|
|||
#define IPADDR4_INIT(u32val) { { { u32val, 0ul, 0ul, 0ul } }, IPADDR_TYPE_V4 }
|
||||
#define IPADDR6_INIT(a, b, c, d) { { { a, b, c, d } }, IPADDR_TYPE_V6 }
|
||||
|
||||
#define IP_IS_V6_L(ipaddr) ((ipaddr)->type == IPADDR_TYPE_V6)
|
||||
#define IP_IS_V6(ipaddr) (((ipaddr) != NULL) && IP_IS_V6_L(ipaddr))
|
||||
#define IP_IS_V6_VAL(ipaddr) ((ipaddr)->type == IPADDR_TYPE_V6)
|
||||
#define IP_IS_V6(ipaddr) (((ipaddr) != NULL) && IP_IS_V6_VAL(ipaddr))
|
||||
#define IP_SET_TYPE_L(ipaddr, iptype) do { (ipaddr)->type = (iptype); }while(0)
|
||||
#define IP_SET_TYPE(ipaddr, iptype) do { if((ipaddr) != NULL) { IP_SET_TYPE_L(ipaddr, iptype); }}while(0)
|
||||
|
||||
#define IP_ADDR_PCB_VERSION_MATCH(pcb, ipaddr) (PCB_ISIPV6(pcb) == IP_IS_V6_L(ipaddr))
|
||||
#define IP_ADDR_PCB_VERSION_MATCH(pcb, ipaddr) (PCB_ISIPV6(pcb) == IP_IS_V6_VAL(ipaddr))
|
||||
|
||||
/* Convert ipv4/ipv6 address to generic ip address.
|
||||
Since source types do not contain the type field, a target storage need to be supplied. */
|
||||
|
@ -88,7 +88,7 @@ static ip4_addr_t* ip_2_ip4(const ip_addr_t *ipaddr)
|
|||
#define IP_ADDR6(ipaddr,idx,a,b,c,d) do { IP6_ADDR(ip_2_ip6(ipaddr),idx,a,b,c,d); \
|
||||
IP_SET_TYPE_L(ipaddr, IPADDR_TYPE_V6); } while(0)
|
||||
|
||||
#define ip_addr_copy(dest, src) do{if(IP_IS_V6_L(&(src))){ \
|
||||
#define ip_addr_copy(dest, src) do{if(IP_IS_V6_VAL(&(src))){ \
|
||||
ip6_addr_copy(*ip_2_ip6(&(dest)), *ip_2_ip6(&(src))); IP_SET_TYPE_L(&(dest), IPADDR_TYPE_V6); }else{ \
|
||||
ip4_addr_copy(*ip_2_ip4(&(dest)), *ip_2_ip4(&(src))); IP_SET_TYPE_L(&(dest), IPADDR_TYPE_V4); }}while(0)
|
||||
#define ip_addr_copy_from_ip6(dest, src) do{ \
|
||||
|
@ -128,6 +128,9 @@ static ip4_addr_t* ip_2_ip4(const ip_addr_t *ipaddr)
|
|||
#define ip_addr_isany(ipaddr) ((IP_IS_V6(ipaddr)) ? \
|
||||
ip6_addr_isany(ip_2_ip6(ipaddr)) : \
|
||||
ip4_addr_isany(ip_2_ip4(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))))
|
||||
#define ip_addr_isbroadcast(ipaddr, netif) ((IP_IS_V6(ipaddr)) ? \
|
||||
0 : \
|
||||
ip4_addr_isbroadcast(ip_2_ip4(ipaddr), netif))
|
||||
|
@ -143,6 +146,9 @@ static ip4_addr_t* ip_2_ip4(const ip_addr_t *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)
|
||||
#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)
|
||||
#define ipaddr_ntoa(addr) (((addr) == NULL) ? "NULL" : \
|
||||
((IP_IS_V6(addr)) ? ip6addr_ntoa(ip_2_ip6(addr)) : ip4addr_ntoa(ip_2_ip4(addr))))
|
||||
#define ipaddr_ntoa_r(addr, buf, buflen) (((addr) == NULL) ? "NULL" : \
|
||||
|
@ -157,7 +163,7 @@ int ipaddr_aton(const char *cp, ip_addr_t *addr);
|
|||
|
||||
typedef ip4_addr_t ip_addr_t;
|
||||
#define IPADDR4_INIT(u32val) { u32val }
|
||||
#define IP_IS_V6_L(ipaddr) 0
|
||||
#define IP_IS_V6_VAL(ipaddr) 0
|
||||
#define IP_IS_V6(ipaddr) 0
|
||||
#define IP_SET_TYPE_L(ipaddr, iptype)
|
||||
#define IP_SET_TYPE(ipaddr, iptype)
|
||||
|
@ -179,11 +185,13 @@ typedef ip4_addr_t ip_addr_t;
|
|||
#define ip_addr_netcmp(addr1, addr2, mask) ip4_addr_netcmp(addr1, addr2, mask)
|
||||
#define ip_addr_cmp(addr1, addr2) ip4_addr_cmp(addr1, addr2)
|
||||
#define ip_addr_isany(ipaddr) ip4_addr_isany(ipaddr)
|
||||
#define ip_addr_isany_val(ipaddr) ip4_addr_isany_val(ipaddr)
|
||||
#define ip_addr_isloopback(ipaddr) ip4_addr_isloopback(ipaddr)
|
||||
#define ip_addr_islinklocal(ipaddr) ip4_addr_islinklocal(ipaddr)
|
||||
#define ip_addr_isbroadcast(addr, netif) ip4_addr_isbroadcast(addr, netif)
|
||||
#define ip_addr_ismulticast(ipaddr) ip4_addr_ismulticast(ipaddr)
|
||||
#define ip_addr_debug_print(debug, ipaddr) ip4_addr_debug_print(debug, ipaddr)
|
||||
#define ip_addr_debug_print_val(debug, ipaddr) ip4_addr_debug_print_val(debug, ipaddr)
|
||||
#define ipaddr_ntoa(ipaddr) ip4addr_ntoa(ipaddr)
|
||||
#define ipaddr_ntoa_r(ipaddr, buf, buflen) ip4addr_ntoa_r(ipaddr, buf, buflen)
|
||||
#define ipaddr_aton(cp, addr) ip4addr_aton(cp, addr)
|
||||
|
@ -192,7 +200,7 @@ typedef ip4_addr_t ip_addr_t;
|
|||
|
||||
typedef ip6_addr_t ip_addr_t;
|
||||
#define IPADDR6_INIT(a, b, c, d) { a, b, c, d }
|
||||
#define IP_IS_V6_L(ipaddr) 1
|
||||
#define IP_IS_V6_VAL(ipaddr) 1
|
||||
#define IP_IS_V6(ipaddr) 1
|
||||
#define IP_SET_TYPE_L(ipaddr, iptype)
|
||||
#define IP_SET_TYPE(ipaddr, iptype)
|
||||
|
@ -212,11 +220,13 @@ typedef ip6_addr_t ip_addr_t;
|
|||
#define ip_addr_netcmp(addr1, addr2, mask) 0
|
||||
#define ip_addr_cmp(addr1, addr2) ip6_addr_cmp(addr1, addr2)
|
||||
#define ip_addr_isany(ipaddr) ip6_addr_isany(ipaddr)
|
||||
#define ip_addr_isany_val(ipaddr) ip6_addr_isany_val(ipaddr)
|
||||
#define ip_addr_isloopback(ipaddr) ip6_addr_isloopback(ipaddr)
|
||||
#define ip_addr_islinklocal(ipaddr) ip6_addr_islinklocal(ipaddr)
|
||||
#define ip_addr_isbroadcast(addr, netif) 0
|
||||
#define ip_addr_ismulticast(ipaddr) ip6_addr_ismulticast(ipaddr)
|
||||
#define ip_addr_debug_print(debug, ipaddr) ip6_addr_debug_print(debug, ipaddr)
|
||||
#define ip_addr_debug_print_val(debug, ipaddr) ip6_addr_debug_print_val(debug, ipaddr)
|
||||
#define ipaddr_ntoa(ipaddr) ip6addr_ntoa(ipaddr)
|
||||
#define ipaddr_ntoa_r(ipaddr, buf, buflen) ip6addr_ntoa_r(ipaddr, buf, buflen)
|
||||
#define ipaddr_aton(cp, addr) ip6addr_aton(cp, addr)
|
||||
|
|
|
@ -383,12 +383,15 @@ typedef struct ip_mreq {
|
|||
#undef FD_SETSIZE
|
||||
/* Make FD_SETSIZE match NUM_SOCKETS in socket.c */
|
||||
#define FD_SETSIZE MEMP_NUM_NETCONN
|
||||
#define FDSETSAFESET(n, p, code) do { \
|
||||
if(((p) != NULL) && ((n) - LWIP_SOCKET_OFFSET < MEMP_NUM_NETCONN) && (((int)(n) - LWIP_SOCKET_OFFSET) >= 0)) { \
|
||||
#define FDSETSAFESET_VAL(n, p, code) do { \
|
||||
if (((n) - LWIP_SOCKET_OFFSET < MEMP_NUM_NETCONN) && (((int)(n) - LWIP_SOCKET_OFFSET) >= 0)) { \
|
||||
code; }} while(0)
|
||||
#define FDSETSAFESET(n, p, code) do { \
|
||||
if ((p) != NULL) { FDSETSAFESET_VAR(n, p, code); }} while(0)
|
||||
#define FDSETSAFEGET(n, p, code) (((p) != NULL) && ((n) - LWIP_SOCKET_OFFSET < MEMP_NUM_NETCONN) && (((int)(n) - LWIP_SOCKET_OFFSET) >= 0) ?\
|
||||
(code) : 0)
|
||||
#define FD_SET(n, p) FDSETSAFESET(n, p, (p)->fd_bits[((n)-LWIP_SOCKET_OFFSET)/8] |= (1 << (((n)-LWIP_SOCKET_OFFSET) & 7)))
|
||||
#define FD_SET_VAL(n, p) FDSETSAFESET_VAL(n, &(p), (p).fd_bits[((n)-LWIP_SOCKET_OFFSET)/8] |= (1 << (((n)-LWIP_SOCKET_OFFSET) & 7)))
|
||||
#define FD_CLR(n, p) FDSETSAFESET(n, p, (p)->fd_bits[((n)-LWIP_SOCKET_OFFSET)/8] &= ~(1 << (((n)-LWIP_SOCKET_OFFSET) & 7)))
|
||||
#define FD_ISSET(n,p) FDSETSAFEGET(n, p, (p)->fd_bits[((n)-LWIP_SOCKET_OFFSET)/8] & (1 << (((n)-LWIP_SOCKET_OFFSET) & 7)))
|
||||
#define FD_ZERO(p) memset((void*)(p), 0, sizeof(*(p)))
|
||||
|
|
|
@ -52,7 +52,9 @@ typedef u8_t sys_mbox_t;
|
|||
#define sys_arch_sem_wait(s,t)
|
||||
#define sys_sem_free(s)
|
||||
#define sys_sem_valid(s) 0
|
||||
#define sys_sem_valid_val(s) 0
|
||||
#define sys_sem_set_invalid(s)
|
||||
#define sys_sem_set_invalid_val(s)
|
||||
#define sys_mutex_new(mu) ERR_OK
|
||||
#define sys_mutex_lock(mu)
|
||||
#define sys_mutex_unlock(mu)
|
||||
|
@ -66,7 +68,9 @@ typedef u8_t sys_mbox_t;
|
|||
#define sys_mbox_trypost(m,d)
|
||||
#define sys_mbox_free(m)
|
||||
#define sys_mbox_valid(m)
|
||||
#define sys_mbox_valid_val(m)
|
||||
#define sys_mbox_set_invalid(m)
|
||||
#define sys_mbox_set_invalid_val(m)
|
||||
|
||||
#define sys_thread_new(n,t,a,s,p)
|
||||
|
||||
|
@ -159,6 +163,14 @@ int sys_sem_valid(sys_sem_t *sem);
|
|||
/** Set a semaphore invalid so that sys_sem_valid returns 0 */
|
||||
void sys_sem_set_invalid(sys_sem_t *sem);
|
||||
#endif
|
||||
#ifndef sys_sem_valid_val
|
||||
/** Same as sys_sem_valid() but taking a value, not a pointer */
|
||||
#define sys_sem_valid_val(sem) sys_sem_valid(&(sem))
|
||||
#endif
|
||||
#ifndef sys_sem_set_invalid_val
|
||||
/** Same as sys_sem_set_invalid() but taking a value, not a pointer */
|
||||
#define sys_sem_set_invalid_val(sem) sys_sem_set_invalid(&(sem))
|
||||
#endif
|
||||
|
||||
/* Time functions. */
|
||||
#ifndef sys_msleep
|
||||
|
@ -212,6 +224,15 @@ int sys_mbox_valid(sys_mbox_t *mbox);
|
|||
/** Set an mbox invalid so that sys_mbox_valid returns 0 */
|
||||
void sys_mbox_set_invalid(sys_mbox_t *mbox);
|
||||
#endif
|
||||
#ifndef sys_mbox_valid_val
|
||||
/** Same as sys_mbox_valid() but taking a value, not a pointer */
|
||||
#define sys_mbox_valid_val(mbox) sys_mbox_valid(&(mbox))
|
||||
#endif
|
||||
#ifndef sys_mbox_set_invalid_val
|
||||
/** Same as sys_mbox_set_invalid() but taking a value, not a pointer */
|
||||
#define sys_mbox_set_invalid_val(mbox) sys_mbox_set_invalid(&(mbox))
|
||||
#endif
|
||||
|
||||
|
||||
/** The only thread function:
|
||||
* Creates a new thread
|
||||
|
|
Loading…
Reference in New Issue
Block a user