X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=lib%2Fsysinfo.c;fp=lib%2Fsysinfo.c;h=fd60dccd1f70bf9a817ee9503aca97577e037fec;hb=67fc54773e1504698e80c9cb83977bde32665350;hp=4f6b564818370b3e4be9a8e05e264914cd648d09;hpb=6a9e980b8799891e0a5467a0126a60b169c8f4eb;p=ap-utils.git diff --git a/lib/sysinfo.c b/lib/sysinfo.c index 4f6b564..fd60dcc 100644 --- a/lib/sysinfo.c +++ b/lib/sysinfo.c @@ -37,21 +37,24 @@ extern int LINES; 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 + }; + /* This one is ATMEL12350 VERNET MIB specific. */ + char UpTime[] = { + 0x2B, 0x06, 0x01, 0x04, 0x01, 0xE0, 0x3E, 0x01, 0x02, 0x09, 0x01, 0x00 }; char message[200]; int i; - varbind varbinds[2]; + varbind varbinds[3]; + struct SysDeviceInfo_ATMEL410 ptr410; + struct SysDeviceInfo_ATMEL12350 ptr12350; extern short ap_type; - struct SysDeviceInfo_ATMEL410 ptr410; - struct SysDeviceInfo_ATMEL12350 ptr12350; + extern char IS_ATMEL12350_VERNET; /* * These have to represent used SysDeviceInfo_{ATMEL410,ATMEL12350} members @@ -72,20 +75,33 @@ void atmel_sysinfo() sysDeviceInfo[6] = 0x3E; } + i = 0; + varbinds[0].oid = sysDescr; varbinds[0].len_oid = sizeof(sysDescr); varbinds[0].value = sysDescr; varbinds[0].type = NULL_VALUE; varbinds[0].len_val = 0; + i++; varbinds[1].oid = sysDeviceInfo; varbinds[1].len_oid = sizeof(sysDeviceInfo); - varbinds[1].value = sysDescr; + varbinds[1].value = sysDeviceInfo; varbinds[1].len_val = 0; varbinds[1].type = NULL_VALUE; + i++; + + if (IS_ATMEL12350_VERNET) { + varbinds[2].oid = UpTime; + varbinds[2].len_oid = sizeof(UpTime); + varbinds[2].value = UpTime; + varbinds[2].len_val = 0; + varbinds[2].type = NULL_VALUE; + i++; + } print_help(WAIT_RET); - if (snmp(varbinds, 2, GET) <= 0) { + if (snmp(varbinds, i, GET) <= 0) { print_helperr(ERR_RET); goto exit; } @@ -111,7 +127,7 @@ void atmel_sysinfo() } else { /* ATMEL12350 */ memcpy(&ptr12350, varbinds[1].value, sizeof(struct SysDeviceInfo_ATMEL12350)); - ap_regdomain=ptr12350.RegulationDomain; + ap_regdomain = ptr12350.RegulationDomain; ap_sversion = ptr12350.StructVersion; ap_macaddr = ptr12350.MacAddress; ap_prodtype = ptr12350.ProductType; @@ -163,6 +179,16 @@ void atmel_sysinfo() oui2manufacturer(ap_macaddr)); mvwaddstr(main_sub, 10, 0, message); + if (IS_ATMEL12350_VERNET) { + i = varbinds[2].len_val == 2 ? + (varbinds[2].value[0] << 8) | varbinds[2].value[1] : + varbinds[2].value[0] < 0x80 ? + varbinds[2].value[0] : 0xff00 | varbinds[2].value[0]; + sprintf(message, _("Uptime: %u days, %02u:%02u:%02u hours:mins:secs"), + i / 60 / 60 / 24, i / 60 / 60 % 24, i / 60 % 60, i % 60); + mvwaddstr(main_sub, 11, 0, message); + } + wrefresh(main_sub); print_help(ANY_KEY); exit: @@ -372,7 +398,7 @@ void nwn_sysinfo() goto exit; } - sprintf(message, _("WEP inplemented: %s"), + sprintf(message, _("WEP implemented: %s"), (*(varbinds[0].value) == 1) ? ON : OFF); mvwaddstr(main_sub, 13, 0, message); sprintf(message, _("Diversity: %s"),