sdk-core v2026.11.05
PS2 SDK - core tier (build-critical EE/IOP modules)
Loading...
Searching...
No Matches
api_msg.h
Go to the documentation of this file.
1
6
7/*
8 * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without modification,
12 * are permitted provided that the following conditions are met:
13 *
14 * 1. Redistributions of source code must retain the above copyright notice,
15 * this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright notice,
17 * this list of conditions and the following disclaimer in the documentation
18 * and/or other materials provided with the distribution.
19 * 3. The name of the author may not be used to endorse or promote products
20 * derived from this software without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
23 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
24 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
25 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
26 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
27 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
30 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
31 * OF SUCH DAMAGE.
32 *
33 * This file is part of the lwIP TCP/IP stack.
34 *
35 * Author: Adam Dunkels <adam@sics.se>
36 *
37 */
38#ifndef LWIP_HDR_API_MSG_H
39#define LWIP_HDR_API_MSG_H
40
41#include "lwip/opt.h"
42
43#include "lwip/arch.h"
44#include "lwip/ip_addr.h"
45#include "lwip/err.h"
46#include "lwip/sys.h"
47#include "lwip/igmp.h"
48#include "lwip/api.h"
50
51#ifdef __cplusplus
52extern "C" {
53#endif
54
55#if LWIP_NETCONN || LWIP_SOCKET /* don't build if not configured for use in lwipopts.h */
56/* Note: Netconn API is always available when sockets are enabled -
57 * sockets are implemented on top of them */
58
59#if LWIP_MPU_COMPATIBLE
60#if LWIP_NETCONN_SEM_PER_THREAD
61#define API_MSG_M_DEF_SEM(m) *m
62#else
63#define API_MSG_M_DEF_SEM(m) API_MSG_M_DEF(m)
64#endif
65#else /* LWIP_MPU_COMPATIBLE */
66#define API_MSG_M_DEF_SEM(m) API_MSG_M_DEF(m)
67#endif /* LWIP_MPU_COMPATIBLE */
68
69/* For the netconn API, these values are use as a bitmask! */
70#define NETCONN_SHUT_RD 1
71#define NETCONN_SHUT_WR 2
72#define NETCONN_SHUT_RDWR (NETCONN_SHUT_RD | NETCONN_SHUT_WR)
73
74/* IP addresses and port numbers are expected to be in
75 * the same byte order as in the corresponding pcb.
76 */
80struct api_msg {
83 struct netconn *conn;
85 err_t err;
87 union {
89 struct netbuf *b;
91 struct {
92 u8_t proto;
93 } n;
95 struct {
96 API_MSG_M_DEF_C(ip_addr_t, ipaddr);
97 u16_t port;
98 u8_t if_idx;
99 } bc;
101 struct {
102 ip_addr_t API_MSG_M_DEF(ipaddr);
103 u16_t API_MSG_M_DEF(port);
104 u8_t local;
105 } ad;
107 struct {
109 const struct netvector *vector;
111 u16_t vector_cnt;
113 size_t vector_off;
115 size_t len;
117 size_t offset;
118 u8_t apiflags;
119#if LWIP_SO_SNDTIMEO
120 u32_t time_started;
121#endif /* LWIP_SO_SNDTIMEO */
122 } w;
124 struct {
125 size_t len;
126 } r;
127#if LWIP_TCP
129 struct {
130 u8_t shut;
131#if LWIP_SO_SNDTIMEO || LWIP_SO_LINGER
132 u32_t time_started;
133#else /* LWIP_SO_SNDTIMEO || LWIP_SO_LINGER */
134 u8_t polls_left;
135#endif /* LWIP_SO_SNDTIMEO || LWIP_SO_LINGER */
136 } sd;
137#endif /* LWIP_TCP */
138#if LWIP_IGMP || (LWIP_IPV6 && LWIP_IPV6_MLD)
140 struct {
141 API_MSG_M_DEF_C(ip_addr_t, multiaddr);
142 API_MSG_M_DEF_C(ip_addr_t, netif_addr);
143 u8_t if_idx;
144 enum netconn_igmp join_or_leave;
145 } jl;
146#endif /* LWIP_IGMP || (LWIP_IPV6 && LWIP_IPV6_MLD) */
147#if TCP_LISTEN_BACKLOG
148 struct {
149 u8_t backlog;
150 } lb;
151#endif /* TCP_LISTEN_BACKLOG */
152 } msg;
153#if LWIP_NETCONN_SEM_PER_THREAD
154 sys_sem_t* op_completed_sem;
155#endif /* LWIP_NETCONN_SEM_PER_THREAD */
156};
157
158#if LWIP_NETCONN_SEM_PER_THREAD
159#define LWIP_API_MSG_SEM(msg) ((msg)->op_completed_sem)
160#else /* LWIP_NETCONN_SEM_PER_THREAD */
161#define LWIP_API_MSG_SEM(msg) (&(msg)->conn->op_completed)
162#endif /* LWIP_NETCONN_SEM_PER_THREAD */
163
164
165#if LWIP_DNS
170struct dns_api_msg {
172#if LWIP_MPU_COMPATIBLE
173 char name[DNS_MAX_NAME_LENGTH];
174#else /* LWIP_MPU_COMPATIBLE */
175 const char *name;
176#endif /* LWIP_MPU_COMPATIBLE */
178 ip_addr_t API_MSG_M_DEF(addr);
179#if LWIP_IPV4 && LWIP_IPV6
181 u8_t dns_addrtype;
182#endif /* LWIP_IPV4 && LWIP_IPV6 */
185 sys_sem_t API_MSG_M_DEF_SEM(sem);
187 err_t API_MSG_M_DEF(err);
188};
189#endif /* LWIP_DNS */
190
191#if LWIP_NETCONN_FULLDUPLEX
192int lwip_netconn_is_deallocated_msg(void *msg);
193#endif
194int lwip_netconn_is_err_msg(void *msg, err_t *err);
195void lwip_netconn_do_newconn (void *m);
196void lwip_netconn_do_delconn (void *m);
197void lwip_netconn_do_bind (void *m);
198void lwip_netconn_do_bind_if (void *m);
199void lwip_netconn_do_connect (void *m);
200void lwip_netconn_do_disconnect (void *m);
201void lwip_netconn_do_listen (void *m);
202void lwip_netconn_do_send (void *m);
203void lwip_netconn_do_recv (void *m);
204#if TCP_LISTEN_BACKLOG
205void lwip_netconn_do_accepted (void *m);
206#endif /* TCP_LISTEN_BACKLOG */
207void lwip_netconn_do_write (void *m);
208void lwip_netconn_do_getaddr (void *m);
209void lwip_netconn_do_close (void *m);
210void lwip_netconn_do_shutdown (void *m);
211#if LWIP_IGMP || (LWIP_IPV6 && LWIP_IPV6_MLD)
212void lwip_netconn_do_join_leave_group(void *m);
213void lwip_netconn_do_join_leave_group_netif(void *m);
214#endif /* LWIP_IGMP || (LWIP_IPV6 && LWIP_IPV6_MLD) */
215
216#if LWIP_DNS
217void lwip_netconn_do_gethostbyname(void *arg);
218#endif /* LWIP_DNS */
219
220struct netconn* netconn_alloc(enum netconn_type t, netconn_callback callback);
221void netconn_free(struct netconn *conn);
222
223#endif /* LWIP_NETCONN || LWIP_SOCKET */
224
225#if LWIP_NETIF_API /* don't build if not configured for use in lwipopts.h */
226
227/* netifapi related lwIP internal definitions */
228
229#if LWIP_MPU_COMPATIBLE
230#define NETIFAPI_IPADDR_DEF(type, m) type m
231#else /* LWIP_MPU_COMPATIBLE */
232#define NETIFAPI_IPADDR_DEF(type, m) const type * m
233#endif /* LWIP_MPU_COMPATIBLE */
234
235typedef void (*netifapi_void_fn)(struct netif *netif);
236typedef err_t (*netifapi_errt_fn)(struct netif *netif);
237
238struct netifapi_msg {
239 struct tcpip_api_call_data call;
240 struct netif *netif;
241 union {
242 struct {
243#if LWIP_IPV4
244 NETIFAPI_IPADDR_DEF(ip4_addr_t, ipaddr);
245 NETIFAPI_IPADDR_DEF(ip4_addr_t, netmask);
246 NETIFAPI_IPADDR_DEF(ip4_addr_t, gw);
247#endif /* LWIP_IPV4 */
248 void *state;
249 netif_init_fn init;
250 netif_input_fn input;
251 } add;
252 struct {
253 netifapi_void_fn voidfunc;
254 netifapi_errt_fn errtfunc;
255 } common;
256 struct {
257#if LWIP_MPU_COMPATIBLE
258 char name[NETIF_NAMESIZE];
259#else /* LWIP_MPU_COMPATIBLE */
260 char *name;
261#endif /* LWIP_MPU_COMPATIBLE */
262 u8_t index;
263 } ifs;
264 } msg;
265};
266
267#endif /* LWIP_NETIF_API */
268
269#ifdef __cplusplus
270}
271#endif
272
273#endif /* LWIP_HDR_API_MSG_H */
err_t(*) netif_input_fn(struct pbuf *p, struct netif *inp)
Definition tcpip.h:1207
err_t(*) netif_init_fn(struct netif *netif)
Definition tcpip.h:1200
s8_t err_t
Definition err.h:96
#define DNS_MAX_NAME_LENGTH
Definition opt.h:1163
#define NETIF_NAMESIZE
Definition netif.h:70
struct ip4_addr ip4_addr_t
Definition ps2ip_rpc.h:41