|
| 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 | + |
| 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 | + |
| 53 | + bool ip_masquerade_done; |
| 54 | + |
| 55 | + LIST_FIELDS(Address, addresses); |
| 56 | +}; |
| 57 | + |
| 58 | +int address_new_static(Network *network, unsigned section, Address **ret); |
| 59 | +int address_new_dynamic(Address **ret); |
| 60 | +void address_free(Address *address); |
| 61 | +int address_configure(Address *address, Link *link, sd_netlink_message_handler_t callback); |
| 62 | +int address_update(Address *address, Link *link, sd_netlink_message_handler_t callback); |
| 63 | +int address_drop(Address *address, Link *link, sd_netlink_message_handler_t callback); |
| 64 | +int address_establish(Address *address, Link *link); |
| 65 | +int address_release(Address *address, Link *link); |
| 66 | +bool address_equal(Address *a1, Address *a2); |
| 67 | + |
| 68 | +DEFINE_TRIVIAL_CLEANUP_FUNC(Address*, address_free); |
| 69 | +#define _cleanup_address_free_ _cleanup_(address_freep) |
| 70 | + |
| 71 | +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); |
| 72 | +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); |
| 73 | +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); |
0 commit comments