]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/network/networkd-address.h
tree-wide: beautify remaining copyright statements
[thirdparty/systemd.git] / src / network / networkd-address.h
1 /* SPDX-License-Identifier: LGPL-2.1+ */
2 #pragma once
3
4 /***
5 Copyright © 2013 Tom Gundersen <teg@jklm.no>
6 ***/
7
8 #include <inttypes.h>
9 #include <stdbool.h>
10
11 #include "conf-parser.h"
12 #include "in-addr-util.h"
13
14 typedef struct Address Address;
15
16 #include "networkd-link.h"
17 #include "networkd-network.h"
18
19 #define CACHE_INFO_INFINITY_LIFE_TIME 0xFFFFFFFFU
20
21 typedef struct Network Network;
22 typedef struct Link Link;
23 typedef struct NetworkConfigSection NetworkConfigSection;
24
25 struct Address {
26 Network *network;
27 NetworkConfigSection *section;
28
29 Link *link;
30
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
43 bool ip_masquerade_done:1;
44 bool duplicate_address_detection;
45 bool manage_temporary_address;
46 bool home_address;
47 bool prefix_route;
48 bool autojoin;
49
50 LIST_FIELDS(Address, addresses);
51 };
52
53 int address_new_static(Network *network, const char *filename, unsigned section, Address **ret);
54 int address_new(Address **ret);
55 void address_free(Address *address);
56 int address_add_foreign(Link *link, int family, const union in_addr_union *in_addr, unsigned char prefixlen, Address **ret);
57 int address_add(Link *link, int family, const union in_addr_union *in_addr, unsigned char prefixlen, Address **ret);
58 int address_get(Link *link, int family, const union in_addr_union *in_addr, unsigned char prefixlen, Address **ret);
59 int address_update(Address *address, unsigned char flags, unsigned char scope, const struct ifa_cacheinfo *cinfo);
60 int address_drop(Address *address);
61 int address_configure(Address *address, Link *link, sd_netlink_message_handler_t callback, bool update);
62 int address_remove(Address *address, Link *link, sd_netlink_message_handler_t callback);
63 bool address_equal(Address *a1, Address *a2);
64 bool address_is_ready(const Address *a);
65
66 DEFINE_TRIVIAL_CLEANUP_FUNC(Address*, address_free);
67
68 CONFIG_PARSER_PROTOTYPE(config_parse_address);
69 CONFIG_PARSER_PROTOTYPE(config_parse_broadcast);
70 CONFIG_PARSER_PROTOTYPE(config_parse_label);
71 CONFIG_PARSER_PROTOTYPE(config_parse_lifetime);
72 CONFIG_PARSER_PROTOTYPE(config_parse_address_flags);
73 CONFIG_PARSER_PROTOTYPE(config_parse_address_scope);