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 va_list arg;
15 int rv;
17 rv = -1;
19 if(dev == nil){
20 werrstr("no device specified");
21 return rv;
22 }
24 rpc = auth_allocrpc();
25 if(rpc != nil){
26 quotefmtinstall(); /* just in case */
27 va_start(arg, fmt);
28 params = vsmprint(fmt, arg);
29 va_end(arg);
30 if(params != nil){
31 p = smprint("proto=wep %s", params);
32 if(p != nil){
33 if(auth_rpc(rpc, "start", p, strlen(p)) == ARok
34 && auth_rpc(rpc, "write", dev, strlen(dev)) == ARok)
35 rv = 0;
36 free(p);
37 }
38 free(params);
39 }
40 auth_freerpc(rpc);
41 }
42 return rv;
43 }