/*
- * sysinfo_set.c from Access Point SNMP Utils for Linux
+ * set_oeminfo.c from Access Point SNMP Utils for Linux
*
- * Copyright (c) Jan Rafaj <jr-aputils at cedric dot unob dot cz>
+ * Copyright (c) 2005 Jan Rafaj <jr-aputils at cedric dot unob dot cz>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License Version 2 from
*/
#include <stdlib.h>
+#include <string.h>
#include <unistd.h>
#include <sys/time.h>
#include <sys/types.h>
#define S_STRUCTVERSION _("Info structure version: ")
#define S_MAC _("[M] Device MAC address: ")
#define V_OUI _(" Manufacturer with this OUI: ")
-#define S_DEFCHAN _("[C] Default channel: ")
#define S_REGDOM _("[D] Regulatory domain: ")
#define S_PRODTYPE _("[T] Product type: ")
#define S_OEMNAME _("[E] OEM name: ")
#define S_OEMID _("[I] OEM ID: ")
#define S_PRODNAME _("[N] Product name: ")
#define S_HWREV _("[H] Hardware revision: ")
-// #define S_PIDVID _("[V] PID & VID: ")
#define S_COUNTRYC _("[O] Country code: ")
-// #define S_CHANNELS _("[A] Available channels: ")
-#define S_TXPOWER _("[P] Nominal Tx Power (CR31) value for all used channels: ")
+#define S_DEFCHAN _("[C] Default channel: ")
+#define S_CHANNELS _("[A] Calibrated channels: ")
+#define S_TXPOWER _("[P] Nominal Tx Power (CR31) value for calibrated channels: ")
#define OEMSET_HELP _("Keys in brackets - set corresponding option; W - write conf; Q - quit to menu")
extern WINDOW *main_sub;
char sysDeviceInfo[] = {
0x2B, 0x06, 0x01, 0x04, 0x01, 0x83, 0x1A, 0x01, 0x01, 0x01, 0x05, 0x00
};
- // Following one is only available in ATMEL12350 MIBs
+ // Following one is only available in newer ATMEL12350 MIBs
char sysDeviceMoreInfo[] = {
0x2B, 0x06, 0x01, 0x04, 0x01, 0xE0, 0x3E, 0x01, 0x01, 0x01, 0x08, 0x00
};
char message[200], c;
char **regdoms;
- int i, rd_idx;
+ int i, rd_idx, st_len;
varbind varbinds[1];
- struct sysDeviceInfo_ATMEL410 str410;
- struct sysDeviceInfo_ATMEL12350 str12350;
+ struct sysDeviceInfo_128 str128; /* SHORTst */
+ struct sysDeviceInfo_160 str160; /* LONGst */
/*
- * These have to represent used sysDeviceInfo_{ATMEL410,ATMEL12350} members
- * Note that sysOIDSize and sysOID can NOT be written using sysDevice*Info
- * OID at all.
+ * These have to represent used sysDeviceInfo_{128,160} members
+ * Note that sysOIDSize, sysOID and PID_VID can NOT be written
+ * using sysDevice*Info OIDs at all - the only way to change them
+ * (highly discouraged !) is in OEM configuration file, using AP RFMD
+ * or AP INTERSIL configuration editor, followed by uploading this file
+ * to the AP using ATMEL tftp client - this way, *all* defaults
+ * can be changed.
*/
uint32_t StructVersion; // [4]
char *MacAddress; // [6]
- // [2 reserved for ATMEL410; 0 for ATMEL12350]
- char Channel = 0; // ATMEL12350 specific; [0 for AT.410; 1 for ATMEL12350]
- uint32_t RegulatoryDomain; // [4 for ATMEL410; 1 for ATMEL12350]
+ // [2 reserved for SHORTst; 0 for LONGst]
+ char Channel = 0; // LONGst specific: [0 for SHORTst; 1 for LONGst]
+ uint32_t RegulatoryDomain; // [4 for SHORTst; 1 for LONGst]
uint32_t ProductType; // [4]
char *OEMName; // [32]
uint32_t OEMID; // [4]
char *ProductName; // [32]
uint32_t HardwareRevision; // [4]
- /* the rest is ATMEL12350 specific */
- char *PID_VID = NULL; // [0 for ATMEL410; 4 for ATMEL12350]
- uint32_t sysOIDSize = 0; // [0 for ATMEL410; 4 for ATMEL12350]
- uint16_t *sysOID = NULL; // [0 for ATMEL410; 32 for ATMEL12350]
- char *CountryCode = NULL; // [0 for ATMEL410; 3 for ATMEL12350]
- // [0 for ATMEL410; 1 reserved for ATMEL12350]
- uint16_t ChannelInformation = 0; // [0 for ATMEL410; 2 for ATMEL12350]
- // [0 for ATMEL410; 2 reserved for ATMEL12350]
- char *TxPower = NULL; // [0 for ATMEL410; 14 for ATMEL12350]
- // [0 for ATMEL410; 10 reserved for ATMEL12350]
+ /* the rest is LONGst specific */
+ char *PID_VID = NULL; // [0 for SHORTst; 4 for LONGst]
+ uint32_t sysOIDSize = 0; // [0 for SHORTst; 4 for LONGst]
+ uint16_t *sysOID = NULL; // [0 for SHORTst; 32 for LONGst]
+ char *CountryCode = NULL; // [0 for SHORTst; 3 for LONGst]
+ // [0 for SHORTst; 1 reserved for LONGst]
+ uint16_t ChannelInformation = 0; // [0 for SHORTst; 2 for LONGst]
+ // [0 for SHORTst; 2 reserved for LONGst]
+ char *TxPower = NULL; // [0 for SHORTst; 14 for LONGst]
+ // [0 for SHORTst; 10 reserved for LONGst]
clear_main(0);
noecho();
goto exit;
}
- if (ap_type == ATMEL410) {
- memcpy(&str410, varbinds[0].value,
- sizeof(struct sysDeviceInfo_ATMEL410));
- StructVersion = str410.StructVersion;
- MacAddress = str410.MacAddress;
- RegulatoryDomain = str410.RegulatoryDomain;
- ProductType = str410.ProductType;
- OEMName = str410.OEMName;
- OEMID = str410.OEMID;
- ProductName = str410.ProductName;
- HardwareRevision = str410.HardwareRevision;
- } else { /* ATMEL12350 */
- memcpy(&str12350, varbinds[0].value,
- sizeof(struct sysDeviceInfo_ATMEL12350));
- StructVersion = str12350.StructVersion;
- MacAddress = str12350.MacAddress;
- Channel = str12350.Channel;
- RegulatoryDomain = str12350.RegulatoryDomain;
- ProductType = str12350.ProductType;
- OEMName = str12350.OEMName;
- OEMID = str12350.OEMID;
- ProductName = str12350.ProductName;
- HardwareRevision = str12350.HardwareRevision;
- PID_VID = str12350.PID_VID;
- sysOIDSize = str12350.sysOIDSize;
- sysOID = str12350.sysOID;
- CountryCode = str12350.CountryCode;
- ChannelInformation = str12350.ChannelInformation;
- TxPower = str12350.TxPower;
+ st_len = varbinds[0].len_val;
+
+ if (st_len == 92 || st_len == 128) { /* SHORTst */
+ memcpy(&str128, varbinds[0].value,
+ sizeof(struct sysDeviceInfo_128));
+ StructVersion = str128.StructVersion;
+ MacAddress = str128.MacAddress;
+ RegulatoryDomain = str128.RegulatoryDomain;
+ ProductType = str128.ProductType;
+ OEMName = str128.OEMName;
+ OEMID = str128.OEMID;
+ ProductName = str128.ProductName;
+ HardwareRevision = str128.HardwareRevision;
+ } else { /* st_len == 160 => LONGst */
+ memcpy(&str160, varbinds[0].value,
+ sizeof(struct sysDeviceInfo_160));
+ StructVersion = str160.StructVersion;
+ MacAddress = str160.MacAddress;
+ Channel = str160.Channel;
+ RegulatoryDomain = str160.RegulatoryDomain;
+ ProductType = str160.ProductType;
+ OEMName = str160.OEMName;
+ OEMID = str160.OEMID;
+ ProductName = str160.ProductName;
+ HardwareRevision = str160.HardwareRevision;
+ PID_VID = str160.PID_VID;
+ sysOIDSize = str160.sysOIDSize;
+ sysOID = str160.sysOID;
+ CountryCode = str160.CountryCode;
+ ChannelInformation = str160.ChannelInformation;
+ TxPower = str160.TxPower;
}
clear_main(0);
sprintf(message, "%s%u", S_HWREV, HardwareRevision);
mvwaddstr(main_sub, 8, 0, message);
- if (ap_type == ATMEL12350) {
- sprintf(message, "%s%02u (%u MHz)", S_DEFCHAN, Channel,
- 2407 + 5 * Channel);
- mvwaddstr(main_sub, 9, 0, message);
-
- wmove(main_sub, 10, 0);
- for (i = 0; i++ < COLS - MCOLS; waddch(main_sub, ACS_BSBS));
+ wmove(main_sub, 9, 0);
+ for (i = 0; ++i < COLS - MCOLS; waddch(main_sub, ACS_BSBS));
+ if (st_len == 160) {
sprintf(message, "%s%s", S_COUNTRYC, CountryCode);
- mvwaddstr(main_sub, 11, 0, message);
+ mvwaddstr(main_sub, 10, 0, message);
-// TODO: find out what format this is in [apparently 2x uint16?]
-// sprintf(message, "%s%u %u %u %u", S_PIDVID,
-// PID_VID[0] & 0xFF, PID_VID[1] & 0xFF,
-// PID_VID[2] & 0xFF, PID_VID[3] & 0xFF);
-// mvwaddstr(main_sub, 12, 0, message);
+ sprintf(message, "%s%02u (%u MHz)", S_DEFCHAN, Channel,
+ 2407 + 5 * Channel);
+ mvwaddstr(main_sub, 11, 0, message);
-// TODO: find out what format ChannelInformation is in & enable this
-// sprintf(message, "%s%u", S_CHANNELS, ChannelInformation);
-// mvwaddstr(main_sub, 13, 0, message);
+ i = 1;
+ while(ChannelInformation >> i) i++;
+ sprintf(message, "%s%i", S_CHANNELS, i);
+ mvwaddstr(main_sub, 12, 0, message);
sprintf(message, "%s%u", S_TXPOWER,
TxPower[regdom_types[rd_idx].first_ch] & 0xFF);
- mvwaddstr(main_sub, 12, 0, message);
+ mvwaddstr(main_sub, 13, 0, message);
#if 0 /* DEBUG */
- wmove(main_sub, 17, 0);
+ wmove(main_sub, 18, 0);
for (i = 0; i < 14; i++) {
sprintf(message, "%-3u ", TxPower[i] & 0xFF);
waddstr(main_sub, message);
}
#endif /* DEBUG */
- sprintf(message, "[-] First %u OID elements: .%u.%u.%u.%u",
- sysOIDSize / 2, sysOID[0], sysOID[1], sysOID[2], sysOID[3]);
- mvwaddstr(main_sub, 13, 0, message);
+ wmove(main_sub, 14, 0);
+ for (i = 0; ++i < COLS - MCOLS; waddch(main_sub, ACS_BSBS));
+
+ sprintf(message, "System control OID part [%u elements]: ", sysOIDSize);
+ mvwaddstr(main_sub, 15, 0, message);
+ i = 0;
+ while (i < (int)sysOIDSize) {
+ sprintf(message, ".%u", sysOID[i++]);
+ waddstr(main_sub, message);
+ }
+
+ sprintf(message, "USB Vendor ID: 0x%04X", (PID_VID[0] & 0xFF) |
+ ((PID_VID[1] & 0xFF) << 8));
+ mvwaddstr(main_sub, 16, 0, message);
+
+ sprintf(message, "USB Product ID: 0x%04X", (PID_VID[2] & 0xFF) |
+ ((PID_VID[3] & 0xFF) << 8));
+ mvwaddstr(main_sub, 17, 0, message);
+
}
wrefresh(main_sub);
free(regdoms);
- if (ap_type == ATMEL12350) {
+ if (st_len == 160) {
Channel = regdom_types[rd_idx].first_ch;
sprintf(message, "%02u (%u MHz)", Channel,
2407 + 5 * Channel);
- print_menusel(9, 0, S_DEFCHAN, message);
+ print_menusel(11, 0, S_DEFCHAN, message);
}
continue;
case 'e':
INT_STRING, 0, 0xFFFFFFFF, OEMSET_HELP);
HardwareRevision = atoi(message);
continue;
+ case 'o':
+ case 'O':
+ if (st_len == 92 || st_len == 128)
+ continue;
+
+ get_value(CountryCode, 10, strlen(S_COUNTRYC), 3, ANY_STRING,
+ 0, 0, NULL);
+ continue;
case 'c':
case 'C':
- if (ap_type != ATMEL12350)
+ if (st_len == 92 || st_len == 128)
continue;
- Channel = menu_choose(3, strlen(S_DEFCHAN) - 2,
+ Channel = menu_choose(11 - regdom_types[rd_idx].chans / 2,
+ strlen(S_DEFCHAN) - 2,
#ifndef NO_REG_DOMAIN
channels + regdom_types[rd_idx].first_ch - 1,
regdom_types[rd_idx].chans) + regdom_types[rd_idx].first_ch;
channels, 14) + 1;
#endif
sprintf(message, "%02u (%u MHz)", Channel, 2407 + 5 * Channel);
- print_menusel(9, 0, S_DEFCHAN, message);
+ print_menusel(11, 0, S_DEFCHAN, message);
continue;
- case 'o':
- case 'O':
- if (ap_type != ATMEL12350)
+ case 'a':
+ case 'A':
+ if (st_len == 92 || st_len == 128)
continue;
- get_value(CountryCode, 11, strlen(S_COUNTRYC), 3, ANY_STRING,
- 0, 0, NULL);
+ get_value(message, 12, strlen(S_CHANNELS), 3, INT_STRING, 1, 14,
+ OEMSET_HELP);
+ memset((void *)TxPower + 1, 0, 13);
+ for(i = 1; i < atoi(message); i++)
+ TxPower[i] = TxPower[0];
+
+ i = 1 << (atoi(message) - 1);
+ ChannelInformation = i | (i - 1);
continue;
case 'p':
case 'P':
- if (ap_type != ATMEL12350)
+ if (st_len == 92 || st_len == 128)
continue;
- memset((void *)TxPower, 0, 14);
- get_value(message, 12, strlen(S_TXPOWER), 4, INT_STRING, 0, 255,
+ get_value(message, 13, strlen(S_TXPOWER), 4, INT_STRING, 0, 255,
OEMSET_HELP);
c = atoi(message) & 0xFF;
+
+ memset((void *)TxPower, 0, 14);
+ i = 0;
+ while(ChannelInformation >> i) {
+ TxPower[i] = c;
+ i++;
+ }
+/*
+ memset((void *)TxPower, 0, 14);
for (i = regdom_types[rd_idx].first_ch; i <
regdom_types[rd_idx].first_ch + regdom_types[rd_idx].chans; i++)
TxPower[i - 1] = c;
-
+*/
continue;
case 'q':
case 'Q':
varbinds[0].len_oid = sizeof(sysDeviceInfo);
varbinds[0].type = STRING_VALUE;
- if (ap_type == ATMEL410) {
- str410.RegulatoryDomain = RegulatoryDomain;
- str410.ProductType = ProductType;
- str410.OEMID = OEMID;
- str410.HardwareRevision = HardwareRevision;
- varbinds[0].value = (char *) &str410;
+ if (st_len == 92 || st_len == 128) { /* SHORTst */
+ str128.RegulatoryDomain = RegulatoryDomain;
+ str128.ProductType = ProductType;
+ str128.OEMID = OEMID;
+ str128.HardwareRevision = HardwareRevision;
+ varbinds[0].value = (char *) &str128;
varbinds[0].len_val =
- sizeof(struct sysDeviceInfo_ATMEL410);
- } else { /* ATMEL12350 */
- str12350.Channel = Channel;
- str12350.RegulatoryDomain = RegulatoryDomain;
- str12350.ProductType = ProductType;
- str12350.OEMID = OEMID;
- str12350.HardwareRevision = HardwareRevision;
-// str12350.ChannelInformation = ChannelInformation;
- varbinds[0].value = (char *) &str12350;
- // first 92 bytes of struct sysDeviceInfo_ATMEL12350 here
+ sizeof(struct sysDeviceInfo_128);
+ } else { /* st_len == 160 => LONGst */
+ str160.Channel = Channel;
+ str160.RegulatoryDomain = RegulatoryDomain;
+ str160.ProductType = ProductType;
+ str160.OEMID = OEMID;
+ str160.HardwareRevision = HardwareRevision;
+ str160.ChannelInformation = ChannelInformation;
+ varbinds[0].value = (char *) &str160;
+ /* first 92 bytes of struct sysDeviceInfo_160 here */
varbinds[0].len_val = 92;
}
goto exit;
}
- if (ap_type == ATMEL12350) {
+ if (st_len == 160) {
varbinds[0].oid = sysDeviceMoreInfo;
varbinds[0].len_oid = sizeof(sysDeviceMoreInfo);
varbinds[0].type = STRING_VALUE;
- // last 32 bytes of struct sysDeviceInfo_ATMEL12350 here
- varbinds[0].value = (char *) &str12350.CountryCode;
+ /* last 32 bytes of struct sysDeviceInfo_160 here */
+ varbinds[0].value = (char *) &str160.CountryCode;
varbinds[0].len_val = 32;
if (snmp(varbinds, 1, SET) <= 0) {
print_helperr(ERR_SET);
}
}
+ wbkgd(main_sub, A_NORMAL);
+ wrefresh(main_sub);
print_help(DONE_SET);
goto exit;
}