Warning, cross-references for /kernel/include/lwip/api.h need to be fixed.
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032 #ifndef __LWIP_API_H__
0033 #define __LWIP_API_H__
0034
0035 #include "lwip/opt.h"
0036
0037 #if LWIP_NETCONN
0038
0039 #include <stddef.h>
0040
0041 #include "lwip/netbuf.h"
0042 #include "lwip/sys.h"
0043 #include "lwip/ip_addr.h"
0044 #include "lwip/err.h"
0045
0046 #ifdef __cplusplus
0047 extern "C" {
0048 #endif
0049
0050
0051
0052
0053
0054
0055 #define NETCONN_NOFLAG 0x00
0056 #define NETCONN_NOCOPY 0x00
0057 #define NETCONN_COPY 0x01
0058 #define NETCONN_MORE 0x02
0059
0060
0061 #define NETCONNTYPE_GROUP(t) (t&0xF0)
0062 #define NETCONNTYPE_DATAGRAM(t) (t&0xE0)
0063
0064 enum netconn_type {
0065 NETCONN_INVALID = 0,
0066
0067 NETCONN_TCP = 0x10,
0068
0069 NETCONN_UDP = 0x20,
0070 NETCONN_UDPLITE = 0x21,
0071 NETCONN_UDPNOCHKSUM= 0x22,
0072
0073 NETCONN_RAW = 0x40
0074 };
0075
0076 enum netconn_state {
0077 NETCONN_NONE,
0078 NETCONN_WRITE,
0079 NETCONN_LISTEN,
0080 NETCONN_CONNECT,
0081 NETCONN_CLOSE
0082 };
0083
0084 enum netconn_evt {
0085 NETCONN_EVT_RCVPLUS,
0086 NETCONN_EVT_RCVMINUS,
0087 NETCONN_EVT_SENDPLUS,
0088 NETCONN_EVT_SENDMINUS
0089 };
0090
0091 #if LWIP_IGMP
0092 enum netconn_igmp {
0093 NETCONN_JOIN,
0094 NETCONN_LEAVE
0095 };
0096 #endif
0097
0098
0099 struct ip_pcb;
0100 struct tcp_pcb;
0101 struct udp_pcb;
0102 struct raw_pcb;
0103 struct netconn;
0104
0105
0106 typedef void (* netconn_callback)(struct netconn *, enum netconn_evt, u16_t len);
0107
0108
0109 struct netconn {
0110
0111 enum netconn_type type;
0112
0113 enum netconn_state state;
0114
0115 union {
0116 struct ip_pcb *ip;
0117 struct tcp_pcb *tcp;
0118 struct udp_pcb *udp;
0119 struct raw_pcb *raw;
0120 } pcb;
0121
0122 err_t err;
0123
0124 sys_sem_t op_completed;
0125
0126
0127 sys_mbox_t recvmbox;
0128
0129
0130 sys_mbox_t acceptmbox;
0131
0132 int socket;
0133 #if LWIP_SO_RCVTIMEO
0134
0135
0136 int recv_timeout;
0137 #endif
0138 #if LWIP_SO_RCVBUF
0139
0140 int recv_bufsize;
0141 #endif
0142 s16_t recv_avail;
0143 #if LWIP_TCP
0144
0145
0146 struct api_msg_msg *write_msg;
0147
0148
0149 size_t write_offset;
0150 #if LWIP_TCPIP_CORE_LOCKING
0151
0152
0153
0154 u8_t write_delayed;
0155 #endif
0156 #endif
0157
0158 netconn_callback callback;
0159 };
0160
0161
0162 #define API_EVENT(c,e,l) if (c->callback) { \
0163 (*c->callback)(c, e, l); \
0164 }
0165
0166
0167 #define netconn_new(t) netconn_new_with_proto_and_callback(t, 0, NULL)
0168 #define netconn_new_with_callback(t, c) netconn_new_with_proto_and_callback(t, 0, c)
0169 struct
0170 netconn *netconn_new_with_proto_and_callback(enum netconn_type t, u8_t proto,
0171 netconn_callback callback);
0172 err_t netconn_delete (struct netconn *conn);
0173
0174 #define netconn_type(conn) (conn->type)
0175
0176 err_t netconn_getaddr (struct netconn *conn,
0177 struct ip_addr *addr,
0178 u16_t *port,
0179 u8_t local);
0180 #define netconn_peer(c,i,p) netconn_getaddr(c,i,p,0)
0181 #define netconn_addr(c,i,p) netconn_getaddr(c,i,p,1)
0182
0183 err_t netconn_bind (struct netconn *conn,
0184 struct ip_addr *addr,
0185 u16_t port);
0186 err_t netconn_connect (struct netconn *conn,
0187 struct ip_addr *addr,
0188 u16_t port);
0189 err_t netconn_disconnect (struct netconn *conn);
0190 err_t netconn_listen_with_backlog(struct netconn *conn, u8_t backlog);
0191 #define netconn_listen(conn) netconn_listen_with_backlog(conn, TCP_DEFAULT_LISTEN_BACKLOG)
0192 struct netconn * netconn_accept (struct netconn *conn);
0193 struct netbuf * netconn_recv (struct netconn *conn);
0194 err_t netconn_sendto (struct netconn *conn,
0195 struct netbuf *buf, struct ip_addr *addr, u16_t port);
0196 err_t netconn_send (struct netconn *conn,
0197 struct netbuf *buf);
0198 err_t netconn_write (struct netconn *conn,
0199 const void *dataptr, size_t size,
0200 u8_t apiflags);
0201 err_t netconn_close (struct netconn *conn);
0202
0203 #if LWIP_IGMP
0204 err_t netconn_join_leave_group (struct netconn *conn,
0205 struct ip_addr *multiaddr,
0206 struct ip_addr *interface,
0207 enum netconn_igmp join_or_leave);
0208 #endif
0209 #if LWIP_DNS
0210 err_t netconn_gethostbyname(const char *name, struct ip_addr *addr);
0211 #endif
0212
0213 #define netconn_err(conn) ((conn)->err)
0214 #define netconn_recv_bufsize(conn) ((conn)->recv_bufsize)
0215
0216 #ifdef __cplusplus
0217 }
0218 #endif
0219
0220 #endif
0221
0222 #endif