mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2025-04-15 23:42:33 +00:00
Applied patch #1596 fixing wrongly cast LWIP_DEBUGF arguments.
(printf expects integers on the var args stack)
This commit is contained in:
parent
af384440f8
commit
ba786dc49b
@ -1,8 +1,8 @@
|
||||
/*
|
||||
* Copyright (c) 2001-2003 Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
@ -11,21 +11,21 @@
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
* Improved by Marc Boucher <marc@mbsi.ca> and David Haas <dhaas@alum.rpi.edu>
|
||||
@ -51,7 +51,7 @@ struct lwip_socket {
|
||||
int err;
|
||||
};
|
||||
|
||||
struct lwip_select_cb
|
||||
struct lwip_select_cb
|
||||
{
|
||||
struct lwip_select_cb *next;
|
||||
fd_set *readset;
|
||||
@ -104,13 +104,13 @@ static struct lwip_socket *
|
||||
get_socket(int s)
|
||||
{
|
||||
struct lwip_socket *sock;
|
||||
|
||||
|
||||
if ((s < 0) || (s > NUM_SOCKETS)) {
|
||||
LWIP_DEBUGF(SOCKETS_DEBUG, ("get_socket(%d): invalid\n", s));
|
||||
set_errno(EBADF);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
sock = &sockets[s];
|
||||
|
||||
if (!sock->conn) {
|
||||
@ -132,7 +132,7 @@ alloc_socket(struct netconn *newconn)
|
||||
|
||||
/* Protect socket array */
|
||||
sys_sem_wait(socksem);
|
||||
|
||||
|
||||
/* allocate a new socket identifier */
|
||||
for(i = 0; i < NUM_SOCKETS; ++i) {
|
||||
if (!sockets[i].conn) {
|
||||
@ -166,12 +166,12 @@ lwip_accept(int s, struct sockaddr *addr, socklen_t *addrlen)
|
||||
if (!sock) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
newconn = netconn_accept(sock->conn);
|
||||
|
||||
|
||||
/* get the IP address and port of the remote host */
|
||||
netconn_peer(newconn, &naddr, &port);
|
||||
|
||||
|
||||
memset(&sin, 0, sizeof(sin));
|
||||
sin.sin_len = sizeof(sin);
|
||||
sin.sin_family = AF_INET;
|
||||
@ -184,14 +184,14 @@ lwip_accept(int s, struct sockaddr *addr, socklen_t *addrlen)
|
||||
memcpy(addr, &sin, *addrlen);
|
||||
|
||||
newsock = alloc_socket(newconn);
|
||||
if (newsock == -1) {
|
||||
if (newsock == -1) {
|
||||
netconn_delete(newconn);
|
||||
sock_set_errno(sock, ENOBUFS);
|
||||
return -1;
|
||||
}
|
||||
newconn->callback = event_callback;
|
||||
sock = get_socket(newsock);
|
||||
|
||||
|
||||
sys_sem_wait(socksem);
|
||||
sock->rcvevent += -1 - newconn->socket;
|
||||
newconn->socket = newsock;
|
||||
@ -199,10 +199,10 @@ lwip_accept(int s, struct sockaddr *addr, socklen_t *addrlen)
|
||||
|
||||
#if SOCKETS_DEBUG
|
||||
LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_accept(%d) returning new sock=%d addr=", s, newsock));
|
||||
ip_addr_debug_print(&naddr);
|
||||
ip_addr_debug_print(SOCKETS_DEBUG, &naddr);
|
||||
LWIP_DEBUGF(SOCKETS_DEBUG, (" port=%u\n", port));
|
||||
#endif
|
||||
|
||||
|
||||
sock_set_errno(sock, 0);
|
||||
return newsock;
|
||||
}
|
||||
@ -214,21 +214,21 @@ lwip_bind(int s, struct sockaddr *name, socklen_t namelen)
|
||||
struct ip_addr local_addr;
|
||||
u16_t local_port;
|
||||
err_t err;
|
||||
|
||||
|
||||
sock = get_socket(s);
|
||||
if (!sock) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
local_addr.addr = ((struct sockaddr_in *)name)->sin_addr.s_addr;
|
||||
local_port = ((struct sockaddr_in *)name)->sin_port;
|
||||
|
||||
#if SOCKETS_DEBUG
|
||||
LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_bind(%d, addr=", s));
|
||||
ip_addr_debug_print(&local_addr);
|
||||
ip_addr_debug_print(SOCKETS_DEBUG, &local_addr);
|
||||
LWIP_DEBUGF(SOCKETS_DEBUG, (" port=%u)\n", ntohs(local_port)));
|
||||
#endif
|
||||
|
||||
|
||||
err = netconn_bind(sock->conn, &local_addr, ntohs(local_port));
|
||||
|
||||
if (err != ERR_OK) {
|
||||
@ -246,20 +246,20 @@ int
|
||||
lwip_close(int s)
|
||||
{
|
||||
struct lwip_socket *sock;
|
||||
|
||||
|
||||
LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_close(%d)\n", s));
|
||||
if (!socksem)
|
||||
socksem = sys_sem_new(1);
|
||||
|
||||
/* We cannot allow multiple closes of the same socket. */
|
||||
sys_sem_wait(socksem);
|
||||
|
||||
|
||||
sock = get_socket(s);
|
||||
if (!sock) {
|
||||
sys_sem_signal(socksem);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
netconn_delete(sock->conn);
|
||||
if (sock->lastdata) {
|
||||
netbuf_delete(sock->lastdata);
|
||||
@ -282,7 +282,7 @@ lwip_connect(int s, struct sockaddr *name, socklen_t namelen)
|
||||
if (!sock) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
if (((struct sockaddr_in *)name)->sin_family == AF_UNSPEC) {
|
||||
LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_connect(%d, AF_UNSPEC)\n", s));
|
||||
err = netconn_disconnect(sock->conn);
|
||||
@ -295,10 +295,10 @@ lwip_connect(int s, struct sockaddr *name, socklen_t namelen)
|
||||
|
||||
#if SOCKETS_DEBUG
|
||||
LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_connect(%d, addr=", s));
|
||||
ip_addr_debug_print(&remote_addr);
|
||||
ip_addr_debug_print(SOCKETS_DEBUG, &remote_addr);
|
||||
LWIP_DEBUGF(SOCKETS_DEBUG, (" port=%u)\n", ntohs(remote_port)));
|
||||
#endif
|
||||
|
||||
|
||||
err = netconn_connect(sock->conn, &remote_addr, ntohs(remote_port));
|
||||
}
|
||||
|
||||
@ -316,15 +316,15 @@ lwip_connect(int s, struct sockaddr *name, socklen_t namelen)
|
||||
int
|
||||
lwip_listen(int s, int backlog)
|
||||
{
|
||||
struct lwip_socket *sock;
|
||||
struct lwip_socket *sock;
|
||||
err_t err;
|
||||
|
||||
|
||||
LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_listen(%d, backlog=%d)\n", s, backlog));
|
||||
sock = get_socket(s);
|
||||
if (!sock) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
err = netconn_listen(sock->conn);
|
||||
|
||||
if (err != ERR_OK) {
|
||||
@ -347,7 +347,7 @@ lwip_recvfrom(int s, void *mem, int len, unsigned int flags,
|
||||
struct ip_addr *addr;
|
||||
u16_t port;
|
||||
|
||||
|
||||
|
||||
LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_recvfrom(%d, %p, %d, 0x%x, ..)\n", s, mem, len, flags));
|
||||
sock = get_socket(s);
|
||||
if (!sock) {
|
||||
@ -355,7 +355,7 @@ lwip_recvfrom(int s, void *mem, int len, unsigned int flags,
|
||||
}
|
||||
|
||||
/* Check if there is data left from the last recv operation. */
|
||||
if (sock->lastdata) {
|
||||
if (sock->lastdata) {
|
||||
buf = sock->lastdata;
|
||||
} else {
|
||||
/* If this is non-blocking call, then check first */
|
||||
@ -366,11 +366,11 @@ lwip_recvfrom(int s, void *mem, int len, unsigned int flags,
|
||||
sock_set_errno(sock, EWOULDBLOCK);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
/* No data was left from the previous operation, so we try to get
|
||||
some from the network. */
|
||||
buf = netconn_recv(sock->conn);
|
||||
|
||||
|
||||
if (!buf) {
|
||||
/* We should really do some error checking here. */
|
||||
LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_recvfrom(%d): buf == NULL!\n", s));
|
||||
@ -378,17 +378,17 @@ lwip_recvfrom(int s, void *mem, int len, unsigned int flags,
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
buflen = netbuf_len(buf);
|
||||
|
||||
buflen -= sock->lastoffset;
|
||||
|
||||
|
||||
if (len > buflen) {
|
||||
copylen = buflen;
|
||||
} else {
|
||||
copylen = len;
|
||||
}
|
||||
|
||||
|
||||
/* copy the contents of the received buffer into
|
||||
the supplied memory pointer mem */
|
||||
netbuf_copy_partial(buf, mem, copylen, sock->lastoffset);
|
||||
@ -413,21 +413,21 @@ lwip_recvfrom(int s, void *mem, int len, unsigned int flags,
|
||||
|
||||
#if SOCKETS_DEBUG
|
||||
LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_recvfrom(%d): addr=", s));
|
||||
ip_addr_debug_print(addr);
|
||||
ip_addr_debug_print(SOCKETS_DEBUG, addr);
|
||||
LWIP_DEBUGF(SOCKETS_DEBUG, (" port=%u len=%u\n", port, copylen));
|
||||
#endif
|
||||
} else {
|
||||
#if SOCKETS_DEBUG > 0
|
||||
addr = netbuf_fromaddr(buf);
|
||||
port = netbuf_fromport(buf);
|
||||
port = netbuf_fromport(buf);
|
||||
|
||||
LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_recvfrom(%d): addr=", s));
|
||||
ip_addr_debug_print(addr);
|
||||
ip_addr_debug_print(SOCKETS_DEBUG, addr);
|
||||
LWIP_DEBUGF(SOCKETS_DEBUG, (" port=%u len=%u\n", port, copylen));
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* If this is a TCP socket, check if there is data left in the
|
||||
buffer. If so, it should be saved in the sock structure for next
|
||||
time around. */
|
||||
@ -440,7 +440,7 @@ lwip_recvfrom(int s, void *mem, int len, unsigned int flags,
|
||||
netbuf_delete(buf);
|
||||
}
|
||||
|
||||
|
||||
|
||||
sock_set_errno(sock, 0);
|
||||
return copylen;
|
||||
}
|
||||
@ -469,8 +469,8 @@ lwip_send(int s, void *data, int size, unsigned int flags)
|
||||
sock = get_socket(s);
|
||||
if (!sock) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
switch (netconn_type(sock->conn)) {
|
||||
case NETCONN_UDP:
|
||||
/* create a buffer */
|
||||
@ -481,7 +481,7 @@ lwip_send(int s, void *data, int size, unsigned int flags)
|
||||
sock_set_errno(sock, ENOBUFS);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
/* make the buffer point to the data that should
|
||||
be sent */
|
||||
netbuf_ref(buf, data, size);
|
||||
@ -502,7 +502,7 @@ lwip_send(int s, void *data, int size, unsigned int flags)
|
||||
if (err != ERR_OK) {
|
||||
LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_send(%d) err=%d\n", s, err));
|
||||
sock_set_errno(sock, err_to_errno(err));
|
||||
return -1;
|
||||
return -1;
|
||||
}
|
||||
|
||||
LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_send(%d) ok size=%d\n", s, size));
|
||||
@ -523,21 +523,21 @@ lwip_sendto(int s, void *data, int size, unsigned int flags,
|
||||
if (!sock) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
/* get the peer if currently connected */
|
||||
connected = (netconn_peer(sock->conn, &addr, &port) == ERR_OK);
|
||||
|
||||
|
||||
remote_addr.addr = ((struct sockaddr_in *)to)->sin_addr.s_addr;
|
||||
remote_port = ((struct sockaddr_in *)to)->sin_port;
|
||||
|
||||
#if SOCKETS_DEBUG
|
||||
LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_sendto(%d, data=%p, size=%d, flags=0x%x to=", s, data, size, flags));
|
||||
ip_addr_debug_print(&remote_addr);
|
||||
ip_addr_debug_print(SOCKETS_DEBUG, &remote_addr);
|
||||
LWIP_DEBUGF(SOCKETS_DEBUG, (" port=%u\n", ntohs(remote_port)));
|
||||
#endif
|
||||
|
||||
|
||||
netconn_connect(sock->conn, &remote_addr, ntohs(remote_port));
|
||||
|
||||
|
||||
ret = lwip_send(s, data, size, flags);
|
||||
|
||||
/* reset the remote address and port number
|
||||
@ -607,7 +607,7 @@ lwip_selscan(int maxfdp1, fd_set *readset, fd_set *writeset, fd_set *exceptset)
|
||||
FD_ZERO(&lreadset);
|
||||
FD_ZERO(&lwriteset);
|
||||
FD_ZERO(&lexceptset);
|
||||
|
||||
|
||||
/* Go through each socket in each list to count number of sockets which
|
||||
currently match */
|
||||
for(i = 0; i < maxfdp1; i++)
|
||||
@ -662,12 +662,12 @@ lwip_select(int maxfdp1, fd_set *readset, fd_set *writeset, fd_set *exceptset,
|
||||
select_cb.writeset = writeset;
|
||||
select_cb.exceptset = exceptset;
|
||||
select_cb.sem_signalled = 0;
|
||||
|
||||
|
||||
/* Protect ourselves searching through the list */
|
||||
if (!selectsem)
|
||||
selectsem = sys_sem_new(1);
|
||||
sys_sem_wait(selectsem);
|
||||
|
||||
|
||||
if (readset)
|
||||
lreadset = *readset;
|
||||
else
|
||||
@ -680,11 +680,11 @@ lwip_select(int maxfdp1, fd_set *readset, fd_set *writeset, fd_set *exceptset,
|
||||
lexceptset = *exceptset;
|
||||
else
|
||||
FD_ZERO(&lexceptset);
|
||||
|
||||
|
||||
/* Go through each socket in each list to count number of sockets which
|
||||
currently match */
|
||||
nready = lwip_selscan(maxfdp1, &lreadset, &lwriteset, &lexceptset);
|
||||
|
||||
|
||||
/* If we don't have any current events, then suspend if we are supposed to */
|
||||
if (!nready)
|
||||
{
|
||||
@ -703,7 +703,7 @@ lwip_select(int maxfdp1, fd_set *readset, fd_set *writeset, fd_set *exceptset,
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* add our semaphore to list */
|
||||
/* We don't actually need any dynamic memory. Our entry on the
|
||||
* list is only valid while we are in this function, so it's ok
|
||||
@ -738,9 +738,9 @@ lwip_select(int maxfdp1, fd_set *readset, fd_set *writeset, fd_set *exceptset,
|
||||
p_selcb->next = select_cb.next;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
sys_sem_signal(selectsem);
|
||||
|
||||
|
||||
sys_sem_free(select_cb.sem);
|
||||
if (i == 0) /* Timeout */
|
||||
{
|
||||
@ -775,14 +775,14 @@ lwip_select(int maxfdp1, fd_set *readset, fd_set *writeset, fd_set *exceptset,
|
||||
}
|
||||
else
|
||||
sys_sem_signal(selectsem);
|
||||
|
||||
|
||||
if (readset)
|
||||
*readset = lreadset;
|
||||
if (writeset)
|
||||
*writeset = lwriteset;
|
||||
if (exceptset)
|
||||
*exceptset = lexceptset;
|
||||
|
||||
|
||||
LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_select: nready=%d\n", nready));
|
||||
set_errno(0);
|
||||
|
||||
@ -796,7 +796,7 @@ event_callback(struct netconn *conn, enum netconn_evt evt, u16_t len)
|
||||
int s;
|
||||
struct lwip_socket *sock;
|
||||
struct lwip_select_cb *scb;
|
||||
|
||||
|
||||
/* Get socket */
|
||||
if (conn)
|
||||
{
|
||||
@ -812,7 +812,7 @@ event_callback(struct netconn *conn, enum netconn_evt evt, u16_t len)
|
||||
conn->socket--;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
sock = get_socket(s);
|
||||
if (!sock)
|
||||
return;
|
||||
@ -822,7 +822,7 @@ event_callback(struct netconn *conn, enum netconn_evt evt, u16_t len)
|
||||
|
||||
if (!selectsem)
|
||||
selectsem = sys_sem_new(1);
|
||||
|
||||
|
||||
sys_sem_wait(selectsem);
|
||||
/* Set event as required */
|
||||
switch (evt)
|
||||
@ -841,7 +841,7 @@ event_callback(struct netconn *conn, enum netconn_evt evt, u16_t len)
|
||||
break;
|
||||
}
|
||||
sys_sem_signal(selectsem);
|
||||
|
||||
|
||||
/* Now decide if anyone is waiting for this socket */
|
||||
/* NOTE: This code is written this way to protect the select link list
|
||||
but to avoid a deadlock situation by releasing socksem before
|
||||
@ -875,7 +875,7 @@ event_callback(struct netconn *conn, enum netconn_evt evt, u16_t len)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
@ -897,20 +897,20 @@ int lwip_getpeername (int s, struct sockaddr *name, socklen_t *namelen)
|
||||
if (!sock) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
memset(&sin, 0, sizeof(sin));
|
||||
sin.sin_len = sizeof(sin);
|
||||
sin.sin_family = AF_INET;
|
||||
|
||||
/* get the IP address and port of the remote host */
|
||||
netconn_peer(sock->conn, &naddr, &sin.sin_port);
|
||||
|
||||
|
||||
#if SOCKETS_DEBUG
|
||||
LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getpeername(%d, addr=", s));
|
||||
ip_addr_debug_print(&naddr);
|
||||
ip_addr_debug_print(SOCKETS_DEBUG, &naddr);
|
||||
LWIP_DEBUGF(SOCKETS_DEBUG, (" port=%d)\n", sin.sin_port));
|
||||
#endif
|
||||
|
||||
|
||||
sin.sin_port = htons(sin.sin_port);
|
||||
sin.sin_addr.s_addr = naddr.addr;
|
||||
|
||||
@ -932,7 +932,7 @@ int lwip_getsockname (int s, struct sockaddr *name, socklen_t *namelen)
|
||||
if (!sock) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
memset(&sin, 0, sizeof(sin));
|
||||
sin.sin_len = sizeof(sin);
|
||||
sin.sin_family = AF_INET;
|
||||
@ -942,10 +942,10 @@ int lwip_getsockname (int s, struct sockaddr *name, socklen_t *namelen)
|
||||
|
||||
#if SOCKETS_DEBUG
|
||||
LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getsockname(%d, addr=", s));
|
||||
ip_addr_debug_print(naddr);
|
||||
ip_addr_debug_print(SOCKETS_DEBUG, naddr);
|
||||
LWIP_DEBUGF(SOCKETS_DEBUG, (" port=%d)\n", sin.sin_port));
|
||||
#endif
|
||||
|
||||
|
||||
sin.sin_port = htons(sin.sin_port);
|
||||
sin.sin_addr.s_addr = naddr->addr;
|
||||
|
||||
|
@ -1119,8 +1119,8 @@ static void dhcp_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, struct ip_
|
||||
u8_t msg_type;
|
||||
u8_t i;
|
||||
LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 3, ("dhcp_recv(pbuf = %p) from DHCP server %u.%u.%u.%u port %u\n", p,
|
||||
(u8_t)(ntohl(addr->addr) >> 24 & 0xff), (u8_t)(ntohl(addr->addr) >> 16 & 0xff),
|
||||
(u8_t)(ntohl(addr->addr) >> 8 & 0xff), (u8_t)(ntohl(addr->addr) & 0xff), port));
|
||||
(unsigned int)(ntohl(addr->addr) >> 24 & 0xff), (unsigned int)(ntohl(addr->addr) >> 16 & 0xff),
|
||||
(unsigned int)(ntohl(addr->addr) >> 8 & 0xff), (unsigned int)(ntohl(addr->addr) & 0xff), port));
|
||||
LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE, ("pbuf->len = %u\n", p->len));
|
||||
LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE, ("pbuf->tot_len = %u\n", p->tot_len));
|
||||
/* prevent warnings about unused arguments */
|
||||
|
@ -1,8 +1,8 @@
|
||||
/*
|
||||
* Copyright (c) 2001-2003 Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
@ -11,21 +11,21 @@
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
@ -53,13 +53,13 @@ icmp_input(struct pbuf *p, struct netif *inp)
|
||||
struct ip_hdr *iphdr;
|
||||
struct ip_addr tmpaddr;
|
||||
u16_t hlen;
|
||||
|
||||
|
||||
#ifdef ICMP_STATS
|
||||
++lwip_stats.icmp.recv;
|
||||
#endif /* ICMP_STATS */
|
||||
snmp_inc_icmpinmsgs();
|
||||
|
||||
|
||||
|
||||
iphdr = p->payload;
|
||||
hlen = IPH_HL(iphdr) * 4;
|
||||
if (pbuf_header(p, -((s16_t)hlen)) || (p->tot_len < sizeof(u16_t)*2)) {
|
||||
@ -69,7 +69,7 @@ icmp_input(struct pbuf *p, struct netif *inp)
|
||||
++lwip_stats.icmp.lenerr;
|
||||
#endif /* ICMP_STATS */
|
||||
snmp_inc_icmpinerrors();
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
type = *((u8_t *)p->payload);
|
||||
@ -95,9 +95,9 @@ icmp_input(struct pbuf *p, struct netif *inp)
|
||||
#endif /* ICMP_STATS */
|
||||
snmp_inc_icmpinerrors();
|
||||
|
||||
return;
|
||||
return;
|
||||
}
|
||||
iecho = p->payload;
|
||||
iecho = p->payload;
|
||||
if (inet_chksum_pbuf(p) != 0) {
|
||||
LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: checksum failed for received ICMP echo\n"));
|
||||
pbuf_free(p);
|
||||
@ -128,7 +128,7 @@ icmp_input(struct pbuf *p, struct netif *inp)
|
||||
pbuf_header(p, hlen);
|
||||
ip_output_if (p, &(iphdr->src), IP_HDRINCL,
|
||||
IPH_TTL(iphdr), IP_PROTO_ICMP, inp);
|
||||
break;
|
||||
break;
|
||||
default:
|
||||
LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: ICMP type %d code %d not supported.\n", (int)type, (int)code));
|
||||
#ifdef ICMP_STATS
|
||||
@ -145,18 +145,18 @@ icmp_dest_unreach(struct pbuf *p, enum icmp_dur_type t)
|
||||
struct pbuf *q;
|
||||
struct ip_hdr *iphdr;
|
||||
struct icmp_dur_hdr *idur;
|
||||
|
||||
|
||||
q = pbuf_alloc(PBUF_IP, 8 + IP_HLEN + 8, PBUF_RAM);
|
||||
/* ICMP header + IP header + 8 bytes of data */
|
||||
|
||||
iphdr = p->payload;
|
||||
|
||||
|
||||
idur = q->payload;
|
||||
ICMPH_TYPE_SET(idur, ICMP_DUR);
|
||||
ICMPH_CODE_SET(idur, t);
|
||||
|
||||
memcpy((char *)q->payload + 8, p->payload, IP_HLEN + 8);
|
||||
|
||||
|
||||
/* calculate checksum */
|
||||
idur->chksum = 0;
|
||||
idur->chksum = inet_chksum(idur, q->len);
|
||||
@ -186,9 +186,9 @@ icmp_time_exceeded(struct pbuf *p, enum icmp_te_type t)
|
||||
iphdr = p->payload;
|
||||
#if ICMP_DEBUG
|
||||
LWIP_DEBUGF(ICMP_DEBUG, ("icmp_time_exceeded from "));
|
||||
ip_addr_debug_print(&(iphdr->src));
|
||||
ip_addr_debug_print(ICMP_DEBUG, &(iphdr->src));
|
||||
LWIP_DEBUGF(ICMP_DEBUG, (" to "));
|
||||
ip_addr_debug_print(&(iphdr->dest));
|
||||
ip_addr_debug_print(ICMP_DEBUG, &(iphdr->dest));
|
||||
LWIP_DEBUGF(ICMP_DEBUG, ("\n"));
|
||||
#endif /* ICMP_DEBNUG */
|
||||
|
||||
@ -198,7 +198,7 @@ icmp_time_exceeded(struct pbuf *p, enum icmp_te_type t)
|
||||
|
||||
/* copy fields from original packet */
|
||||
memcpy((char *)q->payload + 8, (char *)p->payload, IP_HLEN + 8);
|
||||
|
||||
|
||||
/* calculate checksum */
|
||||
tehdr->chksum = 0;
|
||||
tehdr->chksum = inet_chksum(tehdr, q->len);
|
||||
|
@ -1,8 +1,8 @@
|
||||
/*
|
||||
* Copyright (c) 2001-2003 Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
@ -11,21 +11,21 @@
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
@ -36,7 +36,7 @@
|
||||
*
|
||||
* This is the code for the IP layer for IPv6.
|
||||
*
|
||||
*/
|
||||
*/
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
#include "lwip/opt.h"
|
||||
@ -75,7 +75,7 @@ struct netif *
|
||||
ip_route(struct ip_addr *dest)
|
||||
{
|
||||
struct netif *netif;
|
||||
|
||||
|
||||
for(netif = netif_list; netif != NULL; netif = netif->next) {
|
||||
if (ip_addr_maskcmp(dest, &(netif->ip_addr), &(netif->netmask))) {
|
||||
return netif;
|
||||
@ -96,14 +96,14 @@ static void
|
||||
ip_forward(struct pbuf *p, struct ip_hdr *iphdr)
|
||||
{
|
||||
struct netif *netif;
|
||||
|
||||
|
||||
PERF_START;
|
||||
|
||||
|
||||
if ((netif = ip_route((struct ip_addr *)&(iphdr->dest))) == NULL) {
|
||||
|
||||
LWIP_DEBUGF(IP_DEBUG, ("ip_input: no forwarding route found for "));
|
||||
#if IP_DEBUG
|
||||
ip_addr_debug_print(&(iphdr->dest));
|
||||
ip_addr_debug_print(IP_DEBUG, &(iphdr->dest));
|
||||
#endif /* IP_DEBUG */
|
||||
LWIP_DEBUGF(IP_DEBUG, ("\n"));
|
||||
pbuf_free(p);
|
||||
@ -116,20 +116,20 @@ ip_forward(struct pbuf *p, struct ip_hdr *iphdr)
|
||||
icmp_time_exceeded(p, ICMP_TE_TTL);
|
||||
}
|
||||
pbuf_free(p);
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/* Incremental update of the IP checksum. */
|
||||
/* if (iphdr->chksum >= htons(0xffff - 0x100)) {
|
||||
iphdr->chksum += htons(0x100) + 1;
|
||||
} else {
|
||||
iphdr->chksum += htons(0x100);
|
||||
}*/
|
||||
|
||||
|
||||
|
||||
LWIP_DEBUGF(IP_DEBUG, ("ip_forward: forwarding packet to "));
|
||||
#if IP_DEBUG
|
||||
ip_addr_debug_print(&(iphdr->dest));
|
||||
ip_addr_debug_print(IP_DEBUG, &(iphdr->dest));
|
||||
#endif /* IP_DEBUG */
|
||||
LWIP_DEBUGF(IP_DEBUG, ("\n"));
|
||||
|
||||
@ -139,7 +139,7 @@ ip_forward(struct pbuf *p, struct ip_hdr *iphdr)
|
||||
#endif /* IP_STATS */
|
||||
|
||||
PERF_STOP("ip_forward");
|
||||
|
||||
|
||||
netif->output(netif, p, (struct ip_addr *)&(iphdr->dest));
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
@ -158,22 +158,22 @@ ip_input(struct pbuf *p, struct netif *inp) {
|
||||
struct ip_hdr *iphdr;
|
||||
struct netif *netif;
|
||||
|
||||
|
||||
|
||||
PERF_START;
|
||||
|
||||
#if IP_DEBUG
|
||||
ip_debug_print(p);
|
||||
#endif /* IP_DEBUG */
|
||||
|
||||
|
||||
|
||||
#ifdef IP_STATS
|
||||
++lwip_stats.ip.recv;
|
||||
#endif /* IP_STATS */
|
||||
|
||||
|
||||
/* identify the IP header */
|
||||
iphdr = p->payload;
|
||||
|
||||
|
||||
|
||||
if (iphdr->v != 6) {
|
||||
LWIP_DEBUGF(IP_DEBUG, ("IP packet dropped due to bad version number\n"));
|
||||
#if IP_DEBUG
|
||||
@ -186,14 +186,14 @@ ip_input(struct pbuf *p, struct netif *inp) {
|
||||
#endif /* IP_STATS */
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/* is this packet for us? */
|
||||
for(netif = netif_list; netif != NULL; netif = netif->next) {
|
||||
#if IP_DEBUG
|
||||
LWIP_DEBUGF(IP_DEBUG, ("ip_input: iphdr->dest "));
|
||||
ip_addr_debug_print(&(iphdr->dest));
|
||||
ip_addr_debug_print(IP_DEBUG, &(iphdr->dest));
|
||||
LWIP_DEBUGF(IP_DEBUG, ("netif->ip_addr "));
|
||||
ip_addr_debug_print(&(netif->ip_addr));
|
||||
ip_addr_debug_print(IP_DEBUG, &(netif->ip_addr));
|
||||
LWIP_DEBUGF(IP_DEBUG, ("\n"));
|
||||
#endif /* IP_DEBUG */
|
||||
if (ip_addr_cmp(&(iphdr->dest), &(netif->ip_addr))) {
|
||||
@ -201,7 +201,7 @@ ip_input(struct pbuf *p, struct netif *inp) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (netif == NULL) {
|
||||
/* packet not for us, route or discard */
|
||||
#ifdef IP_FORWARD
|
||||
@ -212,14 +212,14 @@ ip_input(struct pbuf *p, struct netif *inp) {
|
||||
}
|
||||
|
||||
pbuf_realloc(p, IP_HLEN + ntohs(iphdr->len));
|
||||
|
||||
|
||||
/* send to upper layers */
|
||||
#if IP_DEBUG
|
||||
/* LWIP_DEBUGF("ip_input: \n");
|
||||
ip_debug_print(p);
|
||||
LWIP_DEBUGF("ip_input: p->len %u p->tot_len %u\n", p->len, p->tot_len);*/
|
||||
#endif /* IP_DEBUG */
|
||||
|
||||
|
||||
|
||||
pbuf_header(p, -IP_HLEN);
|
||||
|
||||
@ -276,9 +276,9 @@ ip_output_if (struct pbuf *p, struct ip_addr *src, struct ip_addr *dest,
|
||||
return ERR_BUF;
|
||||
}
|
||||
printf("len %u tot_len %u\n", p->len, p->tot_len);
|
||||
|
||||
|
||||
iphdr = p->payload;
|
||||
|
||||
|
||||
|
||||
if (dest != IP_HDRINCL) {
|
||||
printf("!IP_HDRLINCL\n");
|
||||
@ -294,7 +294,7 @@ ip_output_if (struct pbuf *p, struct ip_addr *src, struct ip_addr *dest,
|
||||
} else {
|
||||
ip_addr_set(&(iphdr->src), src);
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
dest = &(iphdr->dest);
|
||||
}
|
||||
@ -309,7 +309,7 @@ ip_output_if (struct pbuf *p, struct ip_addr *src, struct ip_addr *dest,
|
||||
#endif /* IP_DEBUG */
|
||||
|
||||
PERF_STOP("ip_output_if");
|
||||
return netif->output(netif, p, dest);
|
||||
return netif->output(netif, p, dest);
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
/* ip_output:
|
||||
@ -342,7 +342,7 @@ ip_debug_print(struct pbuf *p)
|
||||
char *payload;
|
||||
|
||||
payload = (char *)iphdr + IP_HLEN;
|
||||
|
||||
|
||||
LWIP_DEBUGF(IP_DEBUG, ("IP header:\n"));
|
||||
LWIP_DEBUGF(IP_DEBUG, ("+-------------------------------+\n"));
|
||||
LWIP_DEBUGF(IP_DEBUG, ("|%2d | %x%x | %x%x | (v, traffic class, flow label)\n",
|
||||
|
@ -100,11 +100,11 @@ netif_add(struct ip_addr *ipaddr, struct ip_addr *netmask,
|
||||
#if NETIF_DEBUG
|
||||
LWIP_DEBUGF(NETIF_DEBUG, ("netif: added interface %c%c IP addr ",
|
||||
netif->name[0], netif->name[1]));
|
||||
ip_addr_debug_print(ipaddr);
|
||||
ip_addr_debug_print(NETIF_DEBUG, ipaddr);
|
||||
LWIP_DEBUGF(NETIF_DEBUG, (" netmask "));
|
||||
ip_addr_debug_print(netmask);
|
||||
LWIP_DEBUGF(NETIF_DEBUG, (" gw "));
|
||||
ip_addr_debug_print(gw);
|
||||
ip_addr_debug_print(NETIF_DEBUG, netmask);
|
||||
LWIP_DEBUGF(NETIF_DEBUG, (" gw "));
|
||||
ip_addr_debug_print(NETIF_DEBUG, gw);
|
||||
LWIP_DEBUGF(NETIF_DEBUG, ("\n"));
|
||||
#endif /* NETIF_DEBUG */
|
||||
return netif;
|
||||
@ -211,11 +211,11 @@ netif_set_ipaddr(struct netif *netif, struct ip_addr *ipaddr)
|
||||
#endif
|
||||
ip_addr_set(&(netif->ip_addr), ipaddr);
|
||||
LWIP_DEBUGF(NETIF_DEBUG | DBG_TRACE | DBG_STATE | 3, ("netif: IP address of interface %c%c set to %u.%u.%u.%u\n",
|
||||
netif->name[0], netif->name[1],
|
||||
(u8_t)(ntohl(netif->ip_addr.addr) >> 24 & 0xff),
|
||||
(u8_t)(ntohl(netif->ip_addr.addr) >> 16 & 0xff),
|
||||
(u8_t)(ntohl(netif->ip_addr.addr) >> 8 & 0xff),
|
||||
(u8_t)(ntohl(netif->ip_addr.addr) & 0xff)));
|
||||
netif->name[0], netif->name[1],
|
||||
(unsigned int)(ntohl(netif->ip_addr.addr) >> 24 & 0xff),
|
||||
(unsigned int)(ntohl(netif->ip_addr.addr) >> 16 & 0xff),
|
||||
(unsigned int)(ntohl(netif->ip_addr.addr) >> 8 & 0xff),
|
||||
(unsigned int)(ntohl(netif->ip_addr.addr) & 0xff)));
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
void
|
||||
@ -224,10 +224,10 @@ netif_set_gw(struct netif *netif, struct ip_addr *gw)
|
||||
ip_addr_set(&(netif->gw), gw);
|
||||
LWIP_DEBUGF(NETIF_DEBUG | DBG_TRACE | DBG_STATE | 3, ("netif: GW address of interface %c%c set to %u.%u.%u.%u\n",
|
||||
netif->name[0], netif->name[1],
|
||||
(u8_t)(ntohl(netif->gw.addr) >> 24 & 0xff),
|
||||
(u8_t)(ntohl(netif->gw.addr) >> 16 & 0xff),
|
||||
(u8_t)(ntohl(netif->gw.addr) >> 8 & 0xff),
|
||||
(u8_t)(ntohl(netif->gw.addr) & 0xff)));
|
||||
(unsigned int)(ntohl(netif->gw.addr) >> 24 & 0xff),
|
||||
(unsigned int)(ntohl(netif->gw.addr) >> 16 & 0xff),
|
||||
(unsigned int)(ntohl(netif->gw.addr) >> 8 & 0xff),
|
||||
(unsigned int)(ntohl(netif->gw.addr) & 0xff)));
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
void
|
||||
@ -236,10 +236,10 @@ netif_set_netmask(struct netif *netif, struct ip_addr *netmask)
|
||||
ip_addr_set(&(netif->netmask), netmask);
|
||||
LWIP_DEBUGF(NETIF_DEBUG | DBG_TRACE | DBG_STATE | 3, ("netif: netmask of interface %c%c set to %u.%u.%u.%u\n",
|
||||
netif->name[0], netif->name[1],
|
||||
(u8_t)(ntohl(netif->netmask.addr) >> 24 & 0xff),
|
||||
(u8_t)(ntohl(netif->netmask.addr) >> 16 & 0xff),
|
||||
(u8_t)(ntohl(netif->netmask.addr) >> 8 & 0xff),
|
||||
(u8_t)(ntohl(netif->netmask.addr) & 0xff)));
|
||||
(unsigned int)(ntohl(netif->netmask.addr) >> 24 & 0xff),
|
||||
(unsigned int)(ntohl(netif->netmask.addr) >> 16 & 0xff),
|
||||
(unsigned int)(ntohl(netif->netmask.addr) >> 8 & 0xff),
|
||||
(unsigned int)(ntohl(netif->netmask.addr) & 0xff)));
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
void
|
||||
|
@ -291,7 +291,10 @@ tcp_bind(struct tcp_pcb *pcb, struct ip_addr *ipaddr, u16_t port)
|
||||
static err_t
|
||||
tcp_accept_null(void *arg, struct tcp_pcb *pcb, err_t err)
|
||||
{
|
||||
if (arg || pcb || err);
|
||||
(void)arg;
|
||||
(void)pcb;
|
||||
(void)err;
|
||||
|
||||
return ERR_ABRT;
|
||||
}
|
||||
#endif /* LWIP_CALLBACK_API */
|
||||
|
@ -516,10 +516,10 @@ udp_bind(struct udp_pcb *pcb, struct ip_addr *ipaddr, u16_t port)
|
||||
udp_pcbs = pcb;
|
||||
}
|
||||
LWIP_DEBUGF(UDP_DEBUG | DBG_TRACE | DBG_STATE, ("udp_bind: bound to %u.%u.%u.%u, port %u\n",
|
||||
(u8_t)(ntohl(pcb->local_ip.addr) >> 24 & 0xff),
|
||||
(u8_t)(ntohl(pcb->local_ip.addr) >> 16 & 0xff),
|
||||
(u8_t)(ntohl(pcb->local_ip.addr) >> 8 & 0xff),
|
||||
(u8_t)(ntohl(pcb->local_ip.addr) & 0xff), pcb->local_port));
|
||||
(unsigned int)(ntohl(pcb->local_ip.addr) >> 24 & 0xff),
|
||||
(unsigned int)(ntohl(pcb->local_ip.addr) >> 16 & 0xff),
|
||||
(unsigned int)(ntohl(pcb->local_ip.addr) >> 8 & 0xff),
|
||||
(unsigned int)(ntohl(pcb->local_ip.addr) & 0xff), pcb->local_port));
|
||||
return ERR_OK;
|
||||
}
|
||||
/**
|
||||
@ -571,10 +571,10 @@ udp_connect(struct udp_pcb *pcb, struct ip_addr *ipaddr, u16_t port)
|
||||
}
|
||||
#endif
|
||||
LWIP_DEBUGF(UDP_DEBUG | DBG_TRACE | DBG_STATE, ("udp_connect: connected to %u.%u.%u.%u, port %u\n",
|
||||
(u8_t)(ntohl(pcb->remote_ip.addr) >> 24 & 0xff),
|
||||
(u8_t)(ntohl(pcb->remote_ip.addr) >> 16 & 0xff),
|
||||
(u8_t)(ntohl(pcb->remote_ip.addr) >> 8 & 0xff),
|
||||
(u8_t)(ntohl(pcb->remote_ip.addr) & 0xff), pcb->remote_port));
|
||||
(unsigned int)(ntohl(pcb->remote_ip.addr) >> 24 & 0xff),
|
||||
(unsigned int)(ntohl(pcb->remote_ip.addr) >> 16 & 0xff),
|
||||
(unsigned int)(ntohl(pcb->remote_ip.addr) >> 8 & 0xff),
|
||||
(unsigned int)(ntohl(pcb->remote_ip.addr) & 0xff), pcb->remote_port));
|
||||
|
||||
/* Insert UDP PCB into the list of active UDP PCBs. */
|
||||
for(ipcb = udp_pcbs; ipcb != NULL; ipcb = ipcb->next) {
|
||||
|
@ -1,8 +1,8 @@
|
||||
/*
|
||||
* Copyright (c) 2001-2003 Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
@ -11,21 +11,21 @@
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the lwIP TCP/IP stack.
|
||||
*
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
@ -115,21 +115,21 @@ extern const struct ip_addr ip_addr_broadcast;
|
||||
((addr1)->addr == 0xffffffff) || \
|
||||
((addr1)->addr == 0x00000000))
|
||||
|
||||
|
||||
#define ip_addr_ismulticast(addr1) (((addr1)->addr & ntohl(0xf0000000)) == ntohl(0xe0000000))
|
||||
|
||||
|
||||
|
||||
#define ip_addr_debug_print(ipaddr) LWIP_DEBUGF(LWIP_DEBUG, ("%d.%d.%d.%d", \
|
||||
(u8_t)(ntohl((ipaddr)->addr) >> 24) & 0xff, \
|
||||
(u8_t)(ntohl((ipaddr)->addr) >> 16) & 0xff, \
|
||||
(u8_t)(ntohl((ipaddr)->addr) >> 8) & 0xff, \
|
||||
(u8_t)ntohl((ipaddr)->addr) & 0xff))
|
||||
(unsigned int)(ntohl((ipaddr)->addr) >> 24) & 0xff, \
|
||||
(unsigned int)(ntohl((ipaddr)->addr) >> 16) & 0xff, \
|
||||
(unsigned int)(ntohl((ipaddr)->addr) >> 8) & 0xff, \
|
||||
(unsigned int)ntohl((ipaddr)->addr) & 0xff))
|
||||
|
||||
|
||||
#define ip4_addr1(ipaddr) ((u8_t)(ntohl((ipaddr)->addr) >> 24) & 0xff)
|
||||
#define ip4_addr2(ipaddr) ((u8_t)(ntohl((ipaddr)->addr) >> 16) & 0xff)
|
||||
#define ip4_addr3(ipaddr) ((u8_t)(ntohl((ipaddr)->addr) >> 8) & 0xff)
|
||||
#define ip4_addr4(ipaddr) ((u8_t)(ntohl((ipaddr)->addr)) & 0xff)
|
||||
/* cast to unsigned int, as it is used as argument to printf functions
|
||||
* which expect integer arguments */
|
||||
#define ip4_addr1(ipaddr) ((unsigned int)(ntohl((ipaddr)->addr) >> 24) & 0xff)
|
||||
#define ip4_addr2(ipaddr) ((unsigned int)(ntohl((ipaddr)->addr) >> 16) & 0xff)
|
||||
#define ip4_addr3(ipaddr) ((unsigned int)(ntohl((ipaddr)->addr) >> 8) & 0xff)
|
||||
#define ip4_addr4(ipaddr) ((unsigned int)(ntohl((ipaddr)->addr)) & 0xff)
|
||||
#endif /* __LWIP_IP_ADDR_H__ */
|
||||
|
||||
|
||||
|
@ -39,8 +39,6 @@
|
||||
* THIS CODE NEEDS TO BE FIXED - IT IS NOT In SYNC WITH CURRENT ETHARP API
|
||||
*/
|
||||
|
||||
#include "lwip/debug.h"
|
||||
|
||||
#include "lwip/opt.h"
|
||||
#include "lwip/def.h"
|
||||
#include "lwip/mem.h"
|
||||
|
Loading…
x
Reference in New Issue
Block a user