]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/network/networkd-address.h
network: make address/route_configure optionally return created Address/Route object
[thirdparty/systemd.git] / src / network / networkd-address.h
CommitLineData
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
10typedef 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
20typedef struct Network Network;
21typedef struct Link Link;
f4859fc7 22typedef struct NetworkConfigSection NetworkConfigSection;
97f00074 23typedef int (*address_ready_callback_t)(Address *address);
634f0f98 24
fc2f9534
LP
25struct Address {
26 Network *network;
f4859fc7 27 NetworkConfigSection *section;
fc2f9534 28
cf1d700d
TG
29 Link *link;
30
fc2f9534
LP
31 int family;
32 unsigned char prefixlen;
33 unsigned char scope;
34 uint32_t flags;
35 char *label;
36
37 struct in_addr broadcast;
38 struct ifa_cacheinfo cinfo;
39
40 union in_addr_union in_addr;
41 union in_addr_union in_addr_peer;
42
07336a06 43 bool scope_set:1;
adda1ed9 44 bool ip_masquerade_done:1;
051e77ca
SS
45 bool manage_temporary_address:1;
46 bool home_address:1;
47 bool prefix_route:1;
48 bool autojoin:1;
49 AddressFamily duplicate_address_detection;
50
97f00074
YW
51 /* Called when address become ready */
52 address_ready_callback_t callback;
53
051e77ca 54 sd_ipv4acd *acd;
fc2f9534
LP
55
56 LIST_FIELDS(Address, addresses);
57};
58
f0213e37 59int address_new(Address **ret);
fc2f9534 60void address_free(Address *address);
adda1ed9 61int address_add_foreign(Link *link, int family, const union in_addr_union *in_addr, unsigned char prefixlen, Address **ret);
c4a03a56 62int address_add(Link *link, int family, const union in_addr_union *in_addr, unsigned char prefixlen, Address **ret);
cf1d700d 63int address_get(Link *link, int family, const union in_addr_union *in_addr, unsigned char prefixlen, Address **ret);
5eec0a08 64bool address_exists(Link *link, int family, const union in_addr_union *in_addr);
889b550f 65int address_update(Address *address, unsigned char flags, unsigned char scope, const struct ifa_cacheinfo *cinfo);
91b5f997 66int address_drop(Address *address);
80b0e860 67int address_configure(Address *address, Link *link, link_netlink_message_handler_t callback, bool update, Address **ret);
302a796f 68int address_remove(Address *address, Link *link, link_netlink_message_handler_t callback);
fc2f9534 69bool address_equal(Address *a1, Address *a2);
ce6c77eb 70bool address_is_ready(const Address *a);
fcbf4cb7 71int address_section_verify(Address *a);
051e77ca 72int configure_ipv4_duplicate_address_detection(Link *link, Address *address);
fc2f9534 73
5ead5352
SS
74int generate_ipv6_eui_64_address(Link *link, struct in6_addr *ret);
75
fcbf4cb7 76DEFINE_NETWORK_SECTION_FUNCTIONS(Address, address_free);
fc2f9534 77
8a98f11e
KF
78extern const struct hash_ops address_hash_ops;
79
a2106925
LP
80CONFIG_PARSER_PROTOTYPE(config_parse_address);
81CONFIG_PARSER_PROTOTYPE(config_parse_broadcast);
82CONFIG_PARSER_PROTOTYPE(config_parse_label);
83CONFIG_PARSER_PROTOTYPE(config_parse_lifetime);
84CONFIG_PARSER_PROTOTYPE(config_parse_address_flags);
85CONFIG_PARSER_PROTOTYPE(config_parse_address_scope);
051e77ca 86CONFIG_PARSER_PROTOTYPE(config_parse_duplicate_address_detection);