-/* $OpenBSD: art.c,v 1.29 2020/11/12 15:25:28 mpi Exp $ */
+/* $OpenBSD: art.c,v 1.30 2023/11/10 20:05:22 bluhm Exp $ */
/*
* Copyright (c) 2015 Martin Pieuchot
#include <net/art.h>
-int art_bindex(struct art_table *, uint8_t *, int);
+int art_bindex(struct art_table *, const uint8_t *, int);
void art_allot(struct art_table *at, int, struct art_node *,
struct art_node *);
struct art_table *art_table_get(struct art_root *, struct art_table *,
* prefix length is > 24.
*/
int
-art_bindex(struct art_table *at, uint8_t *addr, int plen)
+art_bindex(struct art_table *at, const uint8_t *addr, int plen)
{
uint8_t boff, bend;
uint32_t k;
* corresponding to the range covered by the table ``at''.
*/
static inline int
-art_findex(struct art_table *at, uint8_t *addr)
+art_findex(struct art_table *at, const uint8_t *addr)
{
return art_bindex(at, addr, (at->at_offset + at->at_bits));
}
* Return the best existing match for a destination.
*/
struct art_node *
-art_match(struct art_root *ar, void *addr, struct srp_ref *nsr)
+art_match(struct art_root *ar, const void *addr, struct srp_ref *nsr)
{
struct srp_ref dsr, ndsr;
void *entry;
* it does not exist.
*/
struct art_node *
-art_lookup(struct art_root *ar, void *addr, int plen, struct srp_ref *nsr)
+art_lookup(struct art_root *ar, const void *addr, int plen, struct srp_ref *nsr)
{
void *entry;
struct art_table *at;
* same destination/mask pair is already present.
*/
struct art_node *
-art_insert(struct art_root *ar, struct art_node *an, void *addr, int plen)
+art_insert(struct art_root *ar, struct art_node *an, const void *addr, int plen)
{
struct art_table *at, *child;
struct art_node *node;
* Deletion API function.
*/
struct art_node *
-art_delete(struct art_root *ar, struct art_node *an, void *addr, int plen)
+art_delete(struct art_root *ar, struct art_node *an, const void *addr, int plen)
{
struct art_table *at;
struct art_node *node;
-/* $OpenBSD: art.h,v 1.23 2023/04/19 17:42:47 bluhm Exp $ */
+/* $OpenBSD: art.h,v 1.24 2023/11/10 20:05:22 bluhm Exp $ */
/*
* Copyright (c) 2015 Martin Pieuchot
#define an_gc an_pointer.an__gc
void art_init(void);
-struct art_root *art_alloc(unsigned int, unsigned int, unsigned int);
-struct art_node *art_insert(struct art_root *, struct art_node *, void *,
+struct art_root *art_alloc(unsigned int, unsigned int, unsigned int);
+struct art_node *art_insert(struct art_root *, struct art_node *, const void *,
int);
-struct art_node *art_delete(struct art_root *, struct art_node *, void *,
+struct art_node *art_delete(struct art_root *, struct art_node *, const void *,
int);
-struct art_node *art_match(struct art_root *, void *, struct srp_ref *);
-struct art_node *art_lookup(struct art_root *, void *, int,
+struct art_node *art_match(struct art_root *, const void *, struct srp_ref *);
+struct art_node *art_lookup(struct art_root *, const void *, int,
struct srp_ref *);
int art_walk(struct art_root *,
int (*)(struct art_node *, void *), void *);
-/* $OpenBSD: route.c,v 1.422 2023/04/28 20:03:14 mvs Exp $ */
+/* $OpenBSD: route.c,v 1.423 2023/11/10 20:05:22 bluhm Exp $ */
/* $NetBSD: route.c,v 1.14 1996/02/13 22:00:46 christos Exp $ */
/*
} while (0)
int
-rt_hash(struct rtentry *rt, struct sockaddr *dst, uint32_t *src)
+rt_hash(struct rtentry *rt, const struct sockaddr *dst, uint32_t *src)
{
uint32_t a, b, c;
switch (dst->sa_family) {
case AF_INET:
{
- struct sockaddr_in *sin;
+ const struct sockaddr_in *sin;
if (!ipmultipath)
return (-1);
- sin = satosin(dst);
+ sin = satosin_const(dst);
a += sin->sin_addr.s_addr;
b += src[0];
mix(a, b, c);
#ifdef INET6
case AF_INET6:
{
- struct sockaddr_in6 *sin6;
+ const struct sockaddr_in6 *sin6;
if (!ip6_multipath)
return (-1);
- sin6 = satosin6(dst);
+ sin6 = satosin6_const(dst);
a += sin6->sin6_addr.s6_addr32[0];
b += sin6->sin6_addr.s6_addr32[2];
c += src[0];
-/* $OpenBSD: route.h,v 1.199 2023/04/26 19:54:35 mvs Exp $ */
+/* $OpenBSD: route.h,v 1.200 2023/11/10 20:05:22 bluhm Exp $ */
/* $NetBSD: route.h,v 1.9 1996/02/13 22:00:49 christos Exp $ */
/*
void rt_mpls_clear(struct rtentry *);
int rtisvalid(struct rtentry *);
-int rt_hash(struct rtentry *, struct sockaddr *, uint32_t *);
+int rt_hash(struct rtentry *, const struct sockaddr *, uint32_t *);
struct rtentry *rtalloc_mpath(struct sockaddr *, uint32_t *, u_int);
struct rtentry *rtalloc(struct sockaddr *, int, unsigned int);
void rtref(struct rtentry *);
-/* $OpenBSD: rtable.c,v 1.82 2023/04/19 17:42:47 bluhm Exp $ */
+/* $OpenBSD: rtable.c,v 1.83 2023/11/10 20:05:22 bluhm Exp $ */
/*
* Copyright (c) 2014-2016 Martin Pieuchot
}
-static inline uint8_t *satoaddr(struct art_root *, struct sockaddr *);
+static inline const uint8_t *satoaddr(struct art_root *,
+ const struct sockaddr *);
int an_match(struct art_node *, struct sockaddr *, int);
void rtentry_ref(void *, void *);
struct art_node *an;
struct rtentry *rt = NULL;
struct srp_ref sr, nsr;
- uint8_t *addr;
+ const uint8_t *addr;
int plen;
ar = rtable_get(rtableid, dst->sa_family);
}
struct rtentry *
-rtable_match(unsigned int rtableid, struct sockaddr *dst, uint32_t *src)
+rtable_match(unsigned int rtableid, const struct sockaddr *dst, uint32_t *src)
{
struct art_root *ar;
struct art_node *an;
struct rtentry *rt = NULL;
struct srp_ref sr, nsr;
- uint8_t *addr;
+ const uint8_t *addr;
int hash;
ar = rtable_get(rtableid, dst->sa_family);
struct srp_ref sr;
struct art_root *ar;
struct art_node *an, *prev;
- uint8_t *addr;
+ const uint8_t *addr;
int plen;
unsigned int rt_flags;
int error = 0;
struct art_root *ar;
struct art_node *an;
struct srp_ref sr;
- uint8_t *addr;
+ const uint8_t *addr;
int plen;
struct rtentry *mrt;
int npaths = 0;
struct art_root *ar;
struct art_node *an;
struct srp_ref sr;
- uint8_t *addr;
+ const uint8_t *addr;
int error = 0;
ar = rtable_get(rtableid, dst->sa_family);
* BSD radix tree needed to skip the non-address fields from the flavor
* of "struct sockaddr" used by this routing table.
*/
-static inline uint8_t *
-satoaddr(struct art_root *at, struct sockaddr *sa)
+static inline const uint8_t *
+satoaddr(struct art_root *at, const struct sockaddr *sa)
{
- return (((uint8_t *)sa) + at->ar_off);
+ return (((const uint8_t *)sa) + at->ar_off);
}
/*
-/* $OpenBSD: rtable.h,v 1.26 2020/11/07 09:51:40 denis Exp $ */
+/* $OpenBSD: rtable.h,v 1.27 2023/11/10 20:05:22 bluhm Exp $ */
/*
* Copyright (c) 2014-2016 Martin Pieuchot
void rtable_clearsource(unsigned int, struct sockaddr *);
struct rtentry *rtable_lookup(unsigned int, struct sockaddr *,
struct sockaddr *, struct sockaddr *, uint8_t);
-struct rtentry *rtable_match(unsigned int, struct sockaddr *, uint32_t *);
+struct rtentry *rtable_match(unsigned int, const struct sockaddr *,
+ uint32_t *);
struct rtentry *rtable_iterate(struct rtentry *);
int rtable_insert(unsigned int, struct sockaddr *,
struct sockaddr *, struct sockaddr *, uint8_t,
-/* $OpenBSD: in.h,v 1.144 2023/05/13 13:35:17 bluhm Exp $ */
+/* $OpenBSD: in.h,v 1.145 2023/11/10 20:05:22 bluhm Exp $ */
/* $NetBSD: in.h,v 1.20 1996/02/13 23:41:47 christos Exp $ */
/*
return ((struct sockaddr_in *)(sa));
}
+static inline const struct sockaddr_in *
+satosin_const(const struct sockaddr *sa)
+{
+ return ((const struct sockaddr_in *)(sa));
+}
+
static inline struct sockaddr *
sintosa(struct sockaddr_in *sin)
{
-/* $OpenBSD: in6.h,v 1.109 2021/06/02 00:20:50 dlg Exp $ */
+/* $OpenBSD: in6.h,v 1.110 2023/11/10 20:05:23 bluhm Exp $ */
/* $KAME: in6.h,v 1.83 2001/03/29 02:55:07 jinmei Exp $ */
/*
return ((struct sockaddr_in6 *)(sa));
}
+static inline const struct sockaddr_in6 *
+satosin6_const(const struct sockaddr *sa)
+{
+ return ((const struct sockaddr_in6 *)(sa));
+}
+
static inline struct sockaddr *
sin6tosa(struct sockaddr_in6 *sin6)
{