1.\" $OpenBSD: rtable_walk.9,v 1.1 2019/07/12 16:53:57 mpi Exp $ 2.\" 3.\" Copyright (c) 2019 Martin Pieuchot <mpi@openbsd.org> 4.\" 5.\" Permission to use, copy, modify, and distribute this software for any 6.\" purpose with or without fee is hereby granted, provided that the above 7.\" copyright notice and this permission notice appear in all copies. 8.\" 9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16.\" 17.Dd $Mdocdate: July 12 2019 $ 18.Dt RTABLE_WALK 9 19.Os 20.Sh NAME 21.Nm rtable_walk 22.Nd iterate over a routing table 23.Sh SYNOPSIS 24.In net/rtable.h 25.Ft int 26.Fo rtable_walk 27.Fa "unsigned int rtableid" 28.Fa "sa_family_t af" 29.Fa "struct rtentry **prt" 30.Fa "int (*func)(struct rtentry *, void *, unsigned int)" 31.Fa "void *arg" 32.Fc 33.Sh DESCRIPTION 34The 35.Fn rtable_walk 36function iterates over the routing table 37.Fa rtableid 38and applies 39.Fa func 40to all entries of address family 41.Fa af . 42.Pp 43The iteration is interrupted as soon as 44.Fa func 45returns a non-zero value. 46If 47.Fa prt 48is not 49.Dv NULL 50when the iteration is interrupted, it is set to the current 51routing entry. 52In that case 53.Fn rtfree 54must be called on the routing entry pointed to by 55.Fa prt . 56.Sh CONTEXT 57.Fn rtable_walk 58can be called during autoconf or from process context. 59.Sh RETURN VALUES 60.Fn rtable_walk 61returns any non-zero value returned by 62.Fa func . 63It may also fail with: 64.Pp 65.Bl -tag -width Er -compact 66.It Bq Er EAFNOSUPPORT 67A routing table with ID of 68.Fa rtableid 69and address family of 70.Fa af 71doesn't exist. 72.El 73.Sh SEE ALSO 74.Xr rtfree 9 75