# sockets.h

Go to the documentation of this file.

    00001 /*
    00002  * Copyright (c) 2001, Swedish Institute of Computer Science.
    00003  * All rights reserved.
    00004  *
    00005  * Redistribution and use in source and binary forms, with or without
    00006  * modification, are permitted provided that the following conditions
    00007  * are met:
    00008  * 1. Redistributions of source code must retain the above copyright
    00009  *    notice, this list of conditions and the following disclaimer.
    00010  * 2. Redistributions in binary form must reproduce the above copyright
    00011  *    notice, this list of conditions and the following disclaimer in the
    00012  *    documentation and/or other materials provided with the distribution.
    00013  * 3. Neither the name of the Institute nor the names of its contributors
    00014  *    may be used to endorse or promote products derived from this software
    00015  *    without specific prior written permission.
    00016  *
    00017  * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
    00018  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
    00019  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
    00020  * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
    00021  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
    00022  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
    00023  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
    00024  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
    00025  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
    00026  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
    00027  * SUCH DAMAGE.
    00028  *
    00029  * This file is part of the lwIP TCP/IP stack.
    00030  *
    00031  * Author: Adam Dunkels <adam@sics.se>
    00032  *
    00033  * $Id: sockets_8h-source.html 88 2016-01-12 00:11:29Z reddawg $
    00034  */
    00035
    00036
    00037 #ifndef __LWIP_SOCKETS_H__
    00038 #define __LWIP_SOCKETS_H__
    00039
    00040 #include <ubixos/types.h>
    00041
    00042 struct in_addr {
    00043   uInt32 s_addr;
    00044 };
    00045
    00046
    00047 struct sockaddr_in {
    00048   uInt8 sin_len;
    00049   uInt8 sin_family;
    00050   uInt16 sin_port;
    00051   struct in_addr sin_addr;
    00052   char sin_zero[8];
    00053 };
    00054
    00055 struct sockaddr {
    00056   uInt8 sa_len;
    00057   uInt8 sa_family;
    00058   char sa_data[14];
    00059 };
    00060
    00061 #define SOCK_STREAM     1
    00062 #define SOCK_DGRAM      2
    00063
    00064 #define AF_INET         2
    00065 #define PF_INET         AF_INET
    00066
    00067 #define IPPROTO_TCP     6
    00068 #define IPPROTO_UDP     17
    00069
    00070 #define INADDR_ANY      0
    00071 #define INADDR_BROADCAST 0xffffffff
    00072
    00073 int lwip_accept(int s, struct sockaddr *addr, int *addrlen);
    00074 int lwip_bind(int s, struct sockaddr *name, int namelen);
    00075 int lwip_close(int s);
    00076 int lwip_connect(int s, struct sockaddr *name, int namelen);
    00077 int lwip_listen(int s, int backlog);
    00078 int lwip_recv(int s, void *mem, int len, unsigned int flags);
    00079 int lwip_read(int s, void *mem, int len);
    00080 int lwip_recvfrom(int s, void *mem, int len, unsigned int flags,
    00081                   struct sockaddr *from, int *fromlen);
    00082 int lwip_send(int s, void *dataptr, int size, unsigned int flags);
    00083 int lwip_sendto(int s, void *dataptr, int size, unsigned int flags,
    00084                 struct sockaddr *to, int tolen);
    00085 int lwip_socket(int domain, int type, int protocol);
    00086 int lwip_write(int s, void *dataptr, int size);
    00087
    00088 #ifdef LWIP_COMPAT_SOCKETS
    00089 #define accept(a,b,c)         lwip_accept(a,b,c)
    00090 #define bind(a,b,c)           lwip_bind(a,b,c)
    00091 #define close(s)              lwip_close(s)
    00092 #define connect(a,b,c)        lwip_connect(a,b,c)
    00093 #define listen(a,b)           lwip_listen(a,b)
    00094 #define recv(a,b,c,d)         lwip_recv(a,b,c,d)
    00095 #define read(a,b,c)           lwip_read(a,b,c)
    00096 #define recvfrom(a,b,c,d,e,f) lwip_recvfrom(a,b,c,d,e,f)
    00097 #define send(a,b,c,d)         lwip_send(a,b,c,d)
    00098 #define sendto(a,b,c,d,e,f)   lwip_sendto(a,b,c,d,e,f)
    00099 #define socket(a,b,c)         lwip_socket(a,b,c)
    00100 #define write(a,b,c)          lwip_write(a,b,c)
    00101 #endif /* LWIP_NO_COMPAT_SOCKETS */
    00102
    00103 #endif /* __LWIP_SOCKETS_H__ */
    00104