Blob


1 #include <u.h>
2 #include <libc.h>
3 #include <auth.h>
4 #include "authlocal.h"
6 /*
7 * make factotum add wep keys to an 802.11 device
8 */
9 int
10 auth_wep(char *dev, char *fmt, ...)
11 {
12 AuthRpc *rpc;
13 char *params, *p;
14 int fd;
15 va_list arg;
16 int rv;
18 rv = -1;
20 if(dev == nil){
21 werrstr("no device specified");
22 return rv;
23 }
25 fd = open("/mnt/factotum/rpc", ORDWR);
26 if(fd < 0)
27 return rv;
29 rpc = auth_allocrpc(fd);
30 if(rpc != nil){
31 quotefmtinstall(); /* just in case */
32 va_start(arg, fmt);
33 params = vsmprint(fmt, arg);
34 va_end(arg);
35 if(params != nil){
36 p = smprint("proto=wep %s", params);
37 if(p != nil){
38 if(auth_rpc(rpc, "start", p, strlen(p)) == ARok
39 && auth_rpc(rpc, "write", dev, strlen(dev)) == ARok)
40 rv = 0;
41 free(p);
42 }
43 free(params);
44 }
45 auth_freerpc(rpc);
46 }
47 close(fd);
49 return rv;
50 }