Back to home page

Quest Cross Reference

 
 

    


Warning, cross-references for /kernel/include/lwip/tcpip.h need to be fixed.

0001 /*
0002  * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
0003  * All rights reserved. 
0004  * 
0005  * Redistribution and use in source and binary forms, with or without modification, 
0006  * are permitted provided that the following conditions are met:
0007  *
0008  * 1. Redistributions of source code must retain the above copyright notice,
0009  *    this list of conditions and the following disclaimer.
0010  * 2. Redistributions in binary form must reproduce the above copyright notice,
0011  *    this list of conditions and the following disclaimer in the documentation
0012  *    and/or other materials provided with the distribution.
0013  * 3. The name of the author may not be used to endorse or promote products
0014  *    derived from this software without specific prior written permission. 
0015  *
0016  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 
0017  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
0018  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 
0019  * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
0020  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 
0021  * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
0022  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
0023  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 
0024  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 
0025  * OF SUCH DAMAGE.
0026  *
0027  * This file is part of the lwIP TCP/IP stack.
0028  * 
0029  * Author: Adam Dunkels <adam@sics.se>
0030  *
0031  */
0032 #ifndef __LWIP_TCPIP_H__
0033 #define __LWIP_TCPIP_H__
0034 
0035 #include "lwip/opt.h"
0036 
0037 #if !NO_SYS /* don't build if not configured for use in lwipopts.h */
0038 
0039 #include "lwip/api_msg.h"
0040 #include "lwip/netifapi.h"
0041 #include "lwip/pbuf.h"
0042 #include "lwip/api.h"
0043 #include "lwip/sys.h"
0044 #include "lwip/netif.h"
0045 
0046 #ifdef __cplusplus
0047 extern "C" {
0048 #endif
0049 
0050 #if LWIP_TCPIP_CORE_LOCKING
0051 /** The global semaphore to lock the stack. */
0052 extern sys_sem_t lock_tcpip_core;
0053 #define LOCK_TCPIP_CORE()     sys_sem_wait(lock_tcpip_core)
0054 #define UNLOCK_TCPIP_CORE()   sys_sem_signal(lock_tcpip_core)
0055 #define TCPIP_APIMSG(m)       tcpip_apimsg_lock(m)
0056 #define TCPIP_APIMSG_ACK(m)
0057 #define TCPIP_NETIFAPI(m)     tcpip_netifapi_lock(m)
0058 #define TCPIP_NETIFAPI_ACK(m)
0059 #else
0060 #define LOCK_TCPIP_CORE()
0061 #define UNLOCK_TCPIP_CORE()
0062 #define TCPIP_APIMSG(m)       tcpip_apimsg(m)
0063 #define TCPIP_APIMSG_ACK(m)   sys_sem_signal(m->conn->op_completed)
0064 #define TCPIP_NETIFAPI(m)     tcpip_netifapi(m)
0065 #define TCPIP_NETIFAPI_ACK(m) sys_sem_signal(m->sem)
0066 #endif /* LWIP_TCPIP_CORE_LOCKING */
0067 
0068 void tcpip_init(void (* tcpip_init_done)(void *), void *arg);
0069 
0070 #if LWIP_NETCONN
0071 err_t tcpip_apimsg(struct api_msg *apimsg);
0072 #if LWIP_TCPIP_CORE_LOCKING
0073 err_t tcpip_apimsg_lock(struct api_msg *apimsg);
0074 #endif /* LWIP_TCPIP_CORE_LOCKING */
0075 #endif /* LWIP_NETCONN */
0076 
0077 err_t tcpip_input(struct pbuf *p, struct netif *inp);
0078 
0079 #if LWIP_NETIF_API
0080 err_t tcpip_netifapi(struct netifapi_msg *netifapimsg);
0081 #if LWIP_TCPIP_CORE_LOCKING
0082 err_t tcpip_netifapi_lock(struct netifapi_msg *netifapimsg);
0083 #endif /* LWIP_TCPIP_CORE_LOCKING */
0084 #endif /* LWIP_NETIF_API */
0085 
0086 err_t tcpip_callback_with_block(void (*f)(void *ctx), void *ctx, u8_t block);
0087 #define tcpip_callback(f, ctx)              tcpip_callback_with_block(f, ctx, 1)
0088 
0089 /* free pbufs or heap memory from another context without blocking */
0090 err_t pbuf_free_callback(struct pbuf *p);
0091 err_t mem_free_callback(void *m);
0092 
0093 err_t tcpip_timeout(u32_t msecs, sys_timeout_handler h, void *arg);
0094 err_t tcpip_untimeout(sys_timeout_handler h, void *arg);
0095 
0096 enum tcpip_msg_type {
0097 #if LWIP_NETCONN
0098   TCPIP_MSG_API,
0099 #endif /* LWIP_NETCONN */
0100   TCPIP_MSG_INPKT,
0101 #if LWIP_NETIF_API
0102   TCPIP_MSG_NETIFAPI,
0103 #endif /* LWIP_NETIF_API */
0104   TCPIP_MSG_CALLBACK,
0105   TCPIP_MSG_TIMEOUT,
0106   TCPIP_MSG_UNTIMEOUT
0107 };
0108 
0109 struct tcpip_msg {
0110   enum tcpip_msg_type type;
0111   sys_sem_t *sem;
0112   union {
0113 #if LWIP_NETCONN
0114     struct api_msg *apimsg;
0115 #endif /* LWIP_NETCONN */
0116 #if LWIP_NETIF_API
0117     struct netifapi_msg *netifapimsg;
0118 #endif /* LWIP_NETIF_API */
0119     struct {
0120       struct pbuf *p;
0121       struct netif *netif;
0122     } inp;
0123     struct {
0124       void (*f)(void *ctx);
0125       void *ctx;
0126     } cb;
0127     struct {
0128       u32_t msecs;
0129       sys_timeout_handler h;
0130       void *arg;
0131     } tmo;
0132   } msg;
0133 };
0134 
0135 #ifdef __cplusplus
0136 }
0137 #endif
0138 
0139 #endif /* !NO_SYS */
0140 
0141 #endif /* __LWIP_TCPIP_H__ */