Main Page | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages

api.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2001-2003 Swedish Institute of Computer Science.
00003  * All rights reserved. 
00004  * 
00005  * Redistribution and use in source and binary forms, with or without modification, 
00006  * are permitted provided that the following conditions are met:
00007  *
00008  * 1. Redistributions of source code must retain the above copyright notice,
00009  *    this list of conditions and the following disclaimer.
00010  * 2. Redistributions in binary form must reproduce the above copyright notice,
00011  *    this list of conditions and the following disclaimer in the documentation
00012  *    and/or other materials provided with the distribution.
00013  * 3. The name of the author may not be used to endorse or promote products
00014  *    derived from this software without specific prior written permission. 
00015  *
00016  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 
00017  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
00018  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 
00019  * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
00020  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 
00021  * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
00022  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
00023  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 
00024  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 
00025  * OF SUCH DAMAGE.
00026  *
00027  * This file is part of the lwIP TCP/IP stack.
00028  * 
00029  * Author: Adam Dunkels <adam@sics.se>
00030  *
00031  * CHANGELOG: this file has been modified by Sergio Perez Alcañiz <serpeal@disca.upv.es> 
00032  *            Departamento de Informática de Sistemas y Computadores          
00033  *            Universidad Politécnica de Valencia                             
00034  *            Valencia (Spain)    
00035  *            Date: April 2003                                          
00036  *
00037  */
00038 
00039 #ifndef __LWIP_API_H__
00040 #define __LWIP_API_H__
00041 
00042 #include "lwip/opt.h"
00043 #include "lwip/pbuf.h"
00044 #include "lwip/sys.h"
00045 
00046 #include "lwip/ip.h"
00047 
00048 #include "lwip/udp.h"
00049 #include "lwip/tcp.h"
00050 
00051 #include "lwip/err.h"
00052 
00053 #define NETCONN_NOCOPY 0x00
00054 #define NETCONN_COPY   0x01
00055 
00056 enum netconn_type {
00057   NETCONN_TCP,
00058   NETCONN_UDP,
00059   NETCONN_UDPLITE,
00060   NETCONN_UDPNOCHKSUM
00061 };
00062 
00063 enum netconn_state {
00064   NETCONN_NONE,
00065   NETCONN_WRITE,
00066   NETCONN_ACCEPT,
00067   NETCONN_RECV,
00068   NETCONN_CONNECT,
00069   NETCONN_CLOSE
00070 };
00071 
00072 enum netconn_evt {
00073   NETCONN_EVT_RCVPLUS,
00074   NETCONN_EVT_RCVMINUS,
00075   NETCONN_EVT_SENDPLUS,
00076   NETCONN_EVT_SENDMINUS
00077 };
00078 
00079 struct netbuf {
00080   struct pbuf *p, *ptr;
00081   struct ip_addr *fromaddr;
00082   u16_t fromport;
00083   err_t err;
00084 };
00085 
00086 struct netconn {
00087   enum netconn_type type;
00088   enum netconn_state state;
00089   union {
00090     struct tcp_pcb *tcp;
00091     struct udp_pcb *udp;
00092   } pcb;
00093   err_t err;
00094   sys_mbox_t mbox;
00095   sys_mbox_t recvmbox;
00096   sys_mbox_t acceptmbox;
00097   sys_sem_t sem;
00098   int socket;
00099   u16_t recv_avail;
00100   void (* callback)(struct netconn *, enum netconn_evt, u16_t len);
00101 };
00102 
00103 /* Network buffer functions: */
00104 struct netbuf *   netbuf_new      (void);
00105 void              netbuf_delete   (struct netbuf *buf);
00106 void *            netbuf_alloc    (struct netbuf *buf, u16_t size);
00107 void              netbuf_free     (struct netbuf *buf);
00108 void              netbuf_ref      (struct netbuf *buf,
00109                                    void *dataptr, u16_t size);
00110 void              netbuf_chain    (struct netbuf *head,
00111                                    struct netbuf *tail);
00112 
00113 u16_t             netbuf_len      (struct netbuf *buf);
00114 err_t             netbuf_data     (struct netbuf *buf,
00115                                    void **dataptr, u16_t *len);
00116 s8_t              netbuf_next     (struct netbuf *buf);
00117 void              netbuf_first    (struct netbuf *buf);
00118 
00119 void              netbuf_copy     (struct netbuf *buf,
00120                                    void *dataptr, u16_t len);
00121 void              netbuf_copy_partial(struct netbuf *buf, void *dataptr, 
00122                                       u16_t len, u16_t offset);
00123 struct ip_addr *  netbuf_fromaddr (struct netbuf *buf);
00124 u16_t             netbuf_fromport (struct netbuf *buf);
00125 
00126 /* Network connection functions: */
00127 struct netconn *  netconn_new     (enum netconn_type type);
00128 struct
00129 netconn *netconn_new_with_callback(enum netconn_type t,
00130                                    void (*callback)(struct netconn *, enum netconn_evt, u16_t len));
00131 err_t             netconn_delete  (struct netconn *conn);
00132 enum netconn_type netconn_type    (struct netconn *conn);
00133 err_t             netconn_peer    (struct netconn *conn,
00134                                    struct ip_addr *addr,
00135                                    u16_t *port);
00136 err_t             netconn_addr    (struct netconn *conn,
00137                                    struct ip_addr **addr,
00138                                    u16_t *port);
00139 err_t             netconn_bind    (struct netconn *conn,
00140                                    struct ip_addr *addr,
00141                                    u16_t port);
00142 err_t             netconn_connect (struct netconn *conn,
00143                                    struct ip_addr *addr,
00144                                    u16_t port);
00145 err_t             netconn_disconnect (struct netconn *conn);
00146 err_t             netconn_listen  (struct netconn *conn);
00147 struct netconn *  netconn_accept  (struct netconn *conn);
00148 struct netbuf *   netconn_recv    (struct netconn *conn);
00149 err_t             netconn_send    (struct netconn *conn,
00150                                    struct netbuf *buf);
00151 err_t             netconn_write   (struct netconn *conn,
00152                                    void *dataptr, u16_t size,
00153                                    u8_t copy);
00154 err_t             netconn_close   (struct netconn *conn);
00155 
00156 err_t             netconn_err     (struct netconn *conn);
00157 
00158 #endif /* __LWIP_API_H__ */
00159 
00160 

Generated on Wed Jan 14 12:58:55 2004 for RTL-lwIP-0.4 by doxygen 1.3.4