diff options
author | Harald Welte <laforge@gnumonks.org> | 2015-12-22 23:59:24 +0100 |
---|---|---|
committer | Harald Welte <laforge@gnumonks.org> | 2015-12-23 00:04:05 +0100 |
commit | 75a4e65f52f02e20d56d8426219feb46ec5cabf9 (patch) | |
tree | 5437d0c70291733d1f931c5eb8078bb095f8ece3 /src | |
parent | 38a4f32d580cda9194d7c0cc9e92cbabd4af568d (diff) |
hnbgw: Add SUA client socket towards localhost
This socket doesn't do much yet except to connect to localhost:14001
The host/port needs to be made configurable, and the RUA<->SUA
interfacing needs to be implemented.
Also, we'll need two SUA sockets, one for MSC and one for SGSN.
Diffstat (limited to 'src')
-rw-r--r-- | src/Makefile.am | 4 | ||||
-rw-r--r-- | src/hnbgw.c | 44 | ||||
-rw-r--r-- | src/hnbgw.h | 1 |
3 files changed, 47 insertions, 2 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index ec7250b..cbafe8a 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -3,13 +3,13 @@ SUBDIRS = hnbap rua ranap tests ASN1_ROOT = $(top_builddir)/asn1/ ASN1TOSTRUCT = $(ASN1_ROOT)/utils/asn1tostruct.py -AM_CFLAGS = $(OSMOCORE_CFLAGS) $(OSMOVTY_CFLAGS) $(OSMOGSM_CFLAGS) $(ASN1C_CFLAGS) -Ihnbap/ +AM_CFLAGS = $(OSMOCORE_CFLAGS) $(OSMOVTY_CFLAGS) $(OSMOGSM_CFLAGS) $(ASN1C_CFLAGS) $(OSMOSIGTRAN_CFLAGS) -Ihnbap/ COMMON_LDADD = -lsctp bin_PROGRAMS = hnbgw hnbgw_SOURCES = hnbap_encoder.c hnbap_decoder.c rua_encoder.c rua_decoder.c ranap_common.c rua_common.c hnbap_common.c iu_helpers.c asn1helpers.c hnbgw.c hnbgw_hnbap.c hnbgw_rua.c hnbgw_ranap.c ranap_decoder.c ranap_encoder.c ranap_msg_factory.c -hnbgw_LDADD = $(OSMOCORE_LIBS) $(OSMOVTY_LIBS) $(OSMOGSM_LIBS) $(ASN1C_LIBS) $(COMMON_LDADD) hnbap/libosmo-asn1-hnbap.a rua/libosmo-asn1-rua.a ranap/libosmo-asn1-ranap.a +hnbgw_LDADD = $(OSMOCORE_LIBS) $(OSMOVTY_LIBS) $(OSMOGSM_LIBS) $(ASN1C_LIBS) $(OSMOSIGTRAN_LIBS) $(COMMON_LDADD) hnbap/libosmo-asn1-hnbap.a rua/libosmo-asn1-rua.a ranap/libosmo-asn1-ranap.a BUILT_SOURCES = hnbap_decoder.c hnbap_encoder.c rua_decoder.c rua_encoder.c ranap_decoder.c ranap_encoder.c diff --git a/src/hnbgw.c b/src/hnbgw.c index 143c043..7938c5b 100644 --- a/src/hnbgw.c +++ b/src/hnbgw.c @@ -44,12 +44,17 @@ #include <osmocom/vty/logging.h> #include <osmocom/vty/command.h> +#include <osmocom/sigtran/sua.h> +#include <osmocom/sigtran/protocol/sua.h> +#include <osmocom/sigtran/sccp_sap.h> + #include "hnbgw.h" #include "hnbgw_hnbap.h" #include "hnbgw_rua.h" static void *tall_hnb_ctx; static void *tall_ue_ctx; +static void *tall_sua_ctx; void *talloc_asn1_ctx; struct hnb_gw g_hnb_gw = { @@ -237,6 +242,20 @@ static int listen_fd_cb(struct osmo_fd *fd, unsigned int what) return 0; } +/* Entry point for primitives coming up from SCCP User SAP */ +static int sccp_sap_up(struct osmo_prim_hdr *oph, void *link) +{ + struct osmo_scu_prim *prim = (struct osmo_scu_prim *) oph; + + LOGP(DMAIN, LOGL_DEBUG, "sccp_sap_up(%s)\n", osmo_scu_prim_name(oph)); + + /* FIXME: Do something */ + + msgb_free(oph->msg); + + return 0; +} + static const struct log_info_cat log_cat[] = { [DMAIN] = { .name = "DMAIN", .loglevel = LOGL_INFO, .enabled = 1, @@ -248,6 +267,11 @@ static const struct log_info_cat log_cat[] = { .color = "", .description = "Home Node B Application Part", }, + [DSUA] = { + .name = "DSUA", .loglevel = LOGL_DEBUG, .enabled = 1, + .color = "", + .description = "SCCP User Adaptation", + }, }; static const struct log_info hnbgw_log_info = { @@ -328,10 +352,13 @@ static void hnbgw_vty_init(void) int main(int argc, char **argv) { + struct osmo_sua_user *sua_user; + struct osmo_sua_link *sua_link; int rc; tall_hnb_ctx = talloc_named_const(NULL, 0, "hnb_context"); tall_ue_ctx = talloc_named_const(NULL, 0, "ue_context"); + tall_sua_ctx = talloc_named_const(NULL, 0, "sua"); talloc_asn1_ctx = talloc_named_const(NULL, 0, "asn1_context"); g_hnb_gw.listen_fd.cb = listen_fd_cb; @@ -354,6 +381,23 @@ int main(int argc, char **argv) exit(1); } + osmo_sua_set_log_area(DSUA); + sua_user = osmo_sua_user_create(tall_sua_ctx, sccp_sap_up); + if (!sua_user) { + perror("Failed to init SUA"); + exit(1); + } + rc = osmo_sua_client_connect(sua_user, "127.0.0.1", SUA_PORT); + if (rc < 0) { + perror("Failed to connect SUA"); + exit(1); + } + sua_link = osmo_sua_client_get_link(sua_user); + if (!sua_link) { + perror("Failed to get SUA link"); + exit(1); + } + rc = osmo_sock_init_ofd(&g_hnb_gw.listen_fd, AF_INET, SOCK_STREAM, IPPROTO_SCTP, NULL, g_hnb_gw.config.iuh_listen_port, OSMO_SOCK_F_BIND); diff --git a/src/hnbgw.h b/src/hnbgw.h index 3476c4f..d78dad0 100644 --- a/src/hnbgw.h +++ b/src/hnbgw.h @@ -12,6 +12,7 @@ enum { DMAIN, DHNBAP, + DSUA, }; |