sock_types.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2016 Freie Universit├Ąt Berlin
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser
5  * General Public License v2.1. See the file LICENSE in the top level
6  * directory for more details.
7  */
8 
18 #ifndef SOCK_TYPES_H
19 #define SOCK_TYPES_H
20 
21 #include "net/af.h"
22 #include "lwip/api.h"
23 #ifdef SOCK_HAS_ASYNC
24 #include "net/sock/async/types.h"
25 #endif
26 
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30 
35 typedef struct lwip_sock_base lwip_sock_base_t;
36 
37 #ifdef SOCK_HAS_ASYNC
42 typedef void (*lwip_sock_cb_t)(lwip_sock_base_t *sock,
43  sock_async_flags_t flags,
44  void *arg);
45 #endif /* SOCK_HAS_ASYNC */
46 
54  struct netconn *conn;
55 #ifdef SOCK_HAS_ASYNC
62  union {
63  lwip_sock_cb_t gen;
64 #ifdef MODULE_SOCK_IP
65  sock_ip_cb_t ip;
66 #endif
67 #ifdef MODULE_SOCK_TCP
68  sock_tcp_cb_t tcp;
72  sock_tcp_queue_cb_t tcp_queue;
73 #endif
74 #ifdef MODULE_SOCK_UDP
75  sock_udp_cb_t udp;
76 #endif
77  } async_cb;
78  void *async_cb_arg;
79 #ifdef SOCK_HAS_ASYNC_CTX
80  sock_async_ctx_t async_ctx;
81 #endif /* SOCK_HAS_ASYNC_CTX */
82 #endif /* SOCK_HAS_ASYNC */
83 };
84 
91 struct sock_ip {
93 };
94 
101 struct sock_tcp {
105  struct pbuf *last_buf;
106  ssize_t last_offset;
107 };
108 
116  struct sock_tcp *array;
118  unsigned short len;
119  unsigned short used;
120 };
121 
128 struct sock_udp {
130 };
131 
132 #ifdef __cplusplus
133 }
134 #endif
135 
136 #endif /* SOCK_TYPES_H */
Global UNIX address family definitions.
void(* sock_tcp_queue_cb_t)(sock_tcp_queue_t *queue, sock_async_flags_t flags, void *arg)
Event callback for sock_tcp_queue_t.
Definition: types.h:133
sock_async_flags_t
Flag types to signify asynchronous sock events.
Definition: types.h:37
void(* sock_tcp_cb_t)(sock_tcp_t *sock, sock_async_flags_t flags, void *arg)
Event callback for sock_tcp_t.
Definition: types.h:117
void(* sock_ip_cb_t)(sock_ip_t *sock, sock_async_flags_t flags, void *arg)
Event callback for sock_ip_t.
Definition: types.h:91
void(* sock_udp_cb_t)(sock_udp_t *sock, sock_async_flags_t type, void *arg)
Event callback for sock_udp_t.
Definition: types.h:157
Sock base type.
Definition: sock_types.h:53
struct netconn * conn
lwIP network connection object
Definition: sock_types.h:54
Mutex structure.
Definition: mutex.h:123
Asynchronous context for Asynchronous sock with event API.
Raw IP sock type.
Definition: sock_types.h:91
lwip_sock_base_t base
parent class
Definition: sock_types.h:92
TCP queue type.
Definition: sock_types.h:114
lwip_sock_base_t base
parent class
Definition: sock_types.h:115
unsigned short len
Length of the struct sock_tcp_queue::array.
Definition: sock_types.h:118
struct sock_tcp * array
Allocation array for sock objects to generate.
Definition: sock_types.h:116
unsigned short used
Used entries in struct sock_tcp_queue::array.
Definition: sock_types.h:119
mutex_t mutex
Mutex to protect the queue.
Definition: sock_types.h:117
TCP sock type.
Definition: sock_types.h:101
mutex_t mutex
Mutex to protect the sock.
Definition: sock_types.h:104
lwip_sock_base_t base
parent class
Definition: sock_types.h:102
ssize_t last_offset
Offset in struct sock_tcp::last_buf since last read.
Definition: sock_types.h:106
struct sock_tcp_queue * queue
Queue the sock might have been generated from.
Definition: sock_types.h:103
struct pbuf * last_buf
Last received data.
Definition: sock_types.h:105
UDP sock type.
Definition: sock_types.h:128
lwip_sock_base_t base
parent class
Definition: sock_types.h:129
Definitions for sock extension for asynchronous access.