501-br2684ctl_itfname.patch 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. --- a/src/br2684/br2684ctl.c
  2. +++ b/src/br2684/br2684ctl.c
  3. @@ -45,6 +45,7 @@ struct br2684_params {
  4. int lastsock, lastitf;
  5. static char *up_script;
  6. +const char *itfname = "nas";
  7. void fatal(const char *str, int err)
  8. @@ -73,7 +74,7 @@ int create_pidfile(int num)
  9. if (num < 0) return -1;
  10. - snprintf(name, 32, "/var/run/br2684ctl-nas%d.pid", num);
  11. + snprintf(name, 32, "/var/run/br2684ctl-%s%d.pid", itfname, num);
  12. pidfile = fopen(name, "w");
  13. if (pidfile == NULL) return -1;
  14. fprintf(pidfile, "%d", getpid());
  15. @@ -102,7 +103,7 @@ int create_br(int itfnum, int payload)
  16. ni.media |= BR2684_FLAG_ROUTED;
  17. #endif
  18. ni.mtu = 1500;
  19. - sprintf(ni.ifname, "nas%d", itfnum);
  20. + sprintf(ni.ifname, "%s%d", itfname, itfnum);
  21. err=ioctl (lastsock, ATM_NEWBACKENDIF, &ni);
  22. if (err == 0)
  23. @@ -167,7 +168,7 @@ int assign_vcc(char *astr, int encap, in
  24. be.backend_num = ATM_BACKEND_BR2684;
  25. be.ifspec.method = BR2684_FIND_BYIFNAME;
  26. - sprintf(be.ifspec.spec.ifname, "nas%d", lastitf);
  27. + sprintf(be.ifspec.spec.ifname, "%s%d", itfname, lastitf);
  28. be.fcs_in = BR2684_FCSIN_NO;
  29. be.fcs_out = BR2684_FCSOUT_NO;
  30. be.fcs_auto = 0;
  31. @@ -198,7 +199,7 @@ void start_interface(struct br2684_param
  32. assign_vcc(params->astr, params->encap, params->payload, params->sndbuf,
  33. params->reqqos);
  34. if (up_script) {
  35. - asprintf(&cmd, "%s nas%d", up_script, lastitf);
  36. + asprintf(&cmd, "%s %s%d", up_script, itfname, lastitf);
  37. system(cmd);
  38. free(cmd);
  39. }
  40. @@ -207,7 +208,7 @@ void start_interface(struct br2684_param
  41. void usage(char *s)
  42. {
  43. - printf("usage: %s [-b] [[-c number] [-e 0|1] [-s sndbuf] [-q qos] [-p 0|1] "
  44. + printf("usage: %s [-b] [-n name] [[-c number] [-e 0|1] [-s sndbuf] [-q qos] [-p 0|1] "
  45. "[-a [itf.]vpi.vci]*]* [-S script]\n", s);
  46. printf(" encapsulations: 0=llc, 1=vcmux\n payloads: 0=routed, 1=bridged\n");
  47. exit(1);
  48. @@ -234,7 +235,7 @@ int main (int argc, char **argv)
  49. openlog (LOG_NAME,LOG_OPTION,LOG_FACILITY);
  50. if (argc>1)
  51. - while ((c = getopt(argc, argv,"q:a:bc:e:s:S:p:?h")) !=EOF)
  52. + while ((c = getopt(argc, argv,"q:a:bn:c:e:s:S:p:?h")) !=EOF)
  53. switch (c) {
  54. case 'q':
  55. printf ("optarg : %s",optarg);
  56. @@ -247,6 +248,9 @@ int main (int argc, char **argv)
  57. case 'b':
  58. background=1;
  59. break;
  60. + case 'n':
  61. + itfname = optarg;
  62. + break;
  63. case 'c':
  64. /* temporary, to make it work with multiple interfaces: */
  65. if (params.itfnum>=0) start_interface(&params);