]> git.decadent.org.uk Git - ap-utils.git/blob - src/nwn_advanced.c
986baca0d2df39d30fe293f42ffed399ad365fd2
[ap-utils.git] / src / nwn_advanced.c
1 /*
2  *      wlan.c from Access Point SNMP Utils for Linux
3  *
4  * Copyright (c) 2002 Roman Festchook <roma at polesye dot net>
5  *
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.
9  *
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.
14  *
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
18  *
19  */
20
21 #include <stdlib.h>
22 #include <unistd.h>
23 #include "ap-utils.h"
24 #include "ap-curses.h"
25 #include <menu.h>
26
27 #define RATES_RECORD "[%d]   %02.1fM\t%s"
28
29 void advanced()
30 {
31         char smtStationDBTimeout[] = { 0x2b, 0x06, 0x01, 0x04, 0x01, 0x87, 0x29, 0x03, 0x01, 0x02, 0x01, 0x0F, 0x00 };
32         char smtACKWindow[] = { 0x2b, 0x06, 0x01, 0x04, 0x01, 0x87, 0x29, 0x03, 0x01, 0x02, 0x01, 22, 0x00 };
33
34     char m_dbtimeout=0, m_ackwindow=0, message[80], ackwindow;
35     unsigned int dbtimeout;
36     int i;
37     extern WINDOW *main_sub;
38     varbind varbinds[2];
39
40     for (i = 0; i < 2; i++) {
41         varbinds[i].len_val = 0;
42         varbinds[i].type = NULL_VALUE;
43     }
44     varbinds[0].oid = smtStationDBTimeout;
45     varbinds[0].len_oid = sizeof(smtStationDBTimeout);
46     varbinds[1].oid = smtACKWindow;
47     varbinds[1].len_oid = sizeof(smtACKWindow);
48     print_help(WAIT_RET);
49     if (snmp(varbinds, 2, GET) <= 0) {
50         print_helperr(ERR_RET);
51         goto exit;
52     }
53
54     if (varbinds[0].len_val == 2)
55         dbtimeout = varbinds[0].value[0]*256 + varbinds[0].value[1];
56     else
57         dbtimeout = *(varbinds[0].value);
58         
59     ackwindow = *(varbinds[1].value);
60
61     sprintf(message, _("[D] DB Station Timeout: %d"), dbtimeout);
62     mvwaddstr(main_sub, 1, 0, message);
63     sprintf(message, _("[A] ACK Window: %d"), ackwindow);
64     mvwaddstr(main_sub, 2, 0, message);
65     
66     print_title(_("Advanced Options"));
67     print_help(_("DA - options; W - write conf; Q - quit to menu"));
68     wrefresh(main_sub);
69
70     noecho();
71     while (1) {
72         switch (getch()) {
73         case 'Q':
74         case 'q':
75             goto quit;
76         case 'D':
77         case 'd':
78             get_value(message, 1, 24, 6, INT_STRING, 0, 0, NULL);
79             dbtimeout = atoi(message);
80             m_dbtimeout = 1;
81             continue;
82         case 'A':
83         case 'a':
84             get_value(message, 2, 16, 4, INT_STRING, 0, 0, NULL);
85             ackwindow = atoi(message);
86             m_ackwindow = 1;
87             continue;
88         case 'w':
89         case 'W':
90             i = 0;
91             if (m_dbtimeout) {
92                 if (dbtimeout / 256 >= 1) {
93                      message[0] = (dbtimeout - dbtimeout % 256)/ 256;
94                      message[1] = dbtimeout % 256;
95                      m_dbtimeout = 2;
96                 }
97                 else {
98                         m_dbtimeout = 1;
99                         message[0] = dbtimeout;
100                 }       
101                         
102                 varbinds[i].oid = smtStationDBTimeout;
103                 varbinds[i].len_oid = sizeof(smtStationDBTimeout);
104                 varbinds[i].value = message;
105                 varbinds[i].len_val = m_dbtimeout;
106                 varbinds[i].type = INT_VALUE;
107                 i++;
108             }
109             if (m_ackwindow) {
110                 varbinds[i].oid = smtACKWindow;
111                 varbinds[i].len_oid = sizeof(smtACKWindow);
112                 varbinds[i].value = &ackwindow;
113                 varbinds[i].len_val = 1;
114                 varbinds[i].type = INT_VALUE;
115                 i++;
116             }   
117
118                 print_help(WAIT_SET);
119                 if (snmp(varbinds, i, SET) <= 0) {
120                     print_helperr(ERR_SET);
121                     goto exit;
122                 }
123             print_help(DONE_SET);
124             goto exit;
125         default:
126             continue;
127         }
128     }
129
130   exit:
131     getch();
132   quit:
133     print_title("");
134     clear_main(0);
135 }
136