2 * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
5 * Redistribution and use in source and binary forms, with or without modification,
6 * are permitted provided that the following conditions are met:
8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright notice,
11 * this list of conditions and the following disclaimer in the documentation
12 * and/or other materials provided with the distribution.
13 * 3. The name of the author may not be used to endorse or promote products
14 * derived from this software without specific prior written permission.
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
19 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
21 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
24 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
27 * This file is part of the lwIP TCP/IP stack.
29 * Author: Adam Dunkels <adam@sics.se>
32 #ifndef __LWIP_API_MSG_H__
33 #define __LWIP_API_MSG_H__
37 #if LWIP_NETCONN /* don't build if not configured for use in lwipopts.h */
39 #include "lwip/ip_addr.h"
42 #include "lwip/igmp.h"
49 /* IP addresses and port numbers are expected to be in
50 * the same byte order as in the corresponding pcb.
52 /** This struct includes everything that is necessary to execute a function
53 for a netconn in another thread context (mainly used to process netconns
54 in the tcpip_thread context to be thread safe). */
56 /** The netconn which to process - always needed: it includes the semaphore
57 which is used to block the application thread until the function finished. */
59 /** Depending on the executed function, one of these union members is used */
61 /** used for do_send */
63 /** used for do_newconn */
67 /** used for do_bind and do_connect */
69 struct ip_addr *ipaddr;
72 /** used for do_getaddr */
74 struct ip_addr *ipaddr;
78 /** used for do_write */
84 /** used ofr do_recv */
89 /** used for do_join_leave_group */
91 struct ip_addr *multiaddr;
92 struct ip_addr *interface;
93 enum netconn_igmp join_or_leave;
95 #endif /* LWIP_IGMP */
96 #if TCP_LISTEN_BACKLOG
100 #endif /* TCP_LISTEN_BACKLOG */
104 /** This struct contains a function to execute in another thread context and
105 a struct api_msg_msg that serves as an argument for this function.
106 This is passed to tcpip_apimsg to execute functions in tcpip_thread context. */
108 /** function to execute in tcpip_thread context */
109 void (* function)(struct api_msg_msg *msg);
110 /** arguments for this function */
111 struct api_msg_msg msg;
115 /** As do_gethostbyname requires more arguments but doesn't require a netconn,
116 it has its own struct (to avoid struct api_msg getting bigger than necessary).
117 do_gethostbyname must be called using tcpip_callback instead of tcpip_apimsg
118 (see netconn_gethostbyname). */
120 /** Hostname to query or dotted IP address string */
122 /** Rhe resolved address is stored here */
123 struct ip_addr *addr;
124 /** This semaphore is posted when the name is resolved, the application thread
125 should wait on it. */
127 /** Errors are given back here */
130 #endif /* LWIP_DNS */
132 void do_newconn ( struct api_msg_msg *msg);
133 void do_delconn ( struct api_msg_msg *msg);
134 void do_bind ( struct api_msg_msg *msg);
135 void do_connect ( struct api_msg_msg *msg);
136 void do_disconnect ( struct api_msg_msg *msg);
137 void do_listen ( struct api_msg_msg *msg);
138 void do_send ( struct api_msg_msg *msg);
139 void do_recv ( struct api_msg_msg *msg);
140 void do_write ( struct api_msg_msg *msg);
141 void do_getaddr ( struct api_msg_msg *msg);
142 void do_close ( struct api_msg_msg *msg);
144 void do_join_leave_group( struct api_msg_msg *msg);
145 #endif /* LWIP_IGMP */
148 void do_gethostbyname(void *arg);
149 #endif /* LWIP_DNS */
151 struct netconn* netconn_alloc(enum netconn_type t, netconn_callback callback);
152 void netconn_free(struct netconn *conn);
158 #endif /* LWIP_NETCONN */
160 #endif /* __LWIP_API_MSG_H__ */