mirror of
https://git.savannah.nongnu.org/git/lwip.git
synced 2025-12-10 08:46:40 +08:00
Removed all horizontal line seperators as they serve no use.
This commit is contained in:
parent
29f735d11a
commit
b76cd006d5
@ -38,7 +38,7 @@
|
||||
#include "lwip/api_msg.h"
|
||||
#include "lwip/memp.h"
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
struct
|
||||
netbuf *netbuf_new(void)
|
||||
{
|
||||
@ -53,7 +53,7 @@ netbuf *netbuf_new(void)
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
void
|
||||
netbuf_delete(struct netbuf *buf)
|
||||
{
|
||||
@ -65,7 +65,7 @@ netbuf_delete(struct netbuf *buf)
|
||||
memp_free(MEMP_NETBUF, buf);
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
void *
|
||||
netbuf_alloc(struct netbuf *buf, u16_t size)
|
||||
{
|
||||
@ -80,7 +80,7 @@ netbuf_alloc(struct netbuf *buf, u16_t size)
|
||||
buf->ptr = buf->p;
|
||||
return buf->p->payload;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
void
|
||||
netbuf_free(struct netbuf *buf)
|
||||
{
|
||||
@ -89,7 +89,7 @@ netbuf_free(struct netbuf *buf)
|
||||
}
|
||||
buf->p = buf->ptr = NULL;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
void
|
||||
netbuf_ref(struct netbuf *buf, void *dataptr, u16_t size)
|
||||
{
|
||||
@ -101,7 +101,7 @@ netbuf_ref(struct netbuf *buf, void *dataptr, u16_t size)
|
||||
buf->p->len = buf->p->tot_len = size;
|
||||
buf->ptr = buf->p;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
void
|
||||
netbuf_chain(struct netbuf *head, struct netbuf *tail)
|
||||
{
|
||||
@ -109,13 +109,13 @@ netbuf_chain(struct netbuf *head, struct netbuf *tail)
|
||||
head->ptr = head->p;
|
||||
memp_free(MEMP_NETBUF, tail);
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
u16_t
|
||||
netbuf_len(struct netbuf *buf)
|
||||
{
|
||||
return buf->p->tot_len;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
err_t
|
||||
netbuf_data(struct netbuf *buf, void **dataptr, u16_t *len)
|
||||
{
|
||||
@ -126,7 +126,7 @@ netbuf_data(struct netbuf *buf, void **dataptr, u16_t *len)
|
||||
*len = buf->ptr->len;
|
||||
return ERR_OK;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
s8_t
|
||||
netbuf_next(struct netbuf *buf)
|
||||
{
|
||||
@ -139,13 +139,13 @@ netbuf_next(struct netbuf *buf)
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
void
|
||||
netbuf_first(struct netbuf *buf)
|
||||
{
|
||||
buf->ptr = buf->p;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
void
|
||||
netbuf_copy_partial(struct netbuf *buf, void *dataptr, u16_t len, u16_t offset)
|
||||
{
|
||||
@ -174,25 +174,25 @@ netbuf_copy_partial(struct netbuf *buf, void *dataptr, u16_t len, u16_t offset)
|
||||
}
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
void
|
||||
netbuf_copy(struct netbuf *buf, void *dataptr, u16_t len)
|
||||
{
|
||||
netbuf_copy_partial(buf, dataptr, len, 0);
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
struct ip_addr *
|
||||
netbuf_fromaddr(struct netbuf *buf)
|
||||
{
|
||||
return buf->fromaddr;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
u16_t
|
||||
netbuf_fromport(struct netbuf *buf)
|
||||
{
|
||||
return buf->fromport;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
struct
|
||||
netconn *netconn_new_with_proto_and_callback(enum netconn_type t, u16_t proto,
|
||||
void (*callback)(struct netconn *, enum netconn_evt, u16_t len))
|
||||
@ -241,13 +241,13 @@ netconn *netconn_new_with_proto_and_callback(enum netconn_type t, u16_t proto,
|
||||
return conn;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
struct
|
||||
netconn *netconn_new(enum netconn_type t)
|
||||
{
|
||||
return netconn_new_with_proto_and_callback(t,0,NULL);
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
struct
|
||||
netconn *netconn_new_with_callback(enum netconn_type t,
|
||||
void (*callback)(struct netconn *, enum netconn_evt, u16_t len))
|
||||
@ -255,7 +255,7 @@ netconn *netconn_new_with_callback(enum netconn_type t,
|
||||
return netconn_new_with_proto_and_callback(t,0,callback);
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
err_t
|
||||
netconn_delete(struct netconn *conn)
|
||||
{
|
||||
@ -309,13 +309,13 @@ netconn_delete(struct netconn *conn)
|
||||
memp_free(MEMP_NETCONN, conn);
|
||||
return ERR_OK;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
enum netconn_type
|
||||
netconn_type(struct netconn *conn)
|
||||
{
|
||||
return conn->type;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
err_t
|
||||
netconn_peer(struct netconn *conn, struct ip_addr *addr,
|
||||
u16_t *port)
|
||||
@ -342,7 +342,7 @@ netconn_peer(struct netconn *conn, struct ip_addr *addr,
|
||||
}
|
||||
return (conn->err = ERR_OK);
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
err_t
|
||||
netconn_addr(struct netconn *conn, struct ip_addr **addr,
|
||||
u16_t *port)
|
||||
@ -365,7 +365,7 @@ netconn_addr(struct netconn *conn, struct ip_addr **addr,
|
||||
}
|
||||
return (conn->err = ERR_OK);
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
err_t
|
||||
netconn_bind(struct netconn *conn, struct ip_addr *addr,
|
||||
u16_t port)
|
||||
@ -396,7 +396,7 @@ netconn_bind(struct netconn *conn, struct ip_addr *addr,
|
||||
return conn->err;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
err_t
|
||||
netconn_connect(struct netconn *conn, struct ip_addr *addr,
|
||||
u16_t port)
|
||||
@ -447,7 +447,7 @@ netconn_disconnect(struct netconn *conn)
|
||||
return conn->err;
|
||||
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
err_t
|
||||
netconn_listen(struct netconn *conn)
|
||||
{
|
||||
@ -474,7 +474,7 @@ netconn_listen(struct netconn *conn)
|
||||
memp_free(MEMP_API_MSG, msg);
|
||||
return conn->err;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
struct netconn *
|
||||
netconn_accept(struct netconn *conn)
|
||||
{
|
||||
@ -491,7 +491,7 @@ netconn_accept(struct netconn *conn)
|
||||
|
||||
return newconn;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
struct netbuf *
|
||||
netconn_recv(struct netconn *conn)
|
||||
{
|
||||
@ -587,7 +587,7 @@ netconn_recv(struct netconn *conn)
|
||||
|
||||
return buf;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
err_t
|
||||
netconn_send(struct netconn *conn, struct netbuf *buf)
|
||||
{
|
||||
@ -615,7 +615,7 @@ netconn_send(struct netconn *conn, struct netbuf *buf)
|
||||
memp_free(MEMP_API_MSG, msg);
|
||||
return conn->err;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
err_t
|
||||
netconn_write(struct netconn *conn, void *dataptr, u16_t size, u8_t copy)
|
||||
{
|
||||
@ -691,7 +691,7 @@ netconn_write(struct netconn *conn, void *dataptr, u16_t size, u8_t copy)
|
||||
|
||||
return conn->err;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
err_t
|
||||
netconn_close(struct netconn *conn)
|
||||
{
|
||||
@ -719,10 +719,10 @@ netconn_close(struct netconn *conn)
|
||||
memp_free(MEMP_API_MSG, msg);
|
||||
return conn->err;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
err_t
|
||||
netconn_err(struct netconn *conn)
|
||||
{
|
||||
return conn->err;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
@ -103,7 +103,7 @@ recv_udp(void *arg, struct udp_pcb *pcb, struct pbuf *p,
|
||||
}
|
||||
#endif /* LWIP_UDP */
|
||||
#if LWIP_TCP
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
static err_t
|
||||
recv_tcp(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err)
|
||||
{
|
||||
@ -134,7 +134,7 @@ recv_tcp(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err)
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
static err_t
|
||||
poll_tcp(void *arg, struct tcp_pcb *pcb)
|
||||
{
|
||||
@ -148,7 +148,7 @@ poll_tcp(void *arg, struct tcp_pcb *pcb)
|
||||
}
|
||||
return ERR_OK;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
static err_t
|
||||
sent_tcp(void *arg, struct tcp_pcb *pcb, u16_t len)
|
||||
{
|
||||
@ -165,7 +165,7 @@ sent_tcp(void *arg, struct tcp_pcb *pcb, u16_t len)
|
||||
|
||||
return ERR_OK;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
static void
|
||||
err_tcp(void *arg, err_t err)
|
||||
{
|
||||
@ -196,7 +196,7 @@ err_tcp(void *arg, err_t err)
|
||||
sys_sem_signal(conn->sem);
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
static void
|
||||
setup_tcp(struct netconn *conn)
|
||||
{
|
||||
@ -209,7 +209,7 @@ setup_tcp(struct netconn *conn)
|
||||
tcp_poll(pcb, poll_tcp, 4);
|
||||
tcp_err(pcb, err_tcp);
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
static err_t
|
||||
accept_function(void *arg, struct tcp_pcb *newpcb, err_t err)
|
||||
{
|
||||
@ -265,7 +265,7 @@ accept_function(void *arg, struct tcp_pcb *newpcb, err_t err)
|
||||
return ERR_OK;
|
||||
}
|
||||
#endif /* LWIP_TCP */
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
static void
|
||||
do_newconn(struct api_msg_msg *msg)
|
||||
{
|
||||
@ -331,7 +331,7 @@ do_newconn(struct api_msg_msg *msg)
|
||||
sys_mbox_post(msg->conn->mbox, NULL);
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
static void
|
||||
do_delconn(struct api_msg_msg *msg)
|
||||
{
|
||||
@ -384,7 +384,7 @@ do_delconn(struct api_msg_msg *msg)
|
||||
sys_mbox_post(msg->conn->mbox, NULL);
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
static void
|
||||
do_bind(struct api_msg_msg *msg)
|
||||
{
|
||||
@ -447,7 +447,7 @@ do_bind(struct api_msg_msg *msg)
|
||||
sys_mbox_post(msg->conn->mbox, NULL);
|
||||
}
|
||||
#if LWIP_TCP
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
static err_t
|
||||
do_connected(void *arg, struct tcp_pcb *pcb, err_t err)
|
||||
{
|
||||
@ -467,7 +467,7 @@ do_connected(void *arg, struct tcp_pcb *pcb, err_t err)
|
||||
return ERR_OK;
|
||||
}
|
||||
#endif
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
static void
|
||||
do_connect(struct api_msg_msg *msg)
|
||||
{
|
||||
@ -579,7 +579,7 @@ do_disconnect(struct api_msg_msg *msg)
|
||||
sys_mbox_post(msg->conn->mbox, NULL);
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
static void
|
||||
do_listen(struct api_msg_msg *msg)
|
||||
{
|
||||
@ -622,7 +622,7 @@ do_listen(struct api_msg_msg *msg)
|
||||
}
|
||||
sys_mbox_post(msg->conn->mbox, NULL);
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
static void
|
||||
do_accept(struct api_msg_msg *msg)
|
||||
{
|
||||
@ -647,7 +647,7 @@ do_accept(struct api_msg_msg *msg)
|
||||
}
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
static void
|
||||
do_send(struct api_msg_msg *msg)
|
||||
{
|
||||
@ -673,7 +673,7 @@ do_send(struct api_msg_msg *msg)
|
||||
}
|
||||
sys_mbox_post(msg->conn->mbox, NULL);
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
static void
|
||||
do_recv(struct api_msg_msg *msg)
|
||||
{
|
||||
@ -686,7 +686,7 @@ do_recv(struct api_msg_msg *msg)
|
||||
#endif
|
||||
sys_mbox_post(msg->conn->mbox, NULL);
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
static void
|
||||
do_write(struct api_msg_msg *msg)
|
||||
{
|
||||
@ -734,7 +734,7 @@ do_write(struct api_msg_msg *msg)
|
||||
}
|
||||
sys_mbox_post(msg->conn->mbox, NULL);
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
static void
|
||||
do_close(struct api_msg_msg *msg)
|
||||
{
|
||||
@ -769,7 +769,7 @@ do_close(struct api_msg_msg *msg)
|
||||
}
|
||||
sys_mbox_post(msg->conn->mbox, NULL);
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
typedef void (* api_msg_decode)(struct api_msg_msg *msg);
|
||||
static api_msg_decode decode[API_MSG_MAX] = {
|
||||
do_newconn,
|
||||
@ -789,12 +789,12 @@ api_msg_input(struct api_msg *msg)
|
||||
{
|
||||
decode[msg->type](&(msg->msg));
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
void
|
||||
api_msg_post(struct api_msg *msg)
|
||||
{
|
||||
tcpip_apimsg(msg);
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
|
||||
|
||||
@ -47,13 +47,13 @@ static char *err_strerr[] = {"Ok.",
|
||||
"Address in use."
|
||||
};
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
char *
|
||||
lwip_strerr(err_t err)
|
||||
{
|
||||
return err_strerr[-err];
|
||||
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
#endif /* LWIP_DEBUG */
|
||||
|
||||
@ -99,7 +99,7 @@ static int err_to_errno_table[11] = {
|
||||
set_errno(sk->err); \
|
||||
} while (0)
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
static struct lwip_socket *
|
||||
get_socket(int s)
|
||||
{
|
||||
@ -121,7 +121,7 @@ get_socket(int s)
|
||||
|
||||
return sock;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
static int
|
||||
alloc_socket(struct netconn *newconn)
|
||||
{
|
||||
@ -150,7 +150,7 @@ alloc_socket(struct netconn *newconn)
|
||||
sys_sem_signal(socksem);
|
||||
return -1;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
int
|
||||
lwip_accept(int s, struct sockaddr *addr, socklen_t *addrlen)
|
||||
{
|
||||
@ -205,7 +205,7 @@ lwip_accept(int s, struct sockaddr *addr, socklen_t *addrlen)
|
||||
sock_set_errno(sock, 0);
|
||||
return newsock;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
int
|
||||
lwip_bind(int s, struct sockaddr *name, socklen_t namelen)
|
||||
{
|
||||
@ -239,7 +239,7 @@ lwip_bind(int s, struct sockaddr *name, socklen_t namelen)
|
||||
sock_set_errno(sock, 0);
|
||||
return 0;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
int
|
||||
lwip_close(int s)
|
||||
{
|
||||
@ -270,7 +270,7 @@ lwip_close(int s)
|
||||
sock_set_errno(sock, 0);
|
||||
return 0;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
int
|
||||
lwip_connect(int s, struct sockaddr *name, socklen_t namelen)
|
||||
{
|
||||
@ -310,7 +310,7 @@ lwip_connect(int s, struct sockaddr *name, socklen_t namelen)
|
||||
sock_set_errno(sock, 0);
|
||||
return 0;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
int
|
||||
lwip_listen(int s, int backlog)
|
||||
{
|
||||
@ -335,7 +335,7 @@ lwip_listen(int s, int backlog)
|
||||
sock_set_errno(sock, 0);
|
||||
return 0;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
int
|
||||
lwip_recvfrom(int s, void *mem, int len, unsigned int flags,
|
||||
struct sockaddr *from, socklen_t *fromlen)
|
||||
@ -442,19 +442,19 @@ lwip_recvfrom(int s, void *mem, int len, unsigned int flags,
|
||||
sock_set_errno(sock, 0);
|
||||
return copylen;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
int
|
||||
lwip_read(int s, void *mem, int len)
|
||||
{
|
||||
return lwip_recvfrom(s, mem, len, 0, NULL, NULL);
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
int
|
||||
lwip_recv(int s, void *mem, int len, unsigned int flags)
|
||||
{
|
||||
return lwip_recvfrom(s, mem, len, flags, NULL, NULL);
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
int
|
||||
lwip_send(int s, void *data, int size, unsigned int flags)
|
||||
{
|
||||
@ -511,7 +511,7 @@ lwip_send(int s, void *data, int size, unsigned int flags)
|
||||
sock_set_errno(sock, 0);
|
||||
return size;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
int
|
||||
lwip_sendto(int s, void *data, int size, unsigned int flags,
|
||||
struct sockaddr *to, socklen_t tolen)
|
||||
@ -549,7 +549,7 @@ lwip_sendto(int s, void *data, int size, unsigned int flags,
|
||||
netconn_disconnect(sock->conn);
|
||||
return ret;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
int
|
||||
lwip_socket(int domain, int type, int protocol)
|
||||
{
|
||||
@ -594,14 +594,14 @@ lwip_socket(int domain, int type, int protocol)
|
||||
set_errno(0);
|
||||
return i;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
int
|
||||
lwip_write(int s, void *data, int size)
|
||||
{
|
||||
return lwip_send(s, data, size, 0);
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
static int
|
||||
lwip_selscan(int maxfdp1, fd_set *readset, fd_set *writeset, fd_set *exceptset)
|
||||
{
|
||||
@ -648,7 +648,7 @@ lwip_selscan(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,
|
||||
struct timeval *timeout)
|
||||
@ -794,7 +794,7 @@ lwip_select(int maxfdp1, fd_set *readset, fd_set *writeset, fd_set *exceptset,
|
||||
return nready;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
static void
|
||||
event_callback(struct netconn *conn, enum netconn_evt evt, u16_t len)
|
||||
{
|
||||
@ -883,7 +883,7 @@ event_callback(struct netconn *conn, enum netconn_evt evt, u16_t len)
|
||||
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
|
||||
int lwip_shutdown(int s, int how)
|
||||
|
||||
@ -50,7 +50,7 @@ static sys_mbox_t mbox;
|
||||
static int tcpip_tcp_timer_active = 0;
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
static void
|
||||
tcpip_tcp_timer(void *arg)
|
||||
{
|
||||
@ -73,7 +73,7 @@ tcp_timer_needed(void)
|
||||
}
|
||||
}
|
||||
#endif /* LWIP_TCP */
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
static void
|
||||
tcpip_thread(void *arg)
|
||||
{
|
||||
@ -113,7 +113,7 @@ tcpip_thread(void *arg)
|
||||
memp_free(MEMP_TCPIP_MSG, msg);
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
err_t
|
||||
tcpip_input(struct pbuf *p, struct netif *inp)
|
||||
{
|
||||
@ -131,7 +131,7 @@ tcpip_input(struct pbuf *p, struct netif *inp)
|
||||
sys_mbox_post(mbox, msg);
|
||||
return ERR_OK;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
err_t
|
||||
tcpip_callback(void (*f)(void *ctx), void *ctx)
|
||||
{
|
||||
@ -148,7 +148,7 @@ tcpip_callback(void (*f)(void *ctx), void *ctx)
|
||||
sys_mbox_post(mbox, msg);
|
||||
return ERR_OK;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
void
|
||||
tcpip_apimsg(struct api_msg *apimsg)
|
||||
{
|
||||
@ -162,7 +162,7 @@ tcpip_apimsg(struct api_msg *apimsg)
|
||||
msg->msg.apimsg = apimsg;
|
||||
sys_mbox_post(mbox, msg);
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
void
|
||||
tcpip_init(void (* initfunc)(void *), void *arg)
|
||||
{
|
||||
@ -171,7 +171,7 @@ tcpip_init(void (* initfunc)(void *), void *arg)
|
||||
mbox = sys_mbox_new();
|
||||
sys_thread_new(tcpip_thread, NULL, TCPIP_THREAD_PRIO);
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -30,14 +30,14 @@
|
||||
*
|
||||
*/
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
/* inet.c
|
||||
*
|
||||
* Functions common to all TCP/IP modules, such as the Internet checksum and the
|
||||
* byte order functions.
|
||||
*
|
||||
*/
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
#include "lwip/opt.h"
|
||||
|
||||
@ -47,7 +47,7 @@
|
||||
#include "lwip/inet.h"
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
static u16_t
|
||||
lwip_chksum(void *dataptr, int len)
|
||||
{
|
||||
@ -75,12 +75,12 @@ lwip_chksum(void *dataptr, int len)
|
||||
|
||||
return (u16_t)acc;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
/* inet_chksum_pseudo:
|
||||
*
|
||||
* Calculates the pseudo Internet checksum used by TCP and UDP for a pbuf chain.
|
||||
*/
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
u16_t
|
||||
inet_chksum_pseudo(struct pbuf *p,
|
||||
struct ip_addr *src, struct ip_addr *dest,
|
||||
@ -124,13 +124,13 @@ inet_chksum_pseudo(struct pbuf *p,
|
||||
LWIP_DEBUGF(INET_DEBUG, ("inet_chksum_pseudo(): pbuf chain lwip_chksum()=%lx\n", acc));
|
||||
return ~(acc & 0xffffUL);
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
/* inet_chksum:
|
||||
*
|
||||
* Calculates the Internet checksum over a portion of memory. Used primarely for IP
|
||||
* and ICMP.
|
||||
*/
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
u16_t
|
||||
inet_chksum(void *dataptr, u16_t len)
|
||||
{
|
||||
@ -142,7 +142,7 @@ inet_chksum(void *dataptr, u16_t len)
|
||||
}
|
||||
return ~(acc & 0xffff);
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
u16_t
|
||||
inet_chksum_pbuf(struct pbuf *p)
|
||||
{
|
||||
@ -179,7 +179,7 @@ inet_chksum_pbuf(struct pbuf *p)
|
||||
#define isspace(c) (c == ' ' || c == '\f' || c == '\n' || c == '\r' || c == '\t' || c == '\v')
|
||||
#endif
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
* Ascii internet address interpretation routine.
|
||||
* The value returned is in network order.
|
||||
@ -328,24 +328,24 @@ u8_t *inet_ntoa(u32_t addr)
|
||||
return str;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef BYTE_ORDER
|
||||
#error BYTE_ORDER is not defined
|
||||
#endif
|
||||
#if BYTE_ORDER == LITTLE_ENDIAN
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
u16_t
|
||||
htons(u16_t n)
|
||||
{
|
||||
return ((n & 0xff) << 8) | ((n & 0xff00) >> 8);
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
u16_t
|
||||
ntohs(u16_t n)
|
||||
{
|
||||
return htons(n);
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
u32_t
|
||||
htonl(u32_t n)
|
||||
{
|
||||
@ -354,11 +354,11 @@ htonl(u32_t n)
|
||||
((n & 0xff0000) >> 8) |
|
||||
((n & 0xff000000) >> 24);
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
u32_t
|
||||
ntohl(u32_t n)
|
||||
{
|
||||
return htonl(n);
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
#endif /* BYTE_ORDER == LITTLE_ENDIAN */
|
||||
|
||||
@ -30,14 +30,14 @@
|
||||
*
|
||||
*/
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
/* inet6.c
|
||||
*
|
||||
* Functions common to all TCP/IP modules, such as the Internet checksum and the
|
||||
* byte order functions.
|
||||
*
|
||||
*/
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
#include "lwip/opt.h"
|
||||
|
||||
@ -45,7 +45,7 @@
|
||||
#include "lwip/inet.h"
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
/* chksum:
|
||||
*
|
||||
* Sums up all 16 bit words in a memory portion. Also includes any odd byte.
|
||||
@ -54,7 +54,7 @@
|
||||
* For now, this is not optimized. Must be optimized for the particular processor
|
||||
* arcitecture on which it is to run. Preferebly coded in assembler.
|
||||
*/
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
static u32_t
|
||||
chksum(void *dataptr, u16_t len)
|
||||
{
|
||||
@ -74,12 +74,12 @@ chksum(void *dataptr, u16_t len)
|
||||
return acc;
|
||||
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
/* inet_chksum_pseudo:
|
||||
*
|
||||
* Calculates the pseudo Internet checksum used by TCP and UDP for a pbuf chain.
|
||||
*/
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
u16_t
|
||||
inet_chksum_pseudo(struct pbuf *p,
|
||||
struct ip_addr *src, struct ip_addr *dest,
|
||||
@ -122,13 +122,13 @@ inet_chksum_pseudo(struct pbuf *p,
|
||||
}
|
||||
return ~(acc & 0xffff);
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
/* inet_chksum:
|
||||
*
|
||||
* Calculates the Internet checksum over a portion of memory. Used primarely for IP
|
||||
* and ICMP.
|
||||
*/
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
u16_t
|
||||
inet_chksum(void *dataptr, u16_t len)
|
||||
{
|
||||
@ -139,7 +139,7 @@ inet_chksum(void *dataptr, u16_t len)
|
||||
sum += (sum >> 16);
|
||||
return ~(sum & 0xffff);
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
u16_t
|
||||
inet_chksum_pbuf(struct pbuf *p)
|
||||
{
|
||||
@ -165,4 +165,4 @@ inet_chksum_pbuf(struct pbuf *p)
|
||||
}
|
||||
return ~(acc & 0xffff);
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
@ -43,7 +43,7 @@
|
||||
#include "lwip/stats.h"
|
||||
|
||||
#include "lwip/snmp.h"
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
void
|
||||
icmp_input(struct pbuf *p, struct netif *inp)
|
||||
{
|
||||
@ -124,7 +124,7 @@ icmp_input(struct pbuf *p, struct netif *inp)
|
||||
}
|
||||
pbuf_free(p);
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
void
|
||||
icmp_dest_unreach(struct pbuf *p, enum icmp_dur_type t)
|
||||
{
|
||||
@ -156,7 +156,7 @@ icmp_dest_unreach(struct pbuf *p, enum icmp_dur_type t)
|
||||
ICMP_TTL, 0, IP_PROTO_ICMP);
|
||||
pbuf_free(q);
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
#if IP_FORWARD
|
||||
void
|
||||
icmp_time_exceeded(struct pbuf *p, enum icmp_te_type t)
|
||||
|
||||
@ -31,13 +31,13 @@
|
||||
*/
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
/* ip.c
|
||||
*
|
||||
* This is the code for the IP layer.
|
||||
*
|
||||
*/
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
#include "lwip/opt.h"
|
||||
|
||||
@ -62,23 +62,23 @@
|
||||
# include "lwip/dhcp.h"
|
||||
#endif /* LWIP_DHCP */
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
/* ip_init:
|
||||
*
|
||||
* Initializes the IP layer.
|
||||
*/
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
void
|
||||
ip_init(void)
|
||||
{
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
/* ip_lookup:
|
||||
*
|
||||
* An experimental feature that will be changed in future versions. Do
|
||||
* not depend on it yet...
|
||||
*/
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
#ifdef LWIP_DEBUG
|
||||
u8_t
|
||||
ip_lookup(void *header, struct netif *inp)
|
||||
@ -123,7 +123,7 @@ ip_lookup(void *header, struct netif *inp)
|
||||
}
|
||||
}
|
||||
#endif /* LWIP_DEBUG */
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
/* ip_route:
|
||||
*
|
||||
* Finds the appropriate network interface for a given IP address. It
|
||||
@ -131,7 +131,7 @@ ip_lookup(void *header, struct netif *inp)
|
||||
* if the masked IP address of the network interface equals the masked
|
||||
* IP address given to the function.
|
||||
*/
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
struct netif *
|
||||
ip_route(struct ip_addr *dest)
|
||||
{
|
||||
@ -149,14 +149,14 @@ ip_route(struct ip_addr *dest)
|
||||
return netif_default;
|
||||
}
|
||||
#if IP_FORWARD
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
/* ip_forward:
|
||||
*
|
||||
* Forwards an IP packet. It finds an appropriate route for the
|
||||
* packet, decrements the TTL value of the packet, adjusts the
|
||||
* checksum and outputs the packet on the appropriate interface.
|
||||
*/
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
static void
|
||||
ip_forward(struct pbuf *p, struct ip_hdr *iphdr, struct netif *inp)
|
||||
{
|
||||
@ -210,7 +210,7 @@ ip_forward(struct pbuf *p, struct ip_hdr *iphdr, struct netif *inp)
|
||||
netif->output(netif, p, (struct ip_addr *)&(iphdr->dest));
|
||||
}
|
||||
#endif /* IP_FORWARD */
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
/* ip_input:
|
||||
*
|
||||
* This function is called by the network interface device driver when
|
||||
@ -221,7 +221,7 @@ ip_forward(struct pbuf *p, struct ip_hdr *iphdr, struct netif *inp)
|
||||
*
|
||||
* Finally, the packet is sent to the upper layer protocol input function.
|
||||
*/
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
err_t
|
||||
ip_input(struct pbuf *p, struct netif *inp) {
|
||||
static struct ip_hdr *iphdr;
|
||||
@ -418,7 +418,7 @@ ip_input(struct pbuf *p, struct netif *inp) {
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
/* ip_output_if:
|
||||
*
|
||||
* Sends an IP packet on a network interface. This function constructs
|
||||
@ -426,7 +426,7 @@ ip_input(struct pbuf *p, struct netif *inp) {
|
||||
* IP address is NULL, the IP address of the outgoing network
|
||||
* interface is filled in as source address.
|
||||
*/
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
err_t
|
||||
ip_output_if(struct pbuf *p, struct ip_addr *src, struct ip_addr *dest,
|
||||
u8_t ttl, u8_t tos,
|
||||
@ -487,13 +487,13 @@ ip_output_if(struct pbuf *p, struct ip_addr *src, struct ip_addr *dest,
|
||||
|
||||
return netif->output(netif, p, dest);
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
/* ip_output:
|
||||
*
|
||||
* Simple interface to ip_output_if. It finds the outgoing network
|
||||
* interface and calls upon ip_output_if to do the actual work.
|
||||
*/
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
err_t
|
||||
ip_output(struct pbuf *p, struct ip_addr *src, struct ip_addr *dest,
|
||||
u8_t ttl, u8_t tos, u8_t proto)
|
||||
@ -510,7 +510,7 @@ ip_output(struct pbuf *p, struct ip_addr *src, struct ip_addr *dest,
|
||||
|
||||
return ip_output_if(p, src, dest, ttl, tos, proto, netif);
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
#if IP_DEBUG
|
||||
void
|
||||
ip_debug_print(struct pbuf *p)
|
||||
@ -554,7 +554,7 @@ ip_debug_print(struct pbuf *p)
|
||||
LWIP_DEBUGF(IP_DEBUG, ("+-------------------------------+\n"));
|
||||
}
|
||||
#endif /* IP_DEBUG */
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -31,13 +31,13 @@
|
||||
*
|
||||
*/
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
/* ip_frag.c
|
||||
*
|
||||
* This is the code for IP segmentation and reassembly
|
||||
*
|
||||
*/
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
#include "lwip/opt.h"
|
||||
#include "lwip/sys.h"
|
||||
|
||||
@ -42,7 +42,7 @@
|
||||
|
||||
#include "lwip/stats.h"
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
void
|
||||
icmp_input(struct pbuf *p, struct netif *inp)
|
||||
{
|
||||
@ -113,7 +113,7 @@ icmp_input(struct pbuf *p, struct netif *inp)
|
||||
|
||||
pbuf_free(p);
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
void
|
||||
icmp_dest_unreach(struct pbuf *p, enum icmp_dur_type t)
|
||||
{
|
||||
@ -143,7 +143,7 @@ icmp_dest_unreach(struct pbuf *p, enum icmp_dur_type t)
|
||||
(struct ip_addr *)&(iphdr->src), ICMP_TTL, IP_PROTO_ICMP);
|
||||
pbuf_free(q);
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
void
|
||||
icmp_time_exceeded(struct pbuf *p, enum icmp_te_type t)
|
||||
{
|
||||
|
||||
@ -31,13 +31,13 @@
|
||||
*/
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
/* ip.c
|
||||
*
|
||||
* This is the code for the IP layer for IPv6.
|
||||
*
|
||||
*/
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
#include "lwip/opt.h"
|
||||
|
||||
@ -53,24 +53,24 @@
|
||||
#include "lwip/stats.h"
|
||||
|
||||
#include "arch/perf.h"
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
/* ip_init:
|
||||
*
|
||||
* Initializes the IP layer.
|
||||
*/
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
void
|
||||
ip_init(void)
|
||||
{
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
/* ip_route:
|
||||
*
|
||||
* Finds the appropriate network interface for a given IP address. It searches the
|
||||
* list of network interfaces linearly. A match is found if the masked IP address of
|
||||
* the network interface equals the masked IP address given to the function.
|
||||
*/
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
struct netif *
|
||||
ip_route(struct ip_addr *dest)
|
||||
{
|
||||
@ -84,14 +84,14 @@ ip_route(struct ip_addr *dest)
|
||||
|
||||
return netif_default;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
/* ip_forward:
|
||||
*
|
||||
* Forwards an IP packet. It finds an appropriate route for the packet, decrements
|
||||
* the TTL value of the packet, adjusts the checksum and outputs the packet on the
|
||||
* appropriate interface.
|
||||
*/
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
static void
|
||||
ip_forward(struct pbuf *p, struct ip_hdr *iphdr)
|
||||
{
|
||||
@ -142,7 +142,7 @@ ip_forward(struct pbuf *p, struct ip_hdr *iphdr)
|
||||
|
||||
netif->output(netif, p, (struct ip_addr *)&(iphdr->dest));
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
/* ip_input:
|
||||
*
|
||||
* This function is called by the network interface device driver when an IP packet is
|
||||
@ -152,7 +152,7 @@ ip_forward(struct pbuf *p, struct ip_hdr *iphdr)
|
||||
*
|
||||
* Finally, the packet is sent to the upper layer protocol input function.
|
||||
*/
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
void
|
||||
ip_input(struct pbuf *p, struct netif *inp) {
|
||||
struct ip_hdr *iphdr;
|
||||
@ -249,14 +249,14 @@ ip_input(struct pbuf *p, struct netif *inp) {
|
||||
PERF_STOP("ip_input");
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
/* ip_output_if:
|
||||
*
|
||||
* Sends an IP packet on a network interface. This function constructs the IP header
|
||||
* and calculates the IP header checksum. If the source IP address is NULL,
|
||||
* the IP address of the outgoing network interface is filled in as source address.
|
||||
*/
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
err_t
|
||||
ip_output_if (struct pbuf *p, struct ip_addr *src, struct ip_addr *dest,
|
||||
u8_t ttl,
|
||||
@ -311,13 +311,13 @@ ip_output_if (struct pbuf *p, struct ip_addr *src, struct ip_addr *dest,
|
||||
PERF_STOP("ip_output_if");
|
||||
return netif->output(netif, p, dest);
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
/* ip_output:
|
||||
*
|
||||
* Simple interface to ip_output_if. It finds the outgoing network interface and
|
||||
* calls upon ip_output_if to do the actual work.
|
||||
*/
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
err_t
|
||||
ip_output(struct pbuf *p, struct ip_addr *src, struct ip_addr *dest,
|
||||
u8_t ttl, u8_t proto)
|
||||
@ -333,7 +333,7 @@ ip_output(struct pbuf *p, struct ip_addr *src, struct ip_addr *dest,
|
||||
|
||||
return ip_output_if (p, src, dest, ttl, proto, netif);
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
#if IP_DEBUG
|
||||
void
|
||||
ip_debug_print(struct pbuf *p)
|
||||
@ -383,4 +383,4 @@ ip_debug_print(struct pbuf *p)
|
||||
LWIP_DEBUGF(IP_DEBUG, ("+-------------------------------+\n"));
|
||||
}
|
||||
#endif /* IP_DEBUG */
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
@ -33,7 +33,7 @@
|
||||
#include "lwip/ip_addr.h"
|
||||
#include "lwip/inet.h"
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
int
|
||||
ip_addr_maskcmp(struct ip_addr *addr1, struct ip_addr *addr2,
|
||||
struct ip_addr *mask)
|
||||
@ -44,7 +44,7 @@ ip_addr_maskcmp(struct ip_addr *addr1, struct ip_addr *addr2,
|
||||
(addr1->addr[3] & mask->addr[3]) == (addr2->addr[3] & mask->addr[3]));
|
||||
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
int
|
||||
ip_addr_cmp(struct ip_addr *addr1, struct ip_addr *addr2)
|
||||
{
|
||||
@ -53,7 +53,7 @@ ip_addr_cmp(struct ip_addr *addr1, struct ip_addr *addr2)
|
||||
addr1->addr[2] == addr2->addr[2] &&
|
||||
addr1->addr[3] == addr2->addr[3]);
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
void
|
||||
ip_addr_set(struct ip_addr *dest, struct ip_addr *src)
|
||||
{
|
||||
@ -63,7 +63,7 @@ ip_addr_set(struct ip_addr *dest, struct ip_addr *src)
|
||||
dest->addr[2] = src->addr[2];
|
||||
dest->addr[3] = src->addr[3];*/
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
int
|
||||
ip_addr_isany(struct ip_addr *addr)
|
||||
{
|
||||
@ -71,7 +71,7 @@ ip_addr_isany(struct ip_addr *addr)
|
||||
return((addr->addr[0] | addr->addr[1] | addr->addr[2] | addr->addr[3]) == 0);
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
/*#if IP_DEBUG*/
|
||||
void
|
||||
ip_addr_debug_print(struct ip_addr *addr)
|
||||
@ -87,4 +87,4 @@ ip_addr_debug_print(struct ip_addr *addr)
|
||||
ntohl(addr->addr[3]) & 0xffff);
|
||||
}
|
||||
/*#endif*/ /* IP_DEBUG */
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
@ -183,7 +183,7 @@ mem_reallocm(void *rmem, mem_size_t newsize)
|
||||
mem_free(rmem);
|
||||
return nmem;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
void *
|
||||
mem_realloc(void *rmem, mem_size_t newsize)
|
||||
{
|
||||
|
||||
@ -115,11 +115,11 @@ static u8_t memp_memory[(MEMP_NUM_PBUF *
|
||||
MEM_ALIGN_SIZE(sizeof(struct sys_timeout) +
|
||||
sizeof(struct memp)))];
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
#if !SYS_LIGHTWEIGHT_PROT
|
||||
static sys_sem_t mutex;
|
||||
#endif
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef LWIP_NOASSERT
|
||||
static int
|
||||
memp_sanity(void)
|
||||
@ -141,7 +141,7 @@ memp_sanity(void)
|
||||
return 1;
|
||||
}
|
||||
#endif /* LWIP_DEBUG */
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
void
|
||||
memp_init(void)
|
||||
{
|
||||
@ -182,7 +182,7 @@ memp_init(void)
|
||||
|
||||
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
void *
|
||||
memp_malloc(memp_t type)
|
||||
{
|
||||
@ -236,7 +236,7 @@ memp_malloc(memp_t type)
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
void
|
||||
memp_free(memp_t type, void *mem)
|
||||
{
|
||||
@ -271,4 +271,4 @@ memp_free(memp_t type, void *mem)
|
||||
sys_sem_signal(mutex);
|
||||
#endif /* SYS_LIGHTWEIGHT_PROT */
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
@ -168,7 +168,7 @@ netif_find(char *name)
|
||||
LWIP_DEBUGF(NETIF_DEBUG, ("netif_find: didn't find %c%c\n", name[0], name[1]));
|
||||
return NULL;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
void
|
||||
netif_set_ipaddr(struct netif *netif, struct ip_addr *ipaddr)
|
||||
{
|
||||
@ -214,7 +214,7 @@ netif_set_ipaddr(struct netif *netif, struct ip_addr *ipaddr)
|
||||
(unsigned int)(ntohl(netif->ip_addr.addr) >> 8 & 0xff),
|
||||
(unsigned int)(ntohl(netif->ip_addr.addr) & 0xff)));
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
void
|
||||
netif_set_gw(struct netif *netif, struct ip_addr *gw)
|
||||
{
|
||||
@ -226,7 +226,7 @@ netif_set_gw(struct netif *netif, struct ip_addr *gw)
|
||||
(unsigned int)(ntohl(netif->gw.addr) >> 8 & 0xff),
|
||||
(unsigned int)(ntohl(netif->gw.addr) & 0xff)));
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
void
|
||||
netif_set_netmask(struct netif *netif, struct ip_addr *netmask)
|
||||
{
|
||||
@ -238,7 +238,7 @@ netif_set_netmask(struct netif *netif, struct ip_addr *netmask)
|
||||
(unsigned int)(ntohl(netif->netmask.addr) >> 8 & 0xff),
|
||||
(unsigned int)(ntohl(netif->netmask.addr) & 0xff)));
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
void
|
||||
netif_set_default(struct netif *netif)
|
||||
{
|
||||
@ -246,10 +246,10 @@ netif_set_default(struct netif *netif)
|
||||
LWIP_DEBUGF(NETIF_DEBUG, ("netif: setting default interface %c%c\n",
|
||||
netif ? netif->name[0] : '\'', netif ? netif->name[1] : '\''));
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
void
|
||||
netif_init(void)
|
||||
{
|
||||
netif_list = netif_default = NULL;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
@ -35,13 +35,13 @@
|
||||
*
|
||||
*/
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
/* raw.c
|
||||
*
|
||||
* The code for the Raw Access to the IP
|
||||
*
|
||||
*/
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
#include "lwip/opt.h"
|
||||
|
||||
#include "lwip/def.h"
|
||||
@ -61,7 +61,7 @@
|
||||
|
||||
static struct raw_pcb *raw_pcbs = NULL;
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
void
|
||||
raw_init(void)
|
||||
{
|
||||
|
||||
@ -41,11 +41,11 @@
|
||||
|
||||
#if LWIP_STATS
|
||||
struct stats_ lwip_stats;
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
void
|
||||
stats_init(void)
|
||||
{
|
||||
memset(&lwip_stats, 0, sizeof(struct stats_));
|
||||
}
|
||||
#endif /* LWIP_STATS */
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
@ -44,7 +44,7 @@ struct sswt_cb
|
||||
};
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
void
|
||||
sys_mbox_fetch(sys_mbox_t mbox, void **msg)
|
||||
{
|
||||
@ -96,7 +96,7 @@ sys_mbox_fetch(sys_mbox_t mbox, void **msg)
|
||||
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
void
|
||||
sys_sem_wait(sys_sem_t sem)
|
||||
{
|
||||
@ -152,7 +152,7 @@ sys_sem_wait(sys_sem_t sem)
|
||||
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
void
|
||||
sys_timeout(u32_t msecs, sys_timeout_handler h, void *arg)
|
||||
{
|
||||
@ -203,7 +203,7 @@ sys_timeout(u32_t msecs, sys_timeout_handler h, void *arg)
|
||||
/* Go through timeout list (for this task only) and remove the first matching entry,
|
||||
even though the timeout has not triggered yet.
|
||||
*/
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
void
|
||||
sys_untimeout(sys_timeout_handler h, void *arg)
|
||||
{
|
||||
@ -238,7 +238,7 @@ sys_untimeout(sys_timeout_handler h, void *arg)
|
||||
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
static void
|
||||
sswt_handler(void *arg)
|
||||
{
|
||||
@ -252,7 +252,7 @@ sswt_handler(void *arg)
|
||||
/* Wait for a semaphore with timeout (specified in ms) */
|
||||
/* timeout = 0: wait forever */
|
||||
/* Returns 0 on timeout. 1 otherwise */
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
int
|
||||
sys_sem_wait_timeout(sys_sem_t sem, u32_t timeout)
|
||||
{
|
||||
@ -279,7 +279,7 @@ sys_sem_wait_timeout(sys_sem_t sem, u32_t timeout)
|
||||
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
void
|
||||
sys_msleep(u32_t ms)
|
||||
{
|
||||
@ -289,6 +289,6 @@ sys_msleep(u32_t ms)
|
||||
|
||||
sys_sem_free(delaysem);
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
#endif /* NO_SYS */
|
||||
|
||||
126
src/core/tcp.c
126
src/core/tcp.c
@ -36,7 +36,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
/* tcp.c
|
||||
*
|
||||
* This file contains common functions for the TCP implementation, such as functinos
|
||||
@ -44,7 +44,7 @@
|
||||
* related to input and output is found in tcp_input.c and tcp_output.c respectively.
|
||||
*
|
||||
*/
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
|
||||
#include "lwip/opt.h"
|
||||
@ -74,13 +74,13 @@ static u8_t tcp_timer;
|
||||
|
||||
static u16_t tcp_new_port(void);
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
* tcp_init():
|
||||
*
|
||||
* Initializes the TCP layer.
|
||||
*/
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
void
|
||||
tcp_init(void)
|
||||
{
|
||||
@ -95,14 +95,14 @@ tcp_init(void)
|
||||
tcp_timer = 0;
|
||||
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
* tcp_tmr():
|
||||
*
|
||||
* Called periodically to dispatch TCP timers.
|
||||
*
|
||||
*/
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
void
|
||||
tcp_tmr(void)
|
||||
{
|
||||
@ -115,14 +115,14 @@ tcp_tmr(void)
|
||||
tcp_slowtmr();
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
* tcp_close():
|
||||
*
|
||||
* Closes the connection held by the PCB.
|
||||
*
|
||||
*/
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
err_t
|
||||
tcp_close(struct tcp_pcb *pcb)
|
||||
{
|
||||
@ -176,7 +176,7 @@ tcp_close(struct tcp_pcb *pcb)
|
||||
}
|
||||
return err;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
* tcp_abort()
|
||||
*
|
||||
@ -185,7 +185,7 @@ tcp_close(struct tcp_pcb *pcb)
|
||||
* killed because of shortage of memory.
|
||||
*
|
||||
*/
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
void
|
||||
tcp_abort(struct tcp_pcb *pcb)
|
||||
{
|
||||
@ -233,7 +233,7 @@ tcp_abort(struct tcp_pcb *pcb)
|
||||
tcp_rst(seqno, ackno, &local_ip, &remote_ip, local_port, remote_port);
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
* tcp_bind():
|
||||
*
|
||||
@ -242,7 +242,7 @@ tcp_abort(struct tcp_pcb *pcb)
|
||||
* the outgoing network interface is used instead.
|
||||
*
|
||||
*/
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
err_t
|
||||
tcp_bind(struct tcp_pcb *pcb, struct ip_addr *ipaddr, u16_t port)
|
||||
{
|
||||
@ -390,7 +390,7 @@ tcp_accept_null(void *arg, struct tcp_pcb *pcb, err_t err)
|
||||
return ERR_ABRT;
|
||||
}
|
||||
#endif /* LWIP_CALLBACK_API */
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
* tcp_listen():
|
||||
*
|
||||
@ -400,7 +400,7 @@ tcp_accept_null(void *arg, struct tcp_pcb *pcb, err_t err)
|
||||
* connection to LISTEN is an irreversible process.
|
||||
*
|
||||
*/
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
struct tcp_pcb *
|
||||
tcp_listen(struct tcp_pcb *pcb)
|
||||
{
|
||||
@ -429,7 +429,7 @@ tcp_listen(struct tcp_pcb *pcb)
|
||||
TCP_REG(&tcp_listen_pcbs, lpcb);
|
||||
return (struct tcp_pcb *)lpcb;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
* tcp_recved():
|
||||
*
|
||||
@ -438,7 +438,7 @@ tcp_listen(struct tcp_pcb *pcb)
|
||||
* when the data has been processed.
|
||||
*
|
||||
*/
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
void
|
||||
tcp_recved(struct tcp_pcb *pcb, u16_t len)
|
||||
{
|
||||
@ -455,14 +455,14 @@ tcp_recved(struct tcp_pcb *pcb, u16_t len)
|
||||
LWIP_DEBUGF(TCP_DEBUG, ("tcp_recved: recveived %u bytes, wnd %u (%u).\n",
|
||||
len, pcb->rcv_wnd, TCP_WND - pcb->rcv_wnd));
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
* tcp_new_port():
|
||||
*
|
||||
* A nastly hack featuring 'goto' statements that allocates a
|
||||
* new TCP local port.
|
||||
*/
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
static u16_t
|
||||
tcp_new_port(void)
|
||||
{
|
||||
@ -495,7 +495,7 @@ tcp_new_port(void)
|
||||
}
|
||||
return port;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
* tcp_connect():
|
||||
*
|
||||
@ -503,7 +503,7 @@ tcp_new_port(void)
|
||||
* argument will be called when the connection has been established.
|
||||
*
|
||||
*/
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
err_t
|
||||
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))
|
||||
@ -550,7 +550,7 @@ tcp_connect(struct tcp_pcb *pcb, struct ip_addr *ipaddr, u16_t port,
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
* tcp_slowtmr():
|
||||
*
|
||||
@ -558,7 +558,7 @@ tcp_connect(struct tcp_pcb *pcb, struct ip_addr *ipaddr, u16_t port,
|
||||
* removes PCBs that have been in TIME-WAIT for enough time. It also increments
|
||||
* various timers such as the inactivity timer in each PCB.
|
||||
*/
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
void
|
||||
tcp_slowtmr(void)
|
||||
{
|
||||
@ -734,13 +734,13 @@ tcp_slowtmr(void)
|
||||
}
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
* tcp_fasttmr():
|
||||
*
|
||||
* Is called every TCP_FAST_INTERVAL (250 ms) and sends delayed ACKs.
|
||||
*/
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
void
|
||||
tcp_fasttmr(void)
|
||||
{
|
||||
@ -755,14 +755,14 @@ tcp_fasttmr(void)
|
||||
}
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
* tcp_segs_free():
|
||||
*
|
||||
* Deallocates a list of TCP segments (tcp_seg structures).
|
||||
*
|
||||
*/
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
u8_t
|
||||
tcp_segs_free(struct tcp_seg *seg)
|
||||
{
|
||||
@ -775,14 +775,14 @@ tcp_segs_free(struct tcp_seg *seg)
|
||||
}
|
||||
return count;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
* tcp_seg_free():
|
||||
*
|
||||
* Frees a TCP segment.
|
||||
*
|
||||
*/
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
u8_t
|
||||
tcp_seg_free(struct tcp_seg *seg)
|
||||
{
|
||||
@ -799,28 +799,28 @@ tcp_seg_free(struct tcp_seg *seg)
|
||||
}
|
||||
return count;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
* tcp_setprio():
|
||||
*
|
||||
* Sets the priority of a connection.
|
||||
*
|
||||
*/
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
void
|
||||
tcp_setprio(struct tcp_pcb *pcb, u8_t prio)
|
||||
{
|
||||
pcb->prio = prio;
|
||||
}
|
||||
#if TCP_QUEUE_OOSEQ
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
* tcp_seg_copy():
|
||||
*
|
||||
* Returns a copy of the given TCP segment.
|
||||
*
|
||||
*/
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
struct tcp_seg *
|
||||
tcp_seg_copy(struct tcp_seg *seg)
|
||||
{
|
||||
@ -835,7 +835,7 @@ tcp_seg_copy(struct tcp_seg *seg)
|
||||
return cseg;
|
||||
}
|
||||
#endif
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
#if LWIP_CALLBACK_API
|
||||
static err_t
|
||||
tcp_recv_null(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err)
|
||||
@ -849,7 +849,7 @@ tcp_recv_null(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err)
|
||||
return ERR_OK;
|
||||
}
|
||||
#endif /* LWIP_CALLBACK_API */
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
static void
|
||||
tcp_kill_prio(u8_t prio)
|
||||
{
|
||||
@ -880,7 +880,7 @@ tcp_kill_prio(u8_t prio)
|
||||
}
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
static void
|
||||
tcp_kill_timewait(void)
|
||||
{
|
||||
@ -902,8 +902,8 @@ tcp_kill_timewait(void)
|
||||
}
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
struct tcp_pcb *
|
||||
tcp_alloc(u8_t prio)
|
||||
{
|
||||
@ -955,7 +955,7 @@ tcp_alloc(u8_t prio)
|
||||
}
|
||||
return pcb;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
* tcp_new():
|
||||
*
|
||||
@ -963,13 +963,13 @@ tcp_alloc(u8_t prio)
|
||||
* any of the TCP PCB lists.
|
||||
*
|
||||
*/
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
struct tcp_pcb *
|
||||
tcp_new(void)
|
||||
{
|
||||
return tcp_alloc(TCP_PRIO_NORMAL);
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
* tcp_arg():
|
||||
*
|
||||
@ -977,14 +977,14 @@ tcp_new(void)
|
||||
* functions.
|
||||
*
|
||||
*/
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
void
|
||||
tcp_arg(struct tcp_pcb *pcb, void *arg)
|
||||
{
|
||||
pcb->callback_arg = arg;
|
||||
}
|
||||
#if LWIP_CALLBACK_API
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
* tcp_recv():
|
||||
*
|
||||
@ -992,14 +992,14 @@ tcp_arg(struct tcp_pcb *pcb, void *arg)
|
||||
* connection receives data.
|
||||
*
|
||||
*/
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
void
|
||||
tcp_recv(struct tcp_pcb *pcb,
|
||||
err_t (* recv)(void *arg, struct tcp_pcb *tpcb, struct pbuf *p, err_t err))
|
||||
{
|
||||
pcb->recv = recv;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
* tcp_sent():
|
||||
*
|
||||
@ -1007,14 +1007,14 @@ tcp_recv(struct tcp_pcb *pcb,
|
||||
* has been successfully delivered to the remote host.
|
||||
*
|
||||
*/
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
void
|
||||
tcp_sent(struct tcp_pcb *pcb,
|
||||
err_t (* sent)(void *arg, struct tcp_pcb *tpcb, u16_t len))
|
||||
{
|
||||
pcb->sent = sent;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
* tcp_err():
|
||||
*
|
||||
@ -1022,14 +1022,14 @@ tcp_sent(struct tcp_pcb *pcb,
|
||||
* has occured on the connection.
|
||||
*
|
||||
*/
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
void
|
||||
tcp_err(struct tcp_pcb *pcb,
|
||||
void (* errf)(void *arg, err_t err))
|
||||
{
|
||||
pcb->errf = errf;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
* tcp_accept():
|
||||
*
|
||||
@ -1037,7 +1037,7 @@ tcp_err(struct tcp_pcb *pcb,
|
||||
* LISTENing connection has been connected to another host.
|
||||
*
|
||||
*/
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
void
|
||||
tcp_accept(struct tcp_pcb *pcb,
|
||||
err_t (* accept)(void *arg, struct tcp_pcb *newpcb, err_t err))
|
||||
@ -1046,7 +1046,7 @@ tcp_accept(struct tcp_pcb *pcb,
|
||||
}
|
||||
#endif /* LWIP_CALLBACK_API */
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
* tcp_poll():
|
||||
*
|
||||
@ -1055,7 +1055,7 @@ tcp_accept(struct tcp_pcb *pcb,
|
||||
* timer interval, which is called twice a second.
|
||||
*
|
||||
*/
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
void
|
||||
tcp_poll(struct tcp_pcb *pcb,
|
||||
err_t (* poll)(void *arg, struct tcp_pcb *tpcb), u8_t interval)
|
||||
@ -1065,14 +1065,14 @@ tcp_poll(struct tcp_pcb *pcb,
|
||||
#endif /* LWIP_CALLBACK_API */
|
||||
pcb->pollinterval = interval;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
* tcp_pcb_purge():
|
||||
*
|
||||
* Purges a TCP PCB. Removes any buffered data and frees the buffer memory.
|
||||
*
|
||||
*/
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
void
|
||||
tcp_pcb_purge(struct tcp_pcb *pcb)
|
||||
{
|
||||
@ -1107,14 +1107,14 @@ tcp_pcb_purge(struct tcp_pcb *pcb)
|
||||
NULL;
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
* tcp_pcb_remove():
|
||||
*
|
||||
* Purges the PCB and removes it from a PCB list. Any delayed ACKs are sent first.
|
||||
*
|
||||
*/
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
void
|
||||
tcp_pcb_remove(struct tcp_pcb **pcblist, struct tcp_pcb *pcb)
|
||||
{
|
||||
@ -1133,14 +1133,14 @@ tcp_pcb_remove(struct tcp_pcb **pcblist, struct tcp_pcb *pcb)
|
||||
|
||||
LWIP_ASSERT("tcp_pcb_remove: tcp_pcbs_sane()", tcp_pcbs_sane());
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
* tcp_next_iss():
|
||||
*
|
||||
* Calculates a new initial sequence number for new connections.
|
||||
*
|
||||
*/
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
u32_t
|
||||
tcp_next_iss(void)
|
||||
{
|
||||
@ -1149,7 +1149,7 @@ tcp_next_iss(void)
|
||||
iss += tcp_ticks; /* XXX */
|
||||
return iss;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
#if TCP_DEBUG || TCP_INPUT_DEBUG || TCP_OUTPUT_DEBUG
|
||||
void
|
||||
tcp_debug_print(struct tcp_hdr *tcphdr)
|
||||
@ -1181,7 +1181,7 @@ tcp_debug_print(struct tcp_hdr *tcphdr)
|
||||
ntohs(tcphdr->chksum), ntohs(tcphdr->urgp)));
|
||||
LWIP_DEBUGF(TCP_DEBUG, ("+-------------------------------+\n"));
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
void
|
||||
tcp_debug_print_state(enum tcp_state s)
|
||||
{
|
||||
@ -1222,7 +1222,7 @@ tcp_debug_print_state(enum tcp_state s)
|
||||
break;
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
void
|
||||
tcp_debug_print_flags(u8_t flags)
|
||||
{
|
||||
@ -1251,7 +1251,7 @@ tcp_debug_print_flags(u8_t flags)
|
||||
LWIP_DEBUGF(TCP_DEBUG, ("CWR "));
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
void
|
||||
tcp_debug_print_pcbs(void)
|
||||
{
|
||||
@ -1278,7 +1278,7 @@ tcp_debug_print_pcbs(void)
|
||||
tcp_debug_print_state(pcb->state);
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
int
|
||||
tcp_pcbs_sane(void)
|
||||
{
|
||||
@ -1295,7 +1295,7 @@ tcp_pcbs_sane(void)
|
||||
}
|
||||
#endif /* TCP_DEBUG */
|
||||
#endif /* LWIP_TCP */
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -36,7 +36,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
/* tcp_input.c
|
||||
*
|
||||
* The input processing functions of TCP.
|
||||
@ -45,7 +45,7 @@
|
||||
* tcp_process() -> tcp_receive() (-> application).
|
||||
*
|
||||
*/
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
|
||||
#include "lwip/def.h"
|
||||
@ -85,7 +85,7 @@ static void tcp_parseopt(struct tcp_pcb *pcb);
|
||||
static err_t tcp_listen_input(struct tcp_pcb_listen *pcb);
|
||||
static err_t tcp_timewait_input(struct tcp_pcb *pcb);
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
/* tcp_input:
|
||||
*
|
||||
* The initial input processing of TCP. It verifies the TCP header, demultiplexes
|
||||
@ -93,7 +93,7 @@ static err_t tcp_timewait_input(struct tcp_pcb *pcb);
|
||||
* the TCP finite state machine. This function is called by the IP layer (in
|
||||
* ip_input()).
|
||||
*/
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
void
|
||||
tcp_input(struct pbuf *p, struct netif *inp)
|
||||
{
|
||||
@ -398,13 +398,13 @@ tcp_input(struct pbuf *p, struct netif *inp)
|
||||
LWIP_ASSERT("tcp_input: tcp_pcbs_sane()", tcp_pcbs_sane());
|
||||
PERF_STOP("tcp_input");
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
/* tcp_listen_input():
|
||||
*
|
||||
* Called by tcp_input() when a segment arrives for a listening
|
||||
* connection.
|
||||
*/
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
static err_t
|
||||
tcp_listen_input(struct tcp_pcb_listen *pcb)
|
||||
{
|
||||
@ -465,13 +465,13 @@ tcp_listen_input(struct tcp_pcb_listen *pcb)
|
||||
}
|
||||
return ERR_OK;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
/* tcp_timewait_input():
|
||||
*
|
||||
* Called by tcp_input() when a segment arrives for a connection in
|
||||
* TIME_WAIT.
|
||||
*/
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
static err_t
|
||||
tcp_timewait_input(struct tcp_pcb *pcb)
|
||||
{
|
||||
@ -483,7 +483,7 @@ tcp_timewait_input(struct tcp_pcb *pcb)
|
||||
}
|
||||
return tcp_output(pcb);
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
/* tcp_process
|
||||
*
|
||||
* Implements the TCP state machine. Called by tcp_input. In some
|
||||
@ -491,7 +491,7 @@ tcp_timewait_input(struct tcp_pcb *pcb)
|
||||
* argument will be freed by the caller (tcp_input()) unless the
|
||||
* recv_data pointer in the pcb is set.
|
||||
*/
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
static err_t
|
||||
tcp_process(struct tcp_pcb *pcb)
|
||||
{
|
||||
@ -650,7 +650,7 @@ tcp_process(struct tcp_pcb *pcb)
|
||||
|
||||
return ERR_OK;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
/* tcp_receive:
|
||||
*
|
||||
* Called by tcp_process. Checks if the given segment is an ACK for outstanding
|
||||
@ -662,7 +662,7 @@ tcp_process(struct tcp_pcb *pcb)
|
||||
* If the incoming segment constitutes an ACK for a segment that was used for RTT
|
||||
* estimation, the RTT is estimated here as well.
|
||||
*/
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
static void
|
||||
tcp_receive(struct tcp_pcb *pcb)
|
||||
{
|
||||
@ -1158,7 +1158,7 @@ tcp_receive(struct tcp_pcb *pcb)
|
||||
}
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
* tcp_parseopt:
|
||||
*
|
||||
@ -1166,7 +1166,7 @@ tcp_receive(struct tcp_pcb *pcb)
|
||||
* from uIP with only small changes.)
|
||||
*
|
||||
*/
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
static void
|
||||
tcp_parseopt(struct tcp_pcb *pcb)
|
||||
{
|
||||
@ -1208,5 +1208,5 @@ tcp_parseopt(struct tcp_pcb *pcb)
|
||||
}
|
||||
}
|
||||
#endif /* LWIP_TCP */
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
|
||||
@ -35,13 +35,13 @@
|
||||
*
|
||||
*/
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
/* tcp_output.c
|
||||
*
|
||||
* The output functions of TCP.
|
||||
*
|
||||
*/
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
|
||||
#include "lwip/def.h"
|
||||
@ -64,14 +64,14 @@
|
||||
static void tcp_output_segment(struct tcp_seg *seg, struct tcp_pcb *pcb);
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
err_t
|
||||
tcp_send_ctrl(struct tcp_pcb *pcb, u8_t flags)
|
||||
{
|
||||
return tcp_enqueue(pcb, NULL, 0, flags, 1, NULL, 0);
|
||||
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
err_t
|
||||
tcp_write(struct tcp_pcb *pcb, const void *arg, u16_t len, u8_t copy)
|
||||
{
|
||||
@ -90,7 +90,7 @@ tcp_write(struct tcp_pcb *pcb, const void *arg, u16_t len, u8_t copy)
|
||||
return ERR_CONN;
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
err_t
|
||||
tcp_enqueue(struct tcp_pcb *pcb, void *arg, u16_t len,
|
||||
u8_t flags, u8_t copy,
|
||||
@ -338,7 +338,7 @@ tcp_enqueue(struct tcp_pcb *pcb, void *arg, u16_t len,
|
||||
LWIP_DEBUGF(TCP_QLEN_DEBUG | DBG_STATE, ("tcp_enqueue: %d (with mem err)\n", pcb->snd_queuelen));
|
||||
return ERR_MEM;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
/* find out what we can send and send it */
|
||||
err_t
|
||||
tcp_output(struct tcp_pcb *pcb)
|
||||
@ -468,7 +468,7 @@ tcp_output(struct tcp_pcb *pcb)
|
||||
}
|
||||
return ERR_OK;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
static void
|
||||
tcp_output_segment(struct tcp_seg *seg, struct tcp_pcb *pcb)
|
||||
{
|
||||
@ -526,7 +526,7 @@ tcp_output_segment(struct tcp_seg *seg, struct tcp_pcb *pcb)
|
||||
ip_output(seg->p, &(pcb->local_ip), &(pcb->remote_ip), pcb->ttl, pcb->tos,
|
||||
IP_PROTO_TCP);
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
void
|
||||
tcp_rst(u32_t seqno, u32_t ackno,
|
||||
struct ip_addr *local_ip, struct ip_addr *remote_ip,
|
||||
@ -560,7 +560,7 @@ tcp_rst(u32_t seqno, u32_t ackno,
|
||||
pbuf_free(p);
|
||||
LWIP_DEBUGF(TCP_RST_DEBUG, ("tcp_rst: seqno %lu ackno %lu.\n", seqno, ackno));
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
void
|
||||
tcp_rexmit(struct tcp_pcb *pcb)
|
||||
{
|
||||
@ -590,7 +590,7 @@ tcp_rexmit(struct tcp_pcb *pcb)
|
||||
tcp_output(pcb);
|
||||
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
void
|
||||
tcp_keepalive(struct tcp_pcb *pcb)
|
||||
{
|
||||
|
||||
@ -35,13 +35,13 @@
|
||||
*
|
||||
*/
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
/* udp.c
|
||||
*
|
||||
* The code for the User Datagram Protocol UDP.
|
||||
*
|
||||
*/
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
#include "lwip/opt.h"
|
||||
|
||||
#include "lwip/def.h"
|
||||
@ -64,20 +64,20 @@ struct udp_pcb *udp_pcbs = NULL;
|
||||
|
||||
static struct udp_pcb *pcb_cache = NULL;
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
void
|
||||
udp_init(void)
|
||||
{
|
||||
udp_pcbs = pcb_cache = NULL;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
/* udp_lookup:
|
||||
*
|
||||
* An experimental feature that will be changed in future versions. Do
|
||||
* not depend on it yet...
|
||||
*/
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
#ifdef LWIP_DEBUG
|
||||
u8_t
|
||||
udp_lookup(struct ip_hdr *iphdr, struct netif *inp)
|
||||
@ -718,7 +718,7 @@ udp_disconnect(struct udp_pcb *pcb)
|
||||
{
|
||||
pcb->flags &= ~UDP_FLAGS_CONNECTED;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
void
|
||||
udp_recv(struct udp_pcb *pcb,
|
||||
void (* recv)(void *arg, struct udp_pcb *upcb, struct pbuf *p,
|
||||
@ -777,7 +777,7 @@ udp_new(void) {
|
||||
|
||||
return pcb;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
#if UDP_DEBUG
|
||||
int
|
||||
udp_debug_print(struct udp_hdr *udphdr)
|
||||
@ -793,7 +793,7 @@ udp_debug_print(struct udp_hdr *udphdr)
|
||||
return 0;
|
||||
}
|
||||
#endif /* UDP_DEBUG */
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
#endif /* LWIP_UDP */
|
||||
|
||||
|
||||
|
||||
@ -29,7 +29,7 @@
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
*/
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef __LWIP_PBUF_H__
|
||||
#define __LWIP_PBUF_H__
|
||||
|
||||
|
||||
@ -63,7 +63,7 @@ static void ethernetif_input(struct netif *netif);
|
||||
static err_t ethernetif_output(struct netif *netif, struct pbuf *p,
|
||||
struct ip_addr *ipaddr);
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
static void
|
||||
low_level_init(struct netif *netif)
|
||||
{
|
||||
@ -87,7 +87,7 @@ low_level_init(struct netif *netif)
|
||||
|
||||
/* Do whatever else is needed to initialize interface. */
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
* low_level_output():
|
||||
*
|
||||
@ -96,7 +96,7 @@ low_level_init(struct netif *netif)
|
||||
* might be chained.
|
||||
*
|
||||
*/
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
static err_t
|
||||
low_level_output(struct ethernetif *ethernetif, struct pbuf *p)
|
||||
@ -120,7 +120,7 @@ low_level_output(struct ethernetif *ethernetif, struct pbuf *p)
|
||||
|
||||
return ERR_OK;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
* low_level_input():
|
||||
*
|
||||
@ -128,7 +128,7 @@ low_level_output(struct ethernetif *ethernetif, struct pbuf *p)
|
||||
* packet from the interface into the pbuf.
|
||||
*
|
||||
*/
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
static struct pbuf *
|
||||
low_level_input(struct ethernetif *ethernetif)
|
||||
{
|
||||
@ -165,7 +165,7 @@ low_level_input(struct ethernetif *ethernetif)
|
||||
|
||||
return p;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
* ethernetif_output():
|
||||
*
|
||||
@ -174,7 +174,7 @@ low_level_input(struct ethernetif *ethernetif)
|
||||
* do the actuall transmission of the packet.
|
||||
*
|
||||
*/
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
static err_t
|
||||
ethernetif_output(struct netif *netif, struct pbuf *p,
|
||||
struct ip_addr *ipaddr)
|
||||
@ -264,7 +264,7 @@ ethernetif_output(struct netif *netif, struct pbuf *p,
|
||||
return low_level_output(ethernetif, p);
|
||||
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
* ethernetif_input():
|
||||
*
|
||||
@ -274,7 +274,7 @@ ethernetif_output(struct netif *netif, struct pbuf *p,
|
||||
* interface.
|
||||
*
|
||||
*/
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
static void
|
||||
ethernetif_input(struct netif *netif)
|
||||
{
|
||||
@ -314,14 +314,14 @@ ethernetif_input(struct netif *netif)
|
||||
}
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
static void
|
||||
arp_timer(void *arg)
|
||||
{
|
||||
arp_tmr();
|
||||
sys_timeout(ARP_TMR_INTERVAL, arp_timer, NULL);
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
* ethernetif_init():
|
||||
*
|
||||
@ -330,7 +330,7 @@ arp_timer(void *arg)
|
||||
* actual setup of the hardware.
|
||||
*
|
||||
*/
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
void
|
||||
ethernetif_init(struct netif *netif)
|
||||
{
|
||||
@ -350,4 +350,4 @@ ethernetif_init(struct netif *netif)
|
||||
|
||||
sys_timeout(ARP_TMR_INTERVAL, arp_timer, NULL);
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
@ -40,13 +40,23 @@
|
||||
#include "lwip/tcp.h"
|
||||
#include "lwip/ip.h"
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
static void
|
||||
loopif_input( void * arg )
|
||||
{
|
||||
struct netif *netif = (struct netif *)( ((void **)arg)[ 0 ] );
|
||||
struct pbuf *r = (struct pbuf *)( ((void **)arg)[ 1 ] );
|
||||
|
||||
mem_free( arg );
|
||||
netif -> input( r, netif );
|
||||
}
|
||||
|
||||
static err_t
|
||||
loopif_output(struct netif *netif, struct pbuf *p,
|
||||
struct ip_addr *ipaddr)
|
||||
{
|
||||
struct pbuf *q, *r;
|
||||
char *ptr;
|
||||
void **arg;
|
||||
|
||||
#if defined(LWIP_DEBUG) && defined(LWIP_TCPDUMP)
|
||||
tcpdump(p);
|
||||
@ -60,21 +70,42 @@ loopif_output(struct netif *netif, struct pbuf *p,
|
||||
memcpy(ptr, q->payload, q->len);
|
||||
ptr += q->len;
|
||||
}
|
||||
netif->input(r, netif);
|
||||
|
||||
arg = mem_malloc( sizeof( void *[2]));
|
||||
if( NULL == arg ) {
|
||||
return ERR_MEM;
|
||||
}
|
||||
|
||||
arg[0] = netif;
|
||||
arg[1] = r;
|
||||
/**
|
||||
* workaround (patch #1779) to try to prevent bug #2595:
|
||||
* When connecting to "localhost" with the loopif interface,
|
||||
* tcp_output doesn't get the opportunity to finnish sending the
|
||||
* segment before tcp_process gets it, resulting in tcp_process
|
||||
* referencing pcb->unacked-> which still is NULL.
|
||||
*
|
||||
* TODO: Is there still a race condition here? Leon
|
||||
*/
|
||||
sys_timeout( 1, loopif_input, arg );
|
||||
|
||||
return ERR_OK;
|
||||
}
|
||||
return ERR_MEM;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
err_t
|
||||
loopif_init(struct netif *netif)
|
||||
{
|
||||
netif->name[0] = 'l';
|
||||
netif->name[1] = 'o';
|
||||
#if 0 /** TODO: I think this should be enabled, or not? Leon */
|
||||
netif->input = loopif_input;
|
||||
#endif
|
||||
netif->output = loopif_output;
|
||||
return ERR_OK;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user