xref: /openbsd/share/man/man9/if_addrhook_add.9 (revision 3cab2bb3)
1.\"     $OpenBSD: if_addrhook_add.9,v 1.2 2019/11/08 08:14:11 jmc Exp $
2.\"
3.\"  Copyright (c) 2019 David Gwynne <dlg@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: November 8 2019 $
18.Dt IF_ADDRHOOK_ADD 9
19.Os
20.Sh NAME
21.Nm if_addrhook_add ,
22.Nm if_addrhook_del ,
23.\" .Nm if_addrhooks_run ,
24.Nm if_detachhook_add ,
25.Nm if_detachhook_del ,
26.Nm if_linkstatehook_add ,
27.Nm if_linkstatehook_del
28.Nd interface event hook API
29.Sh SYNOPSIS
30.In net/if_var.h
31.Ft void
32.Fn if_addrhook_add "struct ifnet *ifp" "struct task *t"
33.Ft void
34.Fn if_addrhook_del "struct ifnet *ifp" "struct task *t"
35.\" .Ft void
36.\" .Fn if_addrhooks_run "struct ifnet *ifp"
37.Ft void
38.Fn if_detachhook_add "struct ifnet *ifp" "struct task *t"
39.Ft void
40.Fn if_detachhook_del "struct ifnet *ifp" "struct task *t"
41.Ft void
42.Fn if_inkstatehook_add "struct ifnet *ifp" "struct task *t"
43.Ft void
44.Fn if_inkstatehook_del "struct ifnet *ifp" "struct task *t"
45.Sh DESCRIPTION
46The interface hook API allows for the registration of a task that
47will be called when an IP address change, link state, or detach event
48occurs on the specified interface.
49Tasks should be initialised with
50.Xr task_add 9
51or
52.Xr TASK_INITIALIZER 9
53before being used with the following functions.
54.Pp
55The
56.Fn if_addrhook_add
57function registers the task
58.Fa t
59on the
60.Fa ifp
61interface.
62The event will fire every time an IPv4 or IPv6 address change occurs
63on the interface until explicitly removed with
64.Fn if_addrhook_del .
65.Pp
66The
67.Fn if_addrhook_del
68function removes the task
69.Fa t
70from the
71.Fa ifp
72interface.
73.Pp
74The
75.Fn if_detachhook_add
76function registers the task
77.Fa t
78on the
79.Fa ifp
80interface.
81The event will fire when the interface is being destroyed.
82.Pp
83The
84.Fn if_detachhook_del
85function removes the task
86.Fa t
87from the
88.Fa ifp
89interface.
90.Pp
91The
92.Fn if_linkstatehook_add
93function registers the task
94.Fa t
95on the
96.Fa ifp
97interface.
98The event will fire for every link state change, or when the interface
99is brought up or down, until explicitly removed with
100.Fn if_linkstatehook_del .
101.Pp
102The
103.Fn if_linkstatehook_del
104function removes the task
105.Fa t
106from the
107.Fa ifp
108interface.
109.Sh CONTEXT
110.Fn if_addrhook_add ,
111.Fn if_addrhook_del ,
112.\" .Fn if_addrhooks_run ,
113.Fn if_detachhook_add ,
114.Fn if_detachhook_del ,
115.Fn if_linkstatehook_add ,
116and
117.Fn if_linkstatehook_del
118can be called during autoconf, from process context, or from interrupt context.
119.Sh SEE ALSO
120.Xr task_set 9
121