1 /*
2  * Copyright (c) 2018 Linaro Limited.
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 /**
8  * @file
9  * @brief Socket Offload Redirect API
10  */
11 
12 #ifndef ZEPHYR_INCLUDE_NET_SOCKET_OFFLOAD_H_
13 #define ZEPHYR_INCLUDE_NET_SOCKET_OFFLOAD_H_
14 
15 #include <zephyr/net/net_ip.h>
16 #include <zephyr/net/socket.h>
17 
18 #ifdef __cplusplus
19 extern "C" {
20 #endif
21 
22 /**
23  * @brief An offloaded Socket DNS API interface
24  *
25  * It is assumed that these offload functions follow the
26  * POSIX socket API standard for arguments, return values and setting of errno.
27  */
28 struct socket_dns_offload {
29 	/** DNS getaddrinfo offloaded implementation API */
30 	int (*getaddrinfo)(const char *node, const char *service,
31 			   const struct zsock_addrinfo *hints,
32 			   struct zsock_addrinfo **res);
33 	/** DNS freeaddrinfo offloaded implementation API */
34 	void (*freeaddrinfo)(struct zsock_addrinfo *res);
35 };
36 
37 /**
38  * @brief Register an offloaded socket DNS API interface.
39  *
40  * @param ops A pointer to the offloaded socket DNS API interface.
41  */
42 void socket_offload_dns_register(const struct socket_dns_offload *ops);
43 
44 /** @cond INTERNAL_HIDDEN */
45 
46 int socket_offload_getaddrinfo(const char *node, const char *service,
47 			       const struct zsock_addrinfo *hints,
48 			       struct zsock_addrinfo **res);
49 
50 void socket_offload_freeaddrinfo(struct zsock_addrinfo *res);
51 
52 /** @endcond */
53 
54 #ifdef __cplusplus
55 }
56 #endif
57 
58 #endif /* ZEPHYR_INCLUDE_NET_SOCKET_OFFLOAD_H_ */
59