IF_ADDRHOOK_ADD(9) | Kernel Developer's Manual | IF_ADDRHOOK_ADD(9)

# NAME

`if_addrhook_add`, `if_addrhook_del`, `if_detachhook_add`, `if_detachhook_del`, `if_linkstatehook_add`, `if_linkstatehook_del` — interface event hook API

# SYNOPSIS

`#include <net/if_var.h>`

void
`if_addrhook_add`(struct ifnet *ifp, struct task *t);

void
`if_addrhook_del`(struct ifnet *ifp, struct task *t);

void
`if_detachhook_add`(struct ifnet *ifp, struct task *t);

void
`if_detachhook_del`(struct ifnet *ifp, struct task *t);

void
`if_linkstatehook_add`(struct ifnet *ifp, struct task *t);

void
`if_linkstatehook_del`(struct ifnet *ifp, struct task *t);

# 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 task_add(9) or TASK_INITIALIZER(9) before being used with the following functions.

The `if_addrhook_add`() function registers the task t on the ifp interface. The event will fire every time an IPv4 or IPv6 address change occurs on the interface until explicitly removed with `if_addrhook_del`().

The `if_addrhook_del`() function removes the task t from the ifp interface.

The `if_detachhook_add`() function registers the task t on the ifp interface. The event will fire when the interface is being destroyed.

The `if_detachhook_del`() function removes the task t from the ifp interface.

The `if_linkstatehook_add`() function registers the task t on the ifp interface. The event will fire for every link state change, or when the interface is brought up or down, until explicitly removed with `if_linkstatehook_del`().

The `if_linkstatehook_del`() function removes the task t from the ifp interface.

# CONTEXT

`if_addrhook_add`(), `if_addrhook_del`(), `if_detachhook_add`(), `if_detachhook_del`(), `if_linkstatehook_add`(), and `if_linkstatehook_del`() can be called during autoconf, from process context, or from interrupt context.

# SEE ALSO

task_set(9)

February 22, 2024 | Debian