2 * sysinfo.c from Access Point SNMP Utils for Linux
4 * Copyright (c) 2002 Roman Festchook <roma at polesye dot net>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License Version 2 from
8 * June 1991 as published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 #include <sys/types.h>
29 #include "ap-curses.h"
31 #define SYS_DESCR _("System Description: ")
35 extern WINDOW *main_sub;
41 { 0x2B, 0x06, 0x01, 0x04, 0x01, 0x83, 0x1A, 0x01, 0x01,
44 char sysDeviceInfo[] =
45 { 0x2B, 0x06, 0x01, 0x04, 0x01, 0x83, 0x1A, 0x01, 0x01,
53 struct SysDeviceInfo_ATMEL410 ptr410;
54 struct SysDeviceInfo_ATMEL12350 ptr12350;
57 * These have to represent used SysDeviceInfo_{ATMEL410,ATMEL12350} members
61 uint32_t ap_regdomain;
68 if (ap_type == ATMEL12350) {
71 sysDeviceInfo[5] = 0xE0;
72 sysDeviceInfo[6] = 0x3E;
75 varbinds[0].oid = sysDescr;
76 varbinds[0].len_oid = sizeof(sysDescr);
77 varbinds[0].value = sysDescr;
78 varbinds[0].type = NULL_VALUE;
79 varbinds[0].len_val = 0;
81 varbinds[1].oid = sysDeviceInfo;
82 varbinds[1].len_oid = sizeof(sysDeviceInfo);
83 varbinds[1].value = sysDescr;
84 varbinds[1].len_val = 0;
85 varbinds[1].type = NULL_VALUE;
88 if (snmp(varbinds, 2, GET) <= 0) {
89 print_helperr(ERR_RET);
93 print_title(_("System Info"));
95 mvwaddstr(main_sub, 0, 0, _("Device hardware/software/name info:"));
96 for (i = 0; i < varbinds[0].len_val && *(varbinds[0].value + i); i++) {
97 mvwaddch(main_sub, 1, i + 1, *(varbinds[0].value + i));
100 if (ap_type == ATMEL410) {
102 memcpy(&ptr410, varbinds[1].value, sizeof(struct SysDeviceInfo_ATMEL410));
103 ap_sversion = ptr410.StructVersion;
104 ap_macaddr = ptr410.MacAddress;
105 ap_regdomain = swap4(ptr410.RegulationDomain);
106 ap_prodtype = ptr410.ProductType;
107 ap_oemname = ptr410.OEMName;
108 ap_oemid = ptr410.OEMID;
109 ap_prodname = ptr410.ProductName;
110 ap_hwrev = ptr410.HardwareRevision;
111 } else { /* ATMEL12350 */
113 memcpy(&ptr12350, varbinds[1].value, sizeof(struct SysDeviceInfo_ATMEL12350));
114 ap_regdomain=ptr12350.RegulationDomain;
115 ap_sversion = ptr12350.StructVersion;
116 ap_macaddr = ptr12350.MacAddress;
117 ap_prodtype = ptr12350.ProductType;
118 ap_oemname = ptr12350.OEMName;
119 ap_oemid = ptr12350.OEMID;
120 ap_prodname = ptr12350.ProductName;
121 ap_hwrev = ptr12350.HardwareRevision;
124 sprintf(message, "%s%02X%02X%02X%02X%02X%02X", MAC,
125 ap_macaddr[0] & 0xFF, ap_macaddr[1] & 0xFF,
126 ap_macaddr[2] & 0xFF, ap_macaddr[3] & 0xFF,
127 ap_macaddr[4] & 0xFF, ap_macaddr[5] & 0xFF);
128 mvwaddstr(main_sub, 2, 0, message);
130 mvwaddstr(main_sub, 3, 0, _("Product name:"));
131 for (i = 0; i < 32 && ap_prodname[i]; i++) {
132 mvwaddch(main_sub, 3, i + 14, ap_prodname[i]);
135 sprintf(message, _("Product type: %u"), swap4(ap_prodtype));
136 mvwaddstr(main_sub, 4, 0, message);
138 sprintf(message, _("Hardware revision: %u"), swap4(ap_hwrev));
139 mvwaddstr(main_sub, 5, 0, message);
141 mvwaddstr(main_sub, 6, 0, _("OEM name:"));
142 for (i = 0; i < 32 && ap_oemname[i]; i++) {
143 mvwaddch(main_sub, 6, i + 10, ap_oemname[i]);
146 sprintf(message, "OEM ID: %u", swap4(ap_oemid));
147 mvwaddstr(main_sub, 7, 0, message);
149 sprintf(message, _("Regulation domain: %s [%d]"),
150 (ap_regdomain == 0x10) ? _("FCC (USA)") :
151 (ap_regdomain == 0x20) ? _("DOC (Canada)") :
152 (ap_regdomain == 0x30) ? _("ETSI (Europe)") :
153 (ap_regdomain == 0x31) ? _("Spain") :
154 (ap_regdomain == 0x32) ? _("France") :
155 (ap_regdomain == 0x40) ? _("MKK (Japan)") : _("unknown"), ap_regdomain);
156 mvwaddstr(main_sub, 8, 0, message);
158 sprintf(message, _("Info structure version: %u"), swap4(ap_sversion));
159 mvwaddstr(main_sub, 9, 0, message);
161 sprintf(message, _("Manufacturer OUI: %02X %02X %02X (%s)"),
162 ap_macaddr[0] & 0xFF, ap_macaddr[1] & 0xFF, ap_macaddr[2] & 0xFF,
163 oui2manufacturer(ap_macaddr));
164 mvwaddstr(main_sub, 10, 0, message);
176 char oid_dot11CurrentRegDomain[] =
177 { 0x2a, 0x86, 0x48, 0xce, 0x34, 0x04, 0x01, 0x01, 0x02, 0x01 };
180 varbinds[0].oid = oid_dot11CurrentRegDomain;
181 varbinds[0].len_oid = sizeof(oid_dot11CurrentRegDomain);
182 varbinds[0].value = oid_dot11CurrentRegDomain;
183 varbinds[0].type = NULL_VALUE;
184 varbinds[0].len_val = 0;
186 if (snmp(varbinds, 1, GET) <= 0)
188 return *(varbinds[0].value);
195 { 0x2a, 0x86, 0x48, 0xce, 0x34, 0x02, 0x01, 0x01, 0x01, 0x01 };
196 char oid_manufacturerID[] =
197 { 0x2a, 0x86, 0x48, 0xce, 0x34, 0x02, 0x01, 0x01, 0x08, 0x01 };
198 char oid_productID[] =
199 { 0x2a, 0x86, 0x48, 0xce, 0x34, 0x02, 0x01, 0x01, 0x09, 0x01 };
200 char oid_dot11manufacturerOUI[] =
201 { 0x2a, 0x86, 0x48, 0xce, 0x34, 0x03, 0x01, 0x02, 0x01, 0x01,
204 char oid_dot11manufacturerName[] =
205 { 0x2a, 0x86, 0x48, 0xce, 0x34, 0x03, 0x01, 0x02, 0x01, 0x02,
208 char oid_dot11manufacturerProductName[] =
209 { 0x2a, 0x86, 0x48, 0xce, 0x34, 0x03, 0x01, 0x02, 0x01, 0x03,
212 char oid_dot11manufacturerProductVersion[] =
213 { 0x2a, 0x86, 0x48, 0xce, 0x34, 0x03, 0x01, 0x02, 0x01, 0x04,
216 char oid_dot11PHYType[] =
217 { 0x2a, 0x86, 0x48, 0xce, 0x34, 0x04, 0x01, 0x01, 0x01, 0x01 };
218 char oid_dot11TempType[] =
219 { 0x2a, 0x86, 0x48, 0xce, 0x34, 0x04, 0x01, 0x01, 0x03, 0x01 };
220 char oid_TxPowerLevel1[] =
221 { 0x2a, 0x86, 0x48, 0xce, 0x34, 0x04, 0x03, 0x01, 0x02, 0x01 };
222 char oid_dot11PrivacyOptionImplemented[] =
223 { 0x2a, 0x86, 0x48, 0xce, 0x34, 0x01, 0x01, 0x01, 0x07, 0x01 };
224 char oid_dot11DiversitySupport[] =
225 { 0x2a, 0x86, 0x48, 0xce, 0x34, 0x04, 0x02, 0x01, 0x03, 0x01 };
226 char oid_sysDescr[] =
227 { 0x2b, 0x06, 0x01, 0x02, 0x01, 0x01, 0x01, 0x00 };
228 char oid_sysUptime[] =
229 { 0x2b, 0x06, 0x01, 0x02, 0x01, 0x01, 0x03, 0x00 };
231 { 0x2b, 0x06, 0x01, 0x02, 0x01, 0x04, 0x14, 0x01, 0x01 };
233 { _("FHSS 2.4 GHz"), _("DSSS 2.4 GHz"), _("IR Baseband") };
234 char *temp[3] = { _("Commercial range 0..40 C"),
235 _("Industrial range -30..70 C"),
238 _("manual"), _("notsupported"), _("dynamic")};
241 int i, hand, c, min, sec;
243 varbind varbinds[OID_NUM];
246 for (i = 0; i < OID_NUM; i++) {
247 varbinds[i].value = oid_mac;
248 varbinds[i].type = NULL_VALUE;
249 varbinds[i].len_val = 0;
251 varbinds[0].oid = oid_mac;
252 varbinds[0].len_oid = sizeof(oid_mac);
253 varbinds[1].oid = oid_manufacturerID;
254 varbinds[1].len_oid = sizeof(oid_manufacturerID);
255 varbinds[2].oid = oid_productID;
256 varbinds[2].len_oid = sizeof(oid_productID);
257 varbinds[3].oid = oid_dot11manufacturerOUI;
258 varbinds[3].len_oid = sizeof(oid_dot11manufacturerOUI);
259 varbinds[4].oid = oid_dot11manufacturerName;
260 varbinds[4].len_oid = sizeof(oid_dot11manufacturerName);
261 varbinds[5].oid = oid_dot11manufacturerProductName;
262 varbinds[5].len_oid = sizeof(oid_dot11manufacturerProductName);
263 varbinds[6].oid = oid_dot11manufacturerProductVersion;
264 varbinds[6].len_oid = sizeof(oid_dot11manufacturerProductVersion);
265 varbinds[7].oid = oid_dot11PHYType;
266 varbinds[7].len_oid = sizeof(oid_dot11PHYType);
267 varbinds[8].oid = oid_dot11TempType;
268 varbinds[8].len_oid = sizeof(oid_dot11TempType);
269 varbinds[9].oid = oid_TxPowerLevel1;
270 varbinds[9].len_oid = sizeof(oid_TxPowerLevel1);
272 print_help(WAIT_RET);
273 if (snmp(varbinds, OID_NUM - 1, GET) <= 0) {
274 print_helperr(ERR_RET);
277 print_title(_("System Info"));
281 sprintf(message, "%s%02X%02X%02X%02X%02X%02X", MAC,
282 varbinds[0].value[0] & 0xFF, varbinds[0].value[1] & 0xFF,
283 varbinds[0].value[2] & 0xFF, varbinds[0].value[3] & 0xFF,
284 varbinds[0].value[4] & 0xFF, varbinds[0].value[5] & 0xFF);
285 mvwaddstr(main_sub, 0, 0, message);
287 mvwaddstr(main_sub, 3, 0, _("Manufacturer:"));
289 while (varbinds[4].len_val > i) {
290 mvwaddch(main_sub, 3, i + 20, *(varbinds[4].value + i++));
293 mvwaddstr(main_sub, 4, 0, _("Manufacturer ID:"));
295 while (varbinds[1].len_val > i) {
296 mvwaddch(main_sub, 4, i + 20, *(varbinds[1].value + i++));
299 sprintf(message, _("Manufacturer OUI: %02X %02X %02X (%s)"),
300 varbinds[3].value[0] & 0xFF, varbinds[3].value[1] & 0xFF,
301 varbinds[3].value[2] & 0xFF,
302 oui2manufacturer(varbinds[3].value));
303 mvwaddstr(main_sub, 5, 0, message);
305 sprintf(message, _("Product Name:"));
306 mvwaddstr(main_sub, 6, 0, message);
308 while (varbinds[5].len_val > i) {
309 mvwaddch(main_sub, 6, i + 20, *(varbinds[5].value + i++));
312 sprintf(message, _("Product ID:"));
313 mvwaddstr(main_sub, 7, 0, message);
315 while (varbinds[2].len_val > i) {
316 mvwaddch(main_sub, 7, i + 20, *(varbinds[2].value + i++));
318 sprintf(message, _("Product Version:"));
319 mvwaddstr(main_sub, 8, 0, message);
321 while (varbinds[6].len_val > i) {
322 mvwaddch(main_sub, 8, i + 20, *(varbinds[6].value + i++));
326 sprintf(message, _("PHYType: %s"), types[*(varbinds[7].value) - 1]);
327 mvwaddstr(main_sub, 9, 0, message);
329 sprintf(message, _("Temperature: %s"), temp[*(varbinds[8].value) - 1]);
330 mvwaddstr(main_sub, 10, 0, message);
332 if ((i = get_RegDomain()) == 0) {
333 print_helperr(ERR_RET);
336 sprintf(message, _("Regulation Domain: %s"),
337 (i == 0x10) ? _("FCC (USA)") :
338 (i == 0x20) ? _("DOC (Canada)") :
339 (i == 0x30) ? _("ETSI (Europe)") :
340 (i == 0x31) ? _("Spain") :
341 (i == 0x32) ? _("France") :
342 (i == 0x40) ? _("MKK (Japan)") : _("unknown"));
343 mvwaddstr(main_sub, 11, 0, message);
345 sprintf(message, _("Transmit Power: %u mW"), *(varbinds[9].value));
346 mvwaddstr(main_sub, 12, 0, message);
348 varbinds[0].oid = oid_dot11PrivacyOptionImplemented;
349 varbinds[0].len_oid = sizeof(oid_dot11PrivacyOptionImplemented);
350 varbinds[0].value = oid_mac;
351 varbinds[0].type = NULL_VALUE;
352 varbinds[0].len_val = 0;
353 varbinds[1].oid = oid_dot11DiversitySupport;
354 varbinds[1].len_oid = sizeof(oid_dot11DiversitySupport);
355 varbinds[1].value = oid_mac;
356 varbinds[1].type = NULL_VALUE;
357 varbinds[1].len_val = 0;
358 varbinds[2].oid = oid_sysDescr;
359 varbinds[2].len_oid = sizeof(oid_sysDescr);
360 varbinds[2].value = oid_mac;
361 varbinds[2].type = NULL_VALUE;
362 varbinds[2].len_val = 0;
363 varbinds[3].oid = oid_sysUptime;
364 varbinds[3].len_oid = sizeof(oid_sysUptime);
365 varbinds[3].value = oid_mac;
366 varbinds[3].type = NULL_VALUE;
367 varbinds[3].len_val = 0;
369 print_help(WAIT_RET);
370 if (snmp(varbinds, 4, GET) <= 0) {
371 print_helperr(ERR_RET);
375 sprintf(message, _("WEP inplemented: %s"),
376 (*(varbinds[0].value) == 1) ? ON : OFF);
377 mvwaddstr(main_sub, 13, 0, message);
378 sprintf(message, _("Diversity: %s"),
379 diversity[*(varbinds[1].value) - 1]);
380 mvwaddstr(main_sub, 14, 0, message);
381 mvwaddstr(main_sub, LINES - 8, 0, SYS_DESCR);
383 while (varbinds[2].len_val > i && varbinds[2].value[i]) {
384 message[i] = varbinds[2].value[i];
388 mvwaddstr(main_sub, LINES - 8, strlen(SYS_DESCR) + 1, message);
393 for (c = 1; c <= varbinds[3].len_val; c++) {
395 (unsigned char) varbinds[3].value[varbinds[3].len_val - c] * i;
399 hand = time_stamp % 100;
400 time_stamp = time_stamp / 100;
401 sec = time_stamp % 60;
402 time_stamp = time_stamp / 60;
403 min = time_stamp % 60;
404 time_stamp = time_stamp / 60;
406 sprintf(message, _("Uptime: %u:%02u:%02u.%02u"), time_stamp, min, sec,
408 mvwaddstr(main_sub, 15, 0, message);
410 varbinds[0].oid = oid_ip;
411 varbinds[0].len_oid = sizeof(oid_ip);
412 varbinds[0].value = oid_mac;
413 varbinds[0].type = NULL_VALUE;
414 varbinds[0].len_val = 0;
416 print_help(WAIT_RET);
417 if (snmp(varbinds, 1, GET_NEXT) <= 0) {
418 print_helperr(ERR_RET);
421 memcpy(&ip.s_addr, varbinds[0].value, 4);
422 sprintf(message, _("IP Address: %s"), inet_ntoa(ip));
423 mvwaddstr(main_sub, 1, 0, message);