+ return sprintf(outwalk, "%s", ethspeed);
+#elif defined(__OpenBSD__) || defined(__NetBSD__)
+ char *ethspeed;
+ struct ifmediareq ifmr;
+
+ (void) memset(&ifmr, 0, sizeof(ifmr));
+ (void) strlcpy(ifmr.ifm_name, interface, sizeof(ifmr.ifm_name));
+
+ if (ioctl(general_socket, SIOCGIFMEDIA, (caddr_t)&ifmr) < 0) {
+ if (errno != E2BIG)
+ return sprintf(outwalk, "?");
+ }
+
+ struct ifmedia_description *desc;
+ struct ifmedia_description ifm_subtype_descriptions[] =
+ IFM_SUBTYPE_DESCRIPTIONS;
+
+ for (desc = ifm_subtype_descriptions; desc->ifmt_string != NULL; desc++) {
+ /*
+ * Skip these non-informative values and go right ahead to the
+ * actual speeds.
+ */
+ if (BEGINS_WITH(desc->ifmt_string, "autoselect") ||
+ BEGINS_WITH(desc->ifmt_string, "auto"))
+ continue;
+
+ if (IFM_TYPE_MATCH(desc->ifmt_word, ifmr.ifm_active) &&
+ IFM_SUBTYPE(desc->ifmt_word) == IFM_SUBTYPE(ifmr.ifm_active))
+ break;
+ }
+ ethspeed = (desc->ifmt_string != NULL ? desc->ifmt_string : "?");
+ return sprintf(outwalk, "%s", ethspeed);
+
+#else
+ return sprintf(outwalk, "?");