summaryrefslogtreecommitdiffstats
path: root/sys/net
diff options
context:
space:
mode:
authormlaier <mlaier@FreeBSD.org>2004-02-26 04:27:55 +0000
committermlaier <mlaier@FreeBSD.org>2004-02-26 04:27:55 +0000
commitd937176b3481cd970c24fba3eddbe098a1fe564f (patch)
treeb65ebe6aae423d9c985d1fc587b2e375a7f3c7c4 /sys/net
parent428f1c9a0fbaac94f9cce57cd846b2b6f82e17d1 (diff)
downloadFreeBSD-src-d937176b3481cd970c24fba3eddbe098a1fe564f.zip
FreeBSD-src-d937176b3481cd970c24fba3eddbe098a1fe564f.tar.gz
Bring eventhandler callbacks for pf.
This enables pf to track dynamic address changes on interfaces (dailup) with the "on (<ifname>)"-syntax. This also brings hooks in anticipation of tracking cloned interfaces, which will be in future versions of pf. Approved by: bms(mentor)
Diffstat (limited to 'sys/net')
-rw-r--r--sys/net/if.c6
-rw-r--r--sys/net/if_var.h14
2 files changed, 20 insertions, 0 deletions
diff --git a/sys/net/if.c b/sys/net/if.c
index 8cea0c4..1d412f9 100644
--- a/sys/net/if.c
+++ b/sys/net/if.c
@@ -447,6 +447,8 @@ if_attach(struct ifnet *ifp)
if (domains)
if_attachdomain1(ifp);
+ EVENTHANDLER_INVOKE(ifnet_arrival_event, ifp);
+
/* Announce the interface. */
rt_ifannouncemsg(ifp, IFAN_ARRIVAL);
}
@@ -513,6 +515,7 @@ if_detach(struct ifnet *ifp)
int i;
struct domain *dp;
+ EVENTHANDLER_INVOKE(ifnet_departure_event, ifp);
/*
* Remove routes and flush queues.
*/
@@ -843,6 +846,7 @@ if_clone_attach(struct if_clone *ifc)
bitoff = unit - (bytoff << 3);
ifc->ifc_units[bytoff] |= (1 << bitoff);
}
+ EVENTHANDLER_INVOKE(if_clone_event, ifc);
}
/*
@@ -1378,6 +1382,7 @@ ifhwioctl(u_long cmd, struct ifnet *ifp, caddr_t data, struct thread *td)
if (ifunit(new_name) != NULL)
return (EEXIST);
+ EVENTHANDLER_INVOKE(ifnet_departure_event, ifp);
/* Announce the departure of the interface. */
rt_ifannouncemsg(ifp, IFAN_DEPARTURE);
@@ -1404,6 +1409,7 @@ ifhwioctl(u_long cmd, struct ifnet *ifp, caddr_t data, struct thread *td)
sdl->sdl_data[--namelen] = 0xff;
IFA_UNLOCK(ifa);
+ EVENTHANDLER_INVOKE(ifnet_arrival_event, ifp);
/* Announce the return of the interface. */
rt_ifannouncemsg(ifp, IFAN_ARRIVAL);
break;
diff --git a/sys/net/if_var.h b/sys/net/if_var.h
index a2f9178..5ddd72b 100644
--- a/sys/net/if_var.h
+++ b/sys/net/if_var.h
@@ -78,6 +78,7 @@ struct ether_header;
#ifdef _KERNEL
#include <sys/mbuf.h>
+#include <sys/eventhandler.h>
#endif /* _KERNEL */
#include <sys/lock.h> /* XXX */
#include <sys/mutex.h> /* XXX */
@@ -293,6 +294,19 @@ typedef void if_init_f_t(void *);
} while (0)
#ifdef _KERNEL
+/* interface address change event */
+typedef void (*ifaddr_event_handler_t)(void *, struct ifnet *);
+EVENTHANDLER_DECLARE(ifaddr_event, ifaddr_event_handler_t);
+/* new interface arrival event */
+typedef void (*ifnet_arrival_event_handler_t)(void *, struct ifnet *);
+EVENTHANDLER_DECLARE(ifnet_arrival_event, ifnet_arrival_event_handler_t);
+/* interface departure event */
+typedef void (*ifnet_departure_event_handler_t)(void *, struct ifnet *);
+EVENTHANDLER_DECLARE(ifnet_departure_event, ifnet_departure_event_handler_t);
+/* interface clone event */
+typedef void (*if_clone_event_handler_t)(void *, struct if_clone *);
+EVENTHANDLER_DECLARE(if_clone_event, if_clone_event_handler_t);
+
#define IF_AFDATA_LOCK_INIT(ifp) \
mtx_init(&(ifp)->if_afdata_mtx, "if_afdata", NULL, MTX_DEF)
#define IF_AFDATA_LOCK(ifp) mtx_lock(&(ifp)->if_afdata_mtx)
OpenPOWER on IntegriCloud