mirror of
https://git.savannah.nongnu.org/git/lwip.git
synced 2026-05-15 04:36:53 +08:00
Major stylo search/replace for "One space between keyword and opening bracket."
This commit is contained in:
@@ -45,7 +45,7 @@ netbuf *netbuf_new(void)
|
||||
struct netbuf *buf;
|
||||
|
||||
buf = memp_mallocp(MEMP_NETBUF);
|
||||
if(buf != NULL) {
|
||||
if (buf != NULL) {
|
||||
buf->p = NULL;
|
||||
buf->ptr = NULL;
|
||||
return buf;
|
||||
@@ -57,8 +57,8 @@ netbuf *netbuf_new(void)
|
||||
void
|
||||
netbuf_delete(struct netbuf *buf)
|
||||
{
|
||||
if(buf != NULL) {
|
||||
if(buf->p != NULL) {
|
||||
if (buf != NULL) {
|
||||
if (buf->p != NULL) {
|
||||
pbuf_free(buf->p);
|
||||
buf->p = buf->ptr = NULL;
|
||||
}
|
||||
@@ -70,11 +70,11 @@ void *
|
||||
netbuf_alloc(struct netbuf *buf, u16_t size)
|
||||
{
|
||||
/* Deallocate any previously allocated memory. */
|
||||
if(buf->p != NULL) {
|
||||
if (buf->p != NULL) {
|
||||
pbuf_free(buf->p);
|
||||
}
|
||||
buf->p = pbuf_alloc(PBUF_TRANSPORT, size, PBUF_RAM);
|
||||
if(buf->p == NULL) {
|
||||
if (buf->p == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
buf->ptr = buf->p;
|
||||
@@ -84,7 +84,7 @@ netbuf_alloc(struct netbuf *buf, u16_t size)
|
||||
void
|
||||
netbuf_free(struct netbuf *buf)
|
||||
{
|
||||
if(buf->p != NULL) {
|
||||
if (buf->p != NULL) {
|
||||
pbuf_free(buf->p);
|
||||
}
|
||||
buf->p = buf->ptr = NULL;
|
||||
@@ -93,7 +93,7 @@ netbuf_free(struct netbuf *buf)
|
||||
void
|
||||
netbuf_ref(struct netbuf *buf, void *dataptr, u16_t size)
|
||||
{
|
||||
if(buf->p != NULL) {
|
||||
if (buf->p != NULL) {
|
||||
pbuf_free(buf->p);
|
||||
}
|
||||
buf->p = pbuf_alloc(PBUF_TRANSPORT, 0, PBUF_REF);
|
||||
@@ -119,7 +119,7 @@ netbuf_len(struct netbuf *buf)
|
||||
err_t
|
||||
netbuf_data(struct netbuf *buf, void **dataptr, u16_t *len)
|
||||
{
|
||||
if(buf->ptr == NULL) {
|
||||
if (buf->ptr == NULL) {
|
||||
return ERR_BUF;
|
||||
}
|
||||
*dataptr = buf->ptr->payload;
|
||||
@@ -130,11 +130,11 @@ netbuf_data(struct netbuf *buf, void **dataptr, u16_t *len)
|
||||
s8_t
|
||||
netbuf_next(struct netbuf *buf)
|
||||
{
|
||||
if(buf->ptr->next == NULL) {
|
||||
if (buf->ptr->next == NULL) {
|
||||
return -1;
|
||||
}
|
||||
buf->ptr = buf->ptr->next;
|
||||
if(buf->ptr->next == NULL) {
|
||||
if (buf->ptr->next == NULL) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
@@ -154,19 +154,19 @@ netbuf_copy_partial(struct netbuf *buf, void *dataptr, u16_t len, u16_t offset)
|
||||
|
||||
left = 0;
|
||||
|
||||
if(buf == NULL) {
|
||||
if (buf == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* This implementation is bad. It should use bcopy
|
||||
instead. */
|
||||
for(p = buf->p; left < len && p != NULL; p = p->next) {
|
||||
if(offset != 0 && offset >= p->len) {
|
||||
if (offset != 0 && offset >= p->len) {
|
||||
offset -= p->len;
|
||||
} else {
|
||||
for(i = offset; i < p->len; ++i) {
|
||||
((char *)dataptr)[left] = ((char *)p->payload)[i];
|
||||
if(++left >= len) {
|
||||
if (++left >= len) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -199,13 +199,13 @@ netconn *netconn_new(enum netconn_type t)
|
||||
struct netconn *conn;
|
||||
|
||||
conn = memp_mallocp(MEMP_NETCONN);
|
||||
if(conn == NULL) {
|
||||
if (conn == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
conn->type = t;
|
||||
conn->pcb.tcp = NULL;
|
||||
|
||||
if((conn->mbox = sys_mbox_new()) == SYS_MBOX_NULL) {
|
||||
if ((conn->mbox = sys_mbox_new()) == SYS_MBOX_NULL) {
|
||||
memp_freep(MEMP_NETCONN, conn);
|
||||
return NULL;
|
||||
}
|
||||
@@ -239,11 +239,11 @@ netconn_delete(struct netconn *conn)
|
||||
struct api_msg *msg;
|
||||
void *mem;
|
||||
|
||||
if(conn == NULL) {
|
||||
if (conn == NULL) {
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
if((msg = memp_mallocp(MEMP_API_MSG)) == NULL) {
|
||||
if ((msg = memp_mallocp(MEMP_API_MSG)) == NULL) {
|
||||
return ERR_MEM;
|
||||
}
|
||||
|
||||
@@ -254,9 +254,9 @@ netconn_delete(struct netconn *conn)
|
||||
memp_freep(MEMP_API_MSG, msg);
|
||||
|
||||
/* Drain the recvmbox. */
|
||||
if(conn->recvmbox != SYS_MBOX_NULL) {
|
||||
while(sys_arch_mbox_fetch(conn->recvmbox, &mem, 1) != SYS_ARCH_TIMEOUT) {
|
||||
if(conn->type == NETCONN_TCP) {
|
||||
if (conn->recvmbox != SYS_MBOX_NULL) {
|
||||
while (sys_arch_mbox_fetch(conn->recvmbox, &mem, 1) != SYS_ARCH_TIMEOUT) {
|
||||
if (conn->type == NETCONN_TCP) {
|
||||
pbuf_free((struct pbuf *)mem);
|
||||
} else {
|
||||
netbuf_delete((struct netbuf *)mem);
|
||||
@@ -268,8 +268,8 @@ netconn_delete(struct netconn *conn)
|
||||
|
||||
|
||||
/* Drain the acceptmbox. */
|
||||
if(conn->acceptmbox != SYS_MBOX_NULL) {
|
||||
while(sys_arch_mbox_fetch(conn->acceptmbox, &mem, 1) != SYS_ARCH_TIMEOUT) {
|
||||
if (conn->acceptmbox != SYS_MBOX_NULL) {
|
||||
while (sys_arch_mbox_fetch(conn->acceptmbox, &mem, 1) != SYS_ARCH_TIMEOUT) {
|
||||
netconn_delete((struct netconn *)mem);
|
||||
}
|
||||
|
||||
@@ -279,7 +279,7 @@ netconn_delete(struct netconn *conn)
|
||||
|
||||
sys_mbox_free(conn->mbox);
|
||||
conn->mbox = SYS_MBOX_NULL;
|
||||
if(conn->sem != SYS_SEM_NULL) {
|
||||
if (conn->sem != SYS_SEM_NULL) {
|
||||
sys_sem_free(conn->sem);
|
||||
}
|
||||
/* conn->sem = SYS_SEM_NULL;*/
|
||||
@@ -297,7 +297,7 @@ err_t
|
||||
netconn_peer(struct netconn *conn, struct ip_addr *addr,
|
||||
u16_t *port)
|
||||
{
|
||||
switch(conn->type) {
|
||||
switch (conn->type) {
|
||||
case NETCONN_UDPLITE:
|
||||
case NETCONN_UDPNOCHKSUM:
|
||||
case NETCONN_UDP:
|
||||
@@ -308,7 +308,7 @@ netconn_peer(struct netconn *conn, struct ip_addr *addr,
|
||||
*port = conn->pcb.udp->remote_port;
|
||||
break;
|
||||
case NETCONN_TCP:
|
||||
if(conn->pcb.tcp == NULL)
|
||||
if (conn->pcb.tcp == NULL)
|
||||
return ERR_CONN;
|
||||
*addr = (conn->pcb.tcp->remote_ip);
|
||||
*port = conn->pcb.tcp->remote_port;
|
||||
@@ -321,7 +321,7 @@ err_t
|
||||
netconn_addr(struct netconn *conn, struct ip_addr **addr,
|
||||
u16_t *port)
|
||||
{
|
||||
switch(conn->type) {
|
||||
switch (conn->type) {
|
||||
case NETCONN_UDPLITE:
|
||||
case NETCONN_UDPNOCHKSUM:
|
||||
case NETCONN_UDP:
|
||||
@@ -342,18 +342,18 @@ netconn_bind(struct netconn *conn, struct ip_addr *addr,
|
||||
{
|
||||
struct api_msg *msg;
|
||||
|
||||
if(conn == NULL) {
|
||||
if (conn == NULL) {
|
||||
return ERR_VAL;
|
||||
}
|
||||
|
||||
if(conn->type != NETCONN_TCP &&
|
||||
if (conn->type != NETCONN_TCP &&
|
||||
conn->recvmbox == SYS_MBOX_NULL) {
|
||||
if((conn->recvmbox = sys_mbox_new()) == SYS_MBOX_NULL) {
|
||||
if ((conn->recvmbox = sys_mbox_new()) == SYS_MBOX_NULL) {
|
||||
return ERR_MEM;
|
||||
}
|
||||
}
|
||||
|
||||
if((msg = memp_mallocp(MEMP_API_MSG)) == NULL) {
|
||||
if ((msg = memp_mallocp(MEMP_API_MSG)) == NULL) {
|
||||
return (conn->err = ERR_MEM);
|
||||
}
|
||||
msg->type = API_MSG_BIND;
|
||||
@@ -373,18 +373,18 @@ netconn_connect(struct netconn *conn, struct ip_addr *addr,
|
||||
{
|
||||
struct api_msg *msg;
|
||||
|
||||
if(conn == NULL) {
|
||||
if (conn == NULL) {
|
||||
return ERR_VAL;
|
||||
}
|
||||
|
||||
|
||||
if(conn->recvmbox == SYS_MBOX_NULL) {
|
||||
if((conn->recvmbox = sys_mbox_new()) == SYS_MBOX_NULL) {
|
||||
if (conn->recvmbox == SYS_MBOX_NULL) {
|
||||
if ((conn->recvmbox = sys_mbox_new()) == SYS_MBOX_NULL) {
|
||||
return ERR_MEM;
|
||||
}
|
||||
}
|
||||
|
||||
if((msg = memp_mallocp(MEMP_API_MSG)) == NULL) {
|
||||
if ((msg = memp_mallocp(MEMP_API_MSG)) == NULL) {
|
||||
return ERR_MEM;
|
||||
}
|
||||
msg->type = API_MSG_CONNECT;
|
||||
@@ -402,11 +402,11 @@ netconn_disconnect(struct netconn *conn)
|
||||
{
|
||||
struct api_msg *msg;
|
||||
|
||||
if(conn == NULL) {
|
||||
if (conn == NULL) {
|
||||
return ERR_VAL;
|
||||
}
|
||||
|
||||
if((msg = memp_mallocp(MEMP_API_MSG)) == NULL) {
|
||||
if ((msg = memp_mallocp(MEMP_API_MSG)) == NULL) {
|
||||
return ERR_MEM;
|
||||
}
|
||||
msg->type = API_MSG_DISCONNECT;
|
||||
@@ -423,18 +423,18 @@ netconn_listen(struct netconn *conn)
|
||||
{
|
||||
struct api_msg *msg;
|
||||
|
||||
if(conn == NULL) {
|
||||
if (conn == NULL) {
|
||||
return ERR_VAL;
|
||||
}
|
||||
|
||||
if(conn->acceptmbox == SYS_MBOX_NULL) {
|
||||
if (conn->acceptmbox == SYS_MBOX_NULL) {
|
||||
conn->acceptmbox = sys_mbox_new();
|
||||
if(conn->acceptmbox == SYS_MBOX_NULL) {
|
||||
if (conn->acceptmbox == SYS_MBOX_NULL) {
|
||||
return ERR_MEM;
|
||||
}
|
||||
}
|
||||
|
||||
if((msg = memp_mallocp(MEMP_API_MSG)) == NULL) {
|
||||
if ((msg = memp_mallocp(MEMP_API_MSG)) == NULL) {
|
||||
return (conn->err = ERR_MEM);
|
||||
}
|
||||
msg->type = API_MSG_LISTEN;
|
||||
@@ -450,7 +450,7 @@ netconn_accept(struct netconn *conn)
|
||||
{
|
||||
struct netconn *newconn;
|
||||
|
||||
if(conn == NULL) {
|
||||
if (conn == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -470,21 +470,21 @@ netconn_recv(struct netconn *conn)
|
||||
struct pbuf *p;
|
||||
u16_t len;
|
||||
|
||||
if(conn == NULL) {
|
||||
if (conn == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(conn->recvmbox == SYS_MBOX_NULL) {
|
||||
if (conn->recvmbox == SYS_MBOX_NULL) {
|
||||
conn->err = ERR_CONN;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(conn->err != ERR_OK) {
|
||||
if (conn->err != ERR_OK) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(conn->type == NETCONN_TCP) {
|
||||
if(conn->pcb.tcp->state == LISTEN) {
|
||||
if (conn->type == NETCONN_TCP) {
|
||||
if (conn->pcb.tcp->state == LISTEN) {
|
||||
conn->err = ERR_CONN;
|
||||
return NULL;
|
||||
}
|
||||
@@ -492,7 +492,7 @@ netconn_recv(struct netconn *conn)
|
||||
|
||||
buf = memp_mallocp(MEMP_NETBUF);
|
||||
|
||||
if(buf == NULL) {
|
||||
if (buf == NULL) {
|
||||
conn->err = ERR_MEM;
|
||||
return NULL;
|
||||
}
|
||||
@@ -513,7 +513,7 @@ netconn_recv(struct netconn *conn)
|
||||
|
||||
/* If we are closed, we indicate that we no longer wish to recieve
|
||||
data by setting conn->recvmbox to SYS_MBOX_NULL. */
|
||||
if(p == NULL) {
|
||||
if (p == NULL) {
|
||||
memp_freep(MEMP_NETBUF, buf);
|
||||
sys_mbox_free(conn->recvmbox);
|
||||
conn->recvmbox = SYS_MBOX_NULL;
|
||||
@@ -526,13 +526,13 @@ netconn_recv(struct netconn *conn)
|
||||
buf->fromaddr = NULL;
|
||||
|
||||
/* Let the stack know that we have taken the data. */
|
||||
if((msg = memp_mallocp(MEMP_API_MSG)) == NULL) {
|
||||
if ((msg = memp_mallocp(MEMP_API_MSG)) == NULL) {
|
||||
conn->err = ERR_MEM;
|
||||
return buf;
|
||||
}
|
||||
msg->type = API_MSG_RECV;
|
||||
msg->msg.conn = conn;
|
||||
if(buf != NULL) {
|
||||
if (buf != NULL) {
|
||||
msg->msg.msg.len = buf->p->tot_len;
|
||||
} else {
|
||||
msg->msg.msg.len = 1;
|
||||
@@ -563,15 +563,15 @@ netconn_send(struct netconn *conn, struct netbuf *buf)
|
||||
{
|
||||
struct api_msg *msg;
|
||||
|
||||
if(conn == NULL) {
|
||||
if (conn == NULL) {
|
||||
return ERR_VAL;
|
||||
}
|
||||
|
||||
if(conn->err != ERR_OK) {
|
||||
if (conn->err != ERR_OK) {
|
||||
return conn->err;
|
||||
}
|
||||
|
||||
if((msg = memp_mallocp(MEMP_API_MSG)) == NULL) {
|
||||
if ((msg = memp_mallocp(MEMP_API_MSG)) == NULL) {
|
||||
return (conn->err = ERR_MEM);
|
||||
}
|
||||
|
||||
@@ -592,22 +592,22 @@ netconn_write(struct netconn *conn, void *dataptr, u16_t size, u8_t copy)
|
||||
struct api_msg *msg;
|
||||
u16_t len;
|
||||
|
||||
if(conn == NULL) {
|
||||
if (conn == NULL) {
|
||||
return ERR_VAL;
|
||||
}
|
||||
|
||||
if(conn->err != ERR_OK) {
|
||||
if (conn->err != ERR_OK) {
|
||||
return conn->err;
|
||||
}
|
||||
|
||||
if(conn->sem == SYS_SEM_NULL) {
|
||||
if (conn->sem == SYS_SEM_NULL) {
|
||||
conn->sem = sys_sem_new(0);
|
||||
if(conn->sem == SYS_SEM_NULL) {
|
||||
if (conn->sem == SYS_SEM_NULL) {
|
||||
return ERR_MEM;
|
||||
}
|
||||
}
|
||||
|
||||
if((msg = memp_mallocp(MEMP_API_MSG)) == NULL) {
|
||||
if ((msg = memp_mallocp(MEMP_API_MSG)) == NULL) {
|
||||
return (conn->err = ERR_MEM);
|
||||
}
|
||||
msg->type = API_MSG_WRITE;
|
||||
@@ -615,18 +615,18 @@ netconn_write(struct netconn *conn, void *dataptr, u16_t size, u8_t copy)
|
||||
|
||||
|
||||
conn->state = NETCONN_WRITE;
|
||||
while(conn->err == ERR_OK && size > 0) {
|
||||
while (conn->err == ERR_OK && size > 0) {
|
||||
msg->msg.msg.w.dataptr = dataptr;
|
||||
msg->msg.msg.w.copy = copy;
|
||||
|
||||
if(conn->type == NETCONN_TCP) {
|
||||
if(tcp_sndbuf(conn->pcb.tcp) == 0) {
|
||||
if (conn->type == NETCONN_TCP) {
|
||||
if (tcp_sndbuf(conn->pcb.tcp) == 0) {
|
||||
sys_sem_wait(conn->sem);
|
||||
if(conn->err != ERR_OK) {
|
||||
if (conn->err != ERR_OK) {
|
||||
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
|
||||
time. */
|
||||
len = tcp_sndbuf(conn->pcb.tcp);
|
||||
@@ -641,10 +641,10 @@ netconn_write(struct netconn *conn, void *dataptr, u16_t size, u8_t copy)
|
||||
msg->msg.msg.w.len = len;
|
||||
api_msg_post(msg);
|
||||
sys_mbox_fetch(conn->mbox, NULL);
|
||||
if(conn->err == ERR_OK) {
|
||||
if (conn->err == ERR_OK) {
|
||||
dataptr = (void *)((char *)dataptr + len);
|
||||
size -= len;
|
||||
} else if(conn->err == ERR_MEM) {
|
||||
} else if (conn->err == ERR_MEM) {
|
||||
conn->err = ERR_OK;
|
||||
sys_sem_wait(conn->sem);
|
||||
} else {
|
||||
@@ -654,7 +654,7 @@ netconn_write(struct netconn *conn, void *dataptr, u16_t size, u8_t copy)
|
||||
ret:
|
||||
memp_freep(MEMP_API_MSG, msg);
|
||||
conn->state = NETCONN_NONE;
|
||||
if(conn->sem != SYS_SEM_NULL) {
|
||||
if (conn->sem != SYS_SEM_NULL) {
|
||||
sys_sem_free(conn->sem);
|
||||
conn->sem = SYS_SEM_NULL;
|
||||
}
|
||||
@@ -667,10 +667,10 @@ netconn_close(struct netconn *conn)
|
||||
{
|
||||
struct api_msg *msg;
|
||||
|
||||
if(conn == NULL) {
|
||||
if (conn == NULL) {
|
||||
return ERR_VAL;
|
||||
}
|
||||
if((msg = memp_mallocp(MEMP_API_MSG)) == NULL) {
|
||||
if ((msg = memp_mallocp(MEMP_API_MSG)) == NULL) {
|
||||
return (conn->err = ERR_MEM);
|
||||
}
|
||||
|
||||
@@ -680,7 +680,7 @@ netconn_close(struct netconn *conn)
|
||||
msg->msg.conn = conn;
|
||||
api_msg_post(msg);
|
||||
sys_mbox_fetch(conn->mbox, NULL);
|
||||
if(conn->err == ERR_MEM &&
|
||||
if (conn->err == ERR_MEM &&
|
||||
conn->sem != SYS_SEM_NULL) {
|
||||
sys_sem_wait(conn->sem);
|
||||
goto again;
|
||||
|
||||
@@ -47,13 +47,13 @@ recv_udp(void *arg, struct udp_pcb *pcb, struct pbuf *p,
|
||||
|
||||
conn = arg;
|
||||
|
||||
if(conn == NULL) {
|
||||
if (conn == NULL) {
|
||||
pbuf_free(p);
|
||||
return;
|
||||
}
|
||||
if(conn->recvmbox != SYS_MBOX_NULL) {
|
||||
if (conn->recvmbox != SYS_MBOX_NULL) {
|
||||
buf = memp_mallocp(MEMP_NETBUF);
|
||||
if(buf == NULL) {
|
||||
if (buf == NULL) {
|
||||
pbuf_free(p);
|
||||
return;
|
||||
} else {
|
||||
@@ -81,12 +81,12 @@ recv_tcp(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err)
|
||||
|
||||
conn = arg;
|
||||
|
||||
if(conn == NULL) {
|
||||
if (conn == NULL) {
|
||||
pbuf_free(p);
|
||||
return ERR_VAL;
|
||||
}
|
||||
|
||||
if(conn->recvmbox != SYS_MBOX_NULL) {
|
||||
if (conn->recvmbox != SYS_MBOX_NULL) {
|
||||
|
||||
conn->err = err;
|
||||
if (p != NULL) {
|
||||
@@ -110,7 +110,7 @@ poll_tcp(void *arg, struct tcp_pcb *pcb)
|
||||
struct netconn *conn;
|
||||
|
||||
conn = arg;
|
||||
if(conn != NULL &&
|
||||
if (conn != NULL &&
|
||||
(conn->state == NETCONN_WRITE || conn->state == NETCONN_CLOSE) &&
|
||||
conn->sem != SYS_SEM_NULL) {
|
||||
sys_sem_signal(conn->sem);
|
||||
@@ -124,7 +124,7 @@ sent_tcp(void *arg, struct tcp_pcb *pcb, u16_t len)
|
||||
struct netconn *conn;
|
||||
|
||||
conn = arg;
|
||||
if(conn != NULL && conn->sem != SYS_SEM_NULL) {
|
||||
if (conn != NULL && conn->sem != SYS_SEM_NULL) {
|
||||
sys_sem_signal(conn->sem);
|
||||
}
|
||||
|
||||
@@ -146,22 +146,22 @@ err_tcp(void *arg, err_t err)
|
||||
|
||||
|
||||
conn->err = err;
|
||||
if(conn->recvmbox != SYS_MBOX_NULL) {
|
||||
if (conn->recvmbox != SYS_MBOX_NULL) {
|
||||
/* Register event with callback */
|
||||
if (conn->callback)
|
||||
(*conn->callback)(conn, NETCONN_EVT_RCVPLUS, 0);
|
||||
sys_mbox_post(conn->recvmbox, NULL);
|
||||
}
|
||||
if(conn->mbox != SYS_MBOX_NULL) {
|
||||
if (conn->mbox != SYS_MBOX_NULL) {
|
||||
sys_mbox_post(conn->mbox, NULL);
|
||||
}
|
||||
if(conn->acceptmbox != SYS_MBOX_NULL) {
|
||||
if (conn->acceptmbox != SYS_MBOX_NULL) {
|
||||
/* Register event with callback */
|
||||
if (conn->callback)
|
||||
(*conn->callback)(conn, NETCONN_EVT_RCVPLUS, 0);
|
||||
sys_mbox_post(conn->acceptmbox, NULL);
|
||||
}
|
||||
if(conn->sem != SYS_SEM_NULL) {
|
||||
if (conn->sem != SYS_SEM_NULL) {
|
||||
sys_sem_signal(conn->sem);
|
||||
}
|
||||
}
|
||||
@@ -194,25 +194,25 @@ accept_function(void *arg, struct tcp_pcb *newpcb, err_t err)
|
||||
conn = (struct netconn *)arg;
|
||||
mbox = conn->acceptmbox;
|
||||
newconn = memp_mallocp(MEMP_NETCONN);
|
||||
if(newconn == NULL) {
|
||||
if (newconn == NULL) {
|
||||
return ERR_MEM;
|
||||
}
|
||||
newconn->type = NETCONN_TCP;
|
||||
newconn->pcb.tcp = newpcb;
|
||||
setup_tcp(newconn);
|
||||
newconn->recvmbox = sys_mbox_new();
|
||||
if(newconn->recvmbox == SYS_MBOX_NULL) {
|
||||
if (newconn->recvmbox == SYS_MBOX_NULL) {
|
||||
memp_free(MEMP_NETCONN, newconn);
|
||||
return ERR_MEM;
|
||||
}
|
||||
newconn->mbox = sys_mbox_new();
|
||||
if(newconn->mbox == SYS_MBOX_NULL) {
|
||||
if (newconn->mbox == SYS_MBOX_NULL) {
|
||||
sys_mbox_free(newconn->recvmbox);
|
||||
memp_free(MEMP_NETCONN, newconn);
|
||||
return ERR_MEM;
|
||||
}
|
||||
newconn->sem = sys_sem_new(0);
|
||||
if(newconn->sem == SYS_SEM_NULL) {
|
||||
if (newconn->sem == SYS_SEM_NULL) {
|
||||
sys_mbox_free(newconn->recvmbox);
|
||||
sys_mbox_free(newconn->mbox);
|
||||
memp_free(MEMP_NETCONN, newconn);
|
||||
@@ -243,8 +243,8 @@ do_newconn(struct api_msg_msg *msg)
|
||||
static void
|
||||
do_delconn(struct api_msg_msg *msg)
|
||||
{
|
||||
if(msg->conn->pcb.tcp != NULL) {
|
||||
switch(msg->conn->type) {
|
||||
if (msg->conn->pcb.tcp != NULL) {
|
||||
switch (msg->conn->type) {
|
||||
#if LWIP_UDP
|
||||
case NETCONN_UDPLITE:
|
||||
/* FALLTHROUGH */
|
||||
@@ -257,7 +257,7 @@ do_delconn(struct api_msg_msg *msg)
|
||||
#endif /* LWIP_UDP */
|
||||
#if LWIP_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_accept(msg->conn->pcb.tcp, NULL);
|
||||
tcp_close(msg->conn->pcb.tcp);
|
||||
@@ -267,7 +267,7 @@ do_delconn(struct api_msg_msg *msg)
|
||||
tcp_recv(msg->conn->pcb.tcp, NULL);
|
||||
tcp_poll(msg->conn->pcb.tcp, NULL, 0);
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -283,7 +283,7 @@ do_delconn(struct api_msg_msg *msg)
|
||||
(*msg->conn->callback)(msg->conn, NETCONN_EVT_SENDPLUS, 0);
|
||||
}
|
||||
|
||||
if(msg->conn->mbox != SYS_MBOX_NULL) {
|
||||
if (msg->conn->mbox != SYS_MBOX_NULL) {
|
||||
sys_mbox_post(msg->conn->mbox, NULL);
|
||||
}
|
||||
}
|
||||
@@ -291,8 +291,8 @@ do_delconn(struct api_msg_msg *msg)
|
||||
static void
|
||||
do_bind(struct api_msg_msg *msg)
|
||||
{
|
||||
if(msg->conn->pcb.tcp == NULL) {
|
||||
switch(msg->conn->type) {
|
||||
if (msg->conn->pcb.tcp == NULL) {
|
||||
switch (msg->conn->type) {
|
||||
#if LWIP_UDP
|
||||
case NETCONN_UDPLITE:
|
||||
msg->conn->pcb.udp = udp_new();
|
||||
@@ -318,7 +318,7 @@ do_bind(struct api_msg_msg *msg)
|
||||
break;
|
||||
}
|
||||
}
|
||||
switch(msg->conn->type) {
|
||||
switch (msg->conn->type) {
|
||||
#if LWIP_UDP
|
||||
case NETCONN_UDPLITE:
|
||||
/* FALLTHROUGH */
|
||||
@@ -347,12 +347,12 @@ do_connected(void *arg, struct tcp_pcb *pcb, err_t err)
|
||||
|
||||
conn = arg;
|
||||
|
||||
if(conn == NULL) {
|
||||
if (conn == NULL) {
|
||||
return ERR_VAL;
|
||||
}
|
||||
|
||||
conn->err = err;
|
||||
if(conn->type == NETCONN_TCP && err == ERR_OK) {
|
||||
if (conn->type == NETCONN_TCP && err == ERR_OK) {
|
||||
setup_tcp(conn);
|
||||
}
|
||||
sys_mbox_post(conn->mbox, NULL);
|
||||
@@ -363,12 +363,12 @@ do_connected(void *arg, struct tcp_pcb *pcb, err_t err)
|
||||
static void
|
||||
do_connect(struct api_msg_msg *msg)
|
||||
{
|
||||
if(msg->conn->pcb.tcp == NULL) {
|
||||
switch(msg->conn->type) {
|
||||
if (msg->conn->pcb.tcp == NULL) {
|
||||
switch (msg->conn->type) {
|
||||
#if LWIP_UDP
|
||||
case NETCONN_UDPLITE:
|
||||
msg->conn->pcb.udp = udp_new();
|
||||
if(msg->conn->pcb.udp == NULL) {
|
||||
if (msg->conn->pcb.udp == NULL) {
|
||||
msg->conn->err = ERR_MEM;
|
||||
sys_mbox_post(msg->conn->mbox, NULL);
|
||||
return;
|
||||
@@ -378,7 +378,7 @@ do_connect(struct api_msg_msg *msg)
|
||||
break;
|
||||
case NETCONN_UDPNOCHKSUM:
|
||||
msg->conn->pcb.udp = udp_new();
|
||||
if(msg->conn->pcb.udp == NULL) {
|
||||
if (msg->conn->pcb.udp == NULL) {
|
||||
msg->conn->err = ERR_MEM;
|
||||
sys_mbox_post(msg->conn->mbox, NULL);
|
||||
return;
|
||||
@@ -388,7 +388,7 @@ do_connect(struct api_msg_msg *msg)
|
||||
break;
|
||||
case NETCONN_UDP:
|
||||
msg->conn->pcb.udp = udp_new();
|
||||
if(msg->conn->pcb.udp == NULL) {
|
||||
if (msg->conn->pcb.udp == NULL) {
|
||||
msg->conn->err = ERR_MEM;
|
||||
sys_mbox_post(msg->conn->mbox, NULL);
|
||||
return;
|
||||
@@ -399,7 +399,7 @@ do_connect(struct api_msg_msg *msg)
|
||||
#if LWIP_TCP
|
||||
case NETCONN_TCP:
|
||||
msg->conn->pcb.tcp = tcp_new();
|
||||
if(msg->conn->pcb.tcp == NULL) {
|
||||
if (msg->conn->pcb.tcp == NULL) {
|
||||
msg->conn->err = ERR_MEM;
|
||||
sys_mbox_post(msg->conn->mbox, NULL);
|
||||
return;
|
||||
@@ -409,7 +409,7 @@ do_connect(struct api_msg_msg *msg)
|
||||
break;
|
||||
}
|
||||
}
|
||||
switch(msg->conn->type) {
|
||||
switch (msg->conn->type) {
|
||||
#if LWIP_UDP
|
||||
case NETCONN_UDPLITE:
|
||||
/* FALLTHROUGH */
|
||||
@@ -437,7 +437,7 @@ static void
|
||||
do_disconnect(struct api_msg_msg *msg)
|
||||
{
|
||||
|
||||
switch(msg->conn->type) {
|
||||
switch (msg->conn->type) {
|
||||
#if LWIP_UDP
|
||||
case NETCONN_UDPLITE:
|
||||
/* FALLTHROUGH */
|
||||
@@ -457,8 +457,8 @@ do_disconnect(struct api_msg_msg *msg)
|
||||
static void
|
||||
do_listen(struct api_msg_msg *msg)
|
||||
{
|
||||
if(msg->conn->pcb.tcp != NULL) {
|
||||
switch(msg->conn->type) {
|
||||
if (msg->conn->pcb.tcp != NULL) {
|
||||
switch (msg->conn->type) {
|
||||
#if LWIP_UDP
|
||||
case NETCONN_UDPLITE:
|
||||
/* FALLTHROUGH */
|
||||
@@ -471,12 +471,12 @@ do_listen(struct api_msg_msg *msg)
|
||||
#if LWIP_TCP
|
||||
case NETCONN_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;
|
||||
} else {
|
||||
if(msg->conn->acceptmbox == SYS_MBOX_NULL) {
|
||||
if (msg->conn->acceptmbox == SYS_MBOX_NULL) {
|
||||
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;
|
||||
break;
|
||||
}
|
||||
@@ -495,8 +495,8 @@ do_listen(struct api_msg_msg *msg)
|
||||
static void
|
||||
do_accept(struct api_msg_msg *msg)
|
||||
{
|
||||
if(msg->conn->pcb.tcp != NULL) {
|
||||
switch(msg->conn->type) {
|
||||
if (msg->conn->pcb.tcp != NULL) {
|
||||
switch (msg->conn->type) {
|
||||
#if LWIP_UDP
|
||||
case NETCONN_UDPLITE:
|
||||
/* FALLTHROUGH */
|
||||
@@ -515,8 +515,8 @@ do_accept(struct api_msg_msg *msg)
|
||||
static void
|
||||
do_send(struct api_msg_msg *msg)
|
||||
{
|
||||
if(msg->conn->pcb.tcp != NULL) {
|
||||
switch(msg->conn->type) {
|
||||
if (msg->conn->pcb.tcp != NULL) {
|
||||
switch (msg->conn->type) {
|
||||
#if LWIP_UDP
|
||||
case NETCONN_UDPLITE:
|
||||
/* FALLTHROUGH */
|
||||
@@ -537,8 +537,8 @@ static void
|
||||
do_recv(struct api_msg_msg *msg)
|
||||
{
|
||||
#if LWIP_TCP
|
||||
if(msg->conn->pcb.tcp != NULL) {
|
||||
if(msg->conn->type == NETCONN_TCP) {
|
||||
if (msg->conn->pcb.tcp != NULL) {
|
||||
if (msg->conn->type == NETCONN_TCP) {
|
||||
tcp_recved(msg->conn->pcb.tcp, msg->msg.len);
|
||||
}
|
||||
}
|
||||
@@ -552,8 +552,8 @@ do_write(struct api_msg_msg *msg)
|
||||
#if LWIP_TCP
|
||||
err_t err;
|
||||
#endif
|
||||
if(msg->conn->pcb.tcp != NULL) {
|
||||
switch(msg->conn->type) {
|
||||
if (msg->conn->pcb.tcp != NULL) {
|
||||
switch (msg->conn->type) {
|
||||
#if LWIP_UDP
|
||||
case NETCONN_UDPLITE:
|
||||
/* FALLTHROUGH */
|
||||
@@ -571,7 +571,7 @@ do_write(struct api_msg_msg *msg)
|
||||
segments when new outgoing data arrives from the user if any
|
||||
previously transmitted data on the connection remains
|
||||
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);
|
||||
}
|
||||
msg->conn->err = err;
|
||||
@@ -596,8 +596,8 @@ do_close(struct api_msg_msg *msg)
|
||||
|
||||
err = ERR_OK;
|
||||
|
||||
if(msg->conn->pcb.tcp != NULL) {
|
||||
switch(msg->conn->type) {
|
||||
if (msg->conn->pcb.tcp != NULL) {
|
||||
switch (msg->conn->type) {
|
||||
#if LWIP_UDP
|
||||
case NETCONN_UDPLITE:
|
||||
/* FALLTHROUGH */
|
||||
@@ -608,7 +608,7 @@ do_close(struct api_msg_msg *msg)
|
||||
#endif /* LWIP_UDP */
|
||||
#if LWIP_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);
|
||||
}
|
||||
msg->conn->err = err;
|
||||
|
||||
@@ -97,7 +97,7 @@ static int err_to_errno_table[11] = {
|
||||
#define sock_set_errno(sk, e) do { \
|
||||
sk->err = (e); \
|
||||
set_errno(sk->err); \
|
||||
} while(0)
|
||||
} while (0)
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
static struct lwip_socket *
|
||||
@@ -105,7 +105,7 @@ get_socket(int s)
|
||||
{
|
||||
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));
|
||||
set_errno(EBADF);
|
||||
return NULL;
|
||||
@@ -113,7 +113,7 @@ get_socket(int s)
|
||||
|
||||
sock = &sockets[s];
|
||||
|
||||
if(!sock->conn) {
|
||||
if (!sock->conn) {
|
||||
DEBUGF(SOCKETS_DEBUG, ("get_socket(%d): not active\n", s));
|
||||
set_errno(EBADF);
|
||||
return NULL;
|
||||
@@ -135,7 +135,7 @@ alloc_socket(struct netconn *newconn)
|
||||
|
||||
/* allocate a new socket identifier */
|
||||
for(i = 0; i < NUM_SOCKETS; ++i) {
|
||||
if(!sockets[i].conn) {
|
||||
if (!sockets[i].conn) {
|
||||
sockets[i].conn = newconn;
|
||||
sockets[i].lastdata = NULL;
|
||||
sockets[i].lastoffset = 0;
|
||||
@@ -163,7 +163,7 @@ lwip_accept(int s, struct sockaddr *addr, socklen_t *addrlen)
|
||||
|
||||
DEBUGF(SOCKETS_DEBUG, ("lwip_accept(%d)...\n", s));
|
||||
sock = get_socket(s);
|
||||
if(!sock) {
|
||||
if (!sock) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -178,13 +178,13 @@ lwip_accept(int s, struct sockaddr *addr, socklen_t *addrlen)
|
||||
sin.sin_port = htons(port);
|
||||
sin.sin_addr.s_addr = naddr.addr;
|
||||
|
||||
if(*addrlen > sizeof(sin))
|
||||
if (*addrlen > sizeof(sin))
|
||||
*addrlen = sizeof(sin);
|
||||
|
||||
memcpy(addr, &sin, *addrlen);
|
||||
|
||||
newsock = alloc_socket(newconn);
|
||||
if(newsock == -1) {
|
||||
if (newsock == -1) {
|
||||
netconn_delete(newconn);
|
||||
sock_set_errno(sock, ENOBUFS);
|
||||
return -1;
|
||||
@@ -216,7 +216,7 @@ lwip_bind(int s, struct sockaddr *name, socklen_t namelen)
|
||||
err_t err;
|
||||
|
||||
sock = get_socket(s);
|
||||
if(!sock) {
|
||||
if (!sock) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -231,7 +231,7 @@ lwip_bind(int s, struct sockaddr *name, socklen_t namelen)
|
||||
|
||||
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));
|
||||
sock_set_errno(sock, err_to_errno(err));
|
||||
return -1;
|
||||
@@ -255,13 +255,13 @@ lwip_close(int s)
|
||||
sys_sem_wait(socksem);
|
||||
|
||||
sock = get_socket(s);
|
||||
if(!sock) {
|
||||
if (!sock) {
|
||||
sys_sem_signal(socksem);
|
||||
return -1;
|
||||
}
|
||||
|
||||
netconn_delete(sock->conn);
|
||||
if(sock->lastdata) {
|
||||
if (sock->lastdata) {
|
||||
netbuf_delete(sock->lastdata);
|
||||
}
|
||||
sock->lastdata = NULL;
|
||||
@@ -279,7 +279,7 @@ lwip_connect(int s, struct sockaddr *name, socklen_t namelen)
|
||||
err_t err;
|
||||
|
||||
sock = get_socket(s);
|
||||
if(!sock) {
|
||||
if (!sock) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -302,7 +302,7 @@ lwip_connect(int s, struct sockaddr *name, socklen_t namelen)
|
||||
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));
|
||||
sock_set_errno(sock, err_to_errno(err));
|
||||
return -1;
|
||||
@@ -321,13 +321,13 @@ lwip_listen(int s, int backlog)
|
||||
|
||||
DEBUGF(SOCKETS_DEBUG, ("lwip_listen(%d, backlog=%d)\n", s, backlog));
|
||||
sock = get_socket(s);
|
||||
if(!sock) {
|
||||
if (!sock) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
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));
|
||||
sock_set_errno(sock, err_to_errno(err));
|
||||
return -1;
|
||||
@@ -350,12 +350,12 @@ lwip_recvfrom(int s, void *mem, int len, unsigned int flags,
|
||||
|
||||
DEBUGF(SOCKETS_DEBUG, ("lwip_recvfrom(%d, %p, %d, 0x%x, ..)\n", s, mem, len, flags));
|
||||
sock = get_socket(s);
|
||||
if(!sock) {
|
||||
if (!sock) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Check if there is data left from the last recv operation. */
|
||||
if(sock->lastdata) {
|
||||
if (sock->lastdata) {
|
||||
buf = sock->lastdata;
|
||||
} else {
|
||||
/* If this is non-blocking call, then check first */
|
||||
@@ -371,7 +371,7 @@ lwip_recvfrom(int s, void *mem, int len, unsigned int flags,
|
||||
some from the network. */
|
||||
buf = netconn_recv(sock->conn);
|
||||
|
||||
if(!buf) {
|
||||
if (!buf) {
|
||||
/* We should really do some error checking here. */
|
||||
DEBUGF(SOCKETS_DEBUG, ("lwip_recvfrom(%d): buf == NULL!\n", s));
|
||||
sock_set_errno(sock, 0);
|
||||
@@ -383,7 +383,7 @@ lwip_recvfrom(int s, void *mem, int len, unsigned int flags,
|
||||
|
||||
buflen -= sock->lastoffset;
|
||||
|
||||
if(len > buflen) {
|
||||
if (len > buflen) {
|
||||
copylen = buflen;
|
||||
} else {
|
||||
copylen = len;
|
||||
@@ -394,7 +394,7 @@ lwip_recvfrom(int s, void *mem, int len, unsigned int flags,
|
||||
netbuf_copy_partial(buf, mem, copylen, sock->lastoffset);
|
||||
|
||||
/* Check to see from where the data was. */
|
||||
if(from && fromlen) {
|
||||
if (from && fromlen) {
|
||||
struct sockaddr_in sin;
|
||||
|
||||
addr = netbuf_fromaddr(buf);
|
||||
@@ -406,7 +406,7 @@ lwip_recvfrom(int s, void *mem, int len, unsigned int flags,
|
||||
sin.sin_port = htons(port);
|
||||
sin.sin_addr.s_addr = addr->addr;
|
||||
|
||||
if(*fromlen > sizeof(sin))
|
||||
if (*fromlen > sizeof(sin))
|
||||
*fromlen = sizeof(sin);
|
||||
|
||||
memcpy(from, &sin, *fromlen);
|
||||
@@ -431,7 +431,7 @@ lwip_recvfrom(int s, void *mem, int len, unsigned int flags,
|
||||
/* If this is a TCP socket, check if there is data left in the
|
||||
buffer. If so, it should be saved in the sock structure for next
|
||||
time around. */
|
||||
if(netconn_type(sock->conn) == NETCONN_TCP && buflen - copylen > 0) {
|
||||
if (netconn_type(sock->conn) == NETCONN_TCP && buflen - copylen > 0) {
|
||||
sock->lastdata = buf;
|
||||
sock->lastoffset += copylen;
|
||||
} else {
|
||||
@@ -467,16 +467,16 @@ lwip_send(int s, void *data, int size, unsigned int flags)
|
||||
DEBUGF(SOCKETS_DEBUG, ("lwip_send(%d, data=%p, size=%d, flags=0x%x)\n", s, data, size, flags));
|
||||
|
||||
sock = get_socket(s);
|
||||
if(!sock) {
|
||||
if (!sock) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
switch(netconn_type(sock->conn)) {
|
||||
switch (netconn_type(sock->conn)) {
|
||||
case NETCONN_UDP:
|
||||
/* create a buffer */
|
||||
buf = netbuf_new();
|
||||
|
||||
if(!buf) {
|
||||
if (!buf) {
|
||||
DEBUGF(SOCKETS_DEBUG, ("lwip_send(%d) ENOBUFS\n", s));
|
||||
sock_set_errno(sock, ENOBUFS);
|
||||
return -1;
|
||||
@@ -499,7 +499,7 @@ lwip_send(int s, void *data, int size, unsigned int flags)
|
||||
err = ERR_ARG;
|
||||
break;
|
||||
}
|
||||
if(err != ERR_OK) {
|
||||
if (err != ERR_OK) {
|
||||
DEBUGF(SOCKETS_DEBUG, ("lwip_send(%d) err=%d\n", s, err));
|
||||
sock_set_errno(sock, err_to_errno(err));
|
||||
return -1;
|
||||
@@ -520,7 +520,7 @@ lwip_sendto(int s, void *data, int size, unsigned int flags,
|
||||
int ret,connected;
|
||||
|
||||
sock = get_socket(s);
|
||||
if(!sock) {
|
||||
if (!sock) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -542,7 +542,7 @@ lwip_sendto(int s, void *data, int size, unsigned int flags,
|
||||
|
||||
/* reset the remote address and port number
|
||||
of the connection */
|
||||
if(connected)
|
||||
if (connected)
|
||||
netconn_connect(sock->conn, &addr, port);
|
||||
else
|
||||
netconn_disconnect(sock->conn);
|
||||
@@ -556,7 +556,7 @@ lwip_socket(int domain, int type, int protocol)
|
||||
int i;
|
||||
|
||||
/* create a netconn */
|
||||
switch(type) {
|
||||
switch (type) {
|
||||
case SOCK_DGRAM:
|
||||
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));
|
||||
@@ -571,7 +571,7 @@ lwip_socket(int domain, int type, int protocol)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(!conn) {
|
||||
if (!conn) {
|
||||
DEBUGF(SOCKETS_DEBUG, ("-1 / ENOBUFS (could not create netconn)\n"));
|
||||
set_errno(ENOBUFS);
|
||||
return -1;
|
||||
@@ -579,7 +579,7 @@ lwip_socket(int domain, int type, int protocol)
|
||||
|
||||
i = alloc_socket(conn);
|
||||
|
||||
if(i == -1) {
|
||||
if (i == -1) {
|
||||
netconn_delete(conn);
|
||||
set_errno(ENOBUFS);
|
||||
return -1;
|
||||
@@ -612,7 +612,7 @@ lwip_selscan(int maxfdp1, fd_set *readset, fd_set *writeset, fd_set *exceptset)
|
||||
currently match */
|
||||
for(i = 0; i < maxfdp1; i++)
|
||||
{
|
||||
if(FD_ISSET(i, readset))
|
||||
if (FD_ISSET(i, readset))
|
||||
{
|
||||
/* See if netconn of this socket is ready for read */
|
||||
p_sock = get_socket(i);
|
||||
@@ -623,7 +623,7 @@ lwip_selscan(int maxfdp1, fd_set *readset, fd_set *writeset, fd_set *exceptset)
|
||||
nready++;
|
||||
}
|
||||
}
|
||||
if(FD_ISSET(i, writeset))
|
||||
if (FD_ISSET(i, writeset))
|
||||
{
|
||||
/* See if netconn of this socket is ready for write */
|
||||
p_sock = get_socket(i);
|
||||
@@ -888,7 +888,7 @@ int lwip_getpeername (int s, struct sockaddr *name, socklen_t *namelen)
|
||||
struct ip_addr naddr;
|
||||
|
||||
sock = get_socket(s);
|
||||
if(!sock) {
|
||||
if (!sock) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -908,7 +908,7 @@ int lwip_getpeername (int s, struct sockaddr *name, socklen_t *namelen)
|
||||
sin.sin_port = htons(sin.sin_port);
|
||||
sin.sin_addr.s_addr = naddr.addr;
|
||||
|
||||
if(*namelen > sizeof(sin))
|
||||
if (*namelen > sizeof(sin))
|
||||
*namelen = sizeof(sin);
|
||||
|
||||
memcpy(name, &sin, *namelen);
|
||||
@@ -923,7 +923,7 @@ int lwip_getsockname (int s, struct sockaddr *name, socklen_t *namelen)
|
||||
struct ip_addr *naddr;
|
||||
|
||||
sock = get_socket(s);
|
||||
if(!sock) {
|
||||
if (!sock) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -943,7 +943,7 @@ int lwip_getsockname (int s, struct sockaddr *name, socklen_t *namelen)
|
||||
sin.sin_port = htons(sin.sin_port);
|
||||
sin.sin_addr.s_addr = naddr->addr;
|
||||
|
||||
if(*namelen > sizeof(sin))
|
||||
if (*namelen > sizeof(sin))
|
||||
*namelen = sizeof(sin);
|
||||
|
||||
memcpy(name, &sin, *namelen);
|
||||
@@ -956,14 +956,14 @@ int lwip_getsockopt (int s, int level, int optname, void *optval, socklen_t *opt
|
||||
int err = ENOSYS;
|
||||
struct lwip_socket *sock = get_socket(s);
|
||||
|
||||
if(!sock) {
|
||||
if (!sock) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(level == SOL_SOCKET) {
|
||||
switch(optname) {
|
||||
if (level == SOL_SOCKET) {
|
||||
switch (optname) {
|
||||
case SO_ERROR:
|
||||
if(!optval || !optlen || (*optlen != sizeof(int))) {
|
||||
if (!optval || !optlen || (*optlen != sizeof(int))) {
|
||||
err = EINVAL;
|
||||
break;
|
||||
}
|
||||
@@ -988,12 +988,12 @@ int lwip_setsockopt (int s, int level, int optname, const void *optval, socklen_
|
||||
struct lwip_socket *sock = get_socket(s);
|
||||
int err = ENOSYS;
|
||||
|
||||
if(!sock) {
|
||||
if (!sock) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(level == SOL_SOCKET) {
|
||||
switch(optname) {
|
||||
if (level == SOL_SOCKET) {
|
||||
switch (optname) {
|
||||
case SO_REUSEADDR:
|
||||
DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%d, SOL_SOCKET, SO_REUSEADDR, ..)\n", s));
|
||||
/* XXX just pretend we support this for now */
|
||||
@@ -1015,13 +1015,13 @@ int lwip_ioctl(int s, long cmd, void *argp)
|
||||
{
|
||||
struct lwip_socket *sock = get_socket(s);
|
||||
|
||||
if(!sock) {
|
||||
if (!sock) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
switch(cmd) {
|
||||
switch (cmd) {
|
||||
case FIONREAD:
|
||||
if(!argp) {
|
||||
if (!argp) {
|
||||
sock_set_errno(sock, EINVAL);
|
||||
return -1;
|
||||
}
|
||||
@@ -1033,7 +1033,7 @@ int lwip_ioctl(int s, long cmd, void *argp)
|
||||
return 0;
|
||||
|
||||
case FIONBIO:
|
||||
if(argp && *(u32_t*)argp)
|
||||
if (argp && *(u32_t*)argp)
|
||||
sock->flags |= O_NONBLOCK;
|
||||
else
|
||||
sock->flags &= ~O_NONBLOCK;
|
||||
|
||||
@@ -57,7 +57,7 @@ tcpip_tcp_timer(void *arg)
|
||||
(void)arg;
|
||||
|
||||
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);
|
||||
} else {
|
||||
tcpip_tcp_timer_active = 0;
|
||||
@@ -67,7 +67,7 @@ tcpip_tcp_timer(void *arg)
|
||||
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;
|
||||
sys_timeout(TCP_TMR_INTERVAL, tcpip_tcp_timer, NULL);
|
||||
}
|
||||
@@ -88,13 +88,13 @@ tcpip_thread(void *arg)
|
||||
#if LWIP_TCP
|
||||
tcp_init();
|
||||
#endif
|
||||
if(tcpip_init_done != NULL) {
|
||||
if (tcpip_init_done != NULL) {
|
||||
tcpip_init_done(tcpip_init_done_arg);
|
||||
}
|
||||
|
||||
while(1) { /* MAIN Loop */
|
||||
while (1) { /* MAIN Loop */
|
||||
sys_mbox_fetch(mbox, (void *)&msg);
|
||||
switch(msg->type) {
|
||||
switch (msg->type) {
|
||||
case TCPIP_MSG_API:
|
||||
DEBUGF(TCPIP_DEBUG, ("tcpip_thread: API message %p\n", (void *)msg));
|
||||
api_msg_input(msg->msg.apimsg);
|
||||
@@ -120,7 +120,7 @@ tcpip_input(struct pbuf *p, struct netif *inp)
|
||||
struct tcpip_msg *msg;
|
||||
|
||||
msg = memp_mallocp(MEMP_TCPIP_MSG);
|
||||
if(msg == NULL) {
|
||||
if (msg == NULL) {
|
||||
pbuf_free(p);
|
||||
return ERR_MEM;
|
||||
}
|
||||
@@ -138,7 +138,7 @@ tcpip_callback(void (*f)(void *ctx), void *ctx)
|
||||
struct tcpip_msg *msg;
|
||||
|
||||
msg = memp_mallocp(MEMP_TCPIP_MSG);
|
||||
if(msg == NULL) {
|
||||
if (msg == NULL) {
|
||||
return ERR_MEM;
|
||||
}
|
||||
|
||||
@@ -154,7 +154,7 @@ tcpip_apimsg(struct api_msg *apimsg)
|
||||
{
|
||||
struct tcpip_msg *msg;
|
||||
msg = memp_mallocp(MEMP_TCPIP_MSG);
|
||||
if(msg == NULL) {
|
||||
if (msg == NULL) {
|
||||
memp_free(MEMP_API_MSG, apimsg);
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user