User | Revision | Line number | New contents of line |
mbed714 |
0:d616ece2d859
|
1
|
/*
|
mbed714 |
0:d616ece2d859
|
2
|
* Copyright (c) 2001-2004 Swedish Institute of Computer Science.
|
mbed714 |
0:d616ece2d859
|
3
|
* All rights reserved.
|
mbed714 |
0:d616ece2d859
|
4
|
*
|
mbed714 |
0:d616ece2d859
|
5
|
* Redistribution and use in source and binary forms, with or without modification,
|
mbed714 |
0:d616ece2d859
|
6
|
* are permitted provided that the following conditions are met:
|
mbed714 |
0:d616ece2d859
|
7
|
*
|
mbed714 |
0:d616ece2d859
|
8
|
* 1. Redistributions of source code must retain the above copyright notice,
|
mbed714 |
0:d616ece2d859
|
9
|
* this list of conditions and the following disclaimer.
|
mbed714 |
0:d616ece2d859
|
10
|
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
mbed714 |
0:d616ece2d859
|
11
|
* this list of conditions and the following disclaimer in the documentation
|
mbed714 |
0:d616ece2d859
|
12
|
* and/or other materials provided with the distribution.
|
mbed714 |
0:d616ece2d859
|
13
|
* 3. The name of the author may not be used to endorse or promote products
|
mbed714 |
0:d616ece2d859
|
14
|
* derived from this software without specific prior written permission.
|
mbed714 |
0:d616ece2d859
|
15
|
*
|
mbed714 |
0:d616ece2d859
|
16
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
mbed714 |
0:d616ece2d859
|
17
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
mbed714 |
0:d616ece2d859
|
18
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
mbed714 |
0:d616ece2d859
|
19
|
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
mbed714 |
0:d616ece2d859
|
20
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
mbed714 |
0:d616ece2d859
|
21
|
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
mbed714 |
0:d616ece2d859
|
22
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
mbed714 |
0:d616ece2d859
|
23
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
mbed714 |
0:d616ece2d859
|
24
|
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
mbed714 |
0:d616ece2d859
|
25
|
* OF SUCH DAMAGE.
|
mbed714 |
0:d616ece2d859
|
26
|
*
|
mbed714 |
0:d616ece2d859
|
27
|
* This file is part of the lwIP TCP/IP stack.
|
mbed714 |
0:d616ece2d859
|
28
|
*
|
mbed714 |
0:d616ece2d859
|
29
|
* Author: Adam Dunkels <adam@sics.se>
|
mbed714 |
0:d616ece2d859
|
30
|
*
|
mbed714 |
0:d616ece2d859
|
31
|
*/
|
mbed714 |
0:d616ece2d859
|
32
|
#ifndef __LWIP_API_H__
|
mbed714 |
0:d616ece2d859
|
33
|
#define __LWIP_API_H__
|
mbed714 |
0:d616ece2d859
|
34
|
|
mbed714 |
0:d616ece2d859
|
35
|
#include "lwip/opt.h"
|
mbed714 |
0:d616ece2d859
|
36
|
|
mbed714 |
0:d616ece2d859
|
37
|
#if LWIP_NETCONN /* don't build if not configured for use in lwipopts.h */
|
mbed714 |
0:d616ece2d859
|
38
|
|
mbed714 |
0:d616ece2d859
|
39
|
#include <stddef.h> /* for size_t */
|
mbed714 |
0:d616ece2d859
|
40
|
|
mbed714 |
0:d616ece2d859
|
41
|
#include "lwip/netbuf.h"
|
mbed714 |
0:d616ece2d859
|
42
|
#include "lwip/sys.h"
|
mbed714 |
0:d616ece2d859
|
43
|
#include "lwip/ip_addr.h"
|
mbed714 |
0:d616ece2d859
|
44
|
#include "lwip/err.h"
|
mbed714 |
0:d616ece2d859
|
45
|
|
mbed714 |
0:d616ece2d859
|
46
|
#ifdef __cplusplus
|
mbed714 |
0:d616ece2d859
|
47
|
extern "C" {
|
mbed714 |
0:d616ece2d859
|
48
|
#endif
|
mbed714 |
0:d616ece2d859
|
49
|
|
mbed714 |
0:d616ece2d859
|
50
|
/* Throughout this file, IP addresses and port numbers are expected to be in
|
mbed714 |
0:d616ece2d859
|
51
|
* the same byte order as in the corresponding pcb.
|
mbed714 |
0:d616ece2d859
|
52
|
*/
|
mbed714 |
0:d616ece2d859
|
53
|
|
mbed714 |
0:d616ece2d859
|
54
|
/* Flags for netconn_write (u8_t) */
|
mbed714 |
0:d616ece2d859
|
55
|
#define NETCONN_NOFLAG 0x00
|
mbed714 |
0:d616ece2d859
|
56
|
#define NETCONN_NOCOPY 0x00 /* Only for source code compatibility */
|
mbed714 |
0:d616ece2d859
|
57
|
#define NETCONN_COPY 0x01
|
mbed714 |
0:d616ece2d859
|
58
|
#define NETCONN_MORE 0x02
|
mbed714 |
0:d616ece2d859
|
59
|
#define NETCONN_DONTBLOCK 0x04
|
mbed714 |
0:d616ece2d859
|
60
|
|
mbed714 |
0:d616ece2d859
|
61
|
/* Flags for struct netconn.flags (u8_t) */
|
mbed714 |
0:d616ece2d859
|
62
|
/** TCP: when data passed to netconn_write doesn't fit into the send buffer,
|
mbed714 |
0:d616ece2d859
|
63
|
this temporarily stores whether to wake up the original application task
|
mbed714 |
0:d616ece2d859
|
64
|
if data couldn't be sent in the first try. */
|
mbed714 |
0:d616ece2d859
|
65
|
#define NETCONN_FLAG_WRITE_DELAYED 0x01
|
mbed714 |
0:d616ece2d859
|
66
|
/** Should this netconn avoid blocking? */
|
mbed714 |
0:d616ece2d859
|
67
|
#define NETCONN_FLAG_NON_BLOCKING 0x02
|
mbed714 |
0:d616ece2d859
|
68
|
/** Was the last connect action a non-blocking one? */
|
mbed714 |
0:d616ece2d859
|
69
|
#define NETCONN_FLAG_IN_NONBLOCKING_CONNECT 0x04
|
mbed714 |
0:d616ece2d859
|
70
|
/** If this is set, a TCP netconn must call netconn_recved() to update
|
mbed714 |
0:d616ece2d859
|
71
|
the TCP receive window (done automatically if not set). */
|
mbed714 |
0:d616ece2d859
|
72
|
#define NETCONN_FLAG_NO_AUTO_RECVED 0x08
|
mbed714 |
0:d616ece2d859
|
73
|
/** If a nonblocking write has been rejected before, poll_tcp needs to
|
mbed714 |
0:d616ece2d859
|
74
|
check if the netconn is writable again */
|
mbed714 |
0:d616ece2d859
|
75
|
#define NETCONN_FLAG_CHECK_WRITESPACE 0x10
|
mbed714 |
0:d616ece2d859
|
76
|
|
mbed714 |
0:d616ece2d859
|
77
|
|
mbed714 |
0:d616ece2d859
|
78
|
/* Helpers to process several netconn_types by the same code */
|
mbed714 |
0:d616ece2d859
|
79
|
#define NETCONNTYPE_GROUP(t) (t&0xF0)
|
mbed714 |
0:d616ece2d859
|
80
|
#define NETCONNTYPE_DATAGRAM(t) (t&0xE0)
|
mbed714 |
0:d616ece2d859
|
81
|
|
mbed714 |
0:d616ece2d859
|
82
|
/** Protocol family and type of the netconn */
|
mbed714 |
0:d616ece2d859
|
83
|
enum netconn_type {
|
mbed714 |
0:d616ece2d859
|
84
|
NETCONN_INVALID = 0,
|
mbed714 |
0:d616ece2d859
|
85
|
/* NETCONN_TCP Group */
|
mbed714 |
0:d616ece2d859
|
86
|
NETCONN_TCP = 0x10,
|
mbed714 |
0:d616ece2d859
|
87
|
/* NETCONN_UDP Group */
|
mbed714 |
0:d616ece2d859
|
88
|
NETCONN_UDP = 0x20,
|
mbed714 |
0:d616ece2d859
|
89
|
NETCONN_UDPLITE = 0x21,
|
mbed714 |
0:d616ece2d859
|
90
|
NETCONN_UDPNOCHKSUM= 0x22,
|
mbed714 |
0:d616ece2d859
|
91
|
/* NETCONN_RAW Group */
|
mbed714 |
0:d616ece2d859
|
92
|
NETCONN_RAW = 0x40
|
mbed714 |
0:d616ece2d859
|
93
|
};
|
mbed714 |
0:d616ece2d859
|
94
|
|
mbed714 |
0:d616ece2d859
|
95
|
/** Current state of the netconn. Non-TCP netconns are always
|
mbed714 |
0:d616ece2d859
|
96
|
* in state NETCONN_NONE! */
|
mbed714 |
0:d616ece2d859
|
97
|
enum netconn_state {
|
mbed714 |
0:d616ece2d859
|
98
|
NETCONN_NONE,
|
mbed714 |
0:d616ece2d859
|
99
|
NETCONN_WRITE,
|
mbed714 |
0:d616ece2d859
|
100
|
NETCONN_LISTEN,
|
mbed714 |
0:d616ece2d859
|
101
|
NETCONN_CONNECT,
|
mbed714 |
0:d616ece2d859
|
102
|
NETCONN_CLOSE
|
mbed714 |
0:d616ece2d859
|
103
|
};
|
mbed714 |
0:d616ece2d859
|
104
|
|
mbed714 |
0:d616ece2d859
|
105
|
/** Use to inform the callback function about changes */
|
mbed714 |
0:d616ece2d859
|
106
|
enum netconn_evt {
|
mbed714 |
0:d616ece2d859
|
107
|
NETCONN_EVT_RCVPLUS,
|
mbed714 |
0:d616ece2d859
|
108
|
NETCONN_EVT_RCVMINUS,
|
mbed714 |
0:d616ece2d859
|
109
|
NETCONN_EVT_SENDPLUS,
|
mbed714 |
0:d616ece2d859
|
110
|
NETCONN_EVT_SENDMINUS,
|
mbed714 |
0:d616ece2d859
|
111
|
NETCONN_EVT_ERROR
|
mbed714 |
0:d616ece2d859
|
112
|
};
|
mbed714 |
0:d616ece2d859
|
113
|
|
mbed714 |
0:d616ece2d859
|
114
|
#if LWIP_IGMP
|
mbed714 |
0:d616ece2d859
|
115
|
/** Used for netconn_join_leave_group() */
|
mbed714 |
0:d616ece2d859
|
116
|
enum netconn_igmp {
|
mbed714 |
0:d616ece2d859
|
117
|
NETCONN_JOIN,
|
mbed714 |
0:d616ece2d859
|
118
|
NETCONN_LEAVE
|
mbed714 |
0:d616ece2d859
|
119
|
};
|
mbed714 |
0:d616ece2d859
|
120
|
#endif /* LWIP_IGMP */
|
mbed714 |
0:d616ece2d859
|
121
|
|
mbed714 |
0:d616ece2d859
|
122
|
/* forward-declare some structs to avoid to include their headers */
|
mbed714 |
0:d616ece2d859
|
123
|
struct ip_pcb;
|
mbed714 |
0:d616ece2d859
|
124
|
struct tcp_pcb;
|
mbed714 |
0:d616ece2d859
|
125
|
struct udp_pcb;
|
mbed714 |
0:d616ece2d859
|
126
|
struct raw_pcb;
|
mbed714 |
0:d616ece2d859
|
127
|
struct netconn;
|
mbed714 |
0:d616ece2d859
|
128
|
struct api_msg_msg;
|
mbed714 |
0:d616ece2d859
|
129
|
|
mbed714 |
0:d616ece2d859
|
130
|
/** A callback prototype to inform about events for a netconn */
|
mbed714 |
0:d616ece2d859
|
131
|
typedef void (* netconn_callback)(struct netconn *, enum netconn_evt, u16_t len);
|
mbed714 |
0:d616ece2d859
|
132
|
|
mbed714 |
0:d616ece2d859
|
133
|
/** A netconn descriptor */
|
mbed714 |
0:d616ece2d859
|
134
|
struct netconn {
|
mbed714 |
0:d616ece2d859
|
135
|
/** type of the netconn (TCP, UDP or RAW) */
|
mbed714 |
0:d616ece2d859
|
136
|
enum netconn_type type;
|
mbed714 |
0:d616ece2d859
|
137
|
/** current state of the netconn */
|
mbed714 |
0:d616ece2d859
|
138
|
enum netconn_state state;
|
mbed714 |
0:d616ece2d859
|
139
|
/** the lwIP internal protocol control block */
|
mbed714 |
0:d616ece2d859
|
140
|
union {
|
mbed714 |
0:d616ece2d859
|
141
|
struct ip_pcb *ip;
|
mbed714 |
0:d616ece2d859
|
142
|
struct tcp_pcb *tcp;
|
mbed714 |
0:d616ece2d859
|
143
|
struct udp_pcb *udp;
|
mbed714 |
0:d616ece2d859
|
144
|
struct raw_pcb *raw;
|
mbed714 |
0:d616ece2d859
|
145
|
} pcb;
|
mbed714 |
0:d616ece2d859
|
146
|
/** the last error this netconn had */
|
mbed714 |
0:d616ece2d859
|
147
|
err_t last_err;
|
mbed714 |
0:d616ece2d859
|
148
|
/** sem that is used to synchroneously execute functions in the core context */
|
mbed714 |
0:d616ece2d859
|
149
|
sys_sem_t op_completed;
|
mbed714 |
0:d616ece2d859
|
150
|
/** mbox where received packets are stored until they are fetched
|
mbed714 |
0:d616ece2d859
|
151
|
by the netconn application thread (can grow quite big) */
|
mbed714 |
0:d616ece2d859
|
152
|
sys_mbox_t recvmbox;
|
mbed714 |
0:d616ece2d859
|
153
|
#if LWIP_TCP
|
mbed714 |
0:d616ece2d859
|
154
|
/** mbox where new connections are stored until processed
|
mbed714 |
0:d616ece2d859
|
155
|
by the application thread */
|
mbed714 |
0:d616ece2d859
|
156
|
sys_mbox_t acceptmbox;
|
mbed714 |
0:d616ece2d859
|
157
|
#endif /* LWIP_TCP */
|
mbed714 |
0:d616ece2d859
|
158
|
/** only used for socket layer */
|
mbed714 |
0:d616ece2d859
|
159
|
#if LWIP_SOCKET
|
mbed714 |
0:d616ece2d859
|
160
|
int socket;
|
mbed714 |
0:d616ece2d859
|
161
|
#endif /* LWIP_SOCKET */
|
mbed714 |
0:d616ece2d859
|
162
|
#if LWIP_SO_RCVTIMEO
|
mbed714 |
0:d616ece2d859
|
163
|
/** timeout to wait for new data to be received
|
mbed714 |
0:d616ece2d859
|
164
|
(or connections to arrive for listening netconns) */
|
mbed714 |
0:d616ece2d859
|
165
|
int recv_timeout;
|
mbed714 |
0:d616ece2d859
|
166
|
#endif /* LWIP_SO_RCVTIMEO */
|
mbed714 |
0:d616ece2d859
|
167
|
#if LWIP_SO_RCVBUF
|
mbed714 |
0:d616ece2d859
|
168
|
/** maximum amount of bytes queued in recvmbox
|
mbed714 |
0:d616ece2d859
|
169
|
not used for TCP: adjust TCP_WND instead! */
|
mbed714 |
0:d616ece2d859
|
170
|
int recv_bufsize;
|
mbed714 |
0:d616ece2d859
|
171
|
#endif /* LWIP_SO_RCVBUF */
|
mbed714 |
0:d616ece2d859
|
172
|
/** number of bytes currently in recvmbox to be received,
|
mbed714 |
0:d616ece2d859
|
173
|
tested against recv_bufsize to limit bytes on recvmbox
|
mbed714 |
0:d616ece2d859
|
174
|
for UDP and RAW
|
mbed714 |
0:d616ece2d859
|
175
|
@todo: should only be necessary with LWIP_SO_RCVBUF==1 */
|
mbed714 |
0:d616ece2d859
|
176
|
s16_t recv_avail;
|
mbed714 |
0:d616ece2d859
|
177
|
/** flags holding more netconn-internal state, see NETCONN_FLAG_* defines */
|
mbed714 |
0:d616ece2d859
|
178
|
u8_t flags;
|
mbed714 |
0:d616ece2d859
|
179
|
#if LWIP_TCP
|
mbed714 |
0:d616ece2d859
|
180
|
/** TCP: when data passed to netconn_write doesn't fit into the send buffer,
|
mbed714 |
0:d616ece2d859
|
181
|
this temporarily stores how much is already sent. */
|
mbed714 |
0:d616ece2d859
|
182
|
size_t write_offset;
|
mbed714 |
0:d616ece2d859
|
183
|
/** TCP: when data passed to netconn_write doesn't fit into the send buffer,
|
mbed714 |
0:d616ece2d859
|
184
|
this temporarily stores the message.
|
mbed714 |
0:d616ece2d859
|
185
|
Also used during connect and close. */
|
mbed714 |
0:d616ece2d859
|
186
|
struct api_msg_msg *current_msg;
|
mbed714 |
0:d616ece2d859
|
187
|
#endif /* LWIP_TCP */
|
mbed714 |
0:d616ece2d859
|
188
|
/** A callback function that is informed about events for this netconn */
|
mbed714 |
0:d616ece2d859
|
189
|
netconn_callback callback;
|
mbed714 |
0:d616ece2d859
|
190
|
};
|
mbed714 |
0:d616ece2d859
|
191
|
|
mbed714 |
0:d616ece2d859
|
192
|
/** Register an Network connection event */
|
mbed714 |
0:d616ece2d859
|
193
|
#define API_EVENT(c,e,l) if (c->callback) { \
|
mbed714 |
0:d616ece2d859
|
194
|
(*c->callback)(c, e, l); \
|
mbed714 |
0:d616ece2d859
|
195
|
}
|
mbed714 |
0:d616ece2d859
|
196
|
|
mbed714 |
0:d616ece2d859
|
197
|
/** Set conn->last_err to err but don't overwrite fatal errors */
|
mbed714 |
0:d616ece2d859
|
198
|
#define NETCONN_SET_SAFE_ERR(conn, err) do { \
|
mbed714 |
0:d616ece2d859
|
199
|
SYS_ARCH_DECL_PROTECT(lev); \
|
mbed714 |
0:d616ece2d859
|
200
|
SYS_ARCH_PROTECT(lev); \
|
mbed714 |
0:d616ece2d859
|
201
|
if (!ERR_IS_FATAL((conn)->last_err)) { \
|
mbed714 |
0:d616ece2d859
|
202
|
(conn)->last_err = err; \
|
mbed714 |
0:d616ece2d859
|
203
|
} \
|
mbed714 |
0:d616ece2d859
|
204
|
SYS_ARCH_UNPROTECT(lev); \
|
mbed714 |
0:d616ece2d859
|
205
|
} while(0);
|
mbed714 |
0:d616ece2d859
|
206
|
|
mbed714 |
0:d616ece2d859
|
207
|
/* Network connection functions: */
|
mbed714 |
0:d616ece2d859
|
208
|
#define netconn_new(t) netconn_new_with_proto_and_callback(t, 0, NULL)
|
mbed714 |
0:d616ece2d859
|
209
|
#define netconn_new_with_callback(t, c) netconn_new_with_proto_and_callback(t, 0, c)
|
mbed714 |
0:d616ece2d859
|
210
|
struct
|
mbed714 |
0:d616ece2d859
|
211
|
netconn *netconn_new_with_proto_and_callback(enum netconn_type t, u8_t proto,
|
mbed714 |
0:d616ece2d859
|
212
|
netconn_callback callback);
|
mbed714 |
0:d616ece2d859
|
213
|
err_t netconn_delete(struct netconn *conn);
|
mbed714 |
0:d616ece2d859
|
214
|
/** Get the type of a netconn (as enum netconn_type). */
|
mbed714 |
0:d616ece2d859
|
215
|
#define netconn_type(conn) (conn->type)
|
mbed714 |
0:d616ece2d859
|
216
|
|
mbed714 |
0:d616ece2d859
|
217
|
err_t netconn_getaddr(struct netconn *conn, ip_addr_t *addr,
|
mbed714 |
0:d616ece2d859
|
218
|
u16_t *port, u8_t local);
|
mbed714 |
0:d616ece2d859
|
219
|
#define netconn_peer(c,i,p) netconn_getaddr(c,i,p,0)
|
mbed714 |
0:d616ece2d859
|
220
|
#define netconn_addr(c,i,p) netconn_getaddr(c,i,p,1)
|
mbed714 |
0:d616ece2d859
|
221
|
|
mbed714 |
0:d616ece2d859
|
222
|
err_t netconn_bind(struct netconn *conn, ip_addr_t *addr, u16_t port);
|
mbed714 |
0:d616ece2d859
|
223
|
err_t netconn_connect(struct netconn *conn, ip_addr_t *addr, u16_t port);
|
mbed714 |
0:d616ece2d859
|
224
|
err_t netconn_disconnect (struct netconn *conn);
|
mbed714 |
0:d616ece2d859
|
225
|
err_t netconn_listen_with_backlog(struct netconn *conn, u8_t backlog);
|
mbed714 |
0:d616ece2d859
|
226
|
#define netconn_listen(conn) netconn_listen_with_backlog(conn, TCP_DEFAULT_LISTEN_BACKLOG)
|
mbed714 |
0:d616ece2d859
|
227
|
err_t netconn_accept(struct netconn *conn, struct netconn **new_conn);
|
mbed714 |
0:d616ece2d859
|
228
|
err_t netconn_recv(struct netconn *conn, struct netbuf **new_buf);
|
mbed714 |
0:d616ece2d859
|
229
|
err_t netconn_recv_tcp_pbuf(struct netconn *conn, struct pbuf **new_buf);
|
mbed714 |
0:d616ece2d859
|
230
|
void netconn_recved(struct netconn *conn, u32_t length);
|
mbed714 |
0:d616ece2d859
|
231
|
err_t netconn_sendto(struct netconn *conn, struct netbuf *buf,
|
mbed714 |
0:d616ece2d859
|
232
|
ip_addr_t *addr, u16_t port);
|
mbed714 |
0:d616ece2d859
|
233
|
err_t netconn_send(struct netconn *conn, struct netbuf *buf);
|
mbed714 |
0:d616ece2d859
|
234
|
err_t netconn_write(struct netconn *conn, const void *dataptr, size_t size,
|
mbed714 |
0:d616ece2d859
|
235
|
u8_t apiflags);
|
mbed714 |
0:d616ece2d859
|
236
|
err_t netconn_close(struct netconn *conn);
|
mbed714 |
0:d616ece2d859
|
237
|
err_t netconn_shutdown(struct netconn *conn, u8_t shut_rx, u8_t shut_tx);
|
mbed714 |
0:d616ece2d859
|
238
|
|
mbed714 |
0:d616ece2d859
|
239
|
#if LWIP_IGMP
|
mbed714 |
0:d616ece2d859
|
240
|
err_t netconn_join_leave_group(struct netconn *conn, ip_addr_t *multiaddr,
|
mbed714 |
0:d616ece2d859
|
241
|
ip_addr_t *netif_addr, enum netconn_igmp join_or_leave);
|
mbed714 |
0:d616ece2d859
|
242
|
#endif /* LWIP_IGMP */
|
mbed714 |
0:d616ece2d859
|
243
|
#if LWIP_DNS
|
mbed714 |
0:d616ece2d859
|
244
|
err_t netconn_gethostbyname(const char *name, ip_addr_t *addr);
|
mbed714 |
0:d616ece2d859
|
245
|
#endif /* LWIP_DNS */
|
mbed714 |
0:d616ece2d859
|
246
|
|
mbed714 |
0:d616ece2d859
|
247
|
#define netconn_err(conn) ((conn)->last_err)
|
mbed714 |
0:d616ece2d859
|
248
|
#define netconn_recv_bufsize(conn) ((conn)->recv_bufsize)
|
mbed714 |
0:d616ece2d859
|
249
|
|
mbed714 |
0:d616ece2d859
|
250
|
/** Set the blocking status of netconn calls (@todo: write/send is missing) */
|
mbed714 |
0:d616ece2d859
|
251
|
#define netconn_set_nonblocking(conn, val) do { if(val) { \
|
mbed714 |
0:d616ece2d859
|
252
|
(conn)->flags |= NETCONN_FLAG_NON_BLOCKING; \
|
mbed714 |
0:d616ece2d859
|
253
|
} else { \
|
mbed714 |
0:d616ece2d859
|
254
|
(conn)->flags &= ~ NETCONN_FLAG_NON_BLOCKING; }} while(0)
|
mbed714 |
0:d616ece2d859
|
255
|
/** Get the blocking status of netconn calls (@todo: write/send is missing) */
|
mbed714 |
0:d616ece2d859
|
256
|
#define netconn_is_nonblocking(conn) (((conn)->flags & NETCONN_FLAG_NON_BLOCKING) != 0)
|
mbed714 |
0:d616ece2d859
|
257
|
|
mbed714 |
0:d616ece2d859
|
258
|
/** TCP: Set the no-auto-recved status of netconn calls (see NETCONN_FLAG_NO_AUTO_RECVED) */
|
mbed714 |
0:d616ece2d859
|
259
|
#define netconn_set_noautorecved(conn, val) do { if(val) { \
|
mbed714 |
0:d616ece2d859
|
260
|
(conn)->flags |= NETCONN_FLAG_NO_AUTO_RECVED; \
|
mbed714 |
0:d616ece2d859
|
261
|
} else { \
|
mbed714 |
0:d616ece2d859
|
262
|
(conn)->flags &= ~ NETCONN_FLAG_NO_AUTO_RECVED; }} while(0)
|
mbed714 |
0:d616ece2d859
|
263
|
/** TCP: Get the no-auto-recved status of netconn calls (see NETCONN_FLAG_NO_AUTO_RECVED) */
|
mbed714 |
0:d616ece2d859
|
264
|
#define netconn_get_noautorecved(conn) (((conn)->flags & NETCONN_FLAG_NO_AUTO_RECVED) != 0)
|
mbed714 |
0:d616ece2d859
|
265
|
|
mbed714 |
0:d616ece2d859
|
266
|
#if LWIP_SO_RCVTIMEO
|
mbed714 |
0:d616ece2d859
|
267
|
/** Set the receive timeout in milliseconds */
|
mbed714 |
0:d616ece2d859
|
268
|
#define netconn_set_recvtimeout(conn, timeout) ((conn)->recv_timeout = (timeout))
|
mbed714 |
0:d616ece2d859
|
269
|
/** Get the receive timeout in milliseconds */
|
mbed714 |
0:d616ece2d859
|
270
|
#define netconn_get_recvtimeout(conn) ((conn)->recv_timeout)
|
mbed714 |
0:d616ece2d859
|
271
|
#endif /* LWIP_SO_RCVTIMEO */
|
mbed714 |
0:d616ece2d859
|
272
|
#if LWIP_SO_RCVBUF
|
mbed714 |
0:d616ece2d859
|
273
|
/** Set the receive buffer in bytes */
|
mbed714 |
0:d616ece2d859
|
274
|
#define netconn_set_recvbufsize(conn, recvbufsize) ((conn)->recv_bufsize = (recvbufsize))
|
mbed714 |
0:d616ece2d859
|
275
|
/** Get the receive buffer in bytes */
|
mbed714 |
0:d616ece2d859
|
276
|
#define netconn_get_recvbufsize(conn) ((conn)->recv_bufsize)
|
mbed714 |
0:d616ece2d859
|
277
|
#endif /* LWIP_SO_RCVBUF*/
|
mbed714 |
0:d616ece2d859
|
278
|
|
mbed714 |
0:d616ece2d859
|
279
|
#ifdef __cplusplus
|
mbed714 |
0:d616ece2d859
|
280
|
}
|
mbed714 |
0:d616ece2d859
|
281
|
#endif
|
mbed714 |
0:d616ece2d859
|
282
|
|
mbed714 |
0:d616ece2d859
|
283
|
#endif /* LWIP_NETCONN */
|
mbed714 |
0:d616ece2d859
|
284
|
|
mbed714 |
0:d616ece2d859
|
285
|
#endif /* __LWIP_API_H__ */
|