1 /* $OpenBSD: rtable.h,v 1.26 2020/11/07 09:51:40 denis Exp $ */ 2 3 /* 4 * Copyright (c) 2014-2016 Martin Pieuchot 5 * 6 * Permission to use, copy, modify, and distribute this software for any 7 * purpose with or without fee is hereby granted, provided that the above 8 * copyright notice and this permission notice appear in all copies. 9 * 10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 17 */ 18 19 #ifndef _NET_RTABLE_H_ 20 #define _NET_RTABLE_H_ 21 22 /* 23 * Newer routing table implementation based on ART (Allotment Routing 24 * Table). 25 */ 26 #include <net/art.h> 27 28 #define rt_key(rt) ((rt)->rt_dest) 29 #define rt_plen(rt) ((rt)->rt_plen) 30 #define RT_ROOT(rt) (0) 31 32 int rtable_satoplen(sa_family_t, struct sockaddr *); 33 34 void rtable_init(void); 35 int rtable_exists(unsigned int); 36 int rtable_empty(unsigned int); 37 int rtable_add(unsigned int); 38 unsigned int rtable_l2(unsigned int); 39 unsigned int rtable_loindex(unsigned int); 40 void rtable_l2set(unsigned int, unsigned int, unsigned int); 41 42 int rtable_setsource(unsigned int, int, struct sockaddr *); 43 struct sockaddr *rtable_getsource(unsigned int, int); 44 void rtable_clearsource(unsigned int, struct sockaddr *); 45 struct rtentry *rtable_lookup(unsigned int, struct sockaddr *, 46 struct sockaddr *, struct sockaddr *, uint8_t); 47 struct rtentry *rtable_match(unsigned int, struct sockaddr *, uint32_t *); 48 struct rtentry *rtable_iterate(struct rtentry *); 49 int rtable_insert(unsigned int, struct sockaddr *, 50 struct sockaddr *, struct sockaddr *, uint8_t, 51 struct rtentry *); 52 int rtable_delete(unsigned int, struct sockaddr *, 53 struct sockaddr *, struct rtentry *); 54 int rtable_walk(unsigned int, sa_family_t, struct rtentry **, 55 int (*)(struct rtentry *, void *, unsigned int), void *); 56 57 int rtable_mpath_capable(unsigned int, sa_family_t); 58 struct rtentry *rtable_mpath_match(unsigned int, struct rtentry *, 59 struct sockaddr *, uint8_t); 60 int rtable_mpath_reprio(unsigned int, struct sockaddr *, int, 61 uint8_t, struct rtentry *); 62 63 #endif /* _NET_RTABLE_H_ */ 64