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