/** * @file * netconn API lwIP internal implementations (do not use in application code) *//* ... *//* * Copyright (c) 2001-2004 Swedish Institute of Computer Science. * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY * OF SUCH DAMAGE. * * This file is part of the lwIP TCP/IP stack. * * Author: Adam Dunkels <adam@sics.se> * *//* ... */#ifndefLWIP_HDR_API_MSG_H#defineLWIP_HDR_API_MSG_H#include"lwip/opt.h"#include"lwip/arch.h"#include"lwip/ip_addr.h"#include"lwip/err.h"#include"lwip/sys.h"#include"lwip/igmp.h"#include"lwip/api.h"#include"lwip/priv/tcpip_priv.h"8 includes#ifdef__cplusplusextern"C"{#endif#ifLWIP_NETCONN||LWIP_SOCKET/* don't build if not configured for use in lwipopts.h *//* Note: Netconn API is always available when sockets are enabled - * sockets are implemented on top of them *//* ... */#ifLWIP_MPU_COMPATIBLE#ifLWIP_NETCONN_SEM_PER_THREAD#defineAPI_MSG_M_DEF_SEM(m)*m#else#defineAPI_MSG_M_DEF_SEM(m)API_MSG_M_DEF(m)#endif/* ... */#else/* LWIP_MPU_COMPATIBLE */#defineAPI_MSG_M_DEF_SEM(m)API_MSG_M_DEF(m)#endif/* LWIP_MPU_COMPATIBLE *//* For the netconn API, these values are use as a bitmask! */#defineNETCONN_SHUT_RD1#defineNETCONN_SHUT_WR2#defineNETCONN_SHUT_RDWR(NETCONN_SHUT_RD|NETCONN_SHUT_WR)/* IP addresses and port numbers are expected to be in * the same byte order as in the corresponding pcb. *//* ... *//** This struct includes everything that is necessary to execute a function for a netconn in another thread context (mainly used to process netconns in the tcpip_thread context to be thread safe). *//* ... */structapi_msg{/** The netconn which to process - always needed: it includes the semaphore which is used to block the application thread until the function finished. *//* ... */structnetconn*conn;/** The return value of the function executed in tcpip_thread. */err_terr;/** Depending on the executed function, one of these union members is used */union{/** used for lwip_netconn_do_send */structnetbuf*b;/** used for lwip_netconn_do_newconn */struct{u8_tproto;...}n;/** used for lwip_netconn_do_bind and lwip_netconn_do_connect */struct{API_MSG_M_DEF_C(ip_addr_t,ipaddr);u16_tport;u8_tif_idx;...}bc;/** used for lwip_netconn_do_getaddr */struct{ip_addr_tAPI_MSG_M_DEF(ipaddr);u16_tAPI_MSG_M_DEF(port);u8_tlocal;...}ad;/** used for lwip_netconn_do_write */struct{/** current vector to write */conststructnetvector*vector;/** number of unwritten vectors */u16_tvector_cnt;/** offset into current vector */size_tvector_off;/** total length across vectors */size_tlen;/** offset into total length/output of bytes written when err == ERR_OK */size_toffset;u8_tapiflags;#ifLWIP_SO_SNDTIMEOu32_ttime_started;#endif/* LWIP_SO_SNDTIMEO */...}w;/** used for lwip_netconn_do_recv */struct{size_tlen;...}r;#ifLWIP_TCP/** used for lwip_netconn_do_close (/shutdown) */struct{u8_tshut;#ifLWIP_SO_SNDTIMEO||LWIP_SO_LINGERu32_ttime_started;#else/* LWIP_SO_SNDTIMEO || LWIP_SO_LINGER */u8_tpolls_left;#endif/* LWIP_SO_SNDTIMEO || LWIP_SO_LINGER */...}sd;/* ... */#endif/* LWIP_TCP */#ifLWIP_IGMP||(LWIP_IPV6&&LWIP_IPV6_MLD)/** used for lwip_netconn_do_join_leave_group */struct{API_MSG_M_DEF_C(ip_addr_t,multiaddr);API_MSG_M_DEF_C(ip_addr_t,netif_addr);u8_tif_idx;enumnetconn_igmpjoin_or_leave;...}jl;/* ... */#endif/* LWIP_IGMP || (LWIP_IPV6 && LWIP_IPV6_MLD) */#ifTCP_LISTEN_BACKLOGstruct{u8_tbacklog;...}lb;/* ... */#endif/* TCP_LISTEN_BACKLOG */...}msg;#ifLWIP_NETCONN_SEM_PER_THREADsys_sem_t*op_completed_sem;#endif/* LWIP_NETCONN_SEM_PER_THREAD */...};#ifLWIP_NETCONN_SEM_PER_THREAD#defineLWIP_API_MSG_SEM(msg)((msg)->op_completed_sem)#else/* LWIP_NETCONN_SEM_PER_THREAD */#defineLWIP_API_MSG_SEM(msg)(&(msg)->conn->op_completed)#endif/* LWIP_NETCONN_SEM_PER_THREAD */#ifLWIP_DNS/** As lwip_netconn_do_gethostbyname requires more arguments but doesn't require a netconn, it has its own struct (to avoid struct api_msg getting bigger than necessary). lwip_netconn_do_gethostbyname must be called using tcpip_callback instead of tcpip_apimsg (see netconn_gethostbyname). *//* ... */structdns_api_msg{/** Hostname to query or dotted IP address string */#ifLWIP_MPU_COMPATIBLEcharname[DNS_MAX_NAME_LENGTH];#else/* LWIP_MPU_COMPATIBLE */constchar*name;#endif/* LWIP_MPU_COMPATIBLE *//** The resolved address is stored here */ip_addr_tAPI_MSG_M_DEF(addr);#ifLWIP_IPV4&&LWIP_IPV6/** Type of resolve call */u8_tdns_addrtype;/* ... */#endif/* LWIP_IPV4 && LWIP_IPV6 *//** This semaphore is posted when the name is resolved, the application thread should wait on it. *//* ... */sys_sem_tAPI_MSG_M_DEF_SEM(sem);/** Errors are given back here */err_tAPI_MSG_M_DEF(err);...};/* ... */#endif/* LWIP_DNS */#ifLWIP_NETCONN_FULLDUPLEXintlwip_netconn_is_deallocated_msg(void*msg);#endifintlwip_netconn_is_err_msg(void*msg,err_t*err);voidlwip_netconn_do_newconn(void*m);voidlwip_netconn_do_delconn(void*m);voidlwip_netconn_do_bind(void*m);voidlwip_netconn_do_bind_if(void*m);voidlwip_netconn_do_connect(void*m);voidlwip_netconn_do_disconnect(void*m);voidlwip_netconn_do_listen(void*m);voidlwip_netconn_do_send(void*m);voidlwip_netconn_do_recv(void*m);#ifTCP_LISTEN_BACKLOGvoidlwip_netconn_do_accepted(void*m);#endif/* TCP_LISTEN_BACKLOG */voidlwip_netconn_do_write(void*m);voidlwip_netconn_do_getaddr(void*m);voidlwip_netconn_do_close(void*m);voidlwip_netconn_do_shutdown(void*m);#ifLWIP_IGMP||(LWIP_IPV6&&LWIP_IPV6_MLD)voidlwip_netconn_do_join_leave_group(void*m);voidlwip_netconn_do_join_leave_group_netif(void*m);/* ... */#endif/* LWIP_IGMP || (LWIP_IPV6 && LWIP_IPV6_MLD) */#ifLWIP_DNSvoidlwip_netconn_do_gethostbyname(void*arg);#endif/* LWIP_DNS */structnetconn*netconn_alloc(enumnetconn_typet,netconn_callbackcallback);voidnetconn_free(structnetconn*conn);/* ... */#endif/* LWIP_NETCONN || LWIP_SOCKET */#ifLWIP_NETIF_API/* don't build if not configured for use in lwipopts.h *//* netifapi related lwIP internal definitions */#ifLWIP_MPU_COMPATIBLE#defineNETIFAPI_IPADDR_DEF(type,m)typem#else/* LWIP_MPU_COMPATIBLE */#defineNETIFAPI_IPADDR_DEF(type,m)consttype*m#endif/* LWIP_MPU_COMPATIBLE */typedefvoid(*netifapi_void_fn)(structnetif*netif);typedeferr_t(*netifapi_errt_fn)(structnetif*netif);structnetifapi_msg{structtcpip_api_call_datacall;structnetif*netif;union{struct{#ifLWIP_IPV4NETIFAPI_IPADDR_DEF(ip4_addr_t,ipaddr);NETIFAPI_IPADDR_DEF(ip4_addr_t,netmask);NETIFAPI_IPADDR_DEF(ip4_addr_t,gw);/* ... */#endif/* LWIP_IPV4 */void*state;netif_init_fninit;netif_input_fninput;...}add;struct{netifapi_void_fnvoidfunc;netifapi_errt_fnerrtfunc;...}common;struct{#ifLWIP_MPU_COMPATIBLEcharname[NETIF_NAMESIZE];#else/* LWIP_MPU_COMPATIBLE */char*name;#endif/* LWIP_MPU_COMPATIBLE */u8_tindex;...}ifs;...}msg;...};/* ... */#endif/* LWIP_NETIF_API */#ifdef__cplusplus}extern "C" { ... }#endif/* ... */#endif/* LWIP_HDR_API_MSG_H */
Details
Show: from
Types: Columns:
All items filtered out
All items filtered out
This file uses the notable symbols shown below. Click anywhere in the file to view more details.