auth_wep.c 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*
  2. * This file is part of the UCB release of Plan 9. It is subject to the license
  3. * terms in the LICENSE file found in the top-level directory of this
  4. * distribution and at http://akaros.cs.berkeley.edu/files/Plan9License. No
  5. * part of the UCB release of Plan 9, including this file, may be copied,
  6. * modified, propagated, or distributed except according to the terms contained
  7. * in the LICENSE file.
  8. */
  9. #include <u.h>
  10. #include <libc.h>
  11. #include <auth.h>
  12. #include "authlocal.h"
  13. /*
  14. * make factotum add wep keys to an 802.11 device
  15. */
  16. int
  17. auth_wep(char *dev, char *fmt, ...)
  18. {
  19. AuthRpc *rpc;
  20. char *params, *p;
  21. int fd;
  22. va_list arg;
  23. int rv;
  24. rv = -1;
  25. if(dev == nil){
  26. werrstr("no device specified");
  27. return rv;
  28. }
  29. fd = open("/mnt/factotum/rpc", ORDWR);
  30. if(fd < 0)
  31. return rv;
  32. rpc = auth_allocrpc(fd);
  33. if(rpc != nil){
  34. quotefmtinstall(); /* just in case */
  35. va_start(arg, fmt);
  36. params = vsmprint(fmt, arg);
  37. va_end(arg);
  38. if(params != nil){
  39. p = smprint("proto=wep %s", params);
  40. if(p != nil){
  41. if(auth_rpc(rpc, "start", p, strlen(p)) == ARok
  42. && auth_rpc(rpc, "write", dev, strlen(dev)) == ARok)
  43. rv = 0;
  44. free(p);
  45. }
  46. free(params);
  47. }
  48. auth_freerpc(rpc);
  49. }
  50. close(fd);
  51. return rv;
  52. }