File: aps.c

package info (click to toggle)
ap-utils 1.5-3
  • links: PTS, VCS
  • area: main
  • in suites: buster, stretch
  • size: 2,644 kB
  • sloc: ansic: 22,708; sh: 3,973; makefile: 344; yacc: 316
file content (597 lines) | stat: -rw-r--r-- 16,930 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
/*
 *      aps.c from Access Point SNMP Utils for Linux
 *
 * Copyright (c) 2002 Roman Festchook <roma at polesye dot net>
 * Copyright (c) 2004 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
 * June 1991 as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 *
 */
#include <string.h>
#include <unistd.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdlib.h>
#include "ap-utils.h"

#define KNOWN_APS _("Known Access Points")

extern WINDOW *main_win, *main_sub /* *win_for_menu */;
extern short ap_type, ap_vendorext;
extern int sockfd, atmel410_filter;
extern struct in_addr ap_ip;

int ap_viewtype = 1;

void APs()
{
    /*
     * Structure of single record in the KnownAP table.
     */
    struct ap {
	unsigned char mac[6];
	unsigned char q1;
	unsigned char q2;
	unsigned char channel;
	unsigned char x2;
	unsigned char options;
	unsigned char x3[5];
	unsigned char essid[32];
    } *app = NULL;

    /*
     * Structure used to preserve important values of AP records learnt
     * by KnownAP scan. Used to connect to a specific AP.
     */
    struct known_ap {
	char mac[6];
	int essid_len;
	char channel;
	char essid[32];
	enum { Infrastructure, AdHoc } nettype;
    } ap[16];

    /* this one is ATMEL12350 specific */
    char SiteSurveyCommand[] = {
	0x2B, 0x06, 0x01, 0x04, 0x01, 0xE0, 0x3E, 0x01, 0x01, 0x01, 0x07, 0x00
    };

    char bridgeOperationalMode[] = {
	0x2B, 0x06, 0x01, 0x04, 0x01, 0x83, 0x1A, 0x01, 0x01, 0x04, 0x01, 0x00
    };
    char bridgeRemoteBridgeBSSID[] = {
	0x2B, 0x06, 0x01, 0x04, 0x01, 0x83, 0x1A, 0x01, 0x01, 0x04, 0x02, 0x00
    };

    char operChannelID[] = {
	0x2B, 0x06, 0x01, 0x04, 0x01, 0x83, 0x1A, 0x01, 0x02, 0x01, 0x01, 0x00
    };
    char operESSIDLength[] = {
	0x2B, 0x06, 0x01, 0x04, 0x01, 0x83, 0x1A, 0x01, 0x02, 0x01, 0x02, 0x00
    };
    char operESSID[] = {
	0x2B, 0x06, 0x01, 0x04, 0x01, 0x83, 0x1A, 0x01, 0x02, 0x01, 0x03, 0x00
    };
    char KnownAP[] = {
	0x2B, 0x06, 0x01, 0x04, 0x01, 0x83, 0x1A, 0x01, 0x02, 0x07, 0x01, 0x00
    };

    char value[] = "", c, bridge_mode;
    char essid[33], bssid[13], message[65];
    int i, j, errno, aps_num = 0, needs_opmode_restore = 0;
    varbind varbinds[4];
   
   if (ap_type == ATMEL12350) {
	operESSIDLength[5] = 0xE0;
	operESSIDLength[6] = 0x3E;
	operESSID[5] = 0xE0;
	operESSID[6] = 0x3E;
	operChannelID[5] = 0xE0;
	operChannelID[6] = 0x3E;
	KnownAP[5] = 0xE0;
	KnownAP[6] = 0x3E;
	bridgeOperationalMode[5] = 0xE0;
	bridgeOperationalMode[6] = 0x3E;
	bridgeRemoteBridgeBSSID[5] = 0xE0;
	bridgeRemoteBridgeBSSID[6] = 0x3E;
    }

    noecho();
    print_help(WAIT_RET);

    varbinds[0].oid = bridgeOperationalMode;
    varbinds[0].len_oid = sizeof(bridgeOperationalMode);
    varbinds[0].value = bridgeOperationalMode;
    varbinds[0].len_val = 0;
    varbinds[0].type = NULL_VALUE;
    if (snmp(varbinds, 1, GET) <= 0) {
	print_helperr(ERR_RET);
	goto exit;
    }
    bridge_mode = *(varbinds[0].value);

    /* ATMEL410 firmware KnownAP scan is active in AP Client mode only */
    if (ap_type == ATMEL410 && bridge_mode != 3) {
	mvwaddstr(main_sub, 3, 1,
	    _
	    ("Your Access Point is not in \"AP client\" mode => getting"));
	mvwaddstr(main_sub, 4, 1,
	    _
	    ("up-to-date \"Known APs\" info requires your AP to be"));
	mvwaddstr(main_sub, 5, 1,
	    _
	    ("temporarily configured into \"AP client\" mode and rebooted."));
	mvwaddstr(main_sub, 6, 1,
	    _
	    ("Your AP will be reconfigured back to original mode by this"));
	mvwaddstr(main_sub, 7, 1,
	    _
	    ("utility once you quit the \"KnownAP\" view. This, in turn, may"));
	mvwaddstr(main_sub, 8, 1,
	    _
	    ("cause loss of Access Point's current configuration."));
	wattrset(main_sub, A_BOLD);
	mvwaddstr(main_sub, 9, 1,
	    _
	    ("Do NOT answer \"Yes\" if you're connected to the Access Point"));
	mvwaddstr(main_sub, 10, 1,
	    _
	    ("via its wireless port."));
	wattrset(main_sub, A_NORMAL);
	mvwaddstr(main_sub, 12, 20, _("Do you want to continue? "));
	wrefresh(main_sub);
	if (help_ysn())
	    goto quit;

	needs_opmode_restore = 1;
	print_help(WAIT_RET);
	varbinds[0].oid = bridgeOperationalMode;
	varbinds[0].len_oid = sizeof(bridgeOperationalMode);
	varbinds[0].type = INT_VALUE;
	c = 3;
	varbinds[0].value = &c;
	varbinds[0].len_val = 1;
	if (snmp(varbinds, 1, SET) <= 0) {
	    print_helperr(ERR_RET);
	    goto exit;
	}

	if (SysUpload()) {
	    print_helperr(ERR_RET);
	    goto restore_before_exit;
	}
	sleep(7);
    }

    sprintf(message, "%s%c", VIEW, ap_viewtype + '0');
    print_top(message, KNOWN_APS);

get_stats:
    varbinds[0].oid = KnownAP;
    varbinds[0].len_oid = sizeof(KnownAP);
    varbinds[0].type = NULL_VALUE;
    varbinds[0].value = value;
    varbinds[0].len_val = sizeof(value);

    if (snmp(varbinds, 1, GET) <= 0) {
	print_helperr(ERR_RET);
	goto restore_before_exit;
    }


show_stats:
    /* display column info in main_sub */
    mvwin(main_sub, 0, 0);
    wattrset(main_sub, COLOR_PAIR(13));
    for (i = 0; i < 64; i++)
	waddch(main_sub, ' ');
    switch (ap_viewtype) {
	case 1:
	case 2:
	    mvwaddstr(main_sub, 0, 0, "#");
	    mvwaddstr(main_sub, 0, 2, "ESSID");
	    mvwaddstr(main_sub, 0, 18, "BSSID (MAC)");
	    mvwaddstr(main_sub, 0, 31, "CN");
	    mvwaddstr(main_sub, 0, 34, _("NetworkType"));
	    mvwaddstr(main_sub, 0, 49, "P");
	    mvwaddstr(main_sub, 0, 51, "WEP");
	    mvwaddstr(main_sub, 0, 55, "RSSI");
	    if (ap_type == ATMEL410) mvwaddstr(main_sub, 0, 62, "LQ");
	    break;
	case 3:
	    mvwaddstr(main_sub, 0, 0, "#");
	    mvwaddstr(main_sub, 0, 2, "ESSID");
	    mvwaddstr(main_sub, 0, 35, "BSSID (MAC)");
	    mvwaddstr(main_sub, 0, 48, "CN");
	    mvwaddstr(main_sub, 0, 51, "P");
	    mvwaddstr(main_sub, 0, 53, "WEP");
	    mvwaddstr(main_sub, 0, 57, "RSSI");
	    if (ap_type == ATMEL410) mvwaddstr(main_sub, 0, 62, "LQ");
	    break;
	case 4:
	    mvwaddstr(main_sub, 0, 0, "#");
	    mvwaddstr(main_sub, 0, 2, "BSSID (MAC)");
	    mvwaddstr(main_sub, 0, 15, "Manufacturer OUI");
	    break;
    }
    wattrset(main_sub, A_NORMAL);

    /* main loop */
    i = aps_num = 0;
    while (1) {
	app = (struct ap *) &varbinds[0].value[i];

	j = app->mac[0] | app->mac[1] | app->mac[2] |
	    app->mac[3] | app->mac[4] | app->mac[5];

	if (!app->channel || app->channel>14 || app->mac[0] == 0xFF
	    || j == 0 || aps_num == 16)
	    break;

	i += sizeof(struct ap);
	aps_num++;

	/* display number */
	sprintf(message, "%c", (aps_num < 10) ? aps_num + '0' : aps_num + 55);
	mvwaddstr(main_sub, aps_num+1, 0, message);

	/* get BSSID */
	sprintf(bssid, "%02X%02X%02X%02X%02X%02X",
		app->mac[0] & 0xFF, app->mac[1] & 0xFF,
		app->mac[2] & 0xFF, app->mac[3] & 0xFF,
		app->mac[4] & 0xFF, app->mac[5] & 0xFF);
	bssid[13] = '\0';

	/* get ESSID and its length */
	for (j = 0; j < 32 && app->essid[j]; j++) {
	    essid[j] = app->essid[j];
	}
	essid[j] = '\0';

	/*
	 * fill up ap[] field member to preserve ESSID, BSSID, Channel and
	 * Network type of current AP record, so we may use it later
	 * to connect to this very AP
	 */
	memcpy(ap[aps_num-1].mac, app->mac, 6);
	memcpy(ap[aps_num-1].essid, essid, j);
	ap[aps_num-1].essid_len = j;
	ap[aps_num-1].channel = app->channel;
	ap[aps_num-1].nettype = (app->options & 1) ? Infrastructure : AdHoc;

	/* display ESSID, BSSID, Channel, NetworkType, Preambule and WEP */
	switch (ap_viewtype) {
	    case 1:
	    case 2:
		mvwaddnstr(main_sub, aps_num+1, 2, essid, 15);
		mvwaddstr(main_sub, aps_num+1, 18, bssid);
		sprintf(message, "%2u", app->channel);
		mvwaddstr(main_sub, aps_num+1, 31, message);
		mvwaddstr(main_sub, aps_num+1, 34,
		    (app->options & 1) ? _("Infrastructure") : "Ad-Hoc");
		mvwaddstr(main_sub, aps_num+1, 49,
		    (app->options & 32) ? "S" : "L");
		mvwaddstr(main_sub, aps_num+1, 51,
		    (app->options & 16) ? ON : OFF);
		break;
	    case 3:
		mvwaddstr(main_sub, aps_num+1, 2, essid);
		mvwaddstr(main_sub, aps_num+1, 35, bssid);
		sprintf(message, "%2u", app->channel);
		mvwaddstr(main_sub, aps_num+1, 48, message);
		mvwaddstr(main_sub, aps_num+1, 51,
		    (app->options & 32) ? "S" : "L");
		mvwaddstr(main_sub, aps_num+1, 53,
		    (app->options & 16) ? ON : OFF);
		break;
	    case 4:
		mvwaddstr(main_sub, aps_num+1, 2, bssid);
		mvwaddnstr(main_sub, aps_num+1, 15,
		    oui2manufacturer(app->mac), 48);
		break;
	}

	/* display RSSI and LQ indicators */
	switch (ap_viewtype) {
	    case 1:
		sprintf(message, "%3d%%",
		    (int)((minimum (app->q1, 40)) * (float)2.5));
		mvwaddstr(main_sub, aps_num+1, 55, message);
		if (ap_type == ATMEL410) {
		    sprintf(message, "%3d%%",
			(int)(100 - (minimum (app->q2, 40)) * (float)2.5) );
		    mvwaddstr(main_sub, aps_num+1, 60, message);
		}
		break;
	    case 2:
		sprintf(message, "%3d", dbmconv(app->q1));
		mvwaddstr(main_sub, aps_num+1, 56, message);
		if (ap_type == ATMEL410) {
		    sprintf(message, "%3d%%",
			(int)(100 - (minimum (app->q2, 40)) * (float)2.5) );
		    mvwaddstr(main_sub, aps_num+1, 60, message);
		}
		break;
	    case 3:
		sprintf(message, "%3d", app->q1);
		mvwaddstr(main_sub, aps_num+1, 57, message);
		if (ap_type == ATMEL410) {
		    sprintf(message, "%3d", app->q2);
		    mvwaddstr(main_sub, aps_num+1, 61, message);
		}
		break;
	}

    }

    /* display legend in main_sub */
    switch (ap_viewtype) {
	case 1:
	    mvwaddstr(main_sub, LINES - 6, 0,
		_("CN: Channel Name; P: Preambule Type (S: Short; L: Long);"));
	    mvwaddstr(main_sub, LINES - 5, 0,
		_("RSSI: Radio Signal Strength Indicator [%]"));
	    if (ap_type == ATMEL410)
		waddstr(main_sub, _("; LQ: Link Quality [%]"));
	    break;
	case 2:
	    mvwaddstr(main_sub, LINES - 6, 0,
		_("CN: Channel Name; P: Preambule Type (S: Short; L: Long);"));
	    mvwaddstr(main_sub, LINES - 5, 0,
		_("RSSI: Radio Signal Strength Indicator [dBm]"));
	    if (ap_type == ATMEL410)
		waddstr(main_sub, _("; LQ: Link Quality [%]"));
	    break;
	case 3:
	    mvwaddstr(main_sub, LINES - 6, 0,
		_("CN: Channel Name; P: Preambule Type (S: Short; L: Long);"));
	    mvwaddstr(main_sub, LINES - 5, 0,
		_("RSSI: Radio Signal Strength Indicator [raw]"));
	    if (ap_type == ATMEL410)
		waddstr(main_sub, _("; LQ: Link Q. [raw]"));
	    break;
    }
    wrefresh(main_sub);

    if (ap_type == ATMEL410)
	print_help(_("# con. to AP #; R refresh with reset; T toggle; Q quit; Other = refr. w/o reset"));
    else /* ATMEL12350 */
	print_help(_("# con. to AP #; R initiate AP scan; T toggle view; Q quit; Other = refresh view"));

	while (1)
           switch (i = getch()) {
            case 'Q':
            case 'q':
		goto restore_before_exit;
	    case '1':
            case '2':
	    case '3':
            case '4':
	    case '5':
	    case '6':
	    case '7':
	    case '8':
	    case '9':
	    case 'a':
	    case 'A':
	    case 'b':
	    case 'B':
	    case 'c':
	    case 'C':
	    case 'd':
	    case 'D':
	    case 'e':
	    case 'E':
	    case 'f':
	    case 'F':
	    case 'g':
	    case 'G':
		    if	    (i >= 'a')
			j = i - 87;
		    else if (i >= 'A')
			j = i - 55;
		    else
			j = i - '0';

		    if(j > aps_num)
			    break;

		    /* don't attempt to connect to remote AP in Ad-Hoc net */
		    if(ap[j-1].nettype == AdHoc)
			    break;

		    print_help(WAIT_SET);
		    varbinds[3].oid = operChannelID;
		    varbinds[3].len_oid = sizeof(operChannelID);
		    varbinds[3].value = &ap[j-1].channel;
		    varbinds[3].len_val = 1;
		    varbinds[3].type = INT_VALUE;
		    varbinds[2].oid = bridgeRemoteBridgeBSSID;
		    varbinds[2].len_oid = sizeof(bridgeRemoteBridgeBSSID);
		    varbinds[2].value = ap[j-1].mac;
		    varbinds[2].len_val = 6;
		    varbinds[2].type = STRING_VALUE;
	            varbinds[1].oid = operESSIDLength;
		    varbinds[1].len_oid = sizeof(operESSIDLength);
		    varbinds[1].value = (char *) &ap[j-1].essid_len;
	            varbinds[1].len_val = 1;
	            varbinds[1].type = INT_VALUE;
	            varbinds[0].oid = operESSID;
		    varbinds[0].len_oid = sizeof(operESSID);
		    varbinds[0].value = ap[j-1].essid;
		    varbinds[0].len_val = ap[j-1].essid_len;
		    varbinds[0].type = STRING_VALUE;
                    if (snmp(varbinds, 4, SET) <= 0) {
                        print_helperr(ERR_SET);
                        goto restore_before_exit;
                    }

		    if (bridge_mode != 3) {
			bridge_mode = 3;
			needs_opmode_restore = 1;
		    }

		    if (SysUpload() < 0 ) {
			    print_helperr(ERR_SET);
			    getch();
			    goto restore_before_exit;
		    }
		    print_help(DONE_SET);
		    getch();
		    goto restore_before_exit;
	    case 'R':
	    case 'r':
		    if (ap_type == ATMEL410) {
			/* force KnownAP scan by reset */
			print_help(WAIT_RET);
			if (SysReset() < 0) {
			    print_helperr(ERR_RET);
			    getch();
			    goto restore_before_exit;
			}
			clear_main(0);
			sleep(7);
		    } else { /* ATMEL12350 */
			/*
			 * Init KnownAP scan by issuing SiteSurveyCommand.
			 * Unfortunately, we may not use snmp() here becouse
			 * it would time out, as buggy firmware in ATMEL12350
			 * devices does not confirm our query reception
			 * received via wireless port, in a reasonable
			 * time frame. So we rather use sendto() here.
			 */
			struct sockaddr_in toip;
			struct timeval tv;
			fd_set rfd;

			varbinds[0].oid = SiteSurveyCommand;
			varbinds[0].len_oid = sizeof(SiteSurveyCommand);
			c = 1;
			varbinds[0].value = &c;
			varbinds[0].len_val = 1;
			varbinds[0].type = INT_VALUE;

			memset(&toip, 0, sizeof toip);
			toip.sin_family = AF_INET;
			toip.sin_port = htons(161);
			toip.sin_addr.s_addr = ap_ip.s_addr;
/*
			if (snmp(varbinds, 1, SET) <= 0) {
			    print_helperr(ERR_SET);
			    goto exit;
			}
*/
			errno = 0;
			i = ber(message, varbinds, 1, SET);
			if (sendto(sockfd, message, i, 0,
			    (struct sockaddr *) &toip, SIZE) == -1) {
			    sprintf(message, _("Failure in sendto(): %s. "
				"Press any key."), strerror(errno));
			    print_helperr(message);
			    goto exit;
			}

			clear_main(0);
			mvwaddstr(main_sub, 3, 1,
			    _
			    ("You have just initiated the AP scan. Be advised that it may"));
			mvwaddstr(main_sub, 4, 1,
			    _
			    ("take a few seconds for your Access Point to find out some"));
			mvwaddstr(main_sub, 5, 1,
			    _
			    ("values, so expect finishing the scan in about 5 seconds."));
			mvwaddstr(main_sub, 6, 1,
			    _
			    ("Also note that your Access Point stops forwarding the network"));
			mvwaddstr(main_sub, 7, 1,
			    _
			    ("traffic while the scan is in progress, but restores itself"));
			mvwaddstr(main_sub, 8, 1,
			    _
			    ("to normal operation in time ranging up to 1 minute."));
			mvwaddstr(main_sub, 9, 1,
			    _
			    ("Hence, if you are connected to target Access Point via its"));
			mvwaddstr(main_sub, 10, 1,
			    _
			    ("wireless port, you need to wait a bit longer"));
			mvwaddstr(main_sub, 11, 1,
			    _
			    ("after pressing 'S'."));
			wrefresh(main_sub);
			print_help("");

			/*
			 * Eat the confirmation packet from socket, if it
			 * has been sent by the AP. This only happens
			 * if we issued KnownAP scan via its ethernet
			 * interface.
			 */
			tv.tv_sec = 2;
			tv.tv_usec = 0;
			FD_ZERO(&rfd);
			FD_SET(sockfd, &rfd);
			if (select(sockfd + 1, &rfd, NULL, NULL, &tv) > 0)
			    recv(sockfd, message, 65, 0);

			print_help("Now, you can try pressing 'S' repeatedly "
			    "to watch the progress.");
			getch();
		    }
		    goto get_stats;
	    case 'T':
	    case 't':
		    ap_viewtype += 1;
		    if (ap_viewtype > 4)
			ap_viewtype = 1;
		    clear_main(0);
		    sprintf(message, "%s%c", VIEW, ap_viewtype + '0');
		    print_top(message, KNOWN_APS);
		    goto show_stats;
	    default:
		    print_help(WAIT_RET);
		    clear_main(0);
		    goto get_stats;
            }

  restore_before_exit:
    if (needs_opmode_restore) {
	print_help(WAIT_SET);
	varbinds[0].oid = bridgeOperationalMode;
	varbinds[0].len_oid = sizeof(bridgeOperationalMode);
	varbinds[0].value = (char *) &bridge_mode;
	varbinds[0].len_val = 1;
	varbinds[0].type = INT_VALUE;
	if (snmp(varbinds, 1, SET) <= 0) {
	    print_helperr(ERR_RET);
	    goto exit;
	}

	if (SysUpload()) {
	    print_helperr(ERR_RET);
	    goto exit;
	}
    }
 goto quit;

 exit:
    getch();
 quit:
    print_top(NULL, NULL);
    clear_main(0);
}