]>
Commit | Line | Data |
---|---|---|
53e1b683 | 1 | /* SPDX-License-Identifier: LGPL-2.1+ */ |
fc2f9534 LP |
2 | #pragma once |
3 | ||
fc2f9534 LP |
4 | #include <inttypes.h> |
5 | #include <stdbool.h> | |
6 | ||
a2106925 | 7 | #include "conf-parser.h" |
fc2f9534 LP |
8 | #include "in-addr-util.h" |
9 | ||
10 | typedef struct Address Address; | |
11 | ||
fc2f9534 | 12 | #include "networkd-link.h" |
71d35b6b | 13 | #include "networkd-network.h" |
fcbf4cb7 | 14 | #include "networkd-util.h" |
fc2f9534 | 15 | |
051e77ca SS |
16 | #include "sd-ipv4acd.h" |
17 | ||
fc2f9534 LP |
18 | #define CACHE_INFO_INFINITY_LIFE_TIME 0xFFFFFFFFU |
19 | ||
634f0f98 ZJS |
20 | typedef struct Network Network; |
21 | typedef struct Link Link; | |
f4859fc7 | 22 | typedef struct NetworkConfigSection NetworkConfigSection; |
634f0f98 | 23 | |
fc2f9534 LP |
24 | struct Address { |
25 | Network *network; | |
f4859fc7 | 26 | NetworkConfigSection *section; |
fc2f9534 | 27 | |
cf1d700d TG |
28 | Link *link; |
29 | ||
fc2f9534 LP |
30 | int family; |
31 | unsigned char prefixlen; | |
32 | unsigned char scope; | |
33 | uint32_t flags; | |
34 | char *label; | |
35 | ||
36 | struct in_addr broadcast; | |
37 | struct ifa_cacheinfo cinfo; | |
38 | ||
39 | union in_addr_union in_addr; | |
40 | union in_addr_union in_addr_peer; | |
41 | ||
adda1ed9 | 42 | bool ip_masquerade_done:1; |
051e77ca SS |
43 | bool manage_temporary_address:1; |
44 | bool home_address:1; | |
45 | bool prefix_route:1; | |
46 | bool autojoin:1; | |
47 | AddressFamily duplicate_address_detection; | |
48 | ||
49 | sd_ipv4acd *acd; | |
fc2f9534 LP |
50 | |
51 | LIST_FIELDS(Address, addresses); | |
52 | }; | |
53 | ||
f0213e37 | 54 | int address_new(Address **ret); |
fc2f9534 | 55 | void address_free(Address *address); |
adda1ed9 | 56 | int address_add_foreign(Link *link, int family, const union in_addr_union *in_addr, unsigned char prefixlen, Address **ret); |
c4a03a56 | 57 | int address_add(Link *link, int family, const union in_addr_union *in_addr, unsigned char prefixlen, Address **ret); |
cf1d700d | 58 | int address_get(Link *link, int family, const union in_addr_union *in_addr, unsigned char prefixlen, Address **ret); |
889b550f | 59 | int address_update(Address *address, unsigned char flags, unsigned char scope, const struct ifa_cacheinfo *cinfo); |
91b5f997 | 60 | int address_drop(Address *address); |
302a796f YW |
61 | int address_configure(Address *address, Link *link, link_netlink_message_handler_t callback, bool update); |
62 | int address_remove(Address *address, Link *link, link_netlink_message_handler_t callback); | |
fc2f9534 | 63 | bool address_equal(Address *a1, Address *a2); |
ce6c77eb | 64 | bool address_is_ready(const Address *a); |
fcbf4cb7 | 65 | int address_section_verify(Address *a); |
051e77ca | 66 | int configure_ipv4_duplicate_address_detection(Link *link, Address *address); |
fc2f9534 | 67 | |
fcbf4cb7 | 68 | DEFINE_NETWORK_SECTION_FUNCTIONS(Address, address_free); |
fc2f9534 | 69 | |
8a98f11e KF |
70 | extern const struct hash_ops address_hash_ops; |
71 | ||
a2106925 LP |
72 | CONFIG_PARSER_PROTOTYPE(config_parse_address); |
73 | CONFIG_PARSER_PROTOTYPE(config_parse_broadcast); | |
74 | CONFIG_PARSER_PROTOTYPE(config_parse_label); | |
75 | CONFIG_PARSER_PROTOTYPE(config_parse_lifetime); | |
76 | CONFIG_PARSER_PROTOTYPE(config_parse_address_flags); | |
77 | CONFIG_PARSER_PROTOTYPE(config_parse_address_scope); | |
051e77ca | 78 | CONFIG_PARSER_PROTOTYPE(config_parse_duplicate_address_detection); |