Some quick code to use UDP-only (no TCP) with mBed. Echos received packets and sends packets when a button is pressed
Core/lwIP/include/lwip/netifapi.h@0:a548a085de55, 2010-03-14 (annotated)
- Committer:
- pehrhovey
- Date:
- Sun Mar 14 00:54:12 2010 +0000
- Revision:
- 0:a548a085de55
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
pehrhovey | 0:a548a085de55 | 1 | /* |
pehrhovey | 0:a548a085de55 | 2 | * Redistribution and use in source and binary forms, with or without modification, |
pehrhovey | 0:a548a085de55 | 3 | * are permitted provided that the following conditions are met: |
pehrhovey | 0:a548a085de55 | 4 | * |
pehrhovey | 0:a548a085de55 | 5 | * 1. Redistributions of source code must retain the above copyright notice, |
pehrhovey | 0:a548a085de55 | 6 | * this list of conditions and the following disclaimer. |
pehrhovey | 0:a548a085de55 | 7 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
pehrhovey | 0:a548a085de55 | 8 | * this list of conditions and the following disclaimer in the documentation |
pehrhovey | 0:a548a085de55 | 9 | * and/or other materials provided with the distribution. |
pehrhovey | 0:a548a085de55 | 10 | * 3. The name of the author may not be used to endorse or promote products |
pehrhovey | 0:a548a085de55 | 11 | * derived from this software without specific prior written permission. |
pehrhovey | 0:a548a085de55 | 12 | * |
pehrhovey | 0:a548a085de55 | 13 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED |
pehrhovey | 0:a548a085de55 | 14 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
pehrhovey | 0:a548a085de55 | 15 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT |
pehrhovey | 0:a548a085de55 | 16 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
pehrhovey | 0:a548a085de55 | 17 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT |
pehrhovey | 0:a548a085de55 | 18 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
pehrhovey | 0:a548a085de55 | 19 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
pehrhovey | 0:a548a085de55 | 20 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING |
pehrhovey | 0:a548a085de55 | 21 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY |
pehrhovey | 0:a548a085de55 | 22 | * OF SUCH DAMAGE. |
pehrhovey | 0:a548a085de55 | 23 | * |
pehrhovey | 0:a548a085de55 | 24 | * This file is part of the lwIP TCP/IP stack. |
pehrhovey | 0:a548a085de55 | 25 | * |
pehrhovey | 0:a548a085de55 | 26 | */ |
pehrhovey | 0:a548a085de55 | 27 | |
pehrhovey | 0:a548a085de55 | 28 | #ifndef __LWIP_NETIFAPI_H__ |
pehrhovey | 0:a548a085de55 | 29 | #define __LWIP_NETIFAPI_H__ |
pehrhovey | 0:a548a085de55 | 30 | |
pehrhovey | 0:a548a085de55 | 31 | #include "lwip/opt.h" |
pehrhovey | 0:a548a085de55 | 32 | |
pehrhovey | 0:a548a085de55 | 33 | #if LWIP_NETIF_API /* don't build if not configured for use in lwipopts.h */ |
pehrhovey | 0:a548a085de55 | 34 | |
pehrhovey | 0:a548a085de55 | 35 | #include "lwip/sys.h" |
pehrhovey | 0:a548a085de55 | 36 | #include "lwip/netif.h" |
pehrhovey | 0:a548a085de55 | 37 | #include "lwip/dhcp.h" |
pehrhovey | 0:a548a085de55 | 38 | #include "lwip/autoip.h" |
pehrhovey | 0:a548a085de55 | 39 | |
pehrhovey | 0:a548a085de55 | 40 | #ifdef __cplusplus |
pehrhovey | 0:a548a085de55 | 41 | extern "C" { |
pehrhovey | 0:a548a085de55 | 42 | #endif |
pehrhovey | 0:a548a085de55 | 43 | |
pehrhovey | 0:a548a085de55 | 44 | struct netifapi_msg_msg { |
pehrhovey | 0:a548a085de55 | 45 | #if !LWIP_TCPIP_CORE_LOCKING |
pehrhovey | 0:a548a085de55 | 46 | sys_sem_t sem; |
pehrhovey | 0:a548a085de55 | 47 | #endif /* !LWIP_TCPIP_CORE_LOCKING */ |
pehrhovey | 0:a548a085de55 | 48 | err_t err; |
pehrhovey | 0:a548a085de55 | 49 | struct netif *netif; |
pehrhovey | 0:a548a085de55 | 50 | union { |
pehrhovey | 0:a548a085de55 | 51 | struct { |
pehrhovey | 0:a548a085de55 | 52 | struct ip_addr *ipaddr; |
pehrhovey | 0:a548a085de55 | 53 | struct ip_addr *netmask; |
pehrhovey | 0:a548a085de55 | 54 | struct ip_addr *gw; |
pehrhovey | 0:a548a085de55 | 55 | void *state; |
pehrhovey | 0:a548a085de55 | 56 | err_t (* init) (struct netif *netif); |
pehrhovey | 0:a548a085de55 | 57 | err_t (* input)(struct pbuf *p, struct netif *netif); |
pehrhovey | 0:a548a085de55 | 58 | } add; |
pehrhovey | 0:a548a085de55 | 59 | struct { |
pehrhovey | 0:a548a085de55 | 60 | void (* voidfunc)(struct netif *netif); |
pehrhovey | 0:a548a085de55 | 61 | err_t (* errtfunc)(struct netif *netif); |
pehrhovey | 0:a548a085de55 | 62 | } common; |
pehrhovey | 0:a548a085de55 | 63 | } msg; |
pehrhovey | 0:a548a085de55 | 64 | }; |
pehrhovey | 0:a548a085de55 | 65 | |
pehrhovey | 0:a548a085de55 | 66 | struct netifapi_msg { |
pehrhovey | 0:a548a085de55 | 67 | void (* function)(struct netifapi_msg_msg *msg); |
pehrhovey | 0:a548a085de55 | 68 | struct netifapi_msg_msg msg; |
pehrhovey | 0:a548a085de55 | 69 | }; |
pehrhovey | 0:a548a085de55 | 70 | |
pehrhovey | 0:a548a085de55 | 71 | |
pehrhovey | 0:a548a085de55 | 72 | /* API for application */ |
pehrhovey | 0:a548a085de55 | 73 | err_t netifapi_netif_add ( struct netif *netif, |
pehrhovey | 0:a548a085de55 | 74 | struct ip_addr *ipaddr, |
pehrhovey | 0:a548a085de55 | 75 | struct ip_addr *netmask, |
pehrhovey | 0:a548a085de55 | 76 | struct ip_addr *gw, |
pehrhovey | 0:a548a085de55 | 77 | void *state, |
pehrhovey | 0:a548a085de55 | 78 | err_t (* init)(struct netif *netif), |
pehrhovey | 0:a548a085de55 | 79 | err_t (* input)(struct pbuf *p, struct netif *netif) ); |
pehrhovey | 0:a548a085de55 | 80 | |
pehrhovey | 0:a548a085de55 | 81 | err_t netifapi_netif_set_addr ( struct netif *netif, |
pehrhovey | 0:a548a085de55 | 82 | struct ip_addr *ipaddr, |
pehrhovey | 0:a548a085de55 | 83 | struct ip_addr *netmask, |
pehrhovey | 0:a548a085de55 | 84 | struct ip_addr *gw ); |
pehrhovey | 0:a548a085de55 | 85 | |
pehrhovey | 0:a548a085de55 | 86 | err_t netifapi_netif_common ( struct netif *netif, |
pehrhovey | 0:a548a085de55 | 87 | void (* voidfunc)(struct netif *netif), |
pehrhovey | 0:a548a085de55 | 88 | err_t (* errtfunc)(struct netif *netif) ); |
pehrhovey | 0:a548a085de55 | 89 | |
pehrhovey | 0:a548a085de55 | 90 | #define netifapi_netif_remove(n) netifapi_netif_common(n, netif_remove, NULL) |
pehrhovey | 0:a548a085de55 | 91 | #define netifapi_netif_set_up(n) netifapi_netif_common(n, netif_set_up, NULL) |
pehrhovey | 0:a548a085de55 | 92 | #define netifapi_netif_set_down(n) netifapi_netif_common(n, netif_set_down, NULL) |
pehrhovey | 0:a548a085de55 | 93 | #define netifapi_netif_set_default(n) netifapi_netif_common(n, netif_set_default, NULL) |
pehrhovey | 0:a548a085de55 | 94 | #define netifapi_dhcp_start(n) netifapi_netif_common(n, NULL, dhcp_start) |
pehrhovey | 0:a548a085de55 | 95 | #define netifapi_dhcp_stop(n) netifapi_netif_common(n, dhcp_stop, NULL) |
pehrhovey | 0:a548a085de55 | 96 | #define netifapi_autoip_start(n) netifapi_netif_common(n, NULL, autoip_start) |
pehrhovey | 0:a548a085de55 | 97 | #define netifapi_autoip_stop(n) netifapi_netif_common(n, NULL, autoip_stop) |
pehrhovey | 0:a548a085de55 | 98 | |
pehrhovey | 0:a548a085de55 | 99 | #ifdef __cplusplus |
pehrhovey | 0:a548a085de55 | 100 | } |
pehrhovey | 0:a548a085de55 | 101 | #endif |
pehrhovey | 0:a548a085de55 | 102 | |
pehrhovey | 0:a548a085de55 | 103 | #endif /* LWIP_NETIF_API */ |
pehrhovey | 0:a548a085de55 | 104 | |
pehrhovey | 0:a548a085de55 | 105 | #endif /* __LWIP_NETIFAPI_H__ */ |