Changed DEBUGF to LWIP_DEBUGF

This commit is contained in:
kieranm 2003-06-10 10:45:29 +00:00
parent c699921ff0
commit 8014551908
25 changed files with 568 additions and 557 deletions

View File

@ -552,7 +552,7 @@ netconn_recv(struct netconn *conn)
DEBUGF(API_LIB_DEBUG, ("netconn_recv: received %p (err %d)\n", (void *)buf, conn->err)); LWIP_DEBUGF(API_LIB_DEBUG, ("netconn_recv: received %p (err %d)\n", (void *)buf, conn->err));
return buf; return buf;
@ -575,7 +575,7 @@ netconn_send(struct netconn *conn, struct netbuf *buf)
return (conn->err = ERR_MEM); return (conn->err = ERR_MEM);
} }
DEBUGF(API_LIB_DEBUG, ("netconn_send: sending %d bytes\n", buf->p->tot_len)); LWIP_DEBUGF(API_LIB_DEBUG, ("netconn_send: sending %d bytes\n", buf->p->tot_len));
msg->type = API_MSG_SEND; msg->type = API_MSG_SEND;
msg->msg.conn = conn; msg->msg.conn = conn;
msg->msg.msg.p = buf->p; msg->msg.msg.p = buf->p;
@ -637,7 +637,7 @@ netconn_write(struct netconn *conn, void *dataptr, u16_t size, u8_t copy)
len = size; len = size;
} }
DEBUGF(API_LIB_DEBUG, ("netconn_write: writing %d bytes (%d)\n", len, copy)); LWIP_DEBUGF(API_LIB_DEBUG, ("netconn_write: writing %d bytes (%d)\n", len, copy));
msg->msg.msg.w.len = len; msg->msg.msg.w.len = len;
api_msg_post(msg); api_msg_post(msg);
sys_mbox_fetch(conn->mbox, NULL); sys_mbox_fetch(conn->mbox, NULL);

View File

@ -465,7 +465,7 @@ do_listen(struct api_msg_msg *msg)
case NETCONN_UDPNOCHKSUM: case NETCONN_UDPNOCHKSUM:
/* FALLTHROUGH */ /* FALLTHROUGH */
case NETCONN_UDP: case NETCONN_UDP:
DEBUGF(API_MSG_DEBUG, ("api_msg: listen UDP: cannot listen for UDP.\n")); LWIP_DEBUGF(API_MSG_DEBUG, ("api_msg: listen UDP: cannot listen for UDP.\n"));
break; break;
#endif /* LWIP_UDP */ #endif /* LWIP_UDP */
#if LWIP_TCP #if LWIP_TCP
@ -503,7 +503,7 @@ do_accept(struct api_msg_msg *msg)
case NETCONN_UDPNOCHKSUM: case NETCONN_UDPNOCHKSUM:
/* FALLTHROUGH */ /* FALLTHROUGH */
case NETCONN_UDP: case NETCONN_UDP:
DEBUGF(API_MSG_DEBUG, ("api_msg: accept UDP: cannot accept for UDP.\n")); LWIP_DEBUGF(API_MSG_DEBUG, ("api_msg: accept UDP: cannot accept for UDP.\n"));
break; break;
#endif /* LWIP_UDP */ #endif /* LWIP_UDP */
case NETCONN_TCP: case NETCONN_TCP:

View File

@ -106,16 +106,16 @@ get_socket(int s)
struct lwip_socket *sock; struct lwip_socket *sock;
if ((s < 0) || (s > NUM_SOCKETS)) { if ((s < 0) || (s > NUM_SOCKETS)) {
DEBUGF(SOCKETS_DEBUG, ("get_socket(%d): invalid\n", s)); LWIP_DEBUGF(SOCKETS_DEBUG, ("get_socket(%d): invalid\n", s));
set_errno(EBADF); set_errno(EBADF);
return NULL; return NULL;
} }
sock = &sockets[s]; sock = &sockets[s];
if (!sock->conn) { if (!sock->conn) {
DEBUGF(SOCKETS_DEBUG, ("get_socket(%d): not active\n", s)); LWIP_DEBUGF(SOCKETS_DEBUG, ("get_socket(%d): not active\n", s));
set_errno(EBADF); set_errno(EBADF);
return NULL; return NULL;
} }
@ -161,7 +161,7 @@ lwip_accept(int s, struct sockaddr *addr, socklen_t *addrlen)
int newsock; int newsock;
struct sockaddr_in sin; struct sockaddr_in sin;
DEBUGF(SOCKETS_DEBUG, ("lwip_accept(%d)...\n", s)); LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_accept(%d)...\n", s));
sock = get_socket(s); sock = get_socket(s);
if (!sock) { if (!sock) {
return -1; return -1;
@ -198,9 +198,9 @@ lwip_accept(int s, struct sockaddr *addr, socklen_t *addrlen)
sys_sem_signal(socksem); sys_sem_signal(socksem);
#if SOCKETS_DEBUG #if SOCKETS_DEBUG
DEBUGF(SOCKETS_DEBUG, ("lwip_accept(%d) returning new sock=%d addr=", s, newsock)); LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_accept(%d) returning new sock=%d addr=", s, newsock));
ip_addr_debug_print(&naddr); ip_addr_debug_print(&naddr);
DEBUGF(SOCKETS_DEBUG, (" port=%u\n", port)); LWIP_DEBUGF(SOCKETS_DEBUG, (" port=%u\n", port));
#endif #endif
sock_set_errno(sock, 0); sock_set_errno(sock, 0);
@ -224,20 +224,20 @@ lwip_bind(int s, struct sockaddr *name, socklen_t namelen)
local_port = ((struct sockaddr_in *)name)->sin_port; local_port = ((struct sockaddr_in *)name)->sin_port;
#if SOCKETS_DEBUG #if SOCKETS_DEBUG
DEBUGF(SOCKETS_DEBUG, ("lwip_bind(%d, addr=", s)); LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_bind(%d, addr=", s));
ip_addr_debug_print(&local_addr); ip_addr_debug_print(&local_addr);
DEBUGF(SOCKETS_DEBUG, (" port=%u)\n", ntohs(local_port))); LWIP_DEBUGF(SOCKETS_DEBUG, (" port=%u)\n", ntohs(local_port)));
#endif #endif
err = netconn_bind(sock->conn, &local_addr, ntohs(local_port)); err = netconn_bind(sock->conn, &local_addr, ntohs(local_port));
if (err != ERR_OK) { if (err != ERR_OK) {
DEBUGF(SOCKETS_DEBUG, ("lwip_bind(%d) failed, err=%d\n", s, err)); LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_bind(%d) failed, err=%d\n", s, err));
sock_set_errno(sock, err_to_errno(err)); sock_set_errno(sock, err_to_errno(err));
return -1; return -1;
} }
DEBUGF(SOCKETS_DEBUG, ("lwip_bind(%d) succeeded\n", s)); LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_bind(%d) succeeded\n", s));
sock_set_errno(sock, 0); sock_set_errno(sock, 0);
return 0; return 0;
} }
@ -247,7 +247,7 @@ lwip_close(int s)
{ {
struct lwip_socket *sock; struct lwip_socket *sock;
DEBUGF(SOCKETS_DEBUG, ("lwip_close(%d)\n", s)); LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_close(%d)\n", s));
if (!socksem) if (!socksem)
socksem = sys_sem_new(1); socksem = sys_sem_new(1);
@ -284,8 +284,8 @@ lwip_connect(int s, struct sockaddr *name, socklen_t namelen)
} }
if (((struct sockaddr_in *)name)->sin_family == AF_UNSPEC) { if (((struct sockaddr_in *)name)->sin_family == AF_UNSPEC) {
DEBUGF(SOCKETS_DEBUG, ("lwip_connect(%d, AF_UNSPEC)\n", s)); LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_connect(%d, AF_UNSPEC)\n", s));
err = netconn_disconnect(sock->conn); err = netconn_disconnect(sock->conn);
} else { } else {
struct ip_addr remote_addr; struct ip_addr remote_addr;
u16_t remote_port; u16_t remote_port;
@ -294,21 +294,21 @@ lwip_connect(int s, struct sockaddr *name, socklen_t namelen)
remote_port = ((struct sockaddr_in *)name)->sin_port; remote_port = ((struct sockaddr_in *)name)->sin_port;
#if SOCKETS_DEBUG #if SOCKETS_DEBUG
DEBUGF(SOCKETS_DEBUG, ("lwip_connect(%d, addr=", s)); LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_connect(%d, addr=", s));
ip_addr_debug_print(&remote_addr); ip_addr_debug_print(&remote_addr);
DEBUGF(SOCKETS_DEBUG, (" port=%u)\n", ntohs(remote_port))); LWIP_DEBUGF(SOCKETS_DEBUG, (" port=%u)\n", ntohs(remote_port)));
#endif #endif
err = netconn_connect(sock->conn, &remote_addr, ntohs(remote_port)); err = netconn_connect(sock->conn, &remote_addr, ntohs(remote_port));
} }
if (err != ERR_OK) { if (err != ERR_OK) {
DEBUGF(SOCKETS_DEBUG, ("lwip_connect(%d) failed, err=%d\n", s, err)); LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_connect(%d) failed, err=%d\n", s, err));
sock_set_errno(sock, err_to_errno(err)); sock_set_errno(sock, err_to_errno(err));
return -1; return -1;
} }
DEBUGF(SOCKETS_DEBUG, ("lwip_connect(%d) succeeded\n", s)); LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_connect(%d) succeeded\n", s));
sock_set_errno(sock, 0); sock_set_errno(sock, 0);
return 0; return 0;
} }
@ -319,7 +319,7 @@ lwip_listen(int s, int backlog)
struct lwip_socket *sock; struct lwip_socket *sock;
err_t err; err_t err;
DEBUGF(SOCKETS_DEBUG, ("lwip_listen(%d, backlog=%d)\n", s, backlog)); LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_listen(%d, backlog=%d)\n", s, backlog));
sock = get_socket(s); sock = get_socket(s);
if (!sock) { if (!sock) {
return -1; return -1;
@ -328,8 +328,8 @@ lwip_listen(int s, int backlog)
err = netconn_listen(sock->conn); err = netconn_listen(sock->conn);
if (err != ERR_OK) { if (err != ERR_OK) {
DEBUGF(SOCKETS_DEBUG, ("lwip_listen(%d) failed, err=%d\n", s, err)); LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_listen(%d) failed, err=%d\n", s, err));
sock_set_errno(sock, err_to_errno(err)); sock_set_errno(sock, err_to_errno(err));
return -1; return -1;
} }
@ -348,7 +348,7 @@ lwip_recvfrom(int s, void *mem, int len, unsigned int flags,
u16_t port; u16_t port;
DEBUGF(SOCKETS_DEBUG, ("lwip_recvfrom(%d, %p, %d, 0x%x, ..)\n", s, mem, len, flags)); LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_recvfrom(%d, %p, %d, 0x%x, ..)\n", s, mem, len, flags));
sock = get_socket(s); sock = get_socket(s);
if (!sock) { if (!sock) {
return -1; return -1;
@ -362,7 +362,7 @@ lwip_recvfrom(int s, void *mem, int len, unsigned int flags,
if (((flags & MSG_DONTWAIT) || (sock->flags & O_NONBLOCK)) if (((flags & MSG_DONTWAIT) || (sock->flags & O_NONBLOCK))
&& !sock->rcvevent) && !sock->rcvevent)
{ {
DEBUGF(SOCKETS_DEBUG, ("lwip_recvfrom(%d): returning EWOULDBLOCK\n", s)); LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_recvfrom(%d): returning EWOULDBLOCK\n", s));
sock_set_errno(sock, EWOULDBLOCK); sock_set_errno(sock, EWOULDBLOCK);
return -1; return -1;
} }
@ -373,7 +373,7 @@ lwip_recvfrom(int s, void *mem, int len, unsigned int flags,
if (!buf) { if (!buf) {
/* We should really do some error checking here. */ /* We should really do some error checking here. */
DEBUGF(SOCKETS_DEBUG, ("lwip_recvfrom(%d): buf == NULL!\n", s)); LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_recvfrom(%d): buf == NULL!\n", s));
sock_set_errno(sock, 0); sock_set_errno(sock, 0);
return 0; return 0;
} }
@ -412,18 +412,18 @@ lwip_recvfrom(int s, void *mem, int len, unsigned int flags,
memcpy(from, &sin, *fromlen); memcpy(from, &sin, *fromlen);
#if SOCKETS_DEBUG #if SOCKETS_DEBUG
DEBUGF(SOCKETS_DEBUG, ("lwip_recvfrom(%d): addr=", s)); LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_recvfrom(%d): addr=", s));
ip_addr_debug_print(addr); ip_addr_debug_print(addr);
DEBUGF(SOCKETS_DEBUG, (" port=%u len=%u\n", port, copylen)); LWIP_DEBUGF(SOCKETS_DEBUG, (" port=%u len=%u\n", port, copylen));
#endif #endif
} else { } else {
#if SOCKETS_DEBUG > 0 #if SOCKETS_DEBUG > 0
addr = netbuf_fromaddr(buf); addr = netbuf_fromaddr(buf);
port = netbuf_fromport(buf); port = netbuf_fromport(buf);
DEBUGF(SOCKETS_DEBUG, ("lwip_recvfrom(%d): addr=", s)); LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_recvfrom(%d): addr=", s));
ip_addr_debug_print(addr); ip_addr_debug_print(addr);
DEBUGF(SOCKETS_DEBUG, (" port=%u len=%u\n", port, copylen)); LWIP_DEBUGF(SOCKETS_DEBUG, (" port=%u len=%u\n", port, copylen));
#endif #endif
} }
@ -464,7 +464,7 @@ lwip_send(int s, void *data, int size, unsigned int flags)
struct netbuf *buf; struct netbuf *buf;
err_t err; err_t err;
DEBUGF(SOCKETS_DEBUG, ("lwip_send(%d, data=%p, size=%d, flags=0x%x)\n", s, data, size, flags)); LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_send(%d, data=%p, size=%d, flags=0x%x)\n", s, data, size, flags));
sock = get_socket(s); sock = get_socket(s);
if (!sock) { if (!sock) {
@ -477,8 +477,8 @@ lwip_send(int s, void *data, int size, unsigned int flags)
buf = netbuf_new(); buf = netbuf_new();
if (!buf) { if (!buf) {
DEBUGF(SOCKETS_DEBUG, ("lwip_send(%d) ENOBUFS\n", s)); LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_send(%d) ENOBUFS\n", s));
sock_set_errno(sock, ENOBUFS); sock_set_errno(sock, ENOBUFS);
return -1; return -1;
} }
@ -500,12 +500,12 @@ lwip_send(int s, void *data, int size, unsigned int flags)
break; break;
} }
if (err != ERR_OK) { if (err != ERR_OK) {
DEBUGF(SOCKETS_DEBUG, ("lwip_send(%d) err=%d\n", s, err)); LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_send(%d) err=%d\n", s, err));
sock_set_errno(sock, err_to_errno(err)); sock_set_errno(sock, err_to_errno(err));
return -1; return -1;
} }
DEBUGF(SOCKETS_DEBUG, ("lwip_send(%d) ok size=%d\n", s, size)); LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_send(%d) ok size=%d\n", s, size));
sock_set_errno(sock, 0); sock_set_errno(sock, 0);
return size; return size;
} }
@ -531,9 +531,9 @@ lwip_sendto(int s, void *data, int size, unsigned int flags,
remote_port = ((struct sockaddr_in *)to)->sin_port; remote_port = ((struct sockaddr_in *)to)->sin_port;
#if SOCKETS_DEBUG #if SOCKETS_DEBUG
DEBUGF(SOCKETS_DEBUG, ("lwip_sendto(%d, data=%p, size=%d, flags=0x%x to=", s, data, size, flags)); 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(&remote_addr);
DEBUGF(SOCKETS_DEBUG, (" port=%u\n", ntohs(remote_port))); LWIP_DEBUGF(SOCKETS_DEBUG, (" port=%u\n", ntohs(remote_port)));
#endif #endif
netconn_connect(sock->conn, &remote_addr, ntohs(remote_port)); netconn_connect(sock->conn, &remote_addr, ntohs(remote_port));
@ -559,21 +559,21 @@ lwip_socket(int domain, int type, int protocol)
switch (type) { switch (type) {
case SOCK_DGRAM: case SOCK_DGRAM:
conn = netconn_new_with_callback(NETCONN_UDP, event_callback); conn = netconn_new_with_callback(NETCONN_UDP, event_callback);
DEBUGF(SOCKETS_DEBUG, ("lwip_socket(%s, SOCK_DGRAM, %d) = ", domain == PF_INET ? "PF_INET" : "UNKNOWN", protocol)); LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_socket(%s, SOCK_DGRAM, %d) = ", domain == PF_INET ? "PF_INET" : "UNKNOWN", protocol));
break; break;
case SOCK_STREAM: case SOCK_STREAM:
conn = netconn_new_with_callback(NETCONN_TCP, event_callback); conn = netconn_new_with_callback(NETCONN_TCP, event_callback);
DEBUGF(SOCKETS_DEBUG, ("lwip_socket(%s, SOCK_STREAM, %d) = ", domain == PF_INET ? "PF_INET" : "UNKNOWN", protocol)); LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_socket(%s, SOCK_STREAM, %d) = ", domain == PF_INET ? "PF_INET" : "UNKNOWN", protocol));
break; break;
default: default:
DEBUGF(SOCKETS_DEBUG, ("lwip_socket(%d, %d/UNKNOWN, %d) = -1\n", domain, type, protocol)); LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_socket(%d, %d/UNKNOWN, %d) = -1\n", domain, type, protocol));
set_errno(EINVAL); set_errno(EINVAL);
return -1; return -1;
} }
if (!conn) { if (!conn) {
DEBUGF(SOCKETS_DEBUG, ("-1 / ENOBUFS (could not create netconn)\n")); LWIP_DEBUGF(SOCKETS_DEBUG, ("-1 / ENOBUFS (could not create netconn)\n"));
set_errno(ENOBUFS); set_errno(ENOBUFS);
return -1; return -1;
} }
@ -585,7 +585,7 @@ lwip_socket(int domain, int type, int protocol)
return -1; return -1;
} }
conn->socket = i; conn->socket = i;
DEBUGF(SOCKETS_DEBUG, ("%d\n", i)); LWIP_DEBUGF(SOCKETS_DEBUG, ("%d\n", i));
set_errno(0); set_errno(0);
return i; return i;
} }
@ -619,7 +619,7 @@ lwip_selscan(int maxfdp1, fd_set *readset, fd_set *writeset, fd_set *exceptset)
if (p_sock && (p_sock->lastdata || p_sock->rcvevent)) if (p_sock && (p_sock->lastdata || p_sock->rcvevent))
{ {
FD_SET(i, &lreadset); FD_SET(i, &lreadset);
DEBUGF(SOCKETS_DEBUG, ("lwip_selscan: fd=%d ready for reading\n", i)); LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_selscan: fd=%d ready for reading\n", i));
nready++; nready++;
} }
} }
@ -630,7 +630,7 @@ lwip_selscan(int maxfdp1, fd_set *readset, fd_set *writeset, fd_set *exceptset)
if (p_sock && p_sock->sendevent) if (p_sock && p_sock->sendevent)
{ {
FD_SET(i, &lwriteset); FD_SET(i, &lwriteset);
DEBUGF(SOCKETS_DEBUG, ("lwip_selscan: fd=%d ready for writing\n", i)); LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_selscan: fd=%d ready for writing\n", i));
nready++; nready++;
} }
} }
@ -655,7 +655,8 @@ lwip_select(int maxfdp1, fd_set *readset, fd_set *writeset, fd_set *exceptset,
struct lwip_select_cb select_cb; struct lwip_select_cb select_cb;
struct lwip_select_cb *p_selcb; struct lwip_select_cb *p_selcb;
DEBUGF(SOCKETS_DEBUG, ("lwip_select(%d, %p, %p, %p, tvsec=%ld tvusec=%ld)\n", maxfdp1, (void *)readset, (void *) writeset, (void *) exceptset, timeout ? timeout->tv_sec : -1L, timeout ? timeout->tv_usec : -1L)); LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_select(%d, %p, %p, %p, tvsec=%ld tvusec=%ld)\n", maxfdp1, (void *)readset, (void *) writeset, (void *) exceptset, timeout ? timeout->tv_sec : -1L, timeout ? timeout->tv_usec : -1L));
select_cb.next = 0; select_cb.next = 0;
select_cb.readset = readset; select_cb.readset = readset;
select_cb.writeset = writeset; select_cb.writeset = writeset;
@ -697,8 +698,9 @@ lwip_select(int maxfdp1, fd_set *readset, fd_set *writeset, fd_set *exceptset,
if (exceptset) if (exceptset)
FD_ZERO(exceptset); FD_ZERO(exceptset);
DEBUGF(SOCKETS_DEBUG, ("lwip_select: no timeout, returning 0\n")); LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_select: no timeout, returning 0\n"));
set_errno(0); set_errno(0);
return 0; return 0;
} }
@ -748,8 +750,10 @@ lwip_select(int maxfdp1, fd_set *readset, fd_set *writeset, fd_set *exceptset,
FD_ZERO(writeset); FD_ZERO(writeset);
if (exceptset) if (exceptset)
FD_ZERO(exceptset); FD_ZERO(exceptset);
DEBUGF(SOCKETS_DEBUG, ("lwip_select: timeout expired\n"));
set_errno(0); LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_select: timeout expired\n"));
set_errno(0);
return 0; return 0;
} }
@ -778,8 +782,10 @@ lwip_select(int maxfdp1, fd_set *readset, fd_set *writeset, fd_set *exceptset,
*writeset = lwriteset; *writeset = lwriteset;
if (exceptset) if (exceptset)
*exceptset = lexceptset; *exceptset = lexceptset;
DEBUGF(SOCKETS_DEBUG, ("lwip_select: nready=%d\n", nready));
LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_select: nready=%d\n", nready));
set_errno(0); set_errno(0);
return nready; return nready;
} }
@ -877,8 +883,8 @@ event_callback(struct netconn *conn, enum netconn_evt evt, u16_t len)
int lwip_shutdown(int s, int how) int lwip_shutdown(int s, int how)
{ {
DEBUGF(SOCKETS_DEBUG, ("lwip_shutdown(%d, how=%d)\n", s, how)); LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_shutdown(%d, how=%d)\n", s, how));
return lwip_close(s); /* XXX temporary hack until proper implementation */ return lwip_close(s); /* XXX temporary hack until proper implementation */
} }
int lwip_getpeername (int s, struct sockaddr *name, socklen_t *namelen) int lwip_getpeername (int s, struct sockaddr *name, socklen_t *namelen)
@ -900,9 +906,9 @@ int lwip_getpeername (int s, struct sockaddr *name, socklen_t *namelen)
netconn_peer(sock->conn, &naddr, &sin.sin_port); netconn_peer(sock->conn, &naddr, &sin.sin_port);
#if SOCKETS_DEBUG #if SOCKETS_DEBUG
DEBUGF(SOCKETS_DEBUG, ("lwip_getpeername(%d, addr=", s)); LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getpeername(%d, addr=", s));
ip_addr_debug_print(&naddr); ip_addr_debug_print(&naddr);
DEBUGF(SOCKETS_DEBUG, (" port=%d)\n", sin.sin_port)); LWIP_DEBUGF(SOCKETS_DEBUG, (" port=%d)\n", sin.sin_port));
#endif #endif
sin.sin_port = htons(sin.sin_port); sin.sin_port = htons(sin.sin_port);
@ -935,9 +941,9 @@ int lwip_getsockname (int s, struct sockaddr *name, socklen_t *namelen)
netconn_addr(sock->conn, &naddr, &sin.sin_port); netconn_addr(sock->conn, &naddr, &sin.sin_port);
#if SOCKETS_DEBUG #if SOCKETS_DEBUG
DEBUGF(SOCKETS_DEBUG, ("lwip_getsockname(%d, addr=", s)); LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getsockname(%d, addr=", s));
ip_addr_debug_print(naddr); ip_addr_debug_print(naddr);
DEBUGF(SOCKETS_DEBUG, (" port=%d)\n", sin.sin_port)); LWIP_DEBUGF(SOCKETS_DEBUG, (" port=%d)\n", sin.sin_port));
#endif #endif
sin.sin_port = htons(sin.sin_port); sin.sin_port = htons(sin.sin_port);
@ -969,15 +975,15 @@ int lwip_getsockopt (int s, int level, int optname, void *optval, socklen_t *opt
} }
*(int *)optval = sock->err; *(int *)optval = sock->err;
sock->err = 0; sock->err = 0;
DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt(%d, SOL_SOCKET, SO_ERROR) = %d\n", s, *(int *)optval)); LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt(%d, SOL_SOCKET, SO_ERROR) = %d\n", s, *(int *)optval));
err = 0; err = 0;
break; break;
default: default:
DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt(%d, SOL_SOCKET, UNIMPL: optname=0x%x, ..)\n", s, optname)); LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt(%d, SOL_SOCKET, UNIMPL: optname=0x%x, ..)\n", s, optname));
break; break;
} }
} else { } else {
DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt(%d, level=0x%x, UNIMPL: optname=0x%x, ..)\n", s, level, optname)); LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt(%d, level=0x%x, UNIMPL: optname=0x%x, ..)\n", s, level, optname));
} }
sock_set_errno(sock, err); sock_set_errno(sock, err);
return err ? -1 : 0; return err ? -1 : 0;
@ -995,16 +1001,16 @@ int lwip_setsockopt (int s, int level, int optname, const void *optval, socklen_
if (level == SOL_SOCKET) { if (level == SOL_SOCKET) {
switch (optname) { switch (optname) {
case SO_REUSEADDR: case SO_REUSEADDR:
DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%d, SOL_SOCKET, SO_REUSEADDR, ..)\n", s)); LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%d, SOL_SOCKET, SO_REUSEADDR, ..)\n", s));
/* XXX just pretend we support this for now */ /* XXX just pretend we support this for now */
err = 0; err = 0;
break; break;
default: default:
DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%d, SOL_SOCKET, UNIMPL: optname=0x%x, ..)\n", s, optname)); LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%d, SOL_SOCKET, UNIMPL: optname=0x%x, ..)\n", s, optname));
break; break;
} }
} else { } else {
DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%d, level=0x%x, UNIMPL: optname=0x%x, ..)\n", s, level, optname)); LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%d, level=0x%x, UNIMPL: optname=0x%x, ..)\n", s, level, optname));
} }
sock_set_errno(sock, err); sock_set_errno(sock, err);
@ -1028,7 +1034,7 @@ int lwip_ioctl(int s, long cmd, void *argp)
*((u16_t*)argp) = sock->conn->recv_avail; *((u16_t*)argp) = sock->conn->recv_avail;
DEBUGF(SOCKETS_DEBUG, ("lwip_ioctl(%d, FIONREAD, %p) = %u\n", s, argp, *((u16_t*)argp))); LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_ioctl(%d, FIONREAD, %p) = %u\n", s, argp, *((u16_t*)argp)));
sock_set_errno(sock, 0); sock_set_errno(sock, 0);
return 0; return 0;
@ -1037,12 +1043,12 @@ int lwip_ioctl(int s, long cmd, void *argp)
sock->flags |= O_NONBLOCK; sock->flags |= O_NONBLOCK;
else else
sock->flags &= ~O_NONBLOCK; sock->flags &= ~O_NONBLOCK;
DEBUGF(SOCKETS_DEBUG, ("lwip_ioctl(%d, FIONBIO, %d)\n", s, !!(sock->flags & O_NONBLOCK))); LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_ioctl(%d, FIONBIO, %d)\n", s, !!(sock->flags & O_NONBLOCK)));
sock_set_errno(sock, 0); sock_set_errno(sock, 0);
return 0; return 0;
default: default:
DEBUGF(SOCKETS_DEBUG, ("lwip_ioctl(%d, UNIMPL: 0x%lx, %p)\n", s, cmd, argp)); LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_ioctl(%d, UNIMPL: 0x%lx, %p)\n", s, cmd, argp));
sock_set_errno(sock, ENOSYS); /* not yet implemented */ sock_set_errno(sock, ENOSYS); /* not yet implemented */
return -1; return -1;
} }

View File

@ -96,15 +96,15 @@ tcpip_thread(void *arg)
sys_mbox_fetch(mbox, (void *)&msg); sys_mbox_fetch(mbox, (void *)&msg);
switch (msg->type) { switch (msg->type) {
case TCPIP_MSG_API: case TCPIP_MSG_API:
DEBUGF(TCPIP_DEBUG, ("tcpip_thread: API message %p\n", (void *)msg)); LWIP_DEBUGF(TCPIP_DEBUG, ("tcpip_thread: API message %p\n", (void *)msg));
api_msg_input(msg->msg.apimsg); api_msg_input(msg->msg.apimsg);
break; break;
case TCPIP_MSG_INPUT: case TCPIP_MSG_INPUT:
DEBUGF(TCPIP_DEBUG, ("tcpip_thread: IP packet %p\n", (void *)msg)); LWIP_DEBUGF(TCPIP_DEBUG, ("tcpip_thread: IP packet %p\n", (void *)msg));
ip_input(msg->msg.inp.p, msg->msg.inp.netif); ip_input(msg->msg.inp.p, msg->msg.inp.netif);
break; break;
case TCPIP_MSG_CALLBACK: case TCPIP_MSG_CALLBACK:
DEBUGF(TCPIP_DEBUG, ("tcpip_thread: CALLBACK %p\n", (void *)msg)); LWIP_DEBUGF(TCPIP_DEBUG, ("tcpip_thread: CALLBACK %p\n", (void *)msg));
msg->msg.cb.f(msg->msg.cb.ctx); msg->msg.cb.f(msg->msg.cb.ctx);
break; break;
default: default:

View File

@ -139,9 +139,9 @@ static void dhcp_option_trailer(struct dhcp *dhcp);
static void dhcp_handle_nak(struct netif *netif) { static void dhcp_handle_nak(struct netif *netif) {
struct dhcp *dhcp = netif->dhcp; struct dhcp *dhcp = netif->dhcp;
u16_t msecs = 10 * 1000; u16_t msecs = 10 * 1000;
DEBUGF(DHCP_DEBUG | DBG_TRACE | 3, ("dhcp_handle_nak(netif=%p) %c%c%u\n", netif, netif->name[0], netif->name[1], netif->num)); LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 3, ("dhcp_handle_nak(netif=%p) %c%c%u\n", netif, netif->name[0], netif->name[1], netif->num));
dhcp->request_timeout = (msecs + DHCP_FINE_TIMER_MSECS - 1) / DHCP_FINE_TIMER_MSECS; dhcp->request_timeout = (msecs + DHCP_FINE_TIMER_MSECS - 1) / DHCP_FINE_TIMER_MSECS;
DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_handle_nak(): set request timeout %u msecs\n", msecs)); LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_handle_nak(): set request timeout %u msecs\n", msecs));
dhcp_set_state(dhcp, DHCP_BACKING_OFF); dhcp_set_state(dhcp, DHCP_BACKING_OFF);
} }
@ -157,17 +157,17 @@ static void dhcp_check(struct netif *netif)
struct dhcp *dhcp = netif->dhcp; struct dhcp *dhcp = netif->dhcp;
err_t result; err_t result;
u16_t msecs; u16_t msecs;
DEBUGF(DHCP_DEBUG | DBG_TRACE | 3, ("dhcp_check(netif=%p) %c%c\n", netif, netif->name[0], netif->name[1])); LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 3, ("dhcp_check(netif=%p) %c%c\n", netif, netif->name[0], netif->name[1]));
/* create an ARP query for the offered IP address, expecting that no host /* create an ARP query for the offered IP address, expecting that no host
responds, as the IP address should not be in use. */ responds, as the IP address should not be in use. */
result = etharp_query(netif, &dhcp->offered_ip_addr, NULL); result = etharp_query(netif, &dhcp->offered_ip_addr, NULL);
if (result != ERR_OK) { if (result != ERR_OK) {
DEBUGF(DHCP_DEBUG | DBG_TRACE | 2, ("dhcp_check: could not perform ARP query\n")); LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 2, ("dhcp_check: could not perform ARP query\n"));
} }
dhcp->tries++; dhcp->tries++;
msecs = 500; msecs = 500;
dhcp->request_timeout = (msecs + DHCP_FINE_TIMER_MSECS - 1) / DHCP_FINE_TIMER_MSECS; dhcp->request_timeout = (msecs + DHCP_FINE_TIMER_MSECS - 1) / DHCP_FINE_TIMER_MSECS;
DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_check(): set request timeout %u msecs\n", msecs)); LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_check(): set request timeout %u msecs\n", msecs));
dhcp_set_state(dhcp, DHCP_CHECKING); dhcp_set_state(dhcp, DHCP_CHECKING);
} }
@ -181,14 +181,14 @@ static void dhcp_handle_offer(struct netif *netif)
struct dhcp *dhcp = netif->dhcp; struct dhcp *dhcp = netif->dhcp;
/* obtain the server address */ /* obtain the server address */
u8_t *option_ptr = dhcp_get_option_ptr(dhcp, DHCP_OPTION_SERVER_ID); u8_t *option_ptr = dhcp_get_option_ptr(dhcp, DHCP_OPTION_SERVER_ID);
DEBUGF(DHCP_DEBUG | DBG_TRACE | 3, ("dhcp_handle_offer(netif=%p) %c%c%u\n", netif, netif->name[0], netif->name[1], netif->num)); LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 3, ("dhcp_handle_offer(netif=%p) %c%c%u\n", netif, netif->name[0], netif->name[1], netif->num));
if (option_ptr != NULL) if (option_ptr != NULL)
{ {
dhcp->server_ip_addr.addr = htonl(dhcp_get_option_long(&option_ptr[2])); dhcp->server_ip_addr.addr = htonl(dhcp_get_option_long(&option_ptr[2]));
DEBUGF(DHCP_DEBUG | DBG_STATE, ("dhcp_handle_offer(): server 0x%08lx\n", dhcp->server_ip_addr.addr)); LWIP_DEBUGF(DHCP_DEBUG | DBG_STATE, ("dhcp_handle_offer(): server 0x%08lx\n", dhcp->server_ip_addr.addr));
/* remember offered address */ /* remember offered address */
ip_addr_set(&dhcp->offered_ip_addr, (struct ip_addr *)&dhcp->msg_in->yiaddr); ip_addr_set(&dhcp->offered_ip_addr, (struct ip_addr *)&dhcp->msg_in->yiaddr);
DEBUGF(DHCP_DEBUG | DBG_STATE, ("dhcp_handle_offer(): offer for 0x%08lx\n", dhcp->offered_ip_addr.addr)); LWIP_DEBUGF(DHCP_DEBUG | DBG_STATE, ("dhcp_handle_offer(): offer for 0x%08lx\n", dhcp->offered_ip_addr.addr));
dhcp_select(netif); dhcp_select(netif);
} }
} }
@ -206,7 +206,7 @@ static err_t dhcp_select(struct netif *netif)
struct dhcp *dhcp = netif->dhcp; struct dhcp *dhcp = netif->dhcp;
err_t result; err_t result;
u32_t msecs; u32_t msecs;
DEBUGF(DHCP_DEBUG | DBG_TRACE | 3, ("dhcp_select(netif=%p) %c%c%u\n", netif, netif->name[0], netif->name[1], netif->num)); LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 3, ("dhcp_select(netif=%p) %c%c%u\n", netif, netif->name[0], netif->name[1], netif->num));
/* create and initialize the DHCP message header */ /* create and initialize the DHCP message header */
result = dhcp_create_request(netif); result = dhcp_create_request(netif);
@ -243,15 +243,15 @@ static err_t dhcp_select(struct netif *netif)
/* reconnect to any (or to server here?!) */ /* reconnect to any (or to server here?!) */
udp_connect(dhcp->pcb, IP_ADDR_ANY, DHCP_SERVER_PORT); udp_connect(dhcp->pcb, IP_ADDR_ANY, DHCP_SERVER_PORT);
dhcp_delete_request(netif); dhcp_delete_request(netif);
DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_select: REQUESTING\n")); LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_select: REQUESTING\n"));
dhcp_set_state(dhcp, DHCP_REQUESTING); dhcp_set_state(dhcp, DHCP_REQUESTING);
} else { } else {
DEBUGF(DHCP_DEBUG | DBG_TRACE | 2, ("dhcp_select: could not allocate DHCP request\n")); LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 2, ("dhcp_select: could not allocate DHCP request\n"));
} }
dhcp->tries++; dhcp->tries++;
msecs = dhcp->tries < 4 ? dhcp->tries * 1000 : 4 * 1000; msecs = dhcp->tries < 4 ? dhcp->tries * 1000 : 4 * 1000;
dhcp->request_timeout = (msecs + DHCP_FINE_TIMER_MSECS - 1) / DHCP_FINE_TIMER_MSECS; dhcp->request_timeout = (msecs + DHCP_FINE_TIMER_MSECS - 1) / DHCP_FINE_TIMER_MSECS;
DEBUGF(DHCP_DEBUG | DBG_STATE, ("dhcp_select(): set request timeout %u msecs\n", msecs)); LWIP_DEBUGF(DHCP_DEBUG | DBG_STATE, ("dhcp_select(): set request timeout %u msecs\n", msecs));
return result; return result;
} }
@ -262,19 +262,19 @@ static err_t dhcp_select(struct netif *netif)
void dhcp_coarse_tmr() void dhcp_coarse_tmr()
{ {
struct netif *netif = netif_list; struct netif *netif = netif_list;
DEBUGF(DHCP_DEBUG | DBG_TRACE, ("dhcp_coarse_tmr()\n")); LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE, ("dhcp_coarse_tmr()\n"));
/* iterate through all network interfaces */ /* iterate through all network interfaces */
while (netif != NULL) { while (netif != NULL) {
/* only act on DHCP configured interfaces */ /* only act on DHCP configured interfaces */
if (netif->dhcp != NULL) { if (netif->dhcp != NULL) {
/* timer is active (non zero), and triggers (zeroes) now? */ /* timer is active (non zero), and triggers (zeroes) now? */
if (netif->dhcp->t2_timeout-- == 1) { if (netif->dhcp->t2_timeout-- == 1) {
DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_coarse_tmr(): t2 timeout\n")); LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_coarse_tmr(): t2 timeout\n"));
/* this clients' rebind timeout triggered */ /* this clients' rebind timeout triggered */
dhcp_t2_timeout(netif); dhcp_t2_timeout(netif);
/* timer is active (non zero), and triggers (zeroes) now */ /* timer is active (non zero), and triggers (zeroes) now */
} else if (netif->dhcp->t1_timeout-- == 1) { } else if (netif->dhcp->t1_timeout-- == 1) {
DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_coarse_tmr(): t1 timeout\n")); LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_coarse_tmr(): t1 timeout\n"));
/* this clients' renewal timeout triggered */ /* this clients' renewal timeout triggered */
dhcp_t1_timeout(netif); dhcp_t1_timeout(netif);
} }
@ -299,7 +299,7 @@ void dhcp_fine_tmr()
if (netif->dhcp != NULL) { if (netif->dhcp != NULL) {
/* timer is active (non zero), and triggers (zeroes) now */ /* timer is active (non zero), and triggers (zeroes) now */
if (netif->dhcp->request_timeout-- == 1) { if (netif->dhcp->request_timeout-- == 1) {
DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_fine_tmr(): request timeout\n")); LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_fine_tmr(): request timeout\n"));
/* this clients' request timeout triggered */ /* this clients' request timeout triggered */
dhcp_timeout(netif); dhcp_timeout(netif);
} }
@ -321,24 +321,24 @@ void dhcp_fine_tmr()
static void dhcp_timeout(struct netif *netif) static void dhcp_timeout(struct netif *netif)
{ {
struct dhcp *dhcp = netif->dhcp; struct dhcp *dhcp = netif->dhcp;
DEBUGF(DHCP_DEBUG | DBG_TRACE | 3, ("dhcp_timeout()\n")); LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 3, ("dhcp_timeout()\n"));
/* back-off period has passed, or server selection timed out */ /* back-off period has passed, or server selection timed out */
if ((dhcp->state == DHCP_BACKING_OFF) || (dhcp->state == DHCP_SELECTING)) { if ((dhcp->state == DHCP_BACKING_OFF) || (dhcp->state == DHCP_SELECTING)) {
DEBUGF(DHCP_DEBUG | DBG_TRACE, ("dhcp_timeout(): restarting discovery\n")); LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE, ("dhcp_timeout(): restarting discovery\n"));
dhcp_discover(netif); dhcp_discover(netif);
/* receiving the requested lease timed out */ /* receiving the requested lease timed out */
} else if (dhcp->state == DHCP_REQUESTING) { } else if (dhcp->state == DHCP_REQUESTING) {
DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_timeout(): REQUESTING, DHCP request timed out\n")); LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_timeout(): REQUESTING, DHCP request timed out\n"));
if (dhcp->tries <= 5) { if (dhcp->tries <= 5) {
dhcp_select(netif); dhcp_select(netif);
} else { } else {
DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_timeout(): REQUESTING, releasing, restarting\n")); LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_timeout(): REQUESTING, releasing, restarting\n"));
dhcp_release(netif); dhcp_release(netif);
dhcp_discover(netif); dhcp_discover(netif);
} }
/* received no ARP reply for the offered address (which is good) */ /* received no ARP reply for the offered address (which is good) */
} else if (dhcp->state == DHCP_CHECKING) { } else if (dhcp->state == DHCP_CHECKING) {
DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_timeout(): CHECKING, ARP request timed out\n")); LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_timeout(): CHECKING, ARP request timed out\n"));
if (dhcp->tries <= 1) { if (dhcp->tries <= 1) {
dhcp_check(netif); dhcp_check(netif);
/* no ARP replies on the offered address, /* no ARP replies on the offered address,
@ -350,17 +350,17 @@ static void dhcp_timeout(struct netif *netif)
} }
/* did not get response to renew request? */ /* did not get response to renew request? */
else if (dhcp->state == DHCP_RENEWING) { else if (dhcp->state == DHCP_RENEWING) {
DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_timeout(): RENEWING, DHCP request timed out\n")); LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_timeout(): RENEWING, DHCP request timed out\n"));
/* just retry renewal */ /* just retry renewal */
/* note that the rebind timer will eventually time-out if renew does not work */ /* note that the rebind timer will eventually time-out if renew does not work */
dhcp_renew(netif); dhcp_renew(netif);
/* did not get response to rebind request? */ /* did not get response to rebind request? */
} else if (dhcp->state == DHCP_REBINDING) { } else if (dhcp->state == DHCP_REBINDING) {
DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_timeout(): REBINDING, DHCP request timed out\n")); LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_timeout(): REBINDING, DHCP request timed out\n"));
if (dhcp->tries <= 8) { if (dhcp->tries <= 8) {
dhcp_rebind(netif); dhcp_rebind(netif);
} else { } else {
DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_timeout(): RELEASING, DISCOVERING\n")); LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_timeout(): RELEASING, DISCOVERING\n"));
dhcp_release(netif); dhcp_release(netif);
dhcp_discover(netif); dhcp_discover(netif);
} }
@ -375,11 +375,11 @@ static void dhcp_timeout(struct netif *netif)
static void dhcp_t1_timeout(struct netif *netif) static void dhcp_t1_timeout(struct netif *netif)
{ {
struct dhcp *dhcp = netif->dhcp; struct dhcp *dhcp = netif->dhcp;
DEBUGF(DHCP_DEBUG | DBG_STATE, ("dhcp_t1_timeout()\n")); LWIP_DEBUGF(DHCP_DEBUG | DBG_STATE, ("dhcp_t1_timeout()\n"));
if ((dhcp->state == DHCP_REQUESTING) || (dhcp->state == DHCP_BOUND) || (dhcp->state == DHCP_RENEWING)) { if ((dhcp->state == DHCP_REQUESTING) || (dhcp->state == DHCP_BOUND) || (dhcp->state == DHCP_RENEWING)) {
/* just retry to renew */ /* just retry to renew */
/* note that the rebind timer will eventually time-out if renew does not work */ /* note that the rebind timer will eventually time-out if renew does not work */
DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_t1_timeout(): must renew\n")); LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_t1_timeout(): must renew\n"));
dhcp_renew(netif); dhcp_renew(netif);
} }
} }
@ -391,10 +391,10 @@ static void dhcp_t1_timeout(struct netif *netif)
static void dhcp_t2_timeout(struct netif *netif) static void dhcp_t2_timeout(struct netif *netif)
{ {
struct dhcp *dhcp = netif->dhcp; struct dhcp *dhcp = netif->dhcp;
DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_t2_timeout()\n")); LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_t2_timeout()\n"));
if ((dhcp->state == DHCP_REQUESTING) || (dhcp->state == DHCP_BOUND) || (dhcp->state == DHCP_RENEWING)) { if ((dhcp->state == DHCP_REQUESTING) || (dhcp->state == DHCP_BOUND) || (dhcp->state == DHCP_RENEWING)) {
/* just retry to rebind */ /* just retry to rebind */
DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_t2_timeout(): must rebind\n")); LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_t2_timeout(): must rebind\n"));
dhcp_rebind(netif); dhcp_rebind(netif);
} }
} }
@ -495,22 +495,22 @@ err_t dhcp_start(struct netif *netif)
err_t result = ERR_OK; err_t result = ERR_OK;
LWIP_ASSERT("netif != NULL", netif != NULL); LWIP_ASSERT("netif != NULL", netif != NULL);
DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_start(netif=%p) %c%c%u\n", netif, netif->name[0], netif->name[1], netif->num)); LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_start(netif=%p) %c%c%u\n", netif, netif->name[0], netif->name[1], netif->num));
if (dhcp == NULL) { if (dhcp == NULL) {
DEBUGF(DHCP_DEBUG | DBG_TRACE, ("dhcp_start(): starting new DHCP client\n")); LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE, ("dhcp_start(): starting new DHCP client\n"));
dhcp = mem_malloc(sizeof(struct dhcp)); dhcp = mem_malloc(sizeof(struct dhcp));
if (dhcp == NULL) { if (dhcp == NULL) {
DEBUGF(DHCP_DEBUG | DBG_TRACE, ("dhcp_start(): could not allocate dhcp\n")); LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE, ("dhcp_start(): could not allocate dhcp\n"));
netif->flags &= ~NETIF_FLAG_DHCP; netif->flags &= ~NETIF_FLAG_DHCP;
return ERR_MEM; return ERR_MEM;
} }
/* clear data structure */ /* clear data structure */
memset(dhcp, 0, sizeof(struct dhcp)); memset(dhcp, 0, sizeof(struct dhcp));
DEBUGF(DHCP_DEBUG | DBG_TRACE, ("dhcp_start(): allocated dhcp")); LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE, ("dhcp_start(): allocated dhcp"));
dhcp->pcb = udp_new(); dhcp->pcb = udp_new();
if (dhcp->pcb == NULL) { if (dhcp->pcb == NULL) {
DEBUGF(DHCP_DEBUG | DBG_TRACE, ("dhcp_start(): could not obtain pcb\n")); LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE, ("dhcp_start(): could not obtain pcb\n"));
mem_free((void *)dhcp); mem_free((void *)dhcp);
dhcp = NULL; dhcp = NULL;
netif->flags &= ~NETIF_FLAG_DHCP; netif->flags &= ~NETIF_FLAG_DHCP;
@ -518,10 +518,10 @@ err_t dhcp_start(struct netif *netif)
} }
/* store this dhcp client in the netif */ /* store this dhcp client in the netif */
netif->dhcp = dhcp; netif->dhcp = dhcp;
DEBUGF(DHCP_DEBUG | DBG_TRACE, ("dhcp_start(): created new udp pcb\n")); LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE, ("dhcp_start(): created new udp pcb\n"));
DEBUGF(DHCP_DEBUG | DBG_TRACE, ("dhcp_start(): starting DHCP configuration\n")); LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE, ("dhcp_start(): starting DHCP configuration\n"));
} else { } else {
DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE | 3, ("dhcp_start(): restarting DHCP configuration\n")); LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE | 3, ("dhcp_start(): restarting DHCP configuration\n"));
} }
/* (re)start the DHCP negotiation */ /* (re)start the DHCP negotiation */
result = dhcp_discover(netif); result = dhcp_discover(netif);
@ -548,20 +548,20 @@ void dhcp_inform(struct netif *netif)
err_t result = ERR_OK; err_t result = ERR_OK;
dhcp = mem_malloc(sizeof(struct dhcp)); dhcp = mem_malloc(sizeof(struct dhcp));
if (dhcp == NULL) { if (dhcp == NULL) {
DEBUGF(DHCP_DEBUG | DBG_TRACE | 2, ("dhcp_inform(): could not allocate dhcp\n")); LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 2, ("dhcp_inform(): could not allocate dhcp\n"));
return; return;
} }
netif->dhcp = dhcp; netif->dhcp = dhcp;
memset(dhcp, 0, sizeof(struct dhcp)); memset(dhcp, 0, sizeof(struct dhcp));
DEBUGF(DHCP_DEBUG | DBG_TRACE, ("dhcp_inform(): allocated dhcp\n")); LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE, ("dhcp_inform(): allocated dhcp\n"));
dhcp->pcb = udp_new(); dhcp->pcb = udp_new();
if (dhcp->pcb == NULL) { if (dhcp->pcb == NULL) {
DEBUGF(DHCP_DEBUG | DBG_TRACE | 2, ("dhcp_inform(): could not obtain pcb")); LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 2, ("dhcp_inform(): could not obtain pcb"));
mem_free((void *)dhcp); mem_free((void *)dhcp);
return; return;
} }
DEBUGF(DHCP_DEBUG | DBG_TRACE, ("dhcp_inform(): created new udp pcb\n")); LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE, ("dhcp_inform(): created new udp pcb\n"));
/* create and initialize the DHCP message header */ /* create and initialize the DHCP message header */
result = dhcp_create_request(netif); result = dhcp_create_request(netif);
if (result == ERR_OK) { if (result == ERR_OK) {
@ -579,12 +579,12 @@ void dhcp_inform(struct netif *netif)
udp_bind(dhcp->pcb, IP_ADDR_ANY, DHCP_CLIENT_PORT); udp_bind(dhcp->pcb, IP_ADDR_ANY, DHCP_CLIENT_PORT);
udp_connect(dhcp->pcb, IP_ADDR_BROADCAST, DHCP_SERVER_PORT); udp_connect(dhcp->pcb, IP_ADDR_BROADCAST, DHCP_SERVER_PORT);
DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_inform: INFORMING\n")); LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_inform: INFORMING\n"));
udp_send(dhcp->pcb, dhcp->p_out); udp_send(dhcp->pcb, dhcp->p_out);
udp_connect(dhcp->pcb, IP_ADDR_ANY, DHCP_SERVER_PORT); udp_connect(dhcp->pcb, IP_ADDR_ANY, DHCP_SERVER_PORT);
dhcp_delete_request(netif); dhcp_delete_request(netif);
} else { } else {
DEBUGF(DHCP_DEBUG | DBG_TRACE | 2, ("dhcp_inform: could not allocate DHCP request\n")); LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 2, ("dhcp_inform: could not allocate DHCP request\n"));
} }
if (dhcp != NULL) if (dhcp != NULL)
@ -605,15 +605,15 @@ void dhcp_inform(struct netif *netif)
*/ */
void dhcp_arp_reply(struct netif *netif, struct ip_addr *addr) void dhcp_arp_reply(struct netif *netif, struct ip_addr *addr)
{ {
DEBUGF(DHCP_DEBUG | DBG_TRACE | 3, ("dhcp_arp_reply()\n")); LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 3, ("dhcp_arp_reply()\n"));
/* is this DHCP client doing an ARP check? */ /* is this DHCP client doing an ARP check? */
if ((netif->dhcp != NULL) && (netif->dhcp->state == DHCP_CHECKING)) { if ((netif->dhcp != NULL) && (netif->dhcp->state == DHCP_CHECKING)) {
DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_arp_reply(): CHECKING, arp reply for 0x%08lx\n", addr->addr)); LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_arp_reply(): CHECKING, arp reply for 0x%08lx\n", addr->addr));
/* did a host respond with the address we /* did a host respond with the address we
were offered by the DHCP server? */ were offered by the DHCP server? */
if (ip_addr_cmp(addr, &netif->dhcp->offered_ip_addr)) { if (ip_addr_cmp(addr, &netif->dhcp->offered_ip_addr)) {
/* we will not accept the offered address */ /* we will not accept the offered address */
DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE | 1, ("dhcp_arp_reply(): arp reply matched with offered address, declining\n")); LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE | 1, ("dhcp_arp_reply(): arp reply matched with offered address, declining\n"));
dhcp_decline(netif); dhcp_decline(netif);
} }
} }
@ -631,7 +631,7 @@ static err_t dhcp_decline(struct netif *netif)
struct dhcp *dhcp = netif->dhcp; struct dhcp *dhcp = netif->dhcp;
err_t result = ERR_OK; err_t result = ERR_OK;
u16_t msecs; u16_t msecs;
DEBUGF(DHCP_DEBUG | DBG_TRACE | 3, ("dhcp_decline()\n")); LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 3, ("dhcp_decline()\n"));
dhcp_set_state(dhcp, DHCP_BACKING_OFF); dhcp_set_state(dhcp, DHCP_BACKING_OFF);
/* create and initialize the DHCP message header */ /* create and initialize the DHCP message header */
result = dhcp_create_request(netif); result = dhcp_create_request(netif);
@ -651,14 +651,14 @@ static err_t dhcp_decline(struct netif *netif)
udp_connect(dhcp->pcb, &dhcp->server_ip_addr, DHCP_SERVER_PORT); udp_connect(dhcp->pcb, &dhcp->server_ip_addr, DHCP_SERVER_PORT);
udp_send(dhcp->pcb, dhcp->p_out); udp_send(dhcp->pcb, dhcp->p_out);
dhcp_delete_request(netif); dhcp_delete_request(netif);
DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_decline: BACKING OFF\n")); LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_decline: BACKING OFF\n"));
} else { } else {
DEBUGF(DHCP_DEBUG | DBG_TRACE | 2, ("dhcp_decline: could not allocate DHCP request\n")); LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 2, ("dhcp_decline: could not allocate DHCP request\n"));
} }
dhcp->tries++; dhcp->tries++;
msecs = 10*1000; msecs = 10*1000;
dhcp->request_timeout = (msecs + DHCP_FINE_TIMER_MSECS - 1) / DHCP_FINE_TIMER_MSECS; dhcp->request_timeout = (msecs + DHCP_FINE_TIMER_MSECS - 1) / DHCP_FINE_TIMER_MSECS;
DEBUGF(DHCP_DEBUG | DBG_TRACE, ("dhcp_decline(): set request timeout %u msecs\n", msecs)); LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE, ("dhcp_decline(): set request timeout %u msecs\n", msecs));
return result; return result;
} }
#endif #endif
@ -673,13 +673,13 @@ static err_t dhcp_discover(struct netif *netif)
struct dhcp *dhcp = netif->dhcp; struct dhcp *dhcp = netif->dhcp;
err_t result = ERR_OK; err_t result = ERR_OK;
u16_t msecs; u16_t msecs;
DEBUGF(DHCP_DEBUG | DBG_TRACE | 3, ("dhcp_discover()\n")); LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 3, ("dhcp_discover()\n"));
ip_addr_set(&dhcp->offered_ip_addr, IP_ADDR_ANY); ip_addr_set(&dhcp->offered_ip_addr, IP_ADDR_ANY);
/* create and initialize the DHCP message header */ /* create and initialize the DHCP message header */
result = dhcp_create_request(netif); result = dhcp_create_request(netif);
if (result == ERR_OK) if (result == ERR_OK)
{ {
DEBUGF(DHCP_DEBUG | DBG_TRACE, ("dhcp_discover: making request\n")); LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE, ("dhcp_discover: making request\n"));
dhcp_option(dhcp, DHCP_OPTION_MESSAGE_TYPE, DHCP_OPTION_MESSAGE_TYPE_LEN); dhcp_option(dhcp, DHCP_OPTION_MESSAGE_TYPE, DHCP_OPTION_MESSAGE_TYPE_LEN);
dhcp_option_byte(dhcp, DHCP_DISCOVER); dhcp_option_byte(dhcp, DHCP_DISCOVER);
@ -693,7 +693,7 @@ static err_t dhcp_discover(struct netif *netif)
dhcp_option_trailer(dhcp); dhcp_option_trailer(dhcp);
DEBUGF(DHCP_DEBUG | DBG_TRACE, ("dhcp_discover: realloc()ing\n")); LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE, ("dhcp_discover: realloc()ing\n"));
pbuf_realloc(dhcp->p_out, sizeof(struct dhcp_msg) - DHCP_OPTIONS_LEN + dhcp->options_out_len); pbuf_realloc(dhcp->p_out, sizeof(struct dhcp_msg) - DHCP_OPTIONS_LEN + dhcp->options_out_len);
/* set receive callback function with netif as user data */ /* set receive callback function with netif as user data */
@ -701,24 +701,24 @@ static err_t dhcp_discover(struct netif *netif)
udp_bind(dhcp->pcb, IP_ADDR_ANY, DHCP_CLIENT_PORT); udp_bind(dhcp->pcb, IP_ADDR_ANY, DHCP_CLIENT_PORT);
udp_connect(dhcp->pcb, IP_ADDR_BROADCAST, DHCP_SERVER_PORT); udp_connect(dhcp->pcb, IP_ADDR_BROADCAST, DHCP_SERVER_PORT);
DEBUGF(DHCP_DEBUG | DBG_TRACE, ("dhcp_discover: send()ing\n")); LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE, ("dhcp_discover: send()ing\n"));
udp_send(dhcp->pcb, dhcp->p_out); udp_send(dhcp->pcb, dhcp->p_out);
DEBUGF(DHCP_DEBUG | DBG_TRACE, ("dhcp_discover: bind()ing\n")); LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE, ("dhcp_discover: bind()ing\n"));
udp_bind(dhcp->pcb, IP_ADDR_ANY, DHCP_CLIENT_PORT); udp_bind(dhcp->pcb, IP_ADDR_ANY, DHCP_CLIENT_PORT);
DEBUGF(DHCP_DEBUG | DBG_TRACE, ("dhcp_discover: connect()ing\n")); LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE, ("dhcp_discover: connect()ing\n"));
udp_connect(dhcp->pcb, IP_ADDR_ANY, DHCP_SERVER_PORT); udp_connect(dhcp->pcb, IP_ADDR_ANY, DHCP_SERVER_PORT);
DEBUGF(DHCP_DEBUG | DBG_TRACE, ("dhcp_discover: deleting()ing\n")); LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE, ("dhcp_discover: deleting()ing\n"));
dhcp_delete_request(netif); dhcp_delete_request(netif);
DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_discover: SELECTING\n")); LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_discover: SELECTING\n"));
dhcp_set_state(dhcp, DHCP_SELECTING); dhcp_set_state(dhcp, DHCP_SELECTING);
} else { } else {
DEBUGF(DHCP_DEBUG | DBG_TRACE | 2, ("dhcp_discover: could not allocate DHCP request\n")); LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 2, ("dhcp_discover: could not allocate DHCP request\n"));
} }
dhcp->tries++; dhcp->tries++;
msecs = dhcp->tries < 4 ? (dhcp->tries + 1) * 1000 : 10 * 1000; msecs = dhcp->tries < 4 ? (dhcp->tries + 1) * 1000 : 10 * 1000;
dhcp->request_timeout = (msecs + DHCP_FINE_TIMER_MSECS - 1) / DHCP_FINE_TIMER_MSECS; dhcp->request_timeout = (msecs + DHCP_FINE_TIMER_MSECS - 1) / DHCP_FINE_TIMER_MSECS;
DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_discover(): set request timeout %u msecs\n", msecs)); LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_discover(): set request timeout %u msecs\n", msecs));
return result; return result;
} }
@ -734,22 +734,22 @@ static void dhcp_bind(struct netif *netif)
struct ip_addr sn_mask, gw_addr; struct ip_addr sn_mask, gw_addr;
LWIP_ASSERT("dhcp_bind: netif != NULL", netif != NULL); LWIP_ASSERT("dhcp_bind: netif != NULL", netif != NULL);
LWIP_ASSERT("dhcp_bind: dhcp != NULL", dhcp != NULL); LWIP_ASSERT("dhcp_bind: dhcp != NULL", dhcp != NULL);
DEBUGF(DHCP_DEBUG | DBG_TRACE | 3, ("dhcp_bind(netif=%p) %c%c%u\n", netif, netif->name[0], netif->name[1], netif->num)); LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 3, ("dhcp_bind(netif=%p) %c%c%u\n", netif, netif->name[0], netif->name[1], netif->num));
/* temporary DHCP lease? */ /* temporary DHCP lease? */
if (dhcp->offered_t1_renew != 0xffffffffUL) { if (dhcp->offered_t1_renew != 0xffffffffUL) {
/* set renewal period timer */ /* set renewal period timer */
DEBUGF(DHCP_DEBUG | DBG_TRACE, ("dhcp_bind(): t1 renewal timer %lu secs\n", dhcp->offered_t1_renew)); LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE, ("dhcp_bind(): t1 renewal timer %lu secs\n", dhcp->offered_t1_renew));
dhcp->t1_timeout = (dhcp->offered_t1_renew + DHCP_COARSE_TIMER_SECS / 2) / DHCP_COARSE_TIMER_SECS; dhcp->t1_timeout = (dhcp->offered_t1_renew + DHCP_COARSE_TIMER_SECS / 2) / DHCP_COARSE_TIMER_SECS;
if (dhcp->t1_timeout == 0) dhcp->t1_timeout = 1; if (dhcp->t1_timeout == 0) dhcp->t1_timeout = 1;
DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_bind(): set request timeout %u msecs\n", dhcp->offered_t1_renew*1000)); LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_bind(): set request timeout %u msecs\n", dhcp->offered_t1_renew*1000));
} }
/* set renewal period timer */ /* set renewal period timer */
if (dhcp->offered_t2_rebind != 0xffffffffUL) { if (dhcp->offered_t2_rebind != 0xffffffffUL) {
DEBUGF(DHCP_DEBUG | DBG_TRACE, ("dhcp_bind(): t2 rebind timer %lu secs\n", dhcp->offered_t2_rebind)); LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE, ("dhcp_bind(): t2 rebind timer %lu secs\n", dhcp->offered_t2_rebind));
dhcp->t2_timeout = (dhcp->offered_t2_rebind + DHCP_COARSE_TIMER_SECS / 2) / DHCP_COARSE_TIMER_SECS; dhcp->t2_timeout = (dhcp->offered_t2_rebind + DHCP_COARSE_TIMER_SECS / 2) / DHCP_COARSE_TIMER_SECS;
if (dhcp->t2_timeout == 0) dhcp->t2_timeout = 1; if (dhcp->t2_timeout == 0) dhcp->t2_timeout = 1;
DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_bind(): set request timeout %u msecs\n", dhcp->offered_t2_rebind*1000)); LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_bind(): set request timeout %u msecs\n", dhcp->offered_t2_rebind*1000));
} }
/* copy offered network mask */ /* copy offered network mask */
ip_addr_set(&sn_mask, &dhcp->offered_sn_mask); ip_addr_set(&sn_mask, &dhcp->offered_sn_mask);
@ -773,11 +773,11 @@ static void dhcp_bind(struct netif *netif)
gw_addr.addr |= htonl(0x00000001); gw_addr.addr |= htonl(0x00000001);
} }
DEBUGF(DHCP_DEBUG | DBG_STATE, ("dhcp_bind(): IP: 0x%08lx\n", dhcp->offered_ip_addr.addr)); LWIP_DEBUGF(DHCP_DEBUG | DBG_STATE, ("dhcp_bind(): IP: 0x%08lx\n", dhcp->offered_ip_addr.addr));
netif_set_ipaddr(netif, &dhcp->offered_ip_addr); netif_set_ipaddr(netif, &dhcp->offered_ip_addr);
DEBUGF(DHCP_DEBUG | DBG_STATE, ("dhcp_bind(): SN: 0x%08lx\n", sn_mask.addr)); LWIP_DEBUGF(DHCP_DEBUG | DBG_STATE, ("dhcp_bind(): SN: 0x%08lx\n", sn_mask.addr));
netif_set_netmask(netif, &sn_mask); netif_set_netmask(netif, &sn_mask);
DEBUGF(DHCP_DEBUG | DBG_STATE, ("dhcp_bind(): GW: 0x%08lx\n", gw_addr.addr)); LWIP_DEBUGF(DHCP_DEBUG | DBG_STATE, ("dhcp_bind(): GW: 0x%08lx\n", gw_addr.addr));
netif_set_gw(netif, &gw_addr); netif_set_gw(netif, &gw_addr);
/* netif is now bound to DHCP leased address */ /* netif is now bound to DHCP leased address */
dhcp_set_state(dhcp, DHCP_BOUND); dhcp_set_state(dhcp, DHCP_BOUND);
@ -793,7 +793,7 @@ err_t dhcp_renew(struct netif *netif)
struct dhcp *dhcp = netif->dhcp; struct dhcp *dhcp = netif->dhcp;
err_t result; err_t result;
u16_t msecs; u16_t msecs;
DEBUGF(DHCP_DEBUG | DBG_TRACE | 3, ("dhcp_renew()\n")); LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 3, ("dhcp_renew()\n"));
dhcp_set_state(dhcp, DHCP_RENEWING); dhcp_set_state(dhcp, DHCP_RENEWING);
/* create and initialize the DHCP message header */ /* create and initialize the DHCP message header */
@ -826,15 +826,15 @@ err_t dhcp_renew(struct netif *netif)
udp_send(dhcp->pcb, dhcp->p_out); udp_send(dhcp->pcb, dhcp->p_out);
dhcp_delete_request(netif); dhcp_delete_request(netif);
DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_renew: RENEWING\n")); LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_renew: RENEWING\n"));
} else { } else {
DEBUGF(DHCP_DEBUG | DBG_TRACE | 2, ("dhcp_renew: could not allocate DHCP request\n")); LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 2, ("dhcp_renew: could not allocate DHCP request\n"));
} }
dhcp->tries++; dhcp->tries++;
/* back-off on retries, but to a maximum of 20 seconds */ /* back-off on retries, but to a maximum of 20 seconds */
msecs = dhcp->tries < 10 ? dhcp->tries * 2000 : 20 * 1000; msecs = dhcp->tries < 10 ? dhcp->tries * 2000 : 20 * 1000;
dhcp->request_timeout = (msecs + DHCP_FINE_TIMER_MSECS - 1) / DHCP_FINE_TIMER_MSECS; dhcp->request_timeout = (msecs + DHCP_FINE_TIMER_MSECS - 1) / DHCP_FINE_TIMER_MSECS;
DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_renew(): set request timeout %u msecs\n", msecs)); LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_renew(): set request timeout %u msecs\n", msecs));
return result; return result;
} }
@ -848,7 +848,7 @@ static err_t dhcp_rebind(struct netif *netif)
struct dhcp *dhcp = netif->dhcp; struct dhcp *dhcp = netif->dhcp;
err_t result; err_t result;
u16_t msecs; u16_t msecs;
DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_rebind()\n")); LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_rebind()\n"));
dhcp_set_state(dhcp, DHCP_REBINDING); dhcp_set_state(dhcp, DHCP_REBINDING);
/* create and initialize the DHCP message header */ /* create and initialize the DHCP message header */
@ -879,14 +879,14 @@ static err_t dhcp_rebind(struct netif *netif)
udp_send(dhcp->pcb, dhcp->p_out); udp_send(dhcp->pcb, dhcp->p_out);
udp_connect(dhcp->pcb, IP_ADDR_ANY, DHCP_SERVER_PORT); udp_connect(dhcp->pcb, IP_ADDR_ANY, DHCP_SERVER_PORT);
dhcp_delete_request(netif); dhcp_delete_request(netif);
DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_rebind: REBINDING\n")); LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_rebind: REBINDING\n"));
} else { } else {
DEBUGF(DHCP_DEBUG | DBG_TRACE | 2, ("dhcp_rebind: could not allocate DHCP request\n")); LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 2, ("dhcp_rebind: could not allocate DHCP request\n"));
} }
dhcp->tries++; dhcp->tries++;
msecs = dhcp->tries < 10 ? dhcp->tries * 1000 : 10 * 1000; msecs = dhcp->tries < 10 ? dhcp->tries * 1000 : 10 * 1000;
dhcp->request_timeout = (msecs + DHCP_FINE_TIMER_MSECS - 1) / DHCP_FINE_TIMER_MSECS; dhcp->request_timeout = (msecs + DHCP_FINE_TIMER_MSECS - 1) / DHCP_FINE_TIMER_MSECS;
DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_rebind(): set request timeout %u msecs\n", msecs)); LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_rebind(): set request timeout %u msecs\n", msecs));
return result; return result;
} }
@ -900,7 +900,7 @@ static err_t dhcp_release(struct netif *netif)
struct dhcp *dhcp = netif->dhcp; struct dhcp *dhcp = netif->dhcp;
err_t result; err_t result;
u16_t msecs; u16_t msecs;
DEBUGF(DHCP_DEBUG | DBG_TRACE | 3, ("dhcp_release()\n")); LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 3, ("dhcp_release()\n"));
/* idle DHCP client */ /* idle DHCP client */
dhcp_set_state(dhcp, DHCP_OFF); dhcp_set_state(dhcp, DHCP_OFF);
@ -920,14 +920,14 @@ static err_t dhcp_release(struct netif *netif)
udp_connect(dhcp->pcb, &dhcp->server_ip_addr, DHCP_SERVER_PORT); udp_connect(dhcp->pcb, &dhcp->server_ip_addr, DHCP_SERVER_PORT);
udp_send(dhcp->pcb, dhcp->p_out); udp_send(dhcp->pcb, dhcp->p_out);
dhcp_delete_request(netif); dhcp_delete_request(netif);
DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_release: RELEASED, DHCP_OFF\n")); LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_release: RELEASED, DHCP_OFF\n"));
} else { } else {
DEBUGF(DHCP_DEBUG | DBG_TRACE | 2, ("dhcp_release: could not allocate DHCP request\n")); LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 2, ("dhcp_release: could not allocate DHCP request\n"));
} }
dhcp->tries++; dhcp->tries++;
msecs = dhcp->tries < 10 ? dhcp->tries * 1000 : 10 * 1000; msecs = dhcp->tries < 10 ? dhcp->tries * 1000 : 10 * 1000;
dhcp->request_timeout = (msecs + DHCP_FINE_TIMER_MSECS - 1) / DHCP_FINE_TIMER_MSECS; dhcp->request_timeout = (msecs + DHCP_FINE_TIMER_MSECS - 1) / DHCP_FINE_TIMER_MSECS;
DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_release(): set request timeout %u msecs\n", msecs)); LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | DBG_STATE, ("dhcp_release(): set request timeout %u msecs\n", msecs));
/* remove IP address from interface */ /* remove IP address from interface */
netif_set_ipaddr(netif, IP_ADDR_ANY); netif_set_ipaddr(netif, IP_ADDR_ANY);
netif_set_gw(netif, IP_ADDR_ANY); netif_set_gw(netif, IP_ADDR_ANY);
@ -945,7 +945,7 @@ void dhcp_stop(struct netif *netif)
struct dhcp *dhcp = netif->dhcp; struct dhcp *dhcp = netif->dhcp;
LWIP_ASSERT("dhcp_stop: netif != NULL", netif != NULL); LWIP_ASSERT("dhcp_stop: netif != NULL", netif != NULL);
DEBUGF(DHCP_DEBUG | DBG_TRACE | 3, ("dhcp_stop()\n")); LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 3, ("dhcp_stop()\n"));
/* netif is DHCP configured? */ /* netif is DHCP configured? */
if (dhcp != NULL) if (dhcp != NULL)
{ {
@ -1043,14 +1043,14 @@ static err_t dhcp_unfold_reply(struct dhcp *dhcp)
dhcp->options_in = mem_malloc(dhcp->options_in_len); dhcp->options_in = mem_malloc(dhcp->options_in_len);
if (dhcp->options_in == NULL) if (dhcp->options_in == NULL)
{ {
DEBUGF(DHCP_DEBUG | DBG_TRACE | 2, ("dhcp_unfold_reply(): could not allocate dhcp->options\n")); LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 2, ("dhcp_unfold_reply(): could not allocate dhcp->options\n"));
return ERR_MEM; return ERR_MEM;
} }
} }
dhcp->msg_in = mem_malloc(sizeof(struct dhcp_msg) - DHCP_OPTIONS_LEN); dhcp->msg_in = mem_malloc(sizeof(struct dhcp_msg) - DHCP_OPTIONS_LEN);
if (dhcp->msg_in == NULL) if (dhcp->msg_in == NULL)
{ {
DEBUGF(DHCP_DEBUG | DBG_TRACE | 2, ("dhcp_unfold_reply(): could not allocate dhcp->msg_in\n")); LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 2, ("dhcp_unfold_reply(): could not allocate dhcp->msg_in\n"));
mem_free((void *)dhcp->options_in); mem_free((void *)dhcp->options_in);
dhcp->options_in = NULL; dhcp->options_in = NULL;
return ERR_MEM; return ERR_MEM;
@ -1069,7 +1069,7 @@ static err_t dhcp_unfold_reply(struct dhcp *dhcp)
j = 0; j = 0;
} }
} }
DEBUGF(DHCP_DEBUG | DBG_TRACE, ("dhcp_unfold_reply(): copied %u bytes into dhcp->msg_in[]\n", i)); LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE, ("dhcp_unfold_reply(): copied %u bytes into dhcp->msg_in[]\n", i));
if (dhcp->options_in != NULL) { if (dhcp->options_in != NULL) {
ptr = (u8_t *)dhcp->options_in; ptr = (u8_t *)dhcp->options_in;
/* proceed through options */ /* proceed through options */
@ -1082,7 +1082,7 @@ static err_t dhcp_unfold_reply(struct dhcp *dhcp)
j = 0; j = 0;
} }
} }
DEBUGF(DHCP_DEBUG | DBG_TRACE, ("dhcp_unfold_reply(): copied %u bytes to dhcp->options_in[]\n", i)); LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE, ("dhcp_unfold_reply(): copied %u bytes to dhcp->options_in[]\n", i));
} }
return ERR_OK; return ERR_OK;
} }
@ -1103,7 +1103,7 @@ static void dhcp_free_reply(struct dhcp *dhcp)
dhcp->options_in = NULL; dhcp->options_in = NULL;
dhcp->options_in_len = 0; dhcp->options_in_len = 0;
} }
DEBUGF(DHCP_DEBUG, ("dhcp_free_reply(): free'd\n")); LWIP_DEBUGF(DHCP_DEBUG, ("dhcp_free_reply(): free'd\n"));
} }
@ -1118,17 +1118,17 @@ static void dhcp_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, struct ip_
u8_t *options_ptr; u8_t *options_ptr;
u8_t msg_type; u8_t msg_type;
u8_t i; u8_t i;
DEBUGF(DHCP_DEBUG | DBG_TRACE | 3, ("dhcp_recv(pbuf = %p) from DHCP server %u.%u.%u.%u port %u\n", p, 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) >> 24 & 0xff), (u8_t)(ntohl(addr->addr) >> 16 & 0xff),
(u8_t)(ntohl(addr->addr) >> 8 & 0xff), (u8_t)(ntohl(addr->addr) & 0xff), port)); (u8_t)(ntohl(addr->addr) >> 8 & 0xff), (u8_t)(ntohl(addr->addr) & 0xff), port));
DEBUGF(DHCP_DEBUG | DBG_TRACE, ("pbuf->len = %u\n", p->len)); LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE, ("pbuf->len = %u\n", p->len));
DEBUGF(DHCP_DEBUG | DBG_TRACE, ("pbuf->tot_len = %u\n", p->tot_len)); LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE, ("pbuf->tot_len = %u\n", p->tot_len));
/* prevent warnings about unused arguments */ /* prevent warnings about unused arguments */
(void)pcb; (void)addr; (void)port; (void)pcb; (void)addr; (void)port;
dhcp->p = p; dhcp->p = p;
/* TODO: check packet length before reading them */ /* TODO: check packet length before reading them */
if (reply_msg->op != DHCP_BOOTREPLY) { if (reply_msg->op != DHCP_BOOTREPLY) {
DEBUGF(DHCP_DEBUG | DBG_TRACE | 1, ("not a DHCP reply message, but type %u\n", reply_msg->op)); LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 1, ("not a DHCP reply message, but type %u\n", reply_msg->op));
pbuf_free(p); pbuf_free(p);
dhcp->p = NULL; dhcp->p = NULL;
return; return;
@ -1136,7 +1136,7 @@ static void dhcp_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, struct ip_
/* iterate through hardware address and match against DHCP message */ /* iterate through hardware address and match against DHCP message */
for (i = 0; i < netif->hwaddr_len; i++) { for (i = 0; i < netif->hwaddr_len; i++) {
if (netif->hwaddr[i] != reply_msg->chaddr[i]) { if (netif->hwaddr[i] != reply_msg->chaddr[i]) {
DEBUGF(DHCP_DEBUG | DBG_TRACE | 2, ("netif->hwaddr[%u]==%02x != reply_msg->chaddr[%u]==%02x\n", LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 2, ("netif->hwaddr[%u]==%02x != reply_msg->chaddr[%u]==%02x\n",
i, netif->hwaddr[i], i, reply_msg->chaddr[i])); i, netif->hwaddr[i], i, reply_msg->chaddr[i]));
pbuf_free(p); pbuf_free(p);
dhcp->p = NULL; dhcp->p = NULL;
@ -1145,24 +1145,24 @@ static void dhcp_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, struct ip_
} }
/* match transaction ID against what we expected */ /* match transaction ID against what we expected */
if (ntohl(reply_msg->xid) != dhcp->xid) { if (ntohl(reply_msg->xid) != dhcp->xid) {
DEBUGF(DHCP_DEBUG | DBG_TRACE | 2, ("transaction id mismatch\n")); LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 2, ("transaction id mismatch\n"));
pbuf_free(p); pbuf_free(p);
dhcp->p = NULL; dhcp->p = NULL;
return; return;
} }
/* option fields could be unfold? */ /* option fields could be unfold? */
if (dhcp_unfold_reply(dhcp) != ERR_OK) { if (dhcp_unfold_reply(dhcp) != ERR_OK) {
DEBUGF(DHCP_DEBUG | DBG_TRACE | 2, ("problem unfolding DHCP message - too short on memory?\n")); LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 2, ("problem unfolding DHCP message - too short on memory?\n"));
pbuf_free(p); pbuf_free(p);
dhcp->p = NULL; dhcp->p = NULL;
return; return;
} }
DEBUGF(DHCP_DEBUG | DBG_TRACE, ("searching DHCP_OPTION_MESSAGE_TYPE\n")); LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE, ("searching DHCP_OPTION_MESSAGE_TYPE\n"));
/* obtain pointer to DHCP message type */ /* obtain pointer to DHCP message type */
options_ptr = dhcp_get_option_ptr(dhcp, DHCP_OPTION_MESSAGE_TYPE); options_ptr = dhcp_get_option_ptr(dhcp, DHCP_OPTION_MESSAGE_TYPE);
if (options_ptr == NULL) { if (options_ptr == NULL) {
DEBUGF(DHCP_DEBUG | DBG_TRACE | 1, ("DHCP_OPTION_MESSAGE_TYPE option not found\n")); LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 1, ("DHCP_OPTION_MESSAGE_TYPE option not found\n"));
pbuf_free(p); pbuf_free(p);
dhcp->p = NULL; dhcp->p = NULL;
return; return;
@ -1172,7 +1172,7 @@ static void dhcp_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, struct ip_
msg_type = dhcp_get_option_byte(options_ptr + 2); msg_type = dhcp_get_option_byte(options_ptr + 2);
/* message type is DHCP ACK? */ /* message type is DHCP ACK? */
if (msg_type == DHCP_ACK) { if (msg_type == DHCP_ACK) {
DEBUGF(DHCP_DEBUG | DBG_TRACE | 1, ("DHCP_ACK received\n")); LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 1, ("DHCP_ACK received\n"));
/* in requesting state? */ /* in requesting state? */
if (dhcp->state == DHCP_REQUESTING) { if (dhcp->state == DHCP_REQUESTING) {
dhcp_handle_ack(netif); dhcp_handle_ack(netif);
@ -1195,13 +1195,13 @@ static void dhcp_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, struct ip_
else if ((msg_type == DHCP_NAK) && else if ((msg_type == DHCP_NAK) &&
((dhcp->state == DHCP_REBOOTING) || (dhcp->state == DHCP_REQUESTING) || ((dhcp->state == DHCP_REBOOTING) || (dhcp->state == DHCP_REQUESTING) ||
(dhcp->state == DHCP_REBINDING) || (dhcp->state == DHCP_RENEWING ))) { (dhcp->state == DHCP_REBINDING) || (dhcp->state == DHCP_RENEWING ))) {
DEBUGF(DHCP_DEBUG | DBG_TRACE | 1, ("DHCP_NAK received\n")); LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 1, ("DHCP_NAK received\n"));
dhcp->request_timeout = 0; dhcp->request_timeout = 0;
dhcp_handle_nak(netif); dhcp_handle_nak(netif);
} }
/* received a DHCP_OFFER in DHCP_SELECTING state? */ /* received a DHCP_OFFER in DHCP_SELECTING state? */
else if ((msg_type == DHCP_OFFER) && (dhcp->state == DHCP_SELECTING)) { else if ((msg_type == DHCP_OFFER) && (dhcp->state == DHCP_SELECTING)) {
DEBUGF(DHCP_DEBUG | DBG_TRACE | 1, ("DHCP_OFFER received in DHCP_SELECTING state\n")); LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 1, ("DHCP_OFFER received in DHCP_SELECTING state\n"));
dhcp->request_timeout = 0; dhcp->request_timeout = 0;
/* remember offered lease */ /* remember offered lease */
dhcp_handle_offer(netif); dhcp_handle_offer(netif);
@ -1219,7 +1219,7 @@ static err_t dhcp_create_request(struct netif *netif)
LWIP_ASSERT("dhcp_create_request: dhcp->msg_out == NULL", dhcp->msg_out == NULL); LWIP_ASSERT("dhcp_create_request: dhcp->msg_out == NULL", dhcp->msg_out == NULL);
dhcp->p_out = pbuf_alloc(PBUF_TRANSPORT, sizeof(struct dhcp_msg), PBUF_RAM); dhcp->p_out = pbuf_alloc(PBUF_TRANSPORT, sizeof(struct dhcp_msg), PBUF_RAM);
if (dhcp->p_out == NULL) { if (dhcp->p_out == NULL) {
DEBUGF(DHCP_DEBUG | DBG_TRACE | 2, ("dhcp_create_request(): could not allocate pbuf\n")); LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 2, ("dhcp_create_request(): could not allocate pbuf\n"));
return ERR_MEM; return ERR_MEM;
} }
/* give unique transaction identifier to this request */ /* give unique transaction identifier to this request */
@ -1277,7 +1277,7 @@ static void dhcp_option_trailer(struct dhcp *dhcp)
dhcp->msg_out->options[dhcp->options_out_len++] = DHCP_OPTION_END; dhcp->msg_out->options[dhcp->options_out_len++] = DHCP_OPTION_END;
/* packet is too small, or not 4 byte aligned? */ /* packet is too small, or not 4 byte aligned? */
while ((dhcp->options_out_len < DHCP_MIN_OPTIONS_LEN) || (dhcp->options_out_len & 3)) { while ((dhcp->options_out_len < DHCP_MIN_OPTIONS_LEN) || (dhcp->options_out_len & 3)) {
/* DEBUGF(DHCP_DEBUG, ("dhcp_option_trailer: dhcp->options_out_len=%u, DHCP_OPTIONS_LEN=%u", dhcp->options_out_len, DHCP_OPTIONS_LEN)); */ /* LWIP_DEBUGF(DHCP_DEBUG, ("dhcp_option_trailer: dhcp->options_out_len=%u, DHCP_OPTIONS_LEN=%u", dhcp->options_out_len, DHCP_OPTIONS_LEN)); */
LWIP_ASSERT("dhcp_option_trailer: dhcp->options_out_len < DHCP_OPTIONS_LEN\n", dhcp->options_out_len < DHCP_OPTIONS_LEN); LWIP_ASSERT("dhcp_option_trailer: dhcp->options_out_len < DHCP_OPTIONS_LEN\n", dhcp->options_out_len < DHCP_OPTIONS_LEN);
/* add a fill/padding byte */ /* add a fill/padding byte */
dhcp->msg_out->options[dhcp->options_out_len++] = 0; dhcp->msg_out->options[dhcp->options_out_len++] = 0;
@ -1304,21 +1304,21 @@ static u8_t *dhcp_get_option_ptr(struct dhcp *dhcp, u8_t option_type)
u16_t offset = 0; u16_t offset = 0;
/* at least 1 byte to read and no end marker, then at least 3 bytes to read? */ /* at least 1 byte to read and no end marker, then at least 3 bytes to read? */
while ((offset < dhcp->options_in_len) && (options[offset] != DHCP_OPTION_END)) { while ((offset < dhcp->options_in_len) && (options[offset] != DHCP_OPTION_END)) {
/* DEBUGF(DHCP_DEBUG, ("msg_offset=%u, q->len=%u", msg_offset, q->len)); */ /* LWIP_DEBUGF(DHCP_DEBUG, ("msg_offset=%u, q->len=%u", msg_offset, q->len)); */
/* are the sname and/or file field overloaded with options? */ /* are the sname and/or file field overloaded with options? */
if (options[offset] == DHCP_OPTION_OVERLOAD) { if (options[offset] == DHCP_OPTION_OVERLOAD) {
DEBUGF(DHCP_DEBUG | DBG_TRACE | 2, ("overloaded message detected\n")); LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 2, ("overloaded message detected\n"));
/* skip option type and length */ /* skip option type and length */
offset += 2; offset += 2;
overload = options[offset++]; overload = options[offset++];
} }
/* requested option found */ /* requested option found */
else if (options[offset] == option_type) { else if (options[offset] == option_type) {
DEBUGF(DHCP_DEBUG | DBG_TRACE, ("option found at offset %u in options\n", offset)); LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE, ("option found at offset %u in options\n", offset));
return &options[offset]; return &options[offset];
/* skip option */ /* skip option */
} else { } else {
DEBUGF(DHCP_DEBUG, ("skipping option %u in options\n", options[offset])); LWIP_DEBUGF(DHCP_DEBUG, ("skipping option %u in options\n", options[offset]));
/* skip option type */ /* skip option type */
offset++; offset++;
/* skip option length, and then length bytes */ /* skip option length, and then length bytes */
@ -1329,16 +1329,16 @@ static u8_t *dhcp_get_option_ptr(struct dhcp *dhcp, u8_t option_type)
if (overload != DHCP_OVERLOAD_NONE) { if (overload != DHCP_OVERLOAD_NONE) {
u16_t field_len; u16_t field_len;
if (overload == DHCP_OVERLOAD_FILE) { if (overload == DHCP_OVERLOAD_FILE) {
DEBUGF(DHCP_DEBUG | DBG_TRACE | 1, ("overloaded file field\n")); LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 1, ("overloaded file field\n"));
options = (u8_t *)&dhcp->msg_in->file; options = (u8_t *)&dhcp->msg_in->file;
field_len = DHCP_FILE_LEN; field_len = DHCP_FILE_LEN;
} else if (overload == DHCP_OVERLOAD_SNAME) { } else if (overload == DHCP_OVERLOAD_SNAME) {
DEBUGF(DHCP_DEBUG | DBG_TRACE | 1, ("overloaded sname field\n")); LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 1, ("overloaded sname field\n"));
options = (u8_t *)&dhcp->msg_in->sname; options = (u8_t *)&dhcp->msg_in->sname;
field_len = DHCP_SNAME_LEN; field_len = DHCP_SNAME_LEN;
/* TODO: check if else if () is necessary */ /* TODO: check if else if () is necessary */
} else { } else {
DEBUGF(DHCP_DEBUG | DBG_TRACE | 1, ("overloaded sname and file field\n")); LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE | 1, ("overloaded sname and file field\n"));
options = (u8_t *)&dhcp->msg_in->sname; options = (u8_t *)&dhcp->msg_in->sname;
field_len = DHCP_FILE_LEN + DHCP_SNAME_LEN; field_len = DHCP_FILE_LEN + DHCP_SNAME_LEN;
} }
@ -1347,11 +1347,11 @@ static u8_t *dhcp_get_option_ptr(struct dhcp *dhcp, u8_t option_type)
/* at least 1 byte to read and no end marker */ /* at least 1 byte to read and no end marker */
while ((offset < field_len) && (options[offset] != DHCP_OPTION_END)) { while ((offset < field_len) && (options[offset] != DHCP_OPTION_END)) {
if (options[offset] == option_type) { if (options[offset] == option_type) {
DEBUGF(DHCP_DEBUG | DBG_TRACE, ("option found at offset=%u\n", offset)); LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE, ("option found at offset=%u\n", offset));
return &options[offset]; return &options[offset];
/* skip option */ /* skip option */
} else { } else {
DEBUGF(DHCP_DEBUG | DBG_TRACE, ("skipping option %u\n", options[offset])); LWIP_DEBUGF(DHCP_DEBUG | DBG_TRACE, ("skipping option %u\n", options[offset]));
/* skip option type */ /* skip option type */
offset++; offset++;
offset += 1 + options[offset]; offset += 1 + options[offset];
@ -1372,7 +1372,7 @@ static u8_t *dhcp_get_option_ptr(struct dhcp *dhcp, u8_t option_type)
*/ */
static u8_t dhcp_get_option_byte(u8_t *ptr) static u8_t dhcp_get_option_byte(u8_t *ptr)
{ {
DEBUGF(DHCP_DEBUG, ("option byte value=%u\n", *ptr)); LWIP_DEBUGF(DHCP_DEBUG, ("option byte value=%u\n", *ptr));
return *ptr; return *ptr;
} }
@ -1389,7 +1389,7 @@ static u16_t dhcp_get_option_short(u8_t *ptr)
u16_t value; u16_t value;
value = *ptr++ << 8; value = *ptr++ << 8;
value |= *ptr; value |= *ptr;
DEBUGF(DHCP_DEBUG, ("option short value=%u\n", value)); LWIP_DEBUGF(DHCP_DEBUG, ("option short value=%u\n", value));
return value; return value;
} }
@ -1408,6 +1408,6 @@ static u32_t dhcp_get_option_long(u8_t *ptr)
value |= (u32_t)(*ptr++) << 16; value |= (u32_t)(*ptr++) << 16;
value |= (u32_t)(*ptr++) << 8; value |= (u32_t)(*ptr++) << 8;
value |= (u32_t)(*ptr++); value |= (u32_t)(*ptr++);
DEBUGF(DHCP_DEBUG, ("option long value=%lu\n", value)); LWIP_DEBUGF(DHCP_DEBUG, ("option long value=%lu\n", value));
return value; return value;
} }

View File

@ -53,7 +53,7 @@ lwip_chksum(void *dataptr, int len)
{ {
u32_t acc; u32_t acc;
DEBUGF(INET_DEBUG, ("lwip_chksum(%p, %d)\n", dataptr, len)); LWIP_DEBUGF(INET_DEBUG, ("lwip_chksum(%p, %d)\n", dataptr, len));
for(acc = 0; len > 1; len -= 2) { for(acc = 0; len > 1; len -= 2) {
/* acc = acc + *((u16_t *)dataptr)++;*/ /* acc = acc + *((u16_t *)dataptr)++;*/
acc += *(u16_t *)dataptr; acc += *(u16_t *)dataptr;
@ -63,9 +63,9 @@ lwip_chksum(void *dataptr, int len)
/* add up any odd byte */ /* add up any odd byte */
if (len == 1) { if (len == 1) {
acc += htons((u16_t)((*(u8_t *)dataptr) & 0xff) << 8); acc += htons((u16_t)((*(u8_t *)dataptr) & 0xff) << 8);
DEBUGF(INET_DEBUG, ("inet: chksum: odd byte %d\n", *(u8_t *)dataptr)); LWIP_DEBUGF(INET_DEBUG, ("inet: chksum: odd byte %d\n", *(u8_t *)dataptr));
} else { } else {
DEBUGF(INET_DEBUG, ("inet: chksum: no odd byte\n")); LWIP_DEBUGF(INET_DEBUG, ("inet: chksum: no odd byte\n"));
} }
acc = (acc >> 16) + (acc & 0xffffUL); acc = (acc >> 16) + (acc & 0xffffUL);
@ -94,9 +94,9 @@ inet_chksum_pseudo(struct pbuf *p,
swapped = 0; swapped = 0;
/* iterate through all pbuf in chain */ /* iterate through all pbuf in chain */
for(q = p; q != NULL; q = q->next) { for(q = p; q != NULL; q = q->next) {
DEBUGF(INET_DEBUG, ("inet_chksum_pseudo(): checksumming pbuf %p (has next %p) \n", (void *) q, (void *)q->next)); LWIP_DEBUGF(INET_DEBUG, ("inet_chksum_pseudo(): checksumming pbuf %p (has next %p) \n", (void *) q, (void *)q->next));
acc += lwip_chksum(q->payload, q->len); acc += lwip_chksum(q->payload, q->len);
/*DEBUGF(INET_DEBUG, ("inet_chksum_pseudo(): unwrapped lwip_chksum()=%lx \n", acc));*/ /*LWIP_DEBUGF(INET_DEBUG, ("inet_chksum_pseudo(): unwrapped lwip_chksum()=%lx \n", acc));*/
while (acc >> 16) { while (acc >> 16) {
acc = (acc & 0xffffUL) + (acc >> 16); acc = (acc & 0xffffUL) + (acc >> 16);
} }
@ -104,7 +104,7 @@ inet_chksum_pseudo(struct pbuf *p,
swapped = 1 - swapped; swapped = 1 - swapped;
acc = ((acc & 0xff) << 8) | ((acc & 0xff00UL) >> 8); acc = ((acc & 0xff) << 8) | ((acc & 0xff00UL) >> 8);
} }
/*DEBUGF(INET_DEBUG, ("inet_chksum_pseudo(): wrapped lwip_chksum()=%lx \n", acc));*/ /*LWIP_DEBUGF(INET_DEBUG, ("inet_chksum_pseudo(): wrapped lwip_chksum()=%lx \n", acc));*/
} }
if (swapped) { if (swapped) {
@ -120,7 +120,7 @@ inet_chksum_pseudo(struct pbuf *p,
while (acc >> 16) { while (acc >> 16) {
acc = (acc & 0xffffUL) + (acc >> 16); acc = (acc & 0xffffUL) + (acc >> 16);
} }
DEBUGF(INET_DEBUG, ("inet_chksum_pseudo(): pbuf chain lwip_chksum()=%lx\n", acc)); LWIP_DEBUGF(INET_DEBUG, ("inet_chksum_pseudo(): pbuf chain lwip_chksum()=%lx\n", acc));
return ~(acc & 0xffffUL); return ~(acc & 0xffffUL);
} }
/*-----------------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------------*/

View File

@ -63,7 +63,7 @@ icmp_input(struct pbuf *p, struct netif *inp)
iphdr = p->payload; iphdr = p->payload;
hlen = IPH_HL(iphdr) * 4; hlen = IPH_HL(iphdr) * 4;
if (pbuf_header(p, -((s16_t)hlen)) || (p->tot_len < sizeof(u16_t)*2)) { if (pbuf_header(p, -((s16_t)hlen)) || (p->tot_len < sizeof(u16_t)*2)) {
DEBUGF(ICMP_DEBUG, ("icmp_input: short ICMP (%u bytes) received\n", p->tot_len)); LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: short ICMP (%u bytes) received\n", p->tot_len));
pbuf_free(p); pbuf_free(p);
#ifdef ICMP_STATS #ifdef ICMP_STATS
++lwip_stats.icmp.lenerr; ++lwip_stats.icmp.lenerr;
@ -78,17 +78,17 @@ icmp_input(struct pbuf *p, struct netif *inp)
case ICMP_ECHO: case ICMP_ECHO:
if (ip_addr_isbroadcast(&iphdr->dest, &inp->netmask) || if (ip_addr_isbroadcast(&iphdr->dest, &inp->netmask) ||
ip_addr_ismulticast(&iphdr->dest)) { ip_addr_ismulticast(&iphdr->dest)) {
DEBUGF(ICMP_DEBUG, ("Smurf.\n")); LWIP_DEBUGF(ICMP_DEBUG, ("Smurf.\n"));
#ifdef ICMP_STATS #ifdef ICMP_STATS
++lwip_stats.icmp.err; ++lwip_stats.icmp.err;
#endif /* ICMP_STATS */ #endif /* ICMP_STATS */
pbuf_free(p); pbuf_free(p);
return; return;
} }
DEBUGF(ICMP_DEBUG, ("icmp_input: ping\n")); LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: ping\n"));
DEBUGF(DEMO_DEBUG, ("Pong!\n")); LWIP_DEBUGF(DEMO_DEBUG, ("Pong!\n"));
if (p->tot_len < sizeof(struct icmp_echo_hdr)) { if (p->tot_len < sizeof(struct icmp_echo_hdr)) {
DEBUGF(ICMP_DEBUG, ("icmp_input: bad ICMP echo received\n")); LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: bad ICMP echo received\n"));
pbuf_free(p); pbuf_free(p);
#ifdef ICMP_STATS #ifdef ICMP_STATS
++lwip_stats.icmp.lenerr; ++lwip_stats.icmp.lenerr;
@ -99,7 +99,7 @@ icmp_input(struct pbuf *p, struct netif *inp)
} }
iecho = p->payload; iecho = p->payload;
if (inet_chksum_pbuf(p) != 0) { if (inet_chksum_pbuf(p) != 0) {
DEBUGF(ICMP_DEBUG, ("icmp_input: checksum failed for received ICMP echo\n")); LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: checksum failed for received ICMP echo\n"));
pbuf_free(p); pbuf_free(p);
#ifdef ICMP_STATS #ifdef ICMP_STATS
++lwip_stats.icmp.chkerr; ++lwip_stats.icmp.chkerr;
@ -130,7 +130,7 @@ icmp_input(struct pbuf *p, struct netif *inp)
IPH_TTL(iphdr), IP_PROTO_ICMP, inp); IPH_TTL(iphdr), IP_PROTO_ICMP, inp);
break; break;
default: default:
DEBUGF(ICMP_DEBUG, ("icmp_input: ICMP type %d code %d not supported.\n", (int)type, (int)code)); LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: ICMP type %d code %d not supported.\n", (int)type, (int)code));
#ifdef ICMP_STATS #ifdef ICMP_STATS
++lwip_stats.icmp.proterr; ++lwip_stats.icmp.proterr;
++lwip_stats.icmp.drop; ++lwip_stats.icmp.drop;
@ -185,11 +185,11 @@ icmp_time_exceeded(struct pbuf *p, enum icmp_te_type t)
iphdr = p->payload; iphdr = p->payload;
#if ICMP_DEBUG #if ICMP_DEBUG
DEBUGF(ICMP_DEBUG, ("icmp_time_exceeded from ")); LWIP_DEBUGF(ICMP_DEBUG, ("icmp_time_exceeded from "));
ip_addr_debug_print(&(iphdr->src)); ip_addr_debug_print(&(iphdr->src));
DEBUGF(ICMP_DEBUG, (" to ")); LWIP_DEBUGF(ICMP_DEBUG, (" to "));
ip_addr_debug_print(&(iphdr->dest)); ip_addr_debug_print(&(iphdr->dest));
DEBUGF(ICMP_DEBUG, ("\n")); LWIP_DEBUGF(ICMP_DEBUG, ("\n"));
#endif /* ICMP_DEBNUG */ #endif /* ICMP_DEBNUG */
tehdr = q->payload; tehdr = q->payload;

View File

@ -164,7 +164,7 @@ ip_forward(struct pbuf *p, struct ip_hdr *iphdr, struct netif *inp)
/* Find network interface where to forward this IP packet to. */ /* Find network interface where to forward this IP packet to. */
netif = ip_route((struct ip_addr *)&(iphdr->dest)); netif = ip_route((struct ip_addr *)&(iphdr->dest));
if (netif == NULL) { if (netif == NULL) {
DEBUGF(IP_DEBUG, ("ip_forward: no forwarding route for 0x%lx found\n", LWIP_DEBUGF(IP_DEBUG, ("ip_forward: no forwarding route for 0x%lx found\n",
iphdr->dest.addr)); iphdr->dest.addr));
snmp_inc_ipnoroutes(); snmp_inc_ipnoroutes();
return; return;
@ -172,7 +172,7 @@ ip_forward(struct pbuf *p, struct ip_hdr *iphdr, struct netif *inp)
/* Do not forward packets onto the same network interface on which /* Do not forward packets onto the same network interface on which
they arrived. */ they arrived. */
if (netif == inp) { if (netif == inp) {
DEBUGF(IP_DEBUG, ("ip_forward: not bouncing packets back on incoming interface.\n")); LWIP_DEBUGF(IP_DEBUG, ("ip_forward: not bouncing packets back on incoming interface.\n"));
snmp_inc_ipnoroutes(); snmp_inc_ipnoroutes();
return; return;
} }
@ -196,7 +196,7 @@ ip_forward(struct pbuf *p, struct ip_hdr *iphdr, struct netif *inp)
IPH_CHKSUM_SET(iphdr, IPH_CHKSUM(iphdr) + htons(0x100)); IPH_CHKSUM_SET(iphdr, IPH_CHKSUM(iphdr) + htons(0x100));
} }
DEBUGF(IP_DEBUG, ("ip_forward: forwarding packet to 0x%lx\n", LWIP_DEBUGF(IP_DEBUG, ("ip_forward: forwarding packet to 0x%lx\n",
iphdr->dest.addr)); iphdr->dest.addr));
#ifdef IP_STATS #ifdef IP_STATS
@ -236,7 +236,7 @@ ip_input(struct pbuf *p, struct netif *inp) {
/* identify the IP header */ /* identify the IP header */
iphdr = p->payload; iphdr = p->payload;
if (IPH_V(iphdr) != 4) { if (IPH_V(iphdr) != 4) {
DEBUGF(IP_DEBUG | 1, ("IP packet dropped due to bad version number %d\n", IPH_V(iphdr))); LWIP_DEBUGF(IP_DEBUG | 1, ("IP packet dropped due to bad version number %d\n", IPH_V(iphdr)));
#if IP_DEBUG #if IP_DEBUG
ip_debug_print(p); ip_debug_print(p);
#endif /* IP_DEBUG */ #endif /* IP_DEBUG */
@ -255,7 +255,7 @@ ip_input(struct pbuf *p, struct netif *inp) {
/* header length exceeds first pbuf length? */ /* header length exceeds first pbuf length? */
if (iphdrlen > p->len) { if (iphdrlen > p->len) {
DEBUGF(IP_DEBUG | 2, ("IP header (len %u) does not fit in first pbuf (len %u), IP packet droppped.\n", LWIP_DEBUGF(IP_DEBUG | 2, ("IP header (len %u) does not fit in first pbuf (len %u), IP packet droppped.\n",
iphdrlen, p->len)); iphdrlen, p->len));
/* free (drop) packet pbufs */ /* free (drop) packet pbufs */
pbuf_free(p); pbuf_free(p);
@ -270,7 +270,7 @@ ip_input(struct pbuf *p, struct netif *inp) {
/* verify checksum */ /* verify checksum */
if (inet_chksum(iphdr, iphdrlen) != 0) { if (inet_chksum(iphdr, iphdrlen) != 0) {
DEBUGF(IP_DEBUG | 2, ("Checksum (0x%x) failed, IP packet dropped.\n", inet_chksum(iphdr, iphdrlen))); LWIP_DEBUGF(IP_DEBUG | 2, ("Checksum (0x%x) failed, IP packet dropped.\n", inet_chksum(iphdr, iphdrlen)));
#if IP_DEBUG #if IP_DEBUG
ip_debug_print(p); ip_debug_print(p);
#endif /* IP_DEBUG */ #endif /* IP_DEBUG */
@ -290,7 +290,7 @@ ip_input(struct pbuf *p, struct netif *inp) {
/* is this packet for us? */ /* is this packet for us? */
for(netif = netif_list; netif != NULL; netif = netif->next) { for(netif = netif_list; netif != NULL; netif = netif->next) {
DEBUGF(IP_DEBUG, ("ip_input: iphdr->dest 0x%lx netif->ip_addr 0x%lx (0x%lx, 0x%lx, 0x%lx)\n", LWIP_DEBUGF(IP_DEBUG, ("ip_input: iphdr->dest 0x%lx netif->ip_addr 0x%lx (0x%lx, 0x%lx, 0x%lx)\n",
iphdr->dest.addr, netif->ip_addr.addr, iphdr->dest.addr, netif->ip_addr.addr,
iphdr->dest.addr & netif->netmask.addr, iphdr->dest.addr & netif->netmask.addr,
netif->ip_addr.addr & netif->netmask.addr, netif->ip_addr.addr & netif->netmask.addr,
@ -306,7 +306,7 @@ ip_input(struct pbuf *p, struct netif *inp) {
ip_addr_maskcmp(&(iphdr->dest), &(netif->ip_addr), &(netif->netmask))) || ip_addr_maskcmp(&(iphdr->dest), &(netif->ip_addr), &(netif->netmask))) ||
/* or restricted broadcast? */ /* or restricted broadcast? */
ip_addr_cmp(&(iphdr->dest), IP_ADDR_BROADCAST)) { ip_addr_cmp(&(iphdr->dest), IP_ADDR_BROADCAST)) {
DEBUGF(IP_DEBUG, ("ip_input: packet accepted on interface %c%c\n", LWIP_DEBUGF(IP_DEBUG, ("ip_input: packet accepted on interface %c%c\n",
netif->name[0], netif->name[1])); netif->name[0], netif->name[1]));
/* break out of for loop */ /* break out of for loop */
break; break;
@ -320,10 +320,10 @@ ip_input(struct pbuf *p, struct netif *inp) {
if (netif == NULL) { if (netif == NULL) {
/* remote port is DHCP server? */ /* remote port is DHCP server? */
if (IPH_PROTO(iphdr) == IP_PROTO_UDP) { if (IPH_PROTO(iphdr) == IP_PROTO_UDP) {
DEBUGF(IP_DEBUG | DBG_TRACE | 1, ("ip_input: UDP packet to DHCP client port %u\n", LWIP_DEBUGF(IP_DEBUG | DBG_TRACE | 1, ("ip_input: UDP packet to DHCP client port %u\n",
ntohs(((struct udp_hdr *)((u8_t *)iphdr + iphdrlen))->dest))); ntohs(((struct udp_hdr *)((u8_t *)iphdr + iphdrlen))->dest)));
if (ntohs(((struct udp_hdr *)((u8_t *)iphdr + iphdrlen))->dest) == DHCP_CLIENT_PORT) { if (ntohs(((struct udp_hdr *)((u8_t *)iphdr + iphdrlen))->dest) == DHCP_CLIENT_PORT) {
DEBUGF(IP_DEBUG | DBG_TRACE | 1, ("ip_input: DHCP packet accepted.\n")); LWIP_DEBUGF(IP_DEBUG | DBG_TRACE | 1, ("ip_input: DHCP packet accepted.\n"));
netif = inp; netif = inp;
} }
} }
@ -332,7 +332,7 @@ ip_input(struct pbuf *p, struct netif *inp) {
/* packet not for us? */ /* packet not for us? */
if (netif == NULL) { if (netif == NULL) {
/* packet not for us, route or discard */ /* packet not for us, route or discard */
DEBUGF(IP_DEBUG | DBG_TRACE | 1, ("ip_input: packet not for us.\n")); LWIP_DEBUGF(IP_DEBUG | DBG_TRACE | 1, ("ip_input: packet not for us.\n"));
#if IP_FORWARD #if IP_FORWARD
/* non-broadcast packet? */ /* non-broadcast packet? */
if (!ip_addr_isbroadcast(&(iphdr->dest), &(inp->netmask))) { if (!ip_addr_isbroadcast(&(iphdr->dest), &(inp->netmask))) {
@ -350,7 +350,7 @@ ip_input(struct pbuf *p, struct netif *inp) {
#if IP_REASSEMBLY #if IP_REASSEMBLY
if ((IPH_OFFSET(iphdr) & htons(IP_OFFMASK | IP_MF)) != 0) { if ((IPH_OFFSET(iphdr) & htons(IP_OFFMASK | IP_MF)) != 0) {
DEBUGF(IP_DEBUG, ("IP packet is a fragment (id=0x%04x tot_len=%u len=%u MF=%u offset=%u), calling ip_reass()\n", ntohs(IPH_ID(iphdr)), p->tot_len, ntohs(IPH_LEN(iphdr)), !!(IPH_OFFSET(iphdr) & htons(IP_MF)), (ntohs(IPH_OFFSET(iphdr)) & IP_OFFMASK)*8)); LWIP_DEBUGF(IP_DEBUG, ("IP packet is a fragment (id=0x%04x tot_len=%u len=%u MF=%u offset=%u), calling ip_reass()\n", ntohs(IPH_ID(iphdr)), p->tot_len, ntohs(IPH_LEN(iphdr)), !!(IPH_OFFSET(iphdr) & htons(IP_MF)), (ntohs(IPH_OFFSET(iphdr)) & IP_OFFMASK)*8));
p = ip_reass(p); p = ip_reass(p);
if (p == NULL) { if (p == NULL) {
return ERR_OK; return ERR_OK;
@ -360,7 +360,7 @@ ip_input(struct pbuf *p, struct netif *inp) {
#else /* IP_REASSEMBLY */ #else /* IP_REASSEMBLY */
if ((IPH_OFFSET(iphdr) & htons(IP_OFFMASK | IP_MF)) != 0) { if ((IPH_OFFSET(iphdr) & htons(IP_OFFMASK | IP_MF)) != 0) {
pbuf_free(p); pbuf_free(p);
DEBUGF(IP_DEBUG | 2, ("IP packet dropped since it was fragmented (0x%x) (while IP_REASSEMBLY == 0).\n", LWIP_DEBUGF(IP_DEBUG | 2, ("IP packet dropped since it was fragmented (0x%x) (while IP_REASSEMBLY == 0).\n",
ntohs(IPH_OFFSET(iphdr)))); ntohs(IPH_OFFSET(iphdr))));
#ifdef IP_STATS #ifdef IP_STATS
++lwip_stats.ip.opterr; ++lwip_stats.ip.opterr;
@ -373,7 +373,7 @@ ip_input(struct pbuf *p, struct netif *inp) {
#if IP_OPTIONS == 0 #if IP_OPTIONS == 0
if (iphdrlen > IP_HLEN) { if (iphdrlen > IP_HLEN) {
DEBUGF(IP_DEBUG | 2, ("IP packet dropped since there were IP options (while IP_OPTIONS == 0).\n")); LWIP_DEBUGF(IP_DEBUG | 2, ("IP packet dropped since there were IP options (while IP_OPTIONS == 0).\n"));
pbuf_free(p); pbuf_free(p);
#ifdef IP_STATS #ifdef IP_STATS
++lwip_stats.ip.opterr; ++lwip_stats.ip.opterr;
@ -386,9 +386,9 @@ ip_input(struct pbuf *p, struct netif *inp) {
/* send to upper layers */ /* send to upper layers */
#if IP_DEBUG #if IP_DEBUG
DEBUGF(IP_DEBUG, ("ip_input: \n")); LWIP_DEBUGF(IP_DEBUG, ("ip_input: \n"));
ip_debug_print(p); ip_debug_print(p);
DEBUGF(IP_DEBUG, ("ip_input: p->len %d p->tot_len %d\n", p->len, p->tot_len)); LWIP_DEBUGF(IP_DEBUG, ("ip_input: p->len %d p->tot_len %d\n", p->len, p->tot_len));
#endif /* IP_DEBUG */ #endif /* IP_DEBUG */
switch (IPH_PROTO(iphdr)) { switch (IPH_PROTO(iphdr)) {
@ -417,7 +417,7 @@ ip_input(struct pbuf *p, struct netif *inp) {
} }
pbuf_free(p); pbuf_free(p);
DEBUGF(IP_DEBUG | 2, ("Unsupported transport protocol %d\n", IPH_PROTO(iphdr))); LWIP_DEBUGF(IP_DEBUG | 2, ("Unsupported transport protocol %d\n", IPH_PROTO(iphdr)));
#ifdef IP_STATS #ifdef IP_STATS
++lwip_stats.ip.proterr; ++lwip_stats.ip.proterr;
@ -450,7 +450,7 @@ ip_output_if (struct pbuf *p, struct ip_addr *src, struct ip_addr *dest,
if (dest != IP_HDRINCL) { if (dest != IP_HDRINCL) {
if (pbuf_header(p, IP_HLEN)) { if (pbuf_header(p, IP_HLEN)) {
DEBUGF(IP_DEBUG | 2, ("ip_output: not enough room for IP header in pbuf\n")); LWIP_DEBUGF(IP_DEBUG | 2, ("ip_output: not enough room for IP header in pbuf\n"));
#ifdef IP_STATS #ifdef IP_STATS
++lwip_stats.ip.err; ++lwip_stats.ip.err;
@ -494,12 +494,12 @@ ip_output_if (struct pbuf *p, struct ip_addr *src, struct ip_addr *dest,
#ifdef IP_STATS #ifdef IP_STATS
lwip_stats.ip.xmit++; lwip_stats.ip.xmit++;
#endif /* IP_STATS */ #endif /* IP_STATS */
DEBUGF(IP_DEBUG, ("ip_output_if: %c%c%u\n", netif->name[0], netif->name[1], netif->num)); LWIP_DEBUGF(IP_DEBUG, ("ip_output_if: %c%c%u\n", netif->name[0], netif->name[1], netif->num));
#if IP_DEBUG #if IP_DEBUG
ip_debug_print(p); ip_debug_print(p);
#endif /* IP_DEBUG */ #endif /* IP_DEBUG */
DEBUGF(IP_DEBUG, ("netif->output()")); LWIP_DEBUGF(IP_DEBUG, ("netif->output()"));
return netif->output(netif, p, dest); return netif->output(netif, p, dest);
} }
@ -517,7 +517,7 @@ ip_output(struct pbuf *p, struct ip_addr *src, struct ip_addr *dest,
struct netif *netif; struct netif *netif;
if ((netif = ip_route(dest)) == NULL) { if ((netif = ip_route(dest)) == NULL) {
DEBUGF(IP_DEBUG | 2, ("ip_output: No route to 0x%lx\n", dest->addr)); LWIP_DEBUGF(IP_DEBUG | 2, ("ip_output: No route to 0x%lx\n", dest->addr));
#ifdef IP_STATS #ifdef IP_STATS
++lwip_stats.ip.rterr; ++lwip_stats.ip.rterr;
@ -538,38 +538,38 @@ ip_debug_print(struct pbuf *p)
payload = (u8_t *)iphdr + IP_HLEN; payload = (u8_t *)iphdr + IP_HLEN;
DEBUGF(IP_DEBUG, ("IP header:\n")); LWIP_DEBUGF(IP_DEBUG, ("IP header:\n"));
DEBUGF(IP_DEBUG, ("+-------------------------------+\n")); LWIP_DEBUGF(IP_DEBUG, ("+-------------------------------+\n"));
DEBUGF(IP_DEBUG, ("|%2d |%2d | 0x%02x | %5u | (v, hl, tos, len)\n", LWIP_DEBUGF(IP_DEBUG, ("|%2d |%2d | 0x%02x | %5u | (v, hl, tos, len)\n",
IPH_V(iphdr), IPH_V(iphdr),
IPH_HL(iphdr), IPH_HL(iphdr),
IPH_TOS(iphdr), IPH_TOS(iphdr),
ntohs(IPH_LEN(iphdr)))); ntohs(IPH_LEN(iphdr))));
DEBUGF(IP_DEBUG, ("+-------------------------------+\n")); LWIP_DEBUGF(IP_DEBUG, ("+-------------------------------+\n"));
DEBUGF(IP_DEBUG, ("| %5u |%u%u%u| %4u | (id, flags, offset)\n", LWIP_DEBUGF(IP_DEBUG, ("| %5u |%u%u%u| %4u | (id, flags, offset)\n",
ntohs(IPH_ID(iphdr)), ntohs(IPH_ID(iphdr)),
ntohs(IPH_OFFSET(iphdr)) >> 15 & 1, ntohs(IPH_OFFSET(iphdr)) >> 15 & 1,
ntohs(IPH_OFFSET(iphdr)) >> 14 & 1, ntohs(IPH_OFFSET(iphdr)) >> 14 & 1,
ntohs(IPH_OFFSET(iphdr)) >> 13 & 1, ntohs(IPH_OFFSET(iphdr)) >> 13 & 1,
ntohs(IPH_OFFSET(iphdr)) & IP_OFFMASK)); ntohs(IPH_OFFSET(iphdr)) & IP_OFFMASK));
DEBUGF(IP_DEBUG, ("+-------------------------------+\n")); LWIP_DEBUGF(IP_DEBUG, ("+-------------------------------+\n"));
DEBUGF(IP_DEBUG, ("| %3u | %3u | 0x%04x | (ttl, proto, chksum)\n", LWIP_DEBUGF(IP_DEBUG, ("| %3u | %3u | 0x%04x | (ttl, proto, chksum)\n",
IPH_TTL(iphdr), IPH_TTL(iphdr),
IPH_PROTO(iphdr), IPH_PROTO(iphdr),
ntohs(IPH_CHKSUM(iphdr)))); ntohs(IPH_CHKSUM(iphdr))));
DEBUGF(IP_DEBUG, ("+-------------------------------+\n")); LWIP_DEBUGF(IP_DEBUG, ("+-------------------------------+\n"));
DEBUGF(IP_DEBUG, ("| %3ld | %3ld | %3ld | %3ld | (src)\n", LWIP_DEBUGF(IP_DEBUG, ("| %3ld | %3ld | %3ld | %3ld | (src)\n",
ntohl(iphdr->src.addr) >> 24 & 0xff, ntohl(iphdr->src.addr) >> 24 & 0xff,
ntohl(iphdr->src.addr) >> 16 & 0xff, ntohl(iphdr->src.addr) >> 16 & 0xff,
ntohl(iphdr->src.addr) >> 8 & 0xff, ntohl(iphdr->src.addr) >> 8 & 0xff,
ntohl(iphdr->src.addr) & 0xff)); ntohl(iphdr->src.addr) & 0xff));
DEBUGF(IP_DEBUG, ("+-------------------------------+\n")); LWIP_DEBUGF(IP_DEBUG, ("+-------------------------------+\n"));
DEBUGF(IP_DEBUG, ("| %3ld | %3ld | %3ld | %3ld | (dest)\n", LWIP_DEBUGF(IP_DEBUG, ("| %3ld | %3ld | %3ld | %3ld | (dest)\n",
ntohl(iphdr->dest.addr) >> 24 & 0xff, ntohl(iphdr->dest.addr) >> 24 & 0xff,
ntohl(iphdr->dest.addr) >> 16 & 0xff, ntohl(iphdr->dest.addr) >> 16 & 0xff,
ntohl(iphdr->dest.addr) >> 8 & 0xff, ntohl(iphdr->dest.addr) >> 8 & 0xff,
ntohl(iphdr->dest.addr) & 0xff)); ntohl(iphdr->dest.addr) & 0xff));
DEBUGF(IP_DEBUG, ("+-------------------------------+\n")); LWIP_DEBUGF(IP_DEBUG, ("+-------------------------------+\n"));
} }
#endif /* IP_DEBUG */ #endif /* IP_DEBUG */
/*-----------------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------------*/

View File

@ -119,7 +119,7 @@ ip_reass(struct pbuf *p)
write the IP header of the fragment into the reassembly write the IP header of the fragment into the reassembly
buffer. The timer is updated with the maximum age. */ buffer. The timer is updated with the maximum age. */
if (ip_reasstmr == 0) { if (ip_reasstmr == 0) {
DEBUGF(IP_REASS_DEBUG, ("ip_reass: new packet\n")); LWIP_DEBUGF(IP_REASS_DEBUG, ("ip_reass: new packet\n"));
memcpy(iphdr, fraghdr, IP_HLEN); memcpy(iphdr, fraghdr, IP_HLEN);
ip_reasstmr = IP_REASS_MAXAGE; ip_reasstmr = IP_REASS_MAXAGE;
sys_timeout(IP_REASS_TMO, ip_reass_timer, NULL); sys_timeout(IP_REASS_TMO, ip_reass_timer, NULL);
@ -134,7 +134,7 @@ ip_reass(struct pbuf *p)
if (ip_addr_cmp(&iphdr->src, &fraghdr->src) && if (ip_addr_cmp(&iphdr->src, &fraghdr->src) &&
ip_addr_cmp(&iphdr->dest, &fraghdr->dest) && ip_addr_cmp(&iphdr->dest, &fraghdr->dest) &&
IPH_ID(iphdr) == IPH_ID(fraghdr)) { IPH_ID(iphdr) == IPH_ID(fraghdr)) {
DEBUGF(IP_REASS_DEBUG, ("ip_reass: matching old packet\n")); LWIP_DEBUGF(IP_REASS_DEBUG, ("ip_reass: matching old packet\n"));
#ifdef IP_STATS #ifdef IP_STATS
++lwip_stats.ip_frag.cachehit; ++lwip_stats.ip_frag.cachehit;
#endif /* IP_STATS */ #endif /* IP_STATS */
@ -146,7 +146,7 @@ ip_reass(struct pbuf *p)
/* If the offset or the offset + fragment length overflows the /* If the offset or the offset + fragment length overflows the
reassembly buffer, we discard the entire packet. */ reassembly buffer, we discard the entire packet. */
if (offset > IP_REASS_BUFSIZE || offset + len > IP_REASS_BUFSIZE) { if (offset > IP_REASS_BUFSIZE || offset + len > IP_REASS_BUFSIZE) {
DEBUGF(IP_REASS_DEBUG, LWIP_DEBUGF(IP_REASS_DEBUG,
("ip_reass: fragment outside of buffer (%d:%d/%d).\n", offset, ("ip_reass: fragment outside of buffer (%d:%d/%d).\n", offset,
offset + len, IP_REASS_BUFSIZE)); offset + len, IP_REASS_BUFSIZE));
sys_untimeout(ip_reass_timer, NULL); sys_untimeout(ip_reass_timer, NULL);
@ -156,7 +156,7 @@ ip_reass(struct pbuf *p)
/* Copy the fragment into the reassembly buffer, at the right /* Copy the fragment into the reassembly buffer, at the right
offset. */ offset. */
DEBUGF(IP_REASS_DEBUG, LWIP_DEBUGF(IP_REASS_DEBUG,
("ip_reass: copying with offset %d into %d:%d\n", offset, ("ip_reass: copying with offset %d into %d:%d\n", offset,
IP_HLEN + offset, IP_HLEN + offset + len)); IP_HLEN + offset, IP_HLEN + offset + len));
i = IPH_HL(fraghdr) * 4; i = IPH_HL(fraghdr) * 4;
@ -164,7 +164,7 @@ ip_reass(struct pbuf *p)
/* Update the bitmap. */ /* Update the bitmap. */
if (offset / (8 * 8) == (offset + len) / (8 * 8)) { if (offset / (8 * 8) == (offset + len) / (8 * 8)) {
DEBUGF(IP_REASS_DEBUG, LWIP_DEBUGF(IP_REASS_DEBUG,
("ip_reass: updating single byte in bitmap.\n")); ("ip_reass: updating single byte in bitmap.\n"));
/* If the two endpoints are in the same byte, we only update /* If the two endpoints are in the same byte, we only update
that byte. */ that byte. */
@ -176,7 +176,7 @@ ip_reass(struct pbuf *p)
bytes in the endpoints and fill the stuff inbetween with bytes in the endpoints and fill the stuff inbetween with
0xff. */ 0xff. */
ip_reassbitmap[offset / (8 * 8)] |= bitmap_bits[(offset / 8) & 7]; ip_reassbitmap[offset / (8 * 8)] |= bitmap_bits[(offset / 8) & 7];
DEBUGF(IP_REASS_DEBUG, LWIP_DEBUGF(IP_REASS_DEBUG,
("ip_reass: updating many bytes in bitmap (%d:%d).\n", ("ip_reass: updating many bytes in bitmap (%d:%d).\n",
1 + offset / (8 * 8), (offset + len) / (8 * 8))); 1 + offset / (8 * 8), (offset + len) / (8 * 8)));
for (i = 1 + offset / (8 * 8); i < (offset + len) / (8 * 8); ++i) { for (i = 1 + offset / (8 * 8); i < (offset + len) / (8 * 8); ++i) {
@ -195,7 +195,7 @@ ip_reass(struct pbuf *p)
if ((ntohs(IPH_OFFSET(fraghdr)) & IP_MF) == 0) { if ((ntohs(IPH_OFFSET(fraghdr)) & IP_MF) == 0) {
ip_reassflags |= IP_REASS_FLAG_LASTFRAG; ip_reassflags |= IP_REASS_FLAG_LASTFRAG;
ip_reasslen = offset + len; ip_reasslen = offset + len;
DEBUGF(IP_REASS_DEBUG, LWIP_DEBUGF(IP_REASS_DEBUG,
("ip_reass: last fragment seen, total len %d\n", ("ip_reass: last fragment seen, total len %d\n",
ip_reasslen)); ip_reasslen));
} }
@ -208,7 +208,7 @@ ip_reass(struct pbuf *p)
the bitmap. */ the bitmap. */
for (i = 0; i < ip_reasslen / (8 * 8) - 1; ++i) { for (i = 0; i < ip_reasslen / (8 * 8) - 1; ++i) {
if (ip_reassbitmap[i] != 0xff) { if (ip_reassbitmap[i] != 0xff) {
DEBUGF(IP_REASS_DEBUG, LWIP_DEBUGF(IP_REASS_DEBUG,
("ip_reass: last fragment seen, bitmap %d/%d failed (%x)\n", ("ip_reass: last fragment seen, bitmap %d/%d failed (%x)\n",
i, ip_reasslen / (8 * 8) - 1, ip_reassbitmap[i])); i, ip_reasslen / (8 * 8) - 1, ip_reassbitmap[i]));
goto nullreturn; goto nullreturn;
@ -218,7 +218,7 @@ ip_reass(struct pbuf *p)
right amount of bits. */ right amount of bits. */
if (ip_reassbitmap[ip_reasslen / (8 * 8)] != if (ip_reassbitmap[ip_reasslen / (8 * 8)] !=
(u8_t) ~ bitmap_bits[ip_reasslen / 8 & 7]) { (u8_t) ~ bitmap_bits[ip_reasslen / 8 & 7]) {
DEBUGF(IP_REASS_DEBUG, LWIP_DEBUGF(IP_REASS_DEBUG,
("ip_reass: last fragment seen, bitmap %d didn't contain %x (%x)\n", ("ip_reass: last fragment seen, bitmap %d didn't contain %x (%x)\n",
ip_reasslen / (8 * 8), ~bitmap_bits[ip_reasslen / 8 & 7], ip_reasslen / (8 * 8), ~bitmap_bits[ip_reasslen / 8 & 7],
ip_reassbitmap[ip_reasslen / (8 * 8)])); ip_reassbitmap[ip_reasslen / (8 * 8)]));
@ -247,7 +247,7 @@ ip_reass(struct pbuf *p)
/* Copy enough bytes to fill this pbuf in the chain. The /* Copy enough bytes to fill this pbuf in the chain. The
available data in the pbuf is given by the q->len available data in the pbuf is given by the q->len
variable. */ variable. */
DEBUGF(IP_REASS_DEBUG, LWIP_DEBUGF(IP_REASS_DEBUG,
("ip_reass: memcpy from %p (%d) to %p, %d bytes\n", ("ip_reass: memcpy from %p (%d) to %p, %d bytes\n",
&ip_reassbuf[i], i, q->payload, &ip_reassbuf[i], i, q->payload,
q->len > ip_reasslen - i ? ip_reasslen - i : q->len)); q->len > ip_reasslen - i ? ip_reasslen - i : q->len));
@ -263,7 +263,7 @@ ip_reass(struct pbuf *p)
++lwip_stats.ip_frag.memerr; ++lwip_stats.ip_frag.memerr;
#endif /* IP_STATS */ #endif /* IP_STATS */
} }
DEBUGF(IP_REASS_DEBUG, ("ip_reass: p %p\n", (void*)p)); LWIP_DEBUGF(IP_REASS_DEBUG, ("ip_reass: p %p\n", (void*)p));
return p; return p;
} }
} }

View File

@ -61,10 +61,10 @@ icmp_input(struct pbuf *p, struct netif *inp)
switch (type) { switch (type) {
case ICMP6_ECHO: case ICMP6_ECHO:
DEBUGF(ICMP_DEBUG, ("icmp_input: ping\n")); LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: ping\n"));
if (p->tot_len < sizeof(struct icmp_echo_hdr)) { if (p->tot_len < sizeof(struct icmp_echo_hdr)) {
DEBUGF(ICMP_DEBUG, ("icmp_input: bad ICMP echo received\n")); LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: bad ICMP echo received\n"));
pbuf_free(p); pbuf_free(p);
#ifdef ICMP_STATS #ifdef ICMP_STATS
@ -76,14 +76,14 @@ icmp_input(struct pbuf *p, struct netif *inp)
iecho = p->payload; iecho = p->payload;
iphdr = (struct ip_hdr *)((char *)p->payload - IP_HLEN); iphdr = (struct ip_hdr *)((char *)p->payload - IP_HLEN);
if (inet_chksum_pbuf(p) != 0) { if (inet_chksum_pbuf(p) != 0) {
DEBUGF(ICMP_DEBUG, ("icmp_input: checksum failed for received ICMP echo (%x)\n", inet_chksum_pseudo(p, &(iphdr->src), &(iphdr->dest), IP_PROTO_ICMP, p->tot_len))); LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: checksum failed for received ICMP echo (%x)\n", inet_chksum_pseudo(p, &(iphdr->src), &(iphdr->dest), IP_PROTO_ICMP, p->tot_len)));
#ifdef ICMP_STATS #ifdef ICMP_STATS
++lwip_stats.icmp.chkerr; ++lwip_stats.icmp.chkerr;
#endif /* ICMP_STATS */ #endif /* ICMP_STATS */
/* return;*/ /* return;*/
} }
DEBUGF(ICMP_DEBUG, ("icmp: p->len %d p->tot_len %d\n", p->len, p->tot_len)); LWIP_DEBUGF(ICMP_DEBUG, ("icmp: p->len %d p->tot_len %d\n", p->len, p->tot_len));
ip_addr_set(&tmpaddr, &(iphdr->src)); ip_addr_set(&tmpaddr, &(iphdr->src));
ip_addr_set(&(iphdr->src), &(iphdr->dest)); ip_addr_set(&(iphdr->src), &(iphdr->dest));
ip_addr_set(&(iphdr->dest), &tmpaddr); ip_addr_set(&(iphdr->dest), &tmpaddr);
@ -94,17 +94,17 @@ icmp_input(struct pbuf *p, struct netif *inp)
} else { } else {
iecho->chksum += htons(ICMP6_ECHO << 8); iecho->chksum += htons(ICMP6_ECHO << 8);
} }
DEBUGF(ICMP_DEBUG, ("icmp_input: checksum failed for received ICMP echo (%x)\n", inet_chksum_pseudo(p, &(iphdr->src), &(iphdr->dest), IP_PROTO_ICMP, p->tot_len))); LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: checksum failed for received ICMP echo (%x)\n", inet_chksum_pseudo(p, &(iphdr->src), &(iphdr->dest), IP_PROTO_ICMP, p->tot_len)));
#ifdef ICMP_STATS #ifdef ICMP_STATS
++lwip_stats.icmp.xmit; ++lwip_stats.icmp.xmit;
#endif /* ICMP_STATS */ #endif /* ICMP_STATS */
/* DEBUGF("icmp: p->len %d p->tot_len %d\n", p->len, p->tot_len);*/ /* LWIP_DEBUGF("icmp: p->len %d p->tot_len %d\n", p->len, p->tot_len);*/
ip_output_if (p, &(iphdr->src), IP_HDRINCL, ip_output_if (p, &(iphdr->src), IP_HDRINCL,
iphdr->hoplim, IP_PROTO_ICMP, inp); iphdr->hoplim, IP_PROTO_ICMP, inp);
break; break;
default: default:
DEBUGF(ICMP_DEBUG, ("icmp_input: ICMP type %d not supported.\n", (int)type)); LWIP_DEBUGF(ICMP_DEBUG, ("icmp_input: ICMP type %d not supported.\n", (int)type));
#ifdef ICMP_STATS #ifdef ICMP_STATS
++lwip_stats.icmp.proterr; ++lwip_stats.icmp.proterr;
++lwip_stats.icmp.drop; ++lwip_stats.icmp.drop;
@ -151,7 +151,7 @@ icmp_time_exceeded(struct pbuf *p, enum icmp_te_type t)
struct ip_hdr *iphdr; struct ip_hdr *iphdr;
struct icmp_te_hdr *tehdr; struct icmp_te_hdr *tehdr;
DEBUGF(ICMP_DEBUG, ("icmp_time_exceeded\n")); LWIP_DEBUGF(ICMP_DEBUG, ("icmp_time_exceeded\n"));
q = pbuf_alloc(PBUF_IP, 8 + IP_HLEN + 8, PBUF_RAM); q = pbuf_alloc(PBUF_IP, 8 + IP_HLEN + 8, PBUF_RAM);

View File

@ -101,11 +101,11 @@ ip_forward(struct pbuf *p, struct ip_hdr *iphdr)
if ((netif = ip_route((struct ip_addr *)&(iphdr->dest))) == NULL) { if ((netif = ip_route((struct ip_addr *)&(iphdr->dest))) == NULL) {
DEBUGF(IP_DEBUG, ("ip_input: no forwarding route found for ")); LWIP_DEBUGF(IP_DEBUG, ("ip_input: no forwarding route found for "));
#if IP_DEBUG #if IP_DEBUG
ip_addr_debug_print(&(iphdr->dest)); ip_addr_debug_print(&(iphdr->dest));
#endif /* IP_DEBUG */ #endif /* IP_DEBUG */
DEBUGF(IP_DEBUG, ("\n")); LWIP_DEBUGF(IP_DEBUG, ("\n"));
pbuf_free(p); pbuf_free(p);
return; return;
} }
@ -127,11 +127,11 @@ ip_forward(struct pbuf *p, struct ip_hdr *iphdr)
}*/ }*/
DEBUGF(IP_DEBUG, ("ip_forward: forwarding packet to ")); LWIP_DEBUGF(IP_DEBUG, ("ip_forward: forwarding packet to "));
#if IP_DEBUG #if IP_DEBUG
ip_addr_debug_print(&(iphdr->dest)); ip_addr_debug_print(&(iphdr->dest));
#endif /* IP_DEBUG */ #endif /* IP_DEBUG */
DEBUGF(IP_DEBUG, ("\n")); LWIP_DEBUGF(IP_DEBUG, ("\n"));
#ifdef IP_STATS #ifdef IP_STATS
++lwip_stats.ip.fw; ++lwip_stats.ip.fw;
@ -175,7 +175,7 @@ ip_input(struct pbuf *p, struct netif *inp) {
if (iphdr->v != 6) { if (iphdr->v != 6) {
DEBUGF(IP_DEBUG, ("IP packet dropped due to bad version number\n")); LWIP_DEBUGF(IP_DEBUG, ("IP packet dropped due to bad version number\n"));
#if IP_DEBUG #if IP_DEBUG
ip_debug_print(p); ip_debug_print(p);
#endif /* IP_DEBUG */ #endif /* IP_DEBUG */
@ -190,11 +190,11 @@ ip_input(struct pbuf *p, struct netif *inp) {
/* is this packet for us? */ /* is this packet for us? */
for(netif = netif_list; netif != NULL; netif = netif->next) { for(netif = netif_list; netif != NULL; netif = netif->next) {
#if IP_DEBUG #if IP_DEBUG
DEBUGF(IP_DEBUG, ("ip_input: iphdr->dest ")); LWIP_DEBUGF(IP_DEBUG, ("ip_input: iphdr->dest "));
ip_addr_debug_print(&(iphdr->dest)); ip_addr_debug_print(&(iphdr->dest));
DEBUGF(IP_DEBUG, ("netif->ip_addr ")); LWIP_DEBUGF(IP_DEBUG, ("netif->ip_addr "));
ip_addr_debug_print(&(netif->ip_addr)); ip_addr_debug_print(&(netif->ip_addr));
DEBUGF(IP_DEBUG, ("\n")); LWIP_DEBUGF(IP_DEBUG, ("\n"));
#endif /* IP_DEBUG */ #endif /* IP_DEBUG */
if (ip_addr_cmp(&(iphdr->dest), &(netif->ip_addr))) { if (ip_addr_cmp(&(iphdr->dest), &(netif->ip_addr))) {
break; break;
@ -215,9 +215,9 @@ ip_input(struct pbuf *p, struct netif *inp) {
/* send to upper layers */ /* send to upper layers */
#if IP_DEBUG #if IP_DEBUG
/* DEBUGF("ip_input: \n"); /* LWIP_DEBUGF("ip_input: \n");
ip_debug_print(p); ip_debug_print(p);
DEBUGF("ip_input: p->len %u p->tot_len %u\n", p->len, p->tot_len);*/ LWIP_DEBUGF("ip_input: p->len %u p->tot_len %u\n", p->len, p->tot_len);*/
#endif /* IP_DEBUG */ #endif /* IP_DEBUG */
@ -237,7 +237,7 @@ ip_input(struct pbuf *p, struct netif *inp) {
/* send ICMP destination protocol unreachable */ /* send ICMP destination protocol unreachable */
icmp_dest_unreach(p, ICMP_DUR_PROTO); icmp_dest_unreach(p, ICMP_DUR_PROTO);
pbuf_free(p); pbuf_free(p);
DEBUGF(IP_DEBUG, ("Unsupported transport protocol %u\n", LWIP_DEBUGF(IP_DEBUG, ("Unsupported transport protocol %u\n",
iphdr->nexthdr)); iphdr->nexthdr));
#ifdef IP_STATS #ifdef IP_STATS
@ -268,7 +268,7 @@ ip_output_if (struct pbuf *p, struct ip_addr *src, struct ip_addr *dest,
printf("len %u tot_len %u\n", p->len, p->tot_len); printf("len %u tot_len %u\n", p->len, p->tot_len);
if (pbuf_header(p, IP_HLEN)) { if (pbuf_header(p, IP_HLEN)) {
DEBUGF(IP_DEBUG, ("ip_output: not enough room for IP header in pbuf\n")); LWIP_DEBUGF(IP_DEBUG, ("ip_output: not enough room for IP header in pbuf\n"));
#ifdef IP_STATS #ifdef IP_STATS
++lwip_stats.ip.err; ++lwip_stats.ip.err;
#endif /* IP_STATS */ #endif /* IP_STATS */
@ -303,7 +303,7 @@ ip_output_if (struct pbuf *p, struct ip_addr *src, struct ip_addr *dest,
++lwip_stats.ip.xmit; ++lwip_stats.ip.xmit;
#endif /* IP_STATS */ #endif /* IP_STATS */
DEBUGF(IP_DEBUG, ("ip_output_if: %c%c (len %u)\n", netif->name[0], netif->name[1], p->tot_len)); LWIP_DEBUGF(IP_DEBUG, ("ip_output_if: %c%c (len %u)\n", netif->name[0], netif->name[1], p->tot_len));
#if IP_DEBUG #if IP_DEBUG
ip_debug_print(p); ip_debug_print(p);
#endif /* IP_DEBUG */ #endif /* IP_DEBUG */
@ -324,7 +324,7 @@ ip_output(struct pbuf *p, struct ip_addr *src, struct ip_addr *dest,
{ {
struct netif *netif; struct netif *netif;
if ((netif = ip_route(dest)) == NULL) { if ((netif = ip_route(dest)) == NULL) {
DEBUGF(IP_DEBUG, ("ip_output: No route to 0x%lx\n", dest->addr)); LWIP_DEBUGF(IP_DEBUG, ("ip_output: No route to 0x%lx\n", dest->addr));
#ifdef IP_STATS #ifdef IP_STATS
++lwip_stats.ip.rterr; ++lwip_stats.ip.rterr;
#endif /* IP_STATS */ #endif /* IP_STATS */
@ -343,44 +343,44 @@ ip_debug_print(struct pbuf *p)
payload = (char *)iphdr + IP_HLEN; payload = (char *)iphdr + IP_HLEN;
DEBUGF(IP_DEBUG, ("IP header:\n")); LWIP_DEBUGF(IP_DEBUG, ("IP header:\n"));
DEBUGF(IP_DEBUG, ("+-------------------------------+\n")); LWIP_DEBUGF(IP_DEBUG, ("+-------------------------------+\n"));
DEBUGF(IP_DEBUG, ("|%2d | %x%x | %x%x | (v, traffic class, flow label)\n", LWIP_DEBUGF(IP_DEBUG, ("|%2d | %x%x | %x%x | (v, traffic class, flow label)\n",
iphdr->v, iphdr->v,
iphdr->tclass1, iphdr->tclass2, iphdr->tclass1, iphdr->tclass2,
iphdr->flow1, iphdr->flow2)); iphdr->flow1, iphdr->flow2));
DEBUGF(IP_DEBUG, ("+-------------------------------+\n")); LWIP_DEBUGF(IP_DEBUG, ("+-------------------------------+\n"));
DEBUGF(IP_DEBUG, ("| %5u | %2u | %2u | (len, nexthdr, hoplim)\n", LWIP_DEBUGF(IP_DEBUG, ("| %5u | %2u | %2u | (len, nexthdr, hoplim)\n",
ntohs(iphdr->len), ntohs(iphdr->len),
iphdr->nexthdr, iphdr->nexthdr,
iphdr->hoplim)); iphdr->hoplim));
DEBUGF(IP_DEBUG, ("+-------------------------------+\n")); LWIP_DEBUGF(IP_DEBUG, ("+-------------------------------+\n"));
DEBUGF(IP_DEBUG, ("| %4lx | %4lx | (src)\n", LWIP_DEBUGF(IP_DEBUG, ("| %4lx | %4lx | (src)\n",
ntohl(iphdr->src.addr[0]) >> 16 & 0xffff, ntohl(iphdr->src.addr[0]) >> 16 & 0xffff,
ntohl(iphdr->src.addr[0]) & 0xffff)); ntohl(iphdr->src.addr[0]) & 0xffff));
DEBUGF(IP_DEBUG, ("| %4lx | %4lx | (src)\n", LWIP_DEBUGF(IP_DEBUG, ("| %4lx | %4lx | (src)\n",
ntohl(iphdr->src.addr[1]) >> 16 & 0xffff, ntohl(iphdr->src.addr[1]) >> 16 & 0xffff,
ntohl(iphdr->src.addr[1]) & 0xffff)); ntohl(iphdr->src.addr[1]) & 0xffff));
DEBUGF(IP_DEBUG, ("| %4lx | %4lx | (src)\n", LWIP_DEBUGF(IP_DEBUG, ("| %4lx | %4lx | (src)\n",
ntohl(iphdr->src.addr[2]) >> 16 & 0xffff, ntohl(iphdr->src.addr[2]) >> 16 & 0xffff,
ntohl(iphdr->src.addr[2]) & 0xffff)); ntohl(iphdr->src.addr[2]) & 0xffff));
DEBUGF(IP_DEBUG, ("| %4lx | %4lx | (src)\n", LWIP_DEBUGF(IP_DEBUG, ("| %4lx | %4lx | (src)\n",
ntohl(iphdr->src.addr[3]) >> 16 & 0xffff, ntohl(iphdr->src.addr[3]) >> 16 & 0xffff,
ntohl(iphdr->src.addr[3]) & 0xffff)); ntohl(iphdr->src.addr[3]) & 0xffff));
DEBUGF(IP_DEBUG, ("+-------------------------------+\n")); LWIP_DEBUGF(IP_DEBUG, ("+-------------------------------+\n"));
DEBUGF(IP_DEBUG, ("| %4lx | %4lx | (dest)\n", LWIP_DEBUGF(IP_DEBUG, ("| %4lx | %4lx | (dest)\n",
ntohl(iphdr->dest.addr[0]) >> 16 & 0xffff, ntohl(iphdr->dest.addr[0]) >> 16 & 0xffff,
ntohl(iphdr->dest.addr[0]) & 0xffff)); ntohl(iphdr->dest.addr[0]) & 0xffff));
DEBUGF(IP_DEBUG, ("| %4lx | %4lx | (dest)\n", LWIP_DEBUGF(IP_DEBUG, ("| %4lx | %4lx | (dest)\n",
ntohl(iphdr->dest.addr[1]) >> 16 & 0xffff, ntohl(iphdr->dest.addr[1]) >> 16 & 0xffff,
ntohl(iphdr->dest.addr[1]) & 0xffff)); ntohl(iphdr->dest.addr[1]) & 0xffff));
DEBUGF(IP_DEBUG, ("| %4lx | %4lx | (dest)\n", LWIP_DEBUGF(IP_DEBUG, ("| %4lx | %4lx | (dest)\n",
ntohl(iphdr->dest.addr[2]) >> 16 & 0xffff, ntohl(iphdr->dest.addr[2]) >> 16 & 0xffff,
ntohl(iphdr->dest.addr[2]) & 0xffff)); ntohl(iphdr->dest.addr[2]) & 0xffff));
DEBUGF(IP_DEBUG, ("| %4lx | %4lx | (dest)\n", LWIP_DEBUGF(IP_DEBUG, ("| %4lx | %4lx | (dest)\n",
ntohl(iphdr->dest.addr[3]) >> 16 & 0xffff, ntohl(iphdr->dest.addr[3]) >> 16 & 0xffff,
ntohl(iphdr->dest.addr[3]) & 0xffff)); ntohl(iphdr->dest.addr[3]) & 0xffff));
DEBUGF(IP_DEBUG, ("+-------------------------------+\n")); LWIP_DEBUGF(IP_DEBUG, ("+-------------------------------+\n"));
} }
#endif /* IP_DEBUG */ #endif /* IP_DEBUG */
/*-----------------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------------*/

View File

@ -135,7 +135,7 @@ mem_free(void *rmem)
struct mem *mem; struct mem *mem;
if (rmem == NULL) { if (rmem == NULL) {
DEBUGF(MEM_DEBUG | DBG_TRACE | 2, ("mem_free(p == NULL) was called.\n")); LWIP_DEBUGF(MEM_DEBUG | DBG_TRACE | 2, ("mem_free(p == NULL) was called.\n"));
return; return;
} }
@ -145,7 +145,7 @@ mem_free(void *rmem)
(u8_t *)rmem < (u8_t *)ram_end); (u8_t *)rmem < (u8_t *)ram_end);
if ((u8_t *)rmem < (u8_t *)ram || (u8_t *)rmem >= (u8_t *)ram_end) { if ((u8_t *)rmem < (u8_t *)ram || (u8_t *)rmem >= (u8_t *)ram_end) {
DEBUGF(MEM_DEBUG | 3, ("mem_free: illegal memory\n")); LWIP_DEBUGF(MEM_DEBUG | 3, ("mem_free: illegal memory\n"));
#ifdef MEM_STATS #ifdef MEM_STATS
++lwip_stats.mem.err; ++lwip_stats.mem.err;
#endif /* MEM_STATS */ #endif /* MEM_STATS */
@ -205,7 +205,7 @@ mem_realloc(void *rmem, mem_size_t newsize)
(u8_t *)rmem < (u8_t *)ram_end); (u8_t *)rmem < (u8_t *)ram_end);
if ((u8_t *)rmem < (u8_t *)ram || (u8_t *)rmem >= (u8_t *)ram_end) { if ((u8_t *)rmem < (u8_t *)ram || (u8_t *)rmem >= (u8_t *)ram_end) {
DEBUGF(MEM_DEBUG | 3, ("mem_realloc: illegal memory\n")); LWIP_DEBUGF(MEM_DEBUG | 3, ("mem_realloc: illegal memory\n"));
return rmem; return rmem;
} }
mem = (struct mem *)((u8_t *)rmem - SIZEOF_STRUCT_MEM); mem = (struct mem *)((u8_t *)rmem - SIZEOF_STRUCT_MEM);
@ -296,7 +296,7 @@ mem_malloc(mem_size_t size)
return (u8_t *)mem + SIZEOF_STRUCT_MEM; return (u8_t *)mem + SIZEOF_STRUCT_MEM;
} }
} }
DEBUGF(MEM_DEBUG | 2, ("mem_malloc: could not allocate %d bytes\n", (int)size)); LWIP_DEBUGF(MEM_DEBUG | 2, ("mem_malloc: could not allocate %d bytes\n", (int)size));
#ifdef MEM_STATS #ifdef MEM_STATS
++lwip_stats.mem.err; ++lwip_stats.mem.err;
#endif /* MEM_STATS */ #endif /* MEM_STATS */

View File

@ -204,7 +204,7 @@ memp_malloc(memp_t type)
memset(mem, 0, memp_sizes[type]); memset(mem, 0, memp_sizes[type]);
return mem; return mem;
} else { } else {
DEBUGF(MEMP_DEBUG | 2, ("memp_malloc: out of memory in pool %d\n", type)); LWIP_DEBUGF(MEMP_DEBUG | 2, ("memp_malloc: out of memory in pool %d\n", type));
#ifdef MEMP_STATS #ifdef MEMP_STATS
++lwip_stats.memp[type].err; ++lwip_stats.memp[type].err;
#endif /* MEMP_STATS */ #endif /* MEMP_STATS */

View File

@ -74,7 +74,7 @@ netif_add(struct ip_addr *ipaddr, struct ip_addr *netmask,
netif = mem_malloc(sizeof(struct netif)); netif = mem_malloc(sizeof(struct netif));
if (netif == NULL) { if (netif == NULL) {
DEBUGF(NETIF_DEBUG, ("netif_add(): out of memory for netif\n")); LWIP_DEBUGF(NETIF_DEBUG, ("netif_add(): out of memory for netif\n"));
return NULL; return NULL;
} }
#if LWIP_DHCP #if LWIP_DHCP
@ -98,14 +98,14 @@ netif_add(struct ip_addr *ipaddr, struct ip_addr *netmask,
netif->next = netif_list; netif->next = netif_list;
netif_list = netif; netif_list = netif;
#if NETIF_DEBUG #if NETIF_DEBUG
DEBUGF(NETIF_DEBUG, ("netif: added interface %c%c IP addr ", LWIP_DEBUGF(NETIF_DEBUG, ("netif: added interface %c%c IP addr ",
netif->name[0], netif->name[1])); netif->name[0], netif->name[1]));
ip_addr_debug_print(ipaddr); ip_addr_debug_print(ipaddr);
DEBUGF(NETIF_DEBUG, (" netmask ")); LWIP_DEBUGF(NETIF_DEBUG, (" netmask "));
ip_addr_debug_print(netmask); ip_addr_debug_print(netmask);
DEBUGF(NETIF_DEBUG, (" gw ")); LWIP_DEBUGF(NETIF_DEBUG, (" gw "));
ip_addr_debug_print(gw); ip_addr_debug_print(gw);
DEBUGF(NETIF_DEBUG, ("\n")); LWIP_DEBUGF(NETIF_DEBUG, ("\n"));
#endif /* NETIF_DEBUG */ #endif /* NETIF_DEBUG */
return netif; return netif;
} }
@ -143,7 +143,7 @@ void netif_remove(struct netif * netif)
if (netif_default == netif) if (netif_default == netif)
/* reset default netif */ /* reset default netif */
netif_default = NULL; netif_default = NULL;
DEBUGF( NETIF_DEBUG, ("netif_remove: removed netif\n") ); LWIP_DEBUGF( NETIF_DEBUG, ("netif_remove: removed netif\n") );
mem_free( netif ); mem_free( netif );
} }
@ -163,11 +163,11 @@ netif_find(char *name)
if (num == netif->num && if (num == netif->num &&
name[0] == netif->name[0] && name[0] == netif->name[0] &&
name[1] == netif->name[1]) { name[1] == netif->name[1]) {
DEBUGF(NETIF_DEBUG, ("netif_find: found %c%c\n", name[0], name[1])); LWIP_DEBUGF(NETIF_DEBUG, ("netif_find: found %c%c\n", name[0], name[1]));
return netif; return netif;
} }
} }
DEBUGF(NETIF_DEBUG, ("netif_find: didn't find %c%c\n", name[0], name[1])); LWIP_DEBUGF(NETIF_DEBUG, ("netif_find: didn't find %c%c\n", name[0], name[1]));
return NULL; return NULL;
} }
/*-----------------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------------*/
@ -184,14 +184,14 @@ netif_set_ipaddr(struct netif *netif, struct ip_addr *ipaddr)
if ((ip_addr_cmp(ipaddr, &(netif->ip_addr))) == 0) if ((ip_addr_cmp(ipaddr, &(netif->ip_addr))) == 0)
{ {
extern struct tcp_pcb *tcp_active_pcbs; extern struct tcp_pcb *tcp_active_pcbs;
DEBUGF(NETIF_DEBUG | 1, ("netif_set_ipaddr: netif address being changed\n")); LWIP_DEBUGF(NETIF_DEBUG | 1, ("netif_set_ipaddr: netif address being changed\n"));
pcb = tcp_active_pcbs; pcb = tcp_active_pcbs;
while (pcb != NULL) { while (pcb != NULL) {
/* PCB bound to current local interface address? */ /* PCB bound to current local interface address? */
if (ip_addr_cmp(&(pcb->local_ip), &(netif->ip_addr))) { if (ip_addr_cmp(&(pcb->local_ip), &(netif->ip_addr))) {
/* this connection must be aborted */ /* this connection must be aborted */
struct tcp_pcb *next = pcb->next; struct tcp_pcb *next = pcb->next;
DEBUGF(NETIF_DEBUG | 1, ("netif_set_ipaddr: aborting pcb %p\n", (void *)pcb)); LWIP_DEBUGF(NETIF_DEBUG | 1, ("netif_set_ipaddr: aborting pcb %p\n", (void *)pcb));
tcp_abort(pcb); tcp_abort(pcb);
pcb = next; pcb = next;
} else { } else {
@ -210,8 +210,8 @@ netif_set_ipaddr(struct netif *netif, struct ip_addr *ipaddr)
} }
#endif #endif
ip_addr_set(&(netif->ip_addr), ipaddr); ip_addr_set(&(netif->ip_addr), ipaddr);
DEBUGF(NETIF_DEBUG | DBG_TRACE | DBG_STATE | 3, ("netif: IP address of interface %c%c set to %u.%u.%u.%u\n", 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], netif->name[0], netif->name[1],
(u8_t)(ntohl(netif->ip_addr.addr) >> 24 & 0xff), (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) >> 16 & 0xff),
(u8_t)(ntohl(netif->ip_addr.addr) >> 8 & 0xff), (u8_t)(ntohl(netif->ip_addr.addr) >> 8 & 0xff),
@ -222,7 +222,7 @@ void
netif_set_gw(struct netif *netif, struct ip_addr *gw) netif_set_gw(struct netif *netif, struct ip_addr *gw)
{ {
ip_addr_set(&(netif->gw), gw); ip_addr_set(&(netif->gw), gw);
DEBUGF(NETIF_DEBUG | DBG_TRACE | DBG_STATE | 3, ("netif: GW address of interface %c%c set to %u.%u.%u.%u\n", 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], netif->name[0], netif->name[1],
(u8_t)(ntohl(netif->gw.addr) >> 24 & 0xff), (u8_t)(ntohl(netif->gw.addr) >> 24 & 0xff),
(u8_t)(ntohl(netif->gw.addr) >> 16 & 0xff), (u8_t)(ntohl(netif->gw.addr) >> 16 & 0xff),
@ -234,7 +234,7 @@ void
netif_set_netmask(struct netif *netif, struct ip_addr *netmask) netif_set_netmask(struct netif *netif, struct ip_addr *netmask)
{ {
ip_addr_set(&(netif->netmask), netmask); ip_addr_set(&(netif->netmask), netmask);
DEBUGF(NETIF_DEBUG | DBG_TRACE | DBG_STATE | 3, ("netif: netmask of interface %c%c set to %u.%u.%u.%u\n", 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], netif->name[0], netif->name[1],
(u8_t)(ntohl(netif->netmask.addr) >> 24 & 0xff), (u8_t)(ntohl(netif->netmask.addr) >> 24 & 0xff),
(u8_t)(ntohl(netif->netmask.addr) >> 16 & 0xff), (u8_t)(ntohl(netif->netmask.addr) >> 16 & 0xff),
@ -246,7 +246,7 @@ void
netif_set_default(struct netif *netif) netif_set_default(struct netif *netif)
{ {
netif_default = netif; netif_default = netif;
DEBUGF(NETIF_DEBUG, ("netif: setting default interface %c%c\n", LWIP_DEBUGF(NETIF_DEBUG, ("netif: setting default interface %c%c\n",
netif ? netif->name[0] : '\'', netif ? netif->name[1] : '\'')); netif ? netif->name[0] : '\'', netif ? netif->name[1] : '\''));
} }
/*-----------------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------------*/

View File

@ -213,7 +213,7 @@ pbuf_alloc(pbuf_layer l, u16_t length, pbuf_flag flag)
struct pbuf *p, *q, *r; struct pbuf *p, *q, *r;
u16_t offset; u16_t offset;
s32_t rem_len; /* remaining length */ s32_t rem_len; /* remaining length */
DEBUGF(PBUF_DEBUG | DBG_TRACE | 3, ("pbuf_alloc(length=%u)\n", length)); LWIP_DEBUGF(PBUF_DEBUG | DBG_TRACE | 3, ("pbuf_alloc(length=%u)\n", length));
/* determine header offset */ /* determine header offset */
offset = 0; offset = 0;
@ -241,7 +241,7 @@ pbuf_alloc(pbuf_layer l, u16_t length, pbuf_flag flag)
case PBUF_POOL: case PBUF_POOL:
/* allocate head of pbuf chain into p */ /* allocate head of pbuf chain into p */
p = pbuf_pool_alloc(); p = pbuf_pool_alloc();
DEBUGF(PBUF_DEBUG | DBG_TRACE | 3, ("pbuf_alloc: allocated pbuf %p\n", p)); LWIP_DEBUGF(PBUF_DEBUG | DBG_TRACE | 3, ("pbuf_alloc: allocated pbuf %p\n", p));
if (p == NULL) { if (p == NULL) {
#ifdef PBUF_STATS #ifdef PBUF_STATS
++lwip_stats.pbuf.err; ++lwip_stats.pbuf.err;
@ -273,7 +273,7 @@ pbuf_alloc(pbuf_layer l, u16_t length, pbuf_flag flag)
while (rem_len > 0) { while (rem_len > 0) {
q = pbuf_pool_alloc(); q = pbuf_pool_alloc();
if (q == NULL) { if (q == NULL) {
DEBUGF(PBUF_DEBUG | 2, ("pbuf_alloc: Out of pbufs in pool.\n")); LWIP_DEBUGF(PBUF_DEBUG | 2, ("pbuf_alloc: Out of pbufs in pool.\n"));
#ifdef PBUF_STATS #ifdef PBUF_STATS
++lwip_stats.pbuf.err; ++lwip_stats.pbuf.err;
#endif /* PBUF_STATS */ #endif /* PBUF_STATS */
@ -325,7 +325,7 @@ pbuf_alloc(pbuf_layer l, u16_t length, pbuf_flag flag)
/* only allocate memory for the pbuf structure */ /* only allocate memory for the pbuf structure */
p = memp_mallocp(MEMP_PBUF); p = memp_mallocp(MEMP_PBUF);
if (p == NULL) { if (p == NULL) {
DEBUGF(PBUF_DEBUG | DBG_TRACE | 2, ("pbuf_alloc: Could not allocate MEMP_PBUF for PBUF_%s.\n", flag == PBUF_ROM?"ROM":"REF")); LWIP_DEBUGF(PBUF_DEBUG | DBG_TRACE | 2, ("pbuf_alloc: Could not allocate MEMP_PBUF for PBUF_%s.\n", flag == PBUF_ROM?"ROM":"REF"));
return NULL; return NULL;
} }
/* caller must set this field properly, afterwards */ /* caller must set this field properly, afterwards */
@ -340,7 +340,7 @@ pbuf_alloc(pbuf_layer l, u16_t length, pbuf_flag flag)
} }
/* set reference count */ /* set reference count */
p->ref = 1; p->ref = 1;
DEBUGF(PBUF_DEBUG | DBG_TRACE | 3, ("pbuf_alloc(length=%u) == %p\n", length, (void *)p)); LWIP_DEBUGF(PBUF_DEBUG | DBG_TRACE | 3, ("pbuf_alloc(length=%u) == %p\n", length, (void *)p));
return p; return p;
} }
@ -477,7 +477,7 @@ pbuf_header(struct pbuf *p, s16_t header_size)
p->payload = (u8_t *)p->payload - header_size; p->payload = (u8_t *)p->payload - header_size;
/* boundary check fails? */ /* boundary check fails? */
if ((u8_t *)p->payload < (u8_t *)p + sizeof(struct pbuf)) { if ((u8_t *)p->payload < (u8_t *)p + sizeof(struct pbuf)) {
DEBUGF( PBUF_DEBUG | 2, ("pbuf_header: failed as %p < %p\n", LWIP_DEBUGF( PBUF_DEBUG | 2, ("pbuf_header: failed as %p < %p\n",
(u8_t *)p->payload, (u8_t *)p->payload,
(u8_t *)p + sizeof(struct pbuf)) );\ (u8_t *)p + sizeof(struct pbuf)) );\
/* restore old payload pointer */ /* restore old payload pointer */
@ -497,7 +497,7 @@ pbuf_header(struct pbuf *p, s16_t header_size)
return 1; return 1;
} }
} }
DEBUGF( PBUF_DEBUG, ("pbuf_header: old %p new %p (%d)\n", payload, p->payload, header_size) ); LWIP_DEBUGF( PBUF_DEBUG, ("pbuf_header: old %p new %p (%d)\n", payload, p->payload, header_size) );
/* modify pbuf length fields */ /* modify pbuf length fields */
p->len += header_size; p->len += header_size;
p->tot_len += header_size; p->tot_len += header_size;
@ -541,10 +541,10 @@ pbuf_free(struct pbuf *p)
SYS_ARCH_DECL_PROTECT(old_level); SYS_ARCH_DECL_PROTECT(old_level);
if (p == NULL) { if (p == NULL) {
DEBUGF(PBUF_DEBUG | DBG_TRACE | 2, ("pbuf_free(p == NULL) was called.\n")); LWIP_DEBUGF(PBUF_DEBUG | DBG_TRACE | 2, ("pbuf_free(p == NULL) was called.\n"));
return 0; return 0;
} }
DEBUGF(PBUF_DEBUG | DBG_TRACE | 3, ("pbuf_free(%p)\n", (void *)p)); LWIP_DEBUGF(PBUF_DEBUG | DBG_TRACE | 3, ("pbuf_free(%p)\n", (void *)p));
PERF_START; PERF_START;
@ -568,7 +568,7 @@ pbuf_free(struct pbuf *p)
if (p->ref == 0) { if (p->ref == 0) {
/* remember next pbuf in chain for next iteration */ /* remember next pbuf in chain for next iteration */
q = p->next; q = p->next;
DEBUGF( PBUF_DEBUG | 2, ("pbuf_free: deallocating %p\n", (void *)p)); LWIP_DEBUGF( PBUF_DEBUG | 2, ("pbuf_free: deallocating %p\n", (void *)p));
/* is this a pbuf from the pool? */ /* is this a pbuf from the pool? */
if (p->flags == PBUF_FLAG_POOL) { if (p->flags == PBUF_FLAG_POOL) {
p->len = p->tot_len = PBUF_POOL_BUFSIZE; p->len = p->tot_len = PBUF_POOL_BUFSIZE;
@ -587,7 +587,7 @@ pbuf_free(struct pbuf *p)
/* p->ref > 0, this pbuf is still referenced to */ /* p->ref > 0, this pbuf is still referenced to */
/* (and so the remaining pbufs in chain as well) */ /* (and so the remaining pbufs in chain as well) */
} else { } else {
DEBUGF( PBUF_DEBUG | 2, ("pbuf_free: %p has ref %u, ending here.\n", (void *)p, p->ref)); LWIP_DEBUGF( PBUF_DEBUG | 2, ("pbuf_free: %p has ref %u, ending here.\n", (void *)p, p->ref));
/* stop walking through chain */ /* stop walking through chain */
p = NULL; p = NULL;
} }
@ -674,7 +674,7 @@ pbuf_chain(struct pbuf *h, struct pbuf *t)
p->next = t; p->next = t;
/* t is now referenced to one more time */ /* t is now referenced to one more time */
pbuf_ref(t); pbuf_ref(t);
DEBUGF(PBUF_DEBUG | DBG_FRESH | 2, ("pbuf_chain: %p references %p\n", (void *)p, (void *)t)); LWIP_DEBUGF(PBUF_DEBUG | DBG_FRESH | 2, ("pbuf_chain: %p references %p\n", (void *)p, (void *)t));
} }
/* For packet queueing. Note that queued packets must be dequeued first /* For packet queueing. Note that queued packets must be dequeued first
@ -715,7 +715,7 @@ pbuf_queue(struct pbuf *p, struct pbuf *n)
p->next = n; p->next = n;
/* t is now referenced to one more time */ /* t is now referenced to one more time */
pbuf_ref(n); pbuf_ref(n);
DEBUGF(PBUF_DEBUG | DBG_FRESH | 2, ("pbuf_queue: referencing queued packet %p\n", (void *)n)); LWIP_DEBUGF(PBUF_DEBUG | DBG_FRESH | 2, ("pbuf_queue: referencing queued packet %p\n", (void *)n));
} }
/** /**
@ -743,7 +743,7 @@ pbuf_dequeue(struct pbuf *p)
p->next = NULL; p->next = NULL;
/* q is now referenced to one less time */ /* q is now referenced to one less time */
pbuf_free(q); pbuf_free(q);
DEBUGF(PBUF_DEBUG | DBG_FRESH | 2, ("pbuf_dequeue: dereferencing remaining queue %p\n", (void *)q)); LWIP_DEBUGF(PBUF_DEBUG | DBG_FRESH | 2, ("pbuf_dequeue: dereferencing remaining queue %p\n", (void *)q));
return q; return q;
} }
#endif #endif
@ -775,7 +775,7 @@ pbuf_take(struct pbuf *p)
{ {
struct pbuf *q , *prev, *head; struct pbuf *q , *prev, *head;
LWIP_ASSERT("pbuf_take: p != NULL\n", p != NULL); LWIP_ASSERT("pbuf_take: p != NULL\n", p != NULL);
DEBUGF(PBUF_DEBUG | DBG_TRACE | 3, ("pbuf_take(%p)\n", (void*)p)); LWIP_DEBUGF(PBUF_DEBUG | DBG_TRACE | 3, ("pbuf_take(%p)\n", (void*)p));
prev = NULL; prev = NULL;
head = p; head = p;
@ -784,21 +784,21 @@ pbuf_take(struct pbuf *p)
{ {
/* pbuf is of type PBUF_REF? */ /* pbuf is of type PBUF_REF? */
if (p->flags == PBUF_FLAG_REF) { if (p->flags == PBUF_FLAG_REF) {
DEBUGF(PBUF_DEBUG | DBG_TRACE, ("pbuf_take: encountered PBUF_REF %p\n", (void *)p)); LWIP_DEBUGF(PBUF_DEBUG | DBG_TRACE, ("pbuf_take: encountered PBUF_REF %p\n", (void *)p));
/* allocate a pbuf (w/ payload) fully in RAM */ /* allocate a pbuf (w/ payload) fully in RAM */
/* PBUF_POOL buffers are faster if we can use them */ /* PBUF_POOL buffers are faster if we can use them */
if (p->len <= PBUF_POOL_BUFSIZE) { if (p->len <= PBUF_POOL_BUFSIZE) {
q = pbuf_alloc(PBUF_RAW, p->len, PBUF_POOL); q = pbuf_alloc(PBUF_RAW, p->len, PBUF_POOL);
if (q == NULL) DEBUGF(PBUF_DEBUG | DBG_TRACE | 2, ("pbuf_take: Could not allocate PBUF_POOL\n")); if (q == NULL) LWIP_DEBUGF(PBUF_DEBUG | DBG_TRACE | 2, ("pbuf_take: Could not allocate PBUF_POOL\n"));
} else { } else {
/* no replacement pbuf yet */ /* no replacement pbuf yet */
q = NULL; q = NULL;
DEBUGF(PBUF_DEBUG | DBG_TRACE | 2, ("pbuf_take: PBUF_POOL too small to replace PBUF_REF\n")); LWIP_DEBUGF(PBUF_DEBUG | DBG_TRACE | 2, ("pbuf_take: PBUF_POOL too small to replace PBUF_REF\n"));
} }
/* no (large enough) PBUF_POOL was available? retry with PBUF_RAM */ /* no (large enough) PBUF_POOL was available? retry with PBUF_RAM */
if (q == NULL) { if (q == NULL) {
q = pbuf_alloc(PBUF_RAW, p->len, PBUF_RAM); q = pbuf_alloc(PBUF_RAW, p->len, PBUF_RAM);
if (q == NULL) DEBUGF(PBUF_DEBUG | DBG_TRACE | 2, ("pbuf_take: Could not allocate PBUF_RAM\n")); if (q == NULL) LWIP_DEBUGF(PBUF_DEBUG | DBG_TRACE | 2, ("pbuf_take: Could not allocate PBUF_RAM\n"));
} }
/* replacement pbuf could be allocated? */ /* replacement pbuf could be allocated? */
if (q != NULL) if (q != NULL)
@ -831,24 +831,24 @@ pbuf_take(struct pbuf *p)
*/ */
pbuf_free(p); pbuf_free(p);
/* do not copy ref, since someone else might be using the old buffer */ /* do not copy ref, since someone else might be using the old buffer */
DEBUGF(PBUF_DEBUG, ("pbuf_take: replaced PBUF_REF %p with %p\n", (void *)p, (void *)q)); LWIP_DEBUGF(PBUF_DEBUG, ("pbuf_take: replaced PBUF_REF %p with %p\n", (void *)p, (void *)q));
p = q; p = q;
} else { } else {
/* deallocate chain */ /* deallocate chain */
pbuf_free(head); pbuf_free(head);
DEBUGF(PBUF_DEBUG | 2, ("pbuf_take: failed to allocate replacement pbuf for %p\n", (void *)p)); LWIP_DEBUGF(PBUF_DEBUG | 2, ("pbuf_take: failed to allocate replacement pbuf for %p\n", (void *)p));
return NULL; return NULL;
} }
/* p->flags != PBUF_FLAG_REF */ /* p->flags != PBUF_FLAG_REF */
} else { } else {
DEBUGF(PBUF_DEBUG | DBG_TRACE | 1, ("pbuf_take: skipping pbuf not of type PBUF_REF\n")); LWIP_DEBUGF(PBUF_DEBUG | DBG_TRACE | 1, ("pbuf_take: skipping pbuf not of type PBUF_REF\n"));
} }
/* remember this pbuf */ /* remember this pbuf */
prev = p; prev = p;
/* proceed to next pbuf in original chain */ /* proceed to next pbuf in original chain */
p = p->next; p = p->next;
} while (p); } while (p);
DEBUGF(PBUF_DEBUG | DBG_TRACE | 1, ("pbuf_take: end of chain reached.\n")); LWIP_DEBUGF(PBUF_DEBUG | DBG_TRACE | 1, ("pbuf_take: end of chain reached.\n"));
return head; return head;
} }
@ -880,9 +880,9 @@ pbuf_dechain(struct pbuf *p)
/* total length of pbuf p is its own length only */ /* total length of pbuf p is its own length only */
p->tot_len = p->len; p->tot_len = p->len;
/* q is no longer referenced by p, free it */ /* q is no longer referenced by p, free it */
DEBUGF(PBUF_DEBUG | DBG_STATE, ("pbuf_dechain: unreferencing %p\n", (void *) q)); LWIP_DEBUGF(PBUF_DEBUG | DBG_STATE, ("pbuf_dechain: unreferencing %p\n", (void *) q));
tail_gone = pbuf_free(q); tail_gone = pbuf_free(q);
if (tail_gone > 0) DEBUGF(PBUF_DEBUG | DBG_STATE, ("pbuf_dechain: deallocated %p (as it is no longer referenced)\n", (void *) q)); if (tail_gone > 0) LWIP_DEBUGF(PBUF_DEBUG | DBG_STATE, ("pbuf_dechain: deallocated %p (as it is no longer referenced)\n", (void *) q));
/* return remaining tail or NULL if deallocated */ /* return remaining tail or NULL if deallocated */
} }
/* assert tot_len invariant: (p->tot_len == p->len + (p->next? p->next->tot_len: 0) */ /* assert tot_len invariant: (p->tot_len == p->len + (p->next? p->next->tot_len: 0) */

View File

@ -77,8 +77,8 @@ sys_mbox_fetch(sys_mbox_t mbox, void **msg)
arg = tmptimeout->arg; arg = tmptimeout->arg;
memp_free(MEMP_SYS_TIMEOUT, tmptimeout); memp_free(MEMP_SYS_TIMEOUT, tmptimeout);
if (h != NULL) { if (h != NULL) {
DEBUGF(SYS_DEBUG, ("smf calling h=%p(%p)\n", (void *)h, (void *)arg)); LWIP_DEBUGF(SYS_DEBUG, ("smf calling h=%p(%p)\n", (void *)h, (void *)arg));
h(arg); h(arg);
} }
/* We try again to fetch a message from the mbox. */ /* We try again to fetch a message from the mbox. */
@ -132,7 +132,7 @@ sys_sem_wait(sys_sem_t sem)
arg = tmptimeout->arg; arg = tmptimeout->arg;
memp_free(MEMP_SYS_TIMEOUT, tmptimeout); memp_free(MEMP_SYS_TIMEOUT, tmptimeout);
if (h != NULL) { if (h != NULL) {
DEBUGF(SYS_DEBUG, ("ssw h=%p(%p)\n", (void *)h, (void *)arg)); LWIP_DEBUGF(SYS_DEBUG, ("ssw h=%p(%p)\n", (void *)h, (void *)arg));
h(arg); h(arg);
} }
@ -170,7 +170,7 @@ sys_timeout(u32_t msecs, sys_timeout_handler h, void *arg)
timeouts = sys_arch_timeouts(); timeouts = sys_arch_timeouts();
DEBUGF(SYS_DEBUG, ("sys_timeout: %p msecs=%lu h=%p arg=%p\n", (void *)timeout, msecs, (void *)h, (void *)arg)); LWIP_DEBUGF(SYS_DEBUG, ("sys_timeout: %p msecs=%lu h=%p arg=%p\n", (void *)timeout, msecs, (void *)h, (void *)arg));
LWIP_ASSERT("sys_timeout: timeouts != NULL", timeouts != NULL); LWIP_ASSERT("sys_timeout: timeouts != NULL", timeouts != NULL);
if (timeouts->next == NULL) { if (timeouts->next == NULL) {

View File

@ -136,9 +136,9 @@ tcp_close(struct tcp_pcb *pcb)
err_t err; err_t err;
#if TCP_DEBUG #if TCP_DEBUG
DEBUGF(TCP_DEBUG, ("tcp_close: closing in state ")); LWIP_DEBUGF(TCP_DEBUG, ("tcp_close: closing in state "));
tcp_debug_print_state(pcb->state); tcp_debug_print_state(pcb->state);
DEBUGF(TCP_DEBUG, ("\n")); LWIP_DEBUGF(TCP_DEBUG, ("\n"));
#endif /* TCP_DEBUG */ #endif /* TCP_DEBUG */
switch (pcb->state) { switch (pcb->state) {
case LISTEN: case LISTEN:
@ -236,7 +236,7 @@ tcp_abort(struct tcp_pcb *pcb)
#endif /* TCP_QUEUE_OOSEQ */ #endif /* TCP_QUEUE_OOSEQ */
memp_free(MEMP_TCP_PCB, pcb); memp_free(MEMP_TCP_PCB, pcb);
TCP_EVENT_ERR(errf, errf_arg, ERR_ABRT); TCP_EVENT_ERR(errf, errf_arg, ERR_ABRT);
DEBUGF(TCP_RST_DEBUG, ("tcp_abort: sending RST\n")); LWIP_DEBUGF(TCP_RST_DEBUG, ("tcp_abort: sending RST\n"));
tcp_rst(seqno, ackno, &local_ip, &remote_ip, local_port, remote_port); tcp_rst(seqno, ackno, &local_ip, &remote_ip, local_port, remote_port);
} }
} }
@ -284,7 +284,7 @@ tcp_bind(struct tcp_pcb *pcb, struct ip_addr *ipaddr, u16_t port)
pcb->local_ip = *ipaddr; pcb->local_ip = *ipaddr;
} }
pcb->local_port = port; pcb->local_port = port;
DEBUGF(TCP_DEBUG, ("tcp_bind: bind to port %u\n", port)); LWIP_DEBUGF(TCP_DEBUG, ("tcp_bind: bind to port %u\n", port));
return ERR_OK; return ERR_OK;
} }
#if LWIP_CALLBACK_API #if LWIP_CALLBACK_API
@ -351,7 +351,8 @@ tcp_recved(struct tcp_pcb *pcb, u16_t len)
!(pcb->flags & TF_ACK_NOW)) { !(pcb->flags & TF_ACK_NOW)) {
tcp_ack(pcb); tcp_ack(pcb);
} }
DEBUGF(TCP_DEBUG, ("tcp_recved: recveived %u bytes, wnd %u (%u).\n",
LWIP_DEBUGF(TCP_DEBUG, ("tcp_recved: recveived %u bytes, wnd %u (%u).\n",
len, pcb->rcv_wnd, TCP_WND - pcb->rcv_wnd)); len, pcb->rcv_wnd, TCP_WND - pcb->rcv_wnd));
} }
/*-----------------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------------*/
@ -411,7 +412,7 @@ tcp_connect(struct tcp_pcb *pcb, struct ip_addr *ipaddr, u16_t port,
err_t ret; err_t ret;
u32_t iss; u32_t iss;
DEBUGF(TCP_DEBUG, ("tcp_connect to port %u\n", port)); LWIP_DEBUGF(TCP_DEBUG, ("tcp_connect to port %u\n", port));
if (ipaddr != NULL) { if (ipaddr != NULL) {
pcb->remote_ip = *ipaddr; pcb->remote_ip = *ipaddr;
} else { } else {
@ -473,9 +474,9 @@ tcp_slowtmr(void)
/* Steps through all of the active PCBs. */ /* Steps through all of the active PCBs. */
prev = NULL; prev = NULL;
pcb = tcp_active_pcbs; pcb = tcp_active_pcbs;
if (pcb == NULL) DEBUGF(TCP_DEBUG, ("tcp_slowtmr: no active pcbs\n")); if (pcb == NULL) LWIP_DEBUGF(TCP_DEBUG, ("tcp_slowtmr: no active pcbs\n"));
while (pcb != NULL) { while (pcb != NULL) {
DEBUGF(TCP_DEBUG, ("tcp_slowtmr: processing active pcb\n")); LWIP_DEBUGF(TCP_DEBUG, ("tcp_slowtmr: processing active pcb\n"));
LWIP_ASSERT("tcp_slowtmr: active pcb->state != CLOSED\n", pcb->state != CLOSED); LWIP_ASSERT("tcp_slowtmr: active pcb->state != CLOSED\n", pcb->state != CLOSED);
LWIP_ASSERT("tcp_slowtmr: active pcb->state != LISTEN\n", pcb->state != LISTEN); LWIP_ASSERT("tcp_slowtmr: active pcb->state != LISTEN\n", pcb->state != LISTEN);
LWIP_ASSERT("tcp_slowtmr: active pcb->state != TIME-WAIT\n", pcb->state != TIME_WAIT); LWIP_ASSERT("tcp_slowtmr: active pcb->state != TIME-WAIT\n", pcb->state != TIME_WAIT);
@ -484,17 +485,17 @@ tcp_slowtmr(void)
if (pcb->state == SYN_SENT && pcb->nrtx == TCP_SYNMAXRTX) { if (pcb->state == SYN_SENT && pcb->nrtx == TCP_SYNMAXRTX) {
++pcb_remove; ++pcb_remove;
DEBUGF(TCP_DEBUG, ("tcp_slowtmr: max SYN retries reached\n")); LWIP_DEBUGF(TCP_DEBUG, ("tcp_slowtmr: max SYN retries reached\n"));
} }
else if (pcb->nrtx == TCP_MAXRTX) { else if (pcb->nrtx == TCP_MAXRTX) {
++pcb_remove; ++pcb_remove;
DEBUGF(TCP_DEBUG, ("tcp_slowtmr: max DATA retries reached\n")); LWIP_DEBUGF(TCP_DEBUG, ("tcp_slowtmr: max DATA retries reached\n"));
} else { } else {
++pcb->rtime; ++pcb->rtime;
if (pcb->unacked != NULL && pcb->rtime >= pcb->rto) { if (pcb->unacked != NULL && pcb->rtime >= pcb->rto) {
/* Time for a retransmission. */ /* Time for a retransmission. */
DEBUGF(TCP_RTO_DEBUG, ("tcp_slowtmr: rtime %u pcb->rto %u\n", LWIP_DEBUGF(TCP_RTO_DEBUG, ("tcp_slowtmr: rtime %u pcb->rto %u\n",
pcb->rtime, pcb->rto)); pcb->rtime, pcb->rto));
/* Double retransmission time-out unless we are trying to /* Double retransmission time-out unless we are trying to
@ -510,7 +511,7 @@ tcp_slowtmr(void)
pcb->ssthresh = pcb->mss * 2; pcb->ssthresh = pcb->mss * 2;
} }
pcb->cwnd = pcb->mss; pcb->cwnd = pcb->mss;
DEBUGF(TCP_CWND_DEBUG, ("tcp_slowtmr: cwnd %u ssthresh %u\n", LWIP_DEBUGF(TCP_CWND_DEBUG, ("tcp_slowtmr: cwnd %u ssthresh %u\n",
pcb->cwnd, pcb->ssthresh)); pcb->cwnd, pcb->ssthresh));
} }
} }
@ -519,7 +520,7 @@ tcp_slowtmr(void)
if ((u32_t)(tcp_ticks - pcb->tmr) > if ((u32_t)(tcp_ticks - pcb->tmr) >
TCP_FIN_WAIT_TIMEOUT / TCP_SLOW_INTERVAL) { TCP_FIN_WAIT_TIMEOUT / TCP_SLOW_INTERVAL) {
++pcb_remove; ++pcb_remove;
DEBUGF(TCP_DEBUG, ("tcp_slowtmr: removing pcb stuck in FIN-WAIT-2\n")); LWIP_DEBUGF(TCP_DEBUG, ("tcp_slowtmr: removing pcb stuck in FIN-WAIT-2\n"));
} }
} }
@ -532,7 +533,7 @@ tcp_slowtmr(void)
pcb->rto * TCP_OOSEQ_TIMEOUT) { pcb->rto * TCP_OOSEQ_TIMEOUT) {
tcp_segs_free(pcb->ooseq); tcp_segs_free(pcb->ooseq);
pcb->ooseq = NULL; pcb->ooseq = NULL;
DEBUGF(TCP_CWND_DEBUG, ("tcp_slowtmr: dropping OOSEQ queued data\n")); LWIP_DEBUGF(TCP_CWND_DEBUG, ("tcp_slowtmr: dropping OOSEQ queued data\n"));
} }
#endif /* TCP_QUEUE_OOSEQ */ #endif /* TCP_QUEUE_OOSEQ */
@ -541,7 +542,7 @@ tcp_slowtmr(void)
if ((u32_t)(tcp_ticks - pcb->tmr) > if ((u32_t)(tcp_ticks - pcb->tmr) >
TCP_SYN_RCVD_TIMEOUT / TCP_SLOW_INTERVAL) { TCP_SYN_RCVD_TIMEOUT / TCP_SLOW_INTERVAL) {
++pcb_remove; ++pcb_remove;
DEBUGF(TCP_DEBUG, ("tcp_slowtmr: removing pcb stuck in SYN-RCVD\n")); LWIP_DEBUGF(TCP_DEBUG, ("tcp_slowtmr: removing pcb stuck in SYN-RCVD\n"));
} }
} }
@ -569,12 +570,12 @@ tcp_slowtmr(void)
/* We check if we should poll the connection. */ /* We check if we should poll the connection. */
++pcb->polltmr; ++pcb->polltmr;
if (pcb->polltmr >= pcb->pollinterval) { if (pcb->polltmr >= pcb->pollinterval) {
pcb->polltmr = 0; pcb->polltmr = 0;
DEBUGF(TCP_DEBUG, ("tcp_slowtmr: polling application\n")); LWIP_DEBUGF(TCP_DEBUG, ("tcp_slowtmr: polling application\n"));
TCP_EVENT_POLL(pcb, err); TCP_EVENT_POLL(pcb, err);
if (err == ERR_OK) { if (err == ERR_OK) {
tcp_output(pcb); tcp_output(pcb);
} }
} }
prev = pcb; prev = pcb;
@ -633,7 +634,7 @@ tcp_fasttmr(void)
/* send delayed ACKs */ /* send delayed ACKs */
for(pcb = tcp_active_pcbs; pcb != NULL; pcb = pcb->next) { for(pcb = tcp_active_pcbs; pcb != NULL; pcb = pcb->next) {
if (pcb->flags & TF_ACK_DELAY) { if (pcb->flags & TF_ACK_DELAY) {
DEBUGF(TCP_DEBUG, ("tcp_fasttmr: delayed ACK\n")); LWIP_DEBUGF(TCP_DEBUG, ("tcp_fasttmr: delayed ACK\n"));
tcp_ack_now(pcb); tcp_ack_now(pcb);
pcb->flags &= ~(TF_ACK_DELAY | TF_ACK_NOW); pcb->flags &= ~(TF_ACK_DELAY | TF_ACK_NOW);
} }
@ -760,7 +761,7 @@ tcp_kill_prio(u8_t prio)
} }
} }
if (inactive != NULL) { if (inactive != NULL) {
DEBUGF(TCP_DEBUG, ("tcp_kill_prio: killing oldest PCB 0x%p (%ld)\n", LWIP_DEBUGF(TCP_DEBUG, ("tcp_kill_prio: killing oldest PCB 0x%p (%ld)\n",
(void *)inactive, inactivity)); (void *)inactive, inactivity));
tcp_abort(inactive); tcp_abort(inactive);
} }
@ -782,7 +783,7 @@ tcp_kill_timewait(void)
} }
} }
if (inactive != NULL) { if (inactive != NULL) {
DEBUGF(TCP_DEBUG, ("tcp_kill_timewait: killing oldest TIME-WAIT PCB 0x%p (%ld)\n", LWIP_DEBUGF(TCP_DEBUG, ("tcp_kill_timewait: killing oldest TIME-WAIT PCB 0x%p (%ld)\n",
(void *)inactive, inactivity)); (void *)inactive, inactivity));
tcp_abort(inactive); tcp_abort(inactive);
} }
@ -799,7 +800,7 @@ tcp_alloc(u8_t prio)
pcb = memp_malloc(MEMP_TCP_PCB); pcb = memp_malloc(MEMP_TCP_PCB);
if (pcb == NULL) { if (pcb == NULL) {
/* Try killing oldest connection in TIME-WAIT. */ /* Try killing oldest connection in TIME-WAIT. */
DEBUGF(TCP_DEBUG, ("tcp_alloc: killing off oldest TIME-WAIT connection\n")); LWIP_DEBUGF(TCP_DEBUG, ("tcp_alloc: killing off oldest TIME-WAIT connection\n"));
tcp_kill_timewait(); tcp_kill_timewait();
pcb = memp_malloc(MEMP_TCP_PCB); pcb = memp_malloc(MEMP_TCP_PCB);
if (pcb == NULL) { if (pcb == NULL) {
@ -965,18 +966,18 @@ tcp_pcb_purge(struct tcp_pcb *pcb)
pcb->state != TIME_WAIT && pcb->state != TIME_WAIT &&
pcb->state != LISTEN) { pcb->state != LISTEN) {
DEBUGF(TCP_DEBUG, ("tcp_pcb_purge\n")); LWIP_DEBUGF(TCP_DEBUG, ("tcp_pcb_purge\n"));
#if TCP_DEBUG #if TCP_DEBUG
if (pcb->unsent != NULL) { if (pcb->unsent != NULL) {
DEBUGF(TCP_DEBUG, ("tcp_pcb_purge: not all data sent\n")); LWIP_DEBUGF(TCP_DEBUG, ("tcp_pcb_purge: not all data sent\n"));
} }
if (pcb->unacked != NULL) { if (pcb->unacked != NULL) {
DEBUGF(TCP_DEBUG, ("tcp_pcb_purge: data left on ->unacked\n")); LWIP_DEBUGF(TCP_DEBUG, ("tcp_pcb_purge: data left on ->unacked\n"));
} }
#if TCP_QUEUE_OOSEQ /* LW */ #if TCP_QUEUE_OOSEQ /* LW */
if (pcb->ooseq != NULL) { if (pcb->ooseq != NULL) {
DEBUGF(TCP_DEBUG, ("tcp_pcb_purge: data left on ->ooseq\n")); LWIP_DEBUGF(TCP_DEBUG, ("tcp_pcb_purge: data left on ->ooseq\n"));
} }
#endif #endif
#endif /* TCP_DEBUG */ #endif /* TCP_DEBUG */
@ -1039,18 +1040,18 @@ tcp_next_iss(void)
void void
tcp_debug_print(struct tcp_hdr *tcphdr) tcp_debug_print(struct tcp_hdr *tcphdr)
{ {
DEBUGF(TCP_DEBUG, ("TCP header:\n")); LWIP_DEBUGF(TCP_DEBUG, ("TCP header:\n"));
DEBUGF(TCP_DEBUG, ("+-------------------------------+\n")); LWIP_DEBUGF(TCP_DEBUG, ("+-------------------------------+\n"));
DEBUGF(TCP_DEBUG, ("| %04x | %04x | (src port, dest port)\n", LWIP_DEBUGF(TCP_DEBUG, ("| %04x | %04x | (src port, dest port)\n",
tcphdr->src, tcphdr->dest)); tcphdr->src, tcphdr->dest));
DEBUGF(TCP_DEBUG, ("+-------------------------------+\n")); LWIP_DEBUGF(TCP_DEBUG, ("+-------------------------------+\n"));
DEBUGF(TCP_DEBUG, ("| %08lu | (seq no)\n", LWIP_DEBUGF(TCP_DEBUG, ("| %08lu | (seq no)\n",
tcphdr->seqno)); tcphdr->seqno));
DEBUGF(TCP_DEBUG, ("+-------------------------------+\n")); LWIP_DEBUGF(TCP_DEBUG, ("+-------------------------------+\n"));
DEBUGF(TCP_DEBUG, ("| %08lu | (ack no)\n", LWIP_DEBUGF(TCP_DEBUG, ("| %08lu | (ack no)\n",
tcphdr->ackno)); tcphdr->ackno));
DEBUGF(TCP_DEBUG, ("+-------------------------------+\n")); LWIP_DEBUGF(TCP_DEBUG, ("+-------------------------------+\n"));
DEBUGF(TCP_DEBUG, ("| %2u | |%u%u%u%u%u| %5u | (offset, flags (", LWIP_DEBUGF(TCP_DEBUG, ("| %2u | |%u%u%u%u%u| %5u | (offset, flags (",
TCPH_OFFSET(tcphdr), TCPH_OFFSET(tcphdr),
TCPH_FLAGS(tcphdr) >> 4 & 1, TCPH_FLAGS(tcphdr) >> 4 & 1,
TCPH_FLAGS(tcphdr) >> 4 & 1, TCPH_FLAGS(tcphdr) >> 4 & 1,
@ -1060,50 +1061,50 @@ tcp_debug_print(struct tcp_hdr *tcphdr)
TCPH_FLAGS(tcphdr) & 1, TCPH_FLAGS(tcphdr) & 1,
tcphdr->wnd)); tcphdr->wnd));
tcp_debug_print_flags(TCPH_FLAGS(tcphdr)); tcp_debug_print_flags(TCPH_FLAGS(tcphdr));
DEBUGF(TCP_DEBUG, ("), win)\n")); LWIP_DEBUGF(TCP_DEBUG, ("), win)\n"));
DEBUGF(TCP_DEBUG, ("+-------------------------------+\n")); LWIP_DEBUGF(TCP_DEBUG, ("+-------------------------------+\n"));
DEBUGF(TCP_DEBUG, ("| 0x%04x | %5u | (chksum, urgp)\n", LWIP_DEBUGF(TCP_DEBUG, ("| 0x%04x | %5u | (chksum, urgp)\n",
ntohs(tcphdr->chksum), ntohs(tcphdr->urgp))); ntohs(tcphdr->chksum), ntohs(tcphdr->urgp)));
DEBUGF(TCP_DEBUG, ("+-------------------------------+\n")); LWIP_DEBUGF(TCP_DEBUG, ("+-------------------------------+\n"));
} }
/*-----------------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------------*/
void void
tcp_debug_print_state(enum tcp_state s) tcp_debug_print_state(enum tcp_state s)
{ {
DEBUGF(TCP_DEBUG, ("State: ")); LWIP_DEBUGF(TCP_DEBUG, ("State: "));
switch (s) { switch (s) {
case CLOSED: case CLOSED:
DEBUGF(TCP_DEBUG, ("CLOSED\n")); LWIP_DEBUGF(TCP_DEBUG, ("CLOSED\n"));
break; break;
case LISTEN: case LISTEN:
DEBUGF(TCP_DEBUG, ("LISTEN\n")); LWIP_DEBUGF(TCP_DEBUG, ("LISTEN\n"));
break; break;
case SYN_SENT: case SYN_SENT:
DEBUGF(TCP_DEBUG, ("SYN_SENT\n")); LWIP_DEBUGF(TCP_DEBUG, ("SYN_SENT\n"));
break; break;
case SYN_RCVD: case SYN_RCVD:
DEBUGF(TCP_DEBUG, ("SYN_RCVD\n")); LWIP_DEBUGF(TCP_DEBUG, ("SYN_RCVD\n"));
break; break;
case ESTABLISHED: case ESTABLISHED:
DEBUGF(TCP_DEBUG, ("ESTABLISHED\n")); LWIP_DEBUGF(TCP_DEBUG, ("ESTABLISHED\n"));
break; break;
case FIN_WAIT_1: case FIN_WAIT_1:
DEBUGF(TCP_DEBUG, ("FIN_WAIT_1\n")); LWIP_DEBUGF(TCP_DEBUG, ("FIN_WAIT_1\n"));
break; break;
case FIN_WAIT_2: case FIN_WAIT_2:
DEBUGF(TCP_DEBUG, ("FIN_WAIT_2\n")); LWIP_DEBUGF(TCP_DEBUG, ("FIN_WAIT_2\n"));
break; break;
case CLOSE_WAIT: case CLOSE_WAIT:
DEBUGF(TCP_DEBUG, ("CLOSE_WAIT\n")); LWIP_DEBUGF(TCP_DEBUG, ("CLOSE_WAIT\n"));
break; break;
case CLOSING: case CLOSING:
DEBUGF(TCP_DEBUG, ("CLOSING\n")); LWIP_DEBUGF(TCP_DEBUG, ("CLOSING\n"));
break; break;
case LAST_ACK: case LAST_ACK:
DEBUGF(TCP_DEBUG, ("LAST_ACK\n")); LWIP_DEBUGF(TCP_DEBUG, ("LAST_ACK\n"));
break; break;
case TIME_WAIT: case TIME_WAIT:
DEBUGF(TCP_DEBUG, ("TIME_WAIT\n")); LWIP_DEBUGF(TCP_DEBUG, ("TIME_WAIT\n"));
break; break;
} }
} }
@ -1112,22 +1113,22 @@ void
tcp_debug_print_flags(u8_t flags) tcp_debug_print_flags(u8_t flags)
{ {
if (flags & TCP_FIN) { if (flags & TCP_FIN) {
DEBUGF(TCP_DEBUG, ("FIN ")); LWIP_DEBUGF(TCP_DEBUG, ("FIN "));
} }
if (flags & TCP_SYN) { if (flags & TCP_SYN) {
DEBUGF(TCP_DEBUG, ("SYN ")); LWIP_DEBUGF(TCP_DEBUG, ("SYN "));
} }
if (flags & TCP_RST) { if (flags & TCP_RST) {
DEBUGF(TCP_DEBUG, ("RST ")); LWIP_DEBUGF(TCP_DEBUG, ("RST "));
} }
if (flags & TCP_PSH) { if (flags & TCP_PSH) {
DEBUGF(TCP_DEBUG, ("PSH ")); LWIP_DEBUGF(TCP_DEBUG, ("PSH "));
} }
if (flags & TCP_ACK) { if (flags & TCP_ACK) {
DEBUGF(TCP_DEBUG, ("ACK ")); LWIP_DEBUGF(TCP_DEBUG, ("ACK "));
} }
if (flags & TCP_URG) { if (flags & TCP_URG) {
DEBUGF(TCP_DEBUG, ("URG ")); LWIP_DEBUGF(TCP_DEBUG, ("URG "));
} }
} }
/*-----------------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------------*/
@ -1135,23 +1136,23 @@ void
tcp_debug_print_pcbs(void) tcp_debug_print_pcbs(void)
{ {
struct tcp_pcb *pcb; struct tcp_pcb *pcb;
DEBUGF(TCP_DEBUG, ("Active PCB states:\n")); LWIP_DEBUGF(TCP_DEBUG, ("Active PCB states:\n"));
for(pcb = tcp_active_pcbs; pcb != NULL; pcb = pcb->next) { for(pcb = tcp_active_pcbs; pcb != NULL; pcb = pcb->next) {
DEBUGF(TCP_DEBUG, ("Local port %u, foreign port %u snd_nxt %lu rcv_nxt %lu ", LWIP_DEBUGF(TCP_DEBUG, ("Local port %u, foreign port %u snd_nxt %lu rcv_nxt %lu ",
pcb->local_port, pcb->remote_port, pcb->local_port, pcb->remote_port,
pcb->snd_nxt, pcb->rcv_nxt)); pcb->snd_nxt, pcb->rcv_nxt));
tcp_debug_print_state(pcb->state); tcp_debug_print_state(pcb->state);
} }
DEBUGF(TCP_DEBUG, ("Listen PCB states:\n")); LWIP_DEBUGF(TCP_DEBUG, ("Listen PCB states:\n"));
for(pcb = (struct tcp_pcb *)tcp_listen_pcbs; pcb != NULL; pcb = pcb->next) { for(pcb = (struct tcp_pcb *)tcp_listen_pcbs; pcb != NULL; pcb = pcb->next) {
DEBUGF(TCP_DEBUG, ("Local port %u, foreign port %u snd_nxt %lu rcv_nxt %lu ", LWIP_DEBUGF(TCP_DEBUG, ("Local port %u, foreign port %u snd_nxt %lu rcv_nxt %lu ",
pcb->local_port, pcb->remote_port, pcb->local_port, pcb->remote_port,
pcb->snd_nxt, pcb->rcv_nxt)); pcb->snd_nxt, pcb->rcv_nxt));
tcp_debug_print_state(pcb->state); tcp_debug_print_state(pcb->state);
} }
DEBUGF(TCP_DEBUG, ("TIME-WAIT PCB states:\n")); LWIP_DEBUGF(TCP_DEBUG, ("TIME-WAIT PCB states:\n"));
for(pcb = tcp_tw_pcbs; pcb != NULL; pcb = pcb->next) { for(pcb = tcp_tw_pcbs; pcb != NULL; pcb = pcb->next) {
DEBUGF(TCP_DEBUG, ("Local port %u, foreign port %u snd_nxt %lu rcv_nxt %lu ", LWIP_DEBUGF(TCP_DEBUG, ("Local port %u, foreign port %u snd_nxt %lu rcv_nxt %lu ",
pcb->local_port, pcb->remote_port, pcb->local_port, pcb->remote_port,
pcb->snd_nxt, pcb->rcv_nxt)); pcb->snd_nxt, pcb->rcv_nxt));
tcp_debug_print_state(pcb->state); tcp_debug_print_state(pcb->state);

View File

@ -116,7 +116,7 @@ tcp_input(struct pbuf *p, struct netif *inp)
/* remove header from payload */ /* remove header from payload */
if (pbuf_header(p, -((s16_t)(IPH_HL(iphdr) * 4))) || (p->tot_len < sizeof(struct tcp_hdr))) { if (pbuf_header(p, -((s16_t)(IPH_HL(iphdr) * 4))) || (p->tot_len < sizeof(struct tcp_hdr))) {
/* drop short packets */ /* drop short packets */
DEBUGF(TCP_INPUT_DEBUG, ("tcp_input: short packet (%u bytes) discarded\n", p->tot_len)); LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_input: short packet (%u bytes) discarded\n", p->tot_len));
#ifdef TCP_STATS #ifdef TCP_STATS
++lwip_stats.tcp.lenerr; ++lwip_stats.tcp.lenerr;
++lwip_stats.tcp.drop; ++lwip_stats.tcp.drop;
@ -136,7 +136,7 @@ tcp_input(struct pbuf *p, struct netif *inp)
if (inet_chksum_pseudo(p, (struct ip_addr *)&(iphdr->src), if (inet_chksum_pseudo(p, (struct ip_addr *)&(iphdr->src),
(struct ip_addr *)&(iphdr->dest), (struct ip_addr *)&(iphdr->dest),
IP_PROTO_TCP, p->tot_len) != 0) { IP_PROTO_TCP, p->tot_len) != 0) {
DEBUGF(TCP_INPUT_DEBUG, ("tcp_input: packet discarded due to failing checksum 0x%04x\n", inet_chksum_pseudo(p, (struct ip_addr *)&(iphdr->src), LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_input: packet discarded due to failing checksum 0x%04x\n", inet_chksum_pseudo(p, (struct ip_addr *)&(iphdr->src),
(struct ip_addr *)&(iphdr->dest), (struct ip_addr *)&(iphdr->dest),
IP_PROTO_TCP, p->tot_len))); IP_PROTO_TCP, p->tot_len)));
#if TCP_DEBUG #if TCP_DEBUG
@ -207,7 +207,7 @@ tcp_input(struct pbuf *p, struct netif *inp)
/* We don't really care enough to move this PCB to the front /* We don't really care enough to move this PCB to the front
of the list since we are not very likely to receive that of the list since we are not very likely to receive that
many segments for connections in TIME-WAIT. */ many segments for connections in TIME-WAIT. */
DEBUGF(TCP_INPUT_DEBUG, ("tcp_input: packed for TIME_WAITing connection.\n")); LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_input: packed for TIME_WAITing connection.\n"));
tcp_timewait_input(pcb); tcp_timewait_input(pcb);
pbuf_free(p); pbuf_free(p);
return; return;
@ -232,7 +232,7 @@ tcp_input(struct pbuf *p, struct netif *inp)
tcp_listen_pcbs = lpcb; tcp_listen_pcbs = lpcb;
} }
DEBUGF(TCP_INPUT_DEBUG, ("tcp_input: packed for LISTENing connection.\n")); LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_input: packed for LISTENing connection.\n"));
tcp_listen_input(lpcb); tcp_listen_input(lpcb);
pbuf_free(p); pbuf_free(p);
return; return;
@ -242,9 +242,9 @@ tcp_input(struct pbuf *p, struct netif *inp)
} }
#if TCP_INPUT_DEBUG #if TCP_INPUT_DEBUG
DEBUGF(TCP_INPUT_DEBUG, ("+-+-+-+-+-+-+-+-+-+-+-+-+-+- tcp_input: flags ")); LWIP_DEBUGF(TCP_INPUT_DEBUG, ("+-+-+-+-+-+-+-+-+-+-+-+-+-+- tcp_input: flags "));
tcp_debug_print_flags(TCPH_FLAGS(tcphdr)); tcp_debug_print_flags(TCPH_FLAGS(tcphdr));
DEBUGF(TCP_INPUT_DEBUG, ("-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n")); LWIP_DEBUGF(TCP_INPUT_DEBUG, ("-+-+-+-+-+-+-+-+-+-+-+-+-+-+\n"));
#endif /* TCP_INPUT_DEBUG */ #endif /* TCP_INPUT_DEBUG */
@ -327,7 +327,7 @@ tcp_input(struct pbuf *p, struct netif *inp)
} else { } else {
/* If no matching PCB was found, send a TCP RST (reset) to the /* If no matching PCB was found, send a TCP RST (reset) to the
sender. */ sender. */
DEBUGF(TCP_RST_DEBUG, ("tcp_input: no PCB match found, resetting.\n")); LWIP_DEBUGF(TCP_RST_DEBUG, ("tcp_input: no PCB match found, resetting.\n"));
if (!(TCPH_FLAGS(tcphdr) & TCP_RST)) { if (!(TCPH_FLAGS(tcphdr) & TCP_RST)) {
#ifdef TCP_STATS #ifdef TCP_STATS
++lwip_stats.tcp.proterr; ++lwip_stats.tcp.proterr;
@ -361,18 +361,18 @@ tcp_listen_input(struct tcp_pcb_listen *pcb)
if (flags & TCP_ACK) { if (flags & TCP_ACK) {
/* For incoming segments with the ACK flag set, respond with a /* For incoming segments with the ACK flag set, respond with a
RST. */ RST. */
DEBUGF(TCP_RST_DEBUG, ("tcp_listen_input: ACK in LISTEN, sending reset\n")); LWIP_DEBUGF(TCP_RST_DEBUG, ("tcp_listen_input: ACK in LISTEN, sending reset\n"));
tcp_rst(ackno + 1, seqno + tcplen, tcp_rst(ackno + 1, seqno + tcplen,
&(iphdr->dest), &(iphdr->src), &(iphdr->dest), &(iphdr->src),
tcphdr->dest, tcphdr->src); tcphdr->dest, tcphdr->src);
} else if (flags & TCP_SYN) { } else if (flags & TCP_SYN) {
DEBUGF(DEMO_DEBUG, ("TCP connection request %d -> %d.\n", tcphdr->src, tcphdr->dest)); LWIP_DEBUGF(DEMO_DEBUG, ("TCP connection request %d -> %d.\n", tcphdr->src, tcphdr->dest));
npcb = tcp_alloc(pcb->prio); npcb = tcp_alloc(pcb->prio);
/* If a new PCB could not be created (probably due to lack of memory), /* If a new PCB could not be created (probably due to lack of memory),
we don't do anything, but rely on the sender will retransmit the we don't do anything, but rely on the sender will retransmit the
SYN at a time when we have more memory available. */ SYN at a time when we have more memory available. */
if (npcb == NULL) { if (npcb == NULL) {
DEBUGF(TCP_DEBUG, ("tcp_listen_input: could not allocate PCB\n")); LWIP_DEBUGF(TCP_DEBUG, ("tcp_listen_input: could not allocate PCB\n"));
#ifdef TCP_STATS #ifdef TCP_STATS
++lwip_stats.tcp.memerr; ++lwip_stats.tcp.memerr;
#endif /* TCP_STATS */ #endif /* TCP_STATS */
@ -463,15 +463,15 @@ tcp_process(struct tcp_pcb *pcb)
} }
if (acceptable) { if (acceptable) {
DEBUGF(TCP_INPUT_DEBUG, ("tcp_process: Connection RESET\n")); LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_process: Connection RESET\n"));
LWIP_ASSERT("tcp_input: pcb->state != CLOSED", pcb->state != CLOSED); LWIP_ASSERT("tcp_input: pcb->state != CLOSED", pcb->state != CLOSED);
recv_flags = TF_RESET; recv_flags = TF_RESET;
pcb->flags &= ~TF_ACK_DELAY; pcb->flags &= ~TF_ACK_DELAY;
return ERR_RST; return ERR_RST;
} else { } else {
DEBUGF(TCP_INPUT_DEBUG, ("tcp_process: unacceptable reset seqno %lu rcv_nxt %lu\n", LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_process: unacceptable reset seqno %lu rcv_nxt %lu\n",
seqno, pcb->rcv_nxt)); seqno, pcb->rcv_nxt));
DEBUGF(TCP_DEBUG, ("tcp_process: unacceptable reset seqno %lu rcv_nxt %lu\n", LWIP_DEBUGF(TCP_DEBUG, ("tcp_process: unacceptable reset seqno %lu rcv_nxt %lu\n",
seqno, pcb->rcv_nxt)); seqno, pcb->rcv_nxt));
return ERR_OK; return ERR_OK;
} }
@ -483,7 +483,7 @@ tcp_process(struct tcp_pcb *pcb)
/* Do different things depending on the TCP state. */ /* Do different things depending on the TCP state. */
switch (pcb->state) { switch (pcb->state) {
case SYN_SENT: case SYN_SENT:
DEBUGF(TCP_INPUT_DEBUG, ("SYN-SENT: ackno %lu pcb->snd_nxt %lu unacked %lu\n", ackno, LWIP_DEBUGF(TCP_INPUT_DEBUG, ("SYN-SENT: ackno %lu pcb->snd_nxt %lu unacked %lu\n", ackno,
pcb->snd_nxt, ntohl(pcb->unacked->tcphdr->seqno))); pcb->snd_nxt, ntohl(pcb->unacked->tcphdr->seqno)));
if (flags & (TCP_ACK | TCP_SYN) && if (flags & (TCP_ACK | TCP_SYN) &&
ackno == ntohl(pcb->unacked->tcphdr->seqno) + 1) { ackno == ntohl(pcb->unacked->tcphdr->seqno) + 1) {
@ -493,7 +493,7 @@ tcp_process(struct tcp_pcb *pcb)
pcb->state = ESTABLISHED; pcb->state = ESTABLISHED;
pcb->cwnd = pcb->mss; pcb->cwnd = pcb->mss;
--pcb->snd_queuelen; --pcb->snd_queuelen;
DEBUGF(TCP_QLEN_DEBUG, ("tcp_process: SYN-SENT --queuelen %d\n", pcb->snd_queuelen)); LWIP_DEBUGF(TCP_QLEN_DEBUG, ("tcp_process: SYN-SENT --queuelen %d\n", pcb->snd_queuelen));
rseg = pcb->unacked; rseg = pcb->unacked;
pcb->unacked = rseg->next; pcb->unacked = rseg->next;
tcp_seg_free(rseg); tcp_seg_free(rseg);
@ -513,7 +513,7 @@ tcp_process(struct tcp_pcb *pcb)
if (TCP_SEQ_LT(pcb->lastack, ackno) && if (TCP_SEQ_LT(pcb->lastack, ackno) &&
TCP_SEQ_LEQ(ackno, pcb->snd_nxt)) { TCP_SEQ_LEQ(ackno, pcb->snd_nxt)) {
pcb->state = ESTABLISHED; pcb->state = ESTABLISHED;
DEBUGF(DEMO_DEBUG, ("TCP connection established %d -> %d.\n", inseg.tcphdr->src, inseg.tcphdr->dest)); LWIP_DEBUGF(DEMO_DEBUG, ("TCP connection established %d -> %d.\n", inseg.tcphdr->src, inseg.tcphdr->dest));
LWIP_ASSERT("pcb->accept != NULL", pcb->accept != NULL); LWIP_ASSERT("pcb->accept != NULL", pcb->accept != NULL);
/* Call the accept function. */ /* Call the accept function. */
TCP_EVENT_ACCEPT(pcb, ERR_OK, err); TCP_EVENT_ACCEPT(pcb, ERR_OK, err);
@ -543,7 +543,7 @@ tcp_process(struct tcp_pcb *pcb)
tcp_receive(pcb); tcp_receive(pcb);
if (flags & TCP_FIN) { if (flags & TCP_FIN) {
if (flags & TCP_ACK && ackno == pcb->snd_nxt) { if (flags & TCP_ACK && ackno == pcb->snd_nxt) {
DEBUGF(DEMO_DEBUG, LWIP_DEBUGF(DEMO_DEBUG,
("TCP connection closed %d -> %d.\n", inseg.tcphdr->src, inseg.tcphdr->dest)); ("TCP connection closed %d -> %d.\n", inseg.tcphdr->src, inseg.tcphdr->dest));
tcp_ack_now(pcb); tcp_ack_now(pcb);
tcp_pcb_purge(pcb); tcp_pcb_purge(pcb);
@ -561,7 +561,7 @@ tcp_process(struct tcp_pcb *pcb)
case FIN_WAIT_2: case FIN_WAIT_2:
tcp_receive(pcb); tcp_receive(pcb);
if (flags & TCP_FIN) { if (flags & TCP_FIN) {
DEBUGF(DEMO_DEBUG, ("TCP connection closed %d -> %d.\n", inseg.tcphdr->src, inseg.tcphdr->dest)); LWIP_DEBUGF(DEMO_DEBUG, ("TCP connection closed %d -> %d.\n", inseg.tcphdr->src, inseg.tcphdr->dest));
tcp_ack_now(pcb); tcp_ack_now(pcb);
tcp_pcb_purge(pcb); tcp_pcb_purge(pcb);
TCP_RMV(&tcp_active_pcbs, pcb); TCP_RMV(&tcp_active_pcbs, pcb);
@ -572,7 +572,7 @@ tcp_process(struct tcp_pcb *pcb)
case CLOSING: case CLOSING:
tcp_receive(pcb); tcp_receive(pcb);
if (flags & TCP_ACK && ackno == pcb->snd_nxt) { if (flags & TCP_ACK && ackno == pcb->snd_nxt) {
DEBUGF(DEMO_DEBUG, ("TCP connection closed %d -> %d.\n", inseg.tcphdr->src, inseg.tcphdr->dest)); LWIP_DEBUGF(DEMO_DEBUG, ("TCP connection closed %d -> %d.\n", inseg.tcphdr->src, inseg.tcphdr->dest));
tcp_ack_now(pcb); tcp_ack_now(pcb);
tcp_pcb_purge(pcb); tcp_pcb_purge(pcb);
TCP_RMV(&tcp_active_pcbs, pcb); TCP_RMV(&tcp_active_pcbs, pcb);
@ -583,7 +583,7 @@ tcp_process(struct tcp_pcb *pcb)
case LAST_ACK: case LAST_ACK:
tcp_receive(pcb); tcp_receive(pcb);
if (flags & TCP_ACK && ackno == pcb->snd_nxt) { if (flags & TCP_ACK && ackno == pcb->snd_nxt) {
DEBUGF(DEMO_DEBUG, ("TCP connection closed %d -> %d.\n", inseg.tcphdr->src, inseg.tcphdr->dest)); LWIP_DEBUGF(DEMO_DEBUG, ("TCP connection closed %d -> %d.\n", inseg.tcphdr->src, inseg.tcphdr->dest));
pcb->state = CLOSED; pcb->state = CLOSED;
recv_flags = TF_CLOSED; recv_flags = TF_CLOSED;
} }
@ -630,11 +630,11 @@ tcp_receive(struct tcp_pcb *pcb)
pcb->snd_wnd = tcphdr->wnd; pcb->snd_wnd = tcphdr->wnd;
pcb->snd_wl1 = seqno; pcb->snd_wl1 = seqno;
pcb->snd_wl2 = ackno; pcb->snd_wl2 = ackno;
DEBUGF(TCP_WND_DEBUG, ("tcp_receive: window update %lu\n", pcb->snd_wnd)); LWIP_DEBUGF(TCP_WND_DEBUG, ("tcp_receive: window update %lu\n", pcb->snd_wnd));
#if TCP_WND_DEBUG #if TCP_WND_DEBUG
} else { } else {
if (pcb->snd_wnd != tcphdr->wnd) { if (pcb->snd_wnd != tcphdr->wnd) {
DEBUGF(TCP_WND_DEBUG, ("tcp_receive: no window update lastack %lu snd_max %lu ackno %lu wl1 %lu seqno %lu wl2 %lu\n", LWIP_DEBUGF(TCP_WND_DEBUG, ("tcp_receive: no window update lastack %lu snd_max %lu ackno %lu wl1 %lu seqno %lu wl2 %lu\n",
pcb->lastack, pcb->snd_max, ackno, pcb->snd_wl1, seqno, pcb->snd_wl2)); pcb->lastack, pcb->snd_max, ackno, pcb->snd_wl1, seqno, pcb->snd_wl2));
} }
#endif /* TCP_WND_DEBUG */ #endif /* TCP_WND_DEBUG */
@ -649,7 +649,7 @@ tcp_receive(struct tcp_pcb *pcb)
if (pcb->dupacks >= 3 && pcb->unacked != NULL) { if (pcb->dupacks >= 3 && pcb->unacked != NULL) {
if (!(pcb->flags & TF_INFR)) { if (!(pcb->flags & TF_INFR)) {
/* This is fast retransmit. Retransmit the first unacked segment. */ /* This is fast retransmit. Retransmit the first unacked segment. */
DEBUGF(TCP_FR_DEBUG, ("tcp_receive: dupacks %d (%lu), fast retransmit %lu\n", LWIP_DEBUGF(TCP_FR_DEBUG, ("tcp_receive: dupacks %d (%lu), fast retransmit %lu\n",
pcb->dupacks, pcb->lastack, pcb->dupacks, pcb->lastack,
ntohl(pcb->unacked->tcphdr->seqno))); ntohl(pcb->unacked->tcphdr->seqno)));
tcp_rexmit(pcb); tcp_rexmit(pcb);
@ -669,7 +669,7 @@ tcp_receive(struct tcp_pcb *pcb)
} }
} }
} else { } else {
DEBUGF(TCP_FR_DEBUG, ("tcp_receive: dupack averted %lu %lu\n", LWIP_DEBUGF(TCP_FR_DEBUG, ("tcp_receive: dupack averted %lu %lu\n",
pcb->snd_wl1 + pcb->snd_wnd, right_wnd_edge)); pcb->snd_wl1 + pcb->snd_wnd, right_wnd_edge));
} }
} else if (TCP_SEQ_LT(pcb->lastack, ackno) && } else if (TCP_SEQ_LT(pcb->lastack, ackno) &&
@ -705,16 +705,16 @@ tcp_receive(struct tcp_pcb *pcb)
if ((u16_t)(pcb->cwnd + pcb->mss) > pcb->cwnd) { if ((u16_t)(pcb->cwnd + pcb->mss) > pcb->cwnd) {
pcb->cwnd += pcb->mss; pcb->cwnd += pcb->mss;
} }
DEBUGF(TCP_CWND_DEBUG, ("tcp_receive: slow start cwnd %u\n", pcb->cwnd)); LWIP_DEBUGF(TCP_CWND_DEBUG, ("tcp_receive: slow start cwnd %u\n", pcb->cwnd));
} else { } else {
u16_t new_cwnd = (pcb->cwnd + pcb->mss * pcb->mss / pcb->cwnd); u16_t new_cwnd = (pcb->cwnd + pcb->mss * pcb->mss / pcb->cwnd);
if (new_cwnd > pcb->cwnd) { if (new_cwnd > pcb->cwnd) {
pcb->cwnd = new_cwnd; pcb->cwnd = new_cwnd;
} }
DEBUGF(TCP_CWND_DEBUG, ("tcp_receive: congestion avoidance cwnd %u\n", pcb->cwnd)); LWIP_DEBUGF(TCP_CWND_DEBUG, ("tcp_receive: congestion avoidance cwnd %u\n", pcb->cwnd));
} }
} }
DEBUGF(TCP_INPUT_DEBUG, ("tcp_receive: ACK for %lu, unacked->seqno %lu:%lu\n", LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_receive: ACK for %lu, unacked->seqno %lu:%lu\n",
ackno, ackno,
pcb->unacked != NULL? pcb->unacked != NULL?
ntohl(pcb->unacked->tcphdr->seqno): 0, ntohl(pcb->unacked->tcphdr->seqno): 0,
@ -726,7 +726,7 @@ tcp_receive(struct tcp_pcb *pcb)
while (pcb->unacked != NULL && while (pcb->unacked != NULL &&
TCP_SEQ_LEQ(ntohl(pcb->unacked->tcphdr->seqno) + TCP_SEQ_LEQ(ntohl(pcb->unacked->tcphdr->seqno) +
TCP_TCPLEN(pcb->unacked), ackno)) { TCP_TCPLEN(pcb->unacked), ackno)) {
DEBUGF(TCP_INPUT_DEBUG, ("tcp_receive: removing %lu:%lu from pcb->unacked\n", LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_receive: removing %lu:%lu from pcb->unacked\n",
ntohl(pcb->unacked->tcphdr->seqno), ntohl(pcb->unacked->tcphdr->seqno),
ntohl(pcb->unacked->tcphdr->seqno) + ntohl(pcb->unacked->tcphdr->seqno) +
TCP_TCPLEN(pcb->unacked))); TCP_TCPLEN(pcb->unacked)));
@ -734,11 +734,11 @@ tcp_receive(struct tcp_pcb *pcb)
next = pcb->unacked; next = pcb->unacked;
pcb->unacked = pcb->unacked->next; pcb->unacked = pcb->unacked->next;
DEBUGF(TCP_QLEN_DEBUG, ("tcp_receive: queuelen %d ... ", pcb->snd_queuelen)); LWIP_DEBUGF(TCP_QLEN_DEBUG, ("tcp_receive: queuelen %d ... ", pcb->snd_queuelen));
pcb->snd_queuelen -= pbuf_clen(next->p); pcb->snd_queuelen -= pbuf_clen(next->p);
tcp_seg_free(next); tcp_seg_free(next);
DEBUGF(TCP_QLEN_DEBUG, ("%d (after freeing unacked)\n", pcb->snd_queuelen)); LWIP_DEBUGF(TCP_QLEN_DEBUG, ("%d (after freeing unacked)\n", pcb->snd_queuelen));
if (pcb->snd_queuelen != 0) { if (pcb->snd_queuelen != 0) {
LWIP_ASSERT("tcp_receive: valid queue length", pcb->unacked != NULL || LWIP_ASSERT("tcp_receive: valid queue length", pcb->unacked != NULL ||
pcb->unsent != NULL); pcb->unsent != NULL);
@ -757,17 +757,17 @@ tcp_receive(struct tcp_pcb *pcb)
TCP_SEQ_LEQ(ntohl(pcb->unsent->tcphdr->seqno) + TCP_TCPLEN(pcb->unsent), TCP_SEQ_LEQ(ntohl(pcb->unsent->tcphdr->seqno) + TCP_TCPLEN(pcb->unsent),
ackno) && ackno) &&
TCP_SEQ_LEQ(ackno, pcb->snd_max)) { TCP_SEQ_LEQ(ackno, pcb->snd_max)) {
DEBUGF(TCP_INPUT_DEBUG, ("tcp_receive: removing %lu:%lu from pcb->unsent\n", LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_receive: removing %lu:%lu from pcb->unsent\n",
ntohl(pcb->unsent->tcphdr->seqno), ntohl(pcb->unsent->tcphdr->seqno),
ntohl(pcb->unsent->tcphdr->seqno) + ntohl(pcb->unsent->tcphdr->seqno) +
TCP_TCPLEN(pcb->unsent))); TCP_TCPLEN(pcb->unsent)));
next = pcb->unsent; next = pcb->unsent;
pcb->unsent = pcb->unsent->next; pcb->unsent = pcb->unsent->next;
DEBUGF(TCP_QLEN_DEBUG, ("tcp_receive: queuelen %d ... ", pcb->snd_queuelen)); LWIP_DEBUGF(TCP_QLEN_DEBUG, ("tcp_receive: queuelen %d ... ", pcb->snd_queuelen));
pcb->snd_queuelen -= pbuf_clen(next->p); pcb->snd_queuelen -= pbuf_clen(next->p);
tcp_seg_free(next); tcp_seg_free(next);
DEBUGF(TCP_QLEN_DEBUG, ("%d (after freeing unsent)\n", pcb->snd_queuelen)); LWIP_DEBUGF(TCP_QLEN_DEBUG, ("%d (after freeing unsent)\n", pcb->snd_queuelen));
if (pcb->snd_queuelen != 0) { if (pcb->snd_queuelen != 0) {
LWIP_ASSERT("tcp_receive: valid queue length", pcb->unacked != NULL || LWIP_ASSERT("tcp_receive: valid queue length", pcb->unacked != NULL ||
pcb->unsent != NULL); pcb->unsent != NULL);
@ -780,7 +780,7 @@ tcp_receive(struct tcp_pcb *pcb)
/* End of ACK for new data processing. */ /* End of ACK for new data processing. */
DEBUGF(TCP_RTO_DEBUG, ("tcp_receive: pcb->rttest %d rtseq %lu ackno %lu\n", LWIP_DEBUGF(TCP_RTO_DEBUG, ("tcp_receive: pcb->rttest %d rtseq %lu ackno %lu\n",
pcb->rttest, pcb->rtseq, ackno)); pcb->rttest, pcb->rtseq, ackno));
/* RTT estimation calculations. This is done by checking if the /* RTT estimation calculations. This is done by checking if the
@ -789,7 +789,7 @@ tcp_receive(struct tcp_pcb *pcb)
if (pcb->rttest && TCP_SEQ_LT(pcb->rtseq, ackno)) { if (pcb->rttest && TCP_SEQ_LT(pcb->rtseq, ackno)) {
m = tcp_ticks - pcb->rttest; m = tcp_ticks - pcb->rttest;
DEBUGF(TCP_RTO_DEBUG, ("tcp_receive: experienced rtt %d ticks (%d msec).\n", LWIP_DEBUGF(TCP_RTO_DEBUG, ("tcp_receive: experienced rtt %d ticks (%d msec).\n",
m, m * TCP_SLOW_INTERVAL)); m, m * TCP_SLOW_INTERVAL));
/* This is taken directly from VJs original code in his paper */ /* This is taken directly from VJs original code in his paper */
@ -802,7 +802,7 @@ tcp_receive(struct tcp_pcb *pcb)
pcb->sv += m; pcb->sv += m;
pcb->rto = (pcb->sa >> 3) + pcb->sv; pcb->rto = (pcb->sa >> 3) + pcb->sv;
DEBUGF(TCP_RTO_DEBUG, ("tcp_receive: RTO %d (%d miliseconds)\n", LWIP_DEBUGF(TCP_RTO_DEBUG, ("tcp_receive: RTO %d (%d miliseconds)\n",
pcb->rto, pcb->rto * TCP_SLOW_INTERVAL)); pcb->rto, pcb->rto * TCP_SLOW_INTERVAL));
pcb->rttest = 0; pcb->rttest = 0;
@ -882,7 +882,7 @@ tcp_receive(struct tcp_pcb *pcb)
/* the whole segment is < rcv_nxt */ /* the whole segment is < rcv_nxt */
/* must be a duplicate of a packet that has already been correctly handled */ /* must be a duplicate of a packet that has already been correctly handled */
DEBUGF(TCP_INPUT_DEBUG, ("tcp_receive: duplicate seqno %lu\n", seqno)); LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_receive: duplicate seqno %lu\n", seqno));
tcp_ack_now(pcb); tcp_ack_now(pcb);
} }
} }
@ -934,7 +934,7 @@ tcp_receive(struct tcp_pcb *pcb)
inseg.p = NULL; inseg.p = NULL;
} }
if (TCPH_FLAGS(inseg.tcphdr) & TCP_FIN) { if (TCPH_FLAGS(inseg.tcphdr) & TCP_FIN) {
DEBUGF(TCP_INPUT_DEBUG, ("tcp_receive: received FIN.")); LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_receive: received FIN."));
recv_flags = TF_GOT_FIN; recv_flags = TF_GOT_FIN;
} }
@ -965,7 +965,7 @@ tcp_receive(struct tcp_pcb *pcb)
cseg->p = NULL; cseg->p = NULL;
} }
if (flags & TCP_FIN) { if (flags & TCP_FIN) {
DEBUGF(TCP_INPUT_DEBUG, ("tcp_receive: dequeued FIN.")); LWIP_DEBUGF(TCP_INPUT_DEBUG, ("tcp_receive: dequeued FIN."));
recv_flags = TF_GOT_FIN; recv_flags = TF_GOT_FIN;
} }

View File

@ -75,7 +75,7 @@ tcp_send_ctrl(struct tcp_pcb *pcb, u8_t flags)
err_t err_t
tcp_write(struct tcp_pcb *pcb, const void *arg, u16_t len, u8_t copy) tcp_write(struct tcp_pcb *pcb, const void *arg, u16_t len, u8_t copy)
{ {
DEBUGF(TCP_OUTPUT_DEBUG, ("tcp_write(pcb=%p, arg=%p, len=%u, copy=%d)\n", (void *)pcb, arg, len, copy)); LWIP_DEBUGF(TCP_OUTPUT_DEBUG, ("tcp_write(pcb=%p, arg=%p, len=%u, copy=%d)\n", (void *)pcb, arg, len, copy));
if (pcb->state == SYN_SENT || if (pcb->state == SYN_SENT ||
pcb->state == SYN_RCVD || pcb->state == SYN_RCVD ||
pcb->state == ESTABLISHED || pcb->state == ESTABLISHED ||
@ -85,7 +85,7 @@ tcp_write(struct tcp_pcb *pcb, const void *arg, u16_t len, u8_t copy)
} }
return ERR_OK; return ERR_OK;
} else { } else {
DEBUGF(TCP_OUTPUT_DEBUG | DBG_STATE | 3, ("tcp_write() called in invalid state\n")); LWIP_DEBUGF(TCP_OUTPUT_DEBUG | DBG_STATE | 3, ("tcp_write() called in invalid state\n"));
return ERR_CONN; return ERR_CONN;
} }
} }
@ -102,12 +102,12 @@ tcp_enqueue(struct tcp_pcb *pcb, void *arg, u16_t len,
void *ptr; void *ptr;
u8_t queuelen; u8_t queuelen;
DEBUGF(TCP_OUTPUT_DEBUG, ("tcp_enqueue(pcb=%p, arg=%p, len=%u, flags=%x, copy=%d)\n", (void *)pcb, arg, len, flags, copy)); LWIP_DEBUGF(TCP_OUTPUT_DEBUG, ("tcp_enqueue(pcb=%p, arg=%p, len=%u, flags=%x, copy=%d)\n", (void *)pcb, arg, len, flags, copy));
left = len; left = len;
ptr = arg; ptr = arg;
/* fail on too much data */ /* fail on too much data */
if (len > pcb->snd_buf) { if (len > pcb->snd_buf) {
DEBUGF(TCP_OUTPUT_DEBUG | 3, ("tcp_enqueue: too much data (len=%d > snd_buf=%d)\n", len, pcb->snd_buf)); LWIP_DEBUGF(TCP_OUTPUT_DEBUG | 3, ("tcp_enqueue: too much data (len=%d > snd_buf=%d)\n", len, pcb->snd_buf));
return ERR_MEM; return ERR_MEM;
} }
@ -116,13 +116,13 @@ tcp_enqueue(struct tcp_pcb *pcb, void *arg, u16_t len,
seqno = pcb->snd_lbb; seqno = pcb->snd_lbb;
queue = NULL; queue = NULL;
DEBUGF(TCP_QLEN_DEBUG, ("tcp_enqueue: queuelen: %d\n", pcb->snd_queuelen)); LWIP_DEBUGF(TCP_QLEN_DEBUG, ("tcp_enqueue: queuelen: %d\n", pcb->snd_queuelen));
/* Check if the queue length exceeds the configured maximum queue /* Check if the queue length exceeds the configured maximum queue
* length. If so, we return an error. */ * length. If so, we return an error. */
queuelen = pcb->snd_queuelen; queuelen = pcb->snd_queuelen;
if (queuelen >= TCP_SND_QUEUELEN) { if (queuelen >= TCP_SND_QUEUELEN) {
DEBUGF(TCP_OUTPUT_DEBUG | 3, ("tcp_enqueue: too long queue %d (max %d)\n", queuelen, TCP_SND_QUEUELEN)); LWIP_DEBUGF(TCP_OUTPUT_DEBUG | 3, ("tcp_enqueue: too long queue %d (max %d)\n", queuelen, TCP_SND_QUEUELEN));
goto memerr; goto memerr;
} }
@ -145,7 +145,7 @@ tcp_enqueue(struct tcp_pcb *pcb, void *arg, u16_t len,
/* Allocate memory for tcp_seg, and fill in fields. */ /* Allocate memory for tcp_seg, and fill in fields. */
seg = memp_malloc(MEMP_TCP_SEG); seg = memp_malloc(MEMP_TCP_SEG);
if (seg == NULL) { if (seg == NULL) {
DEBUGF(TCP_OUTPUT_DEBUG | 2, ("tcp_enqueue: could not allocate memory for tcp_seg\n")); LWIP_DEBUGF(TCP_OUTPUT_DEBUG | 2, ("tcp_enqueue: could not allocate memory for tcp_seg\n"));
goto memerr; goto memerr;
} }
seg->next = NULL; seg->next = NULL;
@ -173,7 +173,7 @@ tcp_enqueue(struct tcp_pcb *pcb, void *arg, u16_t len,
} }
else if (copy) { else if (copy) {
if ((seg->p = pbuf_alloc(PBUF_TRANSPORT, seglen, PBUF_RAM)) == NULL) { if ((seg->p = pbuf_alloc(PBUF_TRANSPORT, seglen, PBUF_RAM)) == NULL) {
DEBUGF(TCP_OUTPUT_DEBUG | 2, ("tcp_enqueue : could not allocate memory for pbuf copy size %u\n", seglen)); LWIP_DEBUGF(TCP_OUTPUT_DEBUG | 2, ("tcp_enqueue : could not allocate memory for pbuf copy size %u\n", seglen));
goto memerr; goto memerr;
} }
++queuelen; ++queuelen;
@ -191,7 +191,7 @@ tcp_enqueue(struct tcp_pcb *pcb, void *arg, u16_t len,
* instead of PBUF_REF here. * instead of PBUF_REF here.
*/ */
if ((p = pbuf_alloc(PBUF_TRANSPORT, seglen, PBUF_ROM)) == NULL) { if ((p = pbuf_alloc(PBUF_TRANSPORT, seglen, PBUF_ROM)) == NULL) {
DEBUGF(TCP_OUTPUT_DEBUG | 2, ("tcp_enqueue: could not allocate memory for zero-copy pbuf\n")); LWIP_DEBUGF(TCP_OUTPUT_DEBUG | 2, ("tcp_enqueue: could not allocate memory for zero-copy pbuf\n"));
goto memerr; goto memerr;
} }
++queuelen; ++queuelen;
@ -203,7 +203,7 @@ tcp_enqueue(struct tcp_pcb *pcb, void *arg, u16_t len,
/* If allocation fails, we have to deallocate the data pbuf as /* If allocation fails, we have to deallocate the data pbuf as
* well. */ * well. */
pbuf_free(p); pbuf_free(p);
DEBUGF(TCP_OUTPUT_DEBUG | 2, ("tcp_enqueue: could not allocate memory for header pbuf\n")); LWIP_DEBUGF(TCP_OUTPUT_DEBUG | 2, ("tcp_enqueue: could not allocate memory for header pbuf\n"));
goto memerr; goto memerr;
} }
++queuelen; ++queuelen;
@ -217,7 +217,7 @@ tcp_enqueue(struct tcp_pcb *pcb, void *arg, u16_t len,
/* Now that there are more segments queued, we check again if the /* Now that there are more segments queued, we check again if the
length of the queue exceeds the configured maximum. */ length of the queue exceeds the configured maximum. */
if (queuelen > TCP_SND_QUEUELEN) { if (queuelen > TCP_SND_QUEUELEN) {
DEBUGF(TCP_OUTPUT_DEBUG | 2, ("tcp_enqueue: queue too long %d (%d)\n", queuelen, TCP_SND_QUEUELEN)); LWIP_DEBUGF(TCP_OUTPUT_DEBUG | 2, ("tcp_enqueue: queue too long %d (%d)\n", queuelen, TCP_SND_QUEUELEN));
goto memerr; goto memerr;
} }
@ -230,7 +230,7 @@ tcp_enqueue(struct tcp_pcb *pcb, void *arg, u16_t len,
/* Build TCP header. */ /* Build TCP header. */
if (pbuf_header(seg->p, TCP_HLEN)) { if (pbuf_header(seg->p, TCP_HLEN)) {
DEBUGF(TCP_OUTPUT_DEBUG | 2, ("tcp_enqueue: no room for TCP header in pbuf.\n")); LWIP_DEBUGF(TCP_OUTPUT_DEBUG | 2, ("tcp_enqueue: no room for TCP header in pbuf.\n"));
#ifdef TCP_STATS #ifdef TCP_STATS
++lwip_stats.tcp.err; ++lwip_stats.tcp.err;
@ -256,7 +256,7 @@ tcp_enqueue(struct tcp_pcb *pcb, void *arg, u16_t len,
segments such as SYN|ACK. */ segments such as SYN|ACK. */
memcpy(seg->dataptr, optdata, optlen); memcpy(seg->dataptr, optdata, optlen);
} }
DEBUGF(TCP_OUTPUT_DEBUG | DBG_TRACE, ("tcp_enqueue: queueing %lu:%lu (0x%x)\n", LWIP_DEBUGF(TCP_OUTPUT_DEBUG | DBG_TRACE, ("tcp_enqueue: queueing %lu:%lu (0x%x)\n",
ntohl(seg->tcphdr->seqno), ntohl(seg->tcphdr->seqno),
ntohl(seg->tcphdr->seqno) + TCP_TCPLEN(seg), ntohl(seg->tcphdr->seqno) + TCP_TCPLEN(seg),
flags)); flags));
@ -294,7 +294,7 @@ tcp_enqueue(struct tcp_pcb *pcb, void *arg, u16_t len,
useg->len += queue->len; useg->len += queue->len;
useg->next = queue->next; useg->next = queue->next;
DEBUGF(TCP_OUTPUT_DEBUG | DBG_TRACE | DBG_STATE, ("tcp_enqueue: chaining, new len %u\n", useg->len)); LWIP_DEBUGF(TCP_OUTPUT_DEBUG | DBG_TRACE | DBG_STATE, ("tcp_enqueue: chaining, new len %u\n", useg->len));
if (seg == queue) { if (seg == queue) {
seg = NULL; seg = NULL;
} }
@ -315,7 +315,7 @@ tcp_enqueue(struct tcp_pcb *pcb, void *arg, u16_t len,
pcb->snd_lbb += len; pcb->snd_lbb += len;
pcb->snd_buf -= len; pcb->snd_buf -= len;
pcb->snd_queuelen = queuelen; pcb->snd_queuelen = queuelen;
DEBUGF(TCP_QLEN_DEBUG, ("tcp_enqueue: %d (after enqueued)\n", pcb->snd_queuelen)); LWIP_DEBUGF(TCP_QLEN_DEBUG, ("tcp_enqueue: %d (after enqueued)\n", pcb->snd_queuelen));
if (pcb->snd_queuelen != 0) { if (pcb->snd_queuelen != 0) {
LWIP_ASSERT("tcp_enqueue: valid queue length", pcb->unacked != NULL || LWIP_ASSERT("tcp_enqueue: valid queue length", pcb->unacked != NULL ||
pcb->unsent != NULL); pcb->unsent != NULL);
@ -342,7 +342,7 @@ tcp_enqueue(struct tcp_pcb *pcb, void *arg, u16_t len,
pcb->unsent != NULL); pcb->unsent != NULL);
} }
DEBUGF(TCP_QLEN_DEBUG | DBG_STATE, ("tcp_enqueue: %d (with mem err)\n", pcb->snd_queuelen)); LWIP_DEBUGF(TCP_QLEN_DEBUG | DBG_STATE, ("tcp_enqueue: %d (with mem err)\n", pcb->snd_queuelen));
return ERR_MEM; return ERR_MEM;
} }
/*-----------------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------------*/
@ -383,10 +383,10 @@ tcp_output(struct tcp_pcb *pcb)
pcb->flags &= ~(TF_ACK_DELAY | TF_ACK_NOW); pcb->flags &= ~(TF_ACK_DELAY | TF_ACK_NOW);
p = pbuf_alloc(PBUF_IP, TCP_HLEN, PBUF_RAM); p = pbuf_alloc(PBUF_IP, TCP_HLEN, PBUF_RAM);
if (p == NULL) { if (p == NULL) {
DEBUGF(TCP_OUTPUT_DEBUG, ("tcp_output: (ACK) could not allocate pbuf\n")); LWIP_DEBUGF(TCP_OUTPUT_DEBUG, ("tcp_output: (ACK) could not allocate pbuf\n"));
return ERR_BUF; return ERR_BUF;
} }
DEBUGF(TCP_OUTPUT_DEBUG, ("tcp_output: sending ACK for %lu\n", pcb->rcv_nxt)); LWIP_DEBUGF(TCP_OUTPUT_DEBUG, ("tcp_output: sending ACK for %lu\n", pcb->rcv_nxt));
tcphdr = p->payload; tcphdr = p->payload;
tcphdr->src = htons(pcb->local_port); tcphdr->src = htons(pcb->local_port);
@ -411,16 +411,16 @@ tcp_output(struct tcp_pcb *pcb)
#if TCP_OUTPUT_DEBUG #if TCP_OUTPUT_DEBUG
if (seg == NULL) { if (seg == NULL) {
DEBUGF(TCP_OUTPUT_DEBUG, ("tcp_output: nothing to send (%p)\n", pcb->unsent)); LWIP_DEBUGF(TCP_OUTPUT_DEBUG, ("tcp_output: nothing to send (%p)\n", pcb->unsent));
} }
#endif /* TCP_OUTPUT_DEBUG */ #endif /* TCP_OUTPUT_DEBUG */
#if TCP_CWND_DEBUG #if TCP_CWND_DEBUG
if (seg == NULL) { if (seg == NULL) {
DEBUGF(TCP_CWND_DEBUG, ("tcp_output: snd_wnd %lu, cwnd %lu, wnd %lu, seg == NULL, ack %lu\n", LWIP_DEBUGF(TCP_CWND_DEBUG, ("tcp_output: snd_wnd %lu, cwnd %lu, wnd %lu, seg == NULL, ack %lu\n",
pcb->snd_wnd, pcb->cwnd, wnd, pcb->snd_wnd, pcb->cwnd, wnd,
pcb->lastack)); pcb->lastack));
} else { } else {
DEBUGF(TCP_CWND_DEBUG, ("tcp_output: snd_wnd %lu, cwnd %lu, wnd %lu, effwnd %lu, seq %lu, ack %lu\n", LWIP_DEBUGF(TCP_CWND_DEBUG, ("tcp_output: snd_wnd %lu, cwnd %lu, wnd %lu, effwnd %lu, seq %lu, ack %lu\n",
pcb->snd_wnd, pcb->cwnd, wnd, pcb->snd_wnd, pcb->cwnd, wnd,
ntohl(seg->tcphdr->seqno) - pcb->lastack + seg->len, ntohl(seg->tcphdr->seqno) - pcb->lastack + seg->len,
ntohl(seg->tcphdr->seqno), pcb->lastack)); ntohl(seg->tcphdr->seqno), pcb->lastack));
@ -430,7 +430,7 @@ tcp_output(struct tcp_pcb *pcb)
while (seg != NULL && while (seg != NULL &&
ntohl(seg->tcphdr->seqno) - pcb->lastack + seg->len <= wnd) { ntohl(seg->tcphdr->seqno) - pcb->lastack + seg->len <= wnd) {
#if TCP_CWND_DEBUG #if TCP_CWND_DEBUG
DEBUGF(TCP_CWND_DEBUG, ("tcp_output: snd_wnd %lu, cwnd %lu, wnd %lu, effwnd %lu, seq %lu, ack %lu, i%d\n", LWIP_DEBUGF(TCP_CWND_DEBUG, ("tcp_output: snd_wnd %lu, cwnd %lu, wnd %lu, effwnd %lu, seq %lu, ack %lu, i%d\n",
pcb->snd_wnd, pcb->cwnd, wnd, pcb->snd_wnd, pcb->cwnd, wnd,
ntohl(seg->tcphdr->seqno) + seg->len - ntohl(seg->tcphdr->seqno) + seg->len -
pcb->lastack, pcb->lastack,
@ -503,9 +503,9 @@ tcp_output_segment(struct tcp_seg *seg, struct tcp_pcb *pcb)
pcb->rttest = tcp_ticks; pcb->rttest = tcp_ticks;
pcb->rtseq = ntohl(seg->tcphdr->seqno); pcb->rtseq = ntohl(seg->tcphdr->seqno);
DEBUGF(TCP_RTO_DEBUG, ("tcp_output_segment: rtseq %lu\n", pcb->rtseq)); LWIP_DEBUGF(TCP_RTO_DEBUG, ("tcp_output_segment: rtseq %lu\n", pcb->rtseq));
} }
DEBUGF(TCP_OUTPUT_DEBUG, ("tcp_output_segment: %lu:%lu\n", LWIP_DEBUGF(TCP_OUTPUT_DEBUG, ("tcp_output_segment: %lu:%lu\n",
htonl(seg->tcphdr->seqno), htonl(seg->tcphdr->seqno) + htonl(seg->tcphdr->seqno), htonl(seg->tcphdr->seqno) +
seg->len)); seg->len));
@ -538,7 +538,7 @@ tcp_rst(u32_t seqno, u32_t ackno,
struct tcp_hdr *tcphdr; struct tcp_hdr *tcphdr;
p = pbuf_alloc(PBUF_IP, TCP_HLEN, PBUF_RAM); p = pbuf_alloc(PBUF_IP, TCP_HLEN, PBUF_RAM);
if (p == NULL) { if (p == NULL) {
DEBUGF(TCP_DEBUG, ("tcp_rst: could not allocate memory for pbuf\n")); LWIP_DEBUGF(TCP_DEBUG, ("tcp_rst: could not allocate memory for pbuf\n"));
return; return;
} }
@ -561,7 +561,7 @@ tcp_rst(u32_t seqno, u32_t ackno,
#endif /* TCP_STATS */ #endif /* TCP_STATS */
ip_output(p, local_ip, remote_ip, TCP_TTL, IP_PROTO_TCP); ip_output(p, local_ip, remote_ip, TCP_TTL, IP_PROTO_TCP);
pbuf_free(p); pbuf_free(p);
DEBUGF(TCP_RST_DEBUG, ("tcp_rst: seqno %lu ackno %lu.\n", seqno, ackno)); LWIP_DEBUGF(TCP_RST_DEBUG, ("tcp_rst: seqno %lu ackno %lu.\n", seqno, ackno));
} }
/*-----------------------------------------------------------------------------------*/ /*-----------------------------------------------------------------------------------*/
void void

View File

@ -173,7 +173,7 @@ udp_input(struct pbuf *p, struct netif *inp)
if (pbuf_header(p, -((s16_t)(UDP_HLEN + IPH_HL(iphdr) * 4)))) { if (pbuf_header(p, -((s16_t)(UDP_HLEN + IPH_HL(iphdr) * 4)))) {
/* drop short packets */ /* drop short packets */
DEBUGF(UDP_DEBUG, ("udp_input: short UDP datagram (%u bytes) discarded\n", p->tot_len)); LWIP_DEBUGF(UDP_DEBUG, ("udp_input: short UDP datagram (%u bytes) discarded\n", p->tot_len));
#ifdef UDP_STATS #ifdef UDP_STATS
++lwip_stats.udp.lenerr; ++lwip_stats.udp.lenerr;
++lwip_stats.udp.drop; ++lwip_stats.udp.drop;
@ -185,7 +185,7 @@ udp_input(struct pbuf *p, struct netif *inp)
udphdr = (struct udp_hdr *)((u8_t *)p->payload - UDP_HLEN); udphdr = (struct udp_hdr *)((u8_t *)p->payload - UDP_HLEN);
DEBUGF(UDP_DEBUG, ("udp_input: received datagram of length %u\n", p->tot_len)); LWIP_DEBUGF(UDP_DEBUG, ("udp_input: received datagram of length %u\n", p->tot_len));
src = ntohs(udphdr->src); src = ntohs(udphdr->src);
dest = ntohs(udphdr->dest); dest = ntohs(udphdr->dest);
@ -195,7 +195,7 @@ udp_input(struct pbuf *p, struct netif *inp)
#endif /* UDP_DEBUG */ #endif /* UDP_DEBUG */
/* print the UDP source and destination */ /* print the UDP source and destination */
DEBUGF(UDP_DEBUG, ("udp (%u.%u.%u.%u, %u) <-- (%u.%u.%u.%u, %u)\n", LWIP_DEBUGF(UDP_DEBUG, ("udp (%u.%u.%u.%u, %u) <-- (%u.%u.%u.%u, %u)\n",
ip4_addr1(&iphdr->dest), ip4_addr2(&iphdr->dest), ip4_addr1(&iphdr->dest), ip4_addr2(&iphdr->dest),
ip4_addr3(&iphdr->dest), ip4_addr4(&iphdr->dest), ntohs(udphdr->dest), ip4_addr3(&iphdr->dest), ip4_addr4(&iphdr->dest), ntohs(udphdr->dest),
ip4_addr1(&iphdr->src), ip4_addr2(&iphdr->src), ip4_addr1(&iphdr->src), ip4_addr2(&iphdr->src),
@ -203,7 +203,7 @@ udp_input(struct pbuf *p, struct netif *inp)
/* Iterate through the UDP pcb list for a fully matching pcb */ /* Iterate through the UDP pcb list for a fully matching pcb */
for(pcb = udp_pcbs; pcb != NULL; pcb = pcb->next) { for(pcb = udp_pcbs; pcb != NULL; pcb = pcb->next) {
/* print the PCB local and remote address */ /* print the PCB local and remote address */
DEBUGF(UDP_DEBUG, ("pcb (%u.%u.%u.%u, %u) --- (%u.%u.%u.%u, %u)\n", LWIP_DEBUGF(UDP_DEBUG, ("pcb (%u.%u.%u.%u, %u) --- (%u.%u.%u.%u, %u)\n",
ip4_addr1(&pcb->local_ip), ip4_addr2(&pcb->local_ip), ip4_addr1(&pcb->local_ip), ip4_addr2(&pcb->local_ip),
ip4_addr3(&pcb->local_ip), ip4_addr4(&pcb->local_ip), pcb->local_port, ip4_addr3(&pcb->local_ip), ip4_addr4(&pcb->local_ip), pcb->local_port,
ip4_addr1(&pcb->remote_ip), ip4_addr2(&pcb->remote_ip), ip4_addr1(&pcb->remote_ip), ip4_addr2(&pcb->remote_ip),
@ -229,7 +229,7 @@ udp_input(struct pbuf *p, struct netif *inp)
/* Iterate through the UDP PCB list for a pcb that matches /* Iterate through the UDP PCB list for a pcb that matches
the local address. */ the local address. */
for(pcb = udp_pcbs; pcb != NULL; pcb = pcb->next) { for(pcb = udp_pcbs; pcb != NULL; pcb = pcb->next) {
DEBUGF(UDP_DEBUG, ("pcb (%u.%u.%u.%u, %u) --- (%u.%u.%u.%u, %u)\n", LWIP_DEBUGF(UDP_DEBUG, ("pcb (%u.%u.%u.%u, %u) --- (%u.%u.%u.%u, %u)\n",
ip4_addr1(&pcb->local_ip), ip4_addr2(&pcb->local_ip), ip4_addr1(&pcb->local_ip), ip4_addr2(&pcb->local_ip),
ip4_addr3(&pcb->local_ip), ip4_addr4(&pcb->local_ip), pcb->local_port, ip4_addr3(&pcb->local_ip), ip4_addr4(&pcb->local_ip), pcb->local_port,
ip4_addr1(&pcb->remote_ip), ip4_addr2(&pcb->remote_ip), ip4_addr1(&pcb->remote_ip), ip4_addr2(&pcb->remote_ip),
@ -250,7 +250,7 @@ udp_input(struct pbuf *p, struct netif *inp)
/* Check checksum if this is a match or if it was directed at us. */ /* Check checksum if this is a match or if it was directed at us. */
if (pcb != NULL || ip_addr_cmp(&inp->ip_addr, &iphdr->dest)) if (pcb != NULL || ip_addr_cmp(&inp->ip_addr, &iphdr->dest))
{ {
DEBUGF(UDP_DEBUG | DBG_TRACE, ("udp_input: calculating checksum\n")); LWIP_DEBUGF(UDP_DEBUG | DBG_TRACE, ("udp_input: calculating checksum\n"));
pbuf_header(p, UDP_HLEN); pbuf_header(p, UDP_HLEN);
#ifdef IPv6 #ifdef IPv6
if (iphdr->nexthdr == IP_PROTO_UDPLITE) { if (iphdr->nexthdr == IP_PROTO_UDPLITE) {
@ -261,7 +261,7 @@ udp_input(struct pbuf *p, struct netif *inp)
if (inet_chksum_pseudo(p, (struct ip_addr *)&(iphdr->src), if (inet_chksum_pseudo(p, (struct ip_addr *)&(iphdr->src),
(struct ip_addr *)&(iphdr->dest), (struct ip_addr *)&(iphdr->dest),
IP_PROTO_UDPLITE, ntohs(udphdr->len)) != 0) { IP_PROTO_UDPLITE, ntohs(udphdr->len)) != 0) {
DEBUGF(UDP_DEBUG | 2, ("udp_input: UDP Lite datagram discarded due to failing checksum\n")); LWIP_DEBUGF(UDP_DEBUG | 2, ("udp_input: UDP Lite datagram discarded due to failing checksum\n"));
#ifdef UDP_STATS #ifdef UDP_STATS
++lwip_stats.udp.chkerr; ++lwip_stats.udp.chkerr;
++lwip_stats.udp.drop; ++lwip_stats.udp.drop;
@ -275,7 +275,7 @@ udp_input(struct pbuf *p, struct netif *inp)
if (inet_chksum_pseudo(p, (struct ip_addr *)&(iphdr->src), if (inet_chksum_pseudo(p, (struct ip_addr *)&(iphdr->src),
(struct ip_addr *)&(iphdr->dest), (struct ip_addr *)&(iphdr->dest),
IP_PROTO_UDP, p->tot_len) != 0) { IP_PROTO_UDP, p->tot_len) != 0) {
DEBUGF(UDP_DEBUG | 2, ("udp_input: UDP datagram discarded due to failing checksum\n")); LWIP_DEBUGF(UDP_DEBUG | 2, ("udp_input: UDP datagram discarded due to failing checksum\n"));
#ifdef UDP_STATS #ifdef UDP_STATS
++lwip_stats.udp.chkerr; ++lwip_stats.udp.chkerr;
@ -292,7 +292,7 @@ udp_input(struct pbuf *p, struct netif *inp)
snmp_inc_udpindatagrams(); snmp_inc_udpindatagrams();
pcb->recv(pcb->recv_arg, pcb, p, &(iphdr->src), src); pcb->recv(pcb->recv_arg, pcb, p, &(iphdr->src), src);
} else { } else {
DEBUGF(UDP_DEBUG | DBG_TRACE, ("udp_input: not for us.\n")); LWIP_DEBUGF(UDP_DEBUG | DBG_TRACE, ("udp_input: not for us.\n"));
/* No match was found, send ICMP destination port unreachable unless /* No match was found, send ICMP destination port unreachable unless
destination address was broadcast/multicast. */ destination address was broadcast/multicast. */
@ -341,14 +341,14 @@ udp_send(struct udp_pcb *pcb, struct pbuf *p)
err_t err; err_t err;
struct pbuf *q; /* q will be sent down the stack */ struct pbuf *q; /* q will be sent down the stack */
DEBUGF(UDP_DEBUG | DBG_TRACE | 3, ("udp_send\n")); LWIP_DEBUGF(UDP_DEBUG | DBG_TRACE | 3, ("udp_send\n"));
/* if the PCB is not yet bound to a port, bind it here */ /* if the PCB is not yet bound to a port, bind it here */
if (pcb->local_port == 0) { if (pcb->local_port == 0) {
DEBUGF(UDP_DEBUG | DBG_TRACE | 2, ("udp_send: not yet bound to a port, binding now\n")); LWIP_DEBUGF(UDP_DEBUG | DBG_TRACE | 2, ("udp_send: not yet bound to a port, binding now\n"));
err = udp_bind(pcb, &pcb->local_ip, pcb->local_port); err = udp_bind(pcb, &pcb->local_ip, pcb->local_port);
if (err != ERR_OK) { if (err != ERR_OK) {
DEBUGF(UDP_DEBUG | DBG_TRACE | 2, ("udp_send: forced port bind failed\n")); LWIP_DEBUGF(UDP_DEBUG | DBG_TRACE | 2, ("udp_send: forced port bind failed\n"));
return err; return err;
} }
} }
@ -359,18 +359,18 @@ udp_send(struct udp_pcb *pcb, struct pbuf *p)
q = pbuf_alloc(PBUF_IP, UDP_HLEN, PBUF_RAM); q = pbuf_alloc(PBUF_IP, UDP_HLEN, PBUF_RAM);
/* new header pbuf could not be allocated? */ /* new header pbuf could not be allocated? */
if (q == NULL) { if (q == NULL) {
DEBUGF(UDP_DEBUG | DBG_TRACE | 2, ("udp_send: could not allocate header\n")); LWIP_DEBUGF(UDP_DEBUG | DBG_TRACE | 2, ("udp_send: could not allocate header\n"));
return ERR_MEM; return ERR_MEM;
} }
/* chain header q in front of given pbuf p */ /* chain header q in front of given pbuf p */
pbuf_chain(q, p); pbuf_chain(q, p);
/* { first pbuf q points to header pbuf } */ /* { first pbuf q points to header pbuf } */
DEBUGF(UDP_DEBUG, ("udp_send: added header pbuf %p before given pbuf %p\n", (void *)q, (void *)p)); LWIP_DEBUGF(UDP_DEBUG, ("udp_send: added header pbuf %p before given pbuf %p\n", (void *)q, (void *)p));
/* adding a header within p succeeded */ /* adding a header within p succeeded */
} else { } else {
/* first pbuf q equals given pbuf */ /* first pbuf q equals given pbuf */
q = p; q = p;
DEBUGF(UDP_DEBUG, ("udp_send: added header in given pbuf %p\n", (void *)p)); LWIP_DEBUGF(UDP_DEBUG, ("udp_send: added header in given pbuf %p\n", (void *)p));
} }
udphdr = q->payload; udphdr = q->payload;
@ -379,7 +379,7 @@ udp_send(struct udp_pcb *pcb, struct pbuf *p)
udphdr->chksum = 0x0000; udphdr->chksum = 0x0000;
if ((netif = ip_route(&(pcb->remote_ip))) == NULL) { if ((netif = ip_route(&(pcb->remote_ip))) == NULL) {
DEBUGF(UDP_DEBUG | 1, ("udp_send: No route to 0x%lx\n", pcb->remote_ip.addr)); LWIP_DEBUGF(UDP_DEBUG | 1, ("udp_send: No route to 0x%lx\n", pcb->remote_ip.addr));
#ifdef UDP_STATS #ifdef UDP_STATS
++lwip_stats.udp.rterr; ++lwip_stats.udp.rterr;
#endif /* UDP_STATS */ #endif /* UDP_STATS */
@ -394,11 +394,11 @@ udp_send(struct udp_pcb *pcb, struct pbuf *p)
src_ip = &(pcb->local_ip); src_ip = &(pcb->local_ip);
} }
DEBUGF(UDP_DEBUG, ("udp_send: sending datagram of length %u\n", q->tot_len)); LWIP_DEBUGF(UDP_DEBUG, ("udp_send: sending datagram of length %u\n", q->tot_len));
/* UDP Lite protocol? */ /* UDP Lite protocol? */
if (pcb->flags & UDP_FLAGS_UDPLITE) { if (pcb->flags & UDP_FLAGS_UDPLITE) {
DEBUGF(UDP_DEBUG, ("udp_send: UDP LITE packet length %u\n", q->tot_len)); LWIP_DEBUGF(UDP_DEBUG, ("udp_send: UDP LITE packet length %u\n", q->tot_len));
/* set UDP message length in UDP header */ /* set UDP message length in UDP header */
udphdr->len = htons(pcb->chksum_len); udphdr->len = htons(pcb->chksum_len);
/* calculate checksum */ /* calculate checksum */
@ -410,7 +410,7 @@ udp_send(struct udp_pcb *pcb, struct pbuf *p)
err = ip_output_if (q, src_ip, &pcb->remote_ip, UDP_TTL, IP_PROTO_UDPLITE, netif); err = ip_output_if (q, src_ip, &pcb->remote_ip, UDP_TTL, IP_PROTO_UDPLITE, netif);
snmp_inc_udpoutdatagrams(); snmp_inc_udpoutdatagrams();
} else { } else {
DEBUGF(UDP_DEBUG, ("udp_send: UDP packet length %u\n", q->tot_len)); LWIP_DEBUGF(UDP_DEBUG, ("udp_send: UDP packet length %u\n", q->tot_len));
udphdr->len = htons(q->tot_len); udphdr->len = htons(q->tot_len);
/* calculate checksum */ /* calculate checksum */
if ((pcb->flags & UDP_FLAGS_NOCHKSUM) == 0) { if ((pcb->flags & UDP_FLAGS_NOCHKSUM) == 0) {
@ -418,9 +418,9 @@ udp_send(struct udp_pcb *pcb, struct pbuf *p)
/* chksum zero must become 0xffff, as zero means 'no checksum' */ /* chksum zero must become 0xffff, as zero means 'no checksum' */
if (udphdr->chksum == 0x0000) udphdr->chksum = 0xffff; if (udphdr->chksum == 0x0000) udphdr->chksum = 0xffff;
} }
DEBUGF(UDP_DEBUG, ("udp_send: UDP checksum 0x%04x\n", udphdr->chksum)); LWIP_DEBUGF(UDP_DEBUG, ("udp_send: UDP checksum 0x%04x\n", udphdr->chksum));
snmp_inc_udpoutdatagrams(); snmp_inc_udpoutdatagrams();
DEBUGF(UDP_DEBUG, ("udp_send: ip_output_if (,,,,IP_PROTO_UDP,)\n")); LWIP_DEBUGF(UDP_DEBUG, ("udp_send: ip_output_if (,,,,IP_PROTO_UDP,)\n"));
/* output to IP */ /* output to IP */
err = ip_output_if (q, src_ip, &pcb->remote_ip, UDP_TTL, IP_PROTO_UDP, netif); err = ip_output_if (q, src_ip, &pcb->remote_ip, UDP_TTL, IP_PROTO_UDP, netif);
} }
@ -457,7 +457,7 @@ udp_bind(struct udp_pcb *pcb, struct ip_addr *ipaddr, u16_t port)
{ {
struct udp_pcb *ipcb; struct udp_pcb *ipcb;
u8_t rebind; u8_t rebind;
DEBUGF(UDP_DEBUG | DBG_TRACE | 3, ("udp_bind(ipaddr = %lx, port = %u)\n", ipaddr->addr, port)); LWIP_DEBUGF(UDP_DEBUG | DBG_TRACE | 3, ("udp_bind(ipaddr = %lx, port = %u)\n", ipaddr->addr, port));
rebind = 0; rebind = 0;
/* Check for double bind and rebind of the same pcb */ /* Check for double bind and rebind of the same pcb */
for (ipcb = udp_pcbs; ipcb != NULL; ipcb = ipcb->next) { for (ipcb = udp_pcbs; ipcb != NULL; ipcb = ipcb->next) {
@ -480,7 +480,7 @@ udp_bind(struct udp_pcb *pcb, struct ip_addr *ipaddr, u16_t port)
ip_addr_isany(ipaddr) || ip_addr_isany(ipaddr) ||
ip_addr_cmp(&(ipcb->local_ip), ipaddr))) { ip_addr_cmp(&(ipcb->local_ip), ipaddr))) {
/* other PCB already binds to this local IP and port */ /* other PCB already binds to this local IP and port */
DEBUGF(UDP_DEBUG, ("udp_bind: local port %u already bound by another pcb\n", port)); LWIP_DEBUGF(UDP_DEBUG, ("udp_bind: local port %u already bound by another pcb\n", port));
return ERR_USE; return ERR_USE;
} }
#endif #endif
@ -504,7 +504,7 @@ udp_bind(struct udp_pcb *pcb, struct ip_addr *ipaddr, u16_t port)
} }
if (ipcb != NULL) { if (ipcb != NULL) {
/* no more ports available in local range */ /* no more ports available in local range */
DEBUGF(UDP_DEBUG, ("udp_bind: out of free UDP ports\n")); LWIP_DEBUGF(UDP_DEBUG, ("udp_bind: out of free UDP ports\n"));
return ERR_USE; return ERR_USE;
} }
} }
@ -515,7 +515,7 @@ udp_bind(struct udp_pcb *pcb, struct ip_addr *ipaddr, u16_t port)
pcb->next = udp_pcbs; pcb->next = udp_pcbs;
udp_pcbs = pcb; udp_pcbs = pcb;
} }
DEBUGF(UDP_DEBUG | DBG_TRACE | DBG_STATE, ("udp_bind: bound to %u.%u.%u.%u, port %u\n", 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) >> 24 & 0xff),
(u8_t)(ntohl(pcb->local_ip.addr) >> 16 & 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) >> 8 & 0xff),
@ -556,7 +556,7 @@ udp_connect(struct udp_pcb *pcb, struct ip_addr *ipaddr, u16_t port)
struct netif *netif; struct netif *netif;
if ((netif = ip_route(&(pcb->remote_ip))) == NULL) { if ((netif = ip_route(&(pcb->remote_ip))) == NULL) {
DEBUGF(UDP_DEBUG, ("udp_connect: No route to 0x%lx\n", pcb->remote_ip.addr)); LWIP_DEBUGF(UDP_DEBUG, ("udp_connect: No route to 0x%lx\n", pcb->remote_ip.addr));
#ifdef UDP_STATS #ifdef UDP_STATS
++lwip_stats.udp.rterr; ++lwip_stats.udp.rterr;
#endif /* UDP_STATS */ #endif /* UDP_STATS */
@ -570,7 +570,7 @@ udp_connect(struct udp_pcb *pcb, struct ip_addr *ipaddr, u16_t port)
pcb->local_ip.addr = 0; pcb->local_ip.addr = 0;
} }
#endif #endif
DEBUGF(UDP_DEBUG | DBG_TRACE | DBG_STATE, ("udp_connect: connected to %u.%u.%u.%u, port %u\n", 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) >> 24 & 0xff),
(u8_t)(ntohl(pcb->remote_ip.addr) >> 16 & 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) >> 8 & 0xff),
@ -655,14 +655,14 @@ udp_new(void) {
int int
udp_debug_print(struct udp_hdr *udphdr) udp_debug_print(struct udp_hdr *udphdr)
{ {
DEBUGF(UDP_DEBUG, ("UDP header:\n")); LWIP_DEBUGF(UDP_DEBUG, ("UDP header:\n"));
DEBUGF(UDP_DEBUG, ("+-------------------------------+\n")); LWIP_DEBUGF(UDP_DEBUG, ("+-------------------------------+\n"));
DEBUGF(UDP_DEBUG, ("| %5u | %5u | (src port, dest port)\n", LWIP_DEBUGF(UDP_DEBUG, ("| %5u | %5u | (src port, dest port)\n",
ntohs(udphdr->src), ntohs(udphdr->dest))); ntohs(udphdr->src), ntohs(udphdr->dest)));
DEBUGF(UDP_DEBUG, ("+-------------------------------+\n")); LWIP_DEBUGF(UDP_DEBUG, ("+-------------------------------+\n"));
DEBUGF(UDP_DEBUG, ("| %5u | 0x%04x | (len, chksum)\n", LWIP_DEBUGF(UDP_DEBUG, ("| %5u | 0x%04x | (len, chksum)\n",
ntohs(udphdr->len), ntohs(udphdr->chksum))); ntohs(udphdr->len), ntohs(udphdr->chksum)));
DEBUGF(UDP_DEBUG, ("+-------------------------------+\n")); LWIP_DEBUGF(UDP_DEBUG, ("+-------------------------------+\n"));
return 0; return 0;
} }
#endif /* UDP_DEBUG */ #endif /* UDP_DEBUG */

View File

@ -119,7 +119,7 @@ extern const struct ip_addr ip_addr_broadcast;
#define ip_addr_ismulticast(addr1) (((addr1)->addr & ntohl(0xf0000000)) == ntohl(0xe0000000)) #define ip_addr_ismulticast(addr1) (((addr1)->addr & ntohl(0xf0000000)) == ntohl(0xe0000000))
#define ip_addr_debug_print(ipaddr) DEBUGF(LWIP_DEBUG, ("%d.%d.%d.%d", \ #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) >> 24) & 0xff, \
(u8_t)(ntohl((ipaddr)->addr) >> 16) & 0xff, \ (u8_t)(ntohl((ipaddr)->addr) >> 16) & 0xff, \
(u8_t)(ntohl((ipaddr)->addr) >> 8) & 0xff, \ (u8_t)(ntohl((ipaddr)->addr) >> 8) & 0xff, \

View File

@ -47,30 +47,34 @@
#define DBG_LEVEL_SEVERE 3 /* */ #define DBG_LEVEL_SEVERE 3 /* */
#define DBG_MASK_LEVEL 3 #define DBG_MASK_LEVEL 3
/** flag for DEBUGF to enable that debug message */ /** flag for LWIP_DEBUGF to enable that debug message */
#define DBG_ON 0x80U #define DBG_ON 0x80U
/** flag for DEBUGF to disable that debug message */ /** flag for LWIP_DEBUGF to disable that debug message */
#define DBG_OFF 0x00U #define DBG_OFF 0x00U
/** flag for DEBUGF indicating a tracing message (to follow program flow) */ /** flag for LWIP_DEBUGF indicating a tracing message (to follow program flow) */
#define DBG_TRACE 0x40U #define DBG_TRACE 0x40U
/** flag for DEBUGF indicating a state debug message (to follow module states) */ /** flag for LWIP_DEBUGF indicating a state debug message (to follow module states) */
#define DBG_STATE 0x20U #define DBG_STATE 0x20U
/** flag for DEBUGF indicating newly added code, not thoroughly tested yet */ /** flag for LWIP_DEBUGF indicating newly added code, not thoroughly tested yet */
#define DBG_FRESH 0x10U #define DBG_FRESH 0x10U
/** flag for DEBUGF to halt after printing this debug message */ /** flag for LWIP_DEBUGF to halt after printing this debug message */
#define DBG_HALT 0x08U #define DBG_HALT 0x08U
#ifdef LWIP_DEBUG #ifdef LWIP_DEBUG
# ifndef LWIP_NOASSERT
# define LWIP_ASSERT(x,y) do { if(!(y)) LWIP_PLATFORM_ASSERT(x); } while(0) # define LWIP_ASSERT(x,y) do { if(!(y)) LWIP_PLATFORM_ASSERT(x); } while(0)
# else
# define LWIP_ASSERT(x,y)
# endif
/** print debug message only if debug message type is enabled... /** print debug message only if debug message type is enabled...
* AND is of correct type AND is at least DBG_LEVEL * AND is of correct type AND is at least DBG_LEVEL
*/ */
# define DEBUGF(debug,x) do { if (((debug) & DBG_ON) && ((debug) & DBG_TYPES_ON) && (((debug) & DBG_MASK_LEVEL) >= DBG_MIN_LEVEL)) { LWIP_PLATFORM_DIAG(x); if ((debug) & DBG_HALT) while(1); } } while(0) # define LWIP_DEBUGF(debug,x) do { if (((debug) & DBG_ON) && ((debug) & DBG_TYPES_ON) && (((debug) & DBG_MASK_LEVEL) >= DBG_MIN_LEVEL)) { LWIP_PLATFORM_DIAG(x); if ((debug) & DBG_HALT) while(1); } } while(0)
# define LWIP_ERROR(x) do { LWIP_PLATFORM_DIAG(x); } while(0) # define LWIP_ERROR(x) do { LWIP_PLATFORM_DIAG(x); } while(0)
#else /* LWIP_DEBUG */ #else /* LWIP_DEBUG */
# define LWIP_ASSERT(x,y) # define LWIP_ASSERT(x,y)
# define DEBUGF(debug,x) # define LWIP_DEBUGF(debug,x)
# define LWIP_ERROR(x) # define LWIP_ERROR(x)
#endif /* LWIP_DEBUG */ #endif /* LWIP_DEBUG */

View File

@ -435,7 +435,7 @@ extern struct tcp_pcb *tcp_tmp_pcb; /* Only used for temporary storage. */
with a PCB list or removes a PCB from a list, respectively. */ with a PCB list or removes a PCB from a list, respectively. */
#if 0 #if 0
#define TCP_REG(pcbs, npcb) do {\ #define TCP_REG(pcbs, npcb) do {\
DEBUGF(TCP_DEBUG, ("TCP_REG %p local port %d\n", npcb, npcb->local_port)); \ LWIP_DEBUGF(TCP_DEBUG, ("TCP_REG %p local port %d\n", npcb, npcb->local_port)); \
for(tcp_tmp_pcb = *pcbs; \ for(tcp_tmp_pcb = *pcbs; \
tcp_tmp_pcb != NULL; \ tcp_tmp_pcb != NULL; \
tcp_tmp_pcb = tcp_tmp_pcb->next) { \ tcp_tmp_pcb = tcp_tmp_pcb->next) { \
@ -450,7 +450,7 @@ extern struct tcp_pcb *tcp_tmp_pcb; /* Only used for temporary storage. */
} while(0) } while(0)
#define TCP_RMV(pcbs, npcb) do { \ #define TCP_RMV(pcbs, npcb) do { \
LWIP_ASSERT("TCP_RMV: pcbs != NULL", *pcbs != NULL); \ LWIP_ASSERT("TCP_RMV: pcbs != NULL", *pcbs != NULL); \
DEBUGF(TCP_DEBUG, ("TCP_RMV: removing %p from %p\n", npcb, *pcbs)); \ LWIP_DEBUGF(TCP_DEBUG, ("TCP_RMV: removing %p from %p\n", npcb, *pcbs)); \
if(*pcbs == npcb) { \ if(*pcbs == npcb) { \
*pcbs = (*pcbs)->next; \ *pcbs = (*pcbs)->next; \
} else for(tcp_tmp_pcb = *pcbs; tcp_tmp_pcb != NULL; tcp_tmp_pcb = tcp_tmp_pcb->next) { \ } else for(tcp_tmp_pcb = *pcbs; tcp_tmp_pcb != NULL; tcp_tmp_pcb = tcp_tmp_pcb->next) { \
@ -461,7 +461,7 @@ extern struct tcp_pcb *tcp_tmp_pcb; /* Only used for temporary storage. */
} \ } \
npcb->next = NULL; \ npcb->next = NULL; \
LWIP_ASSERT("TCP_RMV: tcp_pcbs sane", tcp_pcbs_sane()); \ LWIP_ASSERT("TCP_RMV: tcp_pcbs sane", tcp_pcbs_sane()); \
DEBUGF(TCP_DEBUG, ("TCP_RMV: removed %p from %p\n", npcb, *pcbs)); \ LWIP_DEBUGF(TCP_DEBUG, ("TCP_RMV: removed %p from %p\n", npcb, *pcbs)); \
} while(0) } while(0)
#else /* LWIP_DEBUG */ #else /* LWIP_DEBUG */

View File

@ -149,18 +149,18 @@ etharp_tmr(void)
{ {
u8_t i; u8_t i;
DEBUGF(ETHARP_DEBUG, ("etharp_timer\n")); LWIP_DEBUGF(ETHARP_DEBUG, ("etharp_timer\n"));
/* remove expired entries from the ARP table */ /* remove expired entries from the ARP table */
for (i = 0; i < ARP_TABLE_SIZE; ++i) { for (i = 0; i < ARP_TABLE_SIZE; ++i) {
arp_table[i].ctime++; arp_table[i].ctime++;
if ((arp_table[i].state == ETHARP_STATE_STABLE) && if ((arp_table[i].state == ETHARP_STATE_STABLE) &&
(arp_table[i].ctime >= ARP_MAXAGE)) { (arp_table[i].ctime >= ARP_MAXAGE)) {
DEBUGF(ETHARP_DEBUG, ("etharp_timer: expired stable entry %u.\n", i)); LWIP_DEBUGF(ETHARP_DEBUG, ("etharp_timer: expired stable entry %u.\n", i));
arp_table[i].state = ETHARP_STATE_EMPTY; arp_table[i].state = ETHARP_STATE_EMPTY;
#if ARP_QUEUEING #if ARP_QUEUEING
if (arp_table[i].p != NULL) { if (arp_table[i].p != NULL) {
/* remove any queued packet */ /* remove any queued packet */
DEBUGF(ETHARP_DEBUG, ("etharp_timer: freeing packet queue %p.\n", i, (void *)(arp_table[i].p))); LWIP_DEBUGF(ETHARP_DEBUG, ("etharp_timer: freeing packet queue %p.\n", i, (void *)(arp_table[i].p)));
pbuf_free(arp_table[i].p); pbuf_free(arp_table[i].p);
arp_table[i].p = NULL; arp_table[i].p = NULL;
} }
@ -168,11 +168,11 @@ etharp_tmr(void)
} else if ((arp_table[i].state == ETHARP_STATE_PENDING) && } else if ((arp_table[i].state == ETHARP_STATE_PENDING) &&
(arp_table[i].ctime >= ARP_MAXPENDING)) { (arp_table[i].ctime >= ARP_MAXPENDING)) {
arp_table[i].state = ETHARP_STATE_EMPTY; arp_table[i].state = ETHARP_STATE_EMPTY;
DEBUGF(ETHARP_DEBUG, ("etharp_timer: expired pending entry %u.\n", i)); LWIP_DEBUGF(ETHARP_DEBUG, ("etharp_timer: expired pending entry %u.\n", i));
#if ARP_QUEUEING #if ARP_QUEUEING
if (arp_table[i].p != NULL) { if (arp_table[i].p != NULL) {
/* remove any queued packet */ /* remove any queued packet */
DEBUGF(ETHARP_DEBUG, ("etharp_timer: freeing packet queue %p.\n", i, (void *)(arp_table[i].p))); LWIP_DEBUGF(ETHARP_DEBUG, ("etharp_timer: freeing packet queue %p.\n", i, (void *)(arp_table[i].p)));
pbuf_free(arp_table[i].p); pbuf_free(arp_table[i].p);
arp_table[i].p = NULL; arp_table[i].p = NULL;
} }
@ -196,7 +196,7 @@ find_arp_entry(void)
/* Try to find an unused entry in the ARP table. */ /* Try to find an unused entry in the ARP table. */
for (i = 0; i < ARP_TABLE_SIZE; ++i) { for (i = 0; i < ARP_TABLE_SIZE; ++i) {
if (arp_table[i].state == ETHARP_STATE_EMPTY) { if (arp_table[i].state == ETHARP_STATE_EMPTY) {
DEBUGF(ETHARP_DEBUG, ("find_arp_entry: found empty entry %u\n", i)); LWIP_DEBUGF(ETHARP_DEBUG, ("find_arp_entry: found empty entry %u\n", i));
break; break;
} }
} }
@ -218,13 +218,13 @@ find_arp_entry(void)
} }
} }
if (j != ARP_TABLE_SIZE) { if (j != ARP_TABLE_SIZE) {
DEBUGF(ETHARP_DEBUG, ("find_arp_entry: found oldest stable entry %u\n", j)); LWIP_DEBUGF(ETHARP_DEBUG, ("find_arp_entry: found oldest stable entry %u\n", j));
} else { } else {
DEBUGF(ETHARP_DEBUG, ("find_arp_entry: no replacable entry could be found\n")); LWIP_DEBUGF(ETHARP_DEBUG, ("find_arp_entry: no replacable entry could be found\n"));
} }
i = j; i = j;
} }
DEBUGF(ETHARP_DEBUG, ("find_arp_entry: returning %u, state %u\n", i, arp_table[i].state)); LWIP_DEBUGF(ETHARP_DEBUG, ("find_arp_entry: returning %u, state %u\n", i, arp_table[i].state));
return i; return i;
} }
@ -246,13 +246,13 @@ static struct pbuf *
update_arp_entry(struct netif *netif, struct ip_addr *ipaddr, struct eth_addr *ethaddr, u8_t flags) update_arp_entry(struct netif *netif, struct ip_addr *ipaddr, struct eth_addr *ethaddr, u8_t flags)
{ {
u8_t i, k; u8_t i, k;
DEBUGF(ETHARP_DEBUG | DBG_TRACE | 3, ("update_arp_entry()\n")); LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE | 3, ("update_arp_entry()\n"));
LWIP_ASSERT("netif->hwaddr_len != 0", netif->hwaddr_len != 0); LWIP_ASSERT("netif->hwaddr_len != 0", netif->hwaddr_len != 0);
DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("update_arp_entry: %u.%u.%u.%u - %02x:%02x:%02x:%02x:%02x:%02x\n", ip4_addr1(ipaddr), ip4_addr2(ipaddr), ip4_addr3(ipaddr), ip4_addr4(ipaddr), LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("update_arp_entry: %u.%u.%u.%u - %02x:%02x:%02x:%02x:%02x:%02x\n", ip4_addr1(ipaddr), ip4_addr2(ipaddr), ip4_addr3(ipaddr), ip4_addr4(ipaddr),
ethaddr->addr[0], ethaddr->addr[1], ethaddr->addr[2], ethaddr->addr[3], ethaddr->addr[4], ethaddr->addr[5])); ethaddr->addr[0], ethaddr->addr[1], ethaddr->addr[2], ethaddr->addr[3], ethaddr->addr[4], ethaddr->addr[5]));
/* do not update for 0.0.0.0 addresses */ /* do not update for 0.0.0.0 addresses */
if (ipaddr->addr == 0) { if (ipaddr->addr == 0) {
DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("update_arp_entry: will not add 0.0.0.0 to ARP cache\n")); LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("update_arp_entry: will not add 0.0.0.0 to ARP cache\n"));
return NULL; return NULL;
} }
/* Walk through the ARP mapping table and try to find an entry to /* Walk through the ARP mapping table and try to find an entry to
@ -264,7 +264,7 @@ update_arp_entry(struct netif *netif, struct ip_addr *ipaddr, struct eth_addr *e
if (ip_addr_cmp(ipaddr, &arp_table[i].ipaddr)) { if (ip_addr_cmp(ipaddr, &arp_table[i].ipaddr)) {
/* pending entry? */ /* pending entry? */
if (arp_table[i].state == ETHARP_STATE_PENDING) { if (arp_table[i].state == ETHARP_STATE_PENDING) {
DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("update_arp_entry: pending entry %u goes stable\n", i)); LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("update_arp_entry: pending entry %u goes stable\n", i));
/* A pending entry was found, mark it stable */ /* A pending entry was found, mark it stable */
arp_table[i].state = ETHARP_STATE_STABLE; arp_table[i].state = ETHARP_STATE_STABLE;
/* fall-through to next if */ /* fall-through to next if */
@ -275,7 +275,7 @@ update_arp_entry(struct netif *netif, struct ip_addr *ipaddr, struct eth_addr *e
struct pbuf *p; struct pbuf *p;
struct eth_hdr *ethhdr; struct eth_hdr *ethhdr;
#endif #endif
DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("update_arp_entry: updating stable entry %u\n", i)); LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("update_arp_entry: updating stable entry %u\n", i));
/* An old entry found, update this and return. */ /* An old entry found, update this and return. */
for (k = 0; k < netif->hwaddr_len; ++k) { for (k = 0; k < netif->hwaddr_len; ++k) {
arp_table[i].ethaddr.addr[k] = ethaddr->addr[k]; arp_table[i].ethaddr.addr[k] = ethaddr->addr[k];
@ -294,7 +294,7 @@ update_arp_entry(struct netif *netif, struct ip_addr *ipaddr, struct eth_addr *e
ethhdr->dest.addr[k] = ethaddr->addr[k]; ethhdr->dest.addr[k] = ethaddr->addr[k];
} }
ethhdr->type = htons(ETHTYPE_IP); ethhdr->type = htons(ETHTYPE_IP);
DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("update_arp_entry: sending queued IP packet.\n")); LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("update_arp_entry: sending queued IP packet.\n"));
/* send the queued IP packet */ /* send the queued IP packet */
netif->linkoutput(netif, p); netif->linkoutput(netif, p);
/* free the queued IP packet */ /* free the queued IP packet */
@ -309,26 +309,26 @@ update_arp_entry(struct netif *netif, struct ip_addr *ipaddr, struct eth_addr *e
/* no matching ARP entry was found */ /* no matching ARP entry was found */
LWIP_ASSERT("update_arp_entry: i == ARP_TABLE_SIZE", i == ARP_TABLE_SIZE); LWIP_ASSERT("update_arp_entry: i == ARP_TABLE_SIZE", i == ARP_TABLE_SIZE);
DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("update_arp_entry: IP address not yet in table\n")); LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("update_arp_entry: IP address not yet in table\n"));
/* allowed to insert an entry? */ /* allowed to insert an entry? */
if ((ETHARP_ALWAYS_INSERT) || (flags & ARP_INSERT_FLAG)) if ((ETHARP_ALWAYS_INSERT) || (flags & ARP_INSERT_FLAG))
{ {
DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("update_arp_entry: adding entry to table\n")); LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("update_arp_entry: adding entry to table\n"));
/* find an empty or old entry. */ /* find an empty or old entry. */
i = find_arp_entry(); i = find_arp_entry();
if (i == ARP_TABLE_SIZE) { if (i == ARP_TABLE_SIZE) {
DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("update_arp_entry: no available entry found\n")); LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("update_arp_entry: no available entry found\n"));
return NULL; return NULL;
} }
/* see if find_arp_entry() gave us an old stable, or empty entry to re-use */ /* see if find_arp_entry() gave us an old stable, or empty entry to re-use */
if (arp_table[i].state == ETHARP_STATE_STABLE) { if (arp_table[i].state == ETHARP_STATE_STABLE) {
DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("update_arp_entry: overwriting old stable entry %u\n", i)); LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("update_arp_entry: overwriting old stable entry %u\n", i));
/* stable entries should have no queued packets (TODO: allow later) */ /* stable entries should have no queued packets (TODO: allow later) */
#if ARP_QUEUEING #if ARP_QUEUEING
LWIP_ASSERT("update_arp_entry: arp_table[i].p == NULL", arp_table[i].p == NULL); LWIP_ASSERT("update_arp_entry: arp_table[i].p == NULL", arp_table[i].p == NULL);
#endif #endif
} else { } else {
DEBUGF(ETHARP_DEBUG | DBG_TRACE | DBG_STATE, ("update_arp_entry: filling empty entry %u with state %u\n", i, arp_table[i].state)); LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE | DBG_STATE, ("update_arp_entry: filling empty entry %u with state %u\n", i, arp_table[i].state));
LWIP_ASSERT("update_arp_entry: arp_table[i].state == ETHARP_STATE_EMPTY", arp_table[i].state == ETHARP_STATE_EMPTY); LWIP_ASSERT("update_arp_entry: arp_table[i].state == ETHARP_STATE_EMPTY", arp_table[i].state == ETHARP_STATE_EMPTY);
} }
/* set IP address */ /* set IP address */
@ -348,7 +348,7 @@ update_arp_entry(struct netif *netif, struct ip_addr *ipaddr, struct eth_addr *e
} }
else else
{ {
DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("update_arp_entry: no matching stable entry to update\n")); LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("update_arp_entry: no matching stable entry to update\n"));
} }
return NULL; return NULL;
} }
@ -382,7 +382,7 @@ etharp_ip_input(struct netif *netif, struct pbuf *p)
return NULL; return NULL;
} }
DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("etharp_ip_input: updating ETHARP table.\n")); LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("etharp_ip_input: updating ETHARP table.\n"));
/* update ARP table, ask to insert entry */ /* update ARP table, ask to insert entry */
update_arp_entry(netif, &(hdr->ip.src), &(hdr->eth.src), ARP_INSERT_FLAG); update_arp_entry(netif, &(hdr->ip.src), &(hdr->eth.src), ARP_INSERT_FLAG);
return NULL; return NULL;
@ -411,7 +411,7 @@ etharp_arp_input(struct netif *netif, struct eth_addr *ethaddr, struct pbuf *p)
/* drop short ARP packets */ /* drop short ARP packets */
if (p->tot_len < sizeof(struct etharp_hdr)) { if (p->tot_len < sizeof(struct etharp_hdr)) {
DEBUGF(ETHARP_DEBUG | DBG_TRACE | 1, ("etharp_arp_input: packet too short (%d/%d)\n", p->tot_len, sizeof(struct etharp_hdr))); LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE | 1, ("etharp_arp_input: packet too short (%d/%d)\n", p->tot_len, sizeof(struct etharp_hdr)));
pbuf_free(p); pbuf_free(p);
return NULL; return NULL;
} }
@ -425,10 +425,10 @@ etharp_arp_input(struct netif *netif, struct eth_addr *ethaddr, struct pbuf *p)
reply. In any case, we time-stamp any existing ARP entry, reply. In any case, we time-stamp any existing ARP entry,
and possiby send out an IP packet that was queued on it. */ and possiby send out an IP packet that was queued on it. */
DEBUGF (ETHARP_DEBUG | DBG_TRACE, ("etharp_arp_input: incoming ARP request\n")); LWIP_DEBUGF (ETHARP_DEBUG | DBG_TRACE, ("etharp_arp_input: incoming ARP request\n"));
/* we are not configured? */ /* we are not configured? */
if (netif->ip_addr.addr == 0) { if (netif->ip_addr.addr == 0) {
DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("etharp_arp_input: we are unconfigured, ARP request ignored.\n")); LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("etharp_arp_input: we are unconfigured, ARP request ignored.\n"));
pbuf_free(p); pbuf_free(p);
return NULL; return NULL;
} }
@ -437,7 +437,7 @@ etharp_arp_input(struct netif *netif, struct eth_addr *ethaddr, struct pbuf *p)
/* ARP request for our address? */ /* ARP request for our address? */
if (ip_addr_cmp(&(hdr->dipaddr), &(netif->ip_addr))) { if (ip_addr_cmp(&(hdr->dipaddr), &(netif->ip_addr))) {
DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("etharp_arp_input: replying to ARP request for our IP address\n")); LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("etharp_arp_input: replying to ARP request for our IP address\n"));
/* re-use pbuf to send ARP reply */ /* re-use pbuf to send ARP reply */
hdr->opcode = htons(ARP_REPLY); hdr->opcode = htons(ARP_REPLY);
@ -461,24 +461,24 @@ etharp_arp_input(struct netif *netif, struct eth_addr *ethaddr, struct pbuf *p)
/* return ARP reply */ /* return ARP reply */
netif->linkoutput(netif, p); netif->linkoutput(netif, p);
} else { } else {
DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("etharp_arp_input: incoming ARP request was not for us.\n")); LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("etharp_arp_input: incoming ARP request was not for us.\n"));
} }
break; break;
case ARP_REPLY: case ARP_REPLY:
/* ARP reply. We insert or update the ARP table. */ /* ARP reply. We insert or update the ARP table. */
DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("etharp_arp_input: incoming ARP reply\n")); LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("etharp_arp_input: incoming ARP reply\n"));
#if (LWIP_DHCP && DHCP_DOES_ARP_CHECK) #if (LWIP_DHCP && DHCP_DOES_ARP_CHECK)
/* DHCP needs to know about ARP replies */ /* DHCP needs to know about ARP replies */
dhcp_arp_reply(netif, &hdr->sipaddr); dhcp_arp_reply(netif, &hdr->sipaddr);
#endif #endif
/* ARP reply directed to us? */ /* ARP reply directed to us? */
if (ip_addr_cmp(&(hdr->dipaddr), &(netif->ip_addr))) { if (ip_addr_cmp(&(hdr->dipaddr), &(netif->ip_addr))) {
DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("etharp_arp_input: incoming ARP reply is for us\n")); LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("etharp_arp_input: incoming ARP reply is for us\n"));
/* update_the ARP cache, ask to insert */ /* update_the ARP cache, ask to insert */
update_arp_entry(netif, &(hdr->sipaddr), &(hdr->shwaddr), ARP_INSERT_FLAG); update_arp_entry(netif, &(hdr->sipaddr), &(hdr->shwaddr), ARP_INSERT_FLAG);
/* ARP reply not directed to us */ /* ARP reply not directed to us */
} else { } else {
DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("etharp_arp_input: incoming ARP reply is not for us\n")); LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("etharp_arp_input: incoming ARP reply is not for us\n"));
/* update the destination address pair */ /* update the destination address pair */
update_arp_entry(netif, &(hdr->sipaddr), &(hdr->shwaddr), 0); update_arp_entry(netif, &(hdr->sipaddr), &(hdr->shwaddr), 0);
/* update the destination address pair */ /* update the destination address pair */
@ -486,7 +486,7 @@ etharp_arp_input(struct netif *netif, struct eth_addr *ethaddr, struct pbuf *p)
} }
break; break;
default: default:
DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("etharp_arp_input: ARP unknown opcode type %d\n", htons(hdr->opcode))); LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("etharp_arp_input: ARP unknown opcode type %d\n", htons(hdr->opcode)));
break; break;
} }
/* free ARP packet */ /* free ARP packet */
@ -528,7 +528,7 @@ etharp_output(struct netif *netif, struct ip_addr *ipaddr, struct pbuf *q)
if (pbuf_header(q, sizeof(struct eth_hdr)) != 0) { if (pbuf_header(q, sizeof(struct eth_hdr)) != 0) {
/* The pbuf_header() call shouldn't fail, and we'll just bail /* The pbuf_header() call shouldn't fail, and we'll just bail
out if it does.. */ out if it does.. */
DEBUGF(ETHARP_DEBUG | DBG_TRACE | 2, ("etharp_output: could not allocate room for header.\n")); LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE | 2, ("etharp_output: could not allocate room for header.\n"));
#ifdef LINK_STATS #ifdef LINK_STATS
++lwip_stats.link.lenerr; ++lwip_stats.link.lenerr;
#endif /* LINK_STATS */ #endif /* LINK_STATS */
@ -660,14 +660,14 @@ err_t etharp_query(struct netif *netif, struct ip_addr *ipaddr, struct pbuf *q)
for (i = 0; i < ARP_TABLE_SIZE; ++i) { for (i = 0; i < ARP_TABLE_SIZE; ++i) {
if (ip_addr_cmp(ipaddr, &arp_table[i].ipaddr)) { if (ip_addr_cmp(ipaddr, &arp_table[i].ipaddr)) {
if (arp_table[i].state == ETHARP_STATE_PENDING) { if (arp_table[i].state == ETHARP_STATE_PENDING) {
DEBUGF(ETHARP_DEBUG | DBG_TRACE | DBG_STATE, ("etharp_query: requested IP already pending as entry %u\n", i)); LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE | DBG_STATE, ("etharp_query: requested IP already pending as entry %u\n", i));
/* break out of for-loop, user may wish to queue a packet on a stable entry */ /* break out of for-loop, user may wish to queue a packet on a stable entry */
/* TODO: we will issue a new ARP request, which should not occur too often */ /* TODO: we will issue a new ARP request, which should not occur too often */
/* we might want to run a faster timer on ARP to limit this */ /* we might want to run a faster timer on ARP to limit this */
break; break;
} }
else if (arp_table[i].state == ETHARP_STATE_STABLE) { else if (arp_table[i].state == ETHARP_STATE_STABLE) {
DEBUGF(ETHARP_DEBUG | DBG_TRACE | DBG_STATE, ("etharp_query: requested IP already stable as entry %u\n", i)); LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE | DBG_STATE, ("etharp_query: requested IP already stable as entry %u\n", i));
/* user may wish to queue a packet on a stable entry, so we proceed without ARP requesting */ /* user may wish to queue a packet on a stable entry, so we proceed without ARP requesting */
/* TODO: even if the ARP entry is stable, we might do an ARP request anyway */ /* TODO: even if the ARP entry is stable, we might do an ARP request anyway */
perform_arp_request = 0; perform_arp_request = 0;
@ -677,16 +677,16 @@ err_t etharp_query(struct netif *netif, struct ip_addr *ipaddr, struct pbuf *q)
} }
/* queried address not yet in ARP table? */ /* queried address not yet in ARP table? */
if (i == ARP_TABLE_SIZE) { if (i == ARP_TABLE_SIZE) {
DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("etharp_query: IP address not found in ARP table\n")); LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("etharp_query: IP address not found in ARP table\n"));
/* find an available entry */ /* find an available entry */
i = find_arp_entry(); i = find_arp_entry();
/* bail out if no ARP entries are available */ /* bail out if no ARP entries are available */
if (i == ARP_TABLE_SIZE) { if (i == ARP_TABLE_SIZE) {
DEBUGF(ETHARP_DEBUG | 2, ("etharp_query: no more ARP entries available.\n")); LWIP_DEBUGF(ETHARP_DEBUG | 2, ("etharp_query: no more ARP entries available.\n"));
return ERR_MEM; return ERR_MEM;
} }
/* we will now recycle entry i */ /* we will now recycle entry i */
DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("etharp_query: created ARP table entry %u.\n", i)); LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("etharp_query: created ARP table entry %u.\n", i));
/* i is available, create ARP entry */ /* i is available, create ARP entry */
ip_addr_set(&arp_table[i].ipaddr, ipaddr); ip_addr_set(&arp_table[i].ipaddr, ipaddr);
arp_table[i].ctime = 0; arp_table[i].ctime = 0;
@ -696,7 +696,7 @@ err_t etharp_query(struct netif *netif, struct ip_addr *ipaddr, struct pbuf *q)
if (arp_table[i].p != NULL) { if (arp_table[i].p != NULL) {
pbuf_free(arp_table[i].p); pbuf_free(arp_table[i].p);
arp_table[i].p = NULL; arp_table[i].p = NULL;
DEBUGF(ETHARP_DEBUG | DBG_TRACE | 3, ("etharp_query: dropped packet on ARP queue. Should not occur.\n")); LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE | 3, ("etharp_query: dropped packet on ARP queue. Should not occur.\n"));
} }
#endif #endif
} }
@ -709,7 +709,7 @@ err_t etharp_query(struct netif *netif, struct ip_addr *ipaddr, struct pbuf *q)
if (arp_table[i].p != NULL) { if (arp_table[i].p != NULL) {
pbuf_free(arp_table[i].p); pbuf_free(arp_table[i].p);
arp_table[i].p = NULL; arp_table[i].p = NULL;
DEBUGF(ETHARP_DEBUG | DBG_TRACE | 3, ("etharp_query: dropped packet on ARP queue. Should not occur.\n")); LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE | 3, ("etharp_query: dropped packet on ARP queue. Should not occur.\n"));
/* fall-through into next if */ /* fall-through into next if */
} }
#endif #endif
@ -721,7 +721,7 @@ err_t etharp_query(struct netif *netif, struct ip_addr *ipaddr, struct pbuf *q)
arp_table[i].p = q; arp_table[i].p = q;
/* pbufs are queued, increase the reference count */ /* pbufs are queued, increase the reference count */
pbuf_ref(q); pbuf_ref(q);
DEBUGF(ETHARP_DEBUG | DBG_TRACE | DBG_STATE, ("etharp_query: queued packet %p on ARP entry %u.\n", (void *)q, i)); LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE | DBG_STATE, ("etharp_query: queued packet %p on ARP entry %u.\n", (void *)q, i));
} }
} }
#endif #endif
@ -733,7 +733,7 @@ err_t etharp_query(struct netif *netif, struct ip_addr *ipaddr, struct pbuf *q)
/* could allocate pbuf? */ /* could allocate pbuf? */
if (p != NULL) { if (p != NULL) {
u8_t j; u8_t j;
DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("etharp_query: sending ARP request.\n")); LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE, ("etharp_query: sending ARP request.\n"));
hdr = p->payload; hdr = p->payload;
hdr->opcode = htons(ARP_REQUEST); hdr->opcode = htons(ARP_REQUEST);
for(j = 0; j < netif->hwaddr_len; ++j) for(j = 0; j < netif->hwaddr_len; ++j)
@ -762,7 +762,7 @@ err_t etharp_query(struct netif *netif, struct ip_addr *ipaddr, struct pbuf *q)
p = NULL; p = NULL;
} else { } else {
result = ERR_MEM; result = ERR_MEM;
DEBUGF(ETHARP_DEBUG | DBG_TRACE | 2, ("etharp_query: could not allocate pbuf for ARP request.\n")); LWIP_DEBUGF(ETHARP_DEBUG | DBG_TRACE | 2, ("etharp_query: could not allocate pbuf for ARP request.\n"));
} }
} }
return result; return result;

View File

@ -119,7 +119,7 @@ slipif_input( struct netif * netif )
++lwip_stats.link.recv; ++lwip_stats.link.recv;
#endif /* LINK_STATS */ #endif /* LINK_STATS */
DEBUGF(SLIP_DEBUG, ("slipif: Got packet\n")); LWIP_DEBUGF(SLIP_DEBUG, ("slipif: Got packet\n"));
return q; return q;
} }
break; break;
@ -138,13 +138,13 @@ slipif_input( struct netif * netif )
default: default:
if (p == NULL) { if (p == NULL) {
DEBUGF(SLIP_DEBUG, ("slipif_input: alloc\n")); LWIP_DEBUGF(SLIP_DEBUG, ("slipif_input: alloc\n"));
p = pbuf_alloc(PBUF_LINK, PBUF_POOL_BUFSIZE, PBUF_POOL); p = pbuf_alloc(PBUF_LINK, PBUF_POOL_BUFSIZE, PBUF_POOL);
#ifdef LINK_STATS #ifdef LINK_STATS
if (p == NULL) { if (p == NULL) {
++lwip_stats.link.drop; ++lwip_stats.link.drop;
DEBUGF(SLIP_DEBUG, ("slipif_input: no new pbuf! (DROP)\n")); LWIP_DEBUGF(SLIP_DEBUG, ("slipif_input: no new pbuf! (DROP)\n"));
} }
#endif /* LINK_STATS */ #endif /* LINK_STATS */
@ -197,7 +197,7 @@ err_t
slipif_init(struct netif *netif) slipif_init(struct netif *netif)
{ {
DEBUGF(SLIP_DEBUG, ("slipif_init: netif->num=%x\n", (int)netif->num)); LWIP_DEBUGF(SLIP_DEBUG, ("slipif_init: netif->num=%x\n", (int)netif->num));
netif->name[0] = 's'; netif->name[0] = 's';
netif->name[1] = 'l'; netif->name[1] = 'l';