Replaced all tabs with two spaces (regardless of indentation is correct).

This commit is contained in:
likewise
2003-06-09 21:14:47 +00:00
parent 829744dfe6
commit df99ce9d98
42 changed files with 1266 additions and 1267 deletions

View File

@@ -165,10 +165,10 @@ netbuf_copy_partial(struct netbuf *buf, void *dataptr, u16_t len, u16_t offset)
offset -= p->len;
} else {
for(i = offset; i < p->len; ++i) {
((char *)dataptr)[left] = ((char *)p->payload)[i];
if (++left >= len) {
return;
}
((char *)dataptr)[left] = ((char *)p->payload)[i];
if (++left >= len) {
return;
}
}
offset = 0;
}
@@ -257,9 +257,9 @@ netconn_delete(struct netconn *conn)
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);
pbuf_free((struct pbuf *)mem);
} else {
netbuf_delete((struct netbuf *)mem);
netbuf_delete((struct netbuf *)mem);
}
}
sys_mbox_free(conn->recvmbox);
@@ -295,14 +295,14 @@ netconn_type(struct netconn *conn)
/*-----------------------------------------------------------------------------------*/
err_t
netconn_peer(struct netconn *conn, struct ip_addr *addr,
u16_t *port)
u16_t *port)
{
switch (conn->type) {
case NETCONN_UDPLITE:
case NETCONN_UDPNOCHKSUM:
case NETCONN_UDP:
if (conn->pcb.udp == NULL ||
((conn->pcb.udp->flags & UDP_FLAGS_CONNECTED) == 0))
((conn->pcb.udp->flags & UDP_FLAGS_CONNECTED) == 0))
return ERR_CONN;
*addr = (conn->pcb.udp->remote_ip);
*port = conn->pcb.udp->remote_port;
@@ -319,7 +319,7 @@ netconn_peer(struct netconn *conn, struct ip_addr *addr,
/*-----------------------------------------------------------------------------------*/
err_t
netconn_addr(struct netconn *conn, struct ip_addr **addr,
u16_t *port)
u16_t *port)
{
switch (conn->type) {
case NETCONN_UDPLITE:
@@ -338,7 +338,7 @@ netconn_addr(struct netconn *conn, struct ip_addr **addr,
/*-----------------------------------------------------------------------------------*/
err_t
netconn_bind(struct netconn *conn, struct ip_addr *addr,
u16_t port)
u16_t port)
{
struct api_msg *msg;
@@ -369,7 +369,7 @@ netconn_bind(struct netconn *conn, struct ip_addr *addr,
/*-----------------------------------------------------------------------------------*/
err_t
netconn_connect(struct netconn *conn, struct ip_addr *addr,
u16_t port)
u16_t port)
{
struct api_msg *msg;
@@ -543,7 +543,7 @@ netconn_recv(struct netconn *conn)
memp_freep(MEMP_API_MSG, msg);
} else {
sys_mbox_fetch(conn->recvmbox, (void **)&buf);
conn->recv_avail -= buf->p->tot_len;
conn->recv_avail -= buf->p->tot_len;
/* Register event with callback */
if (conn->callback)
(*conn->callback)(conn, NETCONN_EVT_RCVMINUS, buf->p->tot_len);
@@ -621,17 +621,17 @@ netconn_write(struct netconn *conn, void *dataptr, u16_t size, u8_t copy)
if (conn->type == NETCONN_TCP) {
if (tcp_sndbuf(conn->pcb.tcp) == 0) {
sys_sem_wait(conn->sem);
if (conn->err != ERR_OK) {
goto ret;
}
sys_sem_wait(conn->sem);
if (conn->err != ERR_OK) {
goto ret;
}
}
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);
/* We cannot send more than one send buffer's worth of data at a
time. */
len = tcp_sndbuf(conn->pcb.tcp);
} else {
len = size;
len = size;
}
} else {
len = size;

View File

@@ -40,7 +40,7 @@
#if LWIP_UDP
static void
recv_udp(void *arg, struct udp_pcb *pcb, struct pbuf *p,
struct ip_addr *addr, u16_t port)
struct ip_addr *addr, u16_t port)
{
struct netbuf *buf;
struct netconn *conn;
@@ -63,7 +63,7 @@ recv_udp(void *arg, struct udp_pcb *pcb, struct pbuf *p,
buf->fromport = port;
}
conn->recv_avail += p->tot_len;
conn->recv_avail += p->tot_len;
/* Register event with callback */
if (conn->callback)
(*conn->callback)(conn, NETCONN_EVT_RCVPLUS, p->tot_len);
@@ -87,7 +87,7 @@ recv_tcp(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err)
}
if (conn->recvmbox != SYS_MBOX_NULL) {
conn->err = err;
if (p != NULL) {
len = p->tot_len;
@@ -258,18 +258,18 @@ do_delconn(struct api_msg_msg *msg)
#if LWIP_TCP
case NETCONN_TCP:
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);
tcp_arg(msg->conn->pcb.tcp, NULL);
tcp_accept(msg->conn->pcb.tcp, NULL);
tcp_close(msg->conn->pcb.tcp);
} else {
tcp_arg(msg->conn->pcb.tcp, NULL);
tcp_sent(msg->conn->pcb.tcp, NULL);
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) {
tcp_abort(msg->conn->pcb.tcp);
}
tcp_arg(msg->conn->pcb.tcp, NULL);
tcp_sent(msg->conn->pcb.tcp, NULL);
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) {
tcp_abort(msg->conn->pcb.tcp);
}
}
#endif
default:
@@ -331,7 +331,7 @@ do_bind(struct api_msg_msg *msg)
#if LWIP_TCP
case NETCONN_TCP:
msg->conn->err = tcp_bind(msg->conn->pcb.tcp,
msg->msg.bc.ipaddr, msg->msg.bc.port);
msg->msg.bc.ipaddr, msg->msg.bc.port);
#endif /* LWIP_TCP */
default:
break;
@@ -369,9 +369,9 @@ do_connect(struct api_msg_msg *msg)
case NETCONN_UDPLITE:
msg->conn->pcb.udp = udp_new();
if (msg->conn->pcb.udp == NULL) {
msg->conn->err = ERR_MEM;
sys_mbox_post(msg->conn->mbox, NULL);
return;
msg->conn->err = ERR_MEM;
sys_mbox_post(msg->conn->mbox, NULL);
return;
}
udp_setflags(msg->conn->pcb.udp, UDP_FLAGS_UDPLITE);
udp_recv(msg->conn->pcb.udp, recv_udp, msg->conn);
@@ -379,9 +379,9 @@ do_connect(struct api_msg_msg *msg)
case NETCONN_UDPNOCHKSUM:
msg->conn->pcb.udp = udp_new();
if (msg->conn->pcb.udp == NULL) {
msg->conn->err = ERR_MEM;
sys_mbox_post(msg->conn->mbox, NULL);
return;
msg->conn->err = ERR_MEM;
sys_mbox_post(msg->conn->mbox, NULL);
return;
}
udp_setflags(msg->conn->pcb.udp, UDP_FLAGS_NOCHKSUM);
udp_recv(msg->conn->pcb.udp, recv_udp, msg->conn);
@@ -389,9 +389,9 @@ do_connect(struct api_msg_msg *msg)
case NETCONN_UDP:
msg->conn->pcb.udp = udp_new();
if (msg->conn->pcb.udp == NULL) {
msg->conn->err = ERR_MEM;
sys_mbox_post(msg->conn->mbox, NULL);
return;
msg->conn->err = ERR_MEM;
sys_mbox_post(msg->conn->mbox, NULL);
return;
}
udp_recv(msg->conn->pcb.udp, recv_udp, msg->conn);
break;
@@ -400,9 +400,9 @@ do_connect(struct api_msg_msg *msg)
case NETCONN_TCP:
msg->conn->pcb.tcp = tcp_new();
if (msg->conn->pcb.tcp == NULL) {
msg->conn->err = ERR_MEM;
sys_mbox_post(msg->conn->mbox, NULL);
return;
msg->conn->err = ERR_MEM;
sys_mbox_post(msg->conn->mbox, NULL);
return;
}
#endif
default:
@@ -425,7 +425,7 @@ do_connect(struct api_msg_msg *msg)
/* tcp_arg(msg->conn->pcb.tcp, msg->conn);*/
setup_tcp(msg->conn);
tcp_connect(msg->conn->pcb.tcp, msg->msg.bc.ipaddr, msg->msg.bc.port,
do_connected);
do_connected);
/*tcp_output(msg->conn->pcb.tcp);*/
#endif
default:
@@ -472,17 +472,17 @@ do_listen(struct api_msg_msg *msg)
case NETCONN_TCP:
msg->conn->pcb.tcp = tcp_listen(msg->conn->pcb.tcp);
if (msg->conn->pcb.tcp == NULL) {
msg->conn->err = ERR_MEM;
msg->conn->err = ERR_MEM;
} else {
if (msg->conn->acceptmbox == SYS_MBOX_NULL) {
msg->conn->acceptmbox = sys_mbox_new();
if (msg->conn->acceptmbox == SYS_MBOX_NULL) {
msg->conn->err = ERR_MEM;
break;
}
}
tcp_arg(msg->conn->pcb.tcp, msg->conn);
tcp_accept(msg->conn->pcb.tcp, accept_function);
if (msg->conn->acceptmbox == SYS_MBOX_NULL) {
msg->conn->acceptmbox = sys_mbox_new();
if (msg->conn->acceptmbox == SYS_MBOX_NULL) {
msg->conn->err = ERR_MEM;
break;
}
}
tcp_arg(msg->conn->pcb.tcp, msg->conn);
tcp_accept(msg->conn->pcb.tcp, accept_function);
}
#endif
default:
@@ -549,7 +549,7 @@ do_recv(struct api_msg_msg *msg)
static void
do_write(struct api_msg_msg *msg)
{
#if LWIP_TCP
#if LWIP_TCP
err_t err;
#endif
if (msg->conn->pcb.tcp != NULL) {
@@ -568,11 +568,11 @@ do_write(struct api_msg_msg *msg)
err = tcp_write(msg->conn->pcb.tcp, msg->msg.w.dataptr,
msg->msg.w.len, msg->msg.w.copy);
/* This is the Nagle algorithm: inhibit the sending of new TCP
segments when new outgoing data arrives from the user if any
previously transmitted data on the connection remains
unacknowledged. */
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) {
tcp_output(msg->conn->pcb.tcp);
tcp_output(msg->conn->pcb.tcp);
}
msg->conn->err = err;
if (msg->conn->callback)
@@ -609,7 +609,7 @@ do_close(struct api_msg_msg *msg)
#if LWIP_TCP
case NETCONN_TCP:
if (msg->conn->pcb.tcp->state == LISTEN) {
err = tcp_close(msg->conn->pcb.tcp);
err = tcp_close(msg->conn->pcb.tcp);
}
msg->conn->err = err;
#endif

View File

@@ -35,16 +35,16 @@
#ifdef LWIP_DEBUG
static char *err_strerr[] = {"Ok.",
"Out of memory error.",
"Buffer error.",
"Connection aborted.",
"Connection reset.",
"Connection closed.",
"Not connected.",
"Illegal value.",
"Illegal argument.",
"Routing problem.",
"Address in use."
"Out of memory error.",
"Buffer error.",
"Connection aborted.",
"Connection reset.",
"Connection closed.",
"Not connected.",
"Illegal value.",
"Illegal argument.",
"Routing problem.",
"Address in use."
};
/*-----------------------------------------------------------------------------------*/

View File

@@ -47,7 +47,7 @@ struct lwip_socket {
u16_t lastoffset;
u16_t rcvevent;
u16_t sendevent;
u16_t flags;
u16_t flags;
int err;
};
@@ -71,22 +71,22 @@ static void
event_callback(struct netconn *conn, enum netconn_evt evt, u16_t len);
static int err_to_errno_table[11] = {
0, /* ERR_OK 0 No error, everything OK. */
ENOMEM, /* ERR_MEM -1 Out of memory error. */
ENOBUFS, /* ERR_BUF -2 Buffer error. */
ECONNABORTED, /* ERR_ABRT -3 Connection aborted. */
ECONNRESET, /* ERR_RST -4 Connection reset. */
ESHUTDOWN, /* ERR_CLSD -5 Connection closed. */
ENOTCONN, /* ERR_CONN -6 Not connected. */
EINVAL, /* ERR_VAL -7 Illegal value. */
EIO, /* ERR_ARG -8 Illegal argument. */
EHOSTUNREACH, /* ERR_RTE -9 Routing problem. */
EADDRINUSE /* ERR_USE -10 Address in use. */
0, /* ERR_OK 0 No error, everything OK. */
ENOMEM, /* ERR_MEM -1 Out of memory error. */
ENOBUFS, /* ERR_BUF -2 Buffer error. */
ECONNABORTED, /* ERR_ABRT -3 Connection aborted. */
ECONNRESET, /* ERR_RST -4 Connection reset. */
ESHUTDOWN, /* ERR_CLSD -5 Connection closed. */
ENOTCONN, /* ERR_CONN -6 Not connected. */
EINVAL, /* ERR_VAL -7 Illegal value. */
EIO, /* ERR_ARG -8 Illegal argument. */
EHOSTUNREACH, /* ERR_RTE -9 Routing problem. */
EADDRINUSE /* ERR_USE -10 Address in use. */
};
#define err_to_errno(err) \
((err) < (sizeof(err_to_errno_table)/sizeof(int))) ? \
err_to_errno_table[-(err)] : EIO
((err) < (sizeof(err_to_errno_table)/sizeof(int))) ? \
err_to_errno_table[-(err)] : EIO
#ifdef ERRNO
#define set_errno(err) errno = (err)
@@ -95,8 +95,8 @@ static int err_to_errno_table[11] = {
#endif
#define sock_set_errno(sk, e) do { \
sk->err = (e); \
set_errno(sk->err); \
sk->err = (e); \
set_errno(sk->err); \
} while (0)
/*-----------------------------------------------------------------------------------*/
@@ -106,16 +106,16 @@ get_socket(int s)
struct lwip_socket *sock;
if ((s < 0) || (s > NUM_SOCKETS)) {
DEBUGF(SOCKETS_DEBUG, ("get_socket(%d): invalid\n", s));
set_errno(EBADF);
DEBUGF(SOCKETS_DEBUG, ("get_socket(%d): invalid\n", s));
set_errno(EBADF);
return NULL;
}
sock = &sockets[s];
if (!sock->conn) {
DEBUGF(SOCKETS_DEBUG, ("get_socket(%d): not active\n", s));
set_errno(EBADF);
DEBUGF(SOCKETS_DEBUG, ("get_socket(%d): not active\n", s));
set_errno(EBADF);
return NULL;
}
@@ -186,8 +186,8 @@ lwip_accept(int s, struct sockaddr *addr, socklen_t *addrlen)
newsock = alloc_socket(newconn);
if (newsock == -1) {
netconn_delete(newconn);
sock_set_errno(sock, ENOBUFS);
return -1;
sock_set_errno(sock, ENOBUFS);
return -1;
}
newconn->callback = event_callback;
sock = get_socket(newsock);
@@ -232,8 +232,8 @@ lwip_bind(int s, struct sockaddr *name, socklen_t namelen)
err = netconn_bind(sock->conn, &local_addr, ntohs(local_port));
if (err != ERR_OK) {
DEBUGF(SOCKETS_DEBUG, ("lwip_bind(%d) failed, err=%d\n", s, err));
sock_set_errno(sock, err_to_errno(err));
DEBUGF(SOCKETS_DEBUG, ("lwip_bind(%d) failed, err=%d\n", s, err));
sock_set_errno(sock, err_to_errno(err));
return -1;
}
@@ -284,27 +284,27 @@ lwip_connect(int s, struct sockaddr *name, socklen_t namelen)
}
if (((struct sockaddr_in *)name)->sin_family == AF_UNSPEC) {
DEBUGF(SOCKETS_DEBUG, ("lwip_connect(%d, AF_UNSPEC)\n", s));
err = netconn_disconnect(sock->conn);
DEBUGF(SOCKETS_DEBUG, ("lwip_connect(%d, AF_UNSPEC)\n", s));
err = netconn_disconnect(sock->conn);
} else {
struct ip_addr remote_addr;
u16_t remote_port;
struct ip_addr remote_addr;
u16_t remote_port;
remote_addr.addr = ((struct sockaddr_in *)name)->sin_addr.s_addr;
remote_port = ((struct sockaddr_in *)name)->sin_port;
remote_addr.addr = ((struct sockaddr_in *)name)->sin_addr.s_addr;
remote_port = ((struct sockaddr_in *)name)->sin_port;
#if SOCKETS_DEBUG
DEBUGF(SOCKETS_DEBUG, ("lwip_connect(%d, addr=", s));
ip_addr_debug_print(&remote_addr);
DEBUGF(SOCKETS_DEBUG, (" port=%u)\n", ntohs(remote_port)));
DEBUGF(SOCKETS_DEBUG, ("lwip_connect(%d, addr=", s));
ip_addr_debug_print(&remote_addr);
DEBUGF(SOCKETS_DEBUG, (" port=%u)\n", ntohs(remote_port)));
#endif
err = netconn_connect(sock->conn, &remote_addr, ntohs(remote_port));
err = netconn_connect(sock->conn, &remote_addr, ntohs(remote_port));
}
if (err != ERR_OK) {
DEBUGF(SOCKETS_DEBUG, ("lwip_connect(%d) failed, err=%d\n", s, err));
sock_set_errno(sock, err_to_errno(err));
DEBUGF(SOCKETS_DEBUG, ("lwip_connect(%d) failed, err=%d\n", s, err));
sock_set_errno(sock, err_to_errno(err));
return -1;
}
@@ -328,8 +328,8 @@ lwip_listen(int s, int backlog)
err = netconn_listen(sock->conn);
if (err != ERR_OK) {
DEBUGF(SOCKETS_DEBUG, ("lwip_listen(%d) failed, err=%d\n", s, err));
sock_set_errno(sock, err_to_errno(err));
DEBUGF(SOCKETS_DEBUG, ("lwip_listen(%d) failed, err=%d\n", s, err));
sock_set_errno(sock, err_to_errno(err));
return -1;
}
@@ -339,7 +339,7 @@ lwip_listen(int s, int backlog)
/*-----------------------------------------------------------------------------------*/
int
lwip_recvfrom(int s, void *mem, int len, unsigned int flags,
struct sockaddr *from, socklen_t *fromlen)
struct sockaddr *from, socklen_t *fromlen)
{
struct lwip_socket *sock;
struct netbuf *buf;
@@ -360,7 +360,7 @@ lwip_recvfrom(int s, void *mem, int len, unsigned int flags,
} else {
/* If this is non-blocking call, then check first */
if (((flags & MSG_DONTWAIT) || (sock->flags & O_NONBLOCK))
&& !sock->rcvevent)
&& !sock->rcvevent)
{
DEBUGF(SOCKETS_DEBUG, ("lwip_recvfrom(%d): returning EWOULDBLOCK\n", s));
sock_set_errno(sock, EWOULDBLOCK);
@@ -477,8 +477,8 @@ lwip_send(int s, void *data, int size, unsigned int flags)
buf = netbuf_new();
if (!buf) {
DEBUGF(SOCKETS_DEBUG, ("lwip_send(%d) ENOBUFS\n", s));
sock_set_errno(sock, ENOBUFS);
DEBUGF(SOCKETS_DEBUG, ("lwip_send(%d) ENOBUFS\n", s));
sock_set_errno(sock, ENOBUFS);
return -1;
}
@@ -500,8 +500,8 @@ lwip_send(int s, void *data, int size, unsigned int flags)
break;
}
if (err != ERR_OK) {
DEBUGF(SOCKETS_DEBUG, ("lwip_send(%d) err=%d\n", s, err));
sock_set_errno(sock, err_to_errno(err));
DEBUGF(SOCKETS_DEBUG, ("lwip_send(%d) err=%d\n", s, err));
sock_set_errno(sock, err_to_errno(err));
return -1;
}
@@ -543,9 +543,9 @@ lwip_sendto(int s, void *data, int size, unsigned int flags,
/* reset the remote address and port number
of the connection */
if (connected)
netconn_connect(sock->conn, &addr, port);
netconn_connect(sock->conn, &addr, port);
else
netconn_disconnect(sock->conn);
netconn_disconnect(sock->conn);
return ret;
}
/*-----------------------------------------------------------------------------------*/
@@ -559,21 +559,21 @@ lwip_socket(int domain, int type, int protocol)
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));
DEBUGF(SOCKETS_DEBUG, ("lwip_socket(%s, SOCK_DGRAM, %d) = ", domain == PF_INET ? "PF_INET" : "UNKNOWN", protocol));
break;
case SOCK_STREAM:
conn = netconn_new_with_callback(NETCONN_TCP, event_callback);
DEBUGF(SOCKETS_DEBUG, ("lwip_socket(%s, SOCK_STREAM, %d) = ", domain == PF_INET ? "PF_INET" : "UNKNOWN", protocol));
DEBUGF(SOCKETS_DEBUG, ("lwip_socket(%s, SOCK_STREAM, %d) = ", domain == PF_INET ? "PF_INET" : "UNKNOWN", protocol));
break;
default:
DEBUGF(SOCKETS_DEBUG, ("lwip_socket(%d, %d/UNKNOWN, %d) = -1\n", domain, type, protocol));
set_errno(EINVAL);
DEBUGF(SOCKETS_DEBUG, ("lwip_socket(%d, %d/UNKNOWN, %d) = -1\n", domain, type, protocol));
set_errno(EINVAL);
return -1;
}
if (!conn) {
DEBUGF(SOCKETS_DEBUG, ("-1 / ENOBUFS (could not create netconn)\n"));
set_errno(ENOBUFS);
set_errno(ENOBUFS);
return -1;
}
@@ -581,8 +581,8 @@ lwip_socket(int domain, int type, int protocol)
if (i == -1) {
netconn_delete(conn);
set_errno(ENOBUFS);
return -1;
set_errno(ENOBUFS);
return -1;
}
conn->socket = i;
DEBUGF(SOCKETS_DEBUG, ("%d\n", i));
@@ -619,7 +619,7 @@ lwip_selscan(int maxfdp1, fd_set *readset, fd_set *writeset, fd_set *exceptset)
if (p_sock && (p_sock->lastdata || p_sock->rcvevent))
{
FD_SET(i, &lreadset);
DEBUGF(SOCKETS_DEBUG, ("lwip_selscan: fd=%d ready for reading\n", i));
DEBUGF(SOCKETS_DEBUG, ("lwip_selscan: fd=%d ready for reading\n", i));
nready++;
}
}
@@ -630,7 +630,7 @@ lwip_selscan(int maxfdp1, fd_set *readset, fd_set *writeset, fd_set *exceptset)
if (p_sock && p_sock->sendevent)
{
FD_SET(i, &lwriteset);
DEBUGF(SOCKETS_DEBUG, ("lwip_selscan: fd=%d ready for writing\n", i));
DEBUGF(SOCKETS_DEBUG, ("lwip_selscan: fd=%d ready for writing\n", i));
nready++;
}
}
@@ -655,7 +655,7 @@ lwip_select(int maxfdp1, fd_set *readset, fd_set *writeset, fd_set *exceptset,
struct lwip_select_cb select_cb;
struct lwip_select_cb *p_selcb;
DEBUGF(SOCKETS_DEBUG, ("lwip_select(%d, %p, %p, %p, tvsec=%ld tvusec=%ld)\n", maxfdp1, (void *)readset, (void *) writeset, (void *) exceptset, timeout ? timeout->tv_sec : -1L, timeout ? timeout->tv_usec : -1L));
DEBUGF(SOCKETS_DEBUG, ("lwip_select(%d, %p, %p, %p, tvsec=%ld tvusec=%ld)\n", maxfdp1, (void *)readset, (void *) writeset, (void *) exceptset, timeout ? timeout->tv_sec : -1L, timeout ? timeout->tv_usec : -1L));
select_cb.next = 0;
select_cb.readset = readset;
select_cb.writeset = writeset;
@@ -697,8 +697,8 @@ lwip_select(int maxfdp1, fd_set *readset, fd_set *writeset, fd_set *exceptset,
if (exceptset)
FD_ZERO(exceptset);
DEBUGF(SOCKETS_DEBUG, ("lwip_select: no timeout, returning 0\n"));
set_errno(0);
DEBUGF(SOCKETS_DEBUG, ("lwip_select: no timeout, returning 0\n"));
set_errno(0);
return 0;
}
@@ -748,8 +748,8 @@ lwip_select(int maxfdp1, fd_set *readset, fd_set *writeset, fd_set *exceptset,
FD_ZERO(writeset);
if (exceptset)
FD_ZERO(exceptset);
DEBUGF(SOCKETS_DEBUG, ("lwip_select: timeout expired\n"));
set_errno(0);
DEBUGF(SOCKETS_DEBUG, ("lwip_select: timeout expired\n"));
set_errno(0);
return 0;
}
@@ -778,8 +778,8 @@ lwip_select(int maxfdp1, fd_set *readset, fd_set *writeset, fd_set *exceptset,
*writeset = lwriteset;
if (exceptset)
*exceptset = lexceptset;
DEBUGF(SOCKETS_DEBUG, ("lwip_select: nready=%d\n", nready));
set_errno(0);
DEBUGF(SOCKETS_DEBUG, ("lwip_select: nready=%d\n", nready));
set_errno(0);
return nready;
}
@@ -877,7 +877,7 @@ event_callback(struct netconn *conn, enum netconn_evt evt, u16_t len)
int lwip_shutdown(int s, int how)
{
DEBUGF(SOCKETS_DEBUG, ("lwip_shutdown(%d, how=%d)\n", s, how));
DEBUGF(SOCKETS_DEBUG, ("lwip_shutdown(%d, how=%d)\n", s, how));
return lwip_close(s); /* XXX temporary hack until proper implementation */
}
@@ -953,98 +953,98 @@ int lwip_getsockname (int s, struct sockaddr *name, socklen_t *namelen)
int lwip_getsockopt (int s, int level, int optname, void *optval, socklen_t *optlen)
{
int err = ENOSYS;
struct lwip_socket *sock = get_socket(s);
int err = ENOSYS;
struct lwip_socket *sock = get_socket(s);
if (!sock) {
return -1;
}
if (!sock) {
return -1;
}
if (level == SOL_SOCKET) {
switch (optname) {
case SO_ERROR:
if (!optval || !optlen || (*optlen != sizeof(int))) {
err = EINVAL;
break;
}
*(int *)optval = sock->err;
sock->err = 0;
DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt(%d, SOL_SOCKET, SO_ERROR) = %d\n", s, *(int *)optval));
err = 0;
break;
default:
DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt(%d, SOL_SOCKET, UNIMPL: optname=0x%x, ..)\n", s, optname));
break;
}
} else {
DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt(%d, level=0x%x, UNIMPL: optname=0x%x, ..)\n", s, level, optname));
}
sock_set_errno(sock, err);
return err ? -1 : 0;
if (level == SOL_SOCKET) {
switch (optname) {
case SO_ERROR:
if (!optval || !optlen || (*optlen != sizeof(int))) {
err = EINVAL;
break;
}
*(int *)optval = sock->err;
sock->err = 0;
DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt(%d, SOL_SOCKET, SO_ERROR) = %d\n", s, *(int *)optval));
err = 0;
break;
default:
DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt(%d, SOL_SOCKET, UNIMPL: optname=0x%x, ..)\n", s, optname));
break;
}
} else {
DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt(%d, level=0x%x, UNIMPL: optname=0x%x, ..)\n", s, level, optname));
}
sock_set_errno(sock, err);
return err ? -1 : 0;
}
int lwip_setsockopt (int s, int level, int optname, const void *optval, socklen_t optlen)
{
struct lwip_socket *sock = get_socket(s);
int err = ENOSYS;
struct lwip_socket *sock = get_socket(s);
int err = ENOSYS;
if (!sock) {
return -1;
}
if (!sock) {
return -1;
}
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 */
err = 0;
break;
default:
DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%d, SOL_SOCKET, UNIMPL: optname=0x%x, ..)\n", s, optname));
break;
}
} else {
DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%d, level=0x%x, UNIMPL: optname=0x%x, ..)\n", s, level, 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 */
err = 0;
break;
default:
DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%d, SOL_SOCKET, UNIMPL: optname=0x%x, ..)\n", s, optname));
break;
}
} else {
DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%d, level=0x%x, UNIMPL: optname=0x%x, ..)\n", s, level, optname));
}
sock_set_errno(sock, err);
return err ? -1 : 0;
sock_set_errno(sock, err);
return err ? -1 : 0;
}
int lwip_ioctl(int s, long cmd, void *argp)
{
struct lwip_socket *sock = get_socket(s);
struct lwip_socket *sock = get_socket(s);
if (!sock) {
return -1;
}
if (!sock) {
return -1;
}
switch (cmd) {
case FIONREAD:
if (!argp) {
sock_set_errno(sock, EINVAL);
return -1;
}
switch (cmd) {
case FIONREAD:
if (!argp) {
sock_set_errno(sock, EINVAL);
return -1;
}
*((u16_t*)argp) = sock->conn->recv_avail;
*((u16_t*)argp) = sock->conn->recv_avail;
DEBUGF(SOCKETS_DEBUG, ("lwip_ioctl(%d, FIONREAD, %p) = %u\n", s, argp, *((u16_t*)argp)));
sock_set_errno(sock, 0);
return 0;
DEBUGF(SOCKETS_DEBUG, ("lwip_ioctl(%d, FIONREAD, %p) = %u\n", s, argp, *((u16_t*)argp)));
sock_set_errno(sock, 0);
return 0;
case FIONBIO:
if (argp && *(u32_t*)argp)
sock->flags |= O_NONBLOCK;
else
sock->flags &= ~O_NONBLOCK;
DEBUGF(SOCKETS_DEBUG, ("lwip_ioctl(%d, FIONBIO, %d)\n", s, !!(sock->flags & O_NONBLOCK)));
sock_set_errno(sock, 0);
return 0;
case FIONBIO:
if (argp && *(u32_t*)argp)
sock->flags |= O_NONBLOCK;
else
sock->flags &= ~O_NONBLOCK;
DEBUGF(SOCKETS_DEBUG, ("lwip_ioctl(%d, FIONBIO, %d)\n", s, !!(sock->flags & O_NONBLOCK)));
sock_set_errno(sock, 0);
return 0;
default:
DEBUGF(SOCKETS_DEBUG, ("lwip_ioctl(%d, UNIMPL: 0x%lx, %p)\n", s, cmd, argp));
sock_set_errno(sock, ENOSYS); /* not yet implemented */
return -1;
}
default:
DEBUGF(SOCKETS_DEBUG, ("lwip_ioctl(%d, UNIMPL: 0x%lx, %p)\n", s, cmd, argp));
sock_set_errno(sock, ENOSYS); /* not yet implemented */
return -1;
}
}

View File

@@ -58,9 +58,9 @@ tcpip_tcp_timer(void *arg)
tcp_tmr();
if (tcp_active_pcbs || tcp_tw_pcbs) {
sys_timeout(TCP_TMR_INTERVAL, tcpip_tcp_timer, NULL);
sys_timeout(TCP_TMR_INTERVAL, tcpip_tcp_timer, NULL);
} else {
tcpip_tcp_timer_active = 0;
tcpip_tcp_timer_active = 0;
}
}
@@ -68,8 +68,8 @@ void
tcp_timer_needed(void)
{
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);
tcpip_tcp_timer_active = 1;
sys_timeout(TCP_TMR_INTERVAL, tcpip_tcp_timer, NULL);
}
}
#endif /* LWIP_TCP */