X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=lib%2Fsysinfo.c;h=6e1e7f8a387bd779cf12f4c96899779e7e489d24;hb=63444196dd1edb154f81d9418b3d0bc2367163e5;hp=4f6b564818370b3e4be9a8e05e264914cd648d09;hpb=09ed626f25fb3e7c57ad7a59e5261ea005aa498f;p=ap-utils.git diff --git a/lib/sysinfo.c b/lib/sysinfo.c index 4f6b564..6e1e7f8 100644 --- a/lib/sysinfo.c +++ b/lib/sysinfo.c @@ -21,40 +21,56 @@ #include #include #include -#include #include #include #include #include "ap-utils.h" -#include "ap-curses.h" #define SYS_DESCR _("System Description: ") +#define SYSINFO _("System Info") #define OID_NUM 11 extern WINDOW *main_sub; -extern int LINES; +extern char* bridge_modes[6]; void atmel_sysinfo() { - char sysDescr[] = - { 0x2B, 0x06, 0x01, 0x04, 0x01, 0x83, 0x1A, 0x01, 0x01, - 0x01, 0x01, 0x00 + char sysDescr[] = { + 0x2B, 0x06, 0x01, 0x04, 0x01, 0x83, 0x1A, 0x01, 0x01, 0x01, 0x01, 0x00 }; - char sysDeviceInfo[] = - { 0x2B, 0x06, 0x01, 0x04, 0x01, 0x83, 0x1A, 0x01, 0x01, - 0x01, 0x05, 0x00 + char sysDeviceInfo[] = { + 0x2B, 0x06, 0x01, 0x04, 0x01, 0x83, 0x1A, 0x01, 0x01, 0x01, 0x05, 0x00 + }; + char bridgeOperationalMode[] = { + 0x2B, 0x06, 0x01, 0x04, 0x01, 0x83, 0x1A, 0x01, 0x01, 0x04, 0x01, 0x00 + }; + /* This one is ATMEL12350 EZYNET MIB specific. */ + char UpTime[] = { + 0x2B, 0x06, 0x01, 0x04, 0x01, 0xE0, 0x3E, 0x01, 0x02, 0x09, 0x01, 0x00 }; +char *bridge_modes[6] = { + _("Wireless Bridge Point to MultiPoint"), + _("Access Point"), + _("Access Point client"), + _("Wireless Bridge Point to Point"), + _("Repeater"), + _("unknown") +}; + + char message[200]; int i; - varbind varbinds[2]; - extern short ap_type; - struct SysDeviceInfo_ATMEL410 ptr410; - struct SysDeviceInfo_ATMEL12350 ptr12350; + varbind varbinds[4]; + struct sysDeviceInfo_128 str128; + struct sysDeviceInfo_160 str160; + extern short ap_type, ap_vendorext; + extern int LINES, wait_mode; + extern rdprops regdom_types[]; /* - * These have to represent used SysDeviceInfo_{ATMEL410,ATMEL12350} members + * These have to represent used sysDeviceInfo_{128,160} members */ uint32_t ap_sversion; char *ap_macaddr; @@ -70,104 +86,167 @@ void atmel_sysinfo() sysDescr[6] = 0x3E; sysDeviceInfo[5] = 0xE0; sysDeviceInfo[6] = 0x3E; + bridgeOperationalMode[5] = 0xE0; + bridgeOperationalMode[6] = 0x3E; } - varbinds[0].oid = sysDescr; - varbinds[0].len_oid = sizeof(sysDescr); - varbinds[0].value = sysDescr; - varbinds[0].type = NULL_VALUE; - varbinds[0].len_val = 0; + print_top(wait_mode == WAIT_TIMEOUT ? POLL_ON : POLL_OFF, SYSINFO); - varbinds[1].oid = sysDeviceInfo; - varbinds[1].len_oid = sizeof(sysDeviceInfo); - varbinds[1].value = sysDescr; - varbinds[1].len_val = 0; - varbinds[1].type = NULL_VALUE; + if (wait_mode == WAIT_TIMEOUT) + print_help(QT_HELP); - print_help(WAIT_RET); - if (snmp(varbinds, 2, GET) <= 0) { - print_helperr(ERR_RET); - goto exit; - } + while (1) { + i = 0; - print_title(_("System Info")); + varbinds[i].oid = sysDescr; + varbinds[i].len_oid = sizeof(sysDescr); + varbinds[i].value = sysDescr; + varbinds[i].type = NULL_VALUE; + varbinds[i].len_val = 0; + i++; - mvwaddstr(main_sub, 0, 0, _("Device hardware/software/name info:")); - for (i = 0; i < varbinds[0].len_val && *(varbinds[0].value + i); i++) { - mvwaddch(main_sub, 1, i + 1, *(varbinds[0].value + i)); - } + varbinds[i].oid = sysDeviceInfo; + varbinds[i].len_oid = sizeof(sysDeviceInfo); + varbinds[i].value = sysDeviceInfo; + varbinds[i].len_val = 0; + varbinds[i].type = NULL_VALUE; + i++; - if (ap_type == ATMEL410) { - - memcpy(&ptr410, varbinds[1].value, sizeof(struct SysDeviceInfo_ATMEL410)); - ap_sversion = ptr410.StructVersion; - ap_macaddr = ptr410.MacAddress; - ap_regdomain = swap4(ptr410.RegulationDomain); - ap_prodtype = ptr410.ProductType; - ap_oemname = ptr410.OEMName; - ap_oemid = ptr410.OEMID; - ap_prodname = ptr410.ProductName; - ap_hwrev = ptr410.HardwareRevision; - } else { /* ATMEL12350 */ - - memcpy(&ptr12350, varbinds[1].value, sizeof(struct SysDeviceInfo_ATMEL12350)); - ap_regdomain=ptr12350.RegulationDomain; - ap_sversion = ptr12350.StructVersion; - ap_macaddr = ptr12350.MacAddress; - ap_prodtype = ptr12350.ProductType; - ap_oemname = ptr12350.OEMName; - ap_oemid = ptr12350.OEMID; - ap_prodname = ptr12350.ProductName; - ap_hwrev = ptr12350.HardwareRevision; - } + varbinds[i].oid = bridgeOperationalMode; + varbinds[i].len_oid = sizeof(bridgeOperationalMode); + varbinds[i].value = bridgeOperationalMode; + varbinds[i].len_val = 0; + varbinds[i].type = NULL_VALUE; + i++; - sprintf(message, "%s%02X%02X%02X%02X%02X%02X", MAC, + if (ap_type == ATMEL12350 && ap_vendorext == EZYNET) { + varbinds[i].oid = UpTime; + varbinds[i].len_oid = sizeof(UpTime); + varbinds[i].value = UpTime; + varbinds[i].len_val = 0; + varbinds[i].type = NULL_VALUE; + i++; + } + + if (wait_mode == WAIT_FOREVER) + print_help(WAIT_RET); + + if (snmp(varbinds, i, GET) < i) { + print_helperr(ERR_RET); + getch(); + goto quit; + } + + if (wait_mode == WAIT_FOREVER) + print_help(QT_HELP); + + mvwaddstr(main_sub, 0, 0, _("Device hardware/software/name info:")); + for (i = 0; i < varbinds[0].len_val && *(varbinds[0].value + i); i++) + mvwaddch(main_sub, 1, i + 1, *(varbinds[0].value + i)); + + if (varbinds[1].len_val == 128) { + memcpy(&str128, varbinds[1].value, + sizeof(struct sysDeviceInfo_128)); + ap_sversion = str128.StructVersion; + ap_macaddr = str128.MacAddress; + ap_regdomain = swap4(str128.RegulatoryDomain); + ap_prodtype = str128.ProductType; + ap_oemname = str128.OEMName; + ap_oemid = str128.OEMID; + ap_prodname = str128.ProductName; + ap_hwrev = str128.HardwareRevision; + } else { /* varbinds[1].len_val == 160 */ + memcpy(&str160, varbinds[1].value, + sizeof(struct sysDeviceInfo_160)); + ap_regdomain = str160.RegulatoryDomain; + ap_sversion = str160.StructVersion; + ap_macaddr = str160.MacAddress; + ap_prodtype = str160.ProductType; + ap_oemname = str160.OEMName; + ap_oemid = str160.OEMID; + ap_prodname = str160.ProductName; + ap_hwrev = str160.HardwareRevision; + } + + sprintf(message, _("Operational mode: %s"), + bridge_modes[*(varbinds[2].value) - 1]); + mvwaddstr(main_sub, 2, 0, message); + + sprintf(message, "%s%02X%02X%02X%02X%02X%02X", MAC, ap_macaddr[0] & 0xFF, ap_macaddr[1] & 0xFF, ap_macaddr[2] & 0xFF, ap_macaddr[3] & 0xFF, ap_macaddr[4] & 0xFF, ap_macaddr[5] & 0xFF); - mvwaddstr(main_sub, 2, 0, message); - - mvwaddstr(main_sub, 3, 0, _("Product name:")); - for (i = 0; i < 32 && ap_prodname[i]; i++) { - mvwaddch(main_sub, 3, i + 14, ap_prodname[i]); - } - - sprintf(message, _("Product type: %u"), swap4(ap_prodtype)); - mvwaddstr(main_sub, 4, 0, message); - - sprintf(message, _("Hardware revision: %u"), swap4(ap_hwrev)); - mvwaddstr(main_sub, 5, 0, message); - - mvwaddstr(main_sub, 6, 0, _("OEM name:")); - for (i = 0; i < 32 && ap_oemname[i]; i++) { - mvwaddch(main_sub, 6, i + 10, ap_oemname[i]); + mvwaddstr(main_sub, 3, 0, message); + + mvwaddstr(main_sub, 4, 0, _("Product name: ")); + for (i = 0; i < 32 && ap_prodname[i]; i++) + waddch(main_sub, ap_prodname[i]); + + sprintf(message, _("Product type: %u"), swap4(ap_prodtype)); + mvwaddstr(main_sub, 5, 0, message); + + mvwaddstr(main_sub, 6, 0, _("OEM name: ")); + for (i = 0; i < 32 && ap_oemname[i]; i++) + waddch(main_sub, ap_oemname[i]); + + sprintf(message, "OEM ID: %u", swap4(ap_oemid)); + mvwaddstr(main_sub, 7, 0, message); + + sprintf(message, _("Hardware revision: %u"), swap4(ap_hwrev)); + mvwaddstr(main_sub, 8, 0, message); + + i = regdom_idx(ap_regdomain); + sprintf(message, "Regulatory domain: %s [%d]", + regdom_types[i].desc, ap_regdomain); + mvwaddstr(main_sub, 9, 0, message); + + sprintf(message, _("Info structure version: %u"), swap4(ap_sversion)); + mvwaddstr(main_sub, 10, 0, message); + + sprintf(message, _("Manufacturer OUI: %02X %02X %02X (%s)"), + ap_macaddr[0] & 0xFF, ap_macaddr[1] & 0xFF, ap_macaddr[2] & 0xFF, + oui2manufacturer(ap_macaddr)); + mvwaddstr(main_sub, 11, 0, message); + + if (ap_type == ATMEL12350 && ap_vendorext == EZYNET) { + unsigned int j = 0; + + if (varbinds[3].len_val > 1) { + for (i = 0; i < varbinds[3].len_val; i++) + j |= (varbinds[3].value[i] + << (8 * (varbinds[3].len_val - i - 1))); + } else { + j = varbinds[3].value[0] & 0x80 ? + 0xff00 | varbinds[3].value[0] : varbinds[3].value[0]; + } + sprintf(message, + _("Uptime: %u days, %02u:%02u:%02u hours:mins:secs"), + j / 60 / 60 / 24, j / 60 / 60 % 24, j / 60 % 60, j % 60); + mvwaddstr(main_sub, 12, 0, message); + } + + wrefresh(main_sub); + + i = wait_key(); + if (i == -1) + goto quit; + + switch((char) i) { + case 'q': + case 'Q': + goto quit; + case 't': + case 'T': + wait_mode = (wait_mode == WAIT_FOREVER ? + WAIT_TIMEOUT : WAIT_FOREVER); + print_top(wait_mode == WAIT_TIMEOUT ? POLL_ON : POLL_OFF, + SYSINFO); + } + + /* either timeout for user input (i == 0) or invalid key => continue */ } - - sprintf(message, "OEM ID: %u", swap4(ap_oemid)); - mvwaddstr(main_sub, 7, 0, message); - - sprintf(message, _("Regulation domain: %s [%d]"), - (ap_regdomain == 0x10) ? _("FCC (USA)") : - (ap_regdomain == 0x20) ? _("DOC (Canada)") : - (ap_regdomain == 0x30) ? _("ETSI (Europe)") : - (ap_regdomain == 0x31) ? _("Spain") : - (ap_regdomain == 0x32) ? _("France") : - (ap_regdomain == 0x40) ? _("MKK (Japan)") : _("unknown"), ap_regdomain); - mvwaddstr(main_sub, 8, 0, message); - - sprintf(message, _("Info structure version: %u"), swap4(ap_sversion)); - mvwaddstr(main_sub, 9, 0, message); - - sprintf(message, _("Manufacturer OUI: %02X %02X %02X (%s)"), - ap_macaddr[0] & 0xFF, ap_macaddr[1] & 0xFF, ap_macaddr[2] & 0xFF, - oui2manufacturer(ap_macaddr)); - mvwaddstr(main_sub, 10, 0, message); - - wrefresh(main_sub); - print_help(ANY_KEY); - exit: - getch(); - print_title(""); + quit: + print_top(NULL, NULL); clear_main(0); } @@ -186,7 +265,6 @@ int get_RegDomain() if (snmp(varbinds, 1, GET) <= 0) return 0; return *(varbinds[0].value); - } void nwn_sysinfo() @@ -242,190 +320,214 @@ void nwn_sysinfo() struct in_addr ip; varbind varbinds[OID_NUM]; size_t time_stamp; - - for (i = 0; i < OID_NUM; i++) { - varbinds[i].value = oid_mac; - varbinds[i].type = NULL_VALUE; - varbinds[i].len_val = 0; - } - varbinds[0].oid = oid_mac; - varbinds[0].len_oid = sizeof(oid_mac); - varbinds[1].oid = oid_manufacturerID; - varbinds[1].len_oid = sizeof(oid_manufacturerID); - varbinds[2].oid = oid_productID; - varbinds[2].len_oid = sizeof(oid_productID); - varbinds[3].oid = oid_dot11manufacturerOUI; - varbinds[3].len_oid = sizeof(oid_dot11manufacturerOUI); - varbinds[4].oid = oid_dot11manufacturerName; - varbinds[4].len_oid = sizeof(oid_dot11manufacturerName); - varbinds[5].oid = oid_dot11manufacturerProductName; - varbinds[5].len_oid = sizeof(oid_dot11manufacturerProductName); - varbinds[6].oid = oid_dot11manufacturerProductVersion; - varbinds[6].len_oid = sizeof(oid_dot11manufacturerProductVersion); - varbinds[7].oid = oid_dot11PHYType; - varbinds[7].len_oid = sizeof(oid_dot11PHYType); - varbinds[8].oid = oid_dot11TempType; - varbinds[8].len_oid = sizeof(oid_dot11TempType); - varbinds[9].oid = oid_TxPowerLevel1; - varbinds[9].len_oid = sizeof(oid_TxPowerLevel1); - - print_help(WAIT_RET); - if (snmp(varbinds, OID_NUM - 1, GET) <= 0) { - print_helperr(ERR_RET); - goto exit; - } - print_title(_("System Info")); - - - - sprintf(message, "%s%02X%02X%02X%02X%02X%02X", MAC, + extern int wait_mode; + + print_top(wait_mode == WAIT_TIMEOUT ? POLL_ON : POLL_OFF, SYSINFO); + + if (wait_mode == WAIT_TIMEOUT) + print_help(QT_HELP); + + while (1) { + for (i = 0; i < OID_NUM; i++) { + varbinds[i].value = oid_mac; + varbinds[i].type = NULL_VALUE; + varbinds[i].len_val = 0; + } + varbinds[0].oid = oid_mac; + varbinds[0].len_oid = sizeof(oid_mac); + varbinds[1].oid = oid_manufacturerID; + varbinds[1].len_oid = sizeof(oid_manufacturerID); + varbinds[2].oid = oid_productID; + varbinds[2].len_oid = sizeof(oid_productID); + varbinds[3].oid = oid_dot11manufacturerOUI; + varbinds[3].len_oid = sizeof(oid_dot11manufacturerOUI); + varbinds[4].oid = oid_dot11manufacturerName; + varbinds[4].len_oid = sizeof(oid_dot11manufacturerName); + varbinds[5].oid = oid_dot11manufacturerProductName; + varbinds[5].len_oid = sizeof(oid_dot11manufacturerProductName); + varbinds[6].oid = oid_dot11manufacturerProductVersion; + varbinds[6].len_oid = sizeof(oid_dot11manufacturerProductVersion); + varbinds[7].oid = oid_dot11PHYType; + varbinds[7].len_oid = sizeof(oid_dot11PHYType); + varbinds[8].oid = oid_dot11TempType; + varbinds[8].len_oid = sizeof(oid_dot11TempType); + varbinds[9].oid = oid_TxPowerLevel1; + varbinds[9].len_oid = sizeof(oid_TxPowerLevel1); + + if (wait_mode == WAIT_FOREVER) + print_help(WAIT_RET); + + if (snmp(varbinds, OID_NUM - 1, GET) < OID_NUM - 1) { + print_helperr(ERR_RET); + getch(); + goto quit; + } + + sprintf(message, "%s%02X%02X%02X%02X%02X%02X", MAC, varbinds[0].value[0] & 0xFF, varbinds[0].value[1] & 0xFF, varbinds[0].value[2] & 0xFF, varbinds[0].value[3] & 0xFF, varbinds[0].value[4] & 0xFF, varbinds[0].value[5] & 0xFF); - mvwaddstr(main_sub, 0, 0, message); + mvwaddstr(main_sub, 0, 0, message); - mvwaddstr(main_sub, 3, 0, _("Manufacturer:")); - i = 0; - while (varbinds[4].len_val > i) { - mvwaddch(main_sub, 3, i + 20, *(varbinds[4].value + i++)); - } + mvwaddstr(main_sub, 3, 0, _("Manufacturer:")); + i = 0; + while (varbinds[4].len_val > i) + mvwaddch(main_sub, 3, i + 20, *(varbinds[4].value + i++)); - mvwaddstr(main_sub, 4, 0, _("Manufacturer ID:")); - i = 0; - while (varbinds[1].len_val > i) { - mvwaddch(main_sub, 4, i + 20, *(varbinds[1].value + i++)); - } + mvwaddstr(main_sub, 4, 0, _("Manufacturer ID:")); + i = 0; + while (varbinds[1].len_val > i) + mvwaddch(main_sub, 4, i + 20, *(varbinds[1].value + i++)); - sprintf(message, _("Manufacturer OUI: %02X %02X %02X (%s)"), + sprintf(message, _("Manufacturer OUI: %02X %02X %02X (%s)"), varbinds[3].value[0] & 0xFF, varbinds[3].value[1] & 0xFF, varbinds[3].value[2] & 0xFF, oui2manufacturer(varbinds[3].value)); - mvwaddstr(main_sub, 5, 0, message); - - sprintf(message, _("Product Name:")); - mvwaddstr(main_sub, 6, 0, message); - i = 0; - while (varbinds[5].len_val > i) { - mvwaddch(main_sub, 6, i + 20, *(varbinds[5].value + i++)); - } - - sprintf(message, _("Product ID:")); - mvwaddstr(main_sub, 7, 0, message); - i = 0; - while (varbinds[2].len_val > i) { - mvwaddch(main_sub, 7, i + 20, *(varbinds[2].value + i++)); - } - sprintf(message, _("Product Version:")); - mvwaddstr(main_sub, 8, 0, message); - i = 0; - while (varbinds[6].len_val > i) { - mvwaddch(main_sub, 8, i + 20, *(varbinds[6].value + i++)); - } - - - sprintf(message, _("PHYType: %s"), types[*(varbinds[7].value) - 1]); - mvwaddstr(main_sub, 9, 0, message); - - sprintf(message, _("Temperature: %s"), temp[*(varbinds[8].value) - 1]); - mvwaddstr(main_sub, 10, 0, message); - - if ((i = get_RegDomain()) == 0) { - print_helperr(ERR_RET); - goto exit; - } - sprintf(message, _("Regulation Domain: %s"), + mvwaddstr(main_sub, 5, 0, message); + + sprintf(message, _("Product Name:")); + mvwaddstr(main_sub, 6, 0, message); + i = 0; + while (varbinds[5].len_val > i) + mvwaddch(main_sub, 6, i + 20, *(varbinds[5].value + i++)); + + sprintf(message, _("Product ID:")); + mvwaddstr(main_sub, 7, 0, message); + i = 0; + while (varbinds[2].len_val > i) + mvwaddch(main_sub, 7, i + 20, *(varbinds[2].value + i++)); + + sprintf(message, _("Product Version:")); + mvwaddstr(main_sub, 8, 0, message); + i = 0; + while (varbinds[6].len_val > i) + mvwaddch(main_sub, 8, i + 20, *(varbinds[6].value + i++)); + + sprintf(message, _("PHYType: %s"), types[*(varbinds[7].value) - 1]); + mvwaddstr(main_sub, 9, 0, message); + + sprintf(message, _("Temperature: %s"), temp[*(varbinds[8].value) - 1]); + mvwaddstr(main_sub, 10, 0, message); + + if ((i = get_RegDomain()) == 0) { + print_helperr(ERR_RET); + getch(); + goto quit; + } + sprintf(message, _("Regulatory Domain: %s"), (i == 0x10) ? _("FCC (USA)") : (i == 0x20) ? _("DOC (Canada)") : (i == 0x30) ? _("ETSI (Europe)") : (i == 0x31) ? _("Spain") : (i == 0x32) ? _("France") : (i == 0x40) ? _("MKK (Japan)") : _("unknown")); - mvwaddstr(main_sub, 11, 0, message); - - sprintf(message, _("Transmit Power: %u mW"), *(varbinds[9].value)); - mvwaddstr(main_sub, 12, 0, message); - - varbinds[0].oid = oid_dot11PrivacyOptionImplemented; - varbinds[0].len_oid = sizeof(oid_dot11PrivacyOptionImplemented); - varbinds[0].value = oid_mac; - varbinds[0].type = NULL_VALUE; - varbinds[0].len_val = 0; - varbinds[1].oid = oid_dot11DiversitySupport; - varbinds[1].len_oid = sizeof(oid_dot11DiversitySupport); - varbinds[1].value = oid_mac; - varbinds[1].type = NULL_VALUE; - varbinds[1].len_val = 0; - varbinds[2].oid = oid_sysDescr; - varbinds[2].len_oid = sizeof(oid_sysDescr); - varbinds[2].value = oid_mac; - varbinds[2].type = NULL_VALUE; - varbinds[2].len_val = 0; - varbinds[3].oid = oid_sysUptime; - varbinds[3].len_oid = sizeof(oid_sysUptime); - varbinds[3].value = oid_mac; - varbinds[3].type = NULL_VALUE; - varbinds[3].len_val = 0; - - print_help(WAIT_RET); - if (snmp(varbinds, 4, GET) <= 0) { - print_helperr(ERR_RET); - goto exit; - } - - sprintf(message, _("WEP inplemented: %s"), + mvwaddstr(main_sub, 11, 0, message); + + sprintf(message, _("Transmit Power: %u mW"), *(varbinds[9].value)); + mvwaddstr(main_sub, 12, 0, message); + + varbinds[0].oid = oid_dot11PrivacyOptionImplemented; + varbinds[0].len_oid = sizeof(oid_dot11PrivacyOptionImplemented); + varbinds[0].value = oid_mac; + varbinds[0].type = NULL_VALUE; + varbinds[0].len_val = 0; + varbinds[1].oid = oid_dot11DiversitySupport; + varbinds[1].len_oid = sizeof(oid_dot11DiversitySupport); + varbinds[1].value = oid_mac; + varbinds[1].type = NULL_VALUE; + varbinds[1].len_val = 0; + varbinds[2].oid = oid_sysDescr; + varbinds[2].len_oid = sizeof(oid_sysDescr); + varbinds[2].value = oid_mac; + varbinds[2].type = NULL_VALUE; + varbinds[2].len_val = 0; + varbinds[3].oid = oid_sysUptime; + varbinds[3].len_oid = sizeof(oid_sysUptime); + varbinds[3].value = oid_mac; + varbinds[3].type = NULL_VALUE; + varbinds[3].len_val = 0; + + if (snmp(varbinds, 4, GET) < 4) { + print_helperr(ERR_RET); + getch(); + goto quit; + } + + sprintf(message, _("WEP implemented: %s"), (*(varbinds[0].value) == 1) ? ON : OFF); - mvwaddstr(main_sub, 13, 0, message); - sprintf(message, _("Diversity: %s"), + mvwaddstr(main_sub, 13, 0, message); + sprintf(message, _("Diversity: %s"), diversity[*(varbinds[1].value) - 1]); - mvwaddstr(main_sub, 14, 0, message); - mvwaddstr(main_sub, LINES - 8, 0, SYS_DESCR); - i = 0; - while (varbinds[2].len_val > i && varbinds[2].value[i]) { - message[i] = varbinds[2].value[i]; - i++; - } - message[i] = '\0'; - mvwaddstr(main_sub, LINES - 8, strlen(SYS_DESCR) + 1, message); - - time_stamp = 0; - i = 1; - - for (c = 1; c <= varbinds[3].len_val; c++) { - time_stamp += - (unsigned char) varbinds[3].value[varbinds[3].len_val - c] * i; - i *= 256; - } - - hand = time_stamp % 100; - time_stamp = time_stamp / 100; - sec = time_stamp % 60; - time_stamp = time_stamp / 60; - min = time_stamp % 60; - time_stamp = time_stamp / 60; - - sprintf(message, _("Uptime: %u:%02u:%02u.%02u"), time_stamp, min, sec, + mvwaddstr(main_sub, 14, 0, message); + mvwaddstr(main_sub, LINES - 8, 0, SYS_DESCR); + i = 0; + while (varbinds[2].len_val > i && varbinds[2].value[i]) { + message[i] = varbinds[2].value[i]; + i++; + } + message[i] = '\0'; + mvwaddstr(main_sub, LINES - 8, strlen(SYS_DESCR) + 1, message); + + time_stamp = 0; + i = 1; + + for (c = 1; c <= varbinds[3].len_val; c++) { + time_stamp += + (unsigned char) varbinds[3].value[varbinds[3].len_val - c] * i; + i *= 256; + } + + hand = time_stamp % 100; + time_stamp = time_stamp / 100; + sec = time_stamp % 60; + time_stamp = time_stamp / 60; + min = time_stamp % 60; + time_stamp = time_stamp / 60; + + sprintf(message, _("Uptime: %u:%02u:%02u.%02u"), time_stamp, min, sec, hand); - mvwaddstr(main_sub, 15, 0, message); - - varbinds[0].oid = oid_ip; - varbinds[0].len_oid = sizeof(oid_ip); - varbinds[0].value = oid_mac; - varbinds[0].type = NULL_VALUE; - varbinds[0].len_val = 0; - - print_help(WAIT_RET); - if (snmp(varbinds, 1, GET_NEXT) <= 0) { - print_helperr(ERR_RET); - goto exit; + mvwaddstr(main_sub, 15, 0, message); + + varbinds[0].oid = oid_ip; + varbinds[0].len_oid = sizeof(oid_ip); + varbinds[0].value = oid_mac; + varbinds[0].type = NULL_VALUE; + varbinds[0].len_val = 0; + + if (snmp(varbinds, 1, GET_NEXT) <= 0) { + print_helperr(ERR_RET); + getch(); + goto quit; + } + + if (wait_mode == WAIT_FOREVER) + print_help(QT_HELP); + + memcpy(&ip.s_addr, varbinds[0].value, 4); + sprintf(message, _("IP Address: %s"), inet_ntoa(ip)); + mvwaddstr(main_sub, 1, 0, message); + wrefresh(main_sub); + + i = wait_key(); + if (i == -1) + goto quit; + + switch((char) i) { + case 'q': + case 'Q': + goto quit; + case 't': + case 'T': + wait_mode = (wait_mode == WAIT_FOREVER ? + WAIT_TIMEOUT : WAIT_FOREVER); + print_top(wait_mode == WAIT_TIMEOUT ? POLL_ON : POLL_OFF, + SYSINFO); + } + + /* either timeout for user input (i == 0) or invalid key => continue */ } - memcpy(&ip.s_addr, varbinds[0].value, 4); - sprintf(message, _("IP Address: %s"), inet_ntoa(ip)); - mvwaddstr(main_sub, 1, 0, message); - - wrefresh(main_sub); - print_help(ANY_KEY); - exit: - getch(); - print_title(""); + quit: + print_top(NULL, NULL); clear_main(0); } +