]> git.decadent.org.uk Git - ap-utils.git/blob - lib/reset.c
Imported Upstream version 1.5~pre3~a
[ap-utils.git] / lib / reset.c
1 /*
2  *     reset.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 #include <unistd.h>
21 #include "ap-utils.h"
22
23 int SysReset()
24 {
25     char sysReset[] = { 0x2B, 0x06, 0x01, 0x04, 0x01, 0x83, 0x1A, 0x01, 0x01, 0x01, 0x02, 0x00 }, enable = 1;
26     varbind varbinds[1];
27     char operESSID[] = { 0x2a, 0x86, 0x48, 0xce, 0x34, 0x01, 0x01, 0x01, 0x09, 0x01 };
28     extern short ap_type;
29
30         if (ap_type == ATMEL12350) {
31                 sysReset[5] = 0xe0;
32                 sysReset[6] = 0x3e;
33         }
34     
35         if(ap_type == ATMEL410 || ap_type == ATMEL12350){
36                 varbinds[0].oid = sysReset;
37                 varbinds[0].len_oid = sizeof(sysReset);
38                 varbinds[0].value = &enable;
39                 varbinds[0].len_val = 1;
40                 varbinds[0].type = INT_VALUE;
41         }
42         else {
43                 varbinds[0].len_val = 0;
44                 varbinds[0].type = NULL_VALUE;
45                 varbinds[0].oid = operESSID;
46                 varbinds[0].len_oid = sizeof(operESSID);
47                 if (snmp(varbinds, 1, GET) <= 0)
48                         return -1;
49                varbinds[0].type = STRING_VALUE;
50         }
51
52     if (snmp(varbinds, 1, SET) <= 0)
53         return -1;
54     else {
55         if(ap_type==NWN)
56                 sleep(15);
57         return 0;
58     }
59 }
60