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