]> git.proxmox.com Git - systemd.git/blame - src/network/networkd-address.h
Merge tag 'upstream/229'
[systemd.git] / src / network / networkd-address.h
CommitLineData
d9dfd233
MP
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
27typedef struct Address Address;
28
d9dfd233 29#include "networkd-link.h"
4c89c718
MP
30#include "networkd-network.h"
31#include "networkd.h"
d9dfd233
MP
32
33#define CACHE_INFO_INFINITY_LIFE_TIME 0xFFFFFFFFU
34
35struct Address {
36 Network *network;
37 unsigned section;
38
db2df898
MP
39 Link *link;
40
d9dfd233
MP
41 int family;
42 unsigned char prefixlen;
43 unsigned char scope;
44 uint32_t flags;
45 char *label;
46
47 struct in_addr broadcast;
48 struct ifa_cacheinfo cinfo;
49
50 union in_addr_union in_addr;
51 union in_addr_union in_addr_peer;
52
db2df898 53 bool ip_masquerade_done:1;
d9dfd233
MP
54
55 LIST_FIELDS(Address, addresses);
56};
57
58int address_new_static(Network *network, unsigned section, Address **ret);
db2df898 59int address_new(Address **ret);
d9dfd233 60void address_free(Address *address);
db2df898
MP
61int address_add_foreign(Link *link, int family, const union in_addr_union *in_addr, unsigned char prefixlen, Address **ret);
62int address_add(Link *link, int family, const union in_addr_union *in_addr, unsigned char prefixlen, Address **ret);
63int address_get(Link *link, int family, const union in_addr_union *in_addr, unsigned char prefixlen, Address **ret);
64int address_update(Address *address, unsigned char flags, unsigned char scope, struct ifa_cacheinfo *cinfo);
65int address_drop(Address *address);
66int address_configure(Address *address, Link *link, sd_netlink_message_handler_t callback, bool update);
67int address_remove(Address *address, Link *link, sd_netlink_message_handler_t callback);
d9dfd233 68bool address_equal(Address *a1, Address *a2);
db2df898 69bool address_is_ready(const Address *a);
d9dfd233
MP
70
71DEFINE_TRIVIAL_CLEANUP_FUNC(Address*, address_free);
72#define _cleanup_address_free_ _cleanup_(address_freep)
73
74int 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);
75int 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);
76int 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);