+/*
+ * Determines AP MIB type (fills ap_type), and AP MIB vendor extensions
+ * (changes values of IS_ATMEL* globals). Returns with -1 on error or 0
+ * if everything is OK.
+ */
+int get_mib_details()
+{
+ char sysDescr_NWN[] = {
+ 0x2B, 0x06, 0x01, 0x02, 0x01, 0x01, 0x01, 0x00
+ };
+ char sysDescr_ATMEL[] = {
+ 0x2B, 0x06, 0x01, 0x04, 0x01, 0x83, 0x1A, 0x01, 0x01, 0x01, 0x01, 0x00
+ };
+ char operEthernetAddress_ATMEL[] = {
+ 0x2B, 0x06, 0x01, 0x04, 0x01, 0x83, 0x1A, 0x01, 0x01, 0x02, 0x03, 0x00
+ };
+ char Wireless_ATMEL[] = {
+ 0x2B, 0x06, 0x01, 0x04, 0x01, 0x83, 0x1A, 0x01, 0x02, 0x03, 0x01, 0x00
+ };
+ varbind varbinds[2];
+ char oui_sbridges[3] = { 0x00, 0x30, 0x1A };
+ char oui_tellus[3] = { 0x00, 0x04, 0xDB };
+
+ /* first, determine the private MIB types according to enterprises ID */
+ varbinds[0].oid = sysDescr_NWN;
+ varbinds[0].len_oid = sizeof(sysDescr_NWN);
+ varbinds[0].value = NULL;
+ varbinds[0].len_val = 0;
+ varbinds[0].type = NULL_VALUE;
+ if (snmp(varbinds, 1, GET) > 0) {
+ ap_type = NWN;
+ } else {
+ varbinds[0].oid = sysDescr_ATMEL;
+ varbinds[0].len_oid = sizeof(sysDescr_ATMEL);
+ varbinds[0].value = NULL;
+ varbinds[0].len_val = 0;
+ varbinds[0].type = NULL_VALUE;
+ if (snmp(varbinds, 1, GET) > 0) {
+ ap_type = ATMEL410;
+ } else {
+ sysDescr_ATMEL[5] = 0xE0;
+ sysDescr_ATMEL[6] = 0x3E;
+ varbinds[0].oid = sysDescr_ATMEL;
+ varbinds[0].len_oid = sizeof(sysDescr_ATMEL);
+ varbinds[0].value = NULL;
+ varbinds[0].len_val = 0;
+ varbinds[0].type = NULL_VALUE;
+ if (snmp(varbinds, 1, GET) > 0) {
+ ap_type = ATMEL12350;
+ } else {
+ print_helperr(_("Unable to determine AP type "
+ "(no response). Press any key."));
+ getch();
+ return -1;
+ }
+ }
+ }
+
+ /*
+ * It is best to do the following HERE and FOR ONCE ONLY: find out more
+ * about specific MIB modifications - we'll use them on different places
+ * later.
+ */
+ IS_ATMEL410_SBRIDGES = 0;
+ IS_ATMEL12350_TELLUS = 0;
+ IS_ATMEL12350_VERNET = 0;
+
+ varbinds[0].type = NULL_VALUE;
+ varbinds[0].oid = operEthernetAddress_ATMEL;
+ varbinds[0].len_oid = sizeof(operEthernetAddress_ATMEL);
+ varbinds[0].len_val = 0;
+ varbinds[1].type = NULL_VALUE;
+ varbinds[1].oid = Wireless_ATMEL;
+ varbinds[1].len_oid = sizeof(Wireless_ATMEL);
+ varbinds[1].len_val = 0;
+ if (ap_type == ATMEL12350) {
+ operEthernetAddress_ATMEL[5] = 0xE0;
+ operEthernetAddress_ATMEL[6] = 0x3E;
+ Wireless_ATMEL[5] = 0xE0;
+ Wireless_ATMEL[6] = 0x3E;
+ }
+ if (snmp(varbinds, 2, GET) <= 0) {
+ print_helperr(ERR_RET);
+ getch();
+ return -1;
+ }
+
+ /* detection of different vendor-modified ATMEL private MIBs */
+ if (ap_type == ATMEL410 && (memcmp(oui_sbridges, varbinds[0].value, 3) ==0))
+ IS_ATMEL410_SBRIDGES = 1;
+
+ if (ap_type == ATMEL12350 && (memcmp(oui_tellus, varbinds[0].value, 3) ==0))
+ IS_ATMEL12350_TELLUS = 1;
+
+ if (ap_type == ATMEL12350 && varbinds[1].len_val == 104)
+ IS_ATMEL12350_VERNET = 1;
+
+ return 0;
+}
+