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