Line data Source code
1 : /* SPDX-License-Identifier: LGPL-2.1+ */ 2 : #pragma once 3 : 4 : #include "sd-netlink.h" 5 : 6 : #include "conf-parser.h" 7 : #include "ether-addr-util.h" 8 : #include "in-addr-util.h" 9 : #include "list.h" 10 : #include "macro.h" 11 : 12 : typedef struct Neighbor Neighbor; 13 : 14 : #include "networkd-link.h" 15 : #include "networkd-network.h" 16 : #include "networkd-util.h" 17 : 18 : union lladdr_union { 19 : struct ether_addr mac; 20 : union in_addr_union ip; 21 : }; 22 : 23 : struct Neighbor { 24 : Network *network; 25 : Link *link; 26 : NetworkConfigSection *section; 27 : 28 : int family; 29 : union in_addr_union in_addr; 30 : union lladdr_union lladdr; 31 : size_t lladdr_size; 32 : 33 : LIST_FIELDS(Neighbor, neighbors); 34 : }; 35 : 36 : void neighbor_free(Neighbor *neighbor); 37 : 38 0 : DEFINE_NETWORK_SECTION_FUNCTIONS(Neighbor, neighbor_free); 39 : 40 : int neighbor_configure(Neighbor *neighbor, Link *link, link_netlink_message_handler_t callback); 41 : int neighbor_remove(Neighbor *neighbor, Link *link, link_netlink_message_handler_t callback); 42 : 43 : int neighbor_get(Link *link, int family, const union in_addr_union *addr, const union lladdr_union *lladdr, size_t lladdr_size, Neighbor **ret); 44 : int neighbor_add(Link *link, int family, const union in_addr_union *addr, const union lladdr_union *lladdr, size_t lladdr_size, Neighbor **ret); 45 : int neighbor_add_foreign(Link *link, int family, const union in_addr_union *addr, const union lladdr_union *lladdr, size_t lladdr_size, Neighbor **ret); 46 : bool neighbor_equal(const Neighbor *n1, const Neighbor *n2); 47 : 48 : int neighbor_section_verify(Neighbor *neighbor); 49 : 50 : CONFIG_PARSER_PROTOTYPE(config_parse_neighbor_address); 51 : CONFIG_PARSER_PROTOTYPE(config_parse_neighbor_hwaddr); 52 : CONFIG_PARSER_PROTOTYPE(config_parse_neighbor_lladdr);