ip.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2016 Alexander Aring <aar@pengutronix.de>
3  * Freie Universität Berlin
4  * HAW Hamburg
5  * Kaspar Schleiser <kaspar@schleiser.de>
6  *
7  * This file is subject to the terms and conditions of the GNU Lesser
8  * General Public License v2.1. See the file LICENSE in the top level
9  * directory for more details.
10  */
11 
268 #ifndef NET_SOCK_IP_H
269 #define NET_SOCK_IP_H
270 
271 #include <stdint.h>
272 #include <stdlib.h>
273 #include <sys/types.h>
274 
275 /* net/sock/async/types.h included by net/sock.h needs to re-typedef the
276  * `sock_ip_t` to prevent cyclic includes */
277 #if defined (__clang__)
278 # pragma clang diagnostic push
279 # pragma clang diagnostic ignored "-Wtypedef-redefinition"
280 #endif
281 
282 #include "net/sock.h"
283 
284 #ifdef __cplusplus
285 extern "C" {
286 #endif
287 
294 typedef struct sock_ip sock_ip_t;
295 
296 #if defined (__clang__)
297 # pragma clang diagnostic pop
298 #endif
299 
342 int sock_ip_create(sock_ip_t *sock, const sock_ip_ep_t *local,
343  const sock_ip_ep_t *remote, uint8_t proto, uint16_t flags);
344 
352 void sock_ip_close(sock_ip_t *sock);
353 
373 
393 
425 ssize_t sock_ip_recv(sock_ip_t *sock, void *data, size_t max_len,
426  uint32_t timeout, sock_ip_ep_t *remote);
427 
470 ssize_t sock_ip_recv_buf(sock_ip_t *sock, void **data, void **buf_ctx,
471  uint32_t timeout, sock_ip_ep_t *remote);
472 
505 ssize_t sock_ip_send(sock_ip_t *sock, const void *data, size_t len,
506  uint8_t proto, const sock_ip_ep_t *remote);
507 
508 #include "sock_types.h"
509 
510 #ifdef __cplusplus
511 }
512 #endif
513 
514 #endif /* NET_SOCK_IP_H */
515 
sock_ip
Raw IP sock type.
Definition: sock_types.h:91
sock_ip::remote
sock_ip_ep_t remote
remote end-point
Definition: sock_types.h:124
sock_ip_get_remote
int sock_ip_get_remote(sock_ip_t *sock, sock_ip_ep_t *ep)
Gets the remote end point of a raw IPv4/IPv6 sock object.
sock_ip::local
sock_ip_ep_t local
local end-point
Definition: sock_types.h:123
sock_ip_create
int sock_ip_create(sock_ip_t *sock, const sock_ip_ep_t *local, const sock_ip_ep_t *remote, uint8_t proto, uint16_t flags)
Creates a new raw IPv4/IPv6 sock object.
sock_ip::flags
uint16_t flags
option flags
Definition: sock_types.h:125
sock_ip_recv_buf
ssize_t sock_ip_recv_buf(sock_ip_t *sock, void **data, void **buf_ctx, uint32_t timeout, sock_ip_ep_t *remote)
Provides stack-internal buffer space containing an IPv4/IPv6 message from remote end point.
sock_ip_close
void sock_ip_close(sock_ip_t *sock)
Closes a raw IPv4/IPv6 sock object.
sock_ip_recv
ssize_t sock_ip_recv(sock_ip_t *sock, void *data, size_t max_len, uint32_t timeout, sock_ip_ep_t *remote)
Receives a message over IPv4/IPv6 from remote end point.
sock_ip_send
ssize_t sock_ip_send(sock_ip_t *sock, const void *data, size_t len, uint8_t proto, const sock_ip_ep_t *remote)
Sends a message over IPv4/IPv6 to remote end point.
sock_ip_get_local
int sock_ip_get_local(sock_ip_t *sock, sock_ip_ep_t *ep)
Gets the local end point of a raw IPv4/IPv6 sock object.
sock.h
Common sock API definitions.
sock_ip_ep_t
Abstract IP end point and end point for a raw IP sock object.
Definition: sock.h:176