Committer:
mbed714
Date:
Sat Sep 18 23:05:49 2010 +0000
Revision:
0:d616ece2d859

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbed714 0:d616ece2d859 1 /*
mbed714 0:d616ece2d859 2 * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
mbed714 0:d616ece2d859 3 * All rights reserved.
mbed714 0:d616ece2d859 4 *
mbed714 0:d616ece2d859 5 * Redistribution and use in source and binary forms, with or without modification,
mbed714 0:d616ece2d859 6 * are permitted provided that the following conditions are met:
mbed714 0:d616ece2d859 7 *
mbed714 0:d616ece2d859 8 * 1. Redistributions of source code must retain the above copyright notice,
mbed714 0:d616ece2d859 9 * this list of conditions and the following disclaimer.
mbed714 0:d616ece2d859 10 * 2. Redistributions in binary form must reproduce the above copyright notice,
mbed714 0:d616ece2d859 11 * this list of conditions and the following disclaimer in the documentation
mbed714 0:d616ece2d859 12 * and/or other materials provided with the distribution.
mbed714 0:d616ece2d859 13 * 3. The name of the author may not be used to endorse or promote products
mbed714 0:d616ece2d859 14 * derived from this software without specific prior written permission.
mbed714 0:d616ece2d859 15 *
mbed714 0:d616ece2d859 16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
mbed714 0:d616ece2d859 17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
mbed714 0:d616ece2d859 18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
mbed714 0:d616ece2d859 19 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
mbed714 0:d616ece2d859 20 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
mbed714 0:d616ece2d859 21 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
mbed714 0:d616ece2d859 22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
mbed714 0:d616ece2d859 23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
mbed714 0:d616ece2d859 24 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
mbed714 0:d616ece2d859 25 * OF SUCH DAMAGE.
mbed714 0:d616ece2d859 26 *
mbed714 0:d616ece2d859 27 * This file is part of the lwIP TCP/IP stack.
mbed714 0:d616ece2d859 28 *
mbed714 0:d616ece2d859 29 * Author: Adam Dunkels <adam@sics.se>
mbed714 0:d616ece2d859 30 *
mbed714 0:d616ece2d859 31 */
mbed714 0:d616ece2d859 32 #ifndef __LWIP_TCPIP_H__
mbed714 0:d616ece2d859 33 #define __LWIP_TCPIP_H__
mbed714 0:d616ece2d859 34
mbed714 0:d616ece2d859 35 #include "lwip/opt.h"
mbed714 0:d616ece2d859 36
mbed714 0:d616ece2d859 37 #if !NO_SYS /* don't build if not configured for use in lwipopts.h */
mbed714 0:d616ece2d859 38
mbed714 0:d616ece2d859 39 #include "lwip/api_msg.h"
mbed714 0:d616ece2d859 40 #include "lwip/netifapi.h"
mbed714 0:d616ece2d859 41 #include "lwip/pbuf.h"
mbed714 0:d616ece2d859 42 #include "lwip/api.h"
mbed714 0:d616ece2d859 43 #include "lwip/sys.h"
mbed714 0:d616ece2d859 44 #include "lwip/timers.h"
mbed714 0:d616ece2d859 45 #include "lwip/netif.h"
mbed714 0:d616ece2d859 46
mbed714 0:d616ece2d859 47 #ifdef __cplusplus
mbed714 0:d616ece2d859 48 extern "C" {
mbed714 0:d616ece2d859 49 #endif
mbed714 0:d616ece2d859 50
mbed714 0:d616ece2d859 51 /** Define this to something that triggers a watchdog. This is called from
mbed714 0:d616ece2d859 52 * tcpip_thread after processing a message. */
mbed714 0:d616ece2d859 53 #ifndef LWIP_TCPIP_THREAD_ALIVE
mbed714 0:d616ece2d859 54 #define LWIP_TCPIP_THREAD_ALIVE()
mbed714 0:d616ece2d859 55 #endif
mbed714 0:d616ece2d859 56
mbed714 0:d616ece2d859 57 #if LWIP_TCPIP_CORE_LOCKING
mbed714 0:d616ece2d859 58 /** The global semaphore to lock the stack. */
mbed714 0:d616ece2d859 59 extern sys_mutex_t lock_tcpip_core;
mbed714 0:d616ece2d859 60 #define LOCK_TCPIP_CORE() sys_mutex_lock(&lock_tcpip_core)
mbed714 0:d616ece2d859 61 #define UNLOCK_TCPIP_CORE() sys_mutex_unlock(&lock_tcpip_core)
mbed714 0:d616ece2d859 62 #define TCPIP_APIMSG(m) tcpip_apimsg_lock(m)
mbed714 0:d616ece2d859 63 #define TCPIP_APIMSG_ACK(m)
mbed714 0:d616ece2d859 64 #define TCPIP_NETIFAPI(m) tcpip_netifapi_lock(m)
mbed714 0:d616ece2d859 65 #define TCPIP_NETIFAPI_ACK(m)
mbed714 0:d616ece2d859 66 #else /* LWIP_TCPIP_CORE_LOCKING */
mbed714 0:d616ece2d859 67 #define LOCK_TCPIP_CORE()
mbed714 0:d616ece2d859 68 #define UNLOCK_TCPIP_CORE()
mbed714 0:d616ece2d859 69 #define TCPIP_APIMSG(m) tcpip_apimsg(m)
mbed714 0:d616ece2d859 70 #define TCPIP_APIMSG_ACK(m) sys_sem_signal(&m->conn->op_completed)
mbed714 0:d616ece2d859 71 #define TCPIP_NETIFAPI(m) tcpip_netifapi(m)
mbed714 0:d616ece2d859 72 #define TCPIP_NETIFAPI_ACK(m) sys_sem_signal(&m->sem)
mbed714 0:d616ece2d859 73 #endif /* LWIP_TCPIP_CORE_LOCKING */
mbed714 0:d616ece2d859 74
mbed714 0:d616ece2d859 75 /** Function prototype for the init_done function passed to tcpip_init */
mbed714 0:d616ece2d859 76 typedef void (*tcpip_init_done_fn)(void *arg);
mbed714 0:d616ece2d859 77 /** Function prototype for functions passed to tcpip_callback() */
mbed714 0:d616ece2d859 78 typedef void (*tcpip_callback_fn)(void *ctx);
mbed714 0:d616ece2d859 79
mbed714 0:d616ece2d859 80 void tcpip_init(tcpip_init_done_fn tcpip_init_done, void *arg);
mbed714 0:d616ece2d859 81
mbed714 0:d616ece2d859 82 #if LWIP_NETCONN
mbed714 0:d616ece2d859 83 err_t tcpip_apimsg(struct api_msg *apimsg);
mbed714 0:d616ece2d859 84 #if LWIP_TCPIP_CORE_LOCKING
mbed714 0:d616ece2d859 85 err_t tcpip_apimsg_lock(struct api_msg *apimsg);
mbed714 0:d616ece2d859 86 #endif /* LWIP_TCPIP_CORE_LOCKING */
mbed714 0:d616ece2d859 87 #endif /* LWIP_NETCONN */
mbed714 0:d616ece2d859 88
mbed714 0:d616ece2d859 89 err_t tcpip_input(struct pbuf *p, struct netif *inp);
mbed714 0:d616ece2d859 90
mbed714 0:d616ece2d859 91 #if LWIP_NETIF_API
mbed714 0:d616ece2d859 92 err_t tcpip_netifapi(struct netifapi_msg *netifapimsg);
mbed714 0:d616ece2d859 93 #if LWIP_TCPIP_CORE_LOCKING
mbed714 0:d616ece2d859 94 err_t tcpip_netifapi_lock(struct netifapi_msg *netifapimsg);
mbed714 0:d616ece2d859 95 #endif /* LWIP_TCPIP_CORE_LOCKING */
mbed714 0:d616ece2d859 96 #endif /* LWIP_NETIF_API */
mbed714 0:d616ece2d859 97
mbed714 0:d616ece2d859 98 err_t tcpip_callback_with_block(tcpip_callback_fn function, void *ctx, u8_t block);
mbed714 0:d616ece2d859 99 #define tcpip_callback(f, ctx) tcpip_callback_with_block(f, ctx, 1)
mbed714 0:d616ece2d859 100
mbed714 0:d616ece2d859 101 /* free pbufs or heap memory from another context without blocking */
mbed714 0:d616ece2d859 102 err_t pbuf_free_callback(struct pbuf *p);
mbed714 0:d616ece2d859 103 err_t mem_free_callback(void *m);
mbed714 0:d616ece2d859 104
mbed714 0:d616ece2d859 105 #if LWIP_TCPIP_TIMEOUT
mbed714 0:d616ece2d859 106 err_t tcpip_timeout(u32_t msecs, sys_timeout_handler h, void *arg);
mbed714 0:d616ece2d859 107 err_t tcpip_untimeout(sys_timeout_handler h, void *arg);
mbed714 0:d616ece2d859 108 #endif /* LWIP_TCPIP_TIMEOUT */
mbed714 0:d616ece2d859 109
mbed714 0:d616ece2d859 110 enum tcpip_msg_type {
mbed714 0:d616ece2d859 111 #if LWIP_NETCONN
mbed714 0:d616ece2d859 112 TCPIP_MSG_API,
mbed714 0:d616ece2d859 113 #endif /* LWIP_NETCONN */
mbed714 0:d616ece2d859 114 TCPIP_MSG_INPKT,
mbed714 0:d616ece2d859 115 #if LWIP_NETIF_API
mbed714 0:d616ece2d859 116 TCPIP_MSG_NETIFAPI,
mbed714 0:d616ece2d859 117 #endif /* LWIP_NETIF_API */
mbed714 0:d616ece2d859 118 #if LWIP_TCPIP_TIMEOUT
mbed714 0:d616ece2d859 119 TCPIP_MSG_TIMEOUT,
mbed714 0:d616ece2d859 120 TCPIP_MSG_UNTIMEOUT,
mbed714 0:d616ece2d859 121 #endif /* LWIP_TCPIP_TIMEOUT */
mbed714 0:d616ece2d859 122 TCPIP_MSG_CALLBACK
mbed714 0:d616ece2d859 123 };
mbed714 0:d616ece2d859 124
mbed714 0:d616ece2d859 125 struct tcpip_msg {
mbed714 0:d616ece2d859 126 enum tcpip_msg_type type;
mbed714 0:d616ece2d859 127 sys_sem_t *sem;
mbed714 0:d616ece2d859 128 union {
mbed714 0:d616ece2d859 129 #if LWIP_NETCONN
mbed714 0:d616ece2d859 130 struct api_msg *apimsg;
mbed714 0:d616ece2d859 131 #endif /* LWIP_NETCONN */
mbed714 0:d616ece2d859 132 #if LWIP_NETIF_API
mbed714 0:d616ece2d859 133 struct netifapi_msg *netifapimsg;
mbed714 0:d616ece2d859 134 #endif /* LWIP_NETIF_API */
mbed714 0:d616ece2d859 135 struct {
mbed714 0:d616ece2d859 136 struct pbuf *p;
mbed714 0:d616ece2d859 137 struct netif *netif;
mbed714 0:d616ece2d859 138 } inp;
mbed714 0:d616ece2d859 139 struct {
mbed714 0:d616ece2d859 140 tcpip_callback_fn function;
mbed714 0:d616ece2d859 141 void *ctx;
mbed714 0:d616ece2d859 142 } cb;
mbed714 0:d616ece2d859 143 #if LWIP_TCPIP_TIMEOUT
mbed714 0:d616ece2d859 144 struct {
mbed714 0:d616ece2d859 145 u32_t msecs;
mbed714 0:d616ece2d859 146 sys_timeout_handler h;
mbed714 0:d616ece2d859 147 void *arg;
mbed714 0:d616ece2d859 148 } tmo;
mbed714 0:d616ece2d859 149 #endif /* LWIP_TCPIP_TIMEOUT */
mbed714 0:d616ece2d859 150 } msg;
mbed714 0:d616ece2d859 151 };
mbed714 0:d616ece2d859 152
mbed714 0:d616ece2d859 153 #ifdef __cplusplus
mbed714 0:d616ece2d859 154 }
mbed714 0:d616ece2d859 155 #endif
mbed714 0:d616ece2d859 156
mbed714 0:d616ece2d859 157 #endif /* !NO_SYS */
mbed714 0:d616ece2d859 158
mbed714 0:d616ece2d859 159 #endif /* __LWIP_TCPIP_H__ */