A version of LWIP, provided for backwards compatibility.

Dependents:   AA_DemoBoard DemoBoard HelloServerDemo DemoBoard_RangeIndicator ... more

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers tcpip.h Source File

tcpip.h

00001 /*
00002  * Copyright (c) 2001-2004 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  */
00032 #ifndef __LWIP_TCPIP_H__
00033 #define __LWIP_TCPIP_H__
00034 
00035 #include "lwip/opt.h"
00036 
00037 #if !NO_SYS /* don't build if not configured for use in lwipopts.h */
00038 
00039 #include "lwip/api_msg.h"
00040 #include "lwip/netifapi.h"
00041 #include "lwip/pbuf.h"
00042 #include "lwip/api.h"
00043 #include "lwip/sys.h"
00044 
00045 #ifdef __cplusplus
00046 extern "C" {
00047 #endif
00048 
00049 #if LWIP_TCPIP_CORE_LOCKING
00050 /** The global semaphore to lock the stack. */
00051 extern sys_sem_t lock_tcpip_core;
00052 #define LOCK_TCPIP_CORE()     sys_sem_wait(lock_tcpip_core)
00053 #define UNLOCK_TCPIP_CORE()   sys_sem_signal(lock_tcpip_core)
00054 #define TCPIP_APIMSG(m)       tcpip_apimsg_lock(m)
00055 #define TCPIP_APIMSG_ACK(m)
00056 #define TCPIP_NETIFAPI(m)     tcpip_netifapi_lock(m)
00057 #define TCPIP_NETIFAPI_ACK(m)
00058 #else
00059 #define LOCK_TCPIP_CORE()
00060 #define UNLOCK_TCPIP_CORE()
00061 #define TCPIP_APIMSG(m)       tcpip_apimsg(m)
00062 #define TCPIP_APIMSG_ACK(m)   sys_sem_signal(m->conn->op_completed)
00063 #define TCPIP_NETIFAPI(m)     tcpip_netifapi(m)
00064 #define TCPIP_NETIFAPI_ACK(m) sys_sem_signal(m->sem)
00065 #endif /* LWIP_TCPIP_CORE_LOCKING */
00066 
00067 void tcpip_init(void (* tcpip_init_done)(void *), void *arg);
00068 
00069 #if LWIP_NETCONN
00070 err_t tcpip_apimsg(struct api_msg *apimsg);
00071 #if LWIP_TCPIP_CORE_LOCKING
00072 err_t tcpip_apimsg_lock(struct api_msg *apimsg);
00073 #endif /* LWIP_TCPIP_CORE_LOCKING */
00074 #endif /* LWIP_NETCONN */
00075 
00076 err_t tcpip_input(struct pbuf *p, struct netif *inp);
00077 
00078 #if LWIP_NETIF_API
00079 err_t tcpip_netifapi(struct netifapi_msg *netifapimsg);
00080 #if LWIP_TCPIP_CORE_LOCKING
00081 err_t tcpip_netifapi_lock(struct netifapi_msg *netifapimsg);
00082 #endif /* LWIP_TCPIP_CORE_LOCKING */
00083 #endif /* LWIP_NETIF_API */
00084 
00085 err_t tcpip_callback_with_block(void (*f)(void *ctx), void *ctx, u8_t block);
00086 #define tcpip_callback(f, ctx)              tcpip_callback_with_block(f, ctx, 1)
00087 
00088 /* free pbufs or heap memory from another context without blocking */
00089 err_t pbuf_free_callback(struct pbuf *p);
00090 err_t mem_free_callback(void *m);
00091 
00092 err_t tcpip_timeout(u32_t msecs, sys_timeout_handler h, void *arg);
00093 err_t tcpip_untimeout(u32_t msecs, sys_timeout_handler h, void *arg);
00094 
00095 enum tcpip_msg_type {
00096 #if LWIP_NETCONN
00097   TCPIP_MSG_API,
00098 #endif /* LWIP_NETCONN */
00099   TCPIP_MSG_INPKT,
00100 #if LWIP_NETIF_API
00101   TCPIP_MSG_NETIFAPI,
00102 #endif /* LWIP_NETIF_API */
00103   TCPIP_MSG_CALLBACK,
00104   TCPIP_MSG_TIMEOUT,
00105   TCPIP_MSG_UNTIMEOUT
00106 };
00107 
00108 struct tcpip_msg {
00109   enum tcpip_msg_type type;
00110   sys_sem_t *sem;
00111   union {
00112 #if LWIP_NETCONN
00113     struct api_msg *apimsg;
00114 #endif /* LWIP_NETCONN */
00115 #if LWIP_NETIF_API
00116     struct netifapi_msg *netifapimsg;
00117 #endif /* LWIP_NETIF_API */
00118     struct {
00119       struct pbuf *p;
00120       struct netif *netif;
00121     } inp;
00122     struct {
00123       void (*f)(void *ctx);
00124       void *ctx;
00125     } cb;
00126     struct {
00127       u32_t msecs;
00128       sys_timeout_handler h;
00129       void *arg;
00130     } tmo;
00131   } msg;
00132 };
00133 
00134 #ifdef __cplusplus
00135 }
00136 #endif
00137 
00138 #endif /* !NO_SYS */
00139 
00140 #endif /* __LWIP_TCPIP_H__ */