mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-10-04 05:39:53 +00:00
Replaced all tabs with two spaces (regardless of indentation is correct).
This commit is contained in:
parent
829744dfe6
commit
df99ce9d98
@ -165,10 +165,10 @@ netbuf_copy_partial(struct netbuf *buf, void *dataptr, u16_t len, u16_t offset)
|
|||||||
offset -= p->len;
|
offset -= p->len;
|
||||||
} else {
|
} else {
|
||||||
for(i = offset; i < p->len; ++i) {
|
for(i = offset; i < p->len; ++i) {
|
||||||
((char *)dataptr)[left] = ((char *)p->payload)[i];
|
((char *)dataptr)[left] = ((char *)p->payload)[i];
|
||||||
if (++left >= len) {
|
if (++left >= len) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
offset = 0;
|
offset = 0;
|
||||||
}
|
}
|
||||||
@ -257,9 +257,9 @@ netconn_delete(struct netconn *conn)
|
|||||||
if (conn->recvmbox != SYS_MBOX_NULL) {
|
if (conn->recvmbox != SYS_MBOX_NULL) {
|
||||||
while (sys_arch_mbox_fetch(conn->recvmbox, &mem, 1) != SYS_ARCH_TIMEOUT) {
|
while (sys_arch_mbox_fetch(conn->recvmbox, &mem, 1) != SYS_ARCH_TIMEOUT) {
|
||||||
if (conn->type == NETCONN_TCP) {
|
if (conn->type == NETCONN_TCP) {
|
||||||
pbuf_free((struct pbuf *)mem);
|
pbuf_free((struct pbuf *)mem);
|
||||||
} else {
|
} else {
|
||||||
netbuf_delete((struct netbuf *)mem);
|
netbuf_delete((struct netbuf *)mem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sys_mbox_free(conn->recvmbox);
|
sys_mbox_free(conn->recvmbox);
|
||||||
@ -295,14 +295,14 @@ netconn_type(struct netconn *conn)
|
|||||||
/*-----------------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------------*/
|
||||||
err_t
|
err_t
|
||||||
netconn_peer(struct netconn *conn, struct ip_addr *addr,
|
netconn_peer(struct netconn *conn, struct ip_addr *addr,
|
||||||
u16_t *port)
|
u16_t *port)
|
||||||
{
|
{
|
||||||
switch (conn->type) {
|
switch (conn->type) {
|
||||||
case NETCONN_UDPLITE:
|
case NETCONN_UDPLITE:
|
||||||
case NETCONN_UDPNOCHKSUM:
|
case NETCONN_UDPNOCHKSUM:
|
||||||
case NETCONN_UDP:
|
case NETCONN_UDP:
|
||||||
if (conn->pcb.udp == NULL ||
|
if (conn->pcb.udp == NULL ||
|
||||||
((conn->pcb.udp->flags & UDP_FLAGS_CONNECTED) == 0))
|
((conn->pcb.udp->flags & UDP_FLAGS_CONNECTED) == 0))
|
||||||
return ERR_CONN;
|
return ERR_CONN;
|
||||||
*addr = (conn->pcb.udp->remote_ip);
|
*addr = (conn->pcb.udp->remote_ip);
|
||||||
*port = conn->pcb.udp->remote_port;
|
*port = conn->pcb.udp->remote_port;
|
||||||
@ -319,7 +319,7 @@ netconn_peer(struct netconn *conn, struct ip_addr *addr,
|
|||||||
/*-----------------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------------*/
|
||||||
err_t
|
err_t
|
||||||
netconn_addr(struct netconn *conn, struct ip_addr **addr,
|
netconn_addr(struct netconn *conn, struct ip_addr **addr,
|
||||||
u16_t *port)
|
u16_t *port)
|
||||||
{
|
{
|
||||||
switch (conn->type) {
|
switch (conn->type) {
|
||||||
case NETCONN_UDPLITE:
|
case NETCONN_UDPLITE:
|
||||||
@ -338,7 +338,7 @@ netconn_addr(struct netconn *conn, struct ip_addr **addr,
|
|||||||
/*-----------------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------------*/
|
||||||
err_t
|
err_t
|
||||||
netconn_bind(struct netconn *conn, struct ip_addr *addr,
|
netconn_bind(struct netconn *conn, struct ip_addr *addr,
|
||||||
u16_t port)
|
u16_t port)
|
||||||
{
|
{
|
||||||
struct api_msg *msg;
|
struct api_msg *msg;
|
||||||
|
|
||||||
@ -369,7 +369,7 @@ netconn_bind(struct netconn *conn, struct ip_addr *addr,
|
|||||||
/*-----------------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------------*/
|
||||||
err_t
|
err_t
|
||||||
netconn_connect(struct netconn *conn, struct ip_addr *addr,
|
netconn_connect(struct netconn *conn, struct ip_addr *addr,
|
||||||
u16_t port)
|
u16_t port)
|
||||||
{
|
{
|
||||||
struct api_msg *msg;
|
struct api_msg *msg;
|
||||||
|
|
||||||
@ -543,7 +543,7 @@ netconn_recv(struct netconn *conn)
|
|||||||
memp_freep(MEMP_API_MSG, msg);
|
memp_freep(MEMP_API_MSG, msg);
|
||||||
} else {
|
} else {
|
||||||
sys_mbox_fetch(conn->recvmbox, (void **)&buf);
|
sys_mbox_fetch(conn->recvmbox, (void **)&buf);
|
||||||
conn->recv_avail -= buf->p->tot_len;
|
conn->recv_avail -= buf->p->tot_len;
|
||||||
/* Register event with callback */
|
/* Register event with callback */
|
||||||
if (conn->callback)
|
if (conn->callback)
|
||||||
(*conn->callback)(conn, NETCONN_EVT_RCVMINUS, buf->p->tot_len);
|
(*conn->callback)(conn, NETCONN_EVT_RCVMINUS, buf->p->tot_len);
|
||||||
@ -621,17 +621,17 @@ netconn_write(struct netconn *conn, void *dataptr, u16_t size, u8_t copy)
|
|||||||
|
|
||||||
if (conn->type == NETCONN_TCP) {
|
if (conn->type == NETCONN_TCP) {
|
||||||
if (tcp_sndbuf(conn->pcb.tcp) == 0) {
|
if (tcp_sndbuf(conn->pcb.tcp) == 0) {
|
||||||
sys_sem_wait(conn->sem);
|
sys_sem_wait(conn->sem);
|
||||||
if (conn->err != ERR_OK) {
|
if (conn->err != ERR_OK) {
|
||||||
goto ret;
|
goto ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (size > tcp_sndbuf(conn->pcb.tcp)) {
|
if (size > tcp_sndbuf(conn->pcb.tcp)) {
|
||||||
/* We cannot send more than one send buffer's worth of data at a
|
/* We cannot send more than one send buffer's worth of data at a
|
||||||
time. */
|
time. */
|
||||||
len = tcp_sndbuf(conn->pcb.tcp);
|
len = tcp_sndbuf(conn->pcb.tcp);
|
||||||
} else {
|
} else {
|
||||||
len = size;
|
len = size;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
len = size;
|
len = size;
|
||||||
|
@ -40,7 +40,7 @@
|
|||||||
#if LWIP_UDP
|
#if LWIP_UDP
|
||||||
static void
|
static void
|
||||||
recv_udp(void *arg, struct udp_pcb *pcb, struct pbuf *p,
|
recv_udp(void *arg, struct udp_pcb *pcb, struct pbuf *p,
|
||||||
struct ip_addr *addr, u16_t port)
|
struct ip_addr *addr, u16_t port)
|
||||||
{
|
{
|
||||||
struct netbuf *buf;
|
struct netbuf *buf;
|
||||||
struct netconn *conn;
|
struct netconn *conn;
|
||||||
@ -63,7 +63,7 @@ recv_udp(void *arg, struct udp_pcb *pcb, struct pbuf *p,
|
|||||||
buf->fromport = port;
|
buf->fromport = port;
|
||||||
}
|
}
|
||||||
|
|
||||||
conn->recv_avail += p->tot_len;
|
conn->recv_avail += p->tot_len;
|
||||||
/* Register event with callback */
|
/* Register event with callback */
|
||||||
if (conn->callback)
|
if (conn->callback)
|
||||||
(*conn->callback)(conn, NETCONN_EVT_RCVPLUS, p->tot_len);
|
(*conn->callback)(conn, NETCONN_EVT_RCVPLUS, p->tot_len);
|
||||||
@ -87,7 +87,7 @@ recv_tcp(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (conn->recvmbox != SYS_MBOX_NULL) {
|
if (conn->recvmbox != SYS_MBOX_NULL) {
|
||||||
|
|
||||||
conn->err = err;
|
conn->err = err;
|
||||||
if (p != NULL) {
|
if (p != NULL) {
|
||||||
len = p->tot_len;
|
len = p->tot_len;
|
||||||
@ -258,18 +258,18 @@ do_delconn(struct api_msg_msg *msg)
|
|||||||
#if LWIP_TCP
|
#if LWIP_TCP
|
||||||
case NETCONN_TCP:
|
case NETCONN_TCP:
|
||||||
if (msg->conn->pcb.tcp->state == LISTEN) {
|
if (msg->conn->pcb.tcp->state == LISTEN) {
|
||||||
tcp_arg(msg->conn->pcb.tcp, NULL);
|
tcp_arg(msg->conn->pcb.tcp, NULL);
|
||||||
tcp_accept(msg->conn->pcb.tcp, NULL);
|
tcp_accept(msg->conn->pcb.tcp, NULL);
|
||||||
tcp_close(msg->conn->pcb.tcp);
|
tcp_close(msg->conn->pcb.tcp);
|
||||||
} else {
|
} else {
|
||||||
tcp_arg(msg->conn->pcb.tcp, NULL);
|
tcp_arg(msg->conn->pcb.tcp, NULL);
|
||||||
tcp_sent(msg->conn->pcb.tcp, NULL);
|
tcp_sent(msg->conn->pcb.tcp, NULL);
|
||||||
tcp_recv(msg->conn->pcb.tcp, NULL);
|
tcp_recv(msg->conn->pcb.tcp, NULL);
|
||||||
tcp_poll(msg->conn->pcb.tcp, NULL, 0);
|
tcp_poll(msg->conn->pcb.tcp, NULL, 0);
|
||||||
tcp_err(msg->conn->pcb.tcp, NULL);
|
tcp_err(msg->conn->pcb.tcp, NULL);
|
||||||
if (tcp_close(msg->conn->pcb.tcp) != ERR_OK) {
|
if (tcp_close(msg->conn->pcb.tcp) != ERR_OK) {
|
||||||
tcp_abort(msg->conn->pcb.tcp);
|
tcp_abort(msg->conn->pcb.tcp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
default:
|
default:
|
||||||
@ -331,7 +331,7 @@ do_bind(struct api_msg_msg *msg)
|
|||||||
#if LWIP_TCP
|
#if LWIP_TCP
|
||||||
case NETCONN_TCP:
|
case NETCONN_TCP:
|
||||||
msg->conn->err = tcp_bind(msg->conn->pcb.tcp,
|
msg->conn->err = tcp_bind(msg->conn->pcb.tcp,
|
||||||
msg->msg.bc.ipaddr, msg->msg.bc.port);
|
msg->msg.bc.ipaddr, msg->msg.bc.port);
|
||||||
#endif /* LWIP_TCP */
|
#endif /* LWIP_TCP */
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@ -369,9 +369,9 @@ do_connect(struct api_msg_msg *msg)
|
|||||||
case NETCONN_UDPLITE:
|
case NETCONN_UDPLITE:
|
||||||
msg->conn->pcb.udp = udp_new();
|
msg->conn->pcb.udp = udp_new();
|
||||||
if (msg->conn->pcb.udp == NULL) {
|
if (msg->conn->pcb.udp == NULL) {
|
||||||
msg->conn->err = ERR_MEM;
|
msg->conn->err = ERR_MEM;
|
||||||
sys_mbox_post(msg->conn->mbox, NULL);
|
sys_mbox_post(msg->conn->mbox, NULL);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
udp_setflags(msg->conn->pcb.udp, UDP_FLAGS_UDPLITE);
|
udp_setflags(msg->conn->pcb.udp, UDP_FLAGS_UDPLITE);
|
||||||
udp_recv(msg->conn->pcb.udp, recv_udp, msg->conn);
|
udp_recv(msg->conn->pcb.udp, recv_udp, msg->conn);
|
||||||
@ -379,9 +379,9 @@ do_connect(struct api_msg_msg *msg)
|
|||||||
case NETCONN_UDPNOCHKSUM:
|
case NETCONN_UDPNOCHKSUM:
|
||||||
msg->conn->pcb.udp = udp_new();
|
msg->conn->pcb.udp = udp_new();
|
||||||
if (msg->conn->pcb.udp == NULL) {
|
if (msg->conn->pcb.udp == NULL) {
|
||||||
msg->conn->err = ERR_MEM;
|
msg->conn->err = ERR_MEM;
|
||||||
sys_mbox_post(msg->conn->mbox, NULL);
|
sys_mbox_post(msg->conn->mbox, NULL);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
udp_setflags(msg->conn->pcb.udp, UDP_FLAGS_NOCHKSUM);
|
udp_setflags(msg->conn->pcb.udp, UDP_FLAGS_NOCHKSUM);
|
||||||
udp_recv(msg->conn->pcb.udp, recv_udp, msg->conn);
|
udp_recv(msg->conn->pcb.udp, recv_udp, msg->conn);
|
||||||
@ -389,9 +389,9 @@ do_connect(struct api_msg_msg *msg)
|
|||||||
case NETCONN_UDP:
|
case NETCONN_UDP:
|
||||||
msg->conn->pcb.udp = udp_new();
|
msg->conn->pcb.udp = udp_new();
|
||||||
if (msg->conn->pcb.udp == NULL) {
|
if (msg->conn->pcb.udp == NULL) {
|
||||||
msg->conn->err = ERR_MEM;
|
msg->conn->err = ERR_MEM;
|
||||||
sys_mbox_post(msg->conn->mbox, NULL);
|
sys_mbox_post(msg->conn->mbox, NULL);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
udp_recv(msg->conn->pcb.udp, recv_udp, msg->conn);
|
udp_recv(msg->conn->pcb.udp, recv_udp, msg->conn);
|
||||||
break;
|
break;
|
||||||
@ -400,9 +400,9 @@ do_connect(struct api_msg_msg *msg)
|
|||||||
case NETCONN_TCP:
|
case NETCONN_TCP:
|
||||||
msg->conn->pcb.tcp = tcp_new();
|
msg->conn->pcb.tcp = tcp_new();
|
||||||
if (msg->conn->pcb.tcp == NULL) {
|
if (msg->conn->pcb.tcp == NULL) {
|
||||||
msg->conn->err = ERR_MEM;
|
msg->conn->err = ERR_MEM;
|
||||||
sys_mbox_post(msg->conn->mbox, NULL);
|
sys_mbox_post(msg->conn->mbox, NULL);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
default:
|
default:
|
||||||
@ -425,7 +425,7 @@ do_connect(struct api_msg_msg *msg)
|
|||||||
/* tcp_arg(msg->conn->pcb.tcp, msg->conn);*/
|
/* tcp_arg(msg->conn->pcb.tcp, msg->conn);*/
|
||||||
setup_tcp(msg->conn);
|
setup_tcp(msg->conn);
|
||||||
tcp_connect(msg->conn->pcb.tcp, msg->msg.bc.ipaddr, msg->msg.bc.port,
|
tcp_connect(msg->conn->pcb.tcp, msg->msg.bc.ipaddr, msg->msg.bc.port,
|
||||||
do_connected);
|
do_connected);
|
||||||
/*tcp_output(msg->conn->pcb.tcp);*/
|
/*tcp_output(msg->conn->pcb.tcp);*/
|
||||||
#endif
|
#endif
|
||||||
default:
|
default:
|
||||||
@ -472,17 +472,17 @@ do_listen(struct api_msg_msg *msg)
|
|||||||
case NETCONN_TCP:
|
case NETCONN_TCP:
|
||||||
msg->conn->pcb.tcp = tcp_listen(msg->conn->pcb.tcp);
|
msg->conn->pcb.tcp = tcp_listen(msg->conn->pcb.tcp);
|
||||||
if (msg->conn->pcb.tcp == NULL) {
|
if (msg->conn->pcb.tcp == NULL) {
|
||||||
msg->conn->err = ERR_MEM;
|
msg->conn->err = ERR_MEM;
|
||||||
} else {
|
} else {
|
||||||
if (msg->conn->acceptmbox == SYS_MBOX_NULL) {
|
if (msg->conn->acceptmbox == SYS_MBOX_NULL) {
|
||||||
msg->conn->acceptmbox = sys_mbox_new();
|
msg->conn->acceptmbox = sys_mbox_new();
|
||||||
if (msg->conn->acceptmbox == SYS_MBOX_NULL) {
|
if (msg->conn->acceptmbox == SYS_MBOX_NULL) {
|
||||||
msg->conn->err = ERR_MEM;
|
msg->conn->err = ERR_MEM;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tcp_arg(msg->conn->pcb.tcp, msg->conn);
|
tcp_arg(msg->conn->pcb.tcp, msg->conn);
|
||||||
tcp_accept(msg->conn->pcb.tcp, accept_function);
|
tcp_accept(msg->conn->pcb.tcp, accept_function);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
default:
|
default:
|
||||||
@ -549,7 +549,7 @@ do_recv(struct api_msg_msg *msg)
|
|||||||
static void
|
static void
|
||||||
do_write(struct api_msg_msg *msg)
|
do_write(struct api_msg_msg *msg)
|
||||||
{
|
{
|
||||||
#if LWIP_TCP
|
#if LWIP_TCP
|
||||||
err_t err;
|
err_t err;
|
||||||
#endif
|
#endif
|
||||||
if (msg->conn->pcb.tcp != NULL) {
|
if (msg->conn->pcb.tcp != NULL) {
|
||||||
@ -568,11 +568,11 @@ do_write(struct api_msg_msg *msg)
|
|||||||
err = tcp_write(msg->conn->pcb.tcp, msg->msg.w.dataptr,
|
err = tcp_write(msg->conn->pcb.tcp, msg->msg.w.dataptr,
|
||||||
msg->msg.w.len, msg->msg.w.copy);
|
msg->msg.w.len, msg->msg.w.copy);
|
||||||
/* This is the Nagle algorithm: inhibit the sending of new TCP
|
/* This is the Nagle algorithm: inhibit the sending of new TCP
|
||||||
segments when new outgoing data arrives from the user if any
|
segments when new outgoing data arrives from the user if any
|
||||||
previously transmitted data on the connection remains
|
previously transmitted data on the connection remains
|
||||||
unacknowledged. */
|
unacknowledged. */
|
||||||
if (err == ERR_OK && msg->conn->pcb.tcp->unacked == NULL) {
|
if (err == ERR_OK && msg->conn->pcb.tcp->unacked == NULL) {
|
||||||
tcp_output(msg->conn->pcb.tcp);
|
tcp_output(msg->conn->pcb.tcp);
|
||||||
}
|
}
|
||||||
msg->conn->err = err;
|
msg->conn->err = err;
|
||||||
if (msg->conn->callback)
|
if (msg->conn->callback)
|
||||||
@ -609,7 +609,7 @@ do_close(struct api_msg_msg *msg)
|
|||||||
#if LWIP_TCP
|
#if LWIP_TCP
|
||||||
case NETCONN_TCP:
|
case NETCONN_TCP:
|
||||||
if (msg->conn->pcb.tcp->state == LISTEN) {
|
if (msg->conn->pcb.tcp->state == LISTEN) {
|
||||||
err = tcp_close(msg->conn->pcb.tcp);
|
err = tcp_close(msg->conn->pcb.tcp);
|
||||||
}
|
}
|
||||||
msg->conn->err = err;
|
msg->conn->err = err;
|
||||||
#endif
|
#endif
|
||||||
|
@ -35,16 +35,16 @@
|
|||||||
#ifdef LWIP_DEBUG
|
#ifdef LWIP_DEBUG
|
||||||
|
|
||||||
static char *err_strerr[] = {"Ok.",
|
static char *err_strerr[] = {"Ok.",
|
||||||
"Out of memory error.",
|
"Out of memory error.",
|
||||||
"Buffer error.",
|
"Buffer error.",
|
||||||
"Connection aborted.",
|
"Connection aborted.",
|
||||||
"Connection reset.",
|
"Connection reset.",
|
||||||
"Connection closed.",
|
"Connection closed.",
|
||||||
"Not connected.",
|
"Not connected.",
|
||||||
"Illegal value.",
|
"Illegal value.",
|
||||||
"Illegal argument.",
|
"Illegal argument.",
|
||||||
"Routing problem.",
|
"Routing problem.",
|
||||||
"Address in use."
|
"Address in use."
|
||||||
};
|
};
|
||||||
|
|
||||||
/*-----------------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------------*/
|
||||||
|
@ -47,7 +47,7 @@ struct lwip_socket {
|
|||||||
u16_t lastoffset;
|
u16_t lastoffset;
|
||||||
u16_t rcvevent;
|
u16_t rcvevent;
|
||||||
u16_t sendevent;
|
u16_t sendevent;
|
||||||
u16_t flags;
|
u16_t flags;
|
||||||
int err;
|
int err;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -71,22 +71,22 @@ static void
|
|||||||
event_callback(struct netconn *conn, enum netconn_evt evt, u16_t len);
|
event_callback(struct netconn *conn, enum netconn_evt evt, u16_t len);
|
||||||
|
|
||||||
static int err_to_errno_table[11] = {
|
static int err_to_errno_table[11] = {
|
||||||
0, /* ERR_OK 0 No error, everything OK. */
|
0, /* ERR_OK 0 No error, everything OK. */
|
||||||
ENOMEM, /* ERR_MEM -1 Out of memory error. */
|
ENOMEM, /* ERR_MEM -1 Out of memory error. */
|
||||||
ENOBUFS, /* ERR_BUF -2 Buffer error. */
|
ENOBUFS, /* ERR_BUF -2 Buffer error. */
|
||||||
ECONNABORTED, /* ERR_ABRT -3 Connection aborted. */
|
ECONNABORTED, /* ERR_ABRT -3 Connection aborted. */
|
||||||
ECONNRESET, /* ERR_RST -4 Connection reset. */
|
ECONNRESET, /* ERR_RST -4 Connection reset. */
|
||||||
ESHUTDOWN, /* ERR_CLSD -5 Connection closed. */
|
ESHUTDOWN, /* ERR_CLSD -5 Connection closed. */
|
||||||
ENOTCONN, /* ERR_CONN -6 Not connected. */
|
ENOTCONN, /* ERR_CONN -6 Not connected. */
|
||||||
EINVAL, /* ERR_VAL -7 Illegal value. */
|
EINVAL, /* ERR_VAL -7 Illegal value. */
|
||||||
EIO, /* ERR_ARG -8 Illegal argument. */
|
EIO, /* ERR_ARG -8 Illegal argument. */
|
||||||
EHOSTUNREACH, /* ERR_RTE -9 Routing problem. */
|
EHOSTUNREACH, /* ERR_RTE -9 Routing problem. */
|
||||||
EADDRINUSE /* ERR_USE -10 Address in use. */
|
EADDRINUSE /* ERR_USE -10 Address in use. */
|
||||||
};
|
};
|
||||||
|
|
||||||
#define err_to_errno(err) \
|
#define err_to_errno(err) \
|
||||||
((err) < (sizeof(err_to_errno_table)/sizeof(int))) ? \
|
((err) < (sizeof(err_to_errno_table)/sizeof(int))) ? \
|
||||||
err_to_errno_table[-(err)] : EIO
|
err_to_errno_table[-(err)] : EIO
|
||||||
|
|
||||||
#ifdef ERRNO
|
#ifdef ERRNO
|
||||||
#define set_errno(err) errno = (err)
|
#define set_errno(err) errno = (err)
|
||||||
@ -95,8 +95,8 @@ static int err_to_errno_table[11] = {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define sock_set_errno(sk, e) do { \
|
#define sock_set_errno(sk, e) do { \
|
||||||
sk->err = (e); \
|
sk->err = (e); \
|
||||||
set_errno(sk->err); \
|
set_errno(sk->err); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
/*-----------------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------------*/
|
||||||
@ -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));
|
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));
|
DEBUGF(SOCKETS_DEBUG, ("get_socket(%d): not active\n", s));
|
||||||
set_errno(EBADF);
|
set_errno(EBADF);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -186,8 +186,8 @@ lwip_accept(int s, struct sockaddr *addr, socklen_t *addrlen)
|
|||||||
newsock = alloc_socket(newconn);
|
newsock = alloc_socket(newconn);
|
||||||
if (newsock == -1) {
|
if (newsock == -1) {
|
||||||
netconn_delete(newconn);
|
netconn_delete(newconn);
|
||||||
sock_set_errno(sock, ENOBUFS);
|
sock_set_errno(sock, ENOBUFS);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
newconn->callback = event_callback;
|
newconn->callback = event_callback;
|
||||||
sock = get_socket(newsock);
|
sock = get_socket(newsock);
|
||||||
@ -232,8 +232,8 @@ lwip_bind(int s, struct sockaddr *name, socklen_t namelen)
|
|||||||
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));
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -284,27 +284,27 @@ 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));
|
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;
|
||||||
|
|
||||||
remote_addr.addr = ((struct sockaddr_in *)name)->sin_addr.s_addr;
|
remote_addr.addr = ((struct sockaddr_in *)name)->sin_addr.s_addr;
|
||||||
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));
|
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)));
|
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));
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -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));
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -339,7 +339,7 @@ lwip_listen(int s, int backlog)
|
|||||||
/*-----------------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------------*/
|
||||||
int
|
int
|
||||||
lwip_recvfrom(int s, void *mem, int len, unsigned int flags,
|
lwip_recvfrom(int s, void *mem, int len, unsigned int flags,
|
||||||
struct sockaddr *from, socklen_t *fromlen)
|
struct sockaddr *from, socklen_t *fromlen)
|
||||||
{
|
{
|
||||||
struct lwip_socket *sock;
|
struct lwip_socket *sock;
|
||||||
struct netbuf *buf;
|
struct netbuf *buf;
|
||||||
@ -360,7 +360,7 @@ lwip_recvfrom(int s, void *mem, int len, unsigned int flags,
|
|||||||
} else {
|
} else {
|
||||||
/* If this is non-blocking call, then check first */
|
/* If this is non-blocking call, then check first */
|
||||||
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));
|
DEBUGF(SOCKETS_DEBUG, ("lwip_recvfrom(%d): returning EWOULDBLOCK\n", s));
|
||||||
sock_set_errno(sock, EWOULDBLOCK);
|
sock_set_errno(sock, EWOULDBLOCK);
|
||||||
@ -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));
|
DEBUGF(SOCKETS_DEBUG, ("lwip_send(%d) ENOBUFS\n", s));
|
||||||
sock_set_errno(sock, ENOBUFS);
|
sock_set_errno(sock, ENOBUFS);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -500,8 +500,8 @@ 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));
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -543,9 +543,9 @@ lwip_sendto(int s, void *data, int size, unsigned int flags,
|
|||||||
/* reset the remote address and port number
|
/* reset the remote address and port number
|
||||||
of the connection */
|
of the connection */
|
||||||
if (connected)
|
if (connected)
|
||||||
netconn_connect(sock->conn, &addr, port);
|
netconn_connect(sock->conn, &addr, port);
|
||||||
else
|
else
|
||||||
netconn_disconnect(sock->conn);
|
netconn_disconnect(sock->conn);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
/*-----------------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------------*/
|
||||||
@ -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));
|
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));
|
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));
|
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"));
|
DEBUGF(SOCKETS_DEBUG, ("-1 / ENOBUFS (could not create netconn)\n"));
|
||||||
set_errno(ENOBUFS);
|
set_errno(ENOBUFS);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -581,8 +581,8 @@ lwip_socket(int domain, int type, int protocol)
|
|||||||
|
|
||||||
if (i == -1) {
|
if (i == -1) {
|
||||||
netconn_delete(conn);
|
netconn_delete(conn);
|
||||||
set_errno(ENOBUFS);
|
set_errno(ENOBUFS);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
conn->socket = i;
|
conn->socket = i;
|
||||||
DEBUGF(SOCKETS_DEBUG, ("%d\n", i));
|
DEBUGF(SOCKETS_DEBUG, ("%d\n", 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));
|
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));
|
DEBUGF(SOCKETS_DEBUG, ("lwip_selscan: fd=%d ready for writing\n", i));
|
||||||
nready++;
|
nready++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -655,7 +655,7 @@ 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));
|
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 +697,8 @@ 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"));
|
DEBUGF(SOCKETS_DEBUG, ("lwip_select: no timeout, returning 0\n"));
|
||||||
set_errno(0);
|
set_errno(0);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -748,8 +748,8 @@ 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"));
|
DEBUGF(SOCKETS_DEBUG, ("lwip_select: timeout expired\n"));
|
||||||
set_errno(0);
|
set_errno(0);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -778,8 +778,8 @@ 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));
|
DEBUGF(SOCKETS_DEBUG, ("lwip_select: nready=%d\n", nready));
|
||||||
set_errno(0);
|
set_errno(0);
|
||||||
return nready;
|
return nready;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -877,7 +877,7 @@ 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));
|
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 */
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -953,98 +953,98 @@ int lwip_getsockname (int s, struct sockaddr *name, socklen_t *namelen)
|
|||||||
|
|
||||||
int lwip_getsockopt (int s, int level, int optname, void *optval, socklen_t *optlen)
|
int lwip_getsockopt (int s, int level, int optname, void *optval, socklen_t *optlen)
|
||||||
{
|
{
|
||||||
int err = ENOSYS;
|
int err = ENOSYS;
|
||||||
struct lwip_socket *sock = get_socket(s);
|
struct lwip_socket *sock = get_socket(s);
|
||||||
|
|
||||||
if (!sock) {
|
if (!sock) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (level == SOL_SOCKET) {
|
if (level == SOL_SOCKET) {
|
||||||
switch (optname) {
|
switch (optname) {
|
||||||
case SO_ERROR:
|
case SO_ERROR:
|
||||||
if (!optval || !optlen || (*optlen != sizeof(int))) {
|
if (!optval || !optlen || (*optlen != sizeof(int))) {
|
||||||
err = EINVAL;
|
err = EINVAL;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
*(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));
|
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));
|
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));
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
int lwip_setsockopt (int s, int level, int optname, const void *optval, socklen_t optlen)
|
int lwip_setsockopt (int s, int level, int optname, const void *optval, socklen_t optlen)
|
||||||
{
|
{
|
||||||
struct lwip_socket *sock = get_socket(s);
|
struct lwip_socket *sock = get_socket(s);
|
||||||
int err = ENOSYS;
|
int err = ENOSYS;
|
||||||
|
|
||||||
if (!sock) {
|
if (!sock) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
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));
|
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));
|
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));
|
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);
|
||||||
return err ? -1 : 0;
|
return err ? -1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int lwip_ioctl(int s, long cmd, void *argp)
|
int lwip_ioctl(int s, long cmd, void *argp)
|
||||||
{
|
{
|
||||||
struct lwip_socket *sock = get_socket(s);
|
struct lwip_socket *sock = get_socket(s);
|
||||||
|
|
||||||
if (!sock) {
|
if (!sock) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (cmd) {
|
switch (cmd) {
|
||||||
case FIONREAD:
|
case FIONREAD:
|
||||||
if (!argp) {
|
if (!argp) {
|
||||||
sock_set_errno(sock, EINVAL);
|
sock_set_errno(sock, EINVAL);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
*((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)));
|
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;
|
||||||
|
|
||||||
case FIONBIO:
|
case FIONBIO:
|
||||||
if (argp && *(u32_t*)argp)
|
if (argp && *(u32_t*)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)));
|
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));
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,9 +58,9 @@ tcpip_tcp_timer(void *arg)
|
|||||||
|
|
||||||
tcp_tmr();
|
tcp_tmr();
|
||||||
if (tcp_active_pcbs || tcp_tw_pcbs) {
|
if (tcp_active_pcbs || tcp_tw_pcbs) {
|
||||||
sys_timeout(TCP_TMR_INTERVAL, tcpip_tcp_timer, NULL);
|
sys_timeout(TCP_TMR_INTERVAL, tcpip_tcp_timer, NULL);
|
||||||
} else {
|
} else {
|
||||||
tcpip_tcp_timer_active = 0;
|
tcpip_tcp_timer_active = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,8 +68,8 @@ void
|
|||||||
tcp_timer_needed(void)
|
tcp_timer_needed(void)
|
||||||
{
|
{
|
||||||
if (!tcpip_tcp_timer_active && (tcp_active_pcbs || tcp_tw_pcbs)) {
|
if (!tcpip_tcp_timer_active && (tcp_active_pcbs || tcp_tw_pcbs)) {
|
||||||
tcpip_tcp_timer_active = 1;
|
tcpip_tcp_timer_active = 1;
|
||||||
sys_timeout(TCP_TMR_INTERVAL, tcpip_tcp_timer, NULL);
|
sys_timeout(TCP_TMR_INTERVAL, tcpip_tcp_timer, NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif /* LWIP_TCP */
|
#endif /* LWIP_TCP */
|
||||||
|
@ -452,7 +452,7 @@ static void dhcp_handle_ack(struct netif *netif)
|
|||||||
/* boot file name */
|
/* boot file name */
|
||||||
if (dhcp->msg_in->file[0]) {
|
if (dhcp->msg_in->file[0]) {
|
||||||
dhcp->boot_file_name = mem_malloc(strlen(dhcp->msg_in->file) + 1);
|
dhcp->boot_file_name = mem_malloc(strlen(dhcp->msg_in->file) + 1);
|
||||||
strcpy(dhcp->boot_file_name, dhcp->msg_in->file);
|
strcpy(dhcp->boot_file_name, dhcp->msg_in->file);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -83,8 +83,8 @@ lwip_chksum(void *dataptr, int len)
|
|||||||
/*-----------------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------------*/
|
||||||
u16_t
|
u16_t
|
||||||
inet_chksum_pseudo(struct pbuf *p,
|
inet_chksum_pseudo(struct pbuf *p,
|
||||||
struct ip_addr *src, struct ip_addr *dest,
|
struct ip_addr *src, struct ip_addr *dest,
|
||||||
u8_t proto, u16_t proto_len)
|
u8_t proto, u16_t proto_len)
|
||||||
{
|
{
|
||||||
u32_t acc;
|
u32_t acc;
|
||||||
struct pbuf *q;
|
struct pbuf *q;
|
||||||
@ -291,30 +291,30 @@ inet_chksum_pbuf(struct pbuf *p)
|
|||||||
*/
|
*/
|
||||||
u8_t *inet_ntoa(u32_t addr)
|
u8_t *inet_ntoa(u32_t addr)
|
||||||
{
|
{
|
||||||
static u8_t str[16];
|
static u8_t str[16];
|
||||||
u8_t inv[3];
|
u8_t inv[3];
|
||||||
u8_t *rp;
|
u8_t *rp;
|
||||||
u8_t *ap;
|
u8_t *ap;
|
||||||
u8_t rem;
|
u8_t rem;
|
||||||
u8_t n;
|
u8_t n;
|
||||||
u8_t i;
|
u8_t i;
|
||||||
|
|
||||||
rp = str;
|
rp = str;
|
||||||
ap = (u8_t *)&addr;
|
ap = (u8_t *)&addr;
|
||||||
for(n = 0; n < 4; n++) {
|
for(n = 0; n < 4; n++) {
|
||||||
i = 0;
|
i = 0;
|
||||||
do {
|
do {
|
||||||
rem = *ap % (u8_t)10;
|
rem = *ap % (u8_t)10;
|
||||||
*ap /= (u8_t)10;
|
*ap /= (u8_t)10;
|
||||||
inv[i++] = '0' + rem;
|
inv[i++] = '0' + rem;
|
||||||
} while(*ap);
|
} while(*ap);
|
||||||
while(i--)
|
while(i--)
|
||||||
*rp++ = inv[i];
|
*rp++ = inv[i];
|
||||||
*rp++ = '.';
|
*rp++ = '.';
|
||||||
ap++;
|
ap++;
|
||||||
}
|
}
|
||||||
*--rp = 0;
|
*--rp = 0;
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*-----------------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------------*/
|
||||||
|
@ -82,8 +82,8 @@ chksum(void *dataptr, u16_t len)
|
|||||||
/*-----------------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------------*/
|
||||||
u16_t
|
u16_t
|
||||||
inet_chksum_pseudo(struct pbuf *p,
|
inet_chksum_pseudo(struct pbuf *p,
|
||||||
struct ip_addr *src, struct ip_addr *dest,
|
struct ip_addr *src, struct ip_addr *dest,
|
||||||
u8_t proto, u32_t proto_len)
|
u8_t proto, u32_t proto_len)
|
||||||
{
|
{
|
||||||
u32_t acc;
|
u32_t acc;
|
||||||
struct pbuf *q;
|
struct pbuf *q;
|
||||||
|
@ -127,7 +127,7 @@ icmp_input(struct pbuf *p, struct netif *inp)
|
|||||||
|
|
||||||
pbuf_header(p, hlen);
|
pbuf_header(p, hlen);
|
||||||
ip_output_if (p, &(iphdr->src), IP_HDRINCL,
|
ip_output_if (p, &(iphdr->src), IP_HDRINCL,
|
||||||
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));
|
DEBUGF(ICMP_DEBUG, ("icmp_input: ICMP type %d code %d not supported.\n", (int)type, (int)code));
|
||||||
@ -169,7 +169,7 @@ icmp_dest_unreach(struct pbuf *p, enum icmp_dur_type t)
|
|||||||
snmp_inc_icmpoutdestunreachs();
|
snmp_inc_icmpoutdestunreachs();
|
||||||
|
|
||||||
ip_output(q, NULL, &(iphdr->src),
|
ip_output(q, NULL, &(iphdr->src),
|
||||||
ICMP_TTL, IP_PROTO_ICMP);
|
ICMP_TTL, IP_PROTO_ICMP);
|
||||||
pbuf_free(q);
|
pbuf_free(q);
|
||||||
}
|
}
|
||||||
/*-----------------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------------*/
|
||||||
@ -210,7 +210,7 @@ icmp_time_exceeded(struct pbuf *p, enum icmp_te_type t)
|
|||||||
/* increase number of destination unreachable messages attempted to send */
|
/* increase number of destination unreachable messages attempted to send */
|
||||||
snmp_inc_icmpouttimeexcds();
|
snmp_inc_icmpouttimeexcds();
|
||||||
ip_output(q, NULL, &(iphdr->src),
|
ip_output(q, NULL, &(iphdr->src),
|
||||||
ICMP_TTL, IP_PROTO_ICMP);
|
ICMP_TTL, IP_PROTO_ICMP);
|
||||||
pbuf_free(q);
|
pbuf_free(q);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@
|
|||||||
*/
|
*/
|
||||||
static struct pbuf *
|
static struct pbuf *
|
||||||
copy_from_pbuf(struct pbuf *p, u16_t * offset,
|
copy_from_pbuf(struct pbuf *p, u16_t * offset,
|
||||||
u8_t * buffer, u16_t len)
|
u8_t * buffer, u16_t len)
|
||||||
{
|
{
|
||||||
u16_t l;
|
u16_t l;
|
||||||
|
|
||||||
@ -98,7 +98,7 @@ ip_reass_timer(void *arg)
|
|||||||
ip_reasstmr--;
|
ip_reasstmr--;
|
||||||
sys_timeout(IP_REASS_TMO, ip_reass_timer, NULL);
|
sys_timeout(IP_REASS_TMO, ip_reass_timer, NULL);
|
||||||
} else if (ip_reasstmr == 1)
|
} else if (ip_reasstmr == 1)
|
||||||
ip_reasstmr = 0;
|
ip_reasstmr = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct pbuf *
|
struct pbuf *
|
||||||
@ -147,8 +147,8 @@ ip_reass(struct pbuf *p)
|
|||||||
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,
|
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);
|
||||||
ip_reasstmr = 0;
|
ip_reasstmr = 0;
|
||||||
goto nullreturn;
|
goto nullreturn;
|
||||||
@ -157,33 +157,33 @@ 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,
|
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;
|
||||||
copy_from_pbuf(p, &i, &ip_reassbuf[IP_HLEN + offset], len);
|
copy_from_pbuf(p, &i, &ip_reassbuf[IP_HLEN + offset], len);
|
||||||
|
|
||||||
/* 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,
|
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. */
|
||||||
ip_reassbitmap[offset / (8 * 8)] |=
|
ip_reassbitmap[offset / (8 * 8)] |=
|
||||||
bitmap_bits[(offset / 8) & 7] &
|
bitmap_bits[(offset / 8) & 7] &
|
||||||
~bitmap_bits[((offset + len) / 8) & 7];
|
~bitmap_bits[((offset + len) / 8) & 7];
|
||||||
} else {
|
} else {
|
||||||
/* If the two endpoints are in different bytes, we update the
|
/* If the two endpoints are in different bytes, we update the
|
||||||
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,
|
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) {
|
||||||
ip_reassbitmap[i] = 0xff;
|
ip_reassbitmap[i] = 0xff;
|
||||||
}
|
}
|
||||||
ip_reassbitmap[(offset + len) / (8 * 8)] |=
|
ip_reassbitmap[(offset + len) / (8 * 8)] |=
|
||||||
~bitmap_bits[((offset + len) / 8) & 7];
|
~bitmap_bits[((offset + len) / 8) & 7];
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If this fragment has the More Fragments flag set to zero, we
|
/* If this fragment has the More Fragments flag set to zero, we
|
||||||
@ -196,8 +196,8 @@ ip_reass(struct pbuf *p)
|
|||||||
ip_reassflags |= IP_REASS_FLAG_LASTFRAG;
|
ip_reassflags |= IP_REASS_FLAG_LASTFRAG;
|
||||||
ip_reasslen = offset + len;
|
ip_reasslen = offset + len;
|
||||||
DEBUGF(IP_REASS_DEBUG,
|
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));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Finally, we check if we have a full packet in the buffer. We do
|
/* Finally, we check if we have a full packet in the buffer. We do
|
||||||
@ -207,22 +207,22 @@ ip_reass(struct pbuf *p)
|
|||||||
/* Check all bytes up to and including all but the last byte in
|
/* Check all bytes up to and including all but the last byte in
|
||||||
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,
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* Check the last byte in the bitmap. It should contain just the
|
/* Check the last byte in the bitmap. It should contain just the
|
||||||
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,
|
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)]));
|
||||||
goto nullreturn;
|
goto nullreturn;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Pretend to be a "normal" (i.e., not fragmented) IP packet
|
/* Pretend to be a "normal" (i.e., not fragmented) IP packet
|
||||||
@ -242,25 +242,25 @@ ip_reass(struct pbuf *p)
|
|||||||
pbuf_free(p);
|
pbuf_free(p);
|
||||||
p = pbuf_alloc(PBUF_LINK, ip_reasslen, PBUF_POOL);
|
p = pbuf_alloc(PBUF_LINK, ip_reasslen, PBUF_POOL);
|
||||||
if (p != NULL) {
|
if (p != NULL) {
|
||||||
i = 0;
|
i = 0;
|
||||||
for (q = p; q != NULL; q = q->next) {
|
for (q = p; q != NULL; q = q->next) {
|
||||||
/* 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,
|
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));
|
||||||
memcpy(q->payload, &ip_reassbuf[i],
|
memcpy(q->payload, &ip_reassbuf[i],
|
||||||
q->len > ip_reasslen - i ? ip_reasslen - i : q->len);
|
q->len > ip_reasslen - i ? ip_reasslen - i : q->len);
|
||||||
i += q->len;
|
i += q->len;
|
||||||
}
|
}
|
||||||
#ifdef IP_STATS
|
#ifdef IP_STATS
|
||||||
++lwip_stats.ip_frag.fw;
|
++lwip_stats.ip_frag.fw;
|
||||||
#endif /* IP_STATS */
|
#endif /* IP_STATS */
|
||||||
} else {
|
} else {
|
||||||
#ifdef IP_STATS
|
#ifdef IP_STATS
|
||||||
++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));
|
DEBUGF(IP_REASS_DEBUG, ("ip_reass: p %p\n", (void*)p));
|
||||||
|
@ -101,7 +101,7 @@ icmp_input(struct pbuf *p, struct netif *inp)
|
|||||||
|
|
||||||
/* DEBUGF("icmp: p->len %d p->tot_len %d\n", p->len, p->tot_len);*/
|
/* 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));
|
DEBUGF(ICMP_DEBUG, ("icmp_input: ICMP type %d not supported.\n", (int)type));
|
||||||
@ -140,7 +140,7 @@ icmp_dest_unreach(struct pbuf *p, enum icmp_dur_type t)
|
|||||||
#endif /* ICMP_STATS */
|
#endif /* ICMP_STATS */
|
||||||
|
|
||||||
ip_output(q, NULL,
|
ip_output(q, NULL,
|
||||||
(struct ip_addr *)&(iphdr->src), ICMP_TTL, IP_PROTO_ICMP);
|
(struct ip_addr *)&(iphdr->src), ICMP_TTL, IP_PROTO_ICMP);
|
||||||
pbuf_free(q);
|
pbuf_free(q);
|
||||||
}
|
}
|
||||||
/*-----------------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------------*/
|
||||||
@ -171,7 +171,7 @@ icmp_time_exceeded(struct pbuf *p, enum icmp_te_type t)
|
|||||||
++lwip_stats.icmp.xmit;
|
++lwip_stats.icmp.xmit;
|
||||||
#endif /* ICMP_STATS */
|
#endif /* ICMP_STATS */
|
||||||
ip_output(q, NULL,
|
ip_output(q, NULL,
|
||||||
(struct ip_addr *)&(iphdr->src), ICMP_TTL, IP_PROTO_ICMP);
|
(struct ip_addr *)&(iphdr->src), ICMP_TTL, IP_PROTO_ICMP);
|
||||||
pbuf_free(q);
|
pbuf_free(q);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -238,7 +238,7 @@ ip_input(struct pbuf *p, struct netif *inp) {
|
|||||||
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",
|
DEBUGF(IP_DEBUG, ("Unsupported transport protocol %u\n",
|
||||||
iphdr->nexthdr));
|
iphdr->nexthdr));
|
||||||
|
|
||||||
#ifdef IP_STATS
|
#ifdef IP_STATS
|
||||||
++lwip_stats.ip.proterr;
|
++lwip_stats.ip.proterr;
|
||||||
@ -259,8 +259,8 @@ ip_input(struct pbuf *p, struct netif *inp) {
|
|||||||
/*-----------------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------------*/
|
||||||
err_t
|
err_t
|
||||||
ip_output_if (struct pbuf *p, struct ip_addr *src, struct ip_addr *dest,
|
ip_output_if (struct pbuf *p, struct ip_addr *src, struct ip_addr *dest,
|
||||||
u8_t ttl,
|
u8_t ttl,
|
||||||
u8_t proto, struct netif *netif)
|
u8_t proto, struct netif *netif)
|
||||||
{
|
{
|
||||||
struct ip_hdr *iphdr;
|
struct ip_hdr *iphdr;
|
||||||
|
|
||||||
@ -320,7 +320,7 @@ ip_output_if (struct pbuf *p, struct ip_addr *src, struct ip_addr *dest,
|
|||||||
/*-----------------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------------*/
|
||||||
err_t
|
err_t
|
||||||
ip_output(struct pbuf *p, struct ip_addr *src, struct ip_addr *dest,
|
ip_output(struct pbuf *p, struct ip_addr *src, struct ip_addr *dest,
|
||||||
u8_t ttl, u8_t proto)
|
u8_t ttl, u8_t proto)
|
||||||
{
|
{
|
||||||
struct netif *netif;
|
struct netif *netif;
|
||||||
if ((netif = ip_route(dest)) == NULL) {
|
if ((netif = ip_route(dest)) == NULL) {
|
||||||
@ -346,40 +346,40 @@ ip_debug_print(struct pbuf *p)
|
|||||||
DEBUGF(IP_DEBUG, ("IP header:\n"));
|
DEBUGF(IP_DEBUG, ("IP header:\n"));
|
||||||
DEBUGF(IP_DEBUG, ("+-------------------------------+\n"));
|
DEBUGF(IP_DEBUG, ("+-------------------------------+\n"));
|
||||||
DEBUGF(IP_DEBUG, ("|%2d | %x%x | %x%x | (v, traffic class, flow label)\n",
|
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"));
|
DEBUGF(IP_DEBUG, ("+-------------------------------+\n"));
|
||||||
DEBUGF(IP_DEBUG, ("| %5u | %2u | %2u | (len, nexthdr, hoplim)\n",
|
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"));
|
DEBUGF(IP_DEBUG, ("+-------------------------------+\n"));
|
||||||
DEBUGF(IP_DEBUG, ("| %4lx | %4lx | (src)\n",
|
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",
|
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",
|
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",
|
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"));
|
DEBUGF(IP_DEBUG, ("+-------------------------------+\n"));
|
||||||
DEBUGF(IP_DEBUG, ("| %4lx | %4lx | (dest)\n",
|
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",
|
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",
|
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",
|
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"));
|
DEBUGF(IP_DEBUG, ("+-------------------------------+\n"));
|
||||||
}
|
}
|
||||||
#endif /* IP_DEBUG */
|
#endif /* IP_DEBUG */
|
||||||
|
@ -202,7 +202,7 @@ mem_realloc(void *rmem, mem_size_t newsize)
|
|||||||
sys_sem_wait(mem_sem);
|
sys_sem_wait(mem_sem);
|
||||||
|
|
||||||
LWIP_ASSERT("mem_realloc: legal memory", (u8_t *)rmem >= (u8_t *)ram &&
|
LWIP_ASSERT("mem_realloc: legal memory", (u8_t *)rmem >= (u8_t *)ram &&
|
||||||
(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"));
|
DEBUGF(MEM_DEBUG | 3, ("mem_realloc: illegal memory\n"));
|
||||||
@ -275,24 +275,24 @@ mem_malloc(mem_size_t size)
|
|||||||
lwip_stats.mem.used += (size + SIZEOF_STRUCT_MEM);
|
lwip_stats.mem.used += (size + SIZEOF_STRUCT_MEM);
|
||||||
/* if (lwip_stats.mem.max < lwip_stats.mem.used) {
|
/* if (lwip_stats.mem.max < lwip_stats.mem.used) {
|
||||||
lwip_stats.mem.max = lwip_stats.mem.used;
|
lwip_stats.mem.max = lwip_stats.mem.used;
|
||||||
} */
|
} */
|
||||||
if (lwip_stats.mem.max < ptr2) {
|
if (lwip_stats.mem.max < ptr2) {
|
||||||
lwip_stats.mem.max = ptr2;
|
lwip_stats.mem.max = ptr2;
|
||||||
}
|
}
|
||||||
#endif /* MEM_STATS */
|
#endif /* MEM_STATS */
|
||||||
|
|
||||||
if (mem == lfree) {
|
if (mem == lfree) {
|
||||||
/* Find next free block after mem */
|
/* Find next free block after mem */
|
||||||
while (lfree->used && lfree != ram_end) {
|
while (lfree->used && lfree != ram_end) {
|
||||||
lfree = (struct mem *)&ram[lfree->next];
|
lfree = (struct mem *)&ram[lfree->next];
|
||||||
}
|
}
|
||||||
LWIP_ASSERT("mem_malloc: !lfree->used", !lfree->used);
|
LWIP_ASSERT("mem_malloc: !lfree->used", !lfree->used);
|
||||||
}
|
}
|
||||||
sys_sem_signal(mem_sem);
|
sys_sem_signal(mem_sem);
|
||||||
LWIP_ASSERT("mem_malloc: allocated memory not above ram_end.",
|
LWIP_ASSERT("mem_malloc: allocated memory not above ram_end.",
|
||||||
(u32_t)mem + SIZEOF_STRUCT_MEM + size <= (u32_t)ram_end);
|
(u32_t)mem + SIZEOF_STRUCT_MEM + size <= (u32_t)ram_end);
|
||||||
LWIP_ASSERT("mem_malloc: allocated memory properly aligned.",
|
LWIP_ASSERT("mem_malloc: allocated memory properly aligned.",
|
||||||
(unsigned long)((u8_t *)mem + SIZEOF_STRUCT_MEM) % MEM_ALIGNMENT == 0);
|
(unsigned long)((u8_t *)mem + SIZEOF_STRUCT_MEM) % MEM_ALIGNMENT == 0);
|
||||||
return (u8_t *)mem + SIZEOF_STRUCT_MEM;
|
return (u8_t *)mem + SIZEOF_STRUCT_MEM;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -79,35 +79,35 @@ static const u16_t memp_num[MEMP_MAX] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static u8_t memp_memory[(MEMP_NUM_PBUF *
|
static u8_t memp_memory[(MEMP_NUM_PBUF *
|
||||||
MEM_ALIGN_SIZE(sizeof(struct pbuf) +
|
MEM_ALIGN_SIZE(sizeof(struct pbuf) +
|
||||||
sizeof(struct memp)) +
|
sizeof(struct memp)) +
|
||||||
MEMP_NUM_UDP_PCB *
|
MEMP_NUM_UDP_PCB *
|
||||||
MEM_ALIGN_SIZE(sizeof(struct udp_pcb) +
|
MEM_ALIGN_SIZE(sizeof(struct udp_pcb) +
|
||||||
sizeof(struct memp)) +
|
sizeof(struct memp)) +
|
||||||
MEMP_NUM_TCP_PCB *
|
MEMP_NUM_TCP_PCB *
|
||||||
MEM_ALIGN_SIZE(sizeof(struct tcp_pcb) +
|
MEM_ALIGN_SIZE(sizeof(struct tcp_pcb) +
|
||||||
sizeof(struct memp)) +
|
sizeof(struct memp)) +
|
||||||
MEMP_NUM_TCP_PCB_LISTEN *
|
MEMP_NUM_TCP_PCB_LISTEN *
|
||||||
MEM_ALIGN_SIZE(sizeof(struct tcp_pcb_listen) +
|
MEM_ALIGN_SIZE(sizeof(struct tcp_pcb_listen) +
|
||||||
sizeof(struct memp)) +
|
sizeof(struct memp)) +
|
||||||
MEMP_NUM_TCP_SEG *
|
MEMP_NUM_TCP_SEG *
|
||||||
MEM_ALIGN_SIZE(sizeof(struct tcp_seg) +
|
MEM_ALIGN_SIZE(sizeof(struct tcp_seg) +
|
||||||
sizeof(struct memp)) +
|
sizeof(struct memp)) +
|
||||||
MEMP_NUM_NETBUF *
|
MEMP_NUM_NETBUF *
|
||||||
MEM_ALIGN_SIZE(sizeof(struct netbuf) +
|
MEM_ALIGN_SIZE(sizeof(struct netbuf) +
|
||||||
sizeof(struct memp)) +
|
sizeof(struct memp)) +
|
||||||
MEMP_NUM_NETCONN *
|
MEMP_NUM_NETCONN *
|
||||||
MEM_ALIGN_SIZE(sizeof(struct netconn) +
|
MEM_ALIGN_SIZE(sizeof(struct netconn) +
|
||||||
sizeof(struct memp)) +
|
sizeof(struct memp)) +
|
||||||
MEMP_NUM_API_MSG *
|
MEMP_NUM_API_MSG *
|
||||||
MEM_ALIGN_SIZE(sizeof(struct api_msg) +
|
MEM_ALIGN_SIZE(sizeof(struct api_msg) +
|
||||||
sizeof(struct memp)) +
|
sizeof(struct memp)) +
|
||||||
MEMP_NUM_TCPIP_MSG *
|
MEMP_NUM_TCPIP_MSG *
|
||||||
MEM_ALIGN_SIZE(sizeof(struct tcpip_msg) +
|
MEM_ALIGN_SIZE(sizeof(struct tcpip_msg) +
|
||||||
sizeof(struct memp)) +
|
sizeof(struct memp)) +
|
||||||
MEMP_NUM_SYS_TIMEOUT *
|
MEMP_NUM_SYS_TIMEOUT *
|
||||||
MEM_ALIGN_SIZE(sizeof(struct sys_timeout) +
|
MEM_ALIGN_SIZE(sizeof(struct sys_timeout) +
|
||||||
sizeof(struct memp)))];
|
sizeof(struct memp)))];
|
||||||
|
|
||||||
/*-----------------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------------*/
|
||||||
#if !SYS_LIGHTWEIGHT_PROT
|
#if !SYS_LIGHTWEIGHT_PROT
|
||||||
@ -125,10 +125,10 @@ memp_sanity(void)
|
|||||||
for(m = memp_tab[i]; m != NULL; m = m->next) {
|
for(m = memp_tab[i]; m != NULL; m = m->next) {
|
||||||
c = 1;
|
c = 1;
|
||||||
for(n = memp_tab[i]; n != NULL; n = n->next) {
|
for(n = memp_tab[i]; n != NULL; n = n->next) {
|
||||||
if (n == m) {
|
if (n == m) {
|
||||||
--c;
|
--c;
|
||||||
}
|
}
|
||||||
if (c < 0) return 0; /* LW was: abort(); */
|
if (c < 0) return 0; /* LW was: abort(); */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -159,9 +159,9 @@ memp_init(void)
|
|||||||
m = memp;
|
m = memp;
|
||||||
|
|
||||||
for(j = 0; j < memp_num[i]; ++j) {
|
for(j = 0; j < memp_num[i]; ++j) {
|
||||||
m->next = (struct memp *)MEM_ALIGN((u8_t *)m + size);
|
m->next = (struct memp *)MEM_ALIGN((u8_t *)m + size);
|
||||||
memp = m;
|
memp = m;
|
||||||
m = m->next;
|
m = m->next;
|
||||||
}
|
}
|
||||||
memp->next = NULL;
|
memp->next = NULL;
|
||||||
memp = m;
|
memp = m;
|
||||||
@ -197,11 +197,11 @@ memp_malloc(memp_t type)
|
|||||||
}
|
}
|
||||||
#endif /* MEMP_STATS */
|
#endif /* MEMP_STATS */
|
||||||
LWIP_ASSERT("memp_malloc: memp properly aligned",
|
LWIP_ASSERT("memp_malloc: memp properly aligned",
|
||||||
((u32_t)MEM_ALIGN((u8_t *)memp + sizeof(struct memp)) % MEM_ALIGNMENT) == 0);
|
((u32_t)MEM_ALIGN((u8_t *)memp + sizeof(struct memp)) % MEM_ALIGNMENT) == 0);
|
||||||
|
|
||||||
mem = MEM_ALIGN((u8_t *)memp + sizeof(struct memp));
|
mem = MEM_ALIGN((u8_t *)memp + sizeof(struct memp));
|
||||||
/* initialize memp memory with zeroes */
|
/* initialize memp memory with zeroes */
|
||||||
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));
|
DEBUGF(MEMP_DEBUG | 2, ("memp_malloc: out of memory in pool %d\n", type));
|
||||||
|
@ -112,7 +112,7 @@ netif_add(struct ip_addr *ipaddr, struct ip_addr *netmask,
|
|||||||
|
|
||||||
void
|
void
|
||||||
netif_set_addr(struct netif *netif,struct ip_addr *ipaddr, struct ip_addr *netmask,
|
netif_set_addr(struct netif *netif,struct ip_addr *ipaddr, struct ip_addr *netmask,
|
||||||
struct ip_addr *gw)
|
struct ip_addr *gw)
|
||||||
{
|
{
|
||||||
netif_set_ipaddr(netif, ipaddr);
|
netif_set_ipaddr(netif, ipaddr);
|
||||||
netif_set_netmask(netif, netmask);
|
netif_set_netmask(netif, netmask);
|
||||||
@ -131,13 +131,13 @@ void netif_remove(struct netif * netif)
|
|||||||
/* look for netif further down the list */
|
/* look for netif further down the list */
|
||||||
struct netif * tmpNetif;
|
struct netif * tmpNetif;
|
||||||
for (tmpNetif = netif_list; tmpNetif != NULL; tmpNetif = tmpNetif->next) {
|
for (tmpNetif = netif_list; tmpNetif != NULL; tmpNetif = tmpNetif->next) {
|
||||||
if (tmpNetif->next == netif) {
|
if (tmpNetif->next == netif) {
|
||||||
tmpNetif->next = netif->next;
|
tmpNetif->next = netif->next;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (tmpNetif == NULL)
|
if (tmpNetif == NULL)
|
||||||
return; /* we didn't find any netif today */
|
return; /* we didn't find any netif today */
|
||||||
}
|
}
|
||||||
/* this netif is default? */
|
/* this netif is default? */
|
||||||
if (netif_default == netif)
|
if (netif_default == netif)
|
||||||
@ -211,7 +211,7 @@ 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",
|
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),
|
||||||
@ -223,11 +223,11 @@ 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",
|
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),
|
||||||
(u8_t)(ntohl(netif->gw.addr) >> 8 & 0xff),
|
(u8_t)(ntohl(netif->gw.addr) >> 8 & 0xff),
|
||||||
(u8_t)(ntohl(netif->gw.addr) & 0xff)));
|
(u8_t)(ntohl(netif->gw.addr) & 0xff)));
|
||||||
}
|
}
|
||||||
/*-----------------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------------*/
|
||||||
void
|
void
|
||||||
@ -235,11 +235,11 @@ 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",
|
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),
|
||||||
(u8_t)(ntohl(netif->netmask.addr) >> 8 & 0xff),
|
(u8_t)(ntohl(netif->netmask.addr) >> 8 & 0xff),
|
||||||
(u8_t)(ntohl(netif->netmask.addr) & 0xff)));
|
(u8_t)(ntohl(netif->netmask.addr) & 0xff)));
|
||||||
}
|
}
|
||||||
/*-----------------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------------*/
|
||||||
void
|
void
|
||||||
@ -247,7 +247,7 @@ netif_set_default(struct netif *netif)
|
|||||||
{
|
{
|
||||||
netif_default = netif;
|
netif_default = netif;
|
||||||
DEBUGF(NETIF_DEBUG, ("netif: setting default interface %c%c\n",
|
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] : '\''));
|
||||||
}
|
}
|
||||||
/*-----------------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------------*/
|
||||||
void
|
void
|
||||||
|
@ -69,8 +69,8 @@ sys_mbox_fetch(sys_mbox_t mbox, void **msg)
|
|||||||
|
|
||||||
if (time == SYS_ARCH_TIMEOUT) {
|
if (time == SYS_ARCH_TIMEOUT) {
|
||||||
/* If time == SYS_ARCH_TIMEOUT, a timeout occured before a message
|
/* If time == SYS_ARCH_TIMEOUT, a timeout occured before a message
|
||||||
could be fetched. We should now call the timeout handler and
|
could be fetched. We should now call the timeout handler and
|
||||||
deallocate the memory allocated for the timeout. */
|
deallocate the memory allocated for the timeout. */
|
||||||
tmptimeout = timeouts->next;
|
tmptimeout = timeouts->next;
|
||||||
timeouts->next = tmptimeout->next;
|
timeouts->next = tmptimeout->next;
|
||||||
h = tmptimeout->h;
|
h = tmptimeout->h;
|
||||||
@ -78,19 +78,19 @@ sys_mbox_fetch(sys_mbox_t mbox, void **msg)
|
|||||||
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));
|
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. */
|
||||||
goto again;
|
goto again;
|
||||||
} else {
|
} else {
|
||||||
/* If time != SYS_ARCH_TIMEOUT, a message was received before the timeout
|
/* If time != SYS_ARCH_TIMEOUT, a message was received before the timeout
|
||||||
occured. The time variable is set to the number of
|
occured. The time variable is set to the number of
|
||||||
milliseconds we waited for the message. */
|
milliseconds we waited for the message. */
|
||||||
if (time <= timeouts->next->time) {
|
if (time <= timeouts->next->time) {
|
||||||
timeouts->next->time -= time;
|
timeouts->next->time -= time;
|
||||||
} else {
|
} else {
|
||||||
timeouts->next->time = 0;
|
timeouts->next->time = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -124,29 +124,29 @@ sys_sem_wait(sys_sem_t sem)
|
|||||||
|
|
||||||
if (time == SYS_ARCH_TIMEOUT) {
|
if (time == SYS_ARCH_TIMEOUT) {
|
||||||
/* If time == SYS_ARCH_TIMEOUT, a timeout occured before a message
|
/* If time == SYS_ARCH_TIMEOUT, a timeout occured before a message
|
||||||
could be fetched. We should now call the timeout handler and
|
could be fetched. We should now call the timeout handler and
|
||||||
deallocate the memory allocated for the timeout. */
|
deallocate the memory allocated for the timeout. */
|
||||||
tmptimeout = timeouts->next;
|
tmptimeout = timeouts->next;
|
||||||
timeouts->next = tmptimeout->next;
|
timeouts->next = tmptimeout->next;
|
||||||
h = tmptimeout->h;
|
h = tmptimeout->h;
|
||||||
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));
|
DEBUGF(SYS_DEBUG, ("ssw 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. */
|
||||||
goto again;
|
goto again;
|
||||||
} else {
|
} else {
|
||||||
/* If time != SYS_ARCH_TIMEOUT, a message was received before the timeout
|
/* If time != SYS_ARCH_TIMEOUT, a message was received before the timeout
|
||||||
occured. The time variable is set to the number of
|
occured. The time variable is set to the number of
|
||||||
milliseconds we waited for the message. */
|
milliseconds we waited for the message. */
|
||||||
if (time <= timeouts->next->time) {
|
if (time <= timeouts->next->time) {
|
||||||
timeouts->next->time -= time;
|
timeouts->next->time -= time;
|
||||||
} else {
|
} else {
|
||||||
timeouts->next->time = 0;
|
timeouts->next->time = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -186,13 +186,13 @@ sys_timeout(u32_t msecs, sys_timeout_handler h, void *arg)
|
|||||||
for(t = timeouts->next; t != NULL; t = t->next) {
|
for(t = timeouts->next; t != NULL; t = t->next) {
|
||||||
timeout->time -= t->time;
|
timeout->time -= t->time;
|
||||||
if (t->next == NULL ||
|
if (t->next == NULL ||
|
||||||
t->next->time > timeout->time) {
|
t->next->time > timeout->time) {
|
||||||
if (t->next != NULL) {
|
if (t->next != NULL) {
|
||||||
t->next->time -= timeout->time;
|
t->next->time -= timeout->time;
|
||||||
}
|
}
|
||||||
timeout->next = t->next;
|
timeout->next = t->next;
|
||||||
t->next = timeout;
|
t->next = timeout;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -282,11 +282,11 @@ sys_sem_wait_timeout(sys_sem_t sem, u32_t timeout)
|
|||||||
void
|
void
|
||||||
sys_msleep(u32_t ms)
|
sys_msleep(u32_t ms)
|
||||||
{
|
{
|
||||||
sys_sem_t delaysem = sys_sem_new(0);
|
sys_sem_t delaysem = sys_sem_new(0);
|
||||||
|
|
||||||
sys_sem_wait_timeout(delaysem, ms);
|
sys_sem_wait_timeout(delaysem, ms);
|
||||||
|
|
||||||
sys_sem_free(delaysem);
|
sys_sem_free(delaysem);
|
||||||
}
|
}
|
||||||
/*-----------------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
@ -64,8 +64,8 @@ const u8_t tcp_backoff[13] =
|
|||||||
/* The TCP PCB lists. */
|
/* The TCP PCB lists. */
|
||||||
struct tcp_pcb_listen *tcp_listen_pcbs; /* List of all TCP PCBs in LISTEN state. */
|
struct tcp_pcb_listen *tcp_listen_pcbs; /* List of all TCP PCBs in LISTEN state. */
|
||||||
struct tcp_pcb *tcp_active_pcbs; /* List of all TCP PCBs that are in a
|
struct tcp_pcb *tcp_active_pcbs; /* List of all TCP PCBs that are in a
|
||||||
state in which they accept or send
|
state in which they accept or send
|
||||||
data. */
|
data. */
|
||||||
struct tcp_pcb *tcp_tw_pcbs; /* List of all TCP PCBs in TIME-WAIT. */
|
struct tcp_pcb *tcp_tw_pcbs; /* List of all TCP PCBs in TIME-WAIT. */
|
||||||
|
|
||||||
struct tcp_pcb *tcp_tmp_pcb;
|
struct tcp_pcb *tcp_tmp_pcb;
|
||||||
@ -274,9 +274,9 @@ tcp_bind(struct tcp_pcb *pcb, struct ip_addr *ipaddr, u16_t port)
|
|||||||
cpcb != NULL; cpcb = cpcb->next) {
|
cpcb != NULL; cpcb = cpcb->next) {
|
||||||
if (cpcb->local_port == port) {
|
if (cpcb->local_port == port) {
|
||||||
if (ip_addr_isany(&(cpcb->local_ip)) ||
|
if (ip_addr_isany(&(cpcb->local_ip)) ||
|
||||||
ip_addr_isany(ipaddr) ||
|
ip_addr_isany(ipaddr) ||
|
||||||
ip_addr_cmp(&(cpcb->local_ip), ipaddr)) {
|
ip_addr_cmp(&(cpcb->local_ip), ipaddr)) {
|
||||||
return ERR_USE;
|
return ERR_USE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -352,7 +352,7 @@ tcp_recved(struct tcp_pcb *pcb, u16_t len)
|
|||||||
tcp_ack(pcb);
|
tcp_ack(pcb);
|
||||||
}
|
}
|
||||||
DEBUGF(TCP_DEBUG, ("tcp_recved: recveived %u bytes, wnd %u (%u).\n",
|
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));
|
||||||
}
|
}
|
||||||
/*-----------------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------------*/
|
||||||
/*
|
/*
|
||||||
@ -405,7 +405,7 @@ tcp_new_port(void)
|
|||||||
/*-----------------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------------*/
|
||||||
err_t
|
err_t
|
||||||
tcp_connect(struct tcp_pcb *pcb, struct ip_addr *ipaddr, u16_t port,
|
tcp_connect(struct tcp_pcb *pcb, struct ip_addr *ipaddr, u16_t port,
|
||||||
err_t (* connected)(void *arg, struct tcp_pcb *tpcb, err_t err))
|
err_t (* connected)(void *arg, struct tcp_pcb *tpcb, err_t err))
|
||||||
{
|
{
|
||||||
u32_t optdata;
|
u32_t optdata;
|
||||||
err_t ret;
|
err_t ret;
|
||||||
@ -439,9 +439,9 @@ tcp_connect(struct tcp_pcb *pcb, struct ip_addr *ipaddr, u16_t port,
|
|||||||
|
|
||||||
/* Build an MSS option */
|
/* Build an MSS option */
|
||||||
optdata = htonl(((u32_t)2 << 24) |
|
optdata = htonl(((u32_t)2 << 24) |
|
||||||
((u32_t)4 << 16) |
|
((u32_t)4 << 16) |
|
||||||
(((u32_t)pcb->mss / 256) << 8) |
|
(((u32_t)pcb->mss / 256) << 8) |
|
||||||
(pcb->mss & 255));
|
(pcb->mss & 255));
|
||||||
|
|
||||||
ret = tcp_enqueue(pcb, NULL, 0, TCP_SYN, 0, (u8_t *)&optdata, 4);
|
ret = tcp_enqueue(pcb, NULL, 0, TCP_SYN, 0, (u8_t *)&optdata, 4);
|
||||||
if (ret == ERR_OK) {
|
if (ret == ERR_OK) {
|
||||||
@ -539,7 +539,7 @@ tcp_slowtmr(void)
|
|||||||
/* Check if this PCB has stayed too long in SYN-RCVD */
|
/* Check if this PCB has stayed too long in SYN-RCVD */
|
||||||
if (pcb->state == SYN_RCVD) {
|
if (pcb->state == SYN_RCVD) {
|
||||||
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"));
|
DEBUGF(TCP_DEBUG, ("tcp_slowtmr: removing pcb stuck in SYN-RCVD\n"));
|
||||||
}
|
}
|
||||||
@ -551,7 +551,7 @@ tcp_slowtmr(void)
|
|||||||
tcp_pcb_purge(pcb);
|
tcp_pcb_purge(pcb);
|
||||||
/* Remove PCB from tcp_active_pcbs list. */
|
/* Remove PCB from tcp_active_pcbs list. */
|
||||||
if (prev != NULL) {
|
if (prev != NULL) {
|
||||||
LWIP_ASSERT("tcp_slowtmr: middle tcp != tcp_active_pcbs", pcb != tcp_active_pcbs);
|
LWIP_ASSERT("tcp_slowtmr: middle tcp != tcp_active_pcbs", pcb != tcp_active_pcbs);
|
||||||
prev->next = pcb->next;
|
prev->next = pcb->next;
|
||||||
} else {
|
} else {
|
||||||
/* This PCB was the first. */
|
/* This PCB was the first. */
|
||||||
@ -569,12 +569,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"));
|
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;
|
||||||
@ -602,7 +602,7 @@ tcp_slowtmr(void)
|
|||||||
tcp_pcb_purge(pcb);
|
tcp_pcb_purge(pcb);
|
||||||
/* Remove PCB from tcp_tw_pcbs list. */
|
/* Remove PCB from tcp_tw_pcbs list. */
|
||||||
if (prev != NULL) {
|
if (prev != NULL) {
|
||||||
LWIP_ASSERT("tcp_slowtmr: middle tcp != tcp_tw_pcbs", pcb != tcp_tw_pcbs);
|
LWIP_ASSERT("tcp_slowtmr: middle tcp != tcp_tw_pcbs", pcb != tcp_tw_pcbs);
|
||||||
prev->next = pcb->next;
|
prev->next = pcb->next;
|
||||||
} else {
|
} else {
|
||||||
/* This PCB was the first. */
|
/* This PCB was the first. */
|
||||||
@ -761,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",
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -783,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",
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -875,7 +875,7 @@ tcp_arg(struct tcp_pcb *pcb, void *arg)
|
|||||||
#if LWIP_CALLBACK_API
|
#if LWIP_CALLBACK_API
|
||||||
void
|
void
|
||||||
tcp_recv(struct tcp_pcb *pcb,
|
tcp_recv(struct tcp_pcb *pcb,
|
||||||
err_t (* recv)(void *arg, struct tcp_pcb *tpcb, struct pbuf *p, err_t err))
|
err_t (* recv)(void *arg, struct tcp_pcb *tpcb, struct pbuf *p, err_t err))
|
||||||
{
|
{
|
||||||
pcb->recv = recv;
|
pcb->recv = recv;
|
||||||
}
|
}
|
||||||
@ -892,7 +892,7 @@ tcp_recv(struct tcp_pcb *pcb,
|
|||||||
#if LWIP_CALLBACK_API
|
#if LWIP_CALLBACK_API
|
||||||
void
|
void
|
||||||
tcp_sent(struct tcp_pcb *pcb,
|
tcp_sent(struct tcp_pcb *pcb,
|
||||||
err_t (* sent)(void *arg, struct tcp_pcb *tpcb, u16_t len))
|
err_t (* sent)(void *arg, struct tcp_pcb *tpcb, u16_t len))
|
||||||
{
|
{
|
||||||
pcb->sent = sent;
|
pcb->sent = sent;
|
||||||
}
|
}
|
||||||
@ -909,7 +909,7 @@ tcp_sent(struct tcp_pcb *pcb,
|
|||||||
#if LWIP_CALLBACK_API
|
#if LWIP_CALLBACK_API
|
||||||
void
|
void
|
||||||
tcp_err(struct tcp_pcb *pcb,
|
tcp_err(struct tcp_pcb *pcb,
|
||||||
void (* errf)(void *arg, err_t err))
|
void (* errf)(void *arg, err_t err))
|
||||||
{
|
{
|
||||||
pcb->errf = errf;
|
pcb->errf = errf;
|
||||||
}
|
}
|
||||||
@ -926,7 +926,7 @@ tcp_err(struct tcp_pcb *pcb,
|
|||||||
/*-----------------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------------*/
|
||||||
void
|
void
|
||||||
tcp_poll(struct tcp_pcb *pcb,
|
tcp_poll(struct tcp_pcb *pcb,
|
||||||
err_t (* poll)(void *arg, struct tcp_pcb *tpcb), u8_t interval)
|
err_t (* poll)(void *arg, struct tcp_pcb *tpcb), u8_t interval)
|
||||||
{
|
{
|
||||||
#if LWIP_CALLBACK_API
|
#if LWIP_CALLBACK_API
|
||||||
pcb->poll = poll;
|
pcb->poll = poll;
|
||||||
@ -945,7 +945,7 @@ tcp_poll(struct tcp_pcb *pcb,
|
|||||||
#if LWIP_CALLBACK_API
|
#if LWIP_CALLBACK_API
|
||||||
void
|
void
|
||||||
tcp_accept(struct tcp_pcb *pcb,
|
tcp_accept(struct tcp_pcb *pcb,
|
||||||
err_t (* accept)(void *arg, struct tcp_pcb *newpcb, err_t err))
|
err_t (* accept)(void *arg, struct tcp_pcb *newpcb, err_t err))
|
||||||
{
|
{
|
||||||
((struct tcp_pcb_listen *)pcb)->accept = accept;
|
((struct tcp_pcb_listen *)pcb)->accept = accept;
|
||||||
}
|
}
|
||||||
@ -1042,28 +1042,28 @@ tcp_debug_print(struct tcp_hdr *tcphdr)
|
|||||||
DEBUGF(TCP_DEBUG, ("TCP header:\n"));
|
DEBUGF(TCP_DEBUG, ("TCP header:\n"));
|
||||||
DEBUGF(TCP_DEBUG, ("+-------------------------------+\n"));
|
DEBUGF(TCP_DEBUG, ("+-------------------------------+\n"));
|
||||||
DEBUGF(TCP_DEBUG, ("| %04x | %04x | (src port, dest port)\n",
|
DEBUGF(TCP_DEBUG, ("| %04x | %04x | (src port, dest port)\n",
|
||||||
tcphdr->src, tcphdr->dest));
|
tcphdr->src, tcphdr->dest));
|
||||||
DEBUGF(TCP_DEBUG, ("+-------------------------------+\n"));
|
DEBUGF(TCP_DEBUG, ("+-------------------------------+\n"));
|
||||||
DEBUGF(TCP_DEBUG, ("| %08lu | (seq no)\n",
|
DEBUGF(TCP_DEBUG, ("| %08lu | (seq no)\n",
|
||||||
tcphdr->seqno));
|
tcphdr->seqno));
|
||||||
DEBUGF(TCP_DEBUG, ("+-------------------------------+\n"));
|
DEBUGF(TCP_DEBUG, ("+-------------------------------+\n"));
|
||||||
DEBUGF(TCP_DEBUG, ("| %08lu | (ack no)\n",
|
DEBUGF(TCP_DEBUG, ("| %08lu | (ack no)\n",
|
||||||
tcphdr->ackno));
|
tcphdr->ackno));
|
||||||
DEBUGF(TCP_DEBUG, ("+-------------------------------+\n"));
|
DEBUGF(TCP_DEBUG, ("+-------------------------------+\n"));
|
||||||
DEBUGF(TCP_DEBUG, ("| %2u | |%u%u%u%u%u| %5u | (offset, flags (",
|
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,
|
||||||
TCPH_FLAGS(tcphdr) >> 3 & 1,
|
TCPH_FLAGS(tcphdr) >> 3 & 1,
|
||||||
TCPH_FLAGS(tcphdr) >> 2 & 1,
|
TCPH_FLAGS(tcphdr) >> 2 & 1,
|
||||||
TCPH_FLAGS(tcphdr) >> 1 & 1,
|
TCPH_FLAGS(tcphdr) >> 1 & 1,
|
||||||
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"));
|
DEBUGF(TCP_DEBUG, ("), win)\n"));
|
||||||
DEBUGF(TCP_DEBUG, ("+-------------------------------+\n"));
|
DEBUGF(TCP_DEBUG, ("+-------------------------------+\n"));
|
||||||
DEBUGF(TCP_DEBUG, ("| 0x%04x | %5u | (chksum, urgp)\n",
|
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"));
|
DEBUGF(TCP_DEBUG, ("+-------------------------------+\n"));
|
||||||
}
|
}
|
||||||
/*-----------------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------------*/
|
||||||
|
@ -134,11 +134,11 @@ tcp_input(struct pbuf *p, struct netif *inp)
|
|||||||
|
|
||||||
/* Verify TCP checksum. */
|
/* Verify TCP checksum. */
|
||||||
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),
|
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
|
||||||
tcp_debug_print(tcphdr);
|
tcp_debug_print(tcphdr);
|
||||||
#endif /* TCP_DEBUG */
|
#endif /* TCP_DEBUG */
|
||||||
@ -180,13 +180,13 @@ tcp_input(struct pbuf *p, struct netif *inp)
|
|||||||
ip_addr_cmp(&(pcb->local_ip), &(iphdr->dest))) {
|
ip_addr_cmp(&(pcb->local_ip), &(iphdr->dest))) {
|
||||||
|
|
||||||
/* Move this PCB to the front of the list so that subsequent
|
/* Move this PCB to the front of the list so that subsequent
|
||||||
lookups will be faster (we exploit locality in TCP segment
|
lookups will be faster (we exploit locality in TCP segment
|
||||||
arrivals). */
|
arrivals). */
|
||||||
LWIP_ASSERT("tcp_input: pcb->next != pcb (before cache)", pcb->next != pcb);
|
LWIP_ASSERT("tcp_input: pcb->next != pcb (before cache)", pcb->next != pcb);
|
||||||
if (prev != NULL) {
|
if (prev != NULL) {
|
||||||
prev->next = pcb->next;
|
prev->next = pcb->next;
|
||||||
pcb->next = tcp_active_pcbs;
|
pcb->next = tcp_active_pcbs;
|
||||||
tcp_active_pcbs = pcb;
|
tcp_active_pcbs = pcb;
|
||||||
}
|
}
|
||||||
LWIP_ASSERT("tcp_input: pcb->next != pcb (after cache)", pcb->next != pcb);
|
LWIP_ASSERT("tcp_input: pcb->next != pcb (after cache)", pcb->next != pcb);
|
||||||
break;
|
break;
|
||||||
@ -201,16 +201,16 @@ tcp_input(struct pbuf *p, struct netif *inp)
|
|||||||
for(pcb = tcp_tw_pcbs; pcb != NULL; pcb = pcb->next) {
|
for(pcb = tcp_tw_pcbs; pcb != NULL; pcb = pcb->next) {
|
||||||
LWIP_ASSERT("tcp_input: TIME-WAIT pcb->state == TIME-WAIT", pcb->state == TIME_WAIT);
|
LWIP_ASSERT("tcp_input: TIME-WAIT pcb->state == TIME-WAIT", pcb->state == TIME_WAIT);
|
||||||
if (pcb->remote_port == tcphdr->src &&
|
if (pcb->remote_port == tcphdr->src &&
|
||||||
pcb->local_port == tcphdr->dest &&
|
pcb->local_port == tcphdr->dest &&
|
||||||
ip_addr_cmp(&(pcb->remote_ip), &(iphdr->src)) &&
|
ip_addr_cmp(&(pcb->remote_ip), &(iphdr->src)) &&
|
||||||
ip_addr_cmp(&(pcb->local_ip), &(iphdr->dest))) {
|
ip_addr_cmp(&(pcb->local_ip), &(iphdr->dest))) {
|
||||||
/* 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"));
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -219,23 +219,23 @@ tcp_input(struct pbuf *p, struct netif *inp)
|
|||||||
prev = NULL;
|
prev = NULL;
|
||||||
for(lpcb = tcp_listen_pcbs; lpcb != NULL; lpcb = lpcb->next) {
|
for(lpcb = tcp_listen_pcbs; lpcb != NULL; lpcb = lpcb->next) {
|
||||||
if ((ip_addr_isany(&(lpcb->local_ip)) ||
|
if ((ip_addr_isany(&(lpcb->local_ip)) ||
|
||||||
ip_addr_cmp(&(lpcb->local_ip), &(iphdr->dest))) &&
|
ip_addr_cmp(&(lpcb->local_ip), &(iphdr->dest))) &&
|
||||||
lpcb->local_port == tcphdr->dest) {
|
lpcb->local_port == tcphdr->dest) {
|
||||||
/* Move this PCB to the front of the list so that subsequent
|
/* Move this PCB to the front of the list so that subsequent
|
||||||
lookups will be faster (we exploit locality in TCP segment
|
lookups will be faster (we exploit locality in TCP segment
|
||||||
arrivals). */
|
arrivals). */
|
||||||
if (prev != NULL) {
|
if (prev != NULL) {
|
||||||
((struct tcp_pcb_listen *)prev)->next = lpcb->next;
|
((struct tcp_pcb_listen *)prev)->next = lpcb->next;
|
||||||
/* our successor is the remainder of the listening list */
|
/* our successor is the remainder of the listening list */
|
||||||
lpcb->next = tcp_listen_pcbs;
|
lpcb->next = tcp_listen_pcbs;
|
||||||
/* put this listening pcb at the head of the listening list */
|
/* put this listening pcb at the head of the listening list */
|
||||||
tcp_listen_pcbs = lpcb;
|
tcp_listen_pcbs = lpcb;
|
||||||
}
|
}
|
||||||
|
|
||||||
DEBUGF(TCP_INPUT_DEBUG, ("tcp_input: packed for LISTENing connection.\n"));
|
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;
|
||||||
}
|
}
|
||||||
prev = (struct tcp_pcb *)lpcb;
|
prev = (struct tcp_pcb *)lpcb;
|
||||||
}
|
}
|
||||||
@ -273,41 +273,41 @@ tcp_input(struct pbuf *p, struct netif *inp)
|
|||||||
and that the pcb has been freed. If so, we don't do anything. */
|
and that the pcb has been freed. If so, we don't do anything. */
|
||||||
if (err != ERR_ABRT) {
|
if (err != ERR_ABRT) {
|
||||||
if (recv_flags & TF_RESET) {
|
if (recv_flags & TF_RESET) {
|
||||||
/* TF_RESET means that the connection was reset by the other
|
/* TF_RESET means that the connection was reset by the other
|
||||||
end. We then call the error callback to inform the
|
end. We then call the error callback to inform the
|
||||||
application that the connection is dead before we
|
application that the connection is dead before we
|
||||||
deallocate the PCB. */
|
deallocate the PCB. */
|
||||||
TCP_EVENT_ERR(pcb->errf, pcb->callback_arg, ERR_RST);
|
TCP_EVENT_ERR(pcb->errf, pcb->callback_arg, ERR_RST);
|
||||||
tcp_pcb_remove(&tcp_active_pcbs, pcb);
|
tcp_pcb_remove(&tcp_active_pcbs, pcb);
|
||||||
memp_free(MEMP_TCP_PCB, pcb);
|
memp_free(MEMP_TCP_PCB, pcb);
|
||||||
} else if (recv_flags & TF_CLOSED) {
|
} else if (recv_flags & TF_CLOSED) {
|
||||||
/* The connection has been closed and we will deallocate the
|
/* The connection has been closed and we will deallocate the
|
||||||
PCB. */
|
PCB. */
|
||||||
tcp_pcb_remove(&tcp_active_pcbs, pcb);
|
tcp_pcb_remove(&tcp_active_pcbs, pcb);
|
||||||
memp_free(MEMP_TCP_PCB, pcb);
|
memp_free(MEMP_TCP_PCB, pcb);
|
||||||
} else {
|
} else {
|
||||||
err = ERR_OK;
|
err = ERR_OK;
|
||||||
/* If the application has registered a "sent" function to be
|
/* If the application has registered a "sent" function to be
|
||||||
called when new send buffer space is available, we call it
|
called when new send buffer space is available, we call it
|
||||||
now. */
|
now. */
|
||||||
if (pcb->acked > 0) {
|
if (pcb->acked > 0) {
|
||||||
TCP_EVENT_SENT(pcb, pcb->acked, err);
|
TCP_EVENT_SENT(pcb, pcb->acked, err);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (recv_data != NULL) {
|
if (recv_data != NULL) {
|
||||||
/* Notify application that data has been received. */
|
/* Notify application that data has been received. */
|
||||||
TCP_EVENT_RECV(pcb, recv_data, ERR_OK, err);
|
TCP_EVENT_RECV(pcb, recv_data, ERR_OK, err);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If a FIN segment was received, we call the callback
|
/* If a FIN segment was received, we call the callback
|
||||||
function with a NULL buffer to indicate EOF. */
|
function with a NULL buffer to indicate EOF. */
|
||||||
if (recv_flags & TF_GOT_FIN) {
|
if (recv_flags & TF_GOT_FIN) {
|
||||||
TCP_EVENT_RECV(pcb, NULL, ERR_OK, err);
|
TCP_EVENT_RECV(pcb, NULL, ERR_OK, err);
|
||||||
}
|
}
|
||||||
/* If there were no errors, we try to send something out. */
|
/* If there were no errors, we try to send something out. */
|
||||||
if (err == ERR_OK) {
|
if (err == ERR_OK) {
|
||||||
tcp_output(pcb);
|
tcp_output(pcb);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -334,8 +334,8 @@ tcp_input(struct pbuf *p, struct netif *inp)
|
|||||||
++lwip_stats.tcp.drop;
|
++lwip_stats.tcp.drop;
|
||||||
#endif /* TCP_STATS */
|
#endif /* TCP_STATS */
|
||||||
tcp_rst(ackno, seqno + tcplen,
|
tcp_rst(ackno, seqno + tcplen,
|
||||||
&(iphdr->dest), &(iphdr->src),
|
&(iphdr->dest), &(iphdr->src),
|
||||||
tcphdr->dest, tcphdr->src);
|
tcphdr->dest, tcphdr->src);
|
||||||
}
|
}
|
||||||
pbuf_free(p);
|
pbuf_free(p);
|
||||||
}
|
}
|
||||||
@ -363,8 +363,8 @@ tcp_listen_input(struct tcp_pcb_listen *pcb)
|
|||||||
RST. */
|
RST. */
|
||||||
DEBUGF(TCP_RST_DEBUG, ("tcp_listen_input: ACK in LISTEN, sending reset\n"));
|
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));
|
DEBUGF(DEMO_DEBUG, ("TCP connection request %d -> %d.\n", tcphdr->src, tcphdr->dest));
|
||||||
npcb = tcp_alloc(pcb->prio);
|
npcb = tcp_alloc(pcb->prio);
|
||||||
@ -402,9 +402,9 @@ tcp_listen_input(struct tcp_pcb_listen *pcb)
|
|||||||
|
|
||||||
/* Build an MSS option. */
|
/* Build an MSS option. */
|
||||||
optdata = htonl(((u32_t)2 << 24) |
|
optdata = htonl(((u32_t)2 << 24) |
|
||||||
((u32_t)4 << 16) |
|
((u32_t)4 << 16) |
|
||||||
(((u32_t)npcb->mss / 256) << 8) |
|
(((u32_t)npcb->mss / 256) << 8) |
|
||||||
(npcb->mss & 255));
|
(npcb->mss & 255));
|
||||||
/* Send a SYN|ACK together with the MSS option. */
|
/* Send a SYN|ACK together with the MSS option. */
|
||||||
tcp_enqueue(npcb, NULL, 0, TCP_SYN | TCP_ACK, 0, (u8_t *)&optdata, 4);
|
tcp_enqueue(npcb, NULL, 0, TCP_SYN | TCP_ACK, 0, (u8_t *)&optdata, 4);
|
||||||
return tcp_output(npcb);
|
return tcp_output(npcb);
|
||||||
@ -453,12 +453,12 @@ tcp_process(struct tcp_pcb *pcb)
|
|||||||
/* First, determine if the reset is acceptable. */
|
/* First, determine if the reset is acceptable. */
|
||||||
if (pcb->state == SYN_SENT) {
|
if (pcb->state == SYN_SENT) {
|
||||||
if (ackno == pcb->snd_nxt) {
|
if (ackno == pcb->snd_nxt) {
|
||||||
acceptable = 1;
|
acceptable = 1;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (TCP_SEQ_GEQ(seqno, pcb->rcv_nxt) &&
|
if (TCP_SEQ_GEQ(seqno, pcb->rcv_nxt) &&
|
||||||
TCP_SEQ_LEQ(seqno, pcb->rcv_nxt + pcb->rcv_wnd)) {
|
TCP_SEQ_LEQ(seqno, pcb->rcv_nxt + pcb->rcv_wnd)) {
|
||||||
acceptable = 1;
|
acceptable = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -470,9 +470,9 @@ tcp_process(struct tcp_pcb *pcb)
|
|||||||
return ERR_RST;
|
return ERR_RST;
|
||||||
} else {
|
} else {
|
||||||
DEBUGF(TCP_INPUT_DEBUG, ("tcp_process: unacceptable reset seqno %lu rcv_nxt %lu\n",
|
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",
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -484,7 +484,7 @@ tcp_process(struct tcp_pcb *pcb)
|
|||||||
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,
|
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) {
|
||||||
pcb->rcv_nxt = seqno + 1;
|
pcb->rcv_nxt = seqno + 1;
|
||||||
@ -502,7 +502,7 @@ tcp_process(struct tcp_pcb *pcb)
|
|||||||
tcp_parseopt(pcb);
|
tcp_parseopt(pcb);
|
||||||
|
|
||||||
/* Call the user specified function to call when sucessfully
|
/* Call the user specified function to call when sucessfully
|
||||||
connected. */
|
connected. */
|
||||||
TCP_EVENT_CONNECTED(pcb, ERR_OK, err);
|
TCP_EVENT_CONNECTED(pcb, ERR_OK, err);
|
||||||
tcp_ack(pcb);
|
tcp_ack(pcb);
|
||||||
}
|
}
|
||||||
@ -511,29 +511,29 @@ tcp_process(struct tcp_pcb *pcb)
|
|||||||
if (flags & TCP_ACK &&
|
if (flags & TCP_ACK &&
|
||||||
!(flags & TCP_RST)) {
|
!(flags & TCP_RST)) {
|
||||||
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));
|
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);
|
||||||
if (err != ERR_OK) {
|
if (err != ERR_OK) {
|
||||||
/* If the accept function returns with an error, we abort
|
/* If the accept function returns with an error, we abort
|
||||||
the connection. */
|
the connection. */
|
||||||
tcp_abort(pcb);
|
tcp_abort(pcb);
|
||||||
return ERR_ABRT;
|
return ERR_ABRT;
|
||||||
}
|
}
|
||||||
/* If there was any data contained within this ACK,
|
/* If there was any data contained within this ACK,
|
||||||
we'd better pass it on to the application as well. */
|
we'd better pass it on to the application as well. */
|
||||||
tcp_receive(pcb);
|
tcp_receive(pcb);
|
||||||
pcb->cwnd = pcb->mss;
|
pcb->cwnd = pcb->mss;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case CLOSE_WAIT:
|
case CLOSE_WAIT:
|
||||||
/* FALLTHROUGH */
|
/* FALLTHROUGH */
|
||||||
case ESTABLISHED:
|
case ESTABLISHED:
|
||||||
tcp_receive(pcb);
|
tcp_receive(pcb);
|
||||||
if (flags & TCP_FIN) {
|
if (flags & TCP_FIN) {
|
||||||
tcp_ack_now(pcb);
|
tcp_ack_now(pcb);
|
||||||
pcb->state = CLOSE_WAIT;
|
pcb->state = CLOSE_WAIT;
|
||||||
@ -544,15 +544,15 @@ tcp_process(struct tcp_pcb *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,
|
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);
|
||||||
TCP_RMV(&tcp_active_pcbs, pcb);
|
TCP_RMV(&tcp_active_pcbs, pcb);
|
||||||
pcb->state = TIME_WAIT;
|
pcb->state = TIME_WAIT;
|
||||||
TCP_REG(&tcp_tw_pcbs, pcb);
|
TCP_REG(&tcp_tw_pcbs, pcb);
|
||||||
} else {
|
} else {
|
||||||
tcp_ack_now(pcb);
|
tcp_ack_now(pcb);
|
||||||
pcb->state = CLOSING;
|
pcb->state = CLOSING;
|
||||||
}
|
}
|
||||||
} else if (flags & TCP_ACK && ackno == pcb->snd_nxt) {
|
} else if (flags & TCP_ACK && ackno == pcb->snd_nxt) {
|
||||||
pcb->state = FIN_WAIT_2;
|
pcb->state = FIN_WAIT_2;
|
||||||
@ -645,32 +645,32 @@ tcp_receive(struct tcp_pcb *pcb)
|
|||||||
pcb->acked = 0;
|
pcb->acked = 0;
|
||||||
|
|
||||||
if (pcb->snd_wl1 + pcb->snd_wnd == right_wnd_edge){
|
if (pcb->snd_wl1 + pcb->snd_wnd == right_wnd_edge){
|
||||||
++pcb->dupacks;
|
++pcb->dupacks;
|
||||||
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",
|
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);
|
||||||
/* Set ssthresh to max (FlightSize / 2, 2*SMSS) */
|
/* Set ssthresh to max (FlightSize / 2, 2*SMSS) */
|
||||||
pcb->ssthresh = LWIP_MAX((pcb->snd_max -
|
pcb->ssthresh = LWIP_MAX((pcb->snd_max -
|
||||||
pcb->lastack) / 2,
|
pcb->lastack) / 2,
|
||||||
2 * pcb->mss);
|
2 * pcb->mss);
|
||||||
|
|
||||||
pcb->cwnd = pcb->ssthresh + 3 * pcb->mss;
|
pcb->cwnd = pcb->ssthresh + 3 * pcb->mss;
|
||||||
pcb->flags |= TF_INFR;
|
pcb->flags |= TF_INFR;
|
||||||
} else {
|
} else {
|
||||||
/* Inflate the congestion window, but not if it means that
|
/* Inflate the congestion window, but not if it means that
|
||||||
the value overflows. */
|
the value overflows. */
|
||||||
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
DEBUGF(TCP_FR_DEBUG, ("tcp_receive: dupack averted %lu %lu\n",
|
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) &&
|
||||||
TCP_SEQ_LEQ(ackno, pcb->snd_max)) {
|
TCP_SEQ_LEQ(ackno, pcb->snd_max)) {
|
||||||
@ -680,8 +680,8 @@ tcp_receive(struct tcp_pcb *pcb)
|
|||||||
in fast retransmit. Also reset the congestion window to the
|
in fast retransmit. Also reset the congestion window to the
|
||||||
slow start threshold. */
|
slow start threshold. */
|
||||||
if (pcb->flags & TF_INFR) {
|
if (pcb->flags & TF_INFR) {
|
||||||
pcb->flags &= ~TF_INFR;
|
pcb->flags &= ~TF_INFR;
|
||||||
pcb->cwnd = pcb->ssthresh;
|
pcb->cwnd = pcb->ssthresh;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Reset the number of retransmissions. */
|
/* Reset the number of retransmissions. */
|
||||||
@ -702,15 +702,15 @@ tcp_receive(struct tcp_pcb *pcb)
|
|||||||
ssthresh). */
|
ssthresh). */
|
||||||
if (pcb->state >= ESTABLISHED) {
|
if (pcb->state >= ESTABLISHED) {
|
||||||
if (pcb->cwnd < pcb->ssthresh) {
|
if (pcb->cwnd < pcb->ssthresh) {
|
||||||
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));
|
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));
|
DEBUGF(TCP_CWND_DEBUG, ("tcp_receive: congestion avoidance cwnd %u\n", pcb->cwnd));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -722,27 +722,27 @@ tcp_receive(struct tcp_pcb *pcb)
|
|||||||
ntohl(pcb->unacked->tcphdr->seqno) + TCP_TCPLEN(pcb->unacked): 0));
|
ntohl(pcb->unacked->tcphdr->seqno) + TCP_TCPLEN(pcb->unacked): 0));
|
||||||
|
|
||||||
/* Remove segment from the unacknowledged list if the incoming
|
/* Remove segment from the unacknowledged list if the incoming
|
||||||
ACK acknowlegdes them. */
|
ACK acknowlegdes them. */
|
||||||
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",
|
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)));
|
||||||
|
|
||||||
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));
|
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));
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pcb->polltmr = 0;
|
pcb->polltmr = 0;
|
||||||
}
|
}
|
||||||
@ -754,25 +754,25 @@ tcp_receive(struct tcp_pcb *pcb)
|
|||||||
->unsent list after a retransmission, so these segments may
|
->unsent list after a retransmission, so these segments may
|
||||||
in fact have been sent once. */
|
in fact have been sent once. */
|
||||||
while (pcb->unsent != NULL &&
|
while (pcb->unsent != NULL &&
|
||||||
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",
|
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));
|
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));
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pcb->unsent != NULL) {
|
if (pcb->unsent != NULL) {
|
||||||
pcb->snd_nxt = htonl(pcb->unsent->tcphdr->seqno);
|
pcb->snd_nxt = htonl(pcb->unsent->tcphdr->seqno);
|
||||||
}
|
}
|
||||||
@ -781,7 +781,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",
|
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
|
||||||
incoming segment acknowledges the segment we use to take a
|
incoming segment acknowledges the segment we use to take a
|
||||||
@ -790,20 +790,20 @@ tcp_receive(struct tcp_pcb *pcb)
|
|||||||
m = tcp_ticks - pcb->rttest;
|
m = tcp_ticks - pcb->rttest;
|
||||||
|
|
||||||
DEBUGF(TCP_RTO_DEBUG, ("tcp_receive: experienced rtt %d ticks (%d msec).\n",
|
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 */
|
||||||
m = m - (pcb->sa >> 3);
|
m = m - (pcb->sa >> 3);
|
||||||
pcb->sa += m;
|
pcb->sa += m;
|
||||||
if (m < 0) {
|
if (m < 0) {
|
||||||
m = -m;
|
m = -m;
|
||||||
}
|
}
|
||||||
m = m - (pcb->sv >> 2);
|
m = m - (pcb->sv >> 2);
|
||||||
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",
|
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;
|
||||||
}
|
}
|
||||||
@ -842,48 +842,48 @@ tcp_receive(struct tcp_pcb *pcb)
|
|||||||
segment is larger than rcv_nxt. */
|
segment is larger than rcv_nxt. */
|
||||||
if (TCP_SEQ_LT(seqno, pcb->rcv_nxt)){
|
if (TCP_SEQ_LT(seqno, pcb->rcv_nxt)){
|
||||||
if (TCP_SEQ_LT(pcb->rcv_nxt, seqno + tcplen)) {
|
if (TCP_SEQ_LT(pcb->rcv_nxt, seqno + tcplen)) {
|
||||||
/* Trimming the first edge is done by pushing the payload
|
/* Trimming the first edge is done by pushing the payload
|
||||||
pointer in the pbuf downwards. This is somewhat tricky since
|
pointer in the pbuf downwards. This is somewhat tricky since
|
||||||
we do not want to discard the full contents of the pbuf up to
|
we do not want to discard the full contents of the pbuf up to
|
||||||
the new starting point of the data since we have to keep the
|
the new starting point of the data since we have to keep the
|
||||||
TCP header which is present in the first pbuf in the chain.
|
TCP header which is present in the first pbuf in the chain.
|
||||||
|
|
||||||
What is done is really quite a nasty hack: the first pbuf in
|
What is done is really quite a nasty hack: the first pbuf in
|
||||||
the pbuf chain is pointed to by inseg.p. Since we need to be
|
the pbuf chain is pointed to by inseg.p. Since we need to be
|
||||||
able to deallocate the whole pbuf, we cannot change this
|
able to deallocate the whole pbuf, we cannot change this
|
||||||
inseg.p pointer to point to any of the later pbufs in the
|
inseg.p pointer to point to any of the later pbufs in the
|
||||||
chain. Instead, we point the ->payload pointer in the first
|
chain. Instead, we point the ->payload pointer in the first
|
||||||
pbuf to data in one of the later pbufs. We also set the
|
pbuf to data in one of the later pbufs. We also set the
|
||||||
inseg.data pointer to point to the right place. This way, the
|
inseg.data pointer to point to the right place. This way, the
|
||||||
->p pointer will still point to the first pbuf, but the
|
->p pointer will still point to the first pbuf, but the
|
||||||
->p->payload pointer will point to data in another pbuf.
|
->p->payload pointer will point to data in another pbuf.
|
||||||
|
|
||||||
After we are done with adjusting the pbuf pointers we must
|
After we are done with adjusting the pbuf pointers we must
|
||||||
adjust the ->data pointer in the seg and the segment
|
adjust the ->data pointer in the seg and the segment
|
||||||
length.*/
|
length.*/
|
||||||
off = pcb->rcv_nxt - seqno;
|
off = pcb->rcv_nxt - seqno;
|
||||||
if (inseg.p->len < off) {
|
if (inseg.p->len < off) {
|
||||||
p = inseg.p;
|
p = inseg.p;
|
||||||
while (p->len < off) {
|
while (p->len < off) {
|
||||||
off -= p->len;
|
off -= p->len;
|
||||||
inseg.p->tot_len -= p->len;
|
inseg.p->tot_len -= p->len;
|
||||||
p->len = 0;
|
p->len = 0;
|
||||||
p = p->next;
|
p = p->next;
|
||||||
}
|
}
|
||||||
pbuf_header(p, -off);
|
pbuf_header(p, -off);
|
||||||
} else {
|
} else {
|
||||||
pbuf_header(inseg.p, -off);
|
pbuf_header(inseg.p, -off);
|
||||||
}
|
}
|
||||||
inseg.dataptr = inseg.p->payload;
|
inseg.dataptr = inseg.p->payload;
|
||||||
inseg.len -= pcb->rcv_nxt - seqno;
|
inseg.len -= pcb->rcv_nxt - seqno;
|
||||||
inseg.tcphdr->seqno = seqno = pcb->rcv_nxt;
|
inseg.tcphdr->seqno = seqno = pcb->rcv_nxt;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
/* 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));
|
DEBUGF(TCP_INPUT_DEBUG, ("tcp_receive: duplicate seqno %lu\n", seqno));
|
||||||
tcp_ack_now(pcb);
|
tcp_ack_now(pcb);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -892,206 +892,206 @@ tcp_receive(struct tcp_pcb *pcb)
|
|||||||
processed. */
|
processed. */
|
||||||
if (TCP_SEQ_GEQ(seqno, pcb->rcv_nxt) &&
|
if (TCP_SEQ_GEQ(seqno, pcb->rcv_nxt) &&
|
||||||
TCP_SEQ_LT(seqno, pcb->rcv_nxt + pcb->rcv_wnd)) {
|
TCP_SEQ_LT(seqno, pcb->rcv_nxt + pcb->rcv_wnd)) {
|
||||||
if (pcb->rcv_nxt == seqno) {
|
if (pcb->rcv_nxt == seqno) {
|
||||||
/* The incoming segment is the next in sequence. We check if
|
/* The incoming segment is the next in sequence. We check if
|
||||||
we have to trim the end of the segment and update rcv_nxt
|
we have to trim the end of the segment and update rcv_nxt
|
||||||
and pass the data to the application. */
|
and pass the data to the application. */
|
||||||
#if TCP_QUEUE_OOSEQ
|
#if TCP_QUEUE_OOSEQ
|
||||||
if (pcb->ooseq != NULL &&
|
if (pcb->ooseq != NULL &&
|
||||||
TCP_SEQ_LEQ(pcb->ooseq->tcphdr->seqno, seqno + inseg.len)) {
|
TCP_SEQ_LEQ(pcb->ooseq->tcphdr->seqno, seqno + inseg.len)) {
|
||||||
/* We have to trim the second edge of the incoming
|
/* We have to trim the second edge of the incoming
|
||||||
segment. */
|
segment. */
|
||||||
inseg.len = pcb->ooseq->tcphdr->seqno - seqno;
|
inseg.len = pcb->ooseq->tcphdr->seqno - seqno;
|
||||||
pbuf_realloc(inseg.p, inseg.len);
|
pbuf_realloc(inseg.p, inseg.len);
|
||||||
}
|
}
|
||||||
#endif /* TCP_QUEUE_OOSEQ */
|
#endif /* TCP_QUEUE_OOSEQ */
|
||||||
|
|
||||||
tcplen = TCP_TCPLEN(&inseg);
|
tcplen = TCP_TCPLEN(&inseg);
|
||||||
|
|
||||||
pcb->rcv_nxt += tcplen;
|
pcb->rcv_nxt += tcplen;
|
||||||
|
|
||||||
/* Update the receiver's (our) window. */
|
/* Update the receiver's (our) window. */
|
||||||
if (pcb->rcv_wnd < tcplen) {
|
if (pcb->rcv_wnd < tcplen) {
|
||||||
pcb->rcv_wnd = 0;
|
pcb->rcv_wnd = 0;
|
||||||
} else {
|
} else {
|
||||||
pcb->rcv_wnd -= tcplen;
|
pcb->rcv_wnd -= tcplen;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If there is data in the segment, we make preparations to
|
/* If there is data in the segment, we make preparations to
|
||||||
pass this up to the application. The ->recv_data variable
|
pass this up to the application. The ->recv_data variable
|
||||||
is used for holding the pbuf that goes to the
|
is used for holding the pbuf that goes to the
|
||||||
application. The code for reassembling out-of-sequence data
|
application. The code for reassembling out-of-sequence data
|
||||||
chains its data on this pbuf as well.
|
chains its data on this pbuf as well.
|
||||||
|
|
||||||
If the segment was a FIN, we set the TF_GOT_FIN flag that will
|
If the segment was a FIN, we set the TF_GOT_FIN flag that will
|
||||||
be used to indicate to the application that the remote side has
|
be used to indicate to the application that the remote side has
|
||||||
closed its end of the connection. */
|
closed its end of the connection. */
|
||||||
if (inseg.p->tot_len > 0) {
|
if (inseg.p->tot_len > 0) {
|
||||||
recv_data = inseg.p;
|
recv_data = inseg.p;
|
||||||
/* Since this pbuf now is the responsibility of the
|
/* Since this pbuf now is the responsibility of the
|
||||||
application, we delete our reference to it so that we won't
|
application, we delete our reference to it so that we won't
|
||||||
(mistakingly) deallocate it. */
|
(mistakingly) deallocate it. */
|
||||||
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."));
|
DEBUGF(TCP_INPUT_DEBUG, ("tcp_receive: received FIN."));
|
||||||
recv_flags = TF_GOT_FIN;
|
recv_flags = TF_GOT_FIN;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if TCP_QUEUE_OOSEQ
|
#if TCP_QUEUE_OOSEQ
|
||||||
/* We now check if we have segments on the ->ooseq queue that
|
/* We now check if we have segments on the ->ooseq queue that
|
||||||
is now in sequence. */
|
is now in sequence. */
|
||||||
while (pcb->ooseq != NULL &&
|
while (pcb->ooseq != NULL &&
|
||||||
pcb->ooseq->tcphdr->seqno == pcb->rcv_nxt) {
|
pcb->ooseq->tcphdr->seqno == pcb->rcv_nxt) {
|
||||||
|
|
||||||
cseg = pcb->ooseq;
|
cseg = pcb->ooseq;
|
||||||
seqno = pcb->ooseq->tcphdr->seqno;
|
seqno = pcb->ooseq->tcphdr->seqno;
|
||||||
|
|
||||||
pcb->rcv_nxt += TCP_TCPLEN(cseg);
|
pcb->rcv_nxt += TCP_TCPLEN(cseg);
|
||||||
if (pcb->rcv_wnd < TCP_TCPLEN(cseg)) {
|
if (pcb->rcv_wnd < TCP_TCPLEN(cseg)) {
|
||||||
pcb->rcv_wnd = 0;
|
pcb->rcv_wnd = 0;
|
||||||
} else {
|
} else {
|
||||||
pcb->rcv_wnd -= TCP_TCPLEN(cseg);
|
pcb->rcv_wnd -= TCP_TCPLEN(cseg);
|
||||||
}
|
}
|
||||||
if (cseg->p->tot_len > 0) {
|
if (cseg->p->tot_len > 0) {
|
||||||
/* Chain this pbuf onto the pbuf that we will pass to
|
/* Chain this pbuf onto the pbuf that we will pass to
|
||||||
the application. */
|
the application. */
|
||||||
if (recv_data) {
|
if (recv_data) {
|
||||||
pbuf_chain(recv_data, cseg->p);
|
pbuf_chain(recv_data, cseg->p);
|
||||||
pbuf_free(cseg->p);
|
pbuf_free(cseg->p);
|
||||||
} else {
|
} else {
|
||||||
recv_data = cseg->p;
|
recv_data = cseg->p;
|
||||||
}
|
}
|
||||||
cseg->p = NULL;
|
cseg->p = NULL;
|
||||||
}
|
}
|
||||||
if (flags & TCP_FIN) {
|
if (flags & TCP_FIN) {
|
||||||
DEBUGF(TCP_INPUT_DEBUG, ("tcp_receive: dequeued FIN."));
|
DEBUGF(TCP_INPUT_DEBUG, ("tcp_receive: dequeued FIN."));
|
||||||
recv_flags = TF_GOT_FIN;
|
recv_flags = TF_GOT_FIN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
pcb->ooseq = cseg->next;
|
pcb->ooseq = cseg->next;
|
||||||
tcp_seg_free(cseg);
|
tcp_seg_free(cseg);
|
||||||
}
|
}
|
||||||
#endif /* TCP_QUEUE_OOSEQ */
|
#endif /* TCP_QUEUE_OOSEQ */
|
||||||
|
|
||||||
|
|
||||||
/* Acknowledge the segment(s). */
|
/* Acknowledge the segment(s). */
|
||||||
tcp_ack(pcb);
|
tcp_ack(pcb);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
/* We get here if the incoming segment is out-of-sequence. */
|
/* We get here if the incoming segment is out-of-sequence. */
|
||||||
tcp_ack_now(pcb);
|
tcp_ack_now(pcb);
|
||||||
#if TCP_QUEUE_OOSEQ
|
#if TCP_QUEUE_OOSEQ
|
||||||
/* We queue the segment on the ->ooseq queue. */
|
/* We queue the segment on the ->ooseq queue. */
|
||||||
if (pcb->ooseq == NULL) {
|
if (pcb->ooseq == NULL) {
|
||||||
pcb->ooseq = tcp_seg_copy(&inseg);
|
pcb->ooseq = tcp_seg_copy(&inseg);
|
||||||
} else {
|
} else {
|
||||||
/* If the queue is not empty, we walk through the queue and
|
/* If the queue is not empty, we walk through the queue and
|
||||||
try to find a place where the sequence number of the
|
try to find a place where the sequence number of the
|
||||||
incoming segment is between the sequence numbers of the
|
incoming segment is between the sequence numbers of the
|
||||||
previous and the next segment on the ->ooseq queue. That is
|
previous and the next segment on the ->ooseq queue. That is
|
||||||
the place where we put the incoming segment. If needed, we
|
the place where we put the incoming segment. If needed, we
|
||||||
trim the second edges of the previous and the incoming
|
trim the second edges of the previous and the incoming
|
||||||
segment so that it will fit into the sequence.
|
segment so that it will fit into the sequence.
|
||||||
|
|
||||||
If the incoming segment has the same sequence number as a
|
If the incoming segment has the same sequence number as a
|
||||||
segment on the ->ooseq queue, we discard the segment that
|
segment on the ->ooseq queue, we discard the segment that
|
||||||
contains less data. */
|
contains less data. */
|
||||||
|
|
||||||
prev = NULL;
|
prev = NULL;
|
||||||
for(next = pcb->ooseq; next != NULL; next = next->next) {
|
for(next = pcb->ooseq; next != NULL; next = next->next) {
|
||||||
if (seqno == next->tcphdr->seqno) {
|
if (seqno == next->tcphdr->seqno) {
|
||||||
/* The sequence number of the incoming segment is the
|
/* The sequence number of the incoming segment is the
|
||||||
same as the sequence number of the segment on
|
same as the sequence number of the segment on
|
||||||
->ooseq. We check the lengths to see which one to
|
->ooseq. We check the lengths to see which one to
|
||||||
discard. */
|
discard. */
|
||||||
if (inseg.len > next->len) {
|
if (inseg.len > next->len) {
|
||||||
/* The incoming segment is larger than the old
|
/* The incoming segment is larger than the old
|
||||||
segment. We replace the old segment with the new
|
segment. We replace the old segment with the new
|
||||||
one. */
|
one. */
|
||||||
cseg = tcp_seg_copy(&inseg);
|
cseg = tcp_seg_copy(&inseg);
|
||||||
if (cseg != NULL) {
|
if (cseg != NULL) {
|
||||||
cseg->next = next->next;
|
cseg->next = next->next;
|
||||||
if (prev != NULL) {
|
if (prev != NULL) {
|
||||||
prev->next = cseg;
|
prev->next = cseg;
|
||||||
} else {
|
} else {
|
||||||
pcb->ooseq = cseg;
|
pcb->ooseq = cseg;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
/* Either the lenghts are the same or the incoming
|
/* Either the lenghts are the same or the incoming
|
||||||
segment was smaller than the old one; in either
|
segment was smaller than the old one; in either
|
||||||
case, we ditch the incoming segment. */
|
case, we ditch the incoming segment. */
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (prev == NULL) {
|
if (prev == NULL) {
|
||||||
if (TCP_SEQ_LT(seqno, next->tcphdr->seqno)) {
|
if (TCP_SEQ_LT(seqno, next->tcphdr->seqno)) {
|
||||||
/* The sequence number of the incoming segment is lower
|
/* The sequence number of the incoming segment is lower
|
||||||
than the sequence number of the first segment on the
|
than the sequence number of the first segment on the
|
||||||
queue. We put the incoming segment first on the
|
queue. We put the incoming segment first on the
|
||||||
queue. */
|
queue. */
|
||||||
|
|
||||||
if (TCP_SEQ_GT(seqno + inseg.len, next->tcphdr->seqno)) {
|
if (TCP_SEQ_GT(seqno + inseg.len, next->tcphdr->seqno)) {
|
||||||
/* We need to trim the incoming segment. */
|
/* We need to trim the incoming segment. */
|
||||||
inseg.len = next->tcphdr->seqno - seqno;
|
inseg.len = next->tcphdr->seqno - seqno;
|
||||||
pbuf_realloc(inseg.p, inseg.len);
|
pbuf_realloc(inseg.p, inseg.len);
|
||||||
}
|
}
|
||||||
cseg = tcp_seg_copy(&inseg);
|
cseg = tcp_seg_copy(&inseg);
|
||||||
if (cseg != NULL) {
|
if (cseg != NULL) {
|
||||||
cseg->next = next;
|
cseg->next = next;
|
||||||
pcb->ooseq = cseg;
|
pcb->ooseq = cseg;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else if (TCP_SEQ_LT(prev->tcphdr->seqno, seqno) &&
|
} else if (TCP_SEQ_LT(prev->tcphdr->seqno, seqno) &&
|
||||||
TCP_SEQ_LT(seqno, next->tcphdr->seqno)) {
|
TCP_SEQ_LT(seqno, next->tcphdr->seqno)) {
|
||||||
/* The sequence number of the incoming segment is in
|
/* The sequence number of the incoming segment is in
|
||||||
between the sequence numbers of the previous and
|
between the sequence numbers of the previous and
|
||||||
the next segment on ->ooseq. We trim and insert the
|
the next segment on ->ooseq. We trim and insert the
|
||||||
incoming segment and trim the previous segment, if
|
incoming segment and trim the previous segment, if
|
||||||
needed. */
|
needed. */
|
||||||
if (TCP_SEQ_GT(seqno + inseg.len, next->tcphdr->seqno)) {
|
if (TCP_SEQ_GT(seqno + inseg.len, next->tcphdr->seqno)) {
|
||||||
/* We need to trim the incoming segment. */
|
/* We need to trim the incoming segment. */
|
||||||
inseg.len = next->tcphdr->seqno - seqno;
|
inseg.len = next->tcphdr->seqno - seqno;
|
||||||
pbuf_realloc(inseg.p, inseg.len);
|
pbuf_realloc(inseg.p, inseg.len);
|
||||||
}
|
}
|
||||||
|
|
||||||
cseg = tcp_seg_copy(&inseg);
|
cseg = tcp_seg_copy(&inseg);
|
||||||
if (cseg != NULL) {
|
if (cseg != NULL) {
|
||||||
cseg->next = next;
|
cseg->next = next;
|
||||||
prev->next = cseg;
|
prev->next = cseg;
|
||||||
if (TCP_SEQ_GT(prev->tcphdr->seqno + prev->len, seqno)) {
|
if (TCP_SEQ_GT(prev->tcphdr->seqno + prev->len, seqno)) {
|
||||||
/* We need to trim the prev segment. */
|
/* We need to trim the prev segment. */
|
||||||
prev->len = seqno - prev->tcphdr->seqno;
|
prev->len = seqno - prev->tcphdr->seqno;
|
||||||
pbuf_realloc(prev->p, prev->len);
|
pbuf_realloc(prev->p, prev->len);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* If the "next" segment is the last segment on the
|
/* If the "next" segment is the last segment on the
|
||||||
ooseq queue, we add the incoming segment to the end
|
ooseq queue, we add the incoming segment to the end
|
||||||
of the list. */
|
of the list. */
|
||||||
if (next->next == NULL &&
|
if (next->next == NULL &&
|
||||||
TCP_SEQ_GT(seqno, next->tcphdr->seqno)) {
|
TCP_SEQ_GT(seqno, next->tcphdr->seqno)) {
|
||||||
next->next = tcp_seg_copy(&inseg);
|
next->next = tcp_seg_copy(&inseg);
|
||||||
if (next->next != NULL) {
|
if (next->next != NULL) {
|
||||||
if (TCP_SEQ_GT(next->tcphdr->seqno + next->len, seqno)) {
|
if (TCP_SEQ_GT(next->tcphdr->seqno + next->len, seqno)) {
|
||||||
/* We need to trim the last segment. */
|
/* We need to trim the last segment. */
|
||||||
next->len = seqno - next->tcphdr->seqno;
|
next->len = seqno - next->tcphdr->seqno;
|
||||||
pbuf_realloc(next->p, next->len);
|
pbuf_realloc(next->p, next->len);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
prev = next;
|
prev = next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif /* TCP_QUEUE_OOSEQ */
|
#endif /* TCP_QUEUE_OOSEQ */
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -1127,7 +1127,7 @@ tcp_parseopt(struct tcp_pcb *pcb)
|
|||||||
opt = opts[c];
|
opt = opts[c];
|
||||||
if (opt == 0x00) {
|
if (opt == 0x00) {
|
||||||
/* End of options. */
|
/* End of options. */
|
||||||
break;
|
break;
|
||||||
} else if (opt == 0x01) {
|
} else if (opt == 0x01) {
|
||||||
++c;
|
++c;
|
||||||
/* NOP option. */
|
/* NOP option. */
|
||||||
@ -1140,7 +1140,7 @@ tcp_parseopt(struct tcp_pcb *pcb)
|
|||||||
/* And we are done processing options. */
|
/* And we are done processing options. */
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
if (opts[c + 1] == 0) {
|
if (opts[c + 1] == 0) {
|
||||||
/* If the length field is zero, the options are malformed
|
/* If the length field is zero, the options are malformed
|
||||||
and we don't process them further. */
|
and we don't process them further. */
|
||||||
break;
|
break;
|
||||||
|
@ -92,7 +92,7 @@ tcp_write(struct tcp_pcb *pcb, const void *arg, u16_t len, u8_t copy)
|
|||||||
/*-----------------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------------*/
|
||||||
err_t
|
err_t
|
||||||
tcp_enqueue(struct tcp_pcb *pcb, void *arg, u16_t len,
|
tcp_enqueue(struct tcp_pcb *pcb, void *arg, u16_t len,
|
||||||
u8_t flags, u8_t copy,
|
u8_t flags, u8_t copy,
|
||||||
u8_t *optdata, u8_t optlen)
|
u8_t *optdata, u8_t optlen)
|
||||||
{
|
{
|
||||||
struct pbuf *p;
|
struct pbuf *p;
|
||||||
@ -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));
|
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"));
|
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"));
|
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));
|
DEBUGF(TCP_OUTPUT_DEBUG | 2, ("tcp_enqueue: queue too long %d (%d)\n", queuelen, TCP_SND_QUEUELEN));
|
||||||
goto memerr;
|
goto memerr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -400,10 +400,10 @@ tcp_output(struct tcp_pcb *pcb)
|
|||||||
|
|
||||||
tcphdr->chksum = 0;
|
tcphdr->chksum = 0;
|
||||||
tcphdr->chksum = inet_chksum_pseudo(p, &(pcb->local_ip), &(pcb->remote_ip),
|
tcphdr->chksum = inet_chksum_pseudo(p, &(pcb->local_ip), &(pcb->remote_ip),
|
||||||
IP_PROTO_TCP, p->tot_len);
|
IP_PROTO_TCP, p->tot_len);
|
||||||
|
|
||||||
ip_output(p, &(pcb->local_ip), &(pcb->remote_ip), TCP_TTL,
|
ip_output(p, &(pcb->local_ip), &(pcb->remote_ip), TCP_TTL,
|
||||||
IP_PROTO_TCP);
|
IP_PROTO_TCP);
|
||||||
pbuf_free(p);
|
pbuf_free(p);
|
||||||
|
|
||||||
return ERR_OK;
|
return ERR_OK;
|
||||||
@ -428,7 +428,7 @@ tcp_output(struct tcp_pcb *pcb)
|
|||||||
#endif /* TCP_CWND_DEBUG */
|
#endif /* TCP_CWND_DEBUG */
|
||||||
|
|
||||||
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",
|
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,
|
||||||
@ -455,8 +455,8 @@ tcp_output(struct tcp_pcb *pcb)
|
|||||||
seg->next = NULL;
|
seg->next = NULL;
|
||||||
if (pcb->unacked == NULL) {
|
if (pcb->unacked == NULL) {
|
||||||
pcb->unacked = seg;
|
pcb->unacked = seg;
|
||||||
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
for (useg = pcb->unacked; useg->next != NULL; useg = useg->next);
|
for (useg = pcb->unacked; useg->next != NULL; useg = useg->next);
|
||||||
useg->next = seg;
|
useg->next = seg;
|
||||||
@ -506,8 +506,8 @@ tcp_output_segment(struct tcp_seg *seg, struct tcp_pcb *pcb)
|
|||||||
DEBUGF(TCP_RTO_DEBUG, ("tcp_output_segment: rtseq %lu\n", pcb->rtseq));
|
DEBUGF(TCP_RTO_DEBUG, ("tcp_output_segment: rtseq %lu\n", pcb->rtseq));
|
||||||
}
|
}
|
||||||
DEBUGF(TCP_OUTPUT_DEBUG, ("tcp_output_segment: %lu:%lu\n",
|
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));
|
||||||
|
|
||||||
len = (u16_t)((u8_t *)seg->tcphdr - (u8_t *)seg->p->payload);
|
len = (u16_t)((u8_t *)seg->tcphdr - (u8_t *)seg->p->payload);
|
||||||
|
|
||||||
@ -518,21 +518,21 @@ tcp_output_segment(struct tcp_seg *seg, struct tcp_pcb *pcb)
|
|||||||
|
|
||||||
seg->tcphdr->chksum = 0;
|
seg->tcphdr->chksum = 0;
|
||||||
seg->tcphdr->chksum = inet_chksum_pseudo(seg->p,
|
seg->tcphdr->chksum = inet_chksum_pseudo(seg->p,
|
||||||
&(pcb->local_ip),
|
&(pcb->local_ip),
|
||||||
&(pcb->remote_ip),
|
&(pcb->remote_ip),
|
||||||
IP_PROTO_TCP, seg->p->tot_len);
|
IP_PROTO_TCP, seg->p->tot_len);
|
||||||
#ifdef TCP_STATS
|
#ifdef TCP_STATS
|
||||||
++lwip_stats.tcp.xmit;
|
++lwip_stats.tcp.xmit;
|
||||||
#endif /* TCP_STATS */
|
#endif /* TCP_STATS */
|
||||||
|
|
||||||
ip_output(seg->p, &(pcb->local_ip), &(pcb->remote_ip), TCP_TTL,
|
ip_output(seg->p, &(pcb->local_ip), &(pcb->remote_ip), TCP_TTL,
|
||||||
IP_PROTO_TCP);
|
IP_PROTO_TCP);
|
||||||
}
|
}
|
||||||
/*-----------------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------------*/
|
||||||
void
|
void
|
||||||
tcp_rst(u32_t seqno, u32_t ackno,
|
tcp_rst(u32_t seqno, u32_t ackno,
|
||||||
struct ip_addr *local_ip, struct ip_addr *remote_ip,
|
struct ip_addr *local_ip, struct ip_addr *remote_ip,
|
||||||
u16_t local_port, u16_t remote_port)
|
u16_t local_port, u16_t remote_port)
|
||||||
{
|
{
|
||||||
struct pbuf *p;
|
struct pbuf *p;
|
||||||
struct tcp_hdr *tcphdr;
|
struct tcp_hdr *tcphdr;
|
||||||
@ -554,7 +554,7 @@ tcp_rst(u32_t seqno, u32_t ackno,
|
|||||||
|
|
||||||
tcphdr->chksum = 0;
|
tcphdr->chksum = 0;
|
||||||
tcphdr->chksum = inet_chksum_pseudo(p, local_ip, remote_ip,
|
tcphdr->chksum = inet_chksum_pseudo(p, local_ip, remote_ip,
|
||||||
IP_PROTO_TCP, p->tot_len);
|
IP_PROTO_TCP, p->tot_len);
|
||||||
|
|
||||||
#ifdef TCP_STATS
|
#ifdef TCP_STATS
|
||||||
++lwip_stats.tcp.xmit;
|
++lwip_stats.tcp.xmit;
|
||||||
|
229
src/core/udp.c
229
src/core/udp.c
@ -5,9 +5,9 @@
|
|||||||
*/
|
*/
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2001-2003 Swedish Institute of Computer Science.
|
* Copyright (c) 2001-2003 Swedish Institute of Computer Science.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without modification,
|
* Redistribution and use in source and binary forms, with or without modification,
|
||||||
* are permitted provided that the following conditions are met:
|
* are permitted provided that the following conditions are met:
|
||||||
*
|
*
|
||||||
* 1. Redistributions of source code must retain the above copyright notice,
|
* 1. Redistributions of source code must retain the above copyright notice,
|
||||||
@ -16,21 +16,21 @@
|
|||||||
* this list of conditions and the following disclaimer in the documentation
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
* and/or other materials provided with the distribution.
|
* and/or other materials provided with the distribution.
|
||||||
* 3. The name of the author may not be used to endorse or promote products
|
* 3. The name of the author may not be used to endorse or promote products
|
||||||
* derived from this software without specific prior written permission.
|
* derived from this software without specific prior written permission.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||||
* OF SUCH DAMAGE.
|
* OF SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* This file is part of the lwIP TCP/IP stack.
|
* This file is part of the lwIP TCP/IP stack.
|
||||||
*
|
*
|
||||||
* Author: Adam Dunkels <adam@sics.se>
|
* Author: Adam Dunkels <adam@sics.se>
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@ -67,7 +67,7 @@ static struct udp_pcb *pcb_cache = NULL;
|
|||||||
#if UDP_DEBUG
|
#if UDP_DEBUG
|
||||||
int udp_debug_print(struct udp_hdr *udphdr);
|
int udp_debug_print(struct udp_hdr *udphdr);
|
||||||
#endif /* UDP_DEBUG */
|
#endif /* UDP_DEBUG */
|
||||||
|
|
||||||
/*-----------------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------------*/
|
||||||
void
|
void
|
||||||
udp_init(void)
|
udp_init(void)
|
||||||
@ -108,28 +108,28 @@ udp_lookup(struct ip_hdr *iphdr, struct netif *inp)
|
|||||||
ip_addr_cmp(&(pcb->local_ip), &(iphdr->dest)))) {
|
ip_addr_cmp(&(pcb->local_ip), &(iphdr->dest)))) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
for(pcb = udp_pcbs; pcb != NULL; pcb = pcb->next) {
|
for(pcb = udp_pcbs; pcb != NULL; pcb = pcb->next) {
|
||||||
if (pcb->remote_port == src &&
|
if (pcb->remote_port == src &&
|
||||||
pcb->local_port == dest &&
|
pcb->local_port == dest &&
|
||||||
(ip_addr_isany(&pcb->remote_ip) ||
|
(ip_addr_isany(&pcb->remote_ip) ||
|
||||||
ip_addr_cmp(&(pcb->remote_ip), &(iphdr->src))) &&
|
ip_addr_cmp(&(pcb->remote_ip), &(iphdr->src))) &&
|
||||||
(ip_addr_isany(&pcb->local_ip) ||
|
(ip_addr_isany(&pcb->local_ip) ||
|
||||||
ip_addr_cmp(&(pcb->local_ip), &(iphdr->dest)))) {
|
ip_addr_cmp(&(pcb->local_ip), &(iphdr->dest)))) {
|
||||||
pcb_cache = pcb;
|
pcb_cache = pcb;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pcb == NULL) {
|
if (pcb == NULL) {
|
||||||
for(pcb = udp_pcbs; pcb != NULL; pcb = pcb->next) {
|
for(pcb = udp_pcbs; pcb != NULL; pcb = pcb->next) {
|
||||||
if (pcb->remote_port == 0 &&
|
if (pcb->remote_port == 0 &&
|
||||||
pcb->local_port == dest &&
|
pcb->local_port == dest &&
|
||||||
(ip_addr_isany(&pcb->remote_ip) ||
|
(ip_addr_isany(&pcb->remote_ip) ||
|
||||||
ip_addr_cmp(&(pcb->remote_ip), &(iphdr->src))) &&
|
ip_addr_cmp(&(pcb->remote_ip), &(iphdr->src))) &&
|
||||||
(ip_addr_isany(&pcb->local_ip) ||
|
(ip_addr_isany(&pcb->local_ip) ||
|
||||||
ip_addr_cmp(&(pcb->local_ip), &(iphdr->dest)))) {
|
ip_addr_cmp(&(pcb->local_ip), &(iphdr->dest)))) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -140,7 +140,7 @@ udp_lookup(struct ip_hdr *iphdr, struct netif *inp)
|
|||||||
if (pcb != NULL) {
|
if (pcb != NULL) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -154,18 +154,17 @@ udp_lookup(struct ip_hdr *iphdr, struct netif *inp)
|
|||||||
* @param pbuf pbuf to be demultiplexed to a UDP PCB.
|
* @param pbuf pbuf to be demultiplexed to a UDP PCB.
|
||||||
* @param netif network interface on which the datagram was received.
|
* @param netif network interface on which the datagram was received.
|
||||||
*
|
*
|
||||||
* @see udp_disconnect()
|
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
udp_input(struct pbuf *p, struct netif *inp)
|
udp_input(struct pbuf *p, struct netif *inp)
|
||||||
{
|
{
|
||||||
struct udp_hdr *udphdr;
|
struct udp_hdr *udphdr;
|
||||||
struct udp_pcb *pcb;
|
struct udp_pcb *pcb;
|
||||||
struct ip_hdr *iphdr;
|
struct ip_hdr *iphdr;
|
||||||
u16_t src, dest;
|
u16_t src, dest;
|
||||||
|
|
||||||
PERF_START;
|
PERF_START;
|
||||||
|
|
||||||
#ifdef UDP_STATS
|
#ifdef UDP_STATS
|
||||||
++lwip_stats.udp.recv;
|
++lwip_stats.udp.recv;
|
||||||
#endif /* UDP_STATS */
|
#endif /* UDP_STATS */
|
||||||
@ -174,20 +173,20 @@ 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));
|
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;
|
||||||
#endif /* UDP_STATS */
|
#endif /* UDP_STATS */
|
||||||
snmp_inc_udpinerrors();
|
snmp_inc_udpinerrors();
|
||||||
pbuf_free(p);
|
pbuf_free(p);
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
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));
|
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);
|
||||||
|
|
||||||
@ -217,11 +216,11 @@ udp_input(struct pbuf *p, struct netif *inp)
|
|||||||
/* accepting from any remote (source) IP address? or... */
|
/* accepting from any remote (source) IP address? or... */
|
||||||
(ip_addr_isany(&pcb->remote_ip) ||
|
(ip_addr_isany(&pcb->remote_ip) ||
|
||||||
/* PCB remote IP address matches UDP source IP address? */
|
/* PCB remote IP address matches UDP source IP address? */
|
||||||
ip_addr_cmp(&(pcb->remote_ip), &(iphdr->src))) &&
|
ip_addr_cmp(&(pcb->remote_ip), &(iphdr->src))) &&
|
||||||
/* accepting on any local (netif) IP address? or... */
|
/* accepting on any local (netif) IP address? or... */
|
||||||
(ip_addr_isany(&pcb->local_ip) ||
|
(ip_addr_isany(&pcb->local_ip) ||
|
||||||
/* PCB local IP address matches UDP destination IP address? */
|
/* PCB local IP address matches UDP destination IP address? */
|
||||||
ip_addr_cmp(&(pcb->local_ip), &(iphdr->dest)))) {
|
ip_addr_cmp(&(pcb->local_ip), &(iphdr->dest)))) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -237,73 +236,73 @@ udp_input(struct pbuf *p, struct netif *inp)
|
|||||||
ip4_addr3(&pcb->remote_ip), ip4_addr4(&pcb->remote_ip), pcb->remote_port));
|
ip4_addr3(&pcb->remote_ip), ip4_addr4(&pcb->remote_ip), pcb->remote_port));
|
||||||
/* unconnected? */
|
/* unconnected? */
|
||||||
if (((pcb->flags & UDP_FLAGS_CONNECTED) == 0) &&
|
if (((pcb->flags & UDP_FLAGS_CONNECTED) == 0) &&
|
||||||
/* destination port matches? */
|
/* destination port matches? */
|
||||||
(pcb->local_port == dest) &&
|
(pcb->local_port == dest) &&
|
||||||
/* not bound to a specific (local) interface address? or... */
|
/* not bound to a specific (local) interface address? or... */
|
||||||
(ip_addr_isany(&pcb->local_ip) ||
|
(ip_addr_isany(&pcb->local_ip) ||
|
||||||
/* ...matching interface address? */
|
/* ...matching interface address? */
|
||||||
ip_addr_cmp(&(pcb->local_ip), &(iphdr->dest)))) {
|
ip_addr_cmp(&(pcb->local_ip), &(iphdr->dest)))) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 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"));
|
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) {
|
||||||
#else
|
#else
|
||||||
if (IPH_PROTO(iphdr) == IP_PROTO_UDPLITE) {
|
if (IPH_PROTO(iphdr) == IP_PROTO_UDPLITE) {
|
||||||
#endif /* IPv4 */
|
#endif /* IPv4 */
|
||||||
/* Do the UDP Lite checksum */
|
/* Do the UDP Lite checksum */
|
||||||
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"));
|
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;
|
||||||
#endif /* UDP_STATS */
|
#endif /* UDP_STATS */
|
||||||
snmp_inc_udpinerrors();
|
snmp_inc_udpinerrors();
|
||||||
pbuf_free(p);
|
pbuf_free(p);
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (udphdr->chksum != 0) {
|
if (udphdr->chksum != 0) {
|
||||||
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"));
|
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;
|
||||||
++lwip_stats.udp.drop;
|
++lwip_stats.udp.drop;
|
||||||
#endif /* UDP_STATS */
|
#endif /* UDP_STATS */
|
||||||
snmp_inc_udpinerrors();
|
snmp_inc_udpinerrors();
|
||||||
pbuf_free(p);
|
pbuf_free(p);
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pbuf_header(p, -UDP_HLEN);
|
pbuf_header(p, -UDP_HLEN);
|
||||||
if (pcb != NULL) {
|
if (pcb != NULL) {
|
||||||
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"));
|
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. */
|
||||||
|
|
||||||
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)) {
|
||||||
|
|
||||||
/* adjust pbuf pointer */
|
/* adjust pbuf pointer */
|
||||||
p->payload = iphdr;
|
p->payload = iphdr;
|
||||||
icmp_dest_unreach(p, ICMP_DUR_PORT);
|
icmp_dest_unreach(p, ICMP_DUR_PORT);
|
||||||
}
|
}
|
||||||
#ifdef UDP_STATS
|
#ifdef UDP_STATS
|
||||||
++lwip_stats.udp.proterr;
|
++lwip_stats.udp.proterr;
|
||||||
@ -316,11 +315,11 @@ udp_input(struct pbuf *p, struct netif *inp)
|
|||||||
pbuf_free(p);
|
pbuf_free(p);
|
||||||
}
|
}
|
||||||
end:
|
end:
|
||||||
|
|
||||||
PERF_STOP("udp_input");
|
PERF_STOP("udp_input");
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Send data using UDP.
|
* Send data using UDP.
|
||||||
*
|
*
|
||||||
* @param pcb UDP PCB used to send the data.
|
* @param pcb UDP PCB used to send the data.
|
||||||
* @param pbuf chain of pbuf's to be sent.
|
* @param pbuf chain of pbuf's to be sent.
|
||||||
@ -330,7 +329,7 @@ udp_input(struct pbuf *p, struct netif *inp)
|
|||||||
* - ERR_MEM. Out of memory.
|
* - ERR_MEM. Out of memory.
|
||||||
* - ERR_USE. The specified ipaddr and port are already bound to by
|
* - ERR_USE. The specified ipaddr and port are already bound to by
|
||||||
* another UDP PCB.
|
* another UDP PCB.
|
||||||
*
|
*
|
||||||
* @see udp_disconnect()
|
* @see udp_disconnect()
|
||||||
*/
|
*/
|
||||||
err_t
|
err_t
|
||||||
@ -368,7 +367,7 @@ udp_send(struct udp_pcb *pcb, struct pbuf *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));
|
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));
|
DEBUGF(UDP_DEBUG, ("udp_send: added header in given pbuf %p\n", (void *)p));
|
||||||
@ -394,9 +393,9 @@ udp_send(struct udp_pcb *pcb, struct pbuf *p)
|
|||||||
/* use UDP PCB local IP address as source address */
|
/* use UDP PCB local IP address as source address */
|
||||||
src_ip = &(pcb->local_ip);
|
src_ip = &(pcb->local_ip);
|
||||||
}
|
}
|
||||||
|
|
||||||
DEBUGF(UDP_DEBUG, ("udp_send: sending datagram of length %u\n", q->tot_len));
|
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));
|
DEBUGF(UDP_DEBUG, ("udp_send: UDP LITE packet length %u\n", q->tot_len));
|
||||||
@ -404,11 +403,11 @@ udp_send(struct udp_pcb *pcb, struct pbuf *p)
|
|||||||
udphdr->len = htons(pcb->chksum_len);
|
udphdr->len = htons(pcb->chksum_len);
|
||||||
/* calculate checksum */
|
/* calculate checksum */
|
||||||
udphdr->chksum = inet_chksum_pseudo(q, src_ip, &(pcb->remote_ip),
|
udphdr->chksum = inet_chksum_pseudo(q, src_ip, &(pcb->remote_ip),
|
||||||
IP_PROTO_UDP, pcb->chksum_len);
|
IP_PROTO_UDP, pcb->chksum_len);
|
||||||
/* 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;
|
||||||
/* output to IP */
|
/* output to IP */
|
||||||
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));
|
DEBUGF(UDP_DEBUG, ("udp_send: UDP packet length %u\n", q->tot_len));
|
||||||
@ -423,7 +422,7 @@ udp_send(struct udp_pcb *pcb, struct pbuf *p)
|
|||||||
snmp_inc_udpoutdatagrams();
|
snmp_inc_udpoutdatagrams();
|
||||||
DEBUGF(UDP_DEBUG, ("udp_send: ip_output_if (,,,,IP_PROTO_UDP,)\n"));
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* did we chain a header earlier? */
|
/* did we chain a header earlier? */
|
||||||
@ -431,7 +430,7 @@ udp_send(struct udp_pcb *pcb, struct pbuf *p)
|
|||||||
/* free the header */
|
/* free the header */
|
||||||
pbuf_free(q);
|
pbuf_free(q);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef UDP_STATS
|
#ifdef UDP_STATS
|
||||||
++lwip_stats.udp.xmit;
|
++lwip_stats.udp.xmit;
|
||||||
#endif /* UDP_STATS */
|
#endif /* UDP_STATS */
|
||||||
@ -450,7 +449,7 @@ udp_send(struct udp_pcb *pcb, struct pbuf *p)
|
|||||||
* - ERR_OK. Successful. No error occured.
|
* - ERR_OK. Successful. No error occured.
|
||||||
* - ERR_USE. The specified ipaddr and port are already bound to by
|
* - ERR_USE. The specified ipaddr and port are already bound to by
|
||||||
* another UDP PCB.
|
* another UDP PCB.
|
||||||
*
|
*
|
||||||
* @see udp_disconnect()
|
* @see udp_disconnect()
|
||||||
*/
|
*/
|
||||||
err_t
|
err_t
|
||||||
@ -462,27 +461,27 @@ udp_bind(struct udp_pcb *pcb, struct ip_addr *ipaddr, u16_t 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) {
|
||||||
/* is this UDP PCB already on active list? */
|
/* is this UDP PCB already on active list? */
|
||||||
if (pcb == ipcb) {
|
if (pcb == ipcb) {
|
||||||
/* pcb may occur at most once in active list */
|
/* pcb may occur at most once in active list */
|
||||||
LWIP_ASSERT("rebind == 0", rebind == 0);
|
LWIP_ASSERT("rebind == 0", rebind == 0);
|
||||||
/* pcb already in list, just rebind */
|
/* pcb already in list, just rebind */
|
||||||
rebind = 1;
|
rebind = 1;
|
||||||
}
|
}
|
||||||
/* this code does not allow upper layer to share a UDP port for
|
/* this code does not allow upper layer to share a UDP port for
|
||||||
listening to broadcast or multicast traffic (See SO_REUSE_ADDR and
|
listening to broadcast or multicast traffic (See SO_REUSE_ADDR and
|
||||||
SO_REUSE_PORT under *BSD). TODO: See where it fits instead, OR
|
SO_REUSE_PORT under *BSD). TODO: See where it fits instead, OR
|
||||||
combine with implementation of UDP PCB flags. Leon Woestenberg. */
|
combine with implementation of UDP PCB flags. Leon Woestenberg. */
|
||||||
#if 0
|
#if 0
|
||||||
/* port matches that of PCB in list? */
|
/* port matches that of PCB in list? */
|
||||||
else if ((ipcb->local_port == port) &&
|
else if ((ipcb->local_port == port) &&
|
||||||
/* IP address matches, or one is IP_ADDR_ANY? */
|
/* IP address matches, or one is IP_ADDR_ANY? */
|
||||||
(ip_addr_isany(&(ipcb->local_ip)) ||
|
(ip_addr_isany(&(ipcb->local_ip)) ||
|
||||||
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));
|
DEBUGF(UDP_DEBUG, ("udp_bind: local port %u already bound by another pcb\n", port));
|
||||||
return ERR_USE;
|
return ERR_USE;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -501,13 +500,13 @@ udp_bind(struct udp_pcb *pcb, struct ip_addr *ipaddr, u16_t port)
|
|||||||
port++;
|
port++;
|
||||||
ipcb = udp_pcbs;
|
ipcb = udp_pcbs;
|
||||||
} else
|
} else
|
||||||
ipcb = ipcb->next;
|
ipcb = ipcb->next;
|
||||||
}
|
}
|
||||||
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"));
|
DEBUGF(UDP_DEBUG, ("udp_bind: out of free UDP ports\n"));
|
||||||
return ERR_USE;
|
return ERR_USE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pcb->local_port = port;
|
pcb->local_port = port;
|
||||||
/* pcb not active yet? */
|
/* pcb not active yet? */
|
||||||
@ -515,7 +514,7 @@ udp_bind(struct udp_pcb *pcb, struct ip_addr *ipaddr, u16_t port)
|
|||||||
/* place the PCB on the active list if not already there */
|
/* place the PCB on the active list if not already there */
|
||||||
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",
|
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),
|
||||||
@ -533,7 +532,7 @@ udp_bind(struct udp_pcb *pcb, struct ip_addr *ipaddr, u16_t port)
|
|||||||
* @param port remote UDP port to connect with.
|
* @param port remote UDP port to connect with.
|
||||||
*
|
*
|
||||||
* @return lwIP error code
|
* @return lwIP error code
|
||||||
*
|
*
|
||||||
* @see udp_disconnect()
|
* @see udp_disconnect()
|
||||||
*/
|
*/
|
||||||
err_t
|
err_t
|
||||||
@ -553,21 +552,21 @@ udp_connect(struct udp_pcb *pcb, struct ip_addr *ipaddr, u16_t port)
|
|||||||
/** TODO: this functionality belongs in upper layers */
|
/** TODO: this functionality belongs in upper layers */
|
||||||
#if 0
|
#if 0
|
||||||
/* Nail down local IP for netconn_addr()/getsockname() */
|
/* Nail down local IP for netconn_addr()/getsockname() */
|
||||||
if (ip_addr_isany(&pcb->local_ip) && !ip_addr_isany(&pcb->remote_ip)) {
|
if (ip_addr_isany(&pcb->local_ip) && !ip_addr_isany(&pcb->remote_ip)) {
|
||||||
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));
|
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 */
|
||||||
return ERR_RTE;
|
return ERR_RTE;
|
||||||
}
|
}
|
||||||
/** TODO: this will bind the udp pcb locally, to the interface which
|
/** TODO: this will bind the udp pcb locally, to the interface which
|
||||||
is used to route output packets to the remote address. However, we
|
is used to route output packets to the remote address. However, we
|
||||||
might want to accept incoming packets on any interface! */
|
might want to accept incoming packets on any interface! */
|
||||||
pcb->local_ip = netif->ip_addr;
|
pcb->local_ip = netif->ip_addr;
|
||||||
} else if (ip_addr_isany(&pcb->remote_ip)) {
|
} else if (ip_addr_isany(&pcb->remote_ip)) {
|
||||||
pcb->local_ip.addr = 0;
|
pcb->local_ip.addr = 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -593,14 +592,14 @@ udp_connect(struct udp_pcb *pcb, struct ip_addr *ipaddr, u16_t port)
|
|||||||
void
|
void
|
||||||
udp_disconnect(struct udp_pcb *pcb)
|
udp_disconnect(struct udp_pcb *pcb)
|
||||||
{
|
{
|
||||||
pcb->flags &= ~UDP_FLAGS_CONNECTED;
|
pcb->flags &= ~UDP_FLAGS_CONNECTED;
|
||||||
}
|
}
|
||||||
/*-----------------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------------*/
|
||||||
void
|
void
|
||||||
udp_recv(struct udp_pcb *pcb,
|
udp_recv(struct udp_pcb *pcb,
|
||||||
void (* recv)(void *arg, struct udp_pcb *upcb, struct pbuf *p,
|
void (* recv)(void *arg, struct udp_pcb *upcb, struct pbuf *p,
|
||||||
struct ip_addr *addr, u16_t port),
|
struct ip_addr *addr, u16_t port),
|
||||||
void *recv_arg)
|
void *recv_arg)
|
||||||
{
|
{
|
||||||
/* remember recv() callback and user data */
|
/* remember recv() callback and user data */
|
||||||
pcb->recv = recv;
|
pcb->recv = recv;
|
||||||
@ -611,7 +610,7 @@ udp_recv(struct udp_pcb *pcb,
|
|||||||
*
|
*
|
||||||
* @param pcb UDP PCB to be removed. The PCB is removed from the list of
|
* @param pcb UDP PCB to be removed. The PCB is removed from the list of
|
||||||
* UDP PCB's and the data structure is freed from memory.
|
* UDP PCB's and the data structure is freed from memory.
|
||||||
*
|
*
|
||||||
* @see udp_new()
|
* @see udp_new()
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
@ -630,14 +629,14 @@ udp_remove(struct udp_pcb *pcb)
|
|||||||
pcb2->next = pcb->next;
|
pcb2->next = pcb->next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
memp_free(MEMP_UDP_PCB, pcb);
|
memp_free(MEMP_UDP_PCB, pcb);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Create a UDP PCB.
|
* Create a UDP PCB.
|
||||||
*
|
*
|
||||||
* @return The UDP PCB which was created. NULL if the PCB data structure
|
* @return The UDP PCB which was created. NULL if the PCB data structure
|
||||||
* could not be allocated.
|
* could not be allocated.
|
||||||
*
|
*
|
||||||
* @see udp_remove()
|
* @see udp_remove()
|
||||||
*/
|
*/
|
||||||
struct udp_pcb *
|
struct udp_pcb *
|
||||||
@ -659,10 +658,10 @@ udp_debug_print(struct udp_hdr *udphdr)
|
|||||||
DEBUGF(UDP_DEBUG, ("UDP header:\n"));
|
DEBUGF(UDP_DEBUG, ("UDP header:\n"));
|
||||||
DEBUGF(UDP_DEBUG, ("+-------------------------------+\n"));
|
DEBUGF(UDP_DEBUG, ("+-------------------------------+\n"));
|
||||||
DEBUGF(UDP_DEBUG, ("| %5u | %5u | (src port, dest port)\n",
|
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"));
|
DEBUGF(UDP_DEBUG, ("+-------------------------------+\n"));
|
||||||
DEBUGF(UDP_DEBUG, ("| %5u | 0x%04x | (len, chksum)\n",
|
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"));
|
DEBUGF(UDP_DEBUG, ("+-------------------------------+\n"));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -108,4 +108,4 @@ PACK_STRUCT_END
|
|||||||
#define ICMPH_CODE_SET(hdr, code) ((hdr)->_type_code = htons((code) | (ICMPH_TYPE(hdr) << 8)))
|
#define ICMPH_CODE_SET(hdr, code) ((hdr)->_type_code = htons((code) | (ICMPH_TYPE(hdr) << 8)))
|
||||||
|
|
||||||
#endif /* __LWIP_ICMP_H__ */
|
#endif /* __LWIP_ICMP_H__ */
|
||||||
|
|
||||||
|
@ -41,8 +41,8 @@
|
|||||||
u16_t inet_chksum(void *dataptr, u16_t len);
|
u16_t inet_chksum(void *dataptr, u16_t len);
|
||||||
u16_t inet_chksum_pbuf(struct pbuf *p);
|
u16_t inet_chksum_pbuf(struct pbuf *p);
|
||||||
u16_t inet_chksum_pseudo(struct pbuf *p,
|
u16_t inet_chksum_pseudo(struct pbuf *p,
|
||||||
struct ip_addr *src, struct ip_addr *dest,
|
struct ip_addr *src, struct ip_addr *dest,
|
||||||
u8_t proto, u16_t proto_len);
|
u8_t proto, u16_t proto_len);
|
||||||
|
|
||||||
u32_t inet_addr(const char *cp);
|
u32_t inet_addr(const char *cp);
|
||||||
int inet_aton(const char *cp, struct in_addr *addr);
|
int inet_aton(const char *cp, struct in_addr *addr);
|
||||||
|
@ -47,10 +47,10 @@ u8_t ip_lookup(void *header, struct netif *inp);
|
|||||||
struct netif *ip_route(struct ip_addr *dest);
|
struct netif *ip_route(struct ip_addr *dest);
|
||||||
err_t ip_input(struct pbuf *p, struct netif *inp);
|
err_t ip_input(struct pbuf *p, struct netif *inp);
|
||||||
err_t ip_output(struct pbuf *p, struct ip_addr *src, struct ip_addr *dest,
|
err_t ip_output(struct pbuf *p, struct ip_addr *src, struct ip_addr *dest,
|
||||||
u8_t ttl, u8_t proto);
|
u8_t ttl, u8_t proto);
|
||||||
err_t ip_output_if(struct pbuf *p, struct ip_addr *src, struct ip_addr *dest,
|
err_t ip_output_if(struct pbuf *p, struct ip_addr *src, struct ip_addr *dest,
|
||||||
u8_t ttl, u8_t proto,
|
u8_t ttl, u8_t proto,
|
||||||
struct netif *netif);
|
struct netif *netif);
|
||||||
|
|
||||||
#define IP_HLEN 20
|
#define IP_HLEN 20
|
||||||
|
|
||||||
|
@ -40,30 +40,30 @@
|
|||||||
#define IP_ADDR_ANY ((struct ip_addr *)&ip_addr_any)
|
#define IP_ADDR_ANY ((struct ip_addr *)&ip_addr_any)
|
||||||
#define IP_ADDR_BROADCAST ((struct ip_addr *)&ip_addr_broadcast)
|
#define IP_ADDR_BROADCAST ((struct ip_addr *)&ip_addr_broadcast)
|
||||||
|
|
||||||
#define INADDR_NONE ((u32_t) 0xffffffff) /* 255.255.255.255 */
|
#define INADDR_NONE ((u32_t) 0xffffffff) /* 255.255.255.255 */
|
||||||
#define INADDR_LOOPBACK ((u32_t) 0x7f000001) /* 127.0.0.1 */
|
#define INADDR_LOOPBACK ((u32_t) 0x7f000001) /* 127.0.0.1 */
|
||||||
|
|
||||||
/* Definitions of the bits in an Internet address integer.
|
/* Definitions of the bits in an Internet address integer.
|
||||||
|
|
||||||
On subnets, host and network parts are found according to
|
On subnets, host and network parts are found according to
|
||||||
the subnet mask, not these masks. */
|
the subnet mask, not these masks. */
|
||||||
|
|
||||||
#define IN_CLASSA(a) ((((u32_t)(a)) & 0x80000000) == 0)
|
#define IN_CLASSA(a) ((((u32_t)(a)) & 0x80000000) == 0)
|
||||||
#define IN_CLASSA_NET 0xff000000
|
#define IN_CLASSA_NET 0xff000000
|
||||||
#define IN_CLASSA_NSHIFT 24
|
#define IN_CLASSA_NSHIFT 24
|
||||||
#define IN_CLASSA_HOST (0xffffffff & ~IN_CLASSA_NET)
|
#define IN_CLASSA_HOST (0xffffffff & ~IN_CLASSA_NET)
|
||||||
#define IN_CLASSA_MAX 128
|
#define IN_CLASSA_MAX 128
|
||||||
|
|
||||||
#define IN_CLASSB(a) ((((u32_t)(a)) & 0xc0000000) == 0x80000000)
|
#define IN_CLASSB(a) ((((u32_t)(a)) & 0xc0000000) == 0x80000000)
|
||||||
#define IN_CLASSB_NET 0xffff0000
|
#define IN_CLASSB_NET 0xffff0000
|
||||||
#define IN_CLASSB_NSHIFT 16
|
#define IN_CLASSB_NSHIFT 16
|
||||||
#define IN_CLASSB_HOST (0xffffffff & ~IN_CLASSB_NET)
|
#define IN_CLASSB_HOST (0xffffffff & ~IN_CLASSB_NET)
|
||||||
#define IN_CLASSB_MAX 65536
|
#define IN_CLASSB_MAX 65536
|
||||||
|
|
||||||
#define IN_CLASSC(a) ((((u32_t)(a)) & 0xe0000000) == 0xc0000000)
|
#define IN_CLASSC(a) ((((u32_t)(a)) & 0xe0000000) == 0xc0000000)
|
||||||
#define IN_CLASSC_NET 0xffffff00
|
#define IN_CLASSC_NET 0xffffff00
|
||||||
#define IN_CLASSC_NSHIFT 8
|
#define IN_CLASSC_NSHIFT 8
|
||||||
#define IN_CLASSC_HOST (0xffffffff & ~IN_CLASSC_NET)
|
#define IN_CLASSC_HOST (0xffffffff & ~IN_CLASSC_NET)
|
||||||
|
|
||||||
#define IN_CLASSD(a) (((u32_t)(a) & 0xf0000000) == 0xe0000000)
|
#define IN_CLASSD(a) (((u32_t)(a) & 0xf0000000) == 0xe0000000)
|
||||||
#define IN_CLASSD_NET 0xf0000000 /* These ones aren't really */
|
#define IN_CLASSD_NET 0xf0000000 /* These ones aren't really */
|
||||||
@ -90,7 +90,7 @@ PACK_STRUCT_END
|
|||||||
|
|
||||||
/* For compatibility with BSD code */
|
/* For compatibility with BSD code */
|
||||||
struct in_addr {
|
struct in_addr {
|
||||||
u32_t s_addr;
|
u32_t s_addr;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern const struct ip_addr ip_addr_any;
|
extern const struct ip_addr ip_addr_any;
|
||||||
@ -111,19 +111,19 @@ extern const struct ip_addr ip_addr_broadcast;
|
|||||||
#define ip_addr_isany(addr1) ((addr1) == NULL || (addr1)->addr == 0)
|
#define ip_addr_isany(addr1) ((addr1) == NULL || (addr1)->addr == 0)
|
||||||
|
|
||||||
#define ip_addr_isbroadcast(addr1, mask) (((((addr1)->addr) & ~((mask)->addr)) == \
|
#define ip_addr_isbroadcast(addr1, mask) (((((addr1)->addr) & ~((mask)->addr)) == \
|
||||||
(0xffffffff & ~((mask)->addr))) || \
|
(0xffffffff & ~((mask)->addr))) || \
|
||||||
((addr1)->addr == 0xffffffff) || \
|
((addr1)->addr == 0xffffffff) || \
|
||||||
((addr1)->addr == 0x00000000))
|
((addr1)->addr == 0x00000000))
|
||||||
|
|
||||||
|
|
||||||
#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) 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, \
|
||||||
(u8_t)ntohl((ipaddr)->addr) & 0xff))
|
(u8_t)ntohl((ipaddr)->addr) & 0xff))
|
||||||
|
|
||||||
|
|
||||||
#define ip4_addr1(ipaddr) ((u8_t)(ntohl((ipaddr)->addr) >> 24) & 0xff)
|
#define ip4_addr1(ipaddr) ((u8_t)(ntohl((ipaddr)->addr) >> 24) & 0xff)
|
||||||
|
@ -87,4 +87,4 @@ struct icmp_te_hdr {
|
|||||||
};
|
};
|
||||||
|
|
||||||
#endif /* __LWIP_ICMP_H__ */
|
#endif /* __LWIP_ICMP_H__ */
|
||||||
|
|
||||||
|
@ -41,8 +41,8 @@
|
|||||||
u16_t inet_chksum(void *data, u16_t len);
|
u16_t inet_chksum(void *data, u16_t len);
|
||||||
u16_t inet_chksum_pbuf(struct pbuf *p);
|
u16_t inet_chksum_pbuf(struct pbuf *p);
|
||||||
u16_t inet_chksum_pseudo(struct pbuf *p,
|
u16_t inet_chksum_pseudo(struct pbuf *p,
|
||||||
struct ip_addr *src, struct ip_addr *dest,
|
struct ip_addr *src, struct ip_addr *dest,
|
||||||
u8_t proto, u32_t proto_len);
|
u8_t proto, u32_t proto_len);
|
||||||
|
|
||||||
u32_t inet_addr(const char *cp);
|
u32_t inet_addr(const char *cp);
|
||||||
int inet_aton(const char *cp, struct in_addr *addr);
|
int inet_aton(const char *cp, struct in_addr *addr);
|
||||||
|
@ -81,11 +81,11 @@ void ip_input(struct pbuf *p, struct netif *inp);
|
|||||||
|
|
||||||
/* source and destination addresses in network byte order, please */
|
/* source and destination addresses in network byte order, please */
|
||||||
err_t ip_output(struct pbuf *p, struct ip_addr *src, struct ip_addr *dest,
|
err_t ip_output(struct pbuf *p, struct ip_addr *src, struct ip_addr *dest,
|
||||||
unsigned char ttl, unsigned char proto);
|
unsigned char ttl, unsigned char proto);
|
||||||
|
|
||||||
err_t ip_output_if(struct pbuf *p, struct ip_addr *src, struct ip_addr *dest,
|
err_t ip_output_if(struct pbuf *p, struct ip_addr *src, struct ip_addr *dest,
|
||||||
unsigned char ttl, unsigned char proto,
|
unsigned char ttl, unsigned char proto,
|
||||||
struct netif *netif);
|
struct netif *netif);
|
||||||
|
|
||||||
#if IP_DEBUG
|
#if IP_DEBUG
|
||||||
void ip_debug_print(struct pbuf *p);
|
void ip_debug_print(struct pbuf *p);
|
||||||
|
@ -46,7 +46,7 @@ struct ip_addr {
|
|||||||
(ipaddr)->addr[3] = htonl(((g & 0xffff) << 16) | (h & 0xffff)); } while(0)
|
(ipaddr)->addr[3] = htonl(((g & 0xffff) << 16) | (h & 0xffff)); } while(0)
|
||||||
|
|
||||||
int ip_addr_maskcmp(struct ip_addr *addr1, struct ip_addr *addr2,
|
int ip_addr_maskcmp(struct ip_addr *addr1, struct ip_addr *addr2,
|
||||||
struct ip_addr *mask);
|
struct ip_addr *mask);
|
||||||
int ip_addr_cmp(struct ip_addr *addr1, struct ip_addr *addr2);
|
int ip_addr_cmp(struct ip_addr *addr1, struct ip_addr *addr2);
|
||||||
void ip_addr_set(struct ip_addr *dest, struct ip_addr *src);
|
void ip_addr_set(struct ip_addr *dest, struct ip_addr *src);
|
||||||
int ip_addr_isany(struct ip_addr *addr);
|
int ip_addr_isany(struct ip_addr *addr);
|
||||||
|
@ -99,20 +99,20 @@ void netbuf_delete (struct netbuf *buf);
|
|||||||
void * netbuf_alloc (struct netbuf *buf, u16_t size);
|
void * netbuf_alloc (struct netbuf *buf, u16_t size);
|
||||||
void netbuf_free (struct netbuf *buf);
|
void netbuf_free (struct netbuf *buf);
|
||||||
void netbuf_ref (struct netbuf *buf,
|
void netbuf_ref (struct netbuf *buf,
|
||||||
void *dataptr, u16_t size);
|
void *dataptr, u16_t size);
|
||||||
void netbuf_chain (struct netbuf *head,
|
void netbuf_chain (struct netbuf *head,
|
||||||
struct netbuf *tail);
|
struct netbuf *tail);
|
||||||
|
|
||||||
u16_t netbuf_len (struct netbuf *buf);
|
u16_t netbuf_len (struct netbuf *buf);
|
||||||
err_t netbuf_data (struct netbuf *buf,
|
err_t netbuf_data (struct netbuf *buf,
|
||||||
void **dataptr, u16_t *len);
|
void **dataptr, u16_t *len);
|
||||||
s8_t netbuf_next (struct netbuf *buf);
|
s8_t netbuf_next (struct netbuf *buf);
|
||||||
void netbuf_first (struct netbuf *buf);
|
void netbuf_first (struct netbuf *buf);
|
||||||
|
|
||||||
void netbuf_copy (struct netbuf *buf,
|
void netbuf_copy (struct netbuf *buf,
|
||||||
void *dataptr, u16_t len);
|
void *dataptr, u16_t len);
|
||||||
void netbuf_copy_partial(struct netbuf *buf, void *dataptr,
|
void netbuf_copy_partial(struct netbuf *buf, void *dataptr,
|
||||||
u16_t len, u16_t offset);
|
u16_t len, u16_t offset);
|
||||||
struct ip_addr * netbuf_fromaddr (struct netbuf *buf);
|
struct ip_addr * netbuf_fromaddr (struct netbuf *buf);
|
||||||
u16_t netbuf_fromport (struct netbuf *buf);
|
u16_t netbuf_fromport (struct netbuf *buf);
|
||||||
|
|
||||||
@ -124,26 +124,26 @@ netconn *netconn_new_with_callback(enum netconn_type t,
|
|||||||
err_t netconn_delete (struct netconn *conn);
|
err_t netconn_delete (struct netconn *conn);
|
||||||
enum netconn_type netconn_type (struct netconn *conn);
|
enum netconn_type netconn_type (struct netconn *conn);
|
||||||
err_t netconn_peer (struct netconn *conn,
|
err_t netconn_peer (struct netconn *conn,
|
||||||
struct ip_addr *addr,
|
struct ip_addr *addr,
|
||||||
u16_t *port);
|
u16_t *port);
|
||||||
err_t netconn_addr (struct netconn *conn,
|
err_t netconn_addr (struct netconn *conn,
|
||||||
struct ip_addr **addr,
|
struct ip_addr **addr,
|
||||||
u16_t *port);
|
u16_t *port);
|
||||||
err_t netconn_bind (struct netconn *conn,
|
err_t netconn_bind (struct netconn *conn,
|
||||||
struct ip_addr *addr,
|
struct ip_addr *addr,
|
||||||
u16_t port);
|
u16_t port);
|
||||||
err_t netconn_connect (struct netconn *conn,
|
err_t netconn_connect (struct netconn *conn,
|
||||||
struct ip_addr *addr,
|
struct ip_addr *addr,
|
||||||
u16_t port);
|
u16_t port);
|
||||||
err_t netconn_disconnect (struct netconn *conn);
|
err_t netconn_disconnect (struct netconn *conn);
|
||||||
err_t netconn_listen (struct netconn *conn);
|
err_t netconn_listen (struct netconn *conn);
|
||||||
struct netconn * netconn_accept (struct netconn *conn);
|
struct netconn * netconn_accept (struct netconn *conn);
|
||||||
struct netbuf * netconn_recv (struct netconn *conn);
|
struct netbuf * netconn_recv (struct netconn *conn);
|
||||||
err_t netconn_send (struct netconn *conn,
|
err_t netconn_send (struct netconn *conn,
|
||||||
struct netbuf *buf);
|
struct netbuf *buf);
|
||||||
err_t netconn_write (struct netconn *conn,
|
err_t netconn_write (struct netconn *conn,
|
||||||
void *dataptr, u16_t size,
|
void *dataptr, u16_t size,
|
||||||
u8_t copy);
|
u8_t copy);
|
||||||
err_t netconn_close (struct netconn *conn);
|
err_t netconn_close (struct netconn *conn);
|
||||||
|
|
||||||
err_t netconn_err (struct netconn *conn);
|
err_t netconn_err (struct netconn *conn);
|
||||||
|
@ -58,133 +58,133 @@
|
|||||||
|
|
||||||
#ifdef LWIP_PROVIDE_ERRNO
|
#ifdef LWIP_PROVIDE_ERRNO
|
||||||
|
|
||||||
#define EPERM 1 /* Operation not permitted */
|
#define EPERM 1 /* Operation not permitted */
|
||||||
#define ENOENT 2 /* No such file or directory */
|
#define ENOENT 2 /* No such file or directory */
|
||||||
#define ESRCH 3 /* No such process */
|
#define ESRCH 3 /* No such process */
|
||||||
#define EINTR 4 /* Interrupted system call */
|
#define EINTR 4 /* Interrupted system call */
|
||||||
#define EIO 5 /* I/O error */
|
#define EIO 5 /* I/O error */
|
||||||
#define ENXIO 6 /* No such device or address */
|
#define ENXIO 6 /* No such device or address */
|
||||||
#define E2BIG 7 /* Arg list too long */
|
#define E2BIG 7 /* Arg list too long */
|
||||||
#define ENOEXEC 8 /* Exec format error */
|
#define ENOEXEC 8 /* Exec format error */
|
||||||
#define EBADF 9 /* Bad file number */
|
#define EBADF 9 /* Bad file number */
|
||||||
#define ECHILD 10 /* No child processes */
|
#define ECHILD 10 /* No child processes */
|
||||||
#define EAGAIN 11 /* Try again */
|
#define EAGAIN 11 /* Try again */
|
||||||
#define ENOMEM 12 /* Out of memory */
|
#define ENOMEM 12 /* Out of memory */
|
||||||
#define EACCES 13 /* Permission denied */
|
#define EACCES 13 /* Permission denied */
|
||||||
#define EFAULT 14 /* Bad address */
|
#define EFAULT 14 /* Bad address */
|
||||||
#define ENOTBLK 15 /* Block device required */
|
#define ENOTBLK 15 /* Block device required */
|
||||||
#define EBUSY 16 /* Device or resource busy */
|
#define EBUSY 16 /* Device or resource busy */
|
||||||
#define EEXIST 17 /* File exists */
|
#define EEXIST 17 /* File exists */
|
||||||
#define EXDEV 18 /* Cross-device link */
|
#define EXDEV 18 /* Cross-device link */
|
||||||
#define ENODEV 19 /* No such device */
|
#define ENODEV 19 /* No such device */
|
||||||
#define ENOTDIR 20 /* Not a directory */
|
#define ENOTDIR 20 /* Not a directory */
|
||||||
#define EISDIR 21 /* Is a directory */
|
#define EISDIR 21 /* Is a directory */
|
||||||
#define EINVAL 22 /* Invalid argument */
|
#define EINVAL 22 /* Invalid argument */
|
||||||
#define ENFILE 23 /* File table overflow */
|
#define ENFILE 23 /* File table overflow */
|
||||||
#define EMFILE 24 /* Too many open files */
|
#define EMFILE 24 /* Too many open files */
|
||||||
#define ENOTTY 25 /* Not a typewriter */
|
#define ENOTTY 25 /* Not a typewriter */
|
||||||
#define ETXTBSY 26 /* Text file busy */
|
#define ETXTBSY 26 /* Text file busy */
|
||||||
#define EFBIG 27 /* File too large */
|
#define EFBIG 27 /* File too large */
|
||||||
#define ENOSPC 28 /* No space left on device */
|
#define ENOSPC 28 /* No space left on device */
|
||||||
#define ESPIPE 29 /* Illegal seek */
|
#define ESPIPE 29 /* Illegal seek */
|
||||||
#define EROFS 30 /* Read-only file system */
|
#define EROFS 30 /* Read-only file system */
|
||||||
#define EMLINK 31 /* Too many links */
|
#define EMLINK 31 /* Too many links */
|
||||||
#define EPIPE 32 /* Broken pipe */
|
#define EPIPE 32 /* Broken pipe */
|
||||||
#define EDOM 33 /* Math argument out of domain of func */
|
#define EDOM 33 /* Math argument out of domain of func */
|
||||||
#define ERANGE 34 /* Math result not representable */
|
#define ERANGE 34 /* Math result not representable */
|
||||||
#define EDEADLK 35 /* Resource deadlock would occur */
|
#define EDEADLK 35 /* Resource deadlock would occur */
|
||||||
#define ENAMETOOLONG 36 /* File name too long */
|
#define ENAMETOOLONG 36 /* File name too long */
|
||||||
#define ENOLCK 37 /* No record locks available */
|
#define ENOLCK 37 /* No record locks available */
|
||||||
#define ENOSYS 38 /* Function not implemented */
|
#define ENOSYS 38 /* Function not implemented */
|
||||||
#define ENOTEMPTY 39 /* Directory not empty */
|
#define ENOTEMPTY 39 /* Directory not empty */
|
||||||
#define ELOOP 40 /* Too many symbolic links encountered */
|
#define ELOOP 40 /* Too many symbolic links encountered */
|
||||||
#define EWOULDBLOCK EAGAIN /* Operation would block */
|
#define EWOULDBLOCK EAGAIN /* Operation would block */
|
||||||
#define ENOMSG 42 /* No message of desired type */
|
#define ENOMSG 42 /* No message of desired type */
|
||||||
#define EIDRM 43 /* Identifier removed */
|
#define EIDRM 43 /* Identifier removed */
|
||||||
#define ECHRNG 44 /* Channel number out of range */
|
#define ECHRNG 44 /* Channel number out of range */
|
||||||
#define EL2NSYNC 45 /* Level 2 not synchronized */
|
#define EL2NSYNC 45 /* Level 2 not synchronized */
|
||||||
#define EL3HLT 46 /* Level 3 halted */
|
#define EL3HLT 46 /* Level 3 halted */
|
||||||
#define EL3RST 47 /* Level 3 reset */
|
#define EL3RST 47 /* Level 3 reset */
|
||||||
#define ELNRNG 48 /* Link number out of range */
|
#define ELNRNG 48 /* Link number out of range */
|
||||||
#define EUNATCH 49 /* Protocol driver not attached */
|
#define EUNATCH 49 /* Protocol driver not attached */
|
||||||
#define ENOCSI 50 /* No CSI structure available */
|
#define ENOCSI 50 /* No CSI structure available */
|
||||||
#define EL2HLT 51 /* Level 2 halted */
|
#define EL2HLT 51 /* Level 2 halted */
|
||||||
#define EBADE 52 /* Invalid exchange */
|
#define EBADE 52 /* Invalid exchange */
|
||||||
#define EBADR 53 /* Invalid request descriptor */
|
#define EBADR 53 /* Invalid request descriptor */
|
||||||
#define EXFULL 54 /* Exchange full */
|
#define EXFULL 54 /* Exchange full */
|
||||||
#define ENOANO 55 /* No anode */
|
#define ENOANO 55 /* No anode */
|
||||||
#define EBADRQC 56 /* Invalid request code */
|
#define EBADRQC 56 /* Invalid request code */
|
||||||
#define EBADSLT 57 /* Invalid slot */
|
#define EBADSLT 57 /* Invalid slot */
|
||||||
|
|
||||||
#define EDEADLOCK EDEADLK
|
#define EDEADLOCK EDEADLK
|
||||||
|
|
||||||
#define EBFONT 59 /* Bad font file format */
|
#define EBFONT 59 /* Bad font file format */
|
||||||
#define ENOSTR 60 /* Device not a stream */
|
#define ENOSTR 60 /* Device not a stream */
|
||||||
#define ENODATA 61 /* No data available */
|
#define ENODATA 61 /* No data available */
|
||||||
#define ETIME 62 /* Timer expired */
|
#define ETIME 62 /* Timer expired */
|
||||||
#define ENOSR 63 /* Out of streams resources */
|
#define ENOSR 63 /* Out of streams resources */
|
||||||
#define ENONET 64 /* Machine is not on the network */
|
#define ENONET 64 /* Machine is not on the network */
|
||||||
#define ENOPKG 65 /* Package not installed */
|
#define ENOPKG 65 /* Package not installed */
|
||||||
#define EREMOTE 66 /* Object is remote */
|
#define EREMOTE 66 /* Object is remote */
|
||||||
#define ENOLINK 67 /* Link has been severed */
|
#define ENOLINK 67 /* Link has been severed */
|
||||||
#define EADV 68 /* Advertise error */
|
#define EADV 68 /* Advertise error */
|
||||||
#define ESRMNT 69 /* Srmount error */
|
#define ESRMNT 69 /* Srmount error */
|
||||||
#define ECOMM 70 /* Communication error on send */
|
#define ECOMM 70 /* Communication error on send */
|
||||||
#define EPROTO 71 /* Protocol error */
|
#define EPROTO 71 /* Protocol error */
|
||||||
#define EMULTIHOP 72 /* Multihop attempted */
|
#define EMULTIHOP 72 /* Multihop attempted */
|
||||||
#define EDOTDOT 73 /* RFS specific error */
|
#define EDOTDOT 73 /* RFS specific error */
|
||||||
#define EBADMSG 74 /* Not a data message */
|
#define EBADMSG 74 /* Not a data message */
|
||||||
#define EOVERFLOW 75 /* Value too large for defined data type */
|
#define EOVERFLOW 75 /* Value too large for defined data type */
|
||||||
#define ENOTUNIQ 76 /* Name not unique on network */
|
#define ENOTUNIQ 76 /* Name not unique on network */
|
||||||
#define EBADFD 77 /* File descriptor in bad state */
|
#define EBADFD 77 /* File descriptor in bad state */
|
||||||
#define EREMCHG 78 /* Remote address changed */
|
#define EREMCHG 78 /* Remote address changed */
|
||||||
#define ELIBACC 79 /* Can not access a needed shared library */
|
#define ELIBACC 79 /* Can not access a needed shared library */
|
||||||
#define ELIBBAD 80 /* Accessing a corrupted shared library */
|
#define ELIBBAD 80 /* Accessing a corrupted shared library */
|
||||||
#define ELIBSCN 81 /* .lib section in a.out corrupted */
|
#define ELIBSCN 81 /* .lib section in a.out corrupted */
|
||||||
#define ELIBMAX 82 /* Attempting to link in too many shared libraries */
|
#define ELIBMAX 82 /* Attempting to link in too many shared libraries */
|
||||||
#define ELIBEXEC 83 /* Cannot exec a shared library directly */
|
#define ELIBEXEC 83 /* Cannot exec a shared library directly */
|
||||||
#define EILSEQ 84 /* Illegal byte sequence */
|
#define EILSEQ 84 /* Illegal byte sequence */
|
||||||
#define ERESTART 85 /* Interrupted system call should be restarted */
|
#define ERESTART 85 /* Interrupted system call should be restarted */
|
||||||
#define ESTRPIPE 86 /* Streams pipe error */
|
#define ESTRPIPE 86 /* Streams pipe error */
|
||||||
#define EUSERS 87 /* Too many users */
|
#define EUSERS 87 /* Too many users */
|
||||||
#define ENOTSOCK 88 /* Socket operation on non-socket */
|
#define ENOTSOCK 88 /* Socket operation on non-socket */
|
||||||
#define EDESTADDRREQ 89 /* Destination address required */
|
#define EDESTADDRREQ 89 /* Destination address required */
|
||||||
#define EMSGSIZE 90 /* Message too long */
|
#define EMSGSIZE 90 /* Message too long */
|
||||||
#define EPROTOTYPE 91 /* Protocol wrong type for socket */
|
#define EPROTOTYPE 91 /* Protocol wrong type for socket */
|
||||||
#define ENOPROTOOPT 92 /* Protocol not available */
|
#define ENOPROTOOPT 92 /* Protocol not available */
|
||||||
#define EPROTONOSUPPORT 93 /* Protocol not supported */
|
#define EPROTONOSUPPORT 93 /* Protocol not supported */
|
||||||
#define ESOCKTNOSUPPORT 94 /* Socket type not supported */
|
#define ESOCKTNOSUPPORT 94 /* Socket type not supported */
|
||||||
#define EOPNOTSUPP 95 /* Operation not supported on transport endpoint */
|
#define EOPNOTSUPP 95 /* Operation not supported on transport endpoint */
|
||||||
#define EPFNOSUPPORT 96 /* Protocol family not supported */
|
#define EPFNOSUPPORT 96 /* Protocol family not supported */
|
||||||
#define EAFNOSUPPORT 97 /* Address family not supported by protocol */
|
#define EAFNOSUPPORT 97 /* Address family not supported by protocol */
|
||||||
#define EADDRINUSE 98 /* Address already in use */
|
#define EADDRINUSE 98 /* Address already in use */
|
||||||
#define EADDRNOTAVAIL 99 /* Cannot assign requested address */
|
#define EADDRNOTAVAIL 99 /* Cannot assign requested address */
|
||||||
#define ENETDOWN 100 /* Network is down */
|
#define ENETDOWN 100 /* Network is down */
|
||||||
#define ENETUNREACH 101 /* Network is unreachable */
|
#define ENETUNREACH 101 /* Network is unreachable */
|
||||||
#define ENETRESET 102 /* Network dropped connection because of reset */
|
#define ENETRESET 102 /* Network dropped connection because of reset */
|
||||||
#define ECONNABORTED 103 /* Software caused connection abort */
|
#define ECONNABORTED 103 /* Software caused connection abort */
|
||||||
#define ECONNRESET 104 /* Connection reset by peer */
|
#define ECONNRESET 104 /* Connection reset by peer */
|
||||||
#define ENOBUFS 105 /* No buffer space available */
|
#define ENOBUFS 105 /* No buffer space available */
|
||||||
#define EISCONN 106 /* Transport endpoint is already connected */
|
#define EISCONN 106 /* Transport endpoint is already connected */
|
||||||
#define ENOTCONN 107 /* Transport endpoint is not connected */
|
#define ENOTCONN 107 /* Transport endpoint is not connected */
|
||||||
#define ESHUTDOWN 108 /* Cannot send after transport endpoint shutdown */
|
#define ESHUTDOWN 108 /* Cannot send after transport endpoint shutdown */
|
||||||
#define ETOOMANYREFS 109 /* Too many references: cannot splice */
|
#define ETOOMANYREFS 109 /* Too many references: cannot splice */
|
||||||
#define ETIMEDOUT 110 /* Connection timed out */
|
#define ETIMEDOUT 110 /* Connection timed out */
|
||||||
#define ECONNREFUSED 111 /* Connection refused */
|
#define ECONNREFUSED 111 /* Connection refused */
|
||||||
#define EHOSTDOWN 112 /* Host is down */
|
#define EHOSTDOWN 112 /* Host is down */
|
||||||
#define EHOSTUNREACH 113 /* No route to host */
|
#define EHOSTUNREACH 113 /* No route to host */
|
||||||
#define EALREADY 114 /* Operation already in progress */
|
#define EALREADY 114 /* Operation already in progress */
|
||||||
#define EINPROGRESS 115 /* Operation now in progress */
|
#define EINPROGRESS 115 /* Operation now in progress */
|
||||||
#define ESTALE 116 /* Stale NFS file handle */
|
#define ESTALE 116 /* Stale NFS file handle */
|
||||||
#define EUCLEAN 117 /* Structure needs cleaning */
|
#define EUCLEAN 117 /* Structure needs cleaning */
|
||||||
#define ENOTNAM 118 /* Not a XENIX named type file */
|
#define ENOTNAM 118 /* Not a XENIX named type file */
|
||||||
#define ENAVAIL 119 /* No XENIX semaphores available */
|
#define ENAVAIL 119 /* No XENIX semaphores available */
|
||||||
#define EISNAM 120 /* Is a named type file */
|
#define EISNAM 120 /* Is a named type file */
|
||||||
#define EREMOTEIO 121 /* Remote I/O error */
|
#define EREMOTEIO 121 /* Remote I/O error */
|
||||||
#define EDQUOT 122 /* Quota exceeded */
|
#define EDQUOT 122 /* Quota exceeded */
|
||||||
|
|
||||||
#define ENOMEDIUM 123 /* No medium found */
|
#define ENOMEDIUM 123 /* No medium found */
|
||||||
#define EMEDIUMTYPE 124 /* Wrong medium type */
|
#define EMEDIUMTYPE 124 /* Wrong medium type */
|
||||||
|
|
||||||
extern int errno;
|
extern int errno;
|
||||||
|
|
||||||
|
@ -42,9 +42,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#define DBG_LEVEL_OFF 0
|
#define DBG_LEVEL_OFF 0
|
||||||
#define DBG_LEVEL_WARNING 1 /* bad checksums, dropped packets, ... */
|
#define DBG_LEVEL_WARNING 1 /* bad checksums, dropped packets, ... */
|
||||||
#define DBG_LEVEL_SERIOUS 2 /* memory allocation failures, ... */
|
#define DBG_LEVEL_SERIOUS 2 /* memory allocation failures, ... */
|
||||||
#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 DEBUGF to enable that debug message */
|
||||||
@ -67,11 +67,11 @@
|
|||||||
* 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 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 DEBUGF(debug,x)
|
||||||
# define LWIP_ERROR(x)
|
# define LWIP_ERROR(x)
|
||||||
#endif /* LWIP_DEBUG */
|
#endif /* LWIP_DEBUG */
|
||||||
|
|
||||||
#endif /* __LWIP_DEBUG_H__ */
|
#endif /* __LWIP_DEBUG_H__ */
|
||||||
|
@ -36,8 +36,8 @@ struct dhcp
|
|||||||
struct dhcp_msg *msg_out; /* outgoing msg */
|
struct dhcp_msg *msg_out; /* outgoing msg */
|
||||||
u16_t options_out_len; /* outgoing msg options length */
|
u16_t options_out_len; /* outgoing msg options length */
|
||||||
u16_t request_timeout; /* #ticks with period DHCP_FINE_TIMER_SECS for request timeout */
|
u16_t request_timeout; /* #ticks with period DHCP_FINE_TIMER_SECS for request timeout */
|
||||||
u16_t t1_timeout; /* #ticks with period DHCP_COARSE_TIMER_SECS for renewal time */
|
u16_t t1_timeout; /* #ticks with period DHCP_COARSE_TIMER_SECS for renewal time */
|
||||||
u16_t t2_timeout; /* #ticks with period DHCP_COARSE_TIMER_SECS for rebind time */
|
u16_t t2_timeout; /* #ticks with period DHCP_COARSE_TIMER_SECS for rebind time */
|
||||||
struct ip_addr server_ip_addr; /* dhcp server address that offered this lease */
|
struct ip_addr server_ip_addr; /* dhcp server address that offered this lease */
|
||||||
struct ip_addr offered_ip_addr;
|
struct ip_addr offered_ip_addr;
|
||||||
struct ip_addr offered_sn_mask;
|
struct ip_addr offered_sn_mask;
|
||||||
@ -45,9 +45,9 @@ struct dhcp
|
|||||||
struct ip_addr offered_bc_addr;
|
struct ip_addr offered_bc_addr;
|
||||||
u32_t offered_t0_lease; /* lease period (in seconds) */
|
u32_t offered_t0_lease; /* lease period (in seconds) */
|
||||||
u32_t offered_t1_renew; /* recommended renew time (usually 50% of lease period) */
|
u32_t offered_t1_renew; /* recommended renew time (usually 50% of lease period) */
|
||||||
u32_t offered_t2_rebind; /* recommended rebind time (usually 66% of lease period) */
|
u32_t offered_t2_rebind; /* recommended rebind time (usually 66% of lease period) */
|
||||||
/** Patch #1308
|
/** Patch #1308
|
||||||
* TODO: See dhcp.c "TODO"s
|
* TODO: See dhcp.c "TODO"s
|
||||||
*/
|
*/
|
||||||
#if 0
|
#if 0
|
||||||
struct ip_addr offered_si_addr;
|
struct ip_addr offered_si_addr;
|
||||||
@ -134,7 +134,7 @@ void dhcp_fine_tmr(void);
|
|||||||
#define DHCP_COOKIE_OFS (DHCP_MSG_OFS + DHCP_MSG_LEN)
|
#define DHCP_COOKIE_OFS (DHCP_MSG_OFS + DHCP_MSG_LEN)
|
||||||
#define DHCP_OPTIONS_OFS (DHCP_MSG_OFS + DHCP_MSG_LEN + 4)
|
#define DHCP_OPTIONS_OFS (DHCP_MSG_OFS + DHCP_MSG_LEN + 4)
|
||||||
|
|
||||||
#define DHCP_CLIENT_PORT 68
|
#define DHCP_CLIENT_PORT 68
|
||||||
#define DHCP_SERVER_PORT 67
|
#define DHCP_SERVER_PORT 67
|
||||||
|
|
||||||
/** DHCP client states */
|
/** DHCP client states */
|
||||||
@ -206,7 +206,7 @@ void dhcp_fine_tmr(void);
|
|||||||
/** possible combinations of overloading the file and sname fields with options */
|
/** possible combinations of overloading the file and sname fields with options */
|
||||||
#define DHCP_OVERLOAD_NONE 0
|
#define DHCP_OVERLOAD_NONE 0
|
||||||
#define DHCP_OVERLOAD_FILE 1
|
#define DHCP_OVERLOAD_FILE 1
|
||||||
#define DHCP_OVERLOAD_SNAME 2
|
#define DHCP_OVERLOAD_SNAME 2
|
||||||
#define DHCP_OVERLOAD_SNAME_FILE 3
|
#define DHCP_OVERLOAD_SNAME_FILE 3
|
||||||
|
|
||||||
#endif /*__LWIP_DHCP_H__*/
|
#endif /*__LWIP_DHCP_H__*/
|
||||||
|
@ -62,4 +62,4 @@ void *memp_mallocp(memp_t type);
|
|||||||
void memp_freep(memp_t type, void *mem);
|
void memp_freep(memp_t type, void *mem);
|
||||||
|
|
||||||
#endif /* __LWIP_MEMP_H__ */
|
#endif /* __LWIP_MEMP_H__ */
|
||||||
|
|
||||||
|
@ -81,7 +81,7 @@ struct netif {
|
|||||||
to send a packet on the interface. This function typically
|
to send a packet on the interface. This function typically
|
||||||
first resolves the hardware address, then sends the packet. */
|
first resolves the hardware address, then sends the packet. */
|
||||||
err_t (* output)(struct netif *netif, struct pbuf *p,
|
err_t (* output)(struct netif *netif, struct pbuf *p,
|
||||||
struct ip_addr *ipaddr);
|
struct ip_addr *ipaddr);
|
||||||
/** This function is called by the ARP module when it wants
|
/** This function is called by the ARP module when it wants
|
||||||
to send a packet on the interface. This function outputs
|
to send a packet on the interface. This function outputs
|
||||||
the pbuf as-is on the link medium. */
|
the pbuf as-is on the link medium. */
|
||||||
@ -116,14 +116,14 @@ extern struct netif *netif_default;
|
|||||||
void netif_init(void);
|
void netif_init(void);
|
||||||
|
|
||||||
struct netif *netif_add(struct ip_addr *ipaddr, struct ip_addr *netmask,
|
struct netif *netif_add(struct ip_addr *ipaddr, struct ip_addr *netmask,
|
||||||
struct ip_addr *gw,
|
struct ip_addr *gw,
|
||||||
void *state,
|
void *state,
|
||||||
err_t (* init)(struct netif *netif),
|
err_t (* init)(struct netif *netif),
|
||||||
err_t (* input)(struct pbuf *p, struct netif *netif));
|
err_t (* input)(struct pbuf *p, struct netif *netif));
|
||||||
|
|
||||||
void
|
void
|
||||||
netif_set_addr(struct netif *netif,struct ip_addr *ipaddr, struct ip_addr *netmask,
|
netif_set_addr(struct netif *netif,struct ip_addr *ipaddr, struct ip_addr *netmask,
|
||||||
struct ip_addr *gw);
|
struct ip_addr *gw);
|
||||||
void netif_remove(struct netif * netif);
|
void netif_remove(struct netif * netif);
|
||||||
|
|
||||||
/* Returns a network interface given its name. The name is of the form
|
/* Returns a network interface given its name. The name is of the form
|
||||||
|
@ -61,29 +61,29 @@ struct sockaddr {
|
|||||||
/*
|
/*
|
||||||
* Option flags per-socket.
|
* Option flags per-socket.
|
||||||
*/
|
*/
|
||||||
#define SO_DEBUG 0x0001 /* turn on debugging info recording */
|
#define SO_DEBUG 0x0001 /* turn on debugging info recording */
|
||||||
#define SO_ACCEPTCONN 0x0002 /* socket has had listen() */
|
#define SO_ACCEPTCONN 0x0002 /* socket has had listen() */
|
||||||
#define SO_REUSEADDR 0x0004 /* allow local address reuse */
|
#define SO_REUSEADDR 0x0004 /* allow local address reuse */
|
||||||
#define SO_KEEPALIVE 0x0008 /* keep connections alive */
|
#define SO_KEEPALIVE 0x0008 /* keep connections alive */
|
||||||
#define SO_DONTROUTE 0x0010 /* just use interface addresses */
|
#define SO_DONTROUTE 0x0010 /* just use interface addresses */
|
||||||
#define SO_BROADCAST 0x0020 /* permit sending of broadcast msgs */
|
#define SO_BROADCAST 0x0020 /* permit sending of broadcast msgs */
|
||||||
#define SO_USELOOPBACK 0x0040 /* bypass hardware when possible */
|
#define SO_USELOOPBACK 0x0040 /* bypass hardware when possible */
|
||||||
#define SO_LINGER 0x0080 /* linger on close if data present */
|
#define SO_LINGER 0x0080 /* linger on close if data present */
|
||||||
#define SO_OOBINLINE 0x0100 /* leave received OOB data in line */
|
#define SO_OOBINLINE 0x0100 /* leave received OOB data in line */
|
||||||
|
|
||||||
#define SO_DONTLINGER (int)(~SO_LINGER)
|
#define SO_DONTLINGER (int)(~SO_LINGER)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Additional options, not kept in so_options.
|
* Additional options, not kept in so_options.
|
||||||
*/
|
*/
|
||||||
#define SO_SNDBUF 0x1001 /* send buffer size */
|
#define SO_SNDBUF 0x1001 /* send buffer size */
|
||||||
#define SO_RCVBUF 0x1002 /* receive buffer size */
|
#define SO_RCVBUF 0x1002 /* receive buffer size */
|
||||||
#define SO_SNDLOWAT 0x1003 /* send low-water mark */
|
#define SO_SNDLOWAT 0x1003 /* send low-water mark */
|
||||||
#define SO_RCVLOWAT 0x1004 /* receive low-water mark */
|
#define SO_RCVLOWAT 0x1004 /* receive low-water mark */
|
||||||
#define SO_SNDTIMEO 0x1005 /* send timeout */
|
#define SO_SNDTIMEO 0x1005 /* send timeout */
|
||||||
#define SO_RCVTIMEO 0x1006 /* receive timeout */
|
#define SO_RCVTIMEO 0x1006 /* receive timeout */
|
||||||
#define SO_ERROR 0x1007 /* get error status and clear */
|
#define SO_ERROR 0x1007 /* get error status and clear */
|
||||||
#define SO_TYPE 0x1008 /* get socket type */
|
#define SO_TYPE 0x1008 /* get socket type */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -98,7 +98,7 @@ struct linger {
|
|||||||
/*
|
/*
|
||||||
* Level number for (get/set)sockopt() to apply to socket itself.
|
* Level number for (get/set)sockopt() to apply to socket itself.
|
||||||
*/
|
*/
|
||||||
#define SOL_SOCKET 0xfff /* options for socket level */
|
#define SOL_SOCKET 0xfff /* options for socket level */
|
||||||
|
|
||||||
|
|
||||||
#define AF_UNSPEC 0
|
#define AF_UNSPEC 0
|
||||||
@ -175,8 +175,8 @@ struct linger {
|
|||||||
} fd_set;
|
} fd_set;
|
||||||
|
|
||||||
struct timeval {
|
struct timeval {
|
||||||
long tv_sec; /* seconds */
|
long tv_sec; /* seconds */
|
||||||
long tv_usec; /* and microseconds */
|
long tv_usec; /* and microseconds */
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@ -194,10 +194,10 @@ int lwip_listen(int s, int backlog);
|
|||||||
int lwip_recv(int s, void *mem, int len, unsigned int flags);
|
int lwip_recv(int s, void *mem, int len, unsigned int flags);
|
||||||
int lwip_read(int s, void *mem, int len);
|
int lwip_read(int s, void *mem, int len);
|
||||||
int lwip_recvfrom(int s, void *mem, int len, unsigned int flags,
|
int lwip_recvfrom(int s, void *mem, int len, unsigned int flags,
|
||||||
struct sockaddr *from, socklen_t *fromlen);
|
struct sockaddr *from, socklen_t *fromlen);
|
||||||
int lwip_send(int s, void *dataptr, int size, unsigned int flags);
|
int lwip_send(int s, void *dataptr, int size, unsigned int flags);
|
||||||
int lwip_sendto(int s, void *dataptr, int size, unsigned int flags,
|
int lwip_sendto(int s, void *dataptr, int size, unsigned int flags,
|
||||||
struct sockaddr *to, socklen_t tolen);
|
struct sockaddr *to, socklen_t tolen);
|
||||||
int lwip_socket(int domain, int type, int protocol);
|
int lwip_socket(int domain, int type, int protocol);
|
||||||
int lwip_write(int s, void *dataptr, int size);
|
int lwip_write(int s, void *dataptr, int size);
|
||||||
int lwip_select(int maxfdp1, fd_set *readset, fd_set *writeset, fd_set *exceptset,
|
int lwip_select(int maxfdp1, fd_set *readset, fd_set *writeset, fd_set *exceptset,
|
||||||
|
@ -50,45 +50,45 @@ struct tcp_pcb;
|
|||||||
|
|
||||||
/* Lower layer interface to TCP: */
|
/* Lower layer interface to TCP: */
|
||||||
void tcp_init (void); /* Must be called first to
|
void tcp_init (void); /* Must be called first to
|
||||||
initialize TCP. */
|
initialize TCP. */
|
||||||
void tcp_tmr (void); /* Must be called every
|
void tcp_tmr (void); /* Must be called every
|
||||||
TCP_TMR_INTERVAL
|
TCP_TMR_INTERVAL
|
||||||
ms. (Typically 100 ms). */
|
ms. (Typically 100 ms). */
|
||||||
/* Application program's interface: */
|
/* Application program's interface: */
|
||||||
struct tcp_pcb * tcp_new (void);
|
struct tcp_pcb * tcp_new (void);
|
||||||
struct tcp_pcb * tcp_alloc (u8_t prio);
|
struct tcp_pcb * tcp_alloc (u8_t prio);
|
||||||
|
|
||||||
void tcp_arg (struct tcp_pcb *pcb, void *arg);
|
void tcp_arg (struct tcp_pcb *pcb, void *arg);
|
||||||
void tcp_accept (struct tcp_pcb *pcb,
|
void tcp_accept (struct tcp_pcb *pcb,
|
||||||
err_t (* accept)(void *arg, struct tcp_pcb *newpcb,
|
err_t (* accept)(void *arg, struct tcp_pcb *newpcb,
|
||||||
err_t err));
|
err_t err));
|
||||||
void tcp_recv (struct tcp_pcb *pcb,
|
void tcp_recv (struct tcp_pcb *pcb,
|
||||||
err_t (* recv)(void *arg, struct tcp_pcb *tpcb,
|
err_t (* recv)(void *arg, struct tcp_pcb *tpcb,
|
||||||
struct pbuf *p, err_t err));
|
struct pbuf *p, err_t err));
|
||||||
void tcp_sent (struct tcp_pcb *pcb,
|
void tcp_sent (struct tcp_pcb *pcb,
|
||||||
err_t (* sent)(void *arg, struct tcp_pcb *tpcb,
|
err_t (* sent)(void *arg, struct tcp_pcb *tpcb,
|
||||||
u16_t len));
|
u16_t len));
|
||||||
void tcp_poll (struct tcp_pcb *pcb,
|
void tcp_poll (struct tcp_pcb *pcb,
|
||||||
err_t (* poll)(void *arg, struct tcp_pcb *tpcb),
|
err_t (* poll)(void *arg, struct tcp_pcb *tpcb),
|
||||||
u8_t interval);
|
u8_t interval);
|
||||||
void tcp_err (struct tcp_pcb *pcb,
|
void tcp_err (struct tcp_pcb *pcb,
|
||||||
void (* err)(void *arg, err_t err));
|
void (* err)(void *arg, err_t err));
|
||||||
|
|
||||||
#define tcp_mss(pcb) ((pcb)->mss)
|
#define tcp_mss(pcb) ((pcb)->mss)
|
||||||
#define tcp_sndbuf(pcb) ((pcb)->snd_buf)
|
#define tcp_sndbuf(pcb) ((pcb)->snd_buf)
|
||||||
|
|
||||||
void tcp_recved (struct tcp_pcb *pcb, u16_t len);
|
void tcp_recved (struct tcp_pcb *pcb, u16_t len);
|
||||||
err_t tcp_bind (struct tcp_pcb *pcb, struct ip_addr *ipaddr,
|
err_t tcp_bind (struct tcp_pcb *pcb, struct ip_addr *ipaddr,
|
||||||
u16_t port);
|
u16_t port);
|
||||||
err_t tcp_connect (struct tcp_pcb *pcb, struct ip_addr *ipaddr,
|
err_t tcp_connect (struct tcp_pcb *pcb, struct ip_addr *ipaddr,
|
||||||
u16_t port, err_t (* connected)(void *arg,
|
u16_t port, err_t (* connected)(void *arg,
|
||||||
struct tcp_pcb *tpcb,
|
struct tcp_pcb *tpcb,
|
||||||
err_t err));
|
err_t err));
|
||||||
struct tcp_pcb * tcp_listen (struct tcp_pcb *pcb);
|
struct tcp_pcb * tcp_listen (struct tcp_pcb *pcb);
|
||||||
void tcp_abort (struct tcp_pcb *pcb);
|
void tcp_abort (struct tcp_pcb *pcb);
|
||||||
err_t tcp_close (struct tcp_pcb *pcb);
|
err_t tcp_close (struct tcp_pcb *pcb);
|
||||||
err_t tcp_write (struct tcp_pcb *pcb, const void *dataptr, u16_t len,
|
err_t tcp_write (struct tcp_pcb *pcb, const void *dataptr, u16_t len,
|
||||||
u8_t copy);
|
u8_t copy);
|
||||||
|
|
||||||
void tcp_setprio (struct tcp_pcb *pcb, u8_t prio);
|
void tcp_setprio (struct tcp_pcb *pcb, u8_t prio);
|
||||||
|
|
||||||
@ -175,7 +175,7 @@ PACK_STRUCT_END
|
|||||||
#define TCPH_FLAGS_SET(hdr, flags) (hdr)->_offset_flags = htons((TCPH_OFFSET(hdr) << 8) | (flags))
|
#define TCPH_FLAGS_SET(hdr, flags) (hdr)->_offset_flags = htons((TCPH_OFFSET(hdr) << 8) | (flags))
|
||||||
|
|
||||||
#define TCP_TCPLEN(seg) ((seg)->len + ((TCPH_FLAGS((seg)->tcphdr) & TCP_FIN || \
|
#define TCP_TCPLEN(seg) ((seg)->len + ((TCPH_FLAGS((seg)->tcphdr) & TCP_FIN || \
|
||||||
TCPH_FLAGS((seg)->tcphdr) & TCP_SYN)? 1: 0))
|
TCPH_FLAGS((seg)->tcphdr) & TCP_SYN)? 1: 0))
|
||||||
|
|
||||||
enum tcp_state {
|
enum tcp_state {
|
||||||
CLOSED = 0,
|
CLOSED = 0,
|
||||||
@ -247,7 +247,7 @@ struct tcp_pcb {
|
|||||||
snd_max, /* Highest seqno sent. */
|
snd_max, /* Highest seqno sent. */
|
||||||
snd_wnd, /* sender window */
|
snd_wnd, /* sender window */
|
||||||
snd_wl1, snd_wl2, /* Sequence and acknowledgement numbers of last
|
snd_wl1, snd_wl2, /* Sequence and acknowledgement numbers of last
|
||||||
window update. */
|
window update. */
|
||||||
snd_lbb; /* Sequence number of next byte to be buffered. */
|
snd_lbb; /* Sequence number of next byte to be buffered. */
|
||||||
|
|
||||||
u16_t acked;
|
u16_t acked;
|
||||||
@ -315,23 +315,23 @@ enum lwip_event {
|
|||||||
};
|
};
|
||||||
|
|
||||||
err_t lwip_tcp_event(void *arg, struct tcp_pcb *pcb,
|
err_t lwip_tcp_event(void *arg, struct tcp_pcb *pcb,
|
||||||
enum lwip_event,
|
enum lwip_event,
|
||||||
struct pbuf *p,
|
struct pbuf *p,
|
||||||
u16_t size,
|
u16_t size,
|
||||||
err_t err);
|
err_t err);
|
||||||
|
|
||||||
#define TCP_EVENT_ACCEPT(pcb,err,ret) ret = lwip_tcp_event((pcb)->callback_arg, (pcb),\
|
#define TCP_EVENT_ACCEPT(pcb,err,ret) ret = lwip_tcp_event((pcb)->callback_arg, (pcb),\
|
||||||
LWIP_EVENT_ACCEPT, NULL, 0, err)
|
LWIP_EVENT_ACCEPT, NULL, 0, err)
|
||||||
#define TCP_EVENT_SENT(pcb,space,ret) ret = lwip_tcp_event((pcb)->callback_arg, (pcb),\
|
#define TCP_EVENT_SENT(pcb,space,ret) ret = lwip_tcp_event((pcb)->callback_arg, (pcb),\
|
||||||
LWIP_EVENT_SENT, NULL, space, ERR_OK)
|
LWIP_EVENT_SENT, NULL, space, ERR_OK)
|
||||||
#define TCP_EVENT_RECV(pcb,p,err,ret) ret = lwip_tcp_event((pcb)->callback_arg, (pcb),\
|
#define TCP_EVENT_RECV(pcb,p,err,ret) ret = lwip_tcp_event((pcb)->callback_arg, (pcb),\
|
||||||
LWIP_EVENT_RECV, (p), 0, (err))
|
LWIP_EVENT_RECV, (p), 0, (err))
|
||||||
#define TCP_EVENT_CONNECTED(pcb,err,ret) ret = lwip_tcp_event((pcb)->callback_arg, (pcb),\
|
#define TCP_EVENT_CONNECTED(pcb,err,ret) ret = lwip_tcp_event((pcb)->callback_arg, (pcb),\
|
||||||
LWIP_EVENT_CONNECTED, NULL, 0, (err))
|
LWIP_EVENT_CONNECTED, NULL, 0, (err))
|
||||||
#define TCP_EVENT_POLL(pcb,ret) ret = lwip_tcp_event((pcb)->callback_arg, (pcb),\
|
#define TCP_EVENT_POLL(pcb,ret) ret = lwip_tcp_event((pcb)->callback_arg, (pcb),\
|
||||||
LWIP_EVENT_POLL, NULL, 0, ERR_OK)
|
LWIP_EVENT_POLL, NULL, 0, ERR_OK)
|
||||||
#define TCP_EVENT_ERR(errf,arg,err) lwip_tcp_event((arg), NULL, \
|
#define TCP_EVENT_ERR(errf,arg,err) lwip_tcp_event((arg), NULL, \
|
||||||
LWIP_EVENT_ERR, NULL, 0, (err))
|
LWIP_EVENT_ERR, NULL, 0, (err))
|
||||||
#else /* LWIP_EVENT_API */
|
#else /* LWIP_EVENT_API */
|
||||||
#define TCP_EVENT_ACCEPT(pcb,err,ret) \
|
#define TCP_EVENT_ACCEPT(pcb,err,ret) \
|
||||||
if((pcb)->accept != NULL) \
|
if((pcb)->accept != NULL) \
|
||||||
@ -342,7 +342,7 @@ err_t lwip_tcp_event(void *arg, struct tcp_pcb *pcb,
|
|||||||
#define TCP_EVENT_RECV(pcb,p,err,ret) \
|
#define TCP_EVENT_RECV(pcb,p,err,ret) \
|
||||||
if((pcb)->recv != NULL) \
|
if((pcb)->recv != NULL) \
|
||||||
{ ret = (pcb)->recv((pcb)->callback_arg,(pcb),(p),(err)); } else { \
|
{ ret = (pcb)->recv((pcb)->callback_arg,(pcb),(p),(err)); } else { \
|
||||||
pbuf_free(p); }
|
pbuf_free(p); }
|
||||||
#define TCP_EVENT_CONNECTED(pcb,err,ret) \
|
#define TCP_EVENT_CONNECTED(pcb,err,ret) \
|
||||||
if((pcb)->connected != NULL) \
|
if((pcb)->connected != NULL) \
|
||||||
(ret = (pcb)->connected((pcb)->callback_arg,(pcb),(err)))
|
(ret = (pcb)->connected((pcb)->callback_arg,(pcb),(err)))
|
||||||
@ -385,14 +385,14 @@ struct tcp_seg *tcp_seg_copy(struct tcp_seg *seg);
|
|||||||
|
|
||||||
err_t tcp_send_ctrl(struct tcp_pcb *pcb, u8_t flags);
|
err_t tcp_send_ctrl(struct tcp_pcb *pcb, u8_t flags);
|
||||||
err_t tcp_enqueue(struct tcp_pcb *pcb, void *dataptr, u16_t len,
|
err_t tcp_enqueue(struct tcp_pcb *pcb, void *dataptr, u16_t len,
|
||||||
u8_t flags, u8_t copy,
|
u8_t flags, u8_t copy,
|
||||||
u8_t *optdata, u8_t optlen);
|
u8_t *optdata, u8_t optlen);
|
||||||
|
|
||||||
void tcp_rexmit_seg(struct tcp_pcb *pcb, struct tcp_seg *seg);
|
void tcp_rexmit_seg(struct tcp_pcb *pcb, struct tcp_seg *seg);
|
||||||
|
|
||||||
void tcp_rst(u32_t seqno, u32_t ackno,
|
void tcp_rst(u32_t seqno, u32_t ackno,
|
||||||
struct ip_addr *local_ip, struct ip_addr *remote_ip,
|
struct ip_addr *local_ip, struct ip_addr *remote_ip,
|
||||||
u16_t local_port, u16_t remote_port);
|
u16_t local_port, u16_t remote_port);
|
||||||
|
|
||||||
u32_t tcp_next_iss(void);
|
u32_t tcp_next_iss(void);
|
||||||
|
|
||||||
@ -418,8 +418,8 @@ void tcp_timer_needed(void);
|
|||||||
/* The TCP PCB lists. */
|
/* The TCP PCB lists. */
|
||||||
extern struct tcp_pcb_listen *tcp_listen_pcbs; /* List of all TCP PCBs in LISTEN state. */
|
extern struct tcp_pcb_listen *tcp_listen_pcbs; /* List of all TCP PCBs in LISTEN state. */
|
||||||
extern struct tcp_pcb *tcp_active_pcbs; /* List of all TCP PCBs that are in a
|
extern struct tcp_pcb *tcp_active_pcbs; /* List of all TCP PCBs that are in a
|
||||||
state in which they accept or send
|
state in which they accept or send
|
||||||
data. */
|
data. */
|
||||||
extern struct tcp_pcb *tcp_tw_pcbs; /* List of all TCP PCBs in TIME-WAIT. */
|
extern struct tcp_pcb *tcp_tw_pcbs; /* List of all TCP PCBs in TIME-WAIT. */
|
||||||
|
|
||||||
extern struct tcp_pcb *tcp_tmp_pcb; /* Only used for temporary storage. */
|
extern struct tcp_pcb *tcp_tmp_pcb; /* Only used for temporary storage. */
|
||||||
@ -437,8 +437,8 @@ extern struct tcp_pcb *tcp_tmp_pcb; /* Only used for temporary storage. */
|
|||||||
#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)); \
|
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) { \
|
||||||
LWIP_ASSERT("TCP_REG: already registered\n", tcp_tmp_pcb != npcb); \
|
LWIP_ASSERT("TCP_REG: already registered\n", tcp_tmp_pcb != npcb); \
|
||||||
} \
|
} \
|
||||||
LWIP_ASSERT("TCP_REG: pcb->state != CLOSED", npcb->state != CLOSED); \
|
LWIP_ASSERT("TCP_REG: pcb->state != CLOSED", npcb->state != CLOSED); \
|
||||||
@ -446,7 +446,7 @@ extern struct tcp_pcb *tcp_tmp_pcb; /* Only used for temporary storage. */
|
|||||||
LWIP_ASSERT("TCP_REG: npcb->next != npcb", npcb->next != npcb); \
|
LWIP_ASSERT("TCP_REG: npcb->next != npcb", npcb->next != npcb); \
|
||||||
*(pcbs) = npcb; \
|
*(pcbs) = npcb; \
|
||||||
LWIP_ASSERT("TCP_RMV: tcp_pcbs sane", tcp_pcbs_sane()); \
|
LWIP_ASSERT("TCP_RMV: tcp_pcbs sane", tcp_pcbs_sane()); \
|
||||||
tcp_timer_needed(); \
|
tcp_timer_needed(); \
|
||||||
} 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); \
|
||||||
@ -468,7 +468,7 @@ extern struct tcp_pcb *tcp_tmp_pcb; /* Only used for temporary storage. */
|
|||||||
#define TCP_REG(pcbs, npcb) do { \
|
#define TCP_REG(pcbs, npcb) do { \
|
||||||
npcb->next = *pcbs; \
|
npcb->next = *pcbs; \
|
||||||
*(pcbs) = npcb; \
|
*(pcbs) = npcb; \
|
||||||
tcp_timer_needed(); \
|
tcp_timer_needed(); \
|
||||||
} while(0)
|
} while(0)
|
||||||
#define TCP_RMV(pcbs, npcb) do { \
|
#define TCP_RMV(pcbs, npcb) do { \
|
||||||
if(*(pcbs) == npcb) { \
|
if(*(pcbs) == npcb) { \
|
||||||
|
@ -63,7 +63,7 @@ struct udp_pcb {
|
|||||||
u16_t chksum_len;
|
u16_t chksum_len;
|
||||||
|
|
||||||
void (* recv)(void *arg, struct udp_pcb *pcb, struct pbuf *p,
|
void (* recv)(void *arg, struct udp_pcb *pcb, struct pbuf *p,
|
||||||
struct ip_addr *addr, u16_t port);
|
struct ip_addr *addr, u16_t port);
|
||||||
void *recv_arg;
|
void *recv_arg;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -77,11 +77,11 @@ err_t udp_connect (struct udp_pcb *pcb, struct ip_addr *ipaddr,
|
|||||||
u16_t port);
|
u16_t port);
|
||||||
void udp_disconnect (struct udp_pcb *pcb);
|
void udp_disconnect (struct udp_pcb *pcb);
|
||||||
void udp_recv (struct udp_pcb *pcb,
|
void udp_recv (struct udp_pcb *pcb,
|
||||||
void (* recv)(void *arg, struct udp_pcb *upcb,
|
void (* recv)(void *arg, struct udp_pcb *upcb,
|
||||||
struct pbuf *p,
|
struct pbuf *p,
|
||||||
struct ip_addr *addr,
|
struct ip_addr *addr,
|
||||||
u16_t port),
|
u16_t port),
|
||||||
void *recv_arg);
|
void *recv_arg);
|
||||||
err_t udp_send (struct udp_pcb *pcb, struct pbuf *p);
|
err_t udp_send (struct udp_pcb *pcb, struct pbuf *p);
|
||||||
|
|
||||||
#define udp_flags(pcb) ((pcb)->flags)
|
#define udp_flags(pcb) ((pcb)->flags)
|
||||||
|
@ -88,9 +88,9 @@ void etharp_init(void);
|
|||||||
void etharp_tmr(void);
|
void etharp_tmr(void);
|
||||||
struct pbuf *etharp_ip_input(struct netif *netif, struct pbuf *p);
|
struct pbuf *etharp_ip_input(struct netif *netif, struct pbuf *p);
|
||||||
struct pbuf *etharp_arp_input(struct netif *netif, struct eth_addr *ethaddr,
|
struct pbuf *etharp_arp_input(struct netif *netif, struct eth_addr *ethaddr,
|
||||||
struct pbuf *p);
|
struct pbuf *p);
|
||||||
struct pbuf *etharp_output(struct netif *netif, struct ip_addr *ipaddr,
|
struct pbuf *etharp_output(struct netif *netif, struct ip_addr *ipaddr,
|
||||||
struct pbuf *q);
|
struct pbuf *q);
|
||||||
err_t etharp_query(struct netif *netif, struct ip_addr *ipaddr, struct pbuf *q);
|
err_t etharp_query(struct netif *netif, struct ip_addr *ipaddr, struct pbuf *q);
|
||||||
|
|
||||||
|
|
||||||
|
@ -166,7 +166,7 @@ etharp_tmr(void)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
} 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));
|
DEBUGF(ETHARP_DEBUG, ("etharp_timer: expired pending entry %u.\n", i));
|
||||||
#if ARP_QUEUEING
|
#if ARP_QUEUEING
|
||||||
@ -214,7 +214,7 @@ find_arp_entry(void)
|
|||||||
#endif
|
#endif
|
||||||
(arp_table[i].ctime >= maxtime)) {
|
(arp_table[i].ctime >= maxtime)) {
|
||||||
maxtime = arp_table[i].ctime;
|
maxtime = arp_table[i].ctime;
|
||||||
j = i;
|
j = i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (j != ARP_TABLE_SIZE) {
|
if (j != ARP_TABLE_SIZE) {
|
||||||
|
@ -63,7 +63,7 @@ static const struct eth_addr ethbroadcast = {{0xff,0xff,0xff,0xff,0xff,0xff}};
|
|||||||
/* Forward declarations. */
|
/* Forward declarations. */
|
||||||
static void ethernetif_input(struct netif *netif);
|
static void ethernetif_input(struct netif *netif);
|
||||||
static err_t ethernetif_output(struct netif *netif, struct pbuf *p,
|
static err_t ethernetif_output(struct netif *netif, struct pbuf *p,
|
||||||
struct ip_addr *ipaddr);
|
struct ip_addr *ipaddr);
|
||||||
|
|
||||||
/*-----------------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------------*/
|
||||||
static void
|
static void
|
||||||
@ -179,7 +179,7 @@ low_level_input(struct ethernetif *ethernetif)
|
|||||||
/*-----------------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------------*/
|
||||||
static err_t
|
static err_t
|
||||||
ethernetif_output(struct netif *netif, struct pbuf *p,
|
ethernetif_output(struct netif *netif, struct pbuf *p,
|
||||||
struct ip_addr *ipaddr)
|
struct ip_addr *ipaddr)
|
||||||
{
|
{
|
||||||
struct ethernetif *ethernetif;
|
struct ethernetif *ethernetif;
|
||||||
struct pbuf *q;
|
struct pbuf *q;
|
||||||
@ -306,8 +306,8 @@ ethernetif_input(struct netif *netif)
|
|||||||
case ETHTYPE_ARP:
|
case ETHTYPE_ARP:
|
||||||
p = arp_arp_input(netif, ethernetif->ethaddr, p);
|
p = arp_arp_input(netif, ethernetif->ethaddr, p);
|
||||||
if (p != NULL) {
|
if (p != NULL) {
|
||||||
low_level_output(ethernetif, p);
|
low_level_output(ethernetif, p);
|
||||||
pbuf_free(p);
|
pbuf_free(p);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -43,7 +43,7 @@
|
|||||||
/*-----------------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------------*/
|
||||||
static err_t
|
static err_t
|
||||||
loopif_output(struct netif *netif, struct pbuf *p,
|
loopif_output(struct netif *netif, struct pbuf *p,
|
||||||
struct ip_addr *ipaddr)
|
struct ip_addr *ipaddr)
|
||||||
{
|
{
|
||||||
struct pbuf *q, *r;
|
struct pbuf *q, *r;
|
||||||
char *ptr;
|
char *ptr;
|
||||||
|
@ -71,16 +71,16 @@ slipif_output(struct netif *netif, struct pbuf *p, struct ip_addr *ipaddr)
|
|||||||
c = ((u8_t *)q->payload)[i];
|
c = ((u8_t *)q->payload)[i];
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case SLIP_END:
|
case SLIP_END:
|
||||||
sio_send(SLIP_ESC, netif->state);
|
sio_send(SLIP_ESC, netif->state);
|
||||||
sio_send(SLIP_ESC_END, netif->state);
|
sio_send(SLIP_ESC_END, netif->state);
|
||||||
break;
|
break;
|
||||||
case SLIP_ESC:
|
case SLIP_ESC:
|
||||||
sio_send(SLIP_ESC, netif->state);
|
sio_send(SLIP_ESC, netif->state);
|
||||||
sio_send(SLIP_ESC_ESC, netif->state);
|
sio_send(SLIP_ESC_ESC, netif->state);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
sio_send(c, netif->state);
|
sio_send(c, netif->state);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -112,15 +112,15 @@ slipif_input( struct netif * netif )
|
|||||||
switch (c) {
|
switch (c) {
|
||||||
case SLIP_END:
|
case SLIP_END:
|
||||||
if (recved > 0) {
|
if (recved > 0) {
|
||||||
/* Received whole packet. */
|
/* Received whole packet. */
|
||||||
pbuf_realloc(q, recved);
|
pbuf_realloc(q, recved);
|
||||||
|
|
||||||
#ifdef LINK_STATS
|
#ifdef LINK_STATS
|
||||||
++lwip_stats.link.recv;
|
++lwip_stats.link.recv;
|
||||||
#endif /* LINK_STATS */
|
#endif /* LINK_STATS */
|
||||||
|
|
||||||
DEBUGF(SLIP_DEBUG, ("slipif: Got packet\n"));
|
DEBUGF(SLIP_DEBUG, ("slipif: Got packet\n"));
|
||||||
return q;
|
return q;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -128,40 +128,40 @@ slipif_input( struct netif * netif )
|
|||||||
c = sio_recv(netif->state);
|
c = sio_recv(netif->state);
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case SLIP_ESC_END:
|
case SLIP_ESC_END:
|
||||||
c = SLIP_END;
|
c = SLIP_END;
|
||||||
break;
|
break;
|
||||||
case SLIP_ESC_ESC:
|
case SLIP_ESC_ESC:
|
||||||
c = SLIP_ESC;
|
c = SLIP_ESC;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* FALLTHROUGH */
|
/* FALLTHROUGH */
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if (p == NULL) {
|
if (p == NULL) {
|
||||||
DEBUGF(SLIP_DEBUG, ("slipif_input: alloc\n"));
|
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"));
|
DEBUGF(SLIP_DEBUG, ("slipif_input: no new pbuf! (DROP)\n"));
|
||||||
}
|
}
|
||||||
#endif /* LINK_STATS */
|
#endif /* LINK_STATS */
|
||||||
|
|
||||||
if (q != NULL) {
|
if (q != NULL) {
|
||||||
pbuf_chain(q, p);
|
pbuf_chain(q, p);
|
||||||
} else {
|
} else {
|
||||||
q = p;
|
q = p;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (p != NULL && recved < MAX_SIZE) {
|
if (p != NULL && recved < MAX_SIZE) {
|
||||||
((u8_t *)p->payload)[i] = c;
|
((u8_t *)p->payload)[i] = c;
|
||||||
recved++;
|
recved++;
|
||||||
i++;
|
i++;
|
||||||
if (i >= p->len) {
|
if (i >= p->len) {
|
||||||
i = 0;
|
i = 0;
|
||||||
p = NULL;
|
p = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -196,13 +196,13 @@ slipif_loop(void *nf)
|
|||||||
err_t
|
err_t
|
||||||
slipif_init(struct netif *netif)
|
slipif_init(struct netif *netif)
|
||||||
{
|
{
|
||||||
|
|
||||||
DEBUGF(SLIP_DEBUG, ("slipif_init: netif->num=%x\n", (int)netif->num));
|
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';
|
||||||
netif->output = slipif_output;
|
netif->output = slipif_output;
|
||||||
netif->mtu = 1500;
|
netif->mtu = 1500;
|
||||||
|
|
||||||
netif->state = sio_open(netif->num);
|
netif->state = sio_open(netif->num);
|
||||||
if (!netif->state)
|
if (!netif->state)
|
||||||
|
Loading…
Reference in New Issue
Block a user