aboutsummaryrefslogtreecommitdiffstats
path: root/src/libabis
diff options
context:
space:
mode:
Diffstat (limited to 'src/libabis')
-rw-r--r--src/libabis/Makefile.am4
-rw-r--r--src/libabis/Makefile.in8
-rw-r--r--src/libabis/e1_input.c101
-rw-r--r--src/libabis/e1_input_vty.c12
-rw-r--r--src/libabis/input/dahdi.c49
-rw-r--r--src/libabis/input/hsl.c54
-rw-r--r--src/libabis/input/ipaccess.c209
-rw-r--r--src/libabis/input/lapd.c18
-rw-r--r--src/libabis/input/lapd.h2
-rw-r--r--src/libabis/input/misdn.c37
10 files changed, 271 insertions, 223 deletions
diff --git a/src/libabis/Makefile.am b/src/libabis/Makefile.am
index 0df7b5a4a..ffaa201ec 100644
--- a/src/libabis/Makefile.am
+++ b/src/libabis/Makefile.am
@@ -1,6 +1,6 @@
INCLUDES = $(all_includes) -I$(top_srcdir)/include -I$(top_builddir)
-AM_CFLAGS=-Wall $(LIBOSMOCORE_CFLAGS) $(LIBOSMOVTY_CFLAGS) $(COVERAGE_CFLAGS)
-AM_LDFLAGS = $(LIBOSMOCORE_LIBS) $(COVERAGE_LDFLAGS)
+AM_CFLAGS=-Wall $(LIBOSMOCORE_CFLAGS) $(LIBOSMOGSM_CFLAGS) $(LIBOSMOVTY_CFLAGS) $(COVERAGE_CFLAGS)
+AM_LDFLAGS = $(LIBOSMOCORE_LIBS) $(LIBOSMOGSM_LIBS) $(COVERAGE_LDFLAGS)
noinst_LIBRARIES = libabis.a
diff --git a/src/libabis/Makefile.in b/src/libabis/Makefile.in
index 90d628791..a47ca70cc 100644
--- a/src/libabis/Makefile.in
+++ b/src/libabis/Makefile.in
@@ -35,7 +35,7 @@ POST_UNINSTALL = :
subdir = src/libabis
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
-am__aclocal_m4_deps = $(top_srcdir)/configure.in
+am__aclocal_m4_deps = $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(install_sh) -d
@@ -115,6 +115,8 @@ LDFLAGS = @LDFLAGS@
LIBOBJS = @LIBOBJS@
LIBOSMOCORE_CFLAGS = @LIBOSMOCORE_CFLAGS@
LIBOSMOCORE_LIBS = @LIBOSMOCORE_LIBS@
+LIBOSMOGSM_CFLAGS = @LIBOSMOGSM_CFLAGS@
+LIBOSMOGSM_LIBS = @LIBOSMOGSM_LIBS@
LIBOSMOSCCP_CFLAGS = @LIBOSMOSCCP_CFLAGS@
LIBOSMOSCCP_LIBS = @LIBOSMOSCCP_LIBS@
LIBOSMOVTY_CFLAGS = @LIBOSMOVTY_CFLAGS@
@@ -184,8 +186,8 @@ top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
INCLUDES = $(all_includes) -I$(top_srcdir)/include -I$(top_builddir)
-AM_CFLAGS = -Wall $(LIBOSMOCORE_CFLAGS) $(LIBOSMOVTY_CFLAGS) $(COVERAGE_CFLAGS)
-AM_LDFLAGS = $(LIBOSMOCORE_LIBS) $(COVERAGE_LDFLAGS)
+AM_CFLAGS = -Wall $(LIBOSMOCORE_CFLAGS) $(LIBOSMOGSM_CFLAGS) $(LIBOSMOVTY_CFLAGS) $(COVERAGE_CFLAGS)
+AM_LDFLAGS = $(LIBOSMOCORE_LIBS) $(LIBOSMOGSM_LIBS) $(COVERAGE_LDFLAGS)
noinst_LIBRARIES = libabis.a
libabis_a_SOURCES = e1_input.c e1_input_vty.c \
input/misdn.c \
diff --git a/src/libabis/e1_input.c b/src/libabis/e1_input.c
index 3b6644eff..97dcd3364 100644
--- a/src/libabis/e1_input.c
+++ b/src/libabis/e1_input.c
@@ -26,7 +26,6 @@
#include <string.h>
#include <time.h>
#include <sys/fcntl.h>
-#include <sys/types.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <arpa/inet.h>
@@ -39,18 +38,18 @@
#define PF_ISDN AF_ISDN
#endif
-#include <osmocore/select.h>
-#include <osmocore/msgb.h>
+#include <osmocom/core/select.h>
+#include <osmocom/core/msgb.h>
#include <openbsc/debug.h>
#include <openbsc/gsm_data.h>
#include <openbsc/e1_input.h>
#include <openbsc/abis_nm.h>
#include <openbsc/abis_rsl.h>
-#include <osmocore/linuxlist.h>
+#include <osmocom/core/linuxlist.h>
#include <openbsc/subchan_demux.h>
#include <openbsc/trau_frame.h>
#include <openbsc/trau_mux.h>
-#include <osmocore/talloc.h>
+#include <osmocom/core/talloc.h>
#include <openbsc/signal.h>
#include <openbsc/misdn.h>
@@ -75,44 +74,44 @@ static void *tall_sigl_ctx;
#define PCAP_OUTPUT 1
struct pcap_hdr {
- u_int32_t magic_number;
- u_int16_t version_major;
- u_int16_t version_minor;
+ uint32_t magic_number;
+ uint16_t version_major;
+ uint16_t version_minor;
int32_t thiszone;
- u_int32_t sigfigs;
- u_int32_t snaplen;
- u_int32_t network;
+ uint32_t sigfigs;
+ uint32_t snaplen;
+ uint32_t network;
} __attribute__((packed));
struct pcaprec_hdr {
- u_int32_t ts_sec;
- u_int32_t ts_usec;
- u_int32_t incl_len;
- u_int32_t orig_len;
+ uint32_t ts_sec;
+ uint32_t ts_usec;
+ uint32_t incl_len;
+ uint32_t orig_len;
} __attribute__((packed));
struct fake_linux_lapd_header {
- u_int16_t pkttype;
- u_int16_t hatype;
- u_int16_t halen;
- u_int64_t addr;
+ uint16_t pkttype;
+ uint16_t hatype;
+ uint16_t halen;
+ uint64_t addr;
int16_t protocol;
} __attribute__((packed));
struct lapd_header {
- u_int8_t ea1 : 1;
- u_int8_t cr : 1;
- u_int8_t sapi : 6;
- u_int8_t ea2 : 1;
- u_int8_t tei : 7;
- u_int8_t control_foo; /* fake UM's ... */
+ uint8_t ea1 : 1;
+ uint8_t cr : 1;
+ uint8_t sapi : 6;
+ uint8_t ea2 : 1;
+ uint8_t tei : 7;
+ uint8_t control_foo; /* fake UM's ... */
} __attribute__((packed));
-static_assert(offsetof(struct fake_linux_lapd_header, hatype) == 2, hatype_offset);
-static_assert(offsetof(struct fake_linux_lapd_header, halen) == 4, halen_offset);
-static_assert(offsetof(struct fake_linux_lapd_header, addr) == 6, addr_offset);
-static_assert(offsetof(struct fake_linux_lapd_header, protocol) == 14, proto_offset);
-static_assert(sizeof(struct fake_linux_lapd_header) == 16, lapd_header_size);
+osmo_static_assert(offsetof(struct fake_linux_lapd_header, hatype) == 2, hatype_offset);
+osmo_static_assert(offsetof(struct fake_linux_lapd_header, halen) == 4, halen_offset);
+osmo_static_assert(offsetof(struct fake_linux_lapd_header, addr) == 6, addr_offset);
+osmo_static_assert(offsetof(struct fake_linux_lapd_header, protocol) == 14, proto_offset);
+osmo_static_assert(sizeof(struct fake_linux_lapd_header) == 16, lapd_header_size);
static int pcap_fd = -1;
@@ -207,7 +206,7 @@ const char *e1inp_tstype_name(enum e1inp_ts_type tp)
}
/* callback when a TRAU frame was received */
-static int subch_cb(struct subch_demux *dmx, int ch, u_int8_t *data, int len,
+static int subch_cb(struct subch_demux *dmx, int ch, uint8_t *data, int len,
void *_priv)
{
struct e1inp_ts *e1i_ts = _priv;
@@ -230,19 +229,19 @@ int abis_rsl_sendmsg(struct msgb *msg)
if (!msg->trx) {
LOGP(DRSL, LOGL_ERROR, "rsl_sendmsg: msg->trx == NULL: %s\n",
- hexdump(msg->data, msg->len));
+ osmo_hexdump(msg->data, msg->len));
talloc_free(msg);
return -EINVAL;
} else if (!msg->trx->rsl_link) {
LOGP(DRSL, LOGL_ERROR, "rsl_sendmsg: msg->trx->rsl_link == NULL: %s\n",
- hexdump(msg->data, msg->len));
+ osmo_hexdump(msg->data, msg->len));
talloc_free(msg);
return -EIO;
}
sign_link = msg->trx->rsl_link;
e1i_ts = sign_link->ts;
- if (!bsc_timer_pending(&e1i_ts->sign.tx_timer)) {
+ if (!osmo_timer_pending(&e1i_ts->sign.tx_timer)) {
/* notify the driver we have something to write */
e1inp_driver = sign_link->ts->line->driver;
e1inp_driver->want_write(e1i_ts);
@@ -277,7 +276,7 @@ int _abis_nm_sendmsg(struct msgb *msg, int to_trx_oml)
sign_link = msg->trx->bts->oml_link;
e1i_ts = sign_link->ts;
- if (!bsc_timer_pending(&e1i_ts->sign.tx_timer)) {
+ if (!osmo_timer_pending(&e1i_ts->sign.tx_timer)) {
/* notify the driver we have something to write */
e1inp_driver = sign_link->ts->line->driver;
e1inp_driver->want_write(e1i_ts);
@@ -324,7 +323,7 @@ int e1inp_ts_config(struct e1inp_ts *ts, struct e1inp_line *line,
return 0;
}
-struct e1inp_line *e1inp_line_get(u_int8_t e1_nr)
+struct e1inp_line *e1inp_line_get(uint8_t e1_nr)
{
struct e1inp_line *e1i_line;
@@ -336,7 +335,7 @@ struct e1inp_line *e1inp_line_get(u_int8_t e1_nr)
return NULL;
}
-struct e1inp_line *e1inp_line_create(u_int8_t e1_nr, const char *driver_name)
+struct e1inp_line *e1inp_line_create(uint8_t e1_nr, const char *driver_name)
{
struct e1inp_driver *driver;
struct e1inp_line *line;
@@ -373,7 +372,7 @@ struct e1inp_line *e1inp_line_create(u_int8_t e1_nr, const char *driver_name)
}
#if 0
-struct e1inp_line *e1inp_line_get_create(u_int8_t e1_nr)
+struct e1inp_line *e1inp_line_get_create(uint8_t e1_nr)
{
struct e1inp_line *line;
int i;
@@ -397,7 +396,7 @@ struct e1inp_line *e1inp_line_get_create(u_int8_t e1_nr)
}
#endif
-static struct e1inp_ts *e1inp_ts_get(u_int8_t e1_nr, u_int8_t ts_nr)
+static struct e1inp_ts *e1inp_ts_get(uint8_t e1_nr, uint8_t ts_nr)
{
struct e1inp_line *e1i_line;
@@ -408,7 +407,7 @@ static struct e1inp_ts *e1inp_ts_get(u_int8_t e1_nr, u_int8_t ts_nr)
return &e1i_line->ts[ts_nr-1];
}
-struct subch_mux *e1inp_get_mux(u_int8_t e1_nr, u_int8_t ts_nr)
+struct subch_mux *e1inp_get_mux(uint8_t e1_nr, uint8_t ts_nr)
{
struct e1inp_ts *e1i_ts = e1inp_ts_get(e1_nr, ts_nr);
@@ -421,7 +420,7 @@ struct subch_mux *e1inp_get_mux(u_int8_t e1_nr, u_int8_t ts_nr)
/* Signalling Link */
struct e1inp_sign_link *e1inp_lookup_sign_link(struct e1inp_ts *e1i,
- u_int8_t tei, u_int8_t sapi)
+ uint8_t tei, uint8_t sapi)
{
struct e1inp_sign_link *link;
@@ -437,8 +436,8 @@ struct e1inp_sign_link *e1inp_lookup_sign_link(struct e1inp_ts *e1i,
struct e1inp_sign_link *
e1inp_sign_link_create(struct e1inp_ts *ts, enum e1inp_sign_type type,
- struct gsm_bts_trx *trx, u_int8_t tei,
- u_int8_t sapi)
+ struct gsm_bts_trx *trx, uint8_t tei,
+ uint8_t sapi)
{
struct e1inp_sign_link *link;
@@ -472,14 +471,14 @@ void e1inp_sign_link_destroy(struct e1inp_sign_link *link)
}
if (link->ts->type == E1INP_TS_TYPE_SIGN)
- bsc_del_timer(&link->ts->sign.tx_timer);
+ osmo_timer_del(&link->ts->sign.tx_timer);
talloc_free(link);
}
/* the E1 driver tells us he has received something on a TS */
int e1inp_rx_ts(struct e1inp_ts *ts, struct msgb *msg,
- u_int8_t tei, u_int8_t sapi)
+ uint8_t tei, uint8_t sapi)
{
struct e1inp_sign_link *link;
struct gsm_bts *bts;
@@ -562,7 +561,7 @@ struct msgb *e1inp_tx_ts(struct e1inp_ts *e1i_ts,
}
/* called by driver in case some kind of link state event */
-int e1inp_event(struct e1inp_ts *ts, int evt, u_int8_t tei, u_int8_t sapi)
+int e1inp_event(struct e1inp_ts *ts, int evt, uint8_t tei, uint8_t sapi)
{
struct e1inp_sign_link *link;
struct input_signal_data isd;
@@ -577,7 +576,7 @@ int e1inp_event(struct e1inp_ts *ts, int evt, u_int8_t tei, u_int8_t sapi)
isd.sapi = sapi;
/* report further upwards */
- dispatch_signal(SS_INPUT, evt, &isd);
+ osmo_signal_dispatch(SS_INPUT, evt, &isd);
return 0;
}
@@ -613,7 +612,7 @@ int e1inp_line_update(struct e1inp_line *line)
* configured */
memset(&isd, 0, sizeof(isd));
isd.line = line;
- dispatch_signal(SS_INPUT, S_INP_LINE_INIT, &isd);
+ osmo_signal_dispatch(SS_INPUT, S_INP_LINE_INIT, &isd);
return rc;
}
@@ -635,15 +634,19 @@ static int e1i_sig_cb(unsigned int subsys, unsigned int signal,
void e1inp_misdn_init(void);
void e1inp_dahdi_init(void);
+void e1inp_ipaccess_init(void);
+void e1inp_hsl_init(void);
void e1inp_init(void)
{
tall_sigl_ctx = talloc_named_const(tall_bsc_ctx, 1,
"e1inp_sign_link");
- register_signal_handler(SS_GLOBAL, e1i_sig_cb, NULL);
+ osmo_signal_register_handler(SS_GLOBAL, e1i_sig_cb, NULL);
e1inp_misdn_init();
#ifdef HAVE_DAHDI_USER_H
e1inp_dahdi_init();
#endif
+ e1inp_ipaccess_init();
+ e1inp_hsl_init();
}
diff --git a/src/libabis/e1_input_vty.c b/src/libabis/e1_input_vty.c
index 66bf6555e..b211e818f 100644
--- a/src/libabis/e1_input_vty.c
+++ b/src/libabis/e1_input_vty.c
@@ -19,7 +19,6 @@
#include <stdlib.h>
#include <unistd.h>
-#include <sys/types.h>
#include <osmocom/vty/command.h>
#include <osmocom/vty/buffer.h>
@@ -27,12 +26,12 @@
#include <osmocom/vty/logging.h>
#include <osmocom/vty/telnet_interface.h>
-#include <osmocore/linuxlist.h>
+#include <osmocom/core/linuxlist.h>
#include <openbsc/gsm_data.h>
#include <openbsc/e1_input.h>
-#include <osmocore/utils.h>
-#include <osmocore/gsm_utils.h>
-#include <osmocore/talloc.h>
+#include <osmocom/core/utils.h>
+#include <osmocom/gsm/gsm_utils.h>
+#include <osmocom/core/talloc.h>
#include <openbsc/vty.h>
#include <openbsc/debug.h>
@@ -77,6 +76,9 @@ static int e1inp_config_write(struct vty *vty)
{
struct e1inp_line *line;
+ if (llist_empty(&e1inp_line_list))
+ return CMD_SUCCESS;
+
vty_out(vty, "e1_input%s", VTY_NEWLINE);
llist_for_each_entry(line, &e1inp_line_list, list) {
diff --git a/src/libabis/input/dahdi.c b/src/libabis/input/dahdi.c
index 572bb5ae9..6f8983763 100644
--- a/src/libabis/input/dahdi.c
+++ b/src/libabis/input/dahdi.c
@@ -33,14 +33,13 @@
#include <string.h>
#include <time.h>
#include <sys/fcntl.h>
-#include <sys/types.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <arpa/inet.h>
#include <dahdi/user.h>
-#include <osmocore/select.h>
-#include <osmocore/msgb.h>
+#include <osmocom/core/select.h>
+#include <osmocom/core/msgb.h>
#include <openbsc/debug.h>
#include <openbsc/gsm_data.h>
#include <openbsc/abis_nm.h>
@@ -48,7 +47,7 @@
#include <openbsc/subchan_demux.h>
#include <openbsc/e1_input.h>
#include <openbsc/signal.h>
-#include <osmocore/talloc.h>
+#include <osmocom/core/talloc.h>
#include "lapd.h"
@@ -84,16 +83,16 @@ static void handle_dahdi_exception(struct e1inp_ts *ts)
switch (evt) {
case DAHDI_EVENT_ALARM:
/* we should notify the code that the line is gone */
- dispatch_signal(SS_INPUT, S_INP_LINE_ALARM, &isd);
+ osmo_signal_dispatch(SS_INPUT, S_INP_LINE_ALARM, &isd);
break;
case DAHDI_EVENT_NOALARM:
/* alarm has gone, we should re-start the SABM requests */
- dispatch_signal(SS_INPUT, S_INP_LINE_NOALARM, &isd);
+ osmo_signal_dispatch(SS_INPUT, S_INP_LINE_NOALARM, &isd);
break;
}
}
-static int handle_ts1_read(struct bsc_fd *bfd)
+static int handle_ts1_read(struct osmo_fd *bfd)
{
struct e1inp_line *line = bfd->data;
unsigned int ts_nr = bfd->priv_nr;
@@ -148,7 +147,7 @@ static int handle_ts1_read(struct bsc_fd *bfd)
msg->l2h = msg->data + 2;
else
msg->l2h = msg->data + 1;
- DEBUGP(DMI, "RX: %s\n", hexdump(msgb_l2(msg), ret));
+ DEBUGP(DMI, "RX: %s\n", osmo_hexdump(msgb_l2(msg), ret));
ret = e1inp_rx_ts(e1i_ts, msg, tei, sapi);
break;
default:
@@ -185,7 +184,7 @@ static void timeout_ts1_write(void *data)
static void dahdi_write_msg(uint8_t *data, int len, void *cbdata)
{
- struct bsc_fd *bfd = cbdata;
+ struct osmo_fd *bfd = cbdata;
struct e1inp_line *line = bfd->data;
unsigned int ts_nr = bfd->priv_nr;
struct e1inp_ts *e1i_ts = &line->ts[ts_nr-1];
@@ -198,7 +197,7 @@ static void dahdi_write_msg(uint8_t *data, int len, void *cbdata)
LOGP(DMI, LOGL_NOTICE, "%s write failed %d\n", __func__, ret);
}
-static int handle_ts1_write(struct bsc_fd *bfd)
+static int handle_ts1_write(struct osmo_fd *bfd)
{
struct e1inp_line *line = bfd->data;
unsigned int ts_nr = bfd->priv_nr;
@@ -215,7 +214,7 @@ static int handle_ts1_write(struct bsc_fd *bfd)
return 0;
}
- DEBUGP(DMI, "TX: %s\n", hexdump(msg->data, msg->len));
+ DEBUGP(DMI, "TX: %s\n", osmo_hexdump(msg->data, msg->len));
lapd_transmit(e1i_ts->driver.dahdi.lapd, sign_link->tei,
sign_link->sapi, msg->data, msg->len);
msgb_free(msg);
@@ -223,7 +222,7 @@ static int handle_ts1_write(struct bsc_fd *bfd)
/* set tx delay timer for next event */
e1i_ts->sign.tx_timer.cb = timeout_ts1_write;
e1i_ts->sign.tx_timer.data = e1i_ts;
- bsc_schedule_timer(&e1i_ts->sign.tx_timer, 0, 50000);
+ osmo_timer_schedule(&e1i_ts->sign.tx_timer, 0, 50000);
return 0;
}
@@ -231,14 +230,14 @@ static int handle_ts1_write(struct bsc_fd *bfd)
static int invertbits = 1;
-static u_int8_t flip_table[256];
+static uint8_t flip_table[256];
static void init_flip_bits(void)
{
int i,k;
for (i = 0 ; i < 256 ; i++) {
- u_int8_t sample = 0 ;
+ uint8_t sample = 0 ;
for (k = 0; k<8; k++) {
if ( i & 1 << k ) sample |= 0x80 >> k;
}
@@ -246,13 +245,13 @@ static void init_flip_bits(void)
}
}
-static u_int8_t * flip_buf_bits ( u_int8_t * buf , int len)
+static uint8_t * flip_buf_bits ( uint8_t * buf , int len)
{
int i;
- u_int8_t * start = buf;
+ uint8_t * start = buf;
for (i = 0 ; i < len; i++) {
- buf[i] = flip_table[(u_int8_t)buf[i]];
+ buf[i] = flip_table[(uint8_t)buf[i]];
}
return start;
@@ -260,12 +259,12 @@ static u_int8_t * flip_buf_bits ( u_int8_t * buf , int len)
#define D_BCHAN_TX_GRAN 160
/* write to a B channel TS */
-static int handle_tsX_write(struct bsc_fd *bfd)
+static int handle_tsX_write(struct osmo_fd *bfd)
{
struct e1inp_line *line = bfd->data;
unsigned int ts_nr = bfd->priv_nr;
struct e1inp_ts *e1i_ts = &line->ts[ts_nr-1];
- u_int8_t tx_buf[D_BCHAN_TX_GRAN];
+ uint8_t tx_buf[D_BCHAN_TX_GRAN];
struct subch_mux *mx = &e1i_ts->trau.mux;
int ret;
@@ -278,7 +277,7 @@ static int handle_tsX_write(struct bsc_fd *bfd)
}
DEBUGP(DMIB, "BCHAN TX: %s\n",
- hexdump(tx_buf, D_BCHAN_TX_GRAN));
+ osmo_hexdump(tx_buf, D_BCHAN_TX_GRAN));
if (invertbits) {
flip_buf_bits(tx_buf, ret);
@@ -294,7 +293,7 @@ static int handle_tsX_write(struct bsc_fd *bfd)
#define D_TSX_ALLOC_SIZE (D_BCHAN_TX_GRAN)
/* FIXME: read from a B channel TS */
-static int handle_tsX_read(struct bsc_fd *bfd)
+static int handle_tsX_read(struct osmo_fd *bfd)
{
struct e1inp_line *line = bfd->data;
unsigned int ts_nr = bfd->priv_nr;
@@ -319,7 +318,7 @@ static int handle_tsX_read(struct bsc_fd *bfd)
msg->l2h = msg->data;
DEBUGP(DMIB, "BCHAN RX: %s\n",
- hexdump(msgb_l2(msg), ret));
+ osmo_hexdump(msgb_l2(msg), ret));
ret = e1inp_rx_ts(e1i_ts, msg, 0, 0);
/* physical layer indicates that data has been sent,
* we thus can send some more data */
@@ -330,7 +329,7 @@ static int handle_tsX_read(struct bsc_fd *bfd)
}
/* callback from select.c in case one of the fd's can be read/written */
-static int dahdi_fd_cb(struct bsc_fd *bfd, unsigned int what)
+static int dahdi_fd_cb(struct osmo_fd *bfd, unsigned int what)
{
struct e1inp_line *line = bfd->data;
unsigned int ts_nr = bfd->priv_nr;
@@ -421,7 +420,7 @@ static int dahdi_e1_setup(struct e1inp_line *line)
unsigned int idx = ts-1;
char openstr[128];
struct e1inp_ts *e1i_ts = &line->ts[idx];
- struct bsc_fd *bfd = &e1i_ts->driver.dahdi.fd;
+ struct osmo_fd *bfd = &e1i_ts->driver.dahdi.fd;
bfd->data = line;
bfd->priv_nr = ts;
@@ -464,7 +463,7 @@ static int dahdi_e1_setup(struct e1inp_line *line)
return bfd->fd;
}
- ret = bsc_register_fd(bfd);
+ ret = osmo_fd_register(bfd);
if (ret < 0) {
fprintf(stderr, "could not register FD: %s\n",
strerror(ret));
diff --git a/src/libabis/input/hsl.c b/src/libabis/input/hsl.c
index 1afe82b49..c98a22cb4 100644
--- a/src/libabis/input/hsl.c
+++ b/src/libabis/input/hsl.c
@@ -38,14 +38,13 @@
#include <string.h>
#include <time.h>
#include <sys/fcntl.h>
-#include <sys/types.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <arpa/inet.h>
-#include <osmocore/select.h>
-#include <osmocore/tlv.h>
-#include <osmocore/msgb.h>
+#include <osmocom/core/select.h>
+#include <osmocom/gsm/tlv.h>
+#include <osmocom/core/msgb.h>
#include <openbsc/debug.h>
#include <openbsc/gsm_data.h>
#include <openbsc/abis_nm.h>
@@ -55,7 +54,7 @@
#include <openbsc/ipaccess.h>
#include <openbsc/socket.h>
#include <openbsc/signal.h>
-#include <osmocore/talloc.h>
+#include <osmocom/core/talloc.h>
#define HSL_TCP_PORT 2500
#define HSL_PROTO_DEBUG 0xdd
@@ -65,7 +64,7 @@
/* data structure for one E1 interface with A-bis */
struct hsl_e1_handle {
- struct bsc_fd listen_fd;
+ struct osmo_fd listen_fd;
struct gsm_network *gsmnet;
};
@@ -82,7 +81,7 @@ int hsl_drop_oml(struct gsm_bts *bts)
struct gsm_bts_trx *trx;
struct e1inp_ts *ts;
struct e1inp_line *line;
- struct bsc_fd *bfd;
+ struct osmo_fd *bfd;
if (!bts || !bts->oml_link)
return -1;
@@ -93,7 +92,7 @@ int hsl_drop_oml(struct gsm_bts *bts)
e1inp_event(ts, S_INP_TEI_DN, bts->oml_link->tei, bts->oml_link->sapi);
bfd = &ts->driver.ipaccess.fd;
- bsc_unregister_fd(bfd);
+ osmo_fd_unregister(bfd);
close(bfd->fd);
bfd->fd = -1;
@@ -110,7 +109,7 @@ int hsl_drop_oml(struct gsm_bts *bts)
return -1;
}
-static int hsl_drop_ts_fd(struct e1inp_ts *ts, struct bsc_fd *bfd)
+static int hsl_drop_ts_fd(struct e1inp_ts *ts, struct osmo_fd *bfd)
{
struct e1inp_sign_link *link, *link2;
int bts_nr = -1;
@@ -120,7 +119,7 @@ static int hsl_drop_ts_fd(struct e1inp_ts *ts, struct bsc_fd *bfd)
e1inp_sign_link_destroy(link);
}
- bsc_unregister_fd(bfd);
+ osmo_fd_unregister(bfd);
close(bfd->fd);
bfd->fd = -1;
@@ -196,7 +195,7 @@ static int process_hsl_rsl(struct msgb *msg, struct e1inp_line *line)
return 0;
}
-static int handle_ts1_read(struct bsc_fd *bfd)
+static int handle_ts1_read(struct osmo_fd *bfd)
{
struct e1inp_line *line = bfd->data;
unsigned int ts_nr = bfd->priv_nr;
@@ -219,7 +218,7 @@ static int handle_ts1_read(struct bsc_fd *bfd)
return error;
}
- DEBUGP(DMI, "RX %u: %s\n", ts_nr, hexdump(msgb_l2(msg), msgb_l2len(msg)));
+ DEBUGP(DMI, "RX %u: %s\n", ts_nr, osmo_hexdump(msgb_l2(msg), msgb_l2len(msg)));
hh = (struct ipaccess_head *) msg->data;
if (hh->proto == HSL_PROTO_DEBUG) {
@@ -291,14 +290,14 @@ static void timeout_ts1_write(void *data)
ts_want_write(e1i_ts);
}
-static int handle_ts1_write(struct bsc_fd *bfd)
+static int handle_ts1_write(struct osmo_fd *bfd)
{
struct e1inp_line *line = bfd->data;
unsigned int ts_nr = bfd->priv_nr;
struct e1inp_ts *e1i_ts = &line->ts[ts_nr-1];
struct e1inp_sign_link *sign_link;
struct msgb *msg;
- u_int8_t proto;
+ uint8_t proto;
int ret;
bfd->when &= ~BSC_FD_WRITE;
@@ -331,7 +330,7 @@ static int handle_ts1_write(struct bsc_fd *bfd)
msg->l2h = msg->data;
ipaccess_prepend_header(msg, sign_link->tei);
- DEBUGP(DMI, "TX %u: %s\n", ts_nr, hexdump(msg->l2h, msgb_l2len(msg)));
+ DEBUGP(DMI, "TX %u: %s\n", ts_nr, osmo_hexdump(msg->l2h, msgb_l2len(msg)));
ret = send(bfd->fd, msg->data, msg->len, 0);
msgb_free(msg);
@@ -341,13 +340,13 @@ static int handle_ts1_write(struct bsc_fd *bfd)
e1i_ts->sign.tx_timer.data = e1i_ts;
/* Reducing this might break the nanoBTS 900 init. */
- bsc_schedule_timer(&e1i_ts->sign.tx_timer, 0, e1i_ts->sign.delay);
+ osmo_timer_schedule(&e1i_ts->sign.tx_timer, 0, e1i_ts->sign.delay);
return ret;
}
/* callback from select.c in case one of the fd's can be read/written */
-static int hsl_fd_cb(struct bsc_fd *bfd, unsigned int what)
+static int hsl_fd_cb(struct osmo_fd *bfd, unsigned int what)
{
struct e1inp_line *line = bfd->data;
unsigned int ts_nr = bfd->priv_nr;
@@ -378,14 +377,14 @@ struct e1inp_driver hsl_driver = {
};
/* callback of the OML listening filedescriptor */
-static int listen_fd_cb(struct bsc_fd *listen_bfd, unsigned int what)
+static int listen_fd_cb(struct osmo_fd *listen_bfd, unsigned int what)
{
int ret;
int idx = 0;
int i;
struct e1inp_line *line;
struct e1inp_ts *e1i_ts;
- struct bsc_fd *bfd;
+ struct osmo_fd *bfd;
struct sockaddr_in sa;
socklen_t sa_len = sizeof(sa);
@@ -422,7 +421,7 @@ static int listen_fd_cb(struct bsc_fd *listen_bfd, unsigned int what)
bfd->priv_nr = PRIV_OML;
bfd->cb = hsl_fd_cb;
bfd->when = BSC_FD_READ;
- ret = bsc_register_fd(bfd);
+ ret = osmo_fd_register(bfd);
if (ret < 0) {
LOGP(DINP, LOGL_ERROR, "could not register FD\n");
close(bfd->fd);
@@ -438,12 +437,6 @@ int hsl_setup(struct gsm_network *gsmnet)
{
int ret;
- /* register the driver with the core */
- /* FIXME: do this in the plugin initializer function */
- ret = e1inp_driver_register(&hsl_driver);
- if (ret)
- return ret;
-
e1h = talloc_zero(tall_bsc_ctx, struct hsl_e1_handle);
if (!e1h)
return -ENOMEM;
@@ -451,10 +444,15 @@ int hsl_setup(struct gsm_network *gsmnet)
e1h->gsmnet = gsmnet;
/* Listen for connections */
- ret = make_sock(&e1h->listen_fd, IPPROTO_TCP, 0, HSL_TCP_PORT,
- listen_fd_cb);
+ ret = make_sock(&e1h->listen_fd, IPPROTO_TCP, INADDR_ANY, HSL_TCP_PORT,
+ 0, listen_fd_cb, NULL);
if (ret < 0)
return ret;
return 0;
}
+
+void e1inp_hsl_init(void)
+{
+ e1inp_driver_register(&hsl_driver);
+}
diff --git a/src/libabis/input/ipaccess.c b/src/libabis/input/ipaccess.c
index dcf8d1a53..cc2a7a055 100644
--- a/src/libabis/input/ipaccess.c
+++ b/src/libabis/input/ipaccess.c
@@ -28,15 +28,14 @@
#include <string.h>
#include <time.h>
#include <sys/fcntl.h>
-#include <sys/types.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <arpa/inet.h>
-#include <osmocore/select.h>
-#include <osmocore/tlv.h>
-#include <osmocore/msgb.h>
-#include <osmocore/talloc.h>
+#include <osmocom/core/select.h>
+#include <osmocom/gsm/tlv.h>
+#include <osmocom/core/msgb.h>
+#include <osmocom/core/talloc.h>
#include <openbsc/debug.h>
#include <openbsc/gsm_data.h>
#include <openbsc/abis_nm.h>
@@ -52,8 +51,8 @@
/* data structure for one E1 interface with A-bis */
struct ia_e1_handle {
- struct bsc_fd listen_fd;
- struct bsc_fd rsl_listen_fd;
+ struct osmo_fd listen_fd;
+ struct osmo_fd rsl_listen_fd;
struct gsm_network *gsmnet;
};
@@ -62,18 +61,31 @@ static struct ia_e1_handle *e1h;
#define TS1_ALLOC_SIZE 900
-static const u_int8_t pong[] = { 0, 1, IPAC_PROTO_IPACCESS, IPAC_MSGT_PONG };
-static const u_int8_t id_ack[] = { 0, 1, IPAC_PROTO_IPACCESS, IPAC_MSGT_ID_ACK };
-static const u_int8_t id_req[] = { 0, 17, IPAC_PROTO_IPACCESS, IPAC_MSGT_ID_GET,
- 0x01, IPAC_IDTAG_UNIT,
- 0x01, IPAC_IDTAG_MACADDR,
- 0x01, IPAC_IDTAG_LOCATION1,
- 0x01, IPAC_IDTAG_LOCATION2,
- 0x01, IPAC_IDTAG_EQUIPVERS,
- 0x01, IPAC_IDTAG_SWVERSION,
- 0x01, IPAC_IDTAG_UNITNAME,
- 0x01, IPAC_IDTAG_SERNR,
- };
+/*
+ * Common propietary IPA messages:
+ * - PONG: in reply to PING.
+ * - ID_REQUEST: first messages once OML has been established.
+ * - ID_ACK: in reply to ID_ACK.
+ */
+const uint8_t ipa_pong_msg[] = {
+ 0, 1, IPAC_PROTO_IPACCESS, IPAC_MSGT_PONG
+};
+
+const uint8_t ipa_id_ack_msg[] = {
+ 0, 1, IPAC_PROTO_IPACCESS, IPAC_MSGT_ID_ACK
+};
+
+const uint8_t ipa_id_req_msg[] = {
+ 0, 17, IPAC_PROTO_IPACCESS, IPAC_MSGT_ID_GET,
+ 0x01, IPAC_IDTAG_UNIT,
+ 0x01, IPAC_IDTAG_MACADDR,
+ 0x01, IPAC_IDTAG_LOCATION1,
+ 0x01, IPAC_IDTAG_LOCATION2,
+ 0x01, IPAC_IDTAG_EQUIPVERS,
+ 0x01, IPAC_IDTAG_SWVERSION,
+ 0x01, IPAC_IDTAG_UNITNAME,
+ 0x01, IPAC_IDTAG_SERNR,
+};
static const char *idtag_names[] = {
[IPAC_IDTAG_SERNR] = "Serial_Number",
@@ -87,7 +99,7 @@ static const char *idtag_names[] = {
[IPAC_IDTAG_UNIT] = "Unit_ID",
};
-static const char *ipac_idtag_name(int tag)
+const char *ipaccess_idtag_name(uint8_t tag)
{
if (tag >= ARRAY_SIZE(idtag_names))
return "unknown";
@@ -97,9 +109,9 @@ static const char *ipac_idtag_name(int tag)
int ipaccess_idtag_parse(struct tlv_parsed *dec, unsigned char *buf, int len)
{
- u_int8_t t_len;
- u_int8_t t_tag;
- u_int8_t *cur = buf;
+ uint8_t t_len;
+ uint8_t t_tag;
+ uint8_t *cur = buf;
memset(dec, 0, sizeof(*dec));
@@ -110,10 +122,10 @@ int ipaccess_idtag_parse(struct tlv_parsed *dec, unsigned char *buf, int len)
if (t_len > len + 1) {
LOGP(DMI, LOGL_ERROR, "The tag does not fit: %d\n", t_len);
- return -1;
+ return -EINVAL;
}
- DEBUGPC(DMI, "%s='%s' ", ipac_idtag_name(t_tag), cur);
+ DEBUGPC(DMI, "%s='%s' ", ipaccess_idtag_name(t_tag), cur);
dec->lv[t_tag].len = t_len;
dec->lv[t_tag].val = cur;
@@ -125,7 +137,7 @@ int ipaccess_idtag_parse(struct tlv_parsed *dec, unsigned char *buf, int len)
}
struct gsm_bts *find_bts_by_unitid(struct gsm_network *net,
- u_int16_t site_id, u_int16_t bts_id)
+ uint16_t site_id, uint16_t bts_id)
{
struct gsm_bts *bts;
@@ -142,8 +154,8 @@ struct gsm_bts *find_bts_by_unitid(struct gsm_network *net,
return NULL;
}
-static int parse_unitid(const char *str, u_int16_t *site_id, u_int16_t *bts_id,
- u_int16_t *trx_id)
+int ipaccess_parse_unitid(const char *str, uint16_t *site_id,
+ uint16_t *bts_id, uint16_t *trx_id)
{
unsigned long ul;
char *endptr;
@@ -179,27 +191,45 @@ static int parse_unitid(const char *str, u_int16_t *site_id, u_int16_t *bts_id,
return 0;
}
-/* send the id ack */
+static int ipaccess_send(int fd, const void *msg, size_t msglen)
+{
+ int ret;
+
+ ret = write(fd, msg, msglen);
+ if (ret < 0)
+ return ret;
+ if (ret < msglen) {
+ LOGP(DINP, LOGL_ERROR, "ipaccess_send: short write\n");
+ return -EIO;
+ }
+ return ret;
+}
+
+int ipaccess_send_pong(int fd)
+{
+ return ipaccess_send(fd, ipa_pong_msg, sizeof(ipa_pong_msg));
+}
+
int ipaccess_send_id_ack(int fd)
{
- return write(fd, id_ack, sizeof(id_ack));
+ return ipaccess_send(fd, ipa_id_ack_msg, sizeof(ipa_id_ack_msg));
}
int ipaccess_send_id_req(int fd)
{
- return write(fd, id_req, sizeof(id_req));
+ return ipaccess_send(fd, ipa_id_req_msg, sizeof(ipa_id_req_msg));
}
/* base handling of the ip.access protocol */
int ipaccess_rcvmsg_base(struct msgb *msg,
- struct bsc_fd *bfd)
+ struct osmo_fd *bfd)
{
- u_int8_t msg_type = *(msg->l2h);
+ uint8_t msg_type = *(msg->l2h);
int ret = 0;
switch (msg_type) {
case IPAC_MSGT_PING:
- ret = write(bfd->fd, pong, sizeof(pong));
+ ret = ipaccess_send_pong(bfd->fd);
break;
case IPAC_MSGT_PONG:
DEBUGP(DMI, "PONG!\n");
@@ -213,14 +243,14 @@ int ipaccess_rcvmsg_base(struct msgb *msg,
}
static int ipaccess_rcvmsg(struct e1inp_line *line, struct msgb *msg,
- struct bsc_fd *bfd)
+ struct osmo_fd *bfd)
{
struct tlv_parsed tlvp;
- u_int8_t msg_type = *(msg->l2h);
- u_int16_t site_id = 0, bts_id = 0, trx_id = 0;
+ uint8_t msg_type = *(msg->l2h);
+ uint16_t site_id = 0, bts_id = 0, trx_id = 0;
struct gsm_bts *bts;
char *unitid;
- int len;
+ int len, ret;
/* handle base messages */
ipaccess_rcvmsg_base(msg, bfd);
@@ -229,10 +259,14 @@ static int ipaccess_rcvmsg(struct e1inp_line *line, struct msgb *msg,
case IPAC_MSGT_ID_RESP:
DEBUGP(DMI, "ID_RESP ");
/* parse tags, search for Unit ID */
- ipaccess_idtag_parse(&tlvp, (u_int8_t *)msg->l2h + 2,
- msgb_l2len(msg)-2);
+ ret = ipaccess_idtag_parse(&tlvp, (uint8_t *)msg->l2h + 2,
+ msgb_l2len(msg)-2);
DEBUGP(DMI, "\n");
-
+ if (ret < 0) {
+ LOGP(DINP, LOGL_ERROR, "ignoring IPA response message "
+ "with malformed TLVs\n");
+ return ret;
+ }
if (!TLVP_PRESENT(&tlvp, IPAC_IDTAG_UNIT))
break;
@@ -243,7 +277,7 @@ static int ipaccess_rcvmsg(struct e1inp_line *line, struct msgb *msg,
/* lookup BTS, create sign_link, ... */
unitid = (char *) TLVP_VAL(&tlvp, IPAC_IDTAG_UNIT);
unitid[len - 1] = '\0';
- parse_unitid(unitid, &site_id, &bts_id, &trx_id);
+ ipaccess_parse_unitid(unitid, &site_id, &bts_id, &trx_id);
bts = find_bts_by_unitid(e1h->gsmnet, site_id, bts_id);
if (!bts) {
LOGP(DINP, LOGL_ERROR, "Unable to find BTS configuration for "
@@ -260,14 +294,14 @@ static int ipaccess_rcvmsg(struct e1inp_line *line, struct msgb *msg,
bts->oml_tei, 0);
} else if (bfd->priv_nr == PRIV_RSL) {
struct e1inp_ts *e1i_ts;
- struct bsc_fd *newbfd;
+ struct osmo_fd *newbfd;
struct gsm_bts_trx *trx = gsm_bts_trx_num(bts, trx_id);
/* drop any old rsl connection */
ipaccess_drop_rsl(trx);
if (!bts->oml_link) {
- bsc_unregister_fd(bfd);
+ osmo_fd_unregister(bfd);
close(bfd->fd);
bfd->fd = -1;
talloc_free(bfd);
@@ -287,10 +321,10 @@ static int ipaccess_rcvmsg(struct e1inp_line *line, struct msgb *msg,
/* get rid of our old temporary bfd */
memcpy(newbfd, bfd, sizeof(*newbfd));
newbfd->priv_nr = PRIV_RSL + trx_id;
- bsc_unregister_fd(bfd);
+ osmo_fd_unregister(bfd);
bfd->fd = -1;
talloc_free(bfd);
- bsc_register_fd(newbfd);
+ osmo_fd_register(newbfd);
}
break;
}
@@ -304,7 +338,7 @@ static int ipaccess_rcvmsg(struct e1inp_line *line, struct msgb *msg,
* read one ipa message from the socket
* return NULL in case of error
*/
-struct msgb *ipaccess_read_msg(struct bsc_fd *bfd, int *error)
+struct msgb *ipaccess_read_msg(struct osmo_fd *bfd, int *error)
{
struct msgb *msg = msgb_alloc(TS1_ALLOC_SIZE, "Abis/IP");
struct ipaccess_head *hh;
@@ -360,7 +394,7 @@ int ipaccess_drop_oml(struct gsm_bts *bts)
struct gsm_bts_trx *trx;
struct e1inp_ts *ts;
struct e1inp_line *line;
- struct bsc_fd *bfd;
+ struct osmo_fd *bfd;
if (!bts || !bts->oml_link)
return -1;
@@ -371,7 +405,7 @@ int ipaccess_drop_oml(struct gsm_bts *bts)
e1inp_event(ts, S_INP_TEI_DN, bts->oml_link->tei, bts->oml_link->sapi);
bfd = &ts->driver.ipaccess.fd;
- bsc_unregister_fd(bfd);
+ osmo_fd_unregister(bfd);
close(bfd->fd);
bfd->fd = -1;
@@ -390,19 +424,22 @@ int ipaccess_drop_oml(struct gsm_bts *bts)
return -1;
}
-static int ipaccess_drop(struct e1inp_ts *ts, struct bsc_fd *bfd)
+static int ipaccess_drop(struct e1inp_ts *ts, struct osmo_fd *bfd)
{
struct e1inp_sign_link *link;
int bts_nr;
- if (!ts) {
+ if (!ts || !bfd->data) {
/*
* If we don't have a TS this means that this is a RSL
* connection but we are not past the authentication
* handling yet. So we can safely delete this bfd and
* wait for a reconnect.
+ * If we don't have bfd->data this means that a RSL
+ * connection was accept()ed, but nothing was recv()ed
+ * and the connection gets close()ed.
*/
- bsc_unregister_fd(bfd);
+ osmo_fd_unregister(bfd);
close(bfd->fd);
bfd->fd = -1;
talloc_free(bfd);
@@ -421,7 +458,7 @@ static int ipaccess_drop(struct e1inp_ts *ts, struct bsc_fd *bfd)
/* error case */
LOGP(DINP, LOGL_ERROR, "Failed to find a signalling link for ts: %p\n", ts);
- bsc_unregister_fd(bfd);
+ osmo_fd_unregister(bfd);
close(bfd->fd);
bfd->fd = -1;
return -1;
@@ -429,7 +466,7 @@ static int ipaccess_drop(struct e1inp_ts *ts, struct bsc_fd *bfd)
int ipaccess_drop_rsl(struct gsm_bts_trx *trx)
{
- struct bsc_fd *bfd;
+ struct osmo_fd *bfd;
struct e1inp_ts *ts;
if (!trx || !trx->rsl_link)
@@ -441,7 +478,7 @@ int ipaccess_drop_rsl(struct gsm_bts_trx *trx)
/* close the socket */
bfd = &ts->driver.ipaccess.fd;
- bsc_unregister_fd(bfd);
+ osmo_fd_unregister(bfd);
close(bfd->fd);
bfd->fd = -1;
@@ -452,7 +489,7 @@ int ipaccess_drop_rsl(struct gsm_bts_trx *trx)
return -1;
}
-static int handle_ts1_read(struct bsc_fd *bfd)
+static int handle_ts1_read(struct osmo_fd *bfd)
{
struct e1inp_line *line = bfd->data;
unsigned int ts_nr = bfd->priv_nr;
@@ -475,7 +512,7 @@ static int handle_ts1_read(struct bsc_fd *bfd)
return error;
}
- DEBUGP(DMI, "RX %u: %s\n", ts_nr, hexdump(msgb_l2(msg), msgb_l2len(msg)));
+ DEBUGP(DMI, "RX %u: %s\n", ts_nr, osmo_hexdump(msgb_l2(msg), msgb_l2len(msg)));
hh = (struct ipaccess_head *) msg->data;
if (hh->proto == IPAC_PROTO_IPACCESS) {
@@ -520,6 +557,15 @@ static int handle_ts1_read(struct bsc_fd *bfd)
return ret;
}
+void ipaccess_prepend_header_ext(struct msgb *msg, int proto)
+{
+ struct ipaccess_head_ext *hh_ext;
+
+ /* prepend the osmo ip.access header extension */
+ hh_ext = (struct ipaccess_head_ext *) msgb_push(msg, sizeof(*hh_ext));
+ hh_ext->proto = proto;
+}
+
void ipaccess_prepend_header(struct msgb *msg, int proto)
{
struct ipaccess_head *hh;
@@ -545,14 +591,14 @@ static void timeout_ts1_write(void *data)
ts_want_write(e1i_ts);
}
-static int handle_ts1_write(struct bsc_fd *bfd)
+static int handle_ts1_write(struct osmo_fd *bfd)
{
struct e1inp_line *line = bfd->data;
unsigned int ts_nr = bfd->priv_nr;
struct e1inp_ts *e1i_ts = &line->ts[ts_nr-1];
struct e1inp_sign_link *sign_link;
struct msgb *msg;
- u_int8_t proto;
+ uint8_t proto;
int ret;
bfd->when &= ~BSC_FD_WRITE;
@@ -580,7 +626,7 @@ static int handle_ts1_write(struct bsc_fd *bfd)
msg->l2h = msg->data;
ipaccess_prepend_header(msg, sign_link->tei);
- DEBUGP(DMI, "TX %u: %s\n", ts_nr, hexdump(msg->l2h, msgb_l2len(msg)));
+ DEBUGP(DMI, "TX %u: %s\n", ts_nr, osmo_hexdump(msg->l2h, msgb_l2len(msg)));
ret = send(bfd->fd, msg->data, msg->len, 0);
msgb_free(msg);
@@ -590,13 +636,13 @@ static int handle_ts1_write(struct bsc_fd *bfd)
e1i_ts->sign.tx_timer.data = e1i_ts;
/* Reducing this might break the nanoBTS 900 init. */
- bsc_schedule_timer(&e1i_ts->sign.tx_timer, 0, e1i_ts->sign.delay);
+ osmo_timer_schedule(&e1i_ts->sign.tx_timer, 0, e1i_ts->sign.delay);
return ret;
}
/* callback from select.c in case one of the fd's can be read/written */
-static int ipaccess_fd_cb(struct bsc_fd *bfd, unsigned int what)
+static int ipaccess_fd_cb(struct osmo_fd *bfd, unsigned int what)
{
struct e1inp_line *line = bfd->data;
unsigned int ts_nr = bfd->priv_nr;
@@ -627,14 +673,14 @@ struct e1inp_driver ipaccess_driver = {
};
/* callback of the OML listening filedescriptor */
-static int listen_fd_cb(struct bsc_fd *listen_bfd, unsigned int what)
+static int listen_fd_cb(struct osmo_fd *listen_bfd, unsigned int what)
{
int ret;
int idx = 0;
int i;
struct e1inp_line *line;
struct e1inp_ts *e1i_ts;
- struct bsc_fd *bfd;
+ struct osmo_fd *bfd;
struct sockaddr_in sa;
socklen_t sa_len = sizeof(sa);
@@ -671,7 +717,7 @@ static int listen_fd_cb(struct bsc_fd *listen_bfd, unsigned int what)
bfd->priv_nr = PRIV_OML;
bfd->cb = ipaccess_fd_cb;
bfd->when = BSC_FD_READ;
- ret = bsc_register_fd(bfd);
+ ret = osmo_fd_register(bfd);
if (ret < 0) {
LOGP(DINP, LOGL_ERROR, "could not register FD\n");
close(bfd->fd);
@@ -686,17 +732,17 @@ static int listen_fd_cb(struct bsc_fd *listen_bfd, unsigned int what)
//return e1inp_line_register(line);
}
-static int rsl_listen_fd_cb(struct bsc_fd *listen_bfd, unsigned int what)
+static int rsl_listen_fd_cb(struct osmo_fd *listen_bfd, unsigned int what)
{
struct sockaddr_in sa;
socklen_t sa_len = sizeof(sa);
- struct bsc_fd *bfd;
+ struct osmo_fd *bfd;
int ret;
if (!(what & BSC_FD_READ))
return 0;
- bfd = talloc_zero(tall_bsc_ctx, struct bsc_fd);
+ bfd = talloc_zero(tall_bsc_ctx, struct osmo_fd);
if (!bfd)
return -ENOMEM;
@@ -713,7 +759,7 @@ static int rsl_listen_fd_cb(struct bsc_fd *listen_bfd, unsigned int what)
bfd->priv_nr = PRIV_RSL;
bfd->cb = ipaccess_fd_cb;
bfd->when = BSC_FD_READ;
- ret = bsc_register_fd(bfd);
+ ret = osmo_fd_register(bfd);
if (ret < 0) {
LOGP(DINP, LOGL_ERROR, "could not register FD\n");
close(bfd->fd);
@@ -721,7 +767,7 @@ static int rsl_listen_fd_cb(struct bsc_fd *listen_bfd, unsigned int what)
return ret;
}
/* Request ID. FIXME: request LOCATION, HW/SW VErsion, Unit Name, Serno */
- ret = write(bfd->fd, id_req, sizeof(id_req));
+ ret = ipaccess_send_id_req(bfd->fd);
return 0;
}
@@ -730,7 +776,7 @@ static int rsl_listen_fd_cb(struct bsc_fd *listen_bfd, unsigned int what)
int ipaccess_connect(struct e1inp_line *line, struct sockaddr_in *sa)
{
struct e1inp_ts *e1i_ts = &line->ts[0];
- struct bsc_fd *bfd = &e1i_ts->driver.ipaccess.fd;
+ struct osmo_fd *bfd = &e1i_ts->driver.ipaccess.fd;
int ret, on = 1;
bfd->fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
@@ -753,7 +799,7 @@ int ipaccess_connect(struct e1inp_line *line, struct sockaddr_in *sa)
return ret;
}
- ret = bsc_register_fd(bfd);
+ ret = osmo_fd_register(bfd);
if (ret < 0) {
close(bfd->fd);
return ret;
@@ -769,12 +815,6 @@ int ipaccess_setup(struct gsm_network *gsmnet)
{
int ret;
- /* register the driver with the core */
- /* FIXME: do this in the plugin initializer function */
- ret = e1inp_driver_register(&ipaccess_driver);
- if (ret)
- return ret;
-
e1h = talloc_zero(tall_bsc_ctx, struct ia_e1_handle);
if (!e1h)
return -ENOMEM;
@@ -782,16 +822,21 @@ int ipaccess_setup(struct gsm_network *gsmnet)
e1h->gsmnet = gsmnet;
/* Listen for OML connections */
- ret = make_sock(&e1h->listen_fd, IPPROTO_TCP, 0, IPA_TCP_PORT_OML,
- listen_fd_cb);
+ ret = make_sock(&e1h->listen_fd, IPPROTO_TCP, INADDR_ANY,
+ IPA_TCP_PORT_OML, 0, listen_fd_cb, NULL);
if (ret < 0)
return ret;
/* Listen for RSL connections */
- ret = make_sock(&e1h->rsl_listen_fd, IPPROTO_TCP, 0,
- IPA_TCP_PORT_RSL, rsl_listen_fd_cb);
+ ret = make_sock(&e1h->rsl_listen_fd, IPPROTO_TCP, INADDR_ANY,
+ IPA_TCP_PORT_RSL, 0, rsl_listen_fd_cb, NULL);
if (ret < 0)
return ret;
return ret;
}
+
+void e1inp_ipaccess_init(void)
+{
+ e1inp_driver_register(&ipaccess_driver);
+}
diff --git a/src/libabis/input/lapd.c b/src/libabis/input/lapd.c
index 7bce6cc51..d0fab1815 100644
--- a/src/libabis/input/lapd.c
+++ b/src/libabis/input/lapd.c
@@ -36,10 +36,10 @@
#include "lapd.h"
-#include <osmocore/linuxlist.h>
-#include <osmocore/talloc.h>
-#include <osmocore/msgb.h>
-#include <osmocore/timer.h>
+#include <osmocom/core/linuxlist.h>
+#include <osmocom/core/talloc.h>
+#include <osmocom/core/msgb.h>
+#include <osmocom/core/timer.h>
#include <openbsc/debug.h>
#define SABM_INTERVAL 0, 300000
@@ -137,7 +137,7 @@ struct lapd_sap {
int va; /* last acked by peer */
int vr; /* next expected to be received */
- struct timer_list sabme_timer; /* timer to re-transmit SABM message */
+ struct osmo_timer_list sabme_timer; /* timer to re-transmit SABM message */
};
/* 3.5.2.2 Send state variable V(S)
@@ -259,11 +259,11 @@ static void lapd_sap_set_state(struct lapd_tei *teip, uint8_t sapi,
switch (sap->state) {
case SAP_STATE_SABM_RETRANS:
if (newstate != SAP_STATE_SABM_RETRANS)
- bsc_del_timer(&sap->sabme_timer);
+ osmo_timer_del(&sap->sabme_timer);
break;
default:
if (newstate == SAP_STATE_SABM_RETRANS)
- bsc_schedule_timer(&sap->sabme_timer, SABM_INTERVAL);
+ osmo_timer_schedule(&sap->sabme_timer, SABM_INTERVAL);
break;
}
@@ -290,7 +290,7 @@ static void lapd_tei_receive(struct lapd_instance *li, uint8_t *data, int len)
teip = teip_from_tei(li, action);
if (!teip) {
LOGP(DMI, LOGL_INFO, "TEI MGR: New TEI %u\n", action);
- lapd_tei_alloc(li, action);
+ teip = lapd_tei_alloc(li, action);
}
/* Send ACCEPT */
@@ -608,7 +608,7 @@ static void sabme_timer_cb(void *_sap)
lapd_send_sabm(sap->tei->li, sap->tei->tei, sap->sapi);
if (sap->state == SAP_STATE_SABM_RETRANS)
- bsc_schedule_timer(&sap->sabme_timer, SABM_INTERVAL);
+ osmo_timer_schedule(&sap->sabme_timer, SABM_INTERVAL);
}
/* Start a (user-side) SAP for the specified TEI/SAPI on the LAPD instance */
diff --git a/src/libabis/input/lapd.h b/src/libabis/input/lapd.h
index fd11edaa3..fb980d104 100644
--- a/src/libabis/input/lapd.h
+++ b/src/libabis/input/lapd.h
@@ -3,7 +3,7 @@
#include <stdint.h>
-#include <osmocore/linuxlist.h>
+#include <osmocom/core/linuxlist.h>
typedef enum {
LAPD_MPH_NONE = 0,
diff --git a/src/libabis/input/misdn.c b/src/libabis/input/misdn.c
index 459887917..ab92d612f 100644
--- a/src/libabis/input/misdn.c
+++ b/src/libabis/input/misdn.c
@@ -27,7 +27,6 @@
#include <string.h>
#include <time.h>
#include <sys/fcntl.h>
-#include <sys/types.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <arpa/inet.h>
@@ -40,9 +39,9 @@
#define PF_ISDN AF_ISDN
#endif
-#include <osmocore/select.h>
-#include <osmocore/msgb.h>
-#include <osmocore/talloc.h>
+#include <osmocom/core/select.h>
+#include <osmocom/core/msgb.h>
+#include <osmocom/core/talloc.h>
#include <openbsc/debug.h>
#include <openbsc/gsm_data.h>
#include <openbsc/abis_nm.h>
@@ -86,7 +85,7 @@ const char *get_prim_name(unsigned int prim)
return "UNKNOWN";
}
-static int handle_ts1_read(struct bsc_fd *bfd)
+static int handle_ts1_read(struct osmo_fd *bfd)
{
struct e1inp_line *line = bfd->data;
unsigned int ts_nr = bfd->priv_nr;
@@ -163,7 +162,7 @@ static int handle_ts1_read(struct bsc_fd *bfd)
case DL_DATA_IND:
case DL_UNITDATA_IND:
msg->l2h = msg->data + MISDN_HEADER_LEN;
- DEBUGP(DMI, "RX: %s\n", hexdump(msgb_l2(msg), ret - MISDN_HEADER_LEN));
+ DEBUGP(DMI, "RX: %s\n", osmo_hexdump(msgb_l2(msg), ret - MISDN_HEADER_LEN));
ret = e1inp_rx_ts(e1i_ts, msg, l2addr.tei, l2addr.sapi);
break;
case PH_ACTIVATE_IND:
@@ -201,7 +200,7 @@ static void timeout_ts1_write(void *data)
ts_want_write(e1i_ts);
}
-static int handle_ts1_write(struct bsc_fd *bfd)
+static int handle_ts1_write(struct osmo_fd *bfd)
{
struct e1inp_line *line = bfd->data;
unsigned int ts_nr = bfd->priv_nr;
@@ -210,7 +209,7 @@ static int handle_ts1_write(struct bsc_fd *bfd)
struct sockaddr_mISDN sa;
struct msgb *msg;
struct mISDNhead *hh;
- u_int8_t *l2_data;
+ uint8_t *l2_data;
int ret;
bfd->when &= ~BSC_FD_WRITE;
@@ -230,7 +229,7 @@ static int handle_ts1_write(struct bsc_fd *bfd)
DEBUGP(DMI, "TX channel(%d) TEI(%d) SAPI(%d): %s\n",
sign_link->driver.misdn.channel, sign_link->tei,
- sign_link->sapi, hexdump(l2_data, msg->len - MISDN_HEADER_LEN));
+ sign_link->sapi, osmo_hexdump(l2_data, msg->len - MISDN_HEADER_LEN));
/* construct the sockaddr */
sa.family = AF_ISDN;
@@ -247,20 +246,20 @@ static int handle_ts1_write(struct bsc_fd *bfd)
/* set tx delay timer for next event */
e1i_ts->sign.tx_timer.cb = timeout_ts1_write;
e1i_ts->sign.tx_timer.data = e1i_ts;
- bsc_schedule_timer(&e1i_ts->sign.tx_timer, 0, e1i_ts->sign.delay);
+ osmo_timer_schedule(&e1i_ts->sign.tx_timer, 0, e1i_ts->sign.delay);
return ret;
}
#define BCHAN_TX_GRAN 160
/* write to a B channel TS */
-static int handle_tsX_write(struct bsc_fd *bfd)
+static int handle_tsX_write(struct osmo_fd *bfd)
{
struct e1inp_line *line = bfd->data;
unsigned int ts_nr = bfd->priv_nr;
struct e1inp_ts *e1i_ts = &line->ts[ts_nr-1];
struct mISDNhead *hh;
- u_int8_t tx_buf[BCHAN_TX_GRAN + sizeof(*hh)];
+ uint8_t tx_buf[BCHAN_TX_GRAN + sizeof(*hh)];
struct subch_mux *mx = &e1i_ts->trau.mux;
int ret;
@@ -270,7 +269,7 @@ static int handle_tsX_write(struct bsc_fd *bfd)
subchan_mux_out(mx, tx_buf+sizeof(*hh), BCHAN_TX_GRAN);
DEBUGP(DMIB, "BCHAN TX: %s\n",
- hexdump(tx_buf+sizeof(*hh), BCHAN_TX_GRAN));
+ osmo_hexdump(tx_buf+sizeof(*hh), BCHAN_TX_GRAN));
ret = send(bfd->fd, tx_buf, sizeof(*hh) + BCHAN_TX_GRAN, 0);
if (ret < sizeof(*hh) + BCHAN_TX_GRAN)
@@ -282,7 +281,7 @@ static int handle_tsX_write(struct bsc_fd *bfd)
#define TSX_ALLOC_SIZE 4096
/* FIXME: read from a B channel TS */
-static int handle_tsX_read(struct bsc_fd *bfd)
+static int handle_tsX_read(struct osmo_fd *bfd)
{
struct e1inp_line *line = bfd->data;
unsigned int ts_nr = bfd->priv_nr;
@@ -312,7 +311,7 @@ static int handle_tsX_read(struct bsc_fd *bfd)
case PH_DATA_IND:
msg->l2h = msg->data + MISDN_HEADER_LEN;
DEBUGP(DMIB, "BCHAN RX: %s\n",
- hexdump(msgb_l2(msg), ret - MISDN_HEADER_LEN));
+ osmo_hexdump(msgb_l2(msg), ret - MISDN_HEADER_LEN));
ret = e1inp_rx_ts(e1i_ts, msg, 0, 0);
break;
case PH_ACTIVATE_IND:
@@ -330,7 +329,7 @@ static int handle_tsX_read(struct bsc_fd *bfd)
}
/* callback from select.c in case one of the fd's can be read/written */
-static int misdn_fd_cb(struct bsc_fd *bfd, unsigned int what)
+static int misdn_fd_cb(struct osmo_fd *bfd, unsigned int what)
{
struct e1inp_line *line = bfd->data;
unsigned int ts_nr = bfd->priv_nr;
@@ -366,7 +365,7 @@ static int activate_bchan(struct e1inp_line *line, int ts, int act)
int ret;
unsigned int idx = ts-1;
struct e1inp_ts *e1i_ts = &line->ts[idx];
- struct bsc_fd *bfd = &e1i_ts->driver.misdn.fd;
+ struct osmo_fd *bfd = &e1i_ts->driver.misdn.fd;
fprintf(stdout, "activate bchan\n");
if (act)
@@ -401,7 +400,7 @@ static int mi_e1_setup(struct e1inp_line *line, int release_l2)
for (ts = 1; ts < NUM_E1_TS; ts++) {
unsigned int idx = ts-1;
struct e1inp_ts *e1i_ts = &line->ts[idx];
- struct bsc_fd *bfd = &e1i_ts->driver.misdn.fd;
+ struct osmo_fd *bfd = &e1i_ts->driver.misdn.fd;
struct sockaddr_mISDN addr;
bfd->data = line;
@@ -471,7 +470,7 @@ static int mi_e1_setup(struct e1inp_line *line, int release_l2)
if (e1i_ts->type == E1INP_TS_TYPE_TRAU)
activate_bchan(line, ts, 1);
- ret = bsc_register_fd(bfd);
+ ret = osmo_fd_register(bfd);
if (ret < 0) {
fprintf(stderr, "could not register FD: %s\n",
strerror(ret));