br2684ctl: add support for notifying nas* bringup via a script
[openwrt/openwrt.git] / package / network / utils / linux-atm / patches / 500-br2684ctl_script.patch
1 --- a/src/br2684/br2684ctl.c
2 +++ b/src/br2684/br2684ctl.c
3 @@ -1,3 +1,4 @@
4 +#define _GNU_SOURCE
5 #include <stdio.h>
6 #include <stdlib.h>
7 #include <unistd.h>
8 @@ -43,6 +44,7 @@ struct br2684_params {
9
10
11 int lastsock, lastitf;
12 +static char *up_script;
13
14
15 void fatal(const char *str, int err)
16 @@ -185,6 +187,8 @@ int assign_vcc(char *astr, int encap, in
17
18 void start_interface(struct br2684_params* params)
19 {
20 + char *cmd;
21 +
22 if (params->astr==NULL) {
23 syslog(LOG_ERR, "Required ATM parameters not specified.");
24 exit(1);
25 @@ -193,13 +197,18 @@ void start_interface(struct br2684_param
26 create_br(params->itfnum, params->payload);
27 assign_vcc(params->astr, params->encap, params->payload, params->sndbuf,
28 params->reqqos);
29 + if (up_script) {
30 + asprintf(&cmd, "%s nas%d", up_script, lastitf);
31 + system(cmd);
32 + free(cmd);
33 + }
34 }
35
36
37 void usage(char *s)
38 {
39 printf("usage: %s [-b] [[-c number] [-e 0|1] [-s sndbuf] [-q qos] [-p 0|1] "
40 - "[-a [itf.]vpi.vci]*]*\n", s);
41 + "[-a [itf.]vpi.vci]*]* [-S script]\n", s);
42 printf(" encapsulations: 0=llc, 1=vcmux\n payloads: 0=routed, 1=bridged\n");
43 exit(1);
44 }
45 @@ -258,6 +267,9 @@ int main (int argc, char **argv)
46 params.sndbuf=8192;
47 }
48 break;
49 + case 'S':
50 + up_script = optarg;
51 + break;
52 case 'p': /* payload type: routed (0) or bridged (1) */
53 #ifdef BR2684_FLAG_ROUTED
54 params.payload = atoi(optarg);