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