This library is deprecated.

Dependents:   HTTPClientStreamingExample HTTPClientExample HTTPServerExample HTTPServerHelloWorld ... more

Committer:
donatien
Date:
Thu Aug 05 15:09:22 2010 +0000
Revision:
5:bc7df6da7589
Parent:
0:422060928e37

        

Who changed what in which revision?

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