A version of LWIP, provided for backwards compatibility.
Dependents: AA_DemoBoard DemoBoard HelloServerDemo DemoBoard_RangeIndicator ... more
api_msg.h
00001 /* 00002 * Copyright (c) 2001-2004 Swedish Institute of Computer Science. 00003 * All rights reserved. 00004 * 00005 * Redistribution and use in source and binary forms, with or without modification, 00006 * are permitted provided that the following conditions are met: 00007 * 00008 * 1. Redistributions of source code must retain the above copyright notice, 00009 * this list of conditions and the following disclaimer. 00010 * 2. Redistributions in binary form must reproduce the above copyright notice, 00011 * this list of conditions and the following disclaimer in the documentation 00012 * and/or other materials provided with the distribution. 00013 * 3. The name of the author may not be used to endorse or promote products 00014 * derived from this software without specific prior written permission. 00015 * 00016 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 00017 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 00018 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 00019 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 00020 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 00021 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 00022 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 00023 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 00024 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 00025 * OF SUCH DAMAGE. 00026 * 00027 * This file is part of the lwIP TCP/IP stack. 00028 * 00029 * Author: Adam Dunkels <adam@sics.se> 00030 * 00031 */ 00032 #ifndef __LWIP_API_MSG_H__ 00033 #define __LWIP_API_MSG_H__ 00034 00035 #include "lwip/opt.h" 00036 00037 #if LWIP_NETCONN /* don't build if not configured for use in lwipopts.h */ 00038 00039 #include "lwip/ip_addr.h" 00040 #include "lwip/err.h" 00041 #include "lwip/sys.h" 00042 #include "lwip/igmp.h" 00043 #include "lwip/api.h" 00044 00045 #ifdef __cplusplus 00046 extern "C" { 00047 #endif 00048 00049 /* IP addresses and port numbers are expected to be in 00050 * the same byte order as in the corresponding pcb. 00051 */ 00052 /** This struct includes everything that is necessary to execute a function 00053 for a netconn in another thread context (mainly used to process netconns 00054 in the tcpip_thread context to be thread safe). */ 00055 struct api_msg_msg { 00056 /** The netconn which to process - always needed: it includes the semaphore 00057 which is used to block the application thread until the function finished. */ 00058 struct netconn *conn; 00059 /** Depending on the executed function, one of these union members is used */ 00060 union { 00061 /** used for do_send */ 00062 struct netbuf *b; 00063 /** used for do_newconn */ 00064 struct { 00065 u8_t proto; 00066 } n; 00067 /** used for do_bind and do_connect */ 00068 struct { 00069 struct ip_addr *ipaddr; 00070 u16_t port; 00071 } bc; 00072 /** used for do_getaddr */ 00073 struct { 00074 struct ip_addr *ipaddr; 00075 u16_t *port; 00076 u8_t local; 00077 } ad; 00078 /** used for do_write */ 00079 struct { 00080 const void *dataptr; 00081 int len; 00082 u8_t apiflags; 00083 } w; 00084 /** used ofr do_recv */ 00085 struct { 00086 u16_t len; 00087 } r; 00088 #if LWIP_IGMP 00089 /** used for do_join_leave_group */ 00090 struct { 00091 struct ip_addr *multiaddr; 00092 struct ip_addr *interface; 00093 enum netconn_igmp join_or_leave; 00094 } jl; 00095 #endif /* LWIP_IGMP */ 00096 #if TCP_LISTEN_BACKLOG 00097 struct { 00098 u8_t backlog; 00099 } lb; 00100 #endif /* TCP_LISTEN_BACKLOG */ 00101 } msg; 00102 }; 00103 00104 /** This struct contains a function to execute in another thread context and 00105 a struct api_msg_msg that serves as an argument for this function. 00106 This is passed to tcpip_apimsg to execute functions in tcpip_thread context. */ 00107 struct api_msg { 00108 /** function to execute in tcpip_thread context */ 00109 void (* function)(struct api_msg_msg *msg); 00110 /** arguments for this function */ 00111 struct api_msg_msg msg; 00112 }; 00113 00114 #if LWIP_DNS 00115 /** As do_gethostbyname requires more arguments but doesn't require a netconn, 00116 it has its own struct (to avoid struct api_msg getting bigger than necessary). 00117 do_gethostbyname must be called using tcpip_callback instead of tcpip_apimsg 00118 (see netconn_gethostbyname). */ 00119 struct dns_api_msg { 00120 /** Hostname to query or dotted IP address string */ 00121 const char *name; 00122 /** Rhe resolved address is stored here */ 00123 struct ip_addr *addr; 00124 /** This semaphore is posted when the name is resolved, the application thread 00125 should wait on it. */ 00126 sys_sem_t sem; 00127 /** Errors are given back here */ 00128 err_t *err; 00129 }; 00130 #endif /* LWIP_DNS */ 00131 00132 void do_newconn ( struct api_msg_msg *msg); 00133 void do_delconn ( struct api_msg_msg *msg); 00134 void do_bind ( struct api_msg_msg *msg); 00135 void do_connect ( struct api_msg_msg *msg); 00136 void do_disconnect ( struct api_msg_msg *msg); 00137 void do_listen ( struct api_msg_msg *msg); 00138 void do_send ( struct api_msg_msg *msg); 00139 void do_recv ( struct api_msg_msg *msg); 00140 void do_write ( struct api_msg_msg *msg); 00141 void do_getaddr ( struct api_msg_msg *msg); 00142 void do_close ( struct api_msg_msg *msg); 00143 #if LWIP_IGMP 00144 void do_join_leave_group( struct api_msg_msg *msg); 00145 #endif /* LWIP_IGMP */ 00146 00147 #if LWIP_DNS 00148 void do_gethostbyname(void *arg); 00149 #endif /* LWIP_DNS */ 00150 00151 struct netconn* netconn_alloc(enum netconn_type t, netconn_callback callback); 00152 void netconn_free(struct netconn *conn); 00153 00154 #ifdef __cplusplus 00155 } 00156 #endif 00157 00158 #endif /* LWIP_NETCONN */ 00159 00160 #endif /* __LWIP_API_MSG_H__ */
Generated on Tue Jul 12 2022 16:05:59 by 1.7.2