Version of http://mbed.org/cookbook/NetServicesTribute with setting set the same for LPC2368

Dependents:   UDPSocketExample 24LCxx_I2CApp WeatherPlatform_pachube HvZServerLib ... more

Committer:
simon
Date:
Tue Nov 23 14:15:36 2010 +0000
Revision:
0:350011bf8be7
Experimental version for testing UDP

Who changed what in which revision?

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