ppp.c 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #include <u.h>
  2. #include <libc.h>
  3. #include <ip.h>
  4. #include <bio.h>
  5. #include <ndb.h>
  6. #include "../dhcp.h"
  7. typedef struct Block Block;
  8. typedef struct Fs Fs;
  9. #include "/sys/src/9/ip/ipv6.h"
  10. #include "ipconfig.h"
  11. void
  12. pppbinddev(void)
  13. {
  14. int ac, pid;
  15. char *av[12];
  16. Waitmsg *w;
  17. /* ppp does the binding */
  18. /* start with an empty config file */
  19. if(nip == 0)
  20. writendb("", 0, 0);
  21. switch(pid = rfork(RFPROC|RFFDG|RFMEM)){
  22. case -1:
  23. sysfatal("can't start ppp: %r");
  24. case 0:
  25. ac = 0;
  26. av[ac++] = "ppp";
  27. av[ac++] = "-uf";
  28. av[ac++] = "-p";
  29. av[ac++] = conf.dev;
  30. av[ac++] = "-x";
  31. av[ac++] = conf.mpoint;
  32. if(conf.baud != nil){
  33. av[ac++] = "-b";
  34. av[ac++] = conf.baud;
  35. }
  36. av[ac] = nil;
  37. exec("/bin/ip/ppp", av);
  38. exec("/ppp", av);
  39. sysfatal("execing /ppp: %r");
  40. }
  41. /* wait for ppp to finish connecting and configuring */
  42. while((w = wait()) != nil){
  43. if(w->pid == pid){
  44. if(w->msg[0] != 0)
  45. sysfatal("/ppp exited with status: %s", w->msg);
  46. free(w);
  47. break;
  48. }
  49. free(w);
  50. }
  51. if(w == nil)
  52. sysfatal("/ppp disappeared");
  53. /* ppp sets up the configuration itself */
  54. noconfig = 1;
  55. getndb();
  56. }