1 /* SPDX-License-Identifier: LGPL-2.1+ */
7 #include "conf-parser.h"
8 #include "in-addr-util.h"
10 typedef struct Address Address
;
12 #include "networkd-link.h"
13 #include "networkd-network.h"
14 #include "networkd-util.h"
16 #include "sd-ipv4acd.h"
18 #define CACHE_INFO_INFINITY_LIFE_TIME 0xFFFFFFFFU
20 typedef struct Network Network
;
21 typedef struct Link Link
;
22 typedef struct NetworkConfigSection NetworkConfigSection
;
23 typedef int (*address_ready_callback_t
)(Address
*address
);
27 NetworkConfigSection
*section
;
32 unsigned char prefixlen
;
37 struct in_addr broadcast
;
38 struct ifa_cacheinfo cinfo
;
40 union in_addr_union in_addr
;
41 union in_addr_union in_addr_peer
;
44 bool ip_masquerade_done
:1;
45 bool manage_temporary_address
:1;
49 AddressFamily duplicate_address_detection
;
51 /* Called when address become ready */
52 address_ready_callback_t callback
;
56 LIST_FIELDS(Address
, addresses
);
59 int address_new(Address
**ret
);
60 void address_free(Address
*address
);
61 int address_add_foreign(Link
*link
, int family
, const union in_addr_union
*in_addr
, unsigned char prefixlen
, Address
**ret
);
62 int address_add(Link
*link
, int family
, const union in_addr_union
*in_addr
, unsigned char prefixlen
, Address
**ret
);
63 int address_get(Link
*link
, int family
, const union in_addr_union
*in_addr
, unsigned char prefixlen
, Address
**ret
);
64 bool address_exists(Link
*link
, int family
, const union in_addr_union
*in_addr
);
65 int address_update(Address
*address
, unsigned char flags
, unsigned char scope
, const struct ifa_cacheinfo
*cinfo
);
66 int address_drop(Address
*address
);
67 int address_configure(Address
*address
, Link
*link
, link_netlink_message_handler_t callback
, bool update
, Address
**ret
);
68 int address_remove(Address
*address
, Link
*link
, link_netlink_message_handler_t callback
);
69 bool address_equal(Address
*a1
, Address
*a2
);
70 bool address_is_ready(const Address
*a
);
71 int address_section_verify(Address
*a
);
72 int configure_ipv4_duplicate_address_detection(Link
*link
, Address
*address
);
74 int generate_ipv6_eui_64_address(Link
*link
, struct in6_addr
*ret
);
76 DEFINE_NETWORK_SECTION_FUNCTIONS(Address
, address_free
);
78 void address_hash_func(const Address
*a
, struct siphash
*state
);
79 int address_compare_func(const Address
*a1
, const Address
*a2
);
80 extern const struct hash_ops address_hash_ops
;
82 CONFIG_PARSER_PROTOTYPE(config_parse_address
);
83 CONFIG_PARSER_PROTOTYPE(config_parse_broadcast
);
84 CONFIG_PARSER_PROTOTYPE(config_parse_label
);
85 CONFIG_PARSER_PROTOTYPE(config_parse_lifetime
);
86 CONFIG_PARSER_PROTOTYPE(config_parse_address_flags
);
87 CONFIG_PARSER_PROTOTYPE(config_parse_address_scope
);
88 CONFIG_PARSER_PROTOTYPE(config_parse_duplicate_address_detection
);