Web server based weather station using Sparkfun Weather Meters.
Dependencies: FatFileSystem mbed WeatherMeters SDFileSystem
NetStack/lwip/include/lwip/api_msg.h@0:616601bde9fb, 2012-02-23 (annotated)
- Committer:
- AdamGreen
- Date:
- Thu Feb 23 21:38:39 2012 +0000
- Revision:
- 0:616601bde9fb
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
AdamGreen | 0:616601bde9fb | 1 | /* |
AdamGreen | 0:616601bde9fb | 2 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science. |
AdamGreen | 0:616601bde9fb | 3 | * All rights reserved. |
AdamGreen | 0:616601bde9fb | 4 | * |
AdamGreen | 0:616601bde9fb | 5 | * Redistribution and use in source and binary forms, with or without modification, |
AdamGreen | 0:616601bde9fb | 6 | * are permitted provided that the following conditions are met: |
AdamGreen | 0:616601bde9fb | 7 | * |
AdamGreen | 0:616601bde9fb | 8 | * 1. Redistributions of source code must retain the above copyright notice, |
AdamGreen | 0:616601bde9fb | 9 | * this list of conditions and the following disclaimer. |
AdamGreen | 0:616601bde9fb | 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
AdamGreen | 0:616601bde9fb | 11 | * this list of conditions and the following disclaimer in the documentation |
AdamGreen | 0:616601bde9fb | 12 | * and/or other materials provided with the distribution. |
AdamGreen | 0:616601bde9fb | 13 | * 3. The name of the author may not be used to endorse or promote products |
AdamGreen | 0:616601bde9fb | 14 | * derived from this software without specific prior written permission. |
AdamGreen | 0:616601bde9fb | 15 | * |
AdamGreen | 0:616601bde9fb | 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED |
AdamGreen | 0:616601bde9fb | 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
AdamGreen | 0:616601bde9fb | 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT |
AdamGreen | 0:616601bde9fb | 19 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
AdamGreen | 0:616601bde9fb | 20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT |
AdamGreen | 0:616601bde9fb | 21 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
AdamGreen | 0:616601bde9fb | 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
AdamGreen | 0:616601bde9fb | 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING |
AdamGreen | 0:616601bde9fb | 24 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY |
AdamGreen | 0:616601bde9fb | 25 | * OF SUCH DAMAGE. |
AdamGreen | 0:616601bde9fb | 26 | * |
AdamGreen | 0:616601bde9fb | 27 | * This file is part of the lwIP TCP/IP stack. |
AdamGreen | 0:616601bde9fb | 28 | * |
AdamGreen | 0:616601bde9fb | 29 | * Author: Adam Dunkels <adam@sics.se> |
AdamGreen | 0:616601bde9fb | 30 | * |
AdamGreen | 0:616601bde9fb | 31 | */ |
AdamGreen | 0:616601bde9fb | 32 | #ifndef __LWIP_API_MSG_H__ |
AdamGreen | 0:616601bde9fb | 33 | #define __LWIP_API_MSG_H__ |
AdamGreen | 0:616601bde9fb | 34 | |
AdamGreen | 0:616601bde9fb | 35 | #include "lwip/opt.h" |
AdamGreen | 0:616601bde9fb | 36 | |
AdamGreen | 0:616601bde9fb | 37 | #if LWIP_NETCONN /* don't build if not configured for use in lwipopts.h */ |
AdamGreen | 0:616601bde9fb | 38 | |
AdamGreen | 0:616601bde9fb | 39 | #include <stddef.h> /* for size_t */ |
AdamGreen | 0:616601bde9fb | 40 | |
AdamGreen | 0:616601bde9fb | 41 | #include "lwip/ip_addr.h" |
AdamGreen | 0:616601bde9fb | 42 | #include "lwip/err.h" |
AdamGreen | 0:616601bde9fb | 43 | #include "lwip/sys.h" |
AdamGreen | 0:616601bde9fb | 44 | #include "lwip/igmp.h" |
AdamGreen | 0:616601bde9fb | 45 | #include "lwip/api.h" |
AdamGreen | 0:616601bde9fb | 46 | |
AdamGreen | 0:616601bde9fb | 47 | #ifdef __cplusplus |
AdamGreen | 0:616601bde9fb | 48 | extern "C" { |
AdamGreen | 0:616601bde9fb | 49 | #endif |
AdamGreen | 0:616601bde9fb | 50 | |
AdamGreen | 0:616601bde9fb | 51 | #define NETCONN_SHUT_RD 1 |
AdamGreen | 0:616601bde9fb | 52 | #define NETCONN_SHUT_WR 2 |
AdamGreen | 0:616601bde9fb | 53 | #define NETCONN_SHUT_RDWR 3 |
AdamGreen | 0:616601bde9fb | 54 | |
AdamGreen | 0:616601bde9fb | 55 | /* IP addresses and port numbers are expected to be in |
AdamGreen | 0:616601bde9fb | 56 | * the same byte order as in the corresponding pcb. |
AdamGreen | 0:616601bde9fb | 57 | */ |
AdamGreen | 0:616601bde9fb | 58 | /** This struct includes everything that is necessary to execute a function |
AdamGreen | 0:616601bde9fb | 59 | for a netconn in another thread context (mainly used to process netconns |
AdamGreen | 0:616601bde9fb | 60 | in the tcpip_thread context to be thread safe). */ |
AdamGreen | 0:616601bde9fb | 61 | struct api_msg_msg { |
AdamGreen | 0:616601bde9fb | 62 | /** The netconn which to process - always needed: it includes the semaphore |
AdamGreen | 0:616601bde9fb | 63 | which is used to block the application thread until the function finished. */ |
AdamGreen | 0:616601bde9fb | 64 | struct netconn *conn; |
AdamGreen | 0:616601bde9fb | 65 | /** The return value of the function executed in tcpip_thread. */ |
AdamGreen | 0:616601bde9fb | 66 | err_t err; |
AdamGreen | 0:616601bde9fb | 67 | /** Depending on the executed function, one of these union members is used */ |
AdamGreen | 0:616601bde9fb | 68 | union { |
AdamGreen | 0:616601bde9fb | 69 | /** used for do_send */ |
AdamGreen | 0:616601bde9fb | 70 | struct netbuf *b; |
AdamGreen | 0:616601bde9fb | 71 | /** used for do_newconn */ |
AdamGreen | 0:616601bde9fb | 72 | struct { |
AdamGreen | 0:616601bde9fb | 73 | u8_t proto; |
AdamGreen | 0:616601bde9fb | 74 | } n; |
AdamGreen | 0:616601bde9fb | 75 | /** used for do_bind and do_connect */ |
AdamGreen | 0:616601bde9fb | 76 | struct { |
AdamGreen | 0:616601bde9fb | 77 | ip_addr_t *ipaddr; |
AdamGreen | 0:616601bde9fb | 78 | u16_t port; |
AdamGreen | 0:616601bde9fb | 79 | } bc; |
AdamGreen | 0:616601bde9fb | 80 | /** used for do_getaddr */ |
AdamGreen | 0:616601bde9fb | 81 | struct { |
AdamGreen | 0:616601bde9fb | 82 | ip_addr_t *ipaddr; |
AdamGreen | 0:616601bde9fb | 83 | u16_t *port; |
AdamGreen | 0:616601bde9fb | 84 | u8_t local; |
AdamGreen | 0:616601bde9fb | 85 | } ad; |
AdamGreen | 0:616601bde9fb | 86 | /** used for do_write */ |
AdamGreen | 0:616601bde9fb | 87 | struct { |
AdamGreen | 0:616601bde9fb | 88 | const void *dataptr; |
AdamGreen | 0:616601bde9fb | 89 | size_t len; |
AdamGreen | 0:616601bde9fb | 90 | u8_t apiflags; |
AdamGreen | 0:616601bde9fb | 91 | } w; |
AdamGreen | 0:616601bde9fb | 92 | /** used for do_recv */ |
AdamGreen | 0:616601bde9fb | 93 | struct { |
AdamGreen | 0:616601bde9fb | 94 | u32_t len; |
AdamGreen | 0:616601bde9fb | 95 | } r; |
AdamGreen | 0:616601bde9fb | 96 | /** used for do_close (/shutdown) */ |
AdamGreen | 0:616601bde9fb | 97 | struct { |
AdamGreen | 0:616601bde9fb | 98 | u8_t shut; |
AdamGreen | 0:616601bde9fb | 99 | } sd; |
AdamGreen | 0:616601bde9fb | 100 | #if LWIP_IGMP |
AdamGreen | 0:616601bde9fb | 101 | /** used for do_join_leave_group */ |
AdamGreen | 0:616601bde9fb | 102 | struct { |
AdamGreen | 0:616601bde9fb | 103 | ip_addr_t *multiaddr; |
AdamGreen | 0:616601bde9fb | 104 | ip_addr_t *netif_addr; |
AdamGreen | 0:616601bde9fb | 105 | enum netconn_igmp join_or_leave; |
AdamGreen | 0:616601bde9fb | 106 | } jl; |
AdamGreen | 0:616601bde9fb | 107 | #endif /* LWIP_IGMP */ |
AdamGreen | 0:616601bde9fb | 108 | #if TCP_LISTEN_BACKLOG |
AdamGreen | 0:616601bde9fb | 109 | struct { |
AdamGreen | 0:616601bde9fb | 110 | u8_t backlog; |
AdamGreen | 0:616601bde9fb | 111 | } lb; |
AdamGreen | 0:616601bde9fb | 112 | #endif /* TCP_LISTEN_BACKLOG */ |
AdamGreen | 0:616601bde9fb | 113 | } msg; |
AdamGreen | 0:616601bde9fb | 114 | }; |
AdamGreen | 0:616601bde9fb | 115 | |
AdamGreen | 0:616601bde9fb | 116 | /** This struct contains a function to execute in another thread context and |
AdamGreen | 0:616601bde9fb | 117 | a struct api_msg_msg that serves as an argument for this function. |
AdamGreen | 0:616601bde9fb | 118 | This is passed to tcpip_apimsg to execute functions in tcpip_thread context. */ |
AdamGreen | 0:616601bde9fb | 119 | struct api_msg { |
AdamGreen | 0:616601bde9fb | 120 | /** function to execute in tcpip_thread context */ |
AdamGreen | 0:616601bde9fb | 121 | void (* function)(struct api_msg_msg *msg); |
AdamGreen | 0:616601bde9fb | 122 | /** arguments for this function */ |
AdamGreen | 0:616601bde9fb | 123 | struct api_msg_msg msg; |
AdamGreen | 0:616601bde9fb | 124 | }; |
AdamGreen | 0:616601bde9fb | 125 | |
AdamGreen | 0:616601bde9fb | 126 | #if LWIP_DNS |
AdamGreen | 0:616601bde9fb | 127 | /** As do_gethostbyname requires more arguments but doesn't require a netconn, |
AdamGreen | 0:616601bde9fb | 128 | it has its own struct (to avoid struct api_msg getting bigger than necessary). |
AdamGreen | 0:616601bde9fb | 129 | do_gethostbyname must be called using tcpip_callback instead of tcpip_apimsg |
AdamGreen | 0:616601bde9fb | 130 | (see netconn_gethostbyname). */ |
AdamGreen | 0:616601bde9fb | 131 | struct dns_api_msg { |
AdamGreen | 0:616601bde9fb | 132 | /** Hostname to query or dotted IP address string */ |
AdamGreen | 0:616601bde9fb | 133 | const char *name; |
AdamGreen | 0:616601bde9fb | 134 | /** Rhe resolved address is stored here */ |
AdamGreen | 0:616601bde9fb | 135 | ip_addr_t *addr; |
AdamGreen | 0:616601bde9fb | 136 | /** This semaphore is posted when the name is resolved, the application thread |
AdamGreen | 0:616601bde9fb | 137 | should wait on it. */ |
AdamGreen | 0:616601bde9fb | 138 | sys_sem_t *sem; |
AdamGreen | 0:616601bde9fb | 139 | /** Errors are given back here */ |
AdamGreen | 0:616601bde9fb | 140 | err_t *err; |
AdamGreen | 0:616601bde9fb | 141 | }; |
AdamGreen | 0:616601bde9fb | 142 | #endif /* LWIP_DNS */ |
AdamGreen | 0:616601bde9fb | 143 | |
AdamGreen | 0:616601bde9fb | 144 | void do_newconn ( struct api_msg_msg *msg); |
AdamGreen | 0:616601bde9fb | 145 | void do_delconn ( struct api_msg_msg *msg); |
AdamGreen | 0:616601bde9fb | 146 | void do_bind ( struct api_msg_msg *msg); |
AdamGreen | 0:616601bde9fb | 147 | void do_connect ( struct api_msg_msg *msg); |
AdamGreen | 0:616601bde9fb | 148 | void do_disconnect ( struct api_msg_msg *msg); |
AdamGreen | 0:616601bde9fb | 149 | void do_listen ( struct api_msg_msg *msg); |
AdamGreen | 0:616601bde9fb | 150 | void do_send ( struct api_msg_msg *msg); |
AdamGreen | 0:616601bde9fb | 151 | void do_recv ( struct api_msg_msg *msg); |
AdamGreen | 0:616601bde9fb | 152 | void do_write ( struct api_msg_msg *msg); |
AdamGreen | 0:616601bde9fb | 153 | void do_getaddr ( struct api_msg_msg *msg); |
AdamGreen | 0:616601bde9fb | 154 | void do_close ( struct api_msg_msg *msg); |
AdamGreen | 0:616601bde9fb | 155 | void do_shutdown ( struct api_msg_msg *msg); |
AdamGreen | 0:616601bde9fb | 156 | #if LWIP_IGMP |
AdamGreen | 0:616601bde9fb | 157 | void do_join_leave_group( struct api_msg_msg *msg); |
AdamGreen | 0:616601bde9fb | 158 | #endif /* LWIP_IGMP */ |
AdamGreen | 0:616601bde9fb | 159 | |
AdamGreen | 0:616601bde9fb | 160 | #if LWIP_DNS |
AdamGreen | 0:616601bde9fb | 161 | void do_gethostbyname(void *arg); |
AdamGreen | 0:616601bde9fb | 162 | #endif /* LWIP_DNS */ |
AdamGreen | 0:616601bde9fb | 163 | |
AdamGreen | 0:616601bde9fb | 164 | struct netconn* netconn_alloc(enum netconn_type t, netconn_callback callback); |
AdamGreen | 0:616601bde9fb | 165 | void netconn_free(struct netconn *conn); |
AdamGreen | 0:616601bde9fb | 166 | |
AdamGreen | 0:616601bde9fb | 167 | #ifdef __cplusplus |
AdamGreen | 0:616601bde9fb | 168 | } |
AdamGreen | 0:616601bde9fb | 169 | #endif |
AdamGreen | 0:616601bde9fb | 170 | |
AdamGreen | 0:616601bde9fb | 171 | #endif /* LWIP_NETCONN */ |
AdamGreen | 0:616601bde9fb | 172 | |
AdamGreen | 0:616601bde9fb | 173 | #endif /* __LWIP_API_MSG_H__ */ |