Dependents:   RTnoV3 RTnoV3_LED RTnoV3_Template RTnoV3_ADC ... more

Committer:
sherckuith
Date:
Sat Dec 31 11:25:27 2011 +0000
Revision:
0:479ce5546098
Ethernet

Who changed what in which revision?

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