summaryrefslogtreecommitdiff
path: root/sys/net
diff options
context:
space:
mode:
authorMichael Shalayeff <mickey@cvs.openbsd.org>2000-02-26 01:16:31 +0000
committerMichael Shalayeff <mickey@cvs.openbsd.org>2000-02-26 01:16:31 +0000
commit395ca66987a18b51d3ad5c437bd44388c16cc9c2 (patch)
tree5555216637a96685908339e38f119ff3ebb879c1 /sys/net
parent3595964c99622a467783c93e8c5a341b42d0e3e6 (diff)
use LIST_* macros where appropriate instead of using LIST* internals.
From netbsd add 802.11 media types and options add ifmedia_delete_instance() to be used in *detach() routines. a few minor knits. jason@ ok.
Diffstat (limited to 'sys/net')
-rw-r--r--sys/net/if_media.c35
-rw-r--r--sys/net/if_media.h26
2 files changed, 53 insertions, 8 deletions
diff --git a/sys/net/if_media.c b/sys/net/if_media.c
index 1924352d0c7..0e3e4b8b76d 100644
--- a/sys/net/if_media.c
+++ b/sys/net/if_media.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: if_media.c,v 1.2 2000/01/08 05:28:38 jason Exp $ */
-/* $NetBSD: if_media.c,v 1.3 1998/08/30 07:39:39 enami Exp $ */
+/* $OpenBSD: if_media.c,v 1.3 2000/02/26 01:16:30 mickey Exp $ */
+/* $NetBSD: if_media.c,v 1.7 1999/11/03 23:06:35 thorpej Exp $ */
/*-
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -303,7 +303,7 @@ ifmedia_ioctl(ifp, ifr, ifm, cmd)
(*ifm->ifm_status)(ifp, ifmr);
count = 0;
- ep = ifm->ifm_list.lh_first;
+ ep = LIST_FIRST(&ifm->ifm_list);
if (ifmr->ifm_count != 0) {
kptr = (int *)malloc(ifmr->ifm_count * sizeof(int),
@@ -313,7 +313,7 @@ ifmedia_ioctl(ifp, ifr, ifm, cmd)
* Get the media words from the interface's list.
*/
for (; ep != NULL && count < ifmr->ifm_count;
- ep = ep->ifm_list.le_next, count++)
+ ep = LIST_NEXT(ep, ifm_list), count++)
kptr[count] = ep->ifm_media;
if (ep != NULL)
@@ -361,7 +361,6 @@ ifmedia_ioctl(ifp, ifr, ifm, cmd)
/*
* Find media entry matching a given ifm word.
- *
*/
struct ifmedia_entry *
ifmedia_match(ifm, target, mask)
@@ -374,8 +373,8 @@ ifmedia_match(ifm, target, mask)
match = NULL;
mask = ~mask;
- for (next = ifm->ifm_list.lh_first; next != NULL;
- next = next->ifm_list.le_next) {
+ for (next = LIST_FIRST(&ifm->ifm_list); next != NULL;
+ next = LIST_NEXT(next, ifm_list)) {
if ((next->ifm_media & mask) == (target & mask)) {
#if defined(IFMEDIA_DEBUG) || defined(DIAGNOSTIC)
if (match) {
@@ -390,6 +389,28 @@ ifmedia_match(ifm, target, mask)
return match;
}
+/*
+ * Delete all media for a given instance.
+ */
+void
+ifmedia_delete_instance(ifm, inst)
+ struct ifmedia *ifm;
+ int inst;
+{
+ struct ifmedia_entry *ife, *nife;
+
+ for (ife = LIST_FIRST(&ifm->ifm_list); ife != NULL;
+ ife = nife) {
+
+ nife = LIST_NEXT(ife, ifm_list);
+ if (inst == IFM_INST_ANY ||
+ inst == IFM_INST(ife->ifm_media)) {
+ LIST_REMOVE(ife, ifm_list);
+ free(ife, M_DEVBUF);
+ }
+ }
+}
+
#ifdef IFMEDIA_DEBUG
struct ifmedia_description ifm_type_descriptions[] =
diff --git a/sys/net/if_media.h b/sys/net/if_media.h
index bf8de632f1a..67640517e93 100644
--- a/sys/net/if_media.h
+++ b/sys/net/if_media.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_media.h,v 1.4 2000/02/18 14:42:06 jason Exp $ */
+/* $OpenBSD: if_media.h,v 1.5 2000/02/26 01:16:30 mickey Exp $ */
/* $NetBSD: if_media.h,v 1.11 1998/08/12 23:23:29 thorpej Exp $ */
/*-
@@ -142,6 +142,9 @@ int ifmedia_ioctl __P((struct ifnet *ifp, struct ifreq *ifr,
struct ifmedia_entry *ifmedia_match __P((struct ifmedia *ifm,
int flags, int mask));
+/* Delete all media for a given media instance */
+void ifmedia_delete_instance __P((struct ifmedia *, int));
+
#endif /*_KERNEL */
/*
@@ -199,6 +202,17 @@ struct ifmedia_entry *ifmedia_match __P((struct ifmedia *ifm,
#define IFM_FDDI_DA 0x00000100 /* Dual attach / single attach */
/*
+ * IEEE 802.11 Wireless
+ */
+#define IFM_IEEE80211 0x00000080
+#define IFM_IEEE80211_FH1 3 /* Frequency Hopping 1Mbps */
+#define IFM_IEEE80211_FH2 4 /* Frequency Hopping 2Mbps */
+#define IFM_IEEE80211_DS2 5 /* Direct Sequence 2Mbps */
+#define IFM_IEEE80211_DS5 6 /* Direct Sequence 5Mbps*/
+#define IFM_IEEE80211_DS11 7 /* Direct Sequence 11Mbps*/
+#define IFM_IEEE80211_ADHOC 0x100 /* Operate in Adhoc mode */
+
+/*
* Shared media sub-types
*/
#define IFM_AUTO 0 /* Autoselect best media */
@@ -243,6 +257,7 @@ struct ifmedia_entry *ifmedia_match __P((struct ifmedia *ifm,
#define IFM_OPTIONS(x) ((x) & (IFM_OMASK|IFM_GMASK))
#define IFM_INST_MAX IFM_INST(IFM_IMASK)
+#define IFM_INST_ANY (-1)
/*
* Macro to create a media word.
@@ -274,6 +289,7 @@ struct ifmedia_description {
{ IFM_TOKEN, "TokenRing" }, \
{ IFM_TOKEN, "token" }, \
{ IFM_FDDI, "FDDI" }, \
+ { IFM_IEEE80211, "IEEE802.11" }, \
{ 0, NULL }, \
}
@@ -339,6 +355,12 @@ struct ifmedia_description {
{ IFM_FDDI|IFM_FDDI_UTP, "UTP" }, \
{ IFM_FDDI|IFM_FDDI_UTP, "CDDI" }, \
\
+ { IFM_IEEE80211|IFM_IEEE80211_FH1, "FH1" }, \
+ { IFM_IEEE80211|IFM_IEEE80211_FH2, "FH2" }, \
+ { IFM_IEEE80211|IFM_IEEE80211_DS2, "DS2" }, \
+ { IFM_IEEE80211|IFM_IEEE80211_DS5, "DS5" }, \
+ { IFM_IEEE80211|IFM_IEEE80211_DS11, "DS11" }, \
+ \
{ 0, NULL }, \
}
@@ -364,6 +386,8 @@ struct ifmedia_description {
{ IFM_FDDI|IFM_FDDI_DA, "dual-attach" }, \
{ IFM_FDDI|IFM_FDDI_DA, "das" }, \
\
+ { IFM_IEEE80211|IFM_IEEE80211_ADHOC, "adhoc" }, \
+ \
{ 0, NULL }, \
}