1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
2 #pragma once
3 
4 #include "in-addr-util.h"
5 #include "macro.h"
6 #include "socket-util.h"
7 
8 int make_socket_fd(int log_level, const char* address, int type, int flags);
9 
10 int socket_address_parse(SocketAddress *a, const char *s);
11 int socket_address_parse_and_warn(SocketAddress *a, const char *s);
12 int socket_address_parse_netlink(SocketAddress *a, const char *s);
13 
14 bool socket_address_is(const SocketAddress *a, const char *s, int type);
15 bool socket_address_is_netlink(const SocketAddress *a, const char *s);
16 
17 int in_addr_port_ifindex_name_from_string_auto(
18                 const char *s,
19                 int *ret_family,
20                 union in_addr_union *ret_address,
21                 uint16_t *ret_port,
22                 int *ret_ifindex,
23                 char **ret_server_name);
in_addr_ifindex_name_from_string_auto(const char * s,int * family,union in_addr_union * ret,int * ifindex,char ** server_name)24 static inline int in_addr_ifindex_name_from_string_auto(const char *s, int *family, union in_addr_union *ret, int *ifindex, char **server_name) {
25         return in_addr_port_ifindex_name_from_string_auto(s, family, ret, NULL, ifindex, server_name);
26 }
in_addr_ifindex_from_string_auto(const char * s,int * family,union in_addr_union * ret,int * ifindex)27 static inline int in_addr_ifindex_from_string_auto(const char *s, int *family, union in_addr_union *ret, int *ifindex) {
28         return in_addr_ifindex_name_from_string_auto(s, family, ret, ifindex, NULL);
29 }
30 
31 struct in_addr_full {
32         int family;
33         union in_addr_union address;
34         uint16_t port;
35         int ifindex;
36         char *server_name;
37         char *cached_server_string; /* Should not be handled directly, but through in_addr_full_to_string(). */
38 };
39 
40 struct in_addr_full *in_addr_full_free(struct in_addr_full *a);
41 DEFINE_TRIVIAL_CLEANUP_FUNC(struct in_addr_full*, in_addr_full_free);
42 int in_addr_full_new(int family, const union in_addr_union *a, uint16_t port, int ifindex, const char *server_name, struct in_addr_full **ret);
43 int in_addr_full_new_from_string(const char *s, struct in_addr_full **ret);
44 const char *in_addr_full_to_string(struct in_addr_full *a);
45