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;
39 SPRINT(filename, "%s/gsm.conf", CONFIG_DATA);
41 if (!(fp=fopen(filename,"r"))) {
42 UPRINT(conf_error, "Cannot open %s\n",filename);
47 while((GETLINE(buffer, fp))) {
51 while(*p <= 32) { /* skip spaces */
56 if (*p==0 || *p=='#') /* ignore comments and empty line */
60 i=0; /* read option */
62 if (i+1 >= sizeof(option)) {
63 UPRINT(conf_error, "Error in %s (line %d): option too long.\n",filename,line);
70 while(*p <= 32) { /* skip spaces */
78 while(*p!=0 && *p!='#' && pnum < 10) { /* param */
81 if (i+1 >= sizeof(params[pnum])) {
82 UPRINT(conf_error, "Error in %s (line %d): param too long.\n",filename,line);
85 params[pnum][i+1] = '\0';
86 params[pnum][i++] = *p++;
88 while(*p <= 32) { /* skip spaces */
97 /* at this point we have option and param */
100 if (!strcmp(option,"debug")) {
101 if (params[0][0]==0) {
102 UPRINT(conf_error, "Error in %s (line %d): parameter for option %s missing.\n",filename,line,option);
105 SCPY(gsm_conf->debug, params[0]);
108 if (!strcmp(option,"interface-bsc")) {
109 if (params[0][0]==0) {
110 UPRINT(conf_error, "Error in %s (line %d): parameter for option %s missing.\n",filename,line, option);
113 SCPY(gsm_conf->interface_bsc, params[0]);
116 if (!strcmp(option,"interface-lcr")) {
117 if (params[0][0]==0) {
118 UPRINT(conf_error, "Error in %s (line %d): parameter for option %s missing.\n",filename,line, option);
121 SCPY(gsm_conf->interface_lcr, params[0]);
124 if (!strcmp(option,"config")) {
125 if (params[0][0]==0) {
126 UPRINT(conf_error, "Error in %s (line %d): parameter for option %s missing.\n",filename,line, option);
129 SCPY(gsm_conf->openbsc_cfg, params[0]);
132 if (!strcmp(option,"hlr")) {
133 if (params[0][0]==0) {
134 UPRINT(conf_error, "Error in %s (line %d): parameter for option %s missing.\n",filename,line, option);
137 SCPY(gsm_conf->hlr, params[0]);
140 if (!strcmp(option,"reject-cause")) {
141 UPRINT(conf_error, "Option '%s' in gsm.conf has moved to openbsc.cfg", option);
144 if (!strcmp(option,"allow-all")) {
145 gsm_conf->allow_all = 1;
147 if (!strcmp(option,"keep-l2")) {
148 gsm_conf->keep_l2 = 1;
151 if (!strcmp(option,"pcapfile")) {
152 if (params[0][0]==0) {
153 UPRINT(conf_error, "Error in %s (line %d): parameter for option %s missing.\n",filename,line, option);
156 SCPY(gsm_conf->pcapfile, params[0]);
158 UPRINT(conf_error, "Error in %s (line %d): wrong option keyword %s.\n", filename,line,option);