2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
4 * Copyright (c) 2022 Alexander V. Chernikov <melifaro@FreeBSD.org>
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * This file contains definitions shared among NETLINK_ROUTE family
31 #ifndef _NETLINK_ROUTE_ROUTE_VAR_H_
32 #define _NETLINK_ROUTE_ROUTE_VAR_H_
34 #include <sys/priv.h> /* values for priv_check */
40 typedef int rtnl_msg_cb_f(struct nlmsghdr *hdr, struct nlpcb *nlp,
41 struct nl_pstate *npt);
43 struct rtnl_cmd_handler {
51 #define RTNL_F_NOEPOCH 0x01
53 bool rtnl_register_messages(const struct rtnl_cmd_handler *handlers, int count);
57 void rtnl_handle_route_event(uint32_t fibnum, const struct rib_cmd_info *rc);
58 void rtnl_routes_init(void);
61 void rtnl_neighs_init(void);
62 void rtnl_neighs_destroy(void);
65 struct nl_parsed_link {
69 struct nlattr *ifla_idata;
70 unsigned short ifi_type;
75 typedef int rtnl_iface_create_f(struct nl_parsed_link *lattrs, struct nlpcb *nlp,
76 struct nl_pstate *npt);
77 typedef int rtnl_iface_modify_f(struct nl_parsed_link *lattrs, struct nlpcb *nlp,
78 struct nl_pstate *npt);
82 rtnl_iface_create_f *create_f;
83 rtnl_iface_modify_f *modify_f;
84 SLIST_ENTRY(nl_cloner) next;
87 void rtnl_ifaces_init(void);
88 void rtnl_ifaces_destroy(void);
89 void rtnl_iface_add_cloner(struct nl_cloner *cloner);
90 void rtnl_iface_del_cloner(struct nl_cloner *cloner);
93 void rtnl_iface_drivers_register(void);
96 void rtnl_nexthops_init(void);
97 struct nhop_object *nl_find_nhop(uint32_t fibnum, int family,
98 uint32_t uidx, int nh_flags, int *perror);