networkd-address.h revision 71d35b6b5563817dfbe757ab9e3b9f018b2db491
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering#pragma once
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering/***
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering This file is part of systemd.
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering Copyright 2013 Tom Gundersen <teg@jklm.no>
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering systemd is free software; you can redistribute it and/or modify it
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering under the terms of the GNU Lesser General Public License as published by
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering the Free Software Foundation; either version 2.1 of the License, or
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering (at your option) any later version.
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering systemd is distributed in the hope that it will be useful, but
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering WITHOUT ANY WARRANTY; without even the implied warranty of
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering Lesser General Public License for more details.
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering You should have received a copy of the GNU Lesser General Public License
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering along with systemd; If not, see <http://www.gnu.org/licenses/>.
b5efdb8af40ea759a1ea584c1bc44ecc81dd00ceLennart Poettering***/
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
f2f1dbe50fea13abadc9c1e845a29031b90b40f3Lennart Poettering#include <inttypes.h>
b5efdb8af40ea759a1ea584c1bc44ecc81dd00ceLennart Poettering#include <stdbool.h>
be808ea083fa07271116b4519c3c27fd20c5f077Tom Gundersen
f2f1dbe50fea13abadc9c1e845a29031b90b40f3Lennart Poettering#include "in-addr-util.h"
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
9df3ba6c6cb65eecec06f39dfe85a3596cedac4eTom Gundersentypedef struct Address Address;
9df3ba6c6cb65eecec06f39dfe85a3596cedac4eTom Gundersen
9df3ba6c6cb65eecec06f39dfe85a3596cedac4eTom Gundersen#include "networkd-link.h"
9df3ba6c6cb65eecec06f39dfe85a3596cedac4eTom Gundersen#include "networkd-network.h"
be808ea083fa07271116b4519c3c27fd20c5f077Tom Gundersen#include "networkd.h"
be808ea083fa07271116b4519c3c27fd20c5f077Tom Gundersen
be808ea083fa07271116b4519c3c27fd20c5f077Tom Gundersen#define CACHE_INFO_INFINITY_LIFE_TIME 0xFFFFFFFFU
be808ea083fa07271116b4519c3c27fd20c5f077Tom Gundersen
be808ea083fa07271116b4519c3c27fd20c5f077Tom Gundersenstruct Address {
be808ea083fa07271116b4519c3c27fd20c5f077Tom Gundersen Network *network;
be808ea083fa07271116b4519c3c27fd20c5f077Tom Gundersen unsigned section;
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering Link *link;
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering
4e945a6f7971fd7d1f6b2c62ee3afdaff3c95ce4Lennart Poettering int family;
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering unsigned char prefixlen;
0dd25fb9f005d8ab7ac4bc10a609d00569f8c56aLennart Poettering unsigned char scope;
3c0cf502796be355431d4a64d738e75f543aa51dLennart Poettering uint32_t flags;
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering char *label;
eed857b71702f8551b46b66b31fa0d08583cf23cLennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering struct in_addr broadcast;
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering struct ifa_cacheinfo cinfo;
4e945a6f7971fd7d1f6b2c62ee3afdaff3c95ce4Lennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering union in_addr_union in_addr;
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering union in_addr_union in_addr_peer;
eed857b71702f8551b46b66b31fa0d08583cf23cLennart Poettering
eed857b71702f8551b46b66b31fa0d08583cf23cLennart Poettering bool ip_masquerade_done:1;
eed857b71702f8551b46b66b31fa0d08583cf23cLennart Poettering
eed857b71702f8551b46b66b31fa0d08583cf23cLennart Poettering LIST_FIELDS(Address, addresses);
eed857b71702f8551b46b66b31fa0d08583cf23cLennart Poettering};
eed857b71702f8551b46b66b31fa0d08583cf23cLennart Poettering
eed857b71702f8551b46b66b31fa0d08583cf23cLennart Poetteringint address_new_static(Network *network, unsigned section, Address **ret);
eed857b71702f8551b46b66b31fa0d08583cf23cLennart Poetteringint address_new(Address **ret);
eed857b71702f8551b46b66b31fa0d08583cf23cLennart Poetteringvoid address_free(Address *address);
eed857b71702f8551b46b66b31fa0d08583cf23cLennart Poetteringint address_add_foreign(Link *link, int family, const union in_addr_union *in_addr, unsigned char prefixlen, Address **ret);
eed857b71702f8551b46b66b31fa0d08583cf23cLennart Poetteringint address_add(Link *link, int family, const union in_addr_union *in_addr, unsigned char prefixlen, Address **ret);
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poetteringint address_get(Link *link, int family, const union in_addr_union *in_addr, unsigned char prefixlen, Address **ret);
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poetteringint address_update(Address *address, unsigned char flags, unsigned char scope, struct ifa_cacheinfo *cinfo);
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poetteringint address_drop(Address *address);
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poetteringint address_configure(Address *address, Link *link, sd_netlink_message_handler_t callback, bool update);
91b14d6ff362b938a72db17b095ee9903d07381bTom Gundersenint address_remove(Address *address, Link *link, sd_netlink_message_handler_t callback);
0b58db658b5c3f586ac3a837427f1f7fec2abb2eLennart Poetteringbool address_equal(Address *a1, Address *a2);
f4461e5641d53f27d6e76e0607bdaa9c0c58c1f6Lennart Poetteringbool address_is_ready(const Address *a);
f4461e5641d53f27d6e76e0607bdaa9c0c58c1f6Lennart Poettering
be808ea083fa07271116b4519c3c27fd20c5f077Tom GundersenDEFINE_TRIVIAL_CLEANUP_FUNC(Address*, address_free);
d74fb368b18f0fbd9a4fe6f15691bbea7f3c4a01Tom Gundersen#define _cleanup_address_free_ _cleanup_(address_freep)
4e945a6f7971fd7d1f6b2c62ee3afdaff3c95ce4Lennart Poettering
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poetteringint 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);
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poetteringint 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);
9df3ba6c6cb65eecec06f39dfe85a3596cedac4eTom Gundersenint 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);
74b2466e14a1961bf3ac0e8a60cfaceec705bd59Lennart Poettering