summaryrefslogtreecommitdiff
path: root/sys/net
diff options
context:
space:
mode:
authorMarkus Friedl <markus@cvs.openbsd.org>2004-01-15 10:47:56 +0000
committerMarkus Friedl <markus@cvs.openbsd.org>2004-01-15 10:47:56 +0000
commita3652952c54dd6a0f5556a07b4ff01a282561feb (patch)
tree29f7a244fac4ffbbd3d5da5240db25901b98f091 /sys/net
parentad5c63dd4c99fe6a859f8a8247b4f6d36104409f (diff)
add a RTM_IFANNOUNCE message; from netbsd; ok itojun, henning
Diffstat (limited to 'sys/net')
-rw-r--r--sys/net/if.c8
-rw-r--r--sys/net/if.h18
-rw-r--r--sys/net/route.h4
-rw-r--r--sys/net/rtsock.c33
4 files changed, 59 insertions, 4 deletions
diff --git a/sys/net/if.c b/sys/net/if.c
index aab4d9f5d18..8d1be30bb87 100644
--- a/sys/net/if.c
+++ b/sys/net/if.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if.c,v 1.81 2004/01/09 10:44:32 markus Exp $ */
+/* $OpenBSD: if.c,v 1.82 2004/01/15 10:47:55 markus Exp $ */
/* $NetBSD: if.c,v 1.35 1996/05/07 05:26:04 thorpej Exp $ */
/*
@@ -252,6 +252,9 @@ if_attachsetup(ifp)
#if NPF > 0
pfi_attach_ifnet(ifp);
#endif
+
+ /* Announce the interface. */
+ rt_ifannouncemsg(ifp, IFAN_ARRIVAL);
}
/*
@@ -574,6 +577,9 @@ do { \
ifp->if_afdata[dp->dom_family]);
}
+ /* Announce that the interface is gone. */
+ rt_ifannouncemsg(ifp, IFAN_DEPARTURE);
+
splx(s);
}
diff --git a/sys/net/if.h b/sys/net/if.h
index 875355b8916..3025d26a0ef 100644
--- a/sys/net/if.h
+++ b/sys/net/if.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: if.h,v 1.48 2003/12/16 20:33:25 markus Exp $ */
+/* $OpenBSD: if.h,v 1.49 2004/01/15 10:47:55 markus Exp $ */
/* $NetBSD: if.h,v 1.23 1996/05/07 02:40:27 thorpej Exp $ */
/*
@@ -357,6 +357,22 @@ struct ifa_msghdr {
int ifam_metric; /* value of ifa_metric */
};
+
+/*
+ * Message format announcing the arrival or departure of a network interface.
+ */
+struct if_announcemsghdr {
+ u_short ifan_msglen; /* to skip over non-understood messages */
+ u_char ifan_version; /* future binary compatibility */
+ u_char ifan_type; /* message type */
+ u_short ifan_index; /* index for associated ifp */
+ char ifan_name[IFNAMSIZ]; /* if name, e.g. "en0" */
+ u_short ifan_what; /* what type of announcement */
+};
+
+#define IFAN_ARRIVAL 0 /* interface arrival */
+#define IFAN_DEPARTURE 1 /* interface departure */
+
/*
* Interface request structure used for socket
* ioctl's. All interface ioctl's must have parameter
diff --git a/sys/net/route.h b/sys/net/route.h
index cf72b221581..b18a5675d93 100644
--- a/sys/net/route.h
+++ b/sys/net/route.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: route.h,v 1.18 2003/08/26 08:33:12 itojun Exp $ */
+/* $OpenBSD: route.h,v 1.19 2004/01/15 10:47:55 markus Exp $ */
/* $NetBSD: route.h,v 1.9 1996/02/13 22:00:49 christos Exp $ */
/*
@@ -191,6 +191,7 @@ struct rt_msghdr {
#define RTM_NEWADDR 0xc /* address being added to iface */
#define RTM_DELADDR 0xd /* address being removed from iface */
#define RTM_IFINFO 0xe /* iface going up/down etc. */
+#define RTM_IFANNOUNCE 0xf /* iface arrival/departure */
#define RTV_MTU 0x1 /* init or lock _mtu */
#define RTV_HOPCOUNT 0x2 /* init or lock _hopcount */
@@ -291,6 +292,7 @@ int route_output(struct mbuf *, ...);
int route_usrreq(struct socket *, int, struct mbuf *,
struct mbuf *, struct mbuf *);
void rt_ifmsg(struct ifnet *);
+void rt_ifannouncemsg(struct ifnet *, int);
void rt_maskedcopy(struct sockaddr *,
struct sockaddr *, struct sockaddr *);
void rt_missmsg(int, struct rt_addrinfo *, int, int);
diff --git a/sys/net/rtsock.c b/sys/net/rtsock.c
index b8c07b9ef60..c55bf82fae2 100644
--- a/sys/net/rtsock.c
+++ b/sys/net/rtsock.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rtsock.c,v 1.34 2004/01/03 14:08:53 espie Exp $ */
+/* $OpenBSD: rtsock.c,v 1.35 2004/01/15 10:47:55 markus Exp $ */
/* $NetBSD: rtsock.c,v 1.18 1996/03/29 00:32:10 cgd Exp $ */
/*
@@ -469,6 +469,10 @@ rt_msg1(type, rtinfo)
len = sizeof(struct if_msghdr);
break;
+ case RTM_IFANNOUNCE:
+ len = sizeof(struct if_announcemsghdr);
+ break;
+
default:
len = sizeof(struct rt_msghdr);
}
@@ -698,6 +702,33 @@ rt_newaddrmsg(cmd, ifa, error, rt)
}
/*
+ * This is called to generate routing socket messages indicating
+ * network interface arrival and departure.
+ */
+void
+rt_ifannouncemsg(ifp, what)
+ struct ifnet *ifp;
+ int what;
+{
+ struct if_announcemsghdr *ifan;
+ struct mbuf *m;
+ struct rt_addrinfo info;
+
+ if (route_cb.any_count == 0)
+ return;
+ bzero(&info, sizeof(info));
+ m = rt_msg1(RTM_IFANNOUNCE, &info);
+ if (m == 0)
+ return;
+ ifan = mtod(m, struct if_announcemsghdr *);
+ ifan->ifan_index = ifp->if_index;
+ strlcpy(ifan->ifan_name, ifp->if_xname, sizeof(ifan->ifan_name));
+ ifan->ifan_what = what;
+ route_proto.sp_protocol = 0;
+ raw_input(m, &route_proto, &route_src, &route_dst);
+}
+
+/*
* This is used in dumping the kernel table via sysctl().
*/
int