1 /* 2 * Copyright (c) 2019 Linaro Limited 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 /** 8 * @file 9 * @brief Socket utility functions. 10 */ 11 12 #ifndef ZEPHYR_INCLUDE_NET_SOCKETUTILS_H_ 13 #define ZEPHYR_INCLUDE_NET_SOCKETUTILS_H_ 14 15 #include <zephyr/net/socket.h> 16 17 /** 18 * @brief Find port in addr:port string. 19 * 20 * @param addr_str String of addr[:port] format 21 * 22 * @return Pointer to "port" part, or NULL is none. 23 */ 24 const char *net_addr_str_find_port(const char *addr_str); 25 26 /** 27 * @brief Call getaddrinfo() on addr:port string 28 * 29 * Convenience function to split addr[:port] string into address vs port 30 * components (or use default port number), and call getaddrinfo() on the 31 * result. 32 * 33 * @param addr_str String of addr[:port] format 34 * @param def_port Default port number to use if addr_str doesn't contain it 35 * @param hints getaddrinfo() hints 36 * @param res Result of getaddrinfo() (freeaddrinfo() should be called on it 37 * as usual. 38 * 39 * @return Result of getaddrinfo() call. 40 */ 41 int net_getaddrinfo_addr_str(const char *addr_str, const char *def_port, 42 const struct zsock_addrinfo *hints, 43 struct zsock_addrinfo **res); 44 45 #endif /* ZEPHYR_INCLUDE_NET_SOCKETUTILS_H_ */ 46