]> git.decadent.org.uk Git - ap-utils.git/blobdiff - lib/ap-utils.h
Imported Upstream version 1.5~pre2
[ap-utils.git] / lib / ap-utils.h
index 94e256a9747e6a07e58a37cd2d4db42e86546f4c..4436cf86cf3930f93dbe192469f1e6de1ba24ce4 100644 (file)
@@ -38,7 +38,10 @@ typedef unsigned int uint32_t;
 #endif /* ifdef OS_SOLARIS */
 #endif /* ifdef OS_BSD */
 
+#include "ap-curses.h"
+
 #define TITLE "Wireless Access Point Utilites for Unix"
+#define VIEW "View: "
 
 #define minimum(x, y)  x <= y ? x : y
 
@@ -57,13 +60,15 @@ typedef unsigned int uint32_t;
 
 
 #ifdef WORDS_BIGENDIAN
-/* a quick-and-dirty macro to unconditionally swap bytes in 4-byte integers
- * between big-endian and little-endian ordering */
+/*
+ * a quick-and-dirty macros to unconditionally swap bytes in 2 and 4-byte
+ * integers between big-endian and little-endian ordering
+ */
 #define swap2(d) ((((d) >> 8) & 0x00ff) | (((d) << 8) & 0xff00))
 #define swap4(d) ((((d) >> 24) & 0x000000ff) | (((d) >>  8) & 0x0000ff00) | (((d) <<  8) & 0x00ff0000) | (((d) << 24) & 0xff000000))
 #else
 #define swap2(d) d
-#define swap4(n) n
+#define swap4(d) d
 #endif
 
 #define rlong(a)       ((a) = swap4(a))
@@ -95,31 +100,42 @@ typedef unsigned int uint32_t;
 #define BASIC _("Basic")
 
 #define ANY_KEY _("Press any key to continue.")
+#define QT_HELP _("Q - quit to menu. T - toggle polling mode, Other key - force update.")
 
 #define ERR_SET _("Unable to write data to AP. Press any key to continue.")
 #define ERR_RET _("Unable to retrieve (valid) data from AP. Press any key to continue.")
-#define WAIT_RET _("Retrieving data from AP. Please wait...")
+#define WAIT_RET _("Trying to retrieve data from AP. Please wait...")
 #define WAIT_SET _("Writing data to AP. Please wait...")
 #define DONE_SET _("Configuration written to the AP. Press any key to continue.")
+#define ERR_SELECT _("select() function error. Press any key.")
+
+#define ERR_CREATING_SOCKET _("Create socket error. Press any key.")
+#define ERR_BINDING_SOCKET _("Bind socket error. Press any key.")
 
-#define CREATE_SOCKET_ERROR _("Create socket error. Press any key.")
-#define BIND_SOCKET_ERROR _("Bind socket error. Press any key.")
+#define ERR_WRITING_APCONF _("Unable to write AP list file ~/.ap-config. Press any key.")
+#define DONE_WRITING_APCONF _("AP list file ~/.ap-config successfully written. Press any key.")
 
-#define MAIN_MENU  _("Back to main menu")
+#define MAIN_MENU _("Back to main menu")
 #define MENU_EXIT _("Exit program")
 #define MENU_SHELL _("Run subshell. To return type 'exit'.")
 #define MENU_ABOUT _("Short info about program")
 #define MENU_SEARCH _("Find connected Access Points")
 #define MENU_CONNECT _("Set connection options: ip and community")
 #define MENU_ENCRYPT _("Set encryption; edit WEP keys")
-#define MENU_MAC _("Set MAC authorization; edit MAC authorization table")
+#define MENU_AUTH _("Set authorization; edit MAC authorization table")
 #define MENU_COMMUNITY _("Set SNMP community/password for access to the AP")
 #define MENU_SYSINFO _("Get info about AP hardware and firmware")
 #define MENU_WIRELESS _("Get wireless port statistics")
 #define MENU_STAS _("Get list of currently associated stations (Access Point clients)")
+#define MENU_APLINK _("Get link status in APclient mode")
 #define MENU_INFO _("Get info and statistics from AP")
-#define MENU_CONFIG  _("Set various configuration options")
+#define MENU_CONFIG _("Set various configuration options")
 
+#define ST_TITLE _("Associated stations")
+#define AP_TITLE _("AP Client link state")
+
+#define POLL_ON _("Polling: on")
+#define POLL_OFF _("Polling: off")
 
 #define INT_VALUE      0x02
 #define STRING_VALUE   0x04
@@ -145,12 +161,23 @@ typedef unsigned int uint32_t;
 #define MCOLS 15 /* width of menu window */
 #define LAST_ROW LINES-5
 
+#define WAIT_TIMEOUT 1
+#define WAIT_FOREVER 0
+
 /* Basic distinguished MIB (and AP) types */
+/* Numbering with respect to order in ap_types */
 #define ATMEL410 0
 #define NWN 1
 #define ATMEL12350 2
 
-typedef struct VarBind {
+/* Vendor distinguished MIB subtypes */
+/* Numbering with respect to order in ap_vendorexts */
+#define NONE 0
+#define SBRIDGES 1
+#define GEMTEK 1
+#define EZYNET 2
+
+typedef struct {
     unsigned char *oid;
     int len_oid;
     unsigned char *value;
@@ -158,6 +185,13 @@ typedef struct VarBind {
     unsigned char type;
 } varbind;
 
+typedef struct {
+    char code;
+    char *desc;
+    unsigned short first_ch;
+    unsigned short chans;
+} rdprops;
+
 struct umitems {
        char *item;
        char *help;
@@ -165,7 +199,7 @@ struct umitems {
        int is_menu;
 };
 
-struct EthernetRxStatistics {
+struct EthRxStatistics_s {
        uint32_t TotalBytesRx;
        uint32_t TotalPacketsRx;
        uint32_t PacketCRCErrorRx;
@@ -184,7 +218,7 @@ struct EthernetRxStatistics {
        uint32_t TotalJabberRx;
 };
 
-struct EthernetTxStatistics {
+struct EthTxStatistics_s {
        uint32_t TotalBytesTx;
        uint32_t TotalPacketsTx;
        uint32_t PacketCRCErrorTx;
@@ -201,7 +235,7 @@ struct EthernetTxStatistics {
        uint32_t TotalCollisionsTx;
 };
 
-struct WirelessStatistics {
+struct wirelessStatistics_s {
        uint32_t UnicastTransmittedPackets;
        uint32_t BroadcastTransmittedPackets;
        uint32_t MulticastTransmittedPackets;
@@ -224,39 +258,45 @@ struct WirelessStatistics {
        uint32_t AgedPackets;
        uint32_t FCSError;
        uint32_t InvalidPLCP;
-       /* following 4 are specific for ATMEL 12350 MIB enhanced by VERNET */
+       /* following 4 are specific for ATMEL 12350 MIB enhanced by EZYNET */
        uint32_t TransmittedPackets_11Mbps;
        uint32_t TransmittedPackets_55Mbps;
        uint32_t TransmittedPackets_2Mbps;
        uint32_t TransmittedPackets_1Mbps;
 };
 
-struct SysDeviceInfo_ATMEL410 {
-    /* sysDeviceInfo OID struct for ATMEL 410 */
+struct sysDeviceInfo_128 {
+    /* sysDeviceInfo OID struct - version 128 bytes long */
     uint32_t StructVersion;
     unsigned char MacAddress[6];
     unsigned short Reserved;
-    uint32_t RegulationDomain;
+    uint32_t RegulatoryDomain;
     uint32_t ProductType;
     unsigned char OEMName[32];
     uint32_t OEMID;
     unsigned char ProductName[32];
     uint32_t HardwareRevision;
+    /*
+     * NOTE: Although MIBs claim 92 bytes length, it is not true.
+     * 92 bytes seems to be just the 'official' part; the unofficial
+     * (and undocumented) remnant just padds it to the total length of
+     * 128 bytes.
+     * TODO: find out the structure.
+     */
 };
 
-struct SysDeviceInfo_ATMEL12350 {
-    /* sysDeviceInfo OID struct for ATMEL 12350 */
+struct sysDeviceInfo_160 {
+    /* sysDeviceInfo OID struct - version 160 bytes long */
     uint32_t StructVersion;
     unsigned char MacAddress[6];
     unsigned char Channel;
-    unsigned char RegulationDomain;
+    unsigned char RegulatoryDomain;
     uint32_t ProductType;
     unsigned char OEMName[32];
     uint32_t OEMID;
     unsigned char ProductName[32];
     uint32_t HardwareRevision;
-    /* The rest is actually dormant. */
-    /*
+    /* The rest is mostly dormant. */
     unsigned char PID_VID[4];
     uint32_t sysOIDSize;
     uint16_t sysOID[16];
@@ -266,9 +306,36 @@ struct SysDeviceInfo_ATMEL12350 {
     unsigned char Reserved2[2];
     unsigned char TxPower[14];
     unsigned char Reserved3[10];
-    */
 };
 
+/* AP mode: Associated stations diagnostics */
+
+struct AssociatedSTAsInfo_ATMEL410 {
+    unsigned short Index;
+    unsigned char  MacAddress[6];
+    /* The rest is only supported by ATMEL410 SBRIDGES MIB */
+    unsigned char  Status;
+    unsigned char  Port;
+    unsigned char  ParentMacAddress[6];
+    unsigned char  RSSI;
+    unsigned char  LinkQuality;
+    unsigned char  IP[4];
+    unsigned char  Reserved1[2];
+};
+
+struct AssociatedSTAsInfo_ATMEL12350 {
+    unsigned short Index;
+    unsigned char  MacAddress[6];
+    /* The rest is only supported by ATMEL12350 EZYNET MIB */
+    unsigned char  Status;
+    unsigned char  Port;
+    unsigned char  ParentMacAddress[6];
+    unsigned char  RSSI;
+    unsigned char  IP[4];
+    unsigned char  Reserved1[3];
+};
+
+/* This structure unifies all the unique members of the 2 structs above */
 struct MacListStat {
     unsigned char addr[6];
     struct MacListStat *next;
@@ -281,21 +348,52 @@ struct MacListStat {
     struct in_addr IP;
 };
 
+/* APClient mode: AP link diagnostics */
+
+/* size: 53 bytes */
+struct NetworkSettings_ATMEL410_SBRIDGES {
+    unsigned short reserved1;
+    unsigned char BSSID[6];
+    unsigned short InfoCapability;
+    unsigned char Rssi;
+    unsigned char Channel;
+    unsigned char reserved2[2];
+    unsigned char LinkQuality;
+    unsigned char reserved3[5];
+    unsigned char ESSID[32];
+    unsigned char ESSLEN;
+};
+
+/* size: 56 bytes */
+struct NetworkSettings_ATMEL12350_EZYNET {
+    unsigned short reserved1;
+    unsigned char BSSID[6];
+    unsigned short InfoCapability;
+    unsigned char Rssi;
+    unsigned char Channel;
+    unsigned char reserved2[2];
+    unsigned char CurrentRate;
+    unsigned char reserved3[5];
+    unsigned char ESSID[32];
+    unsigned long ESSLEN;
+};
+
 /* function prototypes specific/common for both utilites */
 
 /* service */
 extern char * oui2manufacturer(char *);
-extern int ch_list(int, char **);
+extern int  regdom_idx(char);
+extern int  ch_list(int, char **);
 extern void connect_options(unsigned long int, int);
-extern int get_mib_details(void);
+extern int  get_mib_details(void);
 extern void about(void);
 extern void draw_menu_win(void);
 extern void main_menu(void);
-extern void print_title(char *);
-extern void print_viewtype(char *);
-extern void print_viewtype_rssi(void);
+extern void print_bold(WINDOW *, char *);
 extern void print_menusel(int, int, char *, char *);
 extern void print_bottom(char *);
+extern void print_top(char *, char *);
+extern void print_top_rssi(char *);
 extern void print_help(char *);
 extern void print_helperr(char *);
 extern void clear_main(int);
@@ -304,11 +402,14 @@ extern int  conv_rssi(int);
 extern void get_mac(char *, int, int);
 extern void get_ip(struct in_addr *, int, int, char *);
 extern void get_mask(struct in_addr *, int, int, char *);
-extern void get_value(char *, int, int, int, char, int, int, char *);
+extern void get_value(char *, int, int, int, char, unsigned int, unsigned int,
+                     char *);
 extern void get_pass(char *, int, int, int);
-extern int  menu_choose(int, int, char **, unsigned int);
 extern int  yes_no(int, int);
 extern int  on_off(int, int);
+extern int  menu_choose(int, int, char **, unsigned int);
+extern int  wait_key(void);
+extern int  help_ysn(void);
 extern void scroll_rows(struct MacListStat *, int, int, int, int);
 extern void exit_shell(void);
 extern void exit_program(void);
@@ -321,13 +422,16 @@ extern void AuthorizedSettings(void);
 extern void bridging(void);
 extern void wep(void);
 extern void WirelessStat(void);
-extern void stations(void);
+extern void atmel_stations(void);
+extern void atmel_aplink(void);
 extern void atmel_sysinfo(void);
+extern void atmel_set_oeminfo(void);
 extern void ap_search(void);
 
 /* snmp engine*/
 extern int snmp(varbind *, int, int);
 extern int ber(char *, varbind *, int, int);
+/* extern unsigned int ber_decode_uint(unsigned char *, int); */
 
 /* function prototypes specific for ATMEL utility */
 extern void reset(void);
@@ -340,7 +444,7 @@ extern void APs(void);
 extern void power(void);
 extern void test(void);
 extern void atmel_wireless(void);
-extern void atmel_auth_mac(void);
+extern void atmel_auth(void);
 
 /* function prototypes specific for NWN utility */
 extern void latest(void);