Dependencies:   mbed

Committer:
robertcook
Date:
Wed Jun 13 18:39:46 2012 +0000
Revision:
0:32a0996dff0f

        

Who changed what in which revision?

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