From 2b75e097f182b0e5c0c5d8665b1aacfd4a7c11e4 Mon Sep 17 00:00:00 2001 From: Hartmut Brandt Date: Tue, 29 Apr 2003 17:23:23 +0000 Subject: [PATCH] Add media types and options for ATM. While on most ATM cards media cannot be changed, it is very convenient to be able to toggle SDH/Sonet, idle/unassigned cells and scrambled mode and to see the carrier state. Reviewed by: -arch (if_media.h definitions) --- sbin/ifconfig/ifmedia.c | 34 +++++++++++++++++++++++++++ sys/net/if_media.c | 11 +++++++++ sys/net/if_media.h | 52 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 97 insertions(+) diff --git a/sbin/ifconfig/ifmedia.c b/sbin/ifconfig/ifmedia.c index fe85b14444b9..e1b3d398e442 100644 --- a/sbin/ifconfig/ifmedia.c +++ b/sbin/ifconfig/ifmedia.c @@ -159,6 +159,14 @@ media_status(int s, struct rt_addrinfo *info __unused) else printf("no ring"); break; + + case IFM_ATM: + if (ifmr.ifm_status & IFM_ACTIVE) + printf("active"); + else + printf("no carrier"); + break; + case IFM_IEEE80211: /* XXX: Different value for adhoc? */ if (ifmr.ifm_status & IFM_ACTIVE) @@ -370,6 +378,15 @@ static struct ifmedia_description ifm_subtype_ieee80211_option_descriptions[] = struct ifmedia_description ifm_subtype_ieee80211_mode_descriptions[] = IFM_SUBTYPE_IEEE80211_MODE_DESCRIPTIONS; +static struct ifmedia_description ifm_subtype_atm_descriptions[] = + IFM_SUBTYPE_ATM_DESCRIPTIONS; + +static struct ifmedia_description ifm_subtype_atm_aliases[] = + IFM_SUBTYPE_ATM_ALIASES; + +static struct ifmedia_description ifm_subtype_atm_option_descriptions[] = + IFM_SUBTYPE_ATM_OPTION_DESCRIPTIONS; + static struct ifmedia_description ifm_subtype_shared_descriptions[] = IFM_SUBTYPE_SHARED_DESCRIPTIONS; @@ -465,6 +482,23 @@ static struct ifmedia_type_to_subtype ifmedia_types_to_subtypes[] = { { NULL, 0 }, }, }, + { + { + { &ifm_subtype_shared_descriptions[0], 0 }, + { &ifm_subtype_shared_aliases[0], 1 }, + { &ifm_subtype_atm_descriptions[0], 0 }, + { &ifm_subtype_atm_aliases[0], 1 }, + { NULL, 0 }, + }, + { + { &ifm_shared_option_descriptions[0], 0 }, + { &ifm_subtype_atm_option_descriptions[0], 0 }, + { NULL, 0 }, + }, + { + { NULL, 0 }, + }, + }, }; static int diff --git a/sys/net/if_media.c b/sys/net/if_media.c index 2201c97c04e4..a584419fabb2 100644 --- a/sys/net/if_media.c +++ b/sys/net/if_media.c @@ -412,6 +412,12 @@ struct ifmedia_description ifm_subtype_ieee80211_option_descriptions[] = struct ifmedia_description ifm_subtype_ieee80211_mode_descriptions[] = IFM_SUBTYPE_IEEE80211_MODE_DESCRIPTIONS; +struct ifmedia_description ifm_subtype_atm_descriptions[] = + IFM_SUBTYPE_ATM_DESCRIPTIONS; + +struct ifmedia_description ifm_subtype_atm_option_descriptions[] = + IFM_SUBTYPE_ATM_OPTION_DESCRIPTIONS; + struct ifmedia_description ifm_subtype_shared_descriptions[] = IFM_SUBTYPE_SHARED_DESCRIPTIONS; @@ -446,6 +452,11 @@ struct ifmedia_type_to_subtype ifmedia_types_to_subtypes[] = { &ifm_subtype_ieee80211_option_descriptions[0], &ifm_subtype_ieee80211_mode_descriptions[0] }, + { + &ifm_subtype_atm_descriptions[0], + &ifm_subtype_atm_option_descriptions[0], + NULL, + }, }; /* diff --git a/sys/net/if_media.h b/sys/net/if_media.h index b48f59424504..32d9c3496d3c 100644 --- a/sys/net/if_media.h +++ b/sys/net/if_media.h @@ -199,6 +199,23 @@ int ifmedia_ioctl(struct ifnet *ifp, struct ifreq *ifr, #define IFM_IEEE80211_11B 2 /* Direct Sequence mode */ #define IFM_IEEE80211_11G 3 /* 2Ghz, CCK mode */ +/* + * ATM + */ +#define IFM_ATM 0x000000a0 +#define IFM_ATM_UNKNOWN 3 +#define IFM_ATM_UTP_25 4 +#define IFM_ATM_TAXI_100 5 +#define IFM_ATM_TAXI_140 6 +#define IFM_ATM_MM_155 7 +#define IFM_ATM_SM_155 8 +#define IFM_ATM_UTP_155 9 +#define IFM_ATM_MM_622 10 +#define IFM_ATM_SM_622 11 +#define IFM_ATM_SDH 0x00000100 /* SDH instead of SONET */ +#define IFM_ATM_NOSCRAMB 0x00000200 /* no scrambling */ +#define IFM_ATM_UNASSIGNED 0x00000400 /* unassigned cells */ + /* * Shared media sub-types */ @@ -271,6 +288,7 @@ struct ifmedia_description { { IFM_TOKEN, "Token ring" }, \ { IFM_FDDI, "FDDI" }, \ { IFM_IEEE80211, "IEEE 802.11 Wireless Ethernet" }, \ + { IFM_ATM, "ATM" }, \ { 0, NULL }, \ } @@ -435,6 +453,40 @@ struct ifmedia_description { { 0, NULL }, \ } +# define IFM_SUBTYPE_ATM_DESCRIPTIONS { \ + { IFM_ATM_UNKNOWN, "Unknown" }, \ + { IFM_ATM_UTP_25, "UTP/25.6MBit" }, \ + { IFM_ATM_TAXI_100, "Taxi/100MBit" }, \ + { IFM_ATM_TAXI_140, "Taxi/140MBit" }, \ + { IFM_ATM_MM_155, "Multi-mode/155MBit" }, \ + { IFM_ATM_SM_155, "Single-mode/155MBit" }, \ + { IFM_ATM_UTP_155, "UTP/155MBit" }, \ + { IFM_ATM_MM_622, "Mult-imode/622MBit" }, \ + { IFM_ATM_SM_622, "Single-mode/622MBit" }, \ + { 0, NULL }, \ +} + +# define IFM_SUBTYPE_ATM_ALIASES { \ + { IFM_ATM_UNKNOWN, "UNKNOWN" }, \ + { IFM_ATM_UTP_25, "UTP-25" }, \ + { IFM_ATM_TAXI_100, "TAXI-100" }, \ + { IFM_ATM_TAXI_140, "TAXI-140" }, \ + { IFM_ATM_MM_155, "MM-155" }, \ + { IFM_ATM_SM_155, "SM-155" }, \ + { IFM_ATM_UTP_155, "UTP-155" }, \ + { IFM_ATM_MM_622, "MM-622" }, \ + { IFM_ATM_SM_622, "SM-622" }, \ + { 0, NULL }, \ +} + +#define IFM_SUBTYPE_ATM_OPTION_DESCRIPTIONS { \ + { IFM_ATM_SDH, "SDH" }, \ + { IFM_ATM_NOSCRAMB, "Noscramb" }, \ + { IFM_ATM_UNASSIGNED, "Unassigned" }, \ + { 0, NULL }, \ +} + + #define IFM_SUBTYPE_SHARED_DESCRIPTIONS { \ { IFM_AUTO, "autoselect" }, \ { IFM_MANUAL, "manual" }, \