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