summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/host/layer23/include/osmocom/bb/mobile/app_mobile.h2
-rw-r--r--src/host/layer23/src/mobile/gsm322.c11
-rw-r--r--src/host/layer23/src/mobile/main.c7
3 files changed, 13 insertions, 7 deletions
diff --git a/src/host/layer23/include/osmocom/bb/mobile/app_mobile.h b/src/host/layer23/include/osmocom/bb/mobile/app_mobile.h
index 138fbe04..4010a685 100644
--- a/src/host/layer23/include/osmocom/bb/mobile/app_mobile.h
+++ b/src/host/layer23/include/osmocom/bb/mobile/app_mobile.h
@@ -1,6 +1,8 @@
#ifndef APP_MOBILE_H
#define APP_MOBILE_H
+char *config_dir;
+
int l23_app_init(int (*mncc_recv)(struct osmocom_ms *ms, int, void *),
const char *config_file, uint16_t vty_port);
int l23_app_exit(void);
diff --git a/src/host/layer23/src/mobile/gsm322.c b/src/host/layer23/src/mobile/gsm322.c
index 3c920e4e..1996f93a 100644
--- a/src/host/layer23/src/mobile/gsm322.c
+++ b/src/host/layer23/src/mobile/gsm322.c
@@ -24,6 +24,7 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
+#include <limits.h>
#include <osmocore/msgb.h>
#include <osmocore/talloc.h>
@@ -3463,7 +3464,7 @@ int gsm322_init(struct osmocom_ms *ms)
struct gsm322_plmn *plmn = &ms->plmn;
struct gsm322_cellsel *cs = &ms->cellsel;
FILE *fp;
- char filename[128];
+ char filename[PATH_MAX];
int i;
struct gsm322_ba_list *ba;
uint8_t buf[4];
@@ -3494,7 +3495,7 @@ int gsm322_init(struct osmocom_ms *ms)
cs->list[i].flags |= GSM322_CS_FLAG_SUPPORT;
/* read BA list */
- sprintf(filename, "/etc/osmocom/%s.ba", ms->name);
+ sprintf(filename, "%s/%s.ba", config_dir, ms->name);
fp = fopen(filename, "r");
if (fp) {
int rc;
@@ -3535,7 +3536,7 @@ int gsm322_exit(struct osmocom_ms *ms)
struct llist_head *lh, *lh2;
struct msgb *msg;
FILE *fp;
- char filename[128];
+ char filename[PATH_MAX];
struct gsm322_ba_list *ba;
uint8_t buf[4];
int i;
@@ -3561,7 +3562,7 @@ int gsm322_exit(struct osmocom_ms *ms)
}
/* store BA list */
- sprintf(filename, "/etc/osmocom/%s.ba", ms->name);
+ sprintf(filename, "%s/%s.ba", config_dir, ms->name);
fp = fopen(filename, "w");
if (fp) {
int rc;
@@ -3601,5 +3602,3 @@ int gsm322_exit(struct osmocom_ms *ms)
}
return 0;
}
-
-
diff --git a/src/host/layer23/src/mobile/main.c b/src/host/layer23/src/mobile/main.c
index 5c66510f..cd72d136 100644
--- a/src/host/layer23/src/mobile/main.c
+++ b/src/host/layer23/src/mobile/main.c
@@ -42,6 +42,7 @@
#include <fcntl.h>
#include <signal.h>
#include <time.h>
+#include <libgen.h>
struct log_target *stderr_target;
@@ -50,6 +51,7 @@ struct llist_head ms_list;
static uint32_t gsmtap_ip = 0;
unsigned short vty_port = 4247;
int debug_set = 0;
+char *config_dir = NULL;
int mobile_delete(struct osmocom_ms *ms, int force);
int mobile_signal_cb(unsigned int subsys, unsigned int signal,
@@ -183,8 +185,11 @@ int main(int argc, char **argv)
if (config_file != NULL)
snprintf(config_file, len, "%s/%s", home, osmocomcfg);
}
+ /* save the config file directory name */
+ config_dir = talloc_strdup(l23_ctx, config_file);
+ config_dir = dirname(config_dir);
+
rc = l23_app_init(NULL, config_file, vty_port);
- talloc_free(config_file);
if (rc)
exit(rc);