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