#define NUM_SOCKETS MEMP_NUM_NETCONN
/** Contains all internal pointers and states used for a socket */
-struct lwip_socket {
+struct lwip_sock {
/** sockets currently are built on netconns, each socket has one netconn */
struct netconn *conn;
/** data that was left from the previous read */
* functions running in tcpip_thread context (only a void* is allowed) */
struct lwip_setgetsockopt_data {
/** socket struct for which to change options */
- struct lwip_socket *sock;
+ struct lwip_sock *sock;
/** socket index for which to change options */
int s;
/** level of the option to process */
};
/** The global array of available sockets */
-static struct lwip_socket sockets[NUM_SOCKETS];
+static struct lwip_sock sockets[NUM_SOCKETS];
/** The global list of tasks waiting for select */
static struct lwip_select_cb *select_cb_list;
* Map a externally used socket index to the internal socket representation.
*
* @param s externally used socket index
- * @return struct lwip_socket for the socket or NULL if not found
+ * @return struct lwip_sock for the socket or NULL if not found
*/
-static struct lwip_socket *
+static struct lwip_sock *
get_socket(int s)
{
- struct lwip_socket *sock;
+ struct lwip_sock *sock;
if ((s < 0) || (s >= NUM_SOCKETS)) {
LWIP_DEBUGF(SOCKETS_DEBUG, ("get_socket(%d): invalid\n", s));
* @param sock the socket to free
*/
static void
-free_socket(struct lwip_socket *sock)
+free_socket(struct lwip_sock *sock)
{
struct netbuf *lastdata;
SYS_ARCH_DECL_PROTECT(lev);
int
lwip_accept(int s, struct sockaddr *addr, socklen_t *addrlen)
{
- struct lwip_socket *sock, *nsock;
+ struct lwip_sock *sock, *nsock;
struct netconn *newconn;
ip_addr_t naddr;
u16_t port;
int
lwip_bind(int s, const struct sockaddr *name, socklen_t namelen)
{
- struct lwip_socket *sock;
+ struct lwip_sock *sock;
ip_addr_t local_addr;
u16_t local_port;
err_t err;
int
lwip_close(int s)
{
- struct lwip_socket *sock;
+ struct lwip_sock *sock;
LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_close(%d)\n", s));
int
lwip_connect(int s, const struct sockaddr *name, socklen_t namelen)
{
- struct lwip_socket *sock;
+ struct lwip_sock *sock;
err_t err;
sock = get_socket(s);
int
lwip_listen(int s, int backlog)
{
- struct lwip_socket *sock;
+ struct lwip_sock *sock;
err_t err;
LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_listen(%d, backlog=%d)\n", s, backlog));
lwip_recvfrom(int s, void *mem, size_t len, int flags,
struct sockaddr *from, socklen_t *fromlen)
{
- struct lwip_socket *sock;
+ struct lwip_sock *sock;
struct netbuf *buf;
u16_t buflen, copylen;
int off = 0;
int
lwip_send(int s, const void *data, size_t size, int flags)
{
- struct lwip_socket *sock;
+ struct lwip_sock *sock;
err_t err;
u8_t write_flags;
lwip_sendto(int s, const void *data, size_t size, int flags,
const struct sockaddr *to, socklen_t tolen)
{
- struct lwip_socket *sock;
+ struct lwip_sock *sock;
ip_addr_t remote_addr;
err_t err;
u16_t short_size;
{
int i, nready = 0;
fd_set lreadset, lwriteset, lexceptset;
- struct lwip_socket *p_sock;
+ struct lwip_sock *p_sock;
FD_ZERO(&lreadset);
FD_ZERO(&lwriteset);
event_callback(struct netconn *conn, enum netconn_evt evt, u16_t len)
{
int s;
- struct lwip_socket *sock;
+ struct lwip_sock *sock;
struct lwip_select_cb *scb;
LWIP_UNUSED_ARG(len);
static int
lwip_getaddrname(int s, struct sockaddr *name, socklen_t *namelen, u8_t local)
{
- struct lwip_socket *sock;
+ struct lwip_sock *sock;
struct sockaddr_in sin;
ip_addr_t naddr;
lwip_getsockopt(int s, int level, int optname, void *optval, socklen_t *optlen)
{
err_t err = ERR_OK;
- struct lwip_socket *sock = get_socket(s);
+ struct lwip_sock *sock = get_socket(s);
struct lwip_setgetsockopt_data data;
if (!sock)
static void
lwip_getsockopt_internal(void *arg)
{
- struct lwip_socket *sock;
+ struct lwip_sock *sock;
#ifdef LWIP_DEBUG
int s;
#endif /* LWIP_DEBUG */
int
lwip_setsockopt(int s, int level, int optname, const void *optval, socklen_t optlen)
{
- struct lwip_socket *sock = get_socket(s);
+ struct lwip_sock *sock = get_socket(s);
err_t err = ERR_OK;
struct lwip_setgetsockopt_data data;
static void
lwip_setsockopt_internal(void *arg)
{
- struct lwip_socket *sock;
+ struct lwip_sock *sock;
#ifdef LWIP_DEBUG
int s;
#endif /* LWIP_DEBUG */
int
lwip_ioctl(int s, long cmd, void *argp)
{
- struct lwip_socket *sock = get_socket(s);
+ struct lwip_sock *sock = get_socket(s);
u16_t buflen = 0;
s16_t recv_avail;
u8_t val;
int
lwip_fcntl(int s, int cmd, int val)
{
- struct lwip_socket *sock = get_socket(s);
+ struct lwip_sock *sock = get_socket(s);
int ret = -1;
if (!sock || !sock->conn) {