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