1 /*****************************************************************************\
5 **---------------------------------------------------------------------------**
6 ** Copyright: Andreas Eversberg **
8 ** reading options.conf and filling structure **
10 \*****************************************************************************/
17 * read options from options.conf
19 int gsm_conf(struct gsm_conf *gsm_conf, char *conf_error)
31 SCPY(gsm_conf->debug, "");
32 SCPY(gsm_conf->interface_bsc, "mISDN_l1loop.1");
33 SCPY(gsm_conf->interface_lcr, "mISDN_l1loop.2");
34 SCPY(gsm_conf->hlr, "hlr.sqlite3");
35 SCPY(gsm_conf->openbsc_cfg, "openbsc.cfg");
36 gsm_conf->reject_cause = 0;
37 gsm_conf->keep_l2 = 0;
38 gsm_conf->noemergshut = 0;
40 SPRINT(filename, "%s/gsm.conf", CONFIG_DATA);
42 if (!(fp=fopen(filename,"r"))) {
43 UPRINT(conf_error, "Cannot open %s\n",filename);
48 while((GETLINE(buffer, fp))) {
52 while(*p <= 32) { /* skip spaces */
57 if (*p==0 || *p=='#') /* ignore comments and empty line */
61 i=0; /* read option */
63 if (i+1 >= sizeof(option)) {
64 UPRINT(conf_error, "Error in %s (line %d): option too long.\n",filename,line);
71 while(*p <= 32) { /* skip spaces */
79 while(*p!=0 && *p!='#' && pnum < 10) { /* param */
82 if (i+1 >= sizeof(params[pnum])) {
83 UPRINT(conf_error, "Error in %s (line %d): param too long.\n",filename,line);
86 params[pnum][i+1] = '\0';
87 params[pnum][i++] = *p++;
89 while(*p <= 32) { /* skip spaces */
98 /* at this point we have option and param */
101 if (!strcmp(option,"debug")) {
102 if (params[0][0]==0) {
103 UPRINT(conf_error, "Error in %s (line %d): parameter for option %s missing.\n",filename,line,option);
106 SCPY(gsm_conf->debug, params[0]);
109 if (!strcmp(option,"interface-bsc")) {
110 if (params[0][0]==0) {
111 UPRINT(conf_error, "Error in %s (line %d): parameter for option %s missing.\n",filename,line, option);
114 SCPY(gsm_conf->interface_bsc, params[0]);
117 if (!strcmp(option,"interface-lcr")) {
118 if (params[0][0]==0) {
119 UPRINT(conf_error, "Error in %s (line %d): parameter for option %s missing.\n",filename,line, option);
122 SCPY(gsm_conf->interface_lcr, params[0]);
125 if (!strcmp(option,"config")) {
126 if (params[0][0]==0) {
127 UPRINT(conf_error, "Error in %s (line %d): parameter for option %s missing.\n",filename,line, option);
130 SCPY(gsm_conf->openbsc_cfg, params[0]);
133 if (!strcmp(option,"hlr")) {
134 if (params[0][0]==0) {
135 UPRINT(conf_error, "Error in %s (line %d): parameter for option %s missing.\n",filename,line, option);
138 SCPY(gsm_conf->hlr, params[0]);
141 if (!strcmp(option,"reject-cause")) {
142 UPRINT(conf_error, "Option '%s' in gsm.conf has moved to openbsc.cfg", option);
145 if (!strcmp(option,"allow-all")) {
146 gsm_conf->allow_all = 1;
148 if (!strcmp(option,"keep-l2")) {
149 gsm_conf->keep_l2 = 1;
152 if (!strcmp(option,"no-mergency-shutdown")) {
153 gsm_conf->noemergshut = 1;
155 if (!strcmp(option,"pcapfile")) {
156 if (params[0][0]==0) {
157 UPRINT(conf_error, "Error in %s (line %d): parameter for option %s missing.\n",filename,line, option);
160 SCPY(gsm_conf->pcapfile, params[0]);
162 UPRINT(conf_error, "Error in %s (line %d): wrong option keyword %s.\n", filename,line,option);