]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/network/networkd-address.h
Merge pull request #7388 from keszybz/doc-tweak
[thirdparty/systemd.git] / src / network / networkd-address.h
1 #pragma once
2
3 /***
4 This file is part of systemd.
5
6 Copyright 2013 Tom Gundersen <teg@jklm.no>
7
8 systemd is free software; you can redistribute it and/or modify it
9 under the terms of the GNU Lesser General Public License as published by
10 the Free Software Foundation; either version 2.1 of the License, or
11 (at your option) any later version.
12
13 systemd is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Lesser General Public License for more details.
17
18 You should have received a copy of the GNU Lesser General Public License
19 along with systemd; If not, see <http://www.gnu.org/licenses/>.
20 ***/
21
22 #include <inttypes.h>
23 #include <stdbool.h>
24
25 #include "in-addr-util.h"
26
27 typedef struct Address Address;
28 typedef struct Prefix Prefix;
29
30 #include "networkd-link.h"
31 #include "networkd-network.h"
32
33 #define CACHE_INFO_INFINITY_LIFE_TIME 0xFFFFFFFFU
34
35 typedef struct Network Network;
36 typedef struct Link Link;
37 typedef struct NetworkConfigSection NetworkConfigSection;
38
39 struct Prefix {
40 Network *network;
41 NetworkConfigSection *section;
42
43 sd_radv_prefix *radv_prefix;
44
45 LIST_FIELDS(Prefix, prefixes);
46 };
47
48 struct Address {
49 Network *network;
50 NetworkConfigSection *section;
51
52 Link *link;
53
54 int family;
55 unsigned char prefixlen;
56 unsigned char scope;
57 uint32_t flags;
58 char *label;
59
60 struct in_addr broadcast;
61 struct ifa_cacheinfo cinfo;
62
63 union in_addr_union in_addr;
64 union in_addr_union in_addr_peer;
65
66 bool ip_masquerade_done:1;
67 bool duplicate_address_detection;
68 bool manage_temporary_address;
69 bool home_address;
70 bool prefix_route;
71 bool autojoin;
72
73 LIST_FIELDS(Address, addresses);
74 };
75
76 int address_new_static(Network *network, const char *filename, unsigned section, Address **ret);
77 int address_new(Address **ret);
78 void address_free(Address *address);
79 int address_add_foreign(Link *link, int family, const union in_addr_union *in_addr, unsigned char prefixlen, Address **ret);
80 int address_add(Link *link, int family, const union in_addr_union *in_addr, unsigned char prefixlen, Address **ret);
81 int address_get(Link *link, int family, const union in_addr_union *in_addr, unsigned char prefixlen, Address **ret);
82 int address_update(Address *address, unsigned char flags, unsigned char scope, const struct ifa_cacheinfo *cinfo);
83 int address_drop(Address *address);
84 int address_configure(Address *address, Link *link, sd_netlink_message_handler_t callback, bool update);
85 int address_remove(Address *address, Link *link, sd_netlink_message_handler_t callback);
86 bool address_equal(Address *a1, Address *a2);
87 bool address_is_ready(const Address *a);
88
89 DEFINE_TRIVIAL_CLEANUP_FUNC(Address*, address_free);
90 #define _cleanup_address_free_ _cleanup_(address_freep)
91
92 int prefix_new(Prefix **ret);
93 void prefix_free(Prefix *prefix);
94 int prefix_new_static(Network *network, const char *filename, unsigned section,
95 Prefix **ret);
96
97 DEFINE_TRIVIAL_CLEANUP_FUNC(Prefix*, prefix_free);
98 #define _cleanup_prefix_free_ _cleanup_(prefix_freep)
99
100 int config_parse_address(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
101 int config_parse_broadcast(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
102 int config_parse_label(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
103 int config_parse_lifetime(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
104 int config_parse_address_flags(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
105 int config_parse_address_scope(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
106 int config_parse_router_preference(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
107 int config_parse_prefix(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
108 int config_parse_prefix_flags(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
109 int config_parse_prefix_lifetime(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);