1 /*****************************************************************************\
5 **---------------------------------------------------------------------------**
6 ** Copyright: Andreas Eversberg **
8 ** generate start/stop script **
10 \*****************************************************************************/
23 int coredebug=0, carddebug=0, l1debug=0, l2debug=0, l3debug=0, dspdebug=0;
33 // { "AVM Fritz PCI (PNP)", "avmfritz", 0, 1, 1},
34 { "HFC PCI (Cologne Chip)", "hfcpci", 1, 0, 1},
35 { "HFC-4S 4 S/T Ports (Cologne Chip)", "hfcmulti", 1, 0, 4},
36 { "HFC-8S 8 S/T Ports (Cologne Chip)", "hfcmulti", 1, 0, 8},
37 { "HFC-E1 1 E1 Port (Cologne Chip)", "hfcmulti", 1, 0, 1},
38 { "HFC-S USB (Cologne Chip)", "hfcsusb", 1, 0, 1},
39 // { "HFC-S MINI (Cologne Chip)", "hfcsmini", 1, 0, 1},
40 // { "XHFC (Cologne Chip)", "xhfc", 1, 0, 1},
41 // { "Sedlbaur FAX", "sedlfax", 0, 1, 1},
42 // { "Winbond 6692 PCI", "w6692pci", 0, 0, 1},
49 int i = 0, j, jj, n, anyte = 0, remove_isac;
51 char protocol[1024], layermask[1024], types[256];
53 printf("This program is outdated and requires update to mISDN V2 API\n");
56 printf("\n\nThis program generates a script, which is used to start/stop/restart mISDN\n");
57 printf("driver. All configuration of cards is done for using with the LCR.\n");
59 while(i < (int)sizeof(mode)) /* number of cards */
64 printf("\nEnter mode of isdn port #%d. Should it run in NT-mode (for internal\nphones), or in TE-mode (for external lines)? If you do not like to add more\ncards, say 'done'.\n[nt | te | done]: ", i+1); fflush(stdout);
66 } while (input[0]!='t' && input[0]!='n' && input[0]!='d');
73 printf("\nIs your port #%d connected to point-to-multipoint line/phone, which supports multiple\ntelephones (Mehrgeräteanschluss) OR is it a point-to-point link which is used\nfor LCR and supports extension dialing (Anlagenanschluss)?\n[ptp | ptm]: ", i+1); fflush(stdout);
75 } while (!!strcmp(input,"ptp") && !!strcmp(input,"ptm"));
76 ptp[i] = (input[2]=='p')?1:0;
84 printf("\nSelect driver of ISDN port #%d.\n\n", i+1);
88 if (cards[jj].ntmode || mode[i]!='n')
89 printf(" (%d) %s\n", jj+1, cards[jj].card);
92 printf("\n%sSelect card number[1-n]: ", (mode[i]=='n')?"Your card will run in NT-mode. The shown cards are capable of providing\nhardware layer for NT-mode.\n":""); fflush(stdout);
94 } while (atoi(input) <= 0);
95 type[i] = atoi(input);
100 if (j+1==type[i] && (cards[j].ntmode || mode[i]!='n'))
106 printf("\n\nWrong selection, please try again.\n");
110 if (cards[type[i-1]-1].ports == port[i-1])
114 port[i] = port[i-1]+1;
115 printf("\nUsing port %d of card '%s'.", port[i], cards[type[i]-1].card);
118 printf("\n\n\nSummary: Port #%d of type %s will run in %s-mode and %s-mode.\n", i+1, cards[type[i]-1].card, (mode[i]=='n')?"NT":"TE", (ptp[i])?"point-to-point":"point-to-multipoint");
125 printf("\nNo ports/cards defined!\n");
128 if (cards[type[i-1]-1].ports > port[i-1])
130 printf("\nNot all ports for the last card are defined. Please do that even if they will be not\nused! Select 'NT-mode' for these unused ports.\n");
134 printf("\nEnter LAW audio mode. For a-LAW (default), just enter 0. For u-LAW enter 1.\n[0..n | 0xn]: "); fflush(stdout);
136 lawopt = strtoul(input, NULL, 0);
137 printf("\nEnter debugging flags of mISDN core. For no debug, just enter 0.\n[0..n | 0xn]: "); fflush(stdout);
139 coredebug = strtoul(input, NULL, 0);
140 printf("\nEnter debugging flags of cards. For no debug, just enter 0.\n[0..n | 0xn]: "); fflush(stdout);
142 carddebug = strtoul(input, NULL, 0);
143 printf("\nEnter l1 debugging flags of driver. For no debug, just enter 0.\n[0..n | 0xn]: "); fflush(stdout);
145 l1debug = strtoul(input, NULL, 0);
146 printf("\nEnter l2 debugging flags of driver. For no debug, just enter 0.\n[0..n | 0xn]: "); fflush(stdout);
148 l2debug = strtoul(input, NULL, 0);
149 printf("\nEnter l3 debugging flags of driver. For no debug, just enter 0.\n[0..n | 0xn]: "); fflush(stdout);
151 l3debug = strtoul(input, NULL, 0);
152 printf("\nEnter dsp debugging flags of driver. For no debug, just enter 0.\n[0..n | 0xn]: "); fflush(stdout);
154 dspdebug = strtoul(input, NULL, 0);
158 printf("\nWhere do you like to load the modules from, enter 0 for default, 1 for\n'/usr/local/lcr/modules/' or the full path.\n[0 | 1 | <path>]: "); fflush(stdout);
160 if (!strcmp(input, "0"))
162 if (!strcmp(input, "1"))
163 SCPY(input, "/usr/local/lcr/modules");
164 if (input[0]) if (input[strlen(input)-1] != '/')
167 printf("\n\nFinally tell me where to write the mISDN rc file.\Enter the name 'mISDN' for current directory.\nYou may want to say '/usr/local/lcr/mISDN' or '/etc/rc.d/mISDN'\n: "); fflush(stdout);
169 if (!(fp=fopen(name, "w")))
171 fprintf(stderr, "\nError: Failed to open '%s', try again.\n", name);
174 fprintf(fp, "# rc script for mISDN driver\n\n");
175 fprintf(fp, "case \"$1\" in\n");
176 fprintf(fp, "\tstart|--start)\n");
177 fprintf(fp, "\t\t%s %smISDN_core%s debug=0x%x\n", input[0]?"insmod -f":"modprobe --ignore-install", input, input[0]?".ko":"", coredebug);
180 fprintf(fp, "\t\t%s %smISDN_l1%s debug=0x%x\n", input[0]?"insmod -f":"modprobe --ignore-install", input, input[0]?".ko":"", l1debug);
181 fprintf(fp, "\t\t%s %smISDN_l2%s debug=0x%x\n", input[0]?"insmod -f":"modprobe --ignore-install", input, input[0]?".ko":"", l2debug);
182 fprintf(fp, "\t\t%s %sl3udss1%s debug=0x%x\n", input[0]?"insmod -f":"modprobe --ignore-install", input, input[0]?".ko":"", l3debug);
184 fprintf(fp, "\t\t%s %smISDN_dsp%s debug=0x%x options=0x%x\n", input[0]?"insmod -f":"modprobe --ignore-install", input, input[0]?".ko":"", dspdebug, lawopt);
188 protocol[0] = layermask[0] = types[0] = '\0';
194 if (!strcmp(cards[j].module, "hfcmulti") && port[i]==1)
195 UPRINT(strchr(types,'\0'), "0x%x,", cards[j].ports+((lawopt)?0x100:0)+0x200);
196 UPRINT(strchr(protocol,'\0'), "0x%x,", ((mode[i]=='n')?0x12:0x2) + (ptp[i]?0x20:0x0));
197 UPRINT(strchr(layermask,'\0'), "0x%x,", (mode[i]=='n')?0x3:0x0f);
203 protocol[strlen(protocol)-1] = '\0';
204 layermask[strlen(layermask)-1] = '\0';
207 types[strlen(types)-1] = '\0';
208 fprintf(fp, "\t\t%s %s%s%s type=%s protocol=%s layermask=%s debug=0x%x\n", input[0]?"insmod -f":"modprobe --ignore-install", input, cards[j].module, input[0]?".ko":"", types, protocol, layermask, carddebug);
210 fprintf(fp, "\t\t%s %s%s%s protocol=%s layermask=%s debug=0x%x\n", input[0]?"insmod -f":"modprobe --ignore-install", input, cards[j].module, input[0]?".ko":"", protocol, layermask, carddebug);
214 fprintf(fp, "\t\tsleep 1\n");
215 fprintf(fp, "\t\t;;\n\n");
216 fprintf(fp, "\tstop|--stop)\n");
233 fprintf(fp, "\t\trmmod %s\n", cards[j].module);
241 fprintf(fp, "\t\trmmod mISDN_isac\n");
243 fprintf(fp, "\t\trmmod mISDN_dsp\n");
246 fprintf(fp, "\t\trmmod l3udss1\n");
247 fprintf(fp, "\t\trmmod mISDN_l2\n");
248 fprintf(fp, "\t\trmmod mISDN_l1\n");
250 fprintf(fp, "\t\trmmod mISDN_core\n");
251 fprintf(fp, "\t\t;;\n\n");
252 fprintf(fp, "\trestart|--restart)\n");
253 fprintf(fp, "\t\tsh $0 stop\n");
254 fprintf(fp, "\t\tsleep 2 # some phones will release tei when layer 1 is down\n");
255 fprintf(fp, "\t\tsh $0 start\n");
256 fprintf(fp, "\t\t;;\n\n");
257 fprintf(fp, "\thelp|--help)\n");
258 fprintf(fp, "\t\techo \"Usage: $0 {start|stop|restart|help}\"\n");
259 fprintf(fp, "\t\texit 0\n");
260 fprintf(fp, "\t\t;;\n\n");
261 fprintf(fp, "\t*)\n");
262 fprintf(fp, "\t\techo \"Usage: $0 {start|stop|restart|help}\"\n");
263 fprintf(fp, "\t\texit 2\n");
264 fprintf(fp, "\t\t;;\n\n");
265 fprintf(fp, "esac\n");
268 printf("\nFile '%s' is written to the current directory.\n", name);