1.\" $OpenBSD: rt_ifa_add.9,v 1.2 2014/04/25 11:49:47 mpi Exp $ 2.\" 3.\" Copyright (c) 2014 Martin Pieuchot 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: April 25 2014 $ 18.Dt RT_IFA_ADD 9 19.Os 20.Sh NAME 21.Nm rt_ifa_add , 22.Nm rt_ifa_del , 23.Nm rt_ifa_addloop , 24.Nm rt_ifa_delloop 25.Nd add or delete routes associated with an address 26.Sh SYNOPSIS 27.In sys/socket.h 28.In net/if.h 29.In net/route.h 30.Ft int 31.Fn rt_ifa_add "struct ifaddr *ifa" "int flags" "struct sockaddr *dst" 32.Ft int 33.Fn rt_ifa_del "struct ifaddr *ifa" "int flags" "struct sockaddr *dst" 34.Ft void 35.Fn rt_ifa_addloop "struct ifaddr *ifa" 36.Ft void 37.Fn rt_ifa_delloop "struct ifaddr *ifa" 38.Sh DESCRIPTION 39These functions create and delete routes required by the network stack 40and managed by the kernel. 41.Bl -tag -width rt_ifa_addloopxx 42.It Fn rt_ifa_add 43Creates and associates a connected route with 44.Fa ifa . 45.Pp 46Connected routes are mostly routes to prefixes and should be created with 47.Dv RTF_CLONING 48in 49.Fa flags 50and the address of 51.Fa ifa 52in 53.Fa dst . 54But for Point-to-Point interfaces, connected routes are routes to hosts and 55should be created 56with 57.Dv RTF_HOST 58in 59.Fa flags 60and the destination address in 61.Fa dst . 62Connected routes have a priority of 63.Dv RTP_CONNECTED . 64.It Fn rt_ifa_del 65Removes the connected route associated with 66.Fa ifa . 67.It Fn rt_ifa_addloop 68Creates and associates a local route 69with 70.Fa ifa . 71.Pp 72Local routes are used to not send packets destined to a local address on the 73wire and instead redirect them to 74.Xr lo 4 . 75They have the lowest priority available, 76.Dv RTP_LOCAL , 77and contain a special flag, 78.Dv RTF_LOCAL , 79that can be checked to determine if the address is configured on the system. 80.It Fn rt_ifa_delloop 81Removes the local route associated with 82.Fa ifa . 83.El 84.Sh CONTEXT 85.Fn rt_ifa_add , 86.Fn rt_ifa_del , 87.Fn rt_ifa_addloop , 88and 89.Fn rt_ifa_delloop 90can be called during autoconf, from process context, or from interrupt context. 91.Sh RETURN VALUES 92.Fn rt_ifa_add 93and 94.Fn rt_ifa_del 95will return 96.Dv 0 97on success and the return value of 98.Xr rtrequest1 9 99otherwise. 100.Sh SEE ALSO 101.Xr lo 4 , 102.Xr route 4 , 103.Xr rtrequest1 9 104