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