diff options
author | Pablo Neira Ayuso <pablo@gnumonks.org> | 2011-08-17 22:44:07 +0200 |
---|---|---|
committer | Harald Welte <laforge@gnumonks.org> | 2011-08-19 22:38:35 +0200 |
commit | ed5cacb240b846c106f0fc6a3ab8e8721f4c70a5 (patch) | |
tree | ba6bffbf0c95ecc0c50b5335bed77f3a2b29120f /openbsc/src/osmo-bsc_nat | |
parent | 7abecfcfc9ef94c1367cd88ac858b79d20f75db0 (diff) |
src: port openBSC over libosmo-abisopenbsc/0.9.15
This is a big patch that ports openBSC over libosmo-abis.
Sorry, the changes that are included here are all dependent
of libosmo-abis, splitting them into smaller pieces would
leave the repository in some intermediate state, which is
not desired.
The main changes are:
- The directory libabis/ has been removed as it now lives in
libosmo-abis.
- new configuration file format for nanoBTS and HSL femto, we
need to define the virtual e1_line and attach it to the OML
link.
- all the existing BTS drivers (nanoBTS, hsl femto, Nokia site,
BS11 and rbs2000) now use the new libosmo-abis framework.
- use r232 input driver available in libosmo-abis for bs11_config.
- use ipa_msg_recv instead of old ipaccess_read_msg function.
- delete definition of gsm_e1_subslot and input_signal_data.
These structures now lives in libosmo-abis.
Most of this patch are deletions of libabis/ which has been
moved to libosmo-abis.
This patch also modifies openBSC to use all the new definitions
available in libosmocore and libosmo-abis. In order to do that,
we have replaced the following:
- DINP, DMI, DMIB and DMUX by their respective DL* correspondences.
- SS_GLOBAL by SS_L_GLOBAL
- SS_INPUT by SS_L_INPUT
- S_GLOBAL_SHUTDOWN by S_L_GLOBAL_SHUTDOWN
- SS_INPUT by SS_L_INPUT
- S_INP_* by S_L_INP_* sub-signals
- E1INP_NODE by L_E1INP_NODE vty node
This patch has been tested with:
- one nanoBTS
- the HSL femto with the examples available under libosmo-abis
- BS11 with both dahdi and misdn drivers.
Diffstat (limited to 'openbsc/src/osmo-bsc_nat')
-rw-r--r-- | openbsc/src/osmo-bsc_nat/Makefile.am | 5 | ||||
-rw-r--r-- | openbsc/src/osmo-bsc_nat/bsc_filter.c | 2 | ||||
-rw-r--r-- | openbsc/src/osmo-bsc_nat/bsc_nat.c | 33 | ||||
-rw-r--r-- | openbsc/src/osmo-bsc_nat/bsc_nat_utils.c | 6 | ||||
-rw-r--r-- | openbsc/src/osmo-bsc_nat/bsc_ussd.c | 9 |
5 files changed, 31 insertions, 24 deletions
diff --git a/openbsc/src/osmo-bsc_nat/Makefile.am b/openbsc/src/osmo-bsc_nat/Makefile.am index eea720e28..2554000df 100644 --- a/openbsc/src/osmo-bsc_nat/Makefile.am +++ b/openbsc/src/osmo-bsc_nat/Makefile.am @@ -1,6 +1,6 @@ INCLUDES = $(all_includes) -I$(top_srcdir)/include -I$(top_builddir) -AM_CFLAGS=-Wall $(LIBOSMOCORE_CFLAGS) $(LIBOSMOGSM_CFLAGS) $(LIBOSMOVTY_CFLAGS) $(LIBOSMOSCCP_CFLAGS) $(COVERAGE_CFLAGS) -AM_LDFLAGS = $(LIBOSMOCORE_LIBS) $(LIBOSMOGSM_LIBS) $(LIBOSMOVTY_LIBS) $(COVERAGE_LDFLAGS) +AM_CFLAGS=-Wall $(LIBOSMOCORE_CFLAGS) $(LIBOSMOGSM_CFLAGS) $(LIBOSMOVTY_CFLAGS) $(LIBOSMOSCCP_CFLAGS) $(LIBOSMOABIS_CFLAGS) $(COVERAGE_CFLAGS) +AM_LDFLAGS = $(LIBOSMOCORE_LIBS) $(LIBOSMOGSM_LIBS) $(LIBOSMOVTY_LIBS) $(LIBOSMOABIS_LIBS) $(COVERAGE_LDFLAGS) bin_PROGRAMS = osmo-bsc_nat @@ -10,7 +10,6 @@ osmo_bsc_nat_SOURCES = bsc_filter.c bsc_mgcp_utils.c bsc_nat.c bsc_nat_utils.c \ osmo_bsc_nat_LDADD = $(top_builddir)/src/libcommon/libcommon.a \ $(top_builddir)/src/libmgcp/libmgcp.a \ $(top_builddir)/src/libbsc/libbsc.a \ - $(top_builddir)/src/libabis/libabis.a \ $(top_builddir)/src/libtrau/libtrau.a \ $(top_builddir)/src/libctrl/libctrl.a \ -lrt $(LIBOSMOSCCP_LIBS) diff --git a/openbsc/src/osmo-bsc_nat/bsc_filter.c b/openbsc/src/osmo-bsc_nat/bsc_filter.c index 74a5d193f..bbbba6994 100644 --- a/openbsc/src/osmo-bsc_nat/bsc_filter.c +++ b/openbsc/src/osmo-bsc_nat/bsc_filter.c @@ -98,7 +98,7 @@ struct bsc_nat_parsed *bsc_nat_parse(struct msgb *msg) /* do a size check on the input */ if (ntohs(hh->len) != msgb_l2len(msg)) { - LOGP(DINP, LOGL_ERROR, "Wrong input length?\n"); + LOGP(DLINP, LOGL_ERROR, "Wrong input length?\n"); talloc_free(parsed); return NULL; } diff --git a/openbsc/src/osmo-bsc_nat/bsc_nat.c b/openbsc/src/osmo-bsc_nat/bsc_nat.c index 445f45915..c42061b98 100644 --- a/openbsc/src/osmo-bsc_nat/bsc_nat.c +++ b/openbsc/src/osmo-bsc_nat/bsc_nat.c @@ -48,6 +48,7 @@ #include <osmocom/core/application.h> #include <osmocom/core/talloc.h> +#include <osmocom/gsm/tlv.h> #include <osmocom/gsm/gsm0808.h> #include <osmocom/gsm/protocol/gsm_08_08.h> @@ -57,6 +58,8 @@ #include <osmocom/sccp/sccp.h> +#include <osmocom/abis/ipa.h> + #include "../../bscconfig.h" #define SCCP_CLOSE_TIME 20 @@ -95,14 +98,14 @@ struct bsc_config *bsc_config_num(struct bsc_nat *nat, int num) static void queue_for_msc(struct bsc_msc_connection *con, struct msgb *msg) { if (!con) { - LOGP(DINP, LOGL_ERROR, "No MSC Connection assigned. Check your code.\n"); + LOGP(DLINP, LOGL_ERROR, "No MSC Connection assigned. Check your code.\n"); msgb_free(msg); return; } if (osmo_wqueue_enqueue(&con->write_queue, msg) != 0) { - LOGP(DINP, LOGL_ERROR, "Failed to enqueue the write.\n"); + LOGP(DLINP, LOGL_ERROR, "Failed to enqueue the write.\n"); msgb_free(msg); } } @@ -361,13 +364,13 @@ static void bsc_send_data(struct bsc_connection *bsc, const uint8_t *data, unsig struct msgb *msg; if (length > 4096 - 128) { - LOGP(DINP, LOGL_ERROR, "Can not send message of that size.\n"); + LOGP(DLINP, LOGL_ERROR, "Can not send message of that size.\n"); return; } msg = msgb_alloc_headroom(4096, 128, "to-bsc"); if (!msg) { - LOGP(DINP, LOGL_ERROR, "Failed to allocate memory for BSC msg.\n"); + LOGP(DLINP, LOGL_ERROR, "Failed to allocate memory for BSC msg.\n"); return; } @@ -783,18 +786,19 @@ static void msc_send_reset(struct bsc_msc_connection *msc_con) static int ipaccess_msc_read_cb(struct osmo_fd *bfd) { - int error; struct bsc_msc_connection *msc_con; - struct msgb *msg = ipaccess_read_msg(bfd, &error); + struct msgb *msg; struct ipaccess_head *hh; + int ret; msc_con = (struct bsc_msc_connection *) bfd->data; - if (!msg) { - if (error == 0) + ret = ipa_msg_recv(bfd->fd, &msg); + if (ret <= 0) { + if (ret == 0) LOGP(DNAT, LOGL_FATAL, "The connection the MSC was lost, exiting\n"); else - LOGP(DNAT, LOGL_ERROR, "Failed to parse ip access message: %d\n", error); + LOGP(DNAT, LOGL_ERROR, "Failed to parse ip access message: %d\n", ret); bsc_msc_lost(msc_con); return -1; @@ -1252,21 +1256,22 @@ err: static int ipaccess_bsc_read_cb(struct osmo_fd *bfd) { - int error; struct bsc_connection *bsc = bfd->data; - struct msgb *msg = ipaccess_read_msg(bfd, &error); + struct msgb *msg; struct ipaccess_head *hh; struct ipaccess_head_ext *hh_ext; + int ret; - if (!msg) { - if (error == 0) + ret = ipa_msg_recv(bfd->fd, &msg); + if (ret <= 0) { + if (ret == 0) LOGP(DNAT, LOGL_ERROR, "The connection to the BSC Nr: %d was lost. Cleaning it\n", bsc->cfg ? bsc->cfg->nr : -1); else LOGP(DNAT, LOGL_ERROR, "Stream error on BSC Nr: %d. Failed to parse ip access message: %d\n", - bsc->cfg ? bsc->cfg->nr : -1, error); + bsc->cfg ? bsc->cfg->nr : -1, ret); bsc_close_connection(bsc); return -1; diff --git a/openbsc/src/osmo-bsc_nat/bsc_nat_utils.c b/openbsc/src/osmo-bsc_nat/bsc_nat_utils.c index 8658c3d9b..84b23d1f7 100644 --- a/openbsc/src/osmo-bsc_nat/bsc_nat_utils.c +++ b/openbsc/src/osmo-bsc_nat/bsc_nat_utils.c @@ -318,13 +318,13 @@ int bsc_write_mgcp(struct bsc_connection *bsc, const uint8_t *data, unsigned int struct msgb *msg; if (length > 4096 - 128) { - LOGP(DINP, LOGL_ERROR, "Can not send message of that size.\n"); + LOGP(DLINP, LOGL_ERROR, "Can not send message of that size.\n"); return -1; } msg = msgb_alloc_headroom(4096, 128, "to-bsc"); if (!msg) { - LOGP(DINP, LOGL_ERROR, "Failed to allocate memory for BSC msg.\n"); + LOGP(DLINP, LOGL_ERROR, "Failed to allocate memory for BSC msg.\n"); return -1; } @@ -350,7 +350,7 @@ int bsc_do_write(struct osmo_wqueue *queue, struct msgb *msg, int proto) int bsc_write_msg(struct osmo_wqueue *queue, struct msgb *msg) { if (osmo_wqueue_enqueue(queue, msg) != 0) { - LOGP(DINP, LOGL_ERROR, "Failed to enqueue the write.\n"); + LOGP(DLINP, LOGL_ERROR, "Failed to enqueue the write.\n"); msgb_free(msg); return -1; } diff --git a/openbsc/src/osmo-bsc_nat/bsc_ussd.c b/openbsc/src/osmo-bsc_nat/bsc_ussd.c index bbbeead9a..80d6e779e 100644 --- a/openbsc/src/osmo-bsc_nat/bsc_ussd.c +++ b/openbsc/src/osmo-bsc_nat/bsc_ussd.c @@ -32,6 +32,8 @@ #include <osmocom/sccp/sccp.h> +#include <osmocom/abis/ipa.h> + #include <sys/socket.h> #include <string.h> #include <unistd.h> @@ -97,12 +99,13 @@ static int forward_sccp(struct bsc_nat *nat, struct msgb *msg) static int ussd_read_cb(struct osmo_fd *bfd) { - int error; struct bsc_nat_ussd_con *conn = bfd->data; - struct msgb *msg = ipaccess_read_msg(bfd, &error); + struct msgb *msg; struct ipaccess_head *hh; + int ret; - if (!msg) { + ret = ipa_msg_recv(bfd->fd, &msg); + if (ret <= 0) { LOGP(DNAT, LOGL_ERROR, "USSD Connection was lost.\n"); bsc_nat_ussd_destroy(conn); return -1; |