+/*
+ * Determines AP MIB type (fills ap_type global), and AP MIB vendor extensions
+ * (fills ap_vendorext global). 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
+ };
+ /*
+ * ATMEL410: SMARTBRIDGES MIB define this with length 4 (IpAddress); others
+ * (hopefully) do not define this but eventually return (hopefully)
+ * different value than 4.
+ */
+ char AuthRadiusIP_ATMEL[] = {
+ 0x2B, 0x06, 0x01, 0x04, 0x01, 0x83, 0x1A, 0x01, 0x02, 0x06, 0x03, 0x00
+ };
+ /* ATMEL12350: GEMTEK and EZYNET MIBs define length 160, others 92 or 128 */
+ char sysDeviceInfo_ATMEL[] = {
+ 0x2B, 0x06, 0x01, 0x04, 0x01, 0xE0, 0x3E, 0x01, 0x01, 0x01, 0x05, 0x00
+ };
+ /* ATMEL12350: EZYNET MIB defines length 104, others 88 */
+ char wirelessStatistics_ATMEL[] = {
+ 0x2B, 0x06, 0x01, 0x04, 0x01, 0xE0, 0x3E, 0x01, 0x02, 0x03, 0x01, 0x00
+ };
+
+ varbind varbinds[2];
+ int i;
+
+ print_help(_("Trying to probe AP for MIB properties. Please wait..."));
+
+ /* 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 MIB properties "
+ "(no response from AP). Press any key."));
+ getch();
+ return -1;
+ }
+ }
+ }
+
+ /*
+ * It is best to do the following HERE and FOR ONCE ONLY: find out more
+ * about specific MIB vendor extensions - we'll check against them
+ * on different places later.
+ */
+
+ ap_vendorext = NONE;
+
+ if (ap_type == ATMEL410) {
+ varbinds[0].oid = AuthRadiusIP_ATMEL;
+ varbinds[0].len_oid = sizeof(AuthRadiusIP_ATMEL);
+ varbinds[0].value = NULL;
+ varbinds[0].len_val = 0;
+ varbinds[0].type = NULL_VALUE;
+
+ i = snmp(varbinds, 1, GET);
+ if (i < 0) {
+ print_helperr(ERR_RET);
+ getch();
+ return -1;
+ }
+
+ /*
+ * i == 0 => 'no such variable in the MIB' returned =>
+ * consider 'ap_vendorext = NONE' too.
+ */
+
+ if (varbinds[0].len_val == 4)
+ ap_vendorext = SBRIDGES;
+ }
+
+ if (ap_type == ATMEL12350) {
+ varbinds[0].oid = sysDeviceInfo_ATMEL;
+ varbinds[0].len_oid = sizeof(sysDeviceInfo_ATMEL);
+ varbinds[0].value = NULL;
+ varbinds[0].len_val = 0;
+ varbinds[0].type = NULL_VALUE;
+ varbinds[1].oid = wirelessStatistics_ATMEL;
+ varbinds[1].len_oid = sizeof(wirelessStatistics_ATMEL);
+ varbinds[1].value = NULL;
+ varbinds[1].len_val = 0;
+ varbinds[1].type = NULL_VALUE;
+
+ if (snmp(varbinds, 2, GET) <= 0) {
+ print_helperr(ERR_RET);
+ getch();
+ return -1;
+ }
+
+ if (varbinds[0].len_val == 160)
+ ap_vendorext = GEMTEK;
+
+ if (varbinds[1].len_val == 104)
+ ap_vendorext = EZYNET;
+ }
+
+ return 0;
+}
+