From 6d60dde7cdc51c875890e386f84ea54b32513ec6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Wed, 4 Apr 2007 13:32:18 +0000 Subject: [PATCH] Added support for printing the media type. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20555 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/bin/network/ifconfig/ifconfig.cpp | 36 ++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/src/bin/network/ifconfig/ifconfig.cpp b/src/bin/network/ifconfig/ifconfig.cpp index 2dc5ee4554..73b6698cd2 100644 --- a/src/bin/network/ifconfig/ifconfig.cpp +++ b/src/bin/network/ifconfig/ifconfig.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2006, Haiku, Inc. All Rights Reserved. + * Copyright 2006-2007, Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. * * Authors: @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -172,7 +173,7 @@ list_interface(int socket, const char* name) printf("\n\t"); // get link level interface for this interface - + int linkSocket = ::socket(AF_LINK, SOCK_DGRAM, 0); if (linkSocket < 0) { printf("No link level: %s\n", strerror(errno)); @@ -213,6 +214,35 @@ list_interface(int socket, const char* name) close(linkSocket); } + if (ioctl(socket, SIOCGIFMEDIA, &request, sizeof(struct ifreq)) == 0) { + const char* type = "unknown"; + bool show = true; + + switch (IFM_TYPE(request.ifr_media)) { + case IFM_ETHER: + switch (IFM_SUBTYPE(request.ifr_media)) { + case IFM_10_T: + type = "10 MBit, 10BASE-T"; + break; + case IFM_100_TX: + type = "100 MBit, 100BASE-TX"; + break; + case IFM_1000_T: + case IFM_1000_SX: + type = "1 GBit, 1000BASE-T"; + break; + } + break; + + default: + show = false; + break; + } + + if (show) + printf("\tMedia Type: %s\n", type); + } + uint32 flags = 0; if (ioctl(socket, SIOCGIFFLAGS, &request, sizeof(struct ifreq)) == 0) flags = request.ifr_flags; @@ -270,7 +300,7 @@ list_interface(int socket, const char* name) {IFF_ALLMULTI, "allmulti"}, {IFF_AUTOUP, "autoup"}, {IFF_LINK, "link"}, - {IFF_AUTO_CONFIGURED, "auto-configure"}, + {IFF_AUTO_CONFIGURED, "auto-configured"}, {IFF_CONFIGURING, "configuring"}, }; bool first = true;