]> git.decadent.org.uk Git - ap-utils.git/blob - src/bridge.c
Update config.{sub,guess} in the right place at build time - closes: #534825
[ap-utils.git] / src / bridge.c
1 /*
2  *      bridge.c from Access Point SNMP Utils for Linux
3  *
4  * Copyright (c) 2002 Roman Festchook <roma at polesye dot net>
5  * Copyright (c) 2005 Jan Rafaj <jr-aputils at cedric dot unob dot cz>
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License Version 2 from
9  * June 1991 as published by the Free Software Foundation.
10  *
11  * This program is distributed in the hope that it will be useful, but
12  * WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License along
17  * with this program; if not, write to the Free Software Foundation, Inc.,
18  * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19  *
20  */
21
22 #include <stdlib.h>
23 #include <string.h>
24 #include <sys/types.h>
25 #include "ap-utils.h"
26
27 #define IPADDR _("[I] IP: ")
28 #define NETMASK _("[N] Netmask: ")
29 #define GATEWAY _("[G] Gateway: ")
30 #define IP_FILTER _("[F] Filter non-IP traffic: ")
31 #define PR_PORT _("[P] Primary port: ")
32 #define SB_ATTMAC _("Attached station MAC: ")
33 #define DHCP _("[D] DHCP client: ")
34 #define OPER _("[O] Operational mode: ")
35 #define REMOTE_MAC _("[M] Preferred BSSID (remote MAC addr.): ")
36 #define CF_PORT _("[C] Configuration-enabled port(s): ")
37 #define TRAP_PORT _("[T] Trap-sending port: ")
38 #define FW_BCAST _("[R] Forward broadcast traffic: ")
39 #define SB_BCAST _("[B] Isolate wireless clients (broadcast traffic): ")
40 #define SB_UCAST _("[U] Isolate wireless clients (unicast traffic): ")
41 #define HELP _("INGFPDOMSCRBUT - set; W - write conf; Q - quit to menu")
42
43 extern short ap_type, ap_vendorext;
44
45
46 void bridging()
47 {
48
49 char *bridge_modes[6] = {
50     _("Wireless Bridge Point to MultiPoint"),
51     _("Access Point"),
52     _("Access Point client"),
53     _("Wireless Bridge Point to Point"),
54     _("Repeater"),
55     _("unknown")
56 };
57
58     char sysTrapSwitch[] = {
59         0x2B, 0x06, 0x01, 0x04, 0x01, 0x83, 0x1A, 0x01, 0x01, 0x01, 0x03, 0x00
60     };
61
62     char operIPAddress[] = {
63         0x2B, 0x06, 0x01, 0x04, 0x01, 0x83, 0x1A, 0x01, 0x01, 0x02, 0x01, 0x00
64     };
65     char operIPMask[] = {
66         0x2B, 0x06, 0x01, 0x04, 0x01, 0x83, 0x1A, 0x01, 0x01, 0x02, 0x02, 0x00
67     };
68     char operEthernetAddress[] = {
69         0x2B, 0x06, 0x01, 0x04, 0x01, 0x83, 0x1A, 0x01, 0x01, 0x02, 0x03, 0x00
70     };
71     char operGateway[] = {
72         0x2B, 0x06, 0x01, 0x04, 0x01, 0x83, 0x1A, 0x01, 0x01, 0x02, 0x04, 0x00
73     };
74     char operDHCP[] = {
75         0x2B, 0x06, 0x01, 0x04, 0x01, 0x83, 0x1A, 0x01, 0x01, 0x02, 0x05, 0x00
76     };
77     char operPrimaryPort[] = {
78         0x2B, 0x06, 0x01, 0x04, 0x01, 0x83, 0x1A, 0x01, 0x01, 0x02, 0x06, 0x00
79     };
80
81     /* This one is ATMEL410 SBRIDGES MIB and ATMEL12350 all MIBs specific. */
82     char operConfigurationPort[] = {
83         0x2B, 0x06, 0x01, 0x04, 0x01, 0x83, 0x1A, 0x01, 0x01, 0x02, 0x07, 0x00
84     };
85
86     /* This one is ATMEL12350 GEMTEK MIB and ATMEL12350 EZYNET MIB specific. */
87     char operTrapPort[] = {
88         0x2B, 0x06, 0x01, 0x04, 0x01, 0xE0, 0x3E, 0x01, 0x01, 0x02, 0x08, 0x00
89     };
90
91     char operIPFilter[] = {
92         0x2B, 0x06, 0x01, 0x04, 0x01, 0x83, 0x1A, 0x01, 0x01, 0x03, 0x01, 0x00
93     };
94
95     /* These 3 are ATMEL410 SBRIDGES MIB and ATMEL12350 all MIBs specific. */
96     char operForwarbBcast[] = {
97         0x2B, 0x06, 0x01, 0x04, 0x01, 0x83, 0x1A, 0x01, 0x01, 0x03, 0x02, 0x00
98     };
99     char operSendBackBcast[] = {
100         0x2B, 0x06, 0x01, 0x04, 0x01, 0x83, 0x1A, 0x01, 0x01, 0x03, 0x03, 0x00
101     };
102     char operSendBackUnicast[] = {
103         0x2B, 0x06, 0x01, 0x04, 0x01, 0x83, 0x1A, 0x01, 0x01, 0x03, 0x04, 0x00
104     };
105
106     char bridgeOperationalMode[] = {
107         0x2B, 0x06, 0x01, 0x04, 0x01, 0x83, 0x1A, 0x01, 0x01, 0x04, 0x01, 0x00
108     };
109     char bridgeRemoteBridgeBSSID[] = {
110         0x2B, 0x06, 0x01, 0x04, 0x01, 0x83, 0x1A, 0x01, 0x01, 0x04, 0x02, 0x00
111     };
112
113     extern WINDOW *main_sub;
114     varbind varbinds[15];
115     struct in_addr ip, mask, gw;
116     unsigned char message[1024], filter, primary_port, dhcp, RemoteBSSID[6],
117         bridge_mode, traps, config_port, fw_bcast, sb_bcast,
118         sb_ucast;
119     char m_filter = 0, m_bridge_mode = 0, m_primary_port = 0, m_traps = 0,
120         m_dhcp = 0, m_ip = 0, m_mask = 0, m_gw = 0, m_remote_bssid = 0,
121         m_config_port = 0, m_trap_port = 0, m_fw_bcast = 0, m_sb_bcast = 0,
122         m_sb_ucast = 0;
123     char *pr_ports[2] = {
124         _("Ethernet"),
125         _("Wireless")
126     }, *cf_ports[3] = {
127         _("Ethernet"),
128         _("Wireless (can be risky)"),
129         _("Both")
130     };
131     int i;
132     unsigned int trap_port = 0;
133
134     if (ap_type == ATMEL12350) {
135         sysTrapSwitch[5] = 0xE0;
136         sysTrapSwitch[6] = 0x3E;
137         operIPAddress[5] = 0xE0;
138         operIPAddress[6] = 0x3E;
139         operIPMask[5] = 0xE0;
140         operIPMask[6] = 0x3E;
141         operEthernetAddress[5] = 0xE0;
142         operEthernetAddress[6] = 0x3E;
143         operGateway[5] = 0xE0;
144         operGateway[6] = 0x3E;
145         operDHCP[5] = 0xE0;
146         operDHCP[6] = 0x3E;
147         operPrimaryPort[5] = 0xE0;
148         operPrimaryPort[6] = 0x3E;
149         operConfigurationPort[5] = 0xE0;
150         operConfigurationPort[6] = 0x3E;
151         operIPFilter[5] = 0xE0;
152         operIPFilter[6] = 0x3E;
153         operForwarbBcast[5] = 0xE0;
154         operForwarbBcast[6] = 0x3E;
155         operSendBackBcast[5] = 0xE0;
156         operSendBackBcast[6] = 0x3E;
157         operSendBackUnicast[5] = 0xE0;
158         operSendBackUnicast[6] = 0x3E;
159         bridgeOperationalMode[5] = 0xE0;
160         bridgeOperationalMode[6] = 0x3E;
161         bridgeRemoteBridgeBSSID[5] = 0xE0;
162         bridgeRemoteBridgeBSSID[6] = 0x3E;
163     }
164
165     for (i = 0; i < 15; i++) {
166         varbinds[i].type = NULL_VALUE;
167         varbinds[i].len_val = 0;
168         varbinds[i].len_oid = sizeof(sysTrapSwitch);
169     }
170
171     i = 0;
172
173     varbinds[i++].oid = sysTrapSwitch;
174     varbinds[i++].oid = operIPAddress;
175     varbinds[i++].oid = operIPMask;
176     varbinds[i++].oid = operEthernetAddress;
177     varbinds[i++].oid = operGateway;
178     varbinds[i++].oid = operDHCP;
179     varbinds[i++].oid = operPrimaryPort;
180     varbinds[i++].oid = operIPFilter;
181     varbinds[i++].oid = bridgeOperationalMode;
182     varbinds[i++].oid = bridgeRemoteBridgeBSSID;
183     if ((ap_type == ATMEL410 && ap_vendorext == SBRIDGES) ||
184         (ap_type == ATMEL12350)) {
185         varbinds[i++].oid = operConfigurationPort;
186         varbinds[i++].oid = operForwarbBcast;
187         varbinds[i++].oid = operSendBackBcast;
188         varbinds[i++].oid = operSendBackUnicast;
189     }
190     if (ap_type == ATMEL12350 &&
191         (ap_vendorext == GEMTEK || ap_vendorext == EZYNET)) {
192             varbinds[i++].oid = operTrapPort;
193     }
194
195     print_help(WAIT_RET);
196     if (snmp(varbinds, i, GET) < i) {
197         print_helperr(ERR_RET);
198         goto exit;
199     }
200
201     print_top(NULL, _("Bridging"));
202
203     sprintf(message, "%s%02X%02X%02X%02X%02X%02X", MAC,
204             varbinds[3].value[0] & 0xFF,
205             varbinds[3].value[1] & 0xFF,
206             varbinds[3].value[2] & 0xFF,
207             varbinds[3].value[3] & 0xFF,
208             varbinds[3].value[4] & 0xFF,
209             varbinds[3].value[5] & 0xFF);
210     mvwaddstr(main_sub, 0, 0, message);
211
212     memcpy(&ip.s_addr, varbinds[1].value, 4);
213     sprintf(message, "%s%s", IPADDR, inet_ntoa(ip));
214     mvwaddstr(main_sub, 1, 0, message);
215
216     memcpy(&mask.s_addr, varbinds[2].value, 4);
217     sprintf(message, "%s%s", NETMASK, inet_ntoa(mask));
218     mvwaddstr(main_sub, 1, 24, message);
219
220     memcpy(&gw.s_addr, varbinds[4].value, 4);
221     sprintf(message, "%s%s", GATEWAY, inet_ntoa(gw));
222     mvwaddstr(main_sub, 2, 0, message);
223
224     filter = *(varbinds[7].value);
225     sprintf(message, "%s%s", IP_FILTER, (filter == 1) ? ON : OFF);
226     mvwaddstr(main_sub, 3, 0, message);
227
228 /*
229     if (ap_type == ATMEL410 && ap_vendorext == SBRIDGES) {
230         sprintf(message, "%s%02X%02X%02X%02X%02X%02X", SB_ATTMAC,
231                 *(varbinds[6].value +0) & 0xFF, *(varbinds[6].value +1) & 0xFF,
232                 *(varbinds[6].value +2) & 0xFF, *(varbinds[6].value +3) & 0xFF,
233                 *(varbinds[6].value +4) & 0xFF, *(varbinds[6].value +5) & 0xFF);
234     } else {
235 */
236         primary_port = *(varbinds[6].value);
237         if (primary_port < 1 || primary_port > 2) {
238             primary_port = 1;
239         }
240         sprintf(message, "%s%s", PR_PORT, pr_ports[primary_port - 1]);
241 /*
242     }
243 */
244     mvwaddstr(main_sub, 4, 0, message);
245
246     dhcp = *(varbinds[5].value);
247     sprintf(message, "%s%s", DHCP, (dhcp == 1) ? ON : OFF);
248     mvwaddstr(main_sub, 5, 0, message);
249
250     memcpy(RemoteBSSID, varbinds[9].value, 6);
251     if ((bridge_mode = *(varbinds[8].value)) != 2) {
252         sprintf(message, "%s%02X%02X%02X%02X%02X%02X", REMOTE_MAC,
253                 *(RemoteBSSID + 0) & 0xFF, *(RemoteBSSID + 1) & 0xFF,
254                 *(RemoteBSSID + 2) & 0xFF, *(RemoteBSSID + 3) & 0xFF,
255                 *(RemoteBSSID + 4) & 0xFF, *(RemoteBSSID + 5) & 0xFF);
256         mvwaddstr(main_sub, 7, 0, message);
257     }
258     if (bridge_mode > 5)
259         bridge_mode  = 6;
260     sprintf(message, "%s%s", OPER, bridge_modes[bridge_mode - 1]);
261     mvwaddstr(main_sub, 6, 0, message);
262
263     traps = *(varbinds[0].value);
264     sprintf(message, "%s%s", TRAPS, (traps == 1) ? ON : OFF);
265     mvwaddstr(main_sub, 8, 0, message);
266
267     if ((ap_type == ATMEL410 && ap_vendorext == SBRIDGES) ||
268         ap_type == ATMEL12350) {
269         config_port = *(varbinds[10].value);
270         if (config_port == 0) /* happens with ATMEL12350 EZYNET firmware only */
271             config_port = 3;
272         sprintf(message, "%s%s", CF_PORT, cf_ports[config_port - 1]);
273         mvwaddstr(main_sub, 9, 0, message);
274
275         fw_bcast = *(varbinds[11].value);
276         sprintf(message, "%s%s", FW_BCAST, (fw_bcast == 1) ? ON : OFF);
277         mvwaddstr(main_sub, 10, 0, message);
278
279         sb_bcast = *(varbinds[12].value);
280         sprintf(message, "%s%s", SB_BCAST, (sb_bcast == 1) ? ON : OFF);
281         mvwaddstr(main_sub, 11, 0, message);
282
283         sb_ucast = *(varbinds[13].value);
284         sprintf(message, "%s%s", SB_UCAST, (sb_ucast == 1) ? ON : OFF);
285         mvwaddstr(main_sub, 12, 0, message);
286     }
287
288     if (ap_type == ATMEL12350 &&
289         (ap_vendorext == GEMTEK || ap_vendorext == EZYNET)) {
290         for (i = 0; i < varbinds[14].len_val;
291             trap_port += varbinds[14].value[i] *
292             (1 << ((varbinds[14].len_val - i - 1) * 8)), i++);
293         sprintf(message, "%s%u", TRAP_PORT, trap_port);
294         mvwaddstr(main_sub, 13, 0, message);
295     }
296
297     wrefresh(main_sub);
298     noecho();
299
300     print_help(HELP);
301     while (1) {
302         switch (getch()) {
303         case 'I':
304         case 'i':
305             get_ip(&ip, 1, strlen(IPADDR), HELP);
306             m_ip = 1;
307             continue;
308         case 'N':
309         case 'n':
310             get_mask(&mask, 1, strlen(IPADDR) + 16 + strlen(NETMASK), HELP);
311             m_mask = 1;
312             continue;
313         case 'G':
314         case 'g':
315             get_ip(&gw, 2, strlen(GATEWAY), HELP);
316             m_gw = 1;
317             continue;
318         case 'F':
319         case 'f':
320             filter = on_off(3, strlen(IP_FILTER));
321             clear_main_new(3, 4);
322             print_menusel(3, 0, IP_FILTER, (filter == 1) ? ON : OFF);
323             m_filter = 1;
324             continue;
325         case 'P':
326         case 'p':
327 /*
328             if (ap_type == ATMEL410 && ap_vendorext == SBRIDGES)
329                 continue;
330 */
331             primary_port = menu_choose(4, strlen(PR_PORT), pr_ports, 2) + 1;
332             clear_main_new(4, 5);
333             print_menusel(4, 0, PR_PORT, pr_ports[primary_port - 1]);
334             m_primary_port = 1;
335             continue;
336         case 'D':
337         case 'd':
338             dhcp = on_off(5, strlen(DHCP));
339             clear_main_new(5, 6);
340             print_menusel(5, 0, DHCP, (dhcp == 1) ? ON : OFF);
341             m_dhcp = 1;
342             continue;
343         case 'O':
344         case 'o':
345             bridge_mode = menu_choose(6, strlen(OPER), bridge_modes, 5) + 1;
346             clear_main_new(6, 8);
347             print_menusel(6, 0, OPER, bridge_modes[bridge_mode - 1]);
348             if (bridge_mode != 2) {
349                 sprintf(message, "%02X%02X%02X%02X%02X%02X",
350                         *(RemoteBSSID + 0) & 0xFF,
351                         *(RemoteBSSID + 1) & 0xFF,
352                         *(RemoteBSSID + 2) & 0xFF,
353                         *(RemoteBSSID + 3) & 0xFF,
354                         *(RemoteBSSID + 4) & 0xFF,
355                         *(RemoteBSSID + 5) & 0xFF);
356                 print_menusel(7, 0, REMOTE_MAC, message);
357             }
358             m_bridge_mode = 1;
359             continue;
360         case 'M':
361         case 'm':
362             if (bridge_mode == 2)
363                 continue;
364
365             get_mac(RemoteBSSID, 7, strlen(REMOTE_MAC));
366 /*          mvwaddstr(main_sub, 7, 21, "  :  :  :  :  :  ");
367             for (i = 0; i < 6; i++) {
368                 get_value(message, 7, 21 + i * 3, 3, ANY_STRING, 0, 0, NULL);
369                 RemoteBSSID[i] = strtol(message, NULL, 16);
370             }
371             sprintf(message, "%s%02X%02X%02X%02X%02X%02X", REMOTE_MAC,
372                 *(RemoteBSSID + 0) & 0xFF, *(RemoteBSSID + 1) & 0xFF,
373                 *(RemoteBSSID + 2) & 0xFF, *(RemoteBSSID + 3) & 0xFF,
374                 *(RemoteBSSID + 4) & 0xFF, *(RemoteBSSID + 5) & 0xFF);
375 */
376             m_remote_bssid = 1;
377             continue;
378         case 'S':
379         case 's':
380             traps = on_off(8, strlen(TRAPS));
381             clear_main_new(8, 9);
382             print_menusel(8, 0, TRAPS, (traps == 1) ? ON : OFF);
383             m_traps = 1;
384             continue;
385         case 'C':
386         case 'c':
387             if ((ap_type == ATMEL410 && ap_vendorext == SBRIDGES) ||
388                 ap_type == ATMEL12350) {
389                 config_port = menu_choose(9, strlen(CF_PORT), cf_ports, 3) + 1;
390                 clear_main_new(9, 10);
391                 print_menusel(9, 0, CF_PORT, cf_ports[config_port - 1]);
392                 m_config_port = 1;
393             }
394             continue;
395         case 'R':
396         case 'r':
397             if ((ap_type == ATMEL410 && ap_vendorext == SBRIDGES) ||
398                 ap_type == ATMEL12350) {
399                 fw_bcast = on_off(10, strlen(FW_BCAST));
400                 clear_main_new(10, 11);
401                 print_menusel(10, 0, FW_BCAST, (fw_bcast == 1) ? ON : OFF);
402                 m_fw_bcast = 1;
403             }
404             continue;
405         case 'B':
406         case 'b':
407             if ((ap_type == ATMEL410 && ap_vendorext == SBRIDGES) ||
408                 ap_type == ATMEL12350) {
409                 sb_bcast = on_off(11, strlen(SB_BCAST));
410                 clear_main_new(11, 12);
411                 print_menusel(11, 0, SB_BCAST, (sb_bcast == 1) ? ON : OFF);
412                 m_sb_bcast = 1;
413             }
414             continue;
415         case 'U':
416         case 'u':
417             if ((ap_type == ATMEL410 && ap_vendorext == SBRIDGES) ||
418                 ap_type == ATMEL12350) {
419                 sb_ucast = on_off(12, strlen(SB_UCAST));
420                 clear_main_new(12, 13);
421                 print_menusel(12, 0, SB_UCAST, (sb_ucast == 1) ? ON : OFF);
422                 m_sb_ucast = 1;
423             }
424             continue;
425         case 'T':
426         case 't':
427             if (ap_type == ATMEL12350 &&
428                 (ap_vendorext == GEMTEK || ap_vendorext == EZYNET)) {
429                 get_value(message, 13, strlen(TRAP_PORT), 6, INT_STRING,
430                     0, 65535, HELP);
431                 trap_port = atoi(message);
432                 m_trap_port = 1;
433             }
434             continue;
435         case 'w':
436         case 'W':
437             i = 0;
438             if (m_filter) {
439                 varbinds[i].oid = operIPFilter;
440                 varbinds[i].len_oid = sizeof(operIPFilter);
441                 varbinds[i].type = INT_VALUE;
442                 varbinds[i].value = (char *) &filter;
443                 varbinds[i].len_val = 1;
444                 i++;
445             }
446             if (m_primary_port) {
447                 varbinds[i].oid = operPrimaryPort;
448                 varbinds[i].len_oid = sizeof(operPrimaryPort);
449                 varbinds[i].type = INT_VALUE;
450                 varbinds[i].value = (char *) &primary_port;
451                 varbinds[i].len_val = 1;
452                 i++;
453             }
454             if (m_dhcp) {
455                 varbinds[i].oid = operDHCP;
456                 varbinds[i].len_oid = sizeof(operDHCP);
457                 varbinds[i].type = INT_VALUE;
458                 varbinds[i].value = (char *) &dhcp;
459                 varbinds[i].len_val = 1;
460                 i++;
461             }
462             if (m_ip) {
463                 varbinds[i].oid = operIPAddress;
464                 varbinds[i].len_oid = sizeof(operIPAddress);
465                 ip.s_addr = htonl(ip.s_addr);
466                 ip.s_addr = swap4(ip.s_addr);
467                 varbinds[i].value = (char *) &ip.s_addr;
468                 varbinds[i].len_val = 4;
469                 varbinds[i].type = INT_VALUE;
470                 i++;
471             }
472             if (m_mask) {
473                 varbinds[i].oid = operIPMask;
474                 varbinds[i].len_oid = sizeof(operIPMask);
475                 mask.s_addr = htonl(mask.s_addr);
476                 mask.s_addr = swap4(mask.s_addr);
477                 varbinds[i].value = (char *) &mask.s_addr;
478                 varbinds[i].len_val = 4;
479                 varbinds[i].type = INT_VALUE;
480                 i++;
481             }
482             if (m_gw) {
483                 varbinds[i].oid = operGateway;
484                 gw.s_addr = htonl(gw.s_addr);
485                 gw.s_addr = swap4(gw.s_addr);
486                 varbinds[i].len_oid = sizeof(operGateway);
487                 varbinds[i].value = (char *) &gw.s_addr;
488                 varbinds[i].len_val = 4;
489                 varbinds[i].type = INT_VALUE;
490                 i++;
491             }
492             if (m_traps) {
493                 varbinds[i].oid = sysTrapSwitch;
494                 varbinds[i].len_oid = sizeof(sysTrapSwitch);
495                 varbinds[i].value = &traps;
496                 varbinds[i].len_val = 1;
497                 varbinds[i].type = INT_VALUE;
498                 i++;
499             }
500             if (m_bridge_mode) {
501                 varbinds[i].oid = bridgeOperationalMode;
502                 varbinds[i].len_oid = sizeof(bridgeOperationalMode);
503                 varbinds[i].value = (char *) &bridge_mode;
504                 varbinds[i].len_val = 1;
505                 varbinds[i].type = INT_VALUE;
506                 i++;
507             }
508             if (m_remote_bssid) {
509                 varbinds[i].oid = bridgeRemoteBridgeBSSID;
510                 varbinds[i].len_oid = sizeof(bridgeRemoteBridgeBSSID);
511                 varbinds[i].value = RemoteBSSID;
512                 varbinds[i].len_val = 6;
513                 varbinds[i].type = STRING_VALUE;
514                 i++;
515             }
516             if (m_config_port) {
517                 varbinds[i].oid = operConfigurationPort;
518                 varbinds[i].len_oid = sizeof(operConfigurationPort);
519                 varbinds[i].type = INT_VALUE;
520                 varbinds[i].value = (char *) &config_port;
521                 varbinds[i].len_val = 1;
522                 i++;
523             }
524             if (m_fw_bcast) {
525                 varbinds[i].oid = operForwarbBcast;
526                 varbinds[i].len_oid = sizeof(operForwarbBcast);
527                 varbinds[i].type = INT_VALUE;
528                 varbinds[i].value = (char *) &fw_bcast;
529                 varbinds[i].len_val = 1;
530                 i++;
531             }
532             if (m_sb_bcast) {
533                 varbinds[i].oid = operSendBackBcast;
534                 varbinds[i].len_oid = sizeof(operSendBackBcast);
535                 varbinds[i].type = INT_VALUE;
536                 varbinds[i].value = (char *) &sb_bcast;
537                 varbinds[i].len_val = 1;
538                 i++;
539             }
540             if (m_sb_ucast) {
541                 varbinds[i].oid = operSendBackUnicast;
542                 varbinds[i].len_oid = sizeof(operSendBackUnicast);
543                 varbinds[i].type = INT_VALUE;
544                 varbinds[i].value = (char *) &sb_ucast;
545                 varbinds[i].len_val = 1;
546                 i++;
547             }
548             if (m_trap_port) {
549                 int len_val;
550
551                 len_val = (trap_port > 0x7fff) ? 3 : (trap_port > 0x7f) ? 2 : 1;
552                 varbinds[i].oid = operTrapPort;
553                 varbinds[i].len_oid = sizeof(operTrapPort);
554                 varbinds[i].type = STRING_VALUE;
555                 varbinds[i].value = (char *) &trap_port;
556                 varbinds[i].len_val = len_val;
557                 i++;
558             }
559
560             print_help(WAIT_SET);
561             if (snmp(varbinds, i, SET) <= 0) {
562                 print_helperr(ERR_SET);
563             } else {
564                 wbkgd(main_sub, A_NORMAL);
565                 wrefresh(main_sub);
566                 print_help(DONE_SET);
567             }
568             goto exit;
569         case 'Q':
570         case 'q':
571             goto quit;
572         }
573         continue;
574     }
575   exit:
576     getch();
577   quit:
578     print_top(NULL, NULL);
579     clear_main(0);
580 }