1 /*
2  * Copyright (c) 2018 Linaro Limited.
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 #include <zephyr/logging/log.h>
8 LOG_MODULE_REGISTER(net_socket_offload, CONFIG_NET_SOCKETS_LOG_LEVEL);
9 
10 #include <zephyr/net/socket_offload.h>
11 #include <zephyr/net/socket.h>
12 
13 #include "sockets_internal.h"
14 
15 const struct socket_dns_offload *dns_offload;
16 
socket_offload_dns_register(const struct socket_dns_offload * ops)17 void socket_offload_dns_register(const struct socket_dns_offload *ops)
18 {
19 	__ASSERT_NO_MSG(ops);
20 	__ASSERT_NO_MSG(dns_offload == NULL);
21 
22 	dns_offload = ops;
23 }
24 
socket_offload_getaddrinfo(const char * node,const char * service,const struct zsock_addrinfo * hints,struct zsock_addrinfo ** res)25 int socket_offload_getaddrinfo(const char *node, const char *service,
26 			       const struct zsock_addrinfo *hints,
27 			       struct zsock_addrinfo **res)
28 {
29 	__ASSERT_NO_MSG(dns_offload);
30 	__ASSERT_NO_MSG(dns_offload->getaddrinfo);
31 
32 	return dns_offload->getaddrinfo(node, service, hints, res);
33 }
34 
socket_offload_freeaddrinfo(struct zsock_addrinfo * res)35 void socket_offload_freeaddrinfo(struct zsock_addrinfo *res)
36 {
37 	__ASSERT_NO_MSG(dns_offload);
38 	__ASSERT_NO_MSG(dns_offload->freeaddrinfo);
39 
40 	dns_offload->freeaddrinfo(res);
41 }
42