sockets.c, api.h, api_lib.c, api_msg.h, api_msg.c: Fix bug #19162 "lwip_sento: a possible to corrupt remote addr/port connection state". Reduce problems "not enought memory" with netbuf (if we receive lot of datagrams). Improve lwip_sendto (only one exchange between sockets api and api_msg which run in tcpip_thread context). Add netconn_sento function. WARNING, if you directly access to "fromaddr" & "fromport" field from netbuf struct, these fields are now renamed "addr" & "port".

This commit is contained in:
fbernon
2007-05-04 15:18:29 +00:00
parent 05ea5f05ae
commit 5a12aeb4a1
6 changed files with 102 additions and 124 deletions

View File

@@ -80,8 +80,8 @@ enum netconn_igmp {
struct netbuf {
struct pbuf *p, *ptr;
struct ip_addr *fromaddr;
u16_t fromport;
struct ip_addr *addr;
u16_t port;
};
struct netconn {
@@ -121,12 +121,13 @@ err_t netbuf_data (struct netbuf *buf,
s8_t netbuf_next (struct netbuf *buf);
void netbuf_first (struct netbuf *buf);
void netbuf_copy (struct netbuf *buf,
void *dataptr, u16_t len);
void netbuf_copy_partial(struct netbuf *buf, void *dataptr,
u16_t len, u16_t offset);
struct ip_addr * netbuf_fromaddr (struct netbuf *buf);
u16_t netbuf_fromport (struct netbuf *buf);
#define netbuf_copy(buf,dataptr,len) netbuf_copy_partial(buf, dataptr, len, 0)
#define netbuf_len(buf) ((buf)->p->tot_len)
#define netbuf_fromaddr(buf) ((buf)->addr)
#define netbuf_fromport(buf) ((buf)->port)
/* Network connection functions: */
struct netconn * netconn_new (enum netconn_type type);
@@ -154,6 +155,8 @@ err_t netconn_disconnect (struct netconn *conn);
err_t netconn_listen (struct netconn *conn);
struct netconn * netconn_accept (struct netconn *conn);
struct netbuf * netconn_recv (struct netconn *conn);
err_t netconn_sendto (struct netconn *conn,
struct netbuf *buf, struct ip_addr *addr, u16_t port);
err_t netconn_send (struct netconn *conn,
struct netbuf *buf);
err_t netconn_write (struct netconn *conn,

View File

@@ -70,7 +70,8 @@ struct api_msg_msg {
struct netconn *conn;
enum netconn_type conntype;
union {
struct pbuf *p;
struct pbuf *p;
struct netbuf *b;
struct {
struct ip_addr *ipaddr;
u16_t port;