1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
|
.\" $OpenBSD: if_addrhook_add.9,v 1.2 2019/11/08 08:14:11 jmc Exp $
.\"
.\" Copyright (c) 2019 David Gwynne <dlg@openbsd.org>
.\"
.\" Permission to use, copy, modify, and distribute this software for any
.\" purpose with or without fee is hereby granted, provided that the above
.\" copyright notice and this permission notice appear in all copies.
.\"
.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
.Dd $Mdocdate: November 8 2019 $
.Dt IF_ADDRHOOK_ADD 9
.Os
.Sh NAME
.Nm if_addrhook_add ,
.Nm if_addrhook_del ,
.\" .Nm if_addrhooks_run ,
.Nm if_detachhook_add ,
.Nm if_detachhook_del ,
.Nm if_linkstatehook_add ,
.Nm if_linkstatehook_del
.Nd interface event hook API
.Sh SYNOPSIS
.In net/if_var.h
.Ft void
.Fn if_addrhook_add "struct ifnet *ifp" "struct task *t"
.Ft void
.Fn if_addrhook_del "struct ifnet *ifp" "struct task *t"
.\" .Ft void
.\" .Fn if_addrhooks_run "struct ifnet *ifp"
.Ft void
.Fn if_detachhook_add "struct ifnet *ifp" "struct task *t"
.Ft void
.Fn if_detachhook_del "struct ifnet *ifp" "struct task *t"
.Ft void
.Fn if_inkstatehook_add "struct ifnet *ifp" "struct task *t"
.Ft void
.Fn if_inkstatehook_del "struct ifnet *ifp" "struct task *t"
.Sh DESCRIPTION
The interface hook API allows for the registration of a task that
will be called when an IP address change, link state, or detach event
occurs on the specified interface.
Tasks should be initialised with
.Xr task_add 9
or
.Xr TASK_INITIALIZER 9
before being used with the following functions.
.Pp
The
.Fn if_addrhook_add
function registers the task
.Fa t
on the
.Fa ifp
interface.
The event will fire every time an IPv4 or IPv6 address change occurs
on the interface until explicitly removed with
.Fn if_addrhook_del .
.Pp
The
.Fn if_addrhook_del
function removes the task
.Fa t
from the
.Fa ifp
interface.
.Pp
The
.Fn if_detachhook_add
function registers the task
.Fa t
on the
.Fa ifp
interface.
The event will fire when the interface is being destroyed.
.Pp
The
.Fn if_detachhook_del
function removes the task
.Fa t
from the
.Fa ifp
interface.
.Pp
The
.Fn if_linkstatehook_add
function registers the task
.Fa t
on the
.Fa ifp
interface.
The event will fire for every link state change, or when the interface
is brought up or down, until explicitly removed with
.Fn if_linkstatehook_del .
.Pp
The
.Fn if_linkstatehook_del
function removes the task
.Fa t
from the
.Fa ifp
interface.
.Sh CONTEXT
.Fn if_addrhook_add ,
.Fn if_addrhook_del ,
.\" .Fn if_addrhooks_run ,
.Fn if_detachhook_add ,
.Fn if_detachhook_del ,
.Fn if_linkstatehook_add ,
and
.Fn if_linkstatehook_del
can be called during autoconf, from process context, or from interrupt context.
.Sh SEE ALSO
.Xr task_set 9
|