]>
Commit | Line | Data |
---|---|---|
fc2f9534 LP |
1 | /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/ |
2 | ||
3 | #pragma once | |
4 | ||
5 | /*** | |
6 | This file is part of systemd. | |
7 | ||
8 | Copyright 2013 Tom Gundersen <teg@jklm.no> | |
9 | ||
10 | systemd is free software; you can redistribute it and/or modify it | |
11 | under the terms of the GNU Lesser General Public License as published by | |
12 | the Free Software Foundation; either version 2.1 of the License, or | |
13 | (at your option) any later version. | |
14 | ||
15 | systemd is distributed in the hope that it will be useful, but | |
16 | WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
18 | Lesser General Public License for more details. | |
19 | ||
20 | You should have received a copy of the GNU Lesser General Public License | |
21 | along with systemd; If not, see <http://www.gnu.org/licenses/>. | |
22 | ***/ | |
23 | ||
24 | #include <inttypes.h> | |
25 | #include <stdbool.h> | |
26 | ||
27 | #include "in-addr-util.h" | |
28 | ||
29 | typedef struct Address Address; | |
30 | ||
31 | #include "networkd.h" | |
32 | #include "networkd-network.h" | |
33 | #include "networkd-link.h" | |
34 | ||
35 | #define CACHE_INFO_INFINITY_LIFE_TIME 0xFFFFFFFFU | |
36 | ||
37 | struct Address { | |
38 | Network *network; | |
39 | unsigned section; | |
40 | ||
cf1d700d TG |
41 | Link *link; |
42 | ||
fc2f9534 LP |
43 | int family; |
44 | unsigned char prefixlen; | |
45 | unsigned char scope; | |
46 | uint32_t flags; | |
47 | char *label; | |
48 | ||
49 | struct in_addr broadcast; | |
50 | struct ifa_cacheinfo cinfo; | |
51 | ||
52 | union in_addr_union in_addr; | |
53 | union in_addr_union in_addr_peer; | |
54 | ||
adda1ed9 | 55 | bool ip_masquerade_done:1; |
fc2f9534 LP |
56 | |
57 | LIST_FIELDS(Address, addresses); | |
58 | }; | |
59 | ||
60 | int address_new_static(Network *network, unsigned section, Address **ret); | |
f0213e37 | 61 | int address_new(Address **ret); |
fc2f9534 | 62 | void address_free(Address *address); |
adda1ed9 | 63 | int address_add_foreign(Link *link, int family, const union in_addr_union *in_addr, unsigned char prefixlen, Address **ret); |
c4a03a56 | 64 | int address_add(Link *link, int family, const union in_addr_union *in_addr, unsigned char prefixlen, Address **ret); |
cf1d700d | 65 | int address_get(Link *link, int family, const union in_addr_union *in_addr, unsigned char prefixlen, Address **ret); |
36c32f61 | 66 | int address_update(Address *address, unsigned char flags, unsigned char scope, struct ifa_cacheinfo *cinfo); |
91b5f997 | 67 | int address_drop(Address *address); |
66669078 | 68 | int address_configure(Address *address, Link *link, sd_netlink_message_handler_t callback, bool update); |
91b5f997 | 69 | int address_remove(Address *address, Link *link, sd_netlink_message_handler_t callback); |
fc2f9534 | 70 | bool address_equal(Address *a1, Address *a2); |
ce6c77eb | 71 | bool address_is_ready(const Address *a); |
fc2f9534 LP |
72 | |
73 | DEFINE_TRIVIAL_CLEANUP_FUNC(Address*, address_free); | |
74 | #define _cleanup_address_free_ _cleanup_(address_freep) | |
75 | ||
76 | 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); | |
77 | 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); | |
78 | 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); |