testing of combination of LCS and LAN

Dependencies:   mbed

Committer:
damir
Date:
Wed Jan 14 13:29:55 2015 +0000
Revision:
0:a7a6a692162f
Test of LAN

Who changed what in which revision?

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