From 5d571ce044dc95763a5a557b11f0ac90ff925e99 Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Sat, 26 May 2018 11:32:50 +0200 Subject: Introduce osmo_ss7_register_rx_unknown_cb() for unknown PPID/StreamID Applications may be interested in handling data for those SCTP PPID or IPA StreamID which libosmo-sigtran doesn't implement natively/internally. Let's add osmo_ss7_register_rx_unknown_cb() using which applications can register a call-back to implement whatever behaviour they'd want for those PPID/StreamIDs. Change-Id: I8616f914192000df0ec6547ff4ada80e0f9042a2 --- include/osmocom/sigtran/osmo_ss7.h | 11 +++++++++++ src/ipa.c | 4 +--- src/osmo_ss7.c | 40 ++++++++++++++++++++++++++++---------- src/xua_internal.h | 2 ++ 4 files changed, 44 insertions(+), 13 deletions(-) diff --git a/include/osmocom/sigtran/osmo_ss7.h b/include/osmocom/sigtran/osmo_ss7.h index fd3f103..a93c663 100644 --- a/include/osmocom/sigtran/osmo_ss7.h +++ b/include/osmocom/sigtran/osmo_ss7.h @@ -408,6 +408,17 @@ int osmo_ss7_asp_send(struct osmo_ss7_asp *asp, struct msgb *msg); int osmo_ss7_asp_restart(struct osmo_ss7_asp *asp); int osmo_ss7_asp_use_default_lm(struct osmo_ss7_asp *asp, int log_level); +/*! Weak function to handle payload for unknown/unsupported PPID or IPA StreamID. + * This function can be overridden by application code to implement whatever handling + * it wants for such additional payloads/streams. + * \param[in] asp Application Server Process through which data was received + * \param[in] ppid_sid SCTP PPID (in sigtran case) or IPA Stream ID + * \param[in] msg Message buffer containing received data. Continues to be owned by caller! + * \return 0 on success; negative on error */ +typedef int osmo_ss7_asp_rx_unknown_cb(struct osmo_ss7_asp *asp, int ppid_mux, struct msgb *msg); + +void osmo_ss7_register_rx_unknown_cb(osmo_ss7_asp_rx_unknown_cb *cb); + #define LOGPASP(asp, subsys, level, fmt, args ...) \ LOGP(subsys, level, "asp-%s: " fmt, (asp)->cfg.name, ## args) diff --git a/src/ipa.c b/src/ipa.c index 9f04746..0e6f683 100644 --- a/src/ipa.c +++ b/src/ipa.c @@ -288,9 +288,7 @@ int ipa_rx_msg(struct osmo_ss7_asp *asp, struct msgb *msg) rc = ipa_rx_msg_sccp(asp, msg); break; default: - LOGPASP(asp, DLSS7, LOGL_DEBUG, "Unknown Stream ID 0x%02x: %s\n", - hh->proto, msgb_hexdump(msg)); - rc = -1; + rc = ss7_asp_rx_unknown(asp, hh->proto, msg); } return rc; diff --git a/src/osmo_ss7.c b/src/osmo_ss7.c index 275469e..025c21c 100644 --- a/src/osmo_ss7.c +++ b/src/osmo_ss7.c @@ -1450,11 +1450,8 @@ static int xua_srv_conn_cb(struct osmo_stream_srv *conn) rc = sua_rx_msg(asp, msg); else if (ppid == M3UA_PPID && asp->cfg.proto == OSMO_SS7_ASP_PROT_M3UA) rc = m3ua_rx_msg(asp, msg); - else { - LOGPASP(asp, DLSS7, LOGL_NOTICE, "SCTP chunk for unknown PPID %u " - "received\n", ppid); - rc = 0; - } + else + rc = ss7_asp_rx_unknown(asp, ppid, msg); out: msgb_free(msg); @@ -1591,11 +1588,8 @@ static int xua_cli_read_cb(struct osmo_stream_cli *conn) rc = sua_rx_msg(asp, msg); else if (ppid == M3UA_PPID && asp->cfg.proto == OSMO_SS7_ASP_PROT_M3UA) rc = m3ua_rx_msg(asp, msg); - else { - LOGPASP(asp, DLSS7, LOGL_NOTICE, "SCTP chunk for unknown PPID %u " - "received\n", ppid); - rc = 0; - } + else + rc = ss7_asp_rx_unknown(asp, ppid, msg); out: msgb_free(msg); @@ -1918,3 +1912,29 @@ enum osmo_ss7_as_traffic_mode osmo_ss7_tmode_from_xua(uint32_t in) return OSMO_SS7_AS_TMOD_BCAST; } } + +static osmo_ss7_asp_rx_unknown_cb *g_osmo_ss7_asp_rx_unknown_cb; + +int ss7_asp_rx_unknown(struct osmo_ss7_asp *asp, int ppid_mux, struct msgb *msg) +{ + if (g_osmo_ss7_asp_rx_unknown_cb) + return (*g_osmo_ss7_asp_rx_unknown_cb)(asp, ppid_mux, msg); + + switch(asp->cfg.proto) { + case OSMO_SS7_ASP_PROT_IPA: + LOGPASP(asp, DLSS7, LOGL_NOTICE, "Rx IPA for unknown Stream ID 0x%02x: %s\n", + ppid_mux, msgb_hexdump(msg)); + break; + default: + LOGPASP(asp, DLSS7, LOGL_NOTICE, "Rx SCTP chunk for unknown PPID %u: %s\n", + ppid_mux, msgb_hexdump(msg)); + break; + } + return 0; +} + +/*! Register a call-back function for unknown SCTP PPID / IPA Stream ID */ +void osmo_ss7_register_rx_unknown_cb(osmo_ss7_asp_rx_unknown_cb *cb) +{ + g_osmo_ss7_asp_rx_unknown_cb = cb; +} diff --git a/src/xua_internal.h b/src/xua_internal.h index 96bd153..d836fae 100644 --- a/src/xua_internal.h +++ b/src/xua_internal.h @@ -78,3 +78,5 @@ int osmo_isup_party_parse(char *out_digits, const uint8_t *in, int osmo_sccp_addr_parse(struct osmo_sccp_addr *out, const uint8_t *addr, unsigned int addrlen); int osmo_sccp_addr_encode(struct msgb *msg, const struct osmo_sccp_addr *in); + +int ss7_asp_rx_unknown(struct osmo_ss7_asp *asp, int ppid_mux, struct msgb *msg); -- cgit v1.2.3 From 4dc9088cabedc40cb9072814237ad5926b12bd35 Mon Sep 17 00:00:00 2001 From: Stefan Sperling Date: Tue, 12 Jun 2018 18:55:50 +0200 Subject: make it possible to pass parameters to m3ua_example There are plans to use the m3ua_example tool as an SCCP peer for a TTCN3 test suite. Make it possible to pass paramters to this tool so the user can override hard-coded default values of IP addresses, ports, and point codes. Change-Id: I52243ae926c76020de41c8dfc7263517c7263d7e --- examples/m3ua_example.c | 147 ++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 131 insertions(+), 16 deletions(-) diff --git a/examples/m3ua_example.c b/examples/m3ua_example.c index a9f455c..2a99450 100644 --- a/examples/m3ua_example.c +++ b/examples/m3ua_example.c @@ -4,6 +4,7 @@ #include #include #include +#include #include #include @@ -23,15 +24,17 @@ static struct osmo_sccp_instance *g_sccp; -static struct osmo_sccp_instance *sua_server_helper(void) +static struct osmo_sccp_instance *sua_server_helper(int local_port, const char *local_address, int local_pc, + int remote_port, const char *remote_address, int remote_pc) { struct osmo_sccp_instance *sccp; - sccp = osmo_sccp_simple_server(NULL, 1, OSMO_SS7_ASP_PROT_M3UA, - -1, "127.0.0.2"); + sccp = osmo_sccp_simple_server(NULL, local_pc, OSMO_SS7_ASP_PROT_M3UA, local_port, local_address); + if (sccp == NULL) + return NULL; - osmo_sccp_simple_server_add_clnt(sccp, OSMO_SS7_ASP_PROT_M3UA, - "23", 23, -1, 0, NULL); + osmo_sccp_simple_server_add_clnt(sccp, OSMO_SS7_ASP_PROT_M3UA, "client", remote_pc, local_port, + remote_port, remote_address); return sccp; } @@ -79,10 +82,118 @@ static struct vty_app_info vty_info = { .version = 0, }; +#define DEFAULT_LOCAL_PC -1 +#define DEFAULT_LOCAL_ADDRESS "127.0.0.2" +#define DEFAULT_LOCAL_PORT M3UA_PORT +#define DEFAULT_REMOTE_PC 23 +#define DEFAULT_REMOTE_ADDRESS "127.0.0.1" +#define DEFAULT_REMOTE_PORT M3UA_PORT + +static void usage(void) { + fprintf(stderr, "m3ua_example [-c] [-l LOCAL_ADDRESS[:LOCAL_PORT]]\n" + " [-r REMOTE_ADDRESS[:REMOTE_PORT]]\n" + " [-L LOCAL_POINT_CODE] [-R REMOTE_POINT_CODE]\n" + "Options:\n" + " -c: Run in client mode (default is server mode)\n" + " -l: local IP address and SCTP port (default is %s:%d)\n" + " -r: remote IP address and SCTP port (default is %s:%d)\n" + " -L: local point code (default is %d)\n" + " -R: remote point code (default is %d)\n", + DEFAULT_LOCAL_ADDRESS, DEFAULT_LOCAL_PORT, + DEFAULT_REMOTE_ADDRESS, DEFAULT_REMOTE_PORT, + DEFAULT_LOCAL_PC, DEFAULT_REMOTE_PC); + exit(1); +} + +static int is_decimal_string(const char *s) +{ + const char *p = s; + + if (*p == '\0') + return 0; + + while (*p) { + if (!isdigit(*p++)) + return 0; + } + return 1; +} + +static int parse_address_port(char **address, int *port, const char *arg) +{ + char *s, *colon; + + s = strdup(arg); + OSMO_ASSERT(s); + + colon = strrchr(s, ':'); + if (colon) { + char *portstr = colon + 1; + *colon = '\0'; + if (*portstr == '\0') { + fprintf(stderr, "missing port number after : in '%s'\n", arg); + free(s); + return 1; + } + if (!is_decimal_string(portstr)) { + fprintf(stderr, "invalid port number: '%s'\n", portstr); + free(s); + return 1; + } + *port = atoi(portstr); + } + + *address = s; + return 0; +} + int main(int argc, char **argv) { - bool client; - int rc; + bool client = false; + int rc, ch; + char *local_address = DEFAULT_LOCAL_ADDRESS; + int local_port = DEFAULT_LOCAL_PORT; + int local_pc = DEFAULT_LOCAL_PC; + char *remote_address = DEFAULT_REMOTE_ADDRESS; + int remote_port = DEFAULT_LOCAL_PORT; + int remote_pc = DEFAULT_REMOTE_PC; + + while ((ch = getopt(argc, argv, "cl:r:p:L:R:")) != -1) { + switch (ch) { + case 'c': + client = true; + break; + case 'l': + if (parse_address_port(&local_address, &local_port, optarg)) + exit(1); + break; + case 'r': + if (parse_address_port(&remote_address, &remote_port, optarg)) + exit(1); + break; + case 'L': + if (!is_decimal_string(optarg)) { + fprintf(stderr, "invalid decimal point code: '%s'\n", optarg); + exit(1); + } + local_pc = atoi(optarg); + break; + case 'R': + if (!is_decimal_string(optarg)) { + fprintf(stderr, "invalid decimal point code: '%s'\n", optarg); + exit(1); + } + remote_pc = atoi(optarg); + break; + default: + usage(); + } + } + argc -= optind; + argv += optind; + + if (argc != 0) + usage(); talloc_enable_leak_report_full(); @@ -96,23 +207,27 @@ int main(int argc, char **argv) osmo_ss7_vty_init_asp(NULL); osmo_sccp_vty_init(); - if (argc <= 1) - client = true; - else - client = false; - rc = telnet_init_dynif(NULL, NULL, vty_get_bind_addr(), 2324+client); if (rc < 0) { - perror("Erro binding VTY port\n"); + perror("Error binding VTY port"); exit(1); } - if (client) { - g_sccp = osmo_sccp_simple_client(NULL, "client", 23, OSMO_SS7_ASP_PROT_M3UA, 0, NULL, M3UA_PORT, "127.0.0.2"); + g_sccp = osmo_sccp_simple_client(NULL, "client", local_pc, OSMO_SS7_ASP_PROT_M3UA, + local_port, local_address, remote_port, remote_address); + if (g_sccp == NULL) { + perror("Could not create SCCP client"); + exit (1); + } sccp_test_user_vty_install(g_sccp, OSMO_SCCP_SSN_BSSAP); } else { - g_sccp = sua_server_helper(); + g_sccp = sua_server_helper(local_port, local_address, local_pc, + remote_port, remote_address, remote_pc); + if (g_sccp == NULL) { + perror("Could not create SCCP server"); + exit(1); + } sccp_test_server_init(g_sccp); } -- cgit v1.2.3 From 97db03a68246b7821de144b0ef41ad6ad7486610 Mon Sep 17 00:00:00 2001 From: Stefan Sperling Date: Thu, 14 Jun 2018 11:03:52 +0200 Subject: rename m3ua_example to sccp_demo_user The new name allows for more natural naming of variables in TTCN3 code when this program is used as a TTCN3 test component. Consider e.g. "SCCP_DEMO_USER_VTY" vs. "M3UA_EXAMPLE_VTY". Change-Id: I92b5e16e765a1ac36371a16933389903628f8dfe Related: OS#2666 --- .gitignore | 2 +- examples/Makefile.am | 6 +- examples/m3ua_example.c | 237 ---------------------------------------------- examples/sccp_demo_user.c | 237 ++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 241 insertions(+), 241 deletions(-) delete mode 100644 examples/m3ua_example.c create mode 100644 examples/sccp_demo_user.c diff --git a/.gitignore b/.gitignore index e63e4ee..9423d67 100644 --- a/.gitignore +++ b/.gitignore @@ -60,7 +60,7 @@ tests/package.m4 tests/testsuite tests/testsuite.log -examples/m3ua_example +examples/sccp_demo_user stp/osmo-stp diff --git a/examples/Makefile.am b/examples/Makefile.am index 6418aca..1993a01 100644 --- a/examples/Makefile.am +++ b/examples/Makefile.am @@ -4,8 +4,8 @@ AM_LDFLAGS=$(COVERAGE_LDFLAGS) noinst_HEADERS = internal.h -noinst_PROGRAMS = m3ua_example +noinst_PROGRAMS = sccp_demo_user -m3ua_example_SOURCES = m3ua_example.c sccp_test_server.c sccp_test_vty.c -m3ua_example_LDADD = $(top_builddir)/src/libosmo-sigtran.la \ +sccp_demo_user_SOURCES = sccp_demo_user.c sccp_test_server.c sccp_test_vty.c +sccp_demo_user_LDADD = $(top_builddir)/src/libosmo-sigtran.la \ $(LIBOSMOCORE_LIBS) $(LIBOSMOVTY_LIBS) diff --git a/examples/m3ua_example.c b/examples/m3ua_example.c deleted file mode 100644 index 2a99450..0000000 --- a/examples/m3ua_example.c +++ /dev/null @@ -1,237 +0,0 @@ - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include "internal.h" - -static struct osmo_sccp_instance *g_sccp; - -static struct osmo_sccp_instance *sua_server_helper(int local_port, const char *local_address, int local_pc, - int remote_port, const char *remote_address, int remote_pc) -{ - struct osmo_sccp_instance *sccp; - - sccp = osmo_sccp_simple_server(NULL, local_pc, OSMO_SS7_ASP_PROT_M3UA, local_port, local_address); - if (sccp == NULL) - return NULL; - - osmo_sccp_simple_server_add_clnt(sccp, OSMO_SS7_ASP_PROT_M3UA, "client", remote_pc, local_port, - remote_port, remote_address); - - return sccp; -} - -/*********************************************************************** - * Initialization - ***********************************************************************/ - -static void signal_handler(int signal) -{ - fprintf(stdout, "signal %d received\n", signal); - - switch (signal) { - case SIGUSR1: - talloc_report_full(osmo_sccp_get_ss7(g_sccp), stderr); - break; - case SIGUSR2: - talloc_report_full(NULL, stderr); - break; - } -} - -static const struct log_info_cat log_info_cat[] = { -}; - -static const struct log_info log_info = { - .cat = log_info_cat, - .num_cat = ARRAY_SIZE(log_info_cat), -}; - -static void init_logging(void) -{ - const int log_cats[] = { DLSS7, DLSUA, DLM3UA, DLSCCP, DLINP }; - unsigned int i; - void *tall_ctx = talloc_named_const(NULL, 1, "example"); - msgb_talloc_ctx_init(tall_ctx, 0); - osmo_init_logging2(tall_ctx, &log_info); - - for (i = 0; i < ARRAY_SIZE(log_cats); i++) - log_set_category_filter(osmo_stderr_target, log_cats[i], 1, LOGL_DEBUG); -} - -static struct vty_app_info vty_info = { - .name = "sccp-test", - .version = 0, -}; - -#define DEFAULT_LOCAL_PC -1 -#define DEFAULT_LOCAL_ADDRESS "127.0.0.2" -#define DEFAULT_LOCAL_PORT M3UA_PORT -#define DEFAULT_REMOTE_PC 23 -#define DEFAULT_REMOTE_ADDRESS "127.0.0.1" -#define DEFAULT_REMOTE_PORT M3UA_PORT - -static void usage(void) { - fprintf(stderr, "m3ua_example [-c] [-l LOCAL_ADDRESS[:LOCAL_PORT]]\n" - " [-r REMOTE_ADDRESS[:REMOTE_PORT]]\n" - " [-L LOCAL_POINT_CODE] [-R REMOTE_POINT_CODE]\n" - "Options:\n" - " -c: Run in client mode (default is server mode)\n" - " -l: local IP address and SCTP port (default is %s:%d)\n" - " -r: remote IP address and SCTP port (default is %s:%d)\n" - " -L: local point code (default is %d)\n" - " -R: remote point code (default is %d)\n", - DEFAULT_LOCAL_ADDRESS, DEFAULT_LOCAL_PORT, - DEFAULT_REMOTE_ADDRESS, DEFAULT_REMOTE_PORT, - DEFAULT_LOCAL_PC, DEFAULT_REMOTE_PC); - exit(1); -} - -static int is_decimal_string(const char *s) -{ - const char *p = s; - - if (*p == '\0') - return 0; - - while (*p) { - if (!isdigit(*p++)) - return 0; - } - return 1; -} - -static int parse_address_port(char **address, int *port, const char *arg) -{ - char *s, *colon; - - s = strdup(arg); - OSMO_ASSERT(s); - - colon = strrchr(s, ':'); - if (colon) { - char *portstr = colon + 1; - *colon = '\0'; - if (*portstr == '\0') { - fprintf(stderr, "missing port number after : in '%s'\n", arg); - free(s); - return 1; - } - if (!is_decimal_string(portstr)) { - fprintf(stderr, "invalid port number: '%s'\n", portstr); - free(s); - return 1; - } - *port = atoi(portstr); - } - - *address = s; - return 0; -} - -int main(int argc, char **argv) -{ - bool client = false; - int rc, ch; - char *local_address = DEFAULT_LOCAL_ADDRESS; - int local_port = DEFAULT_LOCAL_PORT; - int local_pc = DEFAULT_LOCAL_PC; - char *remote_address = DEFAULT_REMOTE_ADDRESS; - int remote_port = DEFAULT_LOCAL_PORT; - int remote_pc = DEFAULT_REMOTE_PC; - - while ((ch = getopt(argc, argv, "cl:r:p:L:R:")) != -1) { - switch (ch) { - case 'c': - client = true; - break; - case 'l': - if (parse_address_port(&local_address, &local_port, optarg)) - exit(1); - break; - case 'r': - if (parse_address_port(&remote_address, &remote_port, optarg)) - exit(1); - break; - case 'L': - if (!is_decimal_string(optarg)) { - fprintf(stderr, "invalid decimal point code: '%s'\n", optarg); - exit(1); - } - local_pc = atoi(optarg); - break; - case 'R': - if (!is_decimal_string(optarg)) { - fprintf(stderr, "invalid decimal point code: '%s'\n", optarg); - exit(1); - } - remote_pc = atoi(optarg); - break; - default: - usage(); - } - } - argc -= optind; - argv += optind; - - if (argc != 0) - usage(); - - talloc_enable_leak_report_full(); - - signal(SIGUSR1, &signal_handler); - signal(SIGUSR2, &signal_handler); - - init_logging(); - osmo_ss7_init(); - osmo_fsm_log_addr(false); - vty_init(&vty_info); - osmo_ss7_vty_init_asp(NULL); - osmo_sccp_vty_init(); - - rc = telnet_init_dynif(NULL, NULL, vty_get_bind_addr(), 2324+client); - if (rc < 0) { - perror("Error binding VTY port"); - exit(1); - } - - if (client) { - g_sccp = osmo_sccp_simple_client(NULL, "client", local_pc, OSMO_SS7_ASP_PROT_M3UA, - local_port, local_address, remote_port, remote_address); - if (g_sccp == NULL) { - perror("Could not create SCCP client"); - exit (1); - } - sccp_test_user_vty_install(g_sccp, OSMO_SCCP_SSN_BSSAP); - } else { - g_sccp = sua_server_helper(local_port, local_address, local_pc, - remote_port, remote_address, remote_pc); - if (g_sccp == NULL) { - perror("Could not create SCCP server"); - exit(1); - } - sccp_test_server_init(g_sccp); - } - - while (1) { - osmo_select_main(0); - } -} diff --git a/examples/sccp_demo_user.c b/examples/sccp_demo_user.c new file mode 100644 index 0000000..f0b1a3e --- /dev/null +++ b/examples/sccp_demo_user.c @@ -0,0 +1,237 @@ + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include "internal.h" + +static struct osmo_sccp_instance *g_sccp; + +static struct osmo_sccp_instance *sua_server_helper(int local_port, const char *local_address, int local_pc, + int remote_port, const char *remote_address, int remote_pc) +{ + struct osmo_sccp_instance *sccp; + + sccp = osmo_sccp_simple_server(NULL, local_pc, OSMO_SS7_ASP_PROT_M3UA, local_port, local_address); + if (sccp == NULL) + return NULL; + + osmo_sccp_simple_server_add_clnt(sccp, OSMO_SS7_ASP_PROT_M3UA, "client", remote_pc, local_port, + remote_port, remote_address); + + return sccp; +} + +/*********************************************************************** + * Initialization + ***********************************************************************/ + +static void signal_handler(int signal) +{ + fprintf(stdout, "signal %d received\n", signal); + + switch (signal) { + case SIGUSR1: + talloc_report_full(osmo_sccp_get_ss7(g_sccp), stderr); + break; + case SIGUSR2: + talloc_report_full(NULL, stderr); + break; + } +} + +static const struct log_info_cat log_info_cat[] = { +}; + +static const struct log_info log_info = { + .cat = log_info_cat, + .num_cat = ARRAY_SIZE(log_info_cat), +}; + +static void init_logging(void) +{ + const int log_cats[] = { DLSS7, DLSUA, DLM3UA, DLSCCP, DLINP }; + unsigned int i; + void *tall_ctx = talloc_named_const(NULL, 1, "example"); + msgb_talloc_ctx_init(tall_ctx, 0); + osmo_init_logging2(tall_ctx, &log_info); + + for (i = 0; i < ARRAY_SIZE(log_cats); i++) + log_set_category_filter(osmo_stderr_target, log_cats[i], 1, LOGL_DEBUG); +} + +static struct vty_app_info vty_info = { + .name = "sccp-demo-user", + .version = 0, +}; + +#define DEFAULT_LOCAL_PC -1 +#define DEFAULT_LOCAL_ADDRESS "127.0.0.2" +#define DEFAULT_LOCAL_PORT M3UA_PORT +#define DEFAULT_REMOTE_PC 23 +#define DEFAULT_REMOTE_ADDRESS "127.0.0.1" +#define DEFAULT_REMOTE_PORT M3UA_PORT + +static void usage(void) { + fprintf(stderr, "sccp_demo_user [-c] [-l LOCAL_ADDRESS[:LOCAL_PORT]]\n" + " [-r REMOTE_ADDRESS[:REMOTE_PORT]]\n" + " [-L LOCAL_POINT_CODE] [-R REMOTE_POINT_CODE]\n" + "Options:\n" + " -c: Run in client mode (default is server mode)\n" + " -l: local IP address and SCTP port (default is %s:%d)\n" + " -r: remote IP address and SCTP port (default is %s:%d)\n" + " -L: local point code (default is %d)\n" + " -R: remote point code (default is %d)\n", + DEFAULT_LOCAL_ADDRESS, DEFAULT_LOCAL_PORT, + DEFAULT_REMOTE_ADDRESS, DEFAULT_REMOTE_PORT, + DEFAULT_LOCAL_PC, DEFAULT_REMOTE_PC); + exit(1); +} + +static int is_decimal_string(const char *s) +{ + const char *p = s; + + if (*p == '\0') + return 0; + + while (*p) { + if (!isdigit(*p++)) + return 0; + } + return 1; +} + +static int parse_address_port(char **address, int *port, const char *arg) +{ + char *s, *colon; + + s = strdup(arg); + OSMO_ASSERT(s); + + colon = strrchr(s, ':'); + if (colon) { + char *portstr = colon + 1; + *colon = '\0'; + if (*portstr == '\0') { + fprintf(stderr, "missing port number after : in '%s'\n", arg); + free(s); + return 1; + } + if (!is_decimal_string(portstr)) { + fprintf(stderr, "invalid port number: '%s'\n", portstr); + free(s); + return 1; + } + *port = atoi(portstr); + } + + *address = s; + return 0; +} + +int main(int argc, char **argv) +{ + bool client = false; + int rc, ch; + char *local_address = DEFAULT_LOCAL_ADDRESS; + int local_port = DEFAULT_LOCAL_PORT; + int local_pc = DEFAULT_LOCAL_PC; + char *remote_address = DEFAULT_REMOTE_ADDRESS; + int remote_port = DEFAULT_LOCAL_PORT; + int remote_pc = DEFAULT_REMOTE_PC; + + while ((ch = getopt(argc, argv, "cl:r:p:L:R:")) != -1) { + switch (ch) { + case 'c': + client = true; + break; + case 'l': + if (parse_address_port(&local_address, &local_port, optarg)) + exit(1); + break; + case 'r': + if (parse_address_port(&remote_address, &remote_port, optarg)) + exit(1); + break; + case 'L': + if (!is_decimal_string(optarg)) { + fprintf(stderr, "invalid decimal point code: '%s'\n", optarg); + exit(1); + } + local_pc = atoi(optarg); + break; + case 'R': + if (!is_decimal_string(optarg)) { + fprintf(stderr, "invalid decimal point code: '%s'\n", optarg); + exit(1); + } + remote_pc = atoi(optarg); + break; + default: + usage(); + } + } + argc -= optind; + argv += optind; + + if (argc != 0) + usage(); + + talloc_enable_leak_report_full(); + + signal(SIGUSR1, &signal_handler); + signal(SIGUSR2, &signal_handler); + + init_logging(); + osmo_ss7_init(); + osmo_fsm_log_addr(false); + vty_init(&vty_info); + osmo_ss7_vty_init_asp(NULL); + osmo_sccp_vty_init(); + + rc = telnet_init_dynif(NULL, NULL, vty_get_bind_addr(), 2324+client); + if (rc < 0) { + perror("Error binding VTY port"); + exit(1); + } + + if (client) { + g_sccp = osmo_sccp_simple_client(NULL, "client", local_pc, OSMO_SS7_ASP_PROT_M3UA, + local_port, local_address, remote_port, remote_address); + if (g_sccp == NULL) { + perror("Could not create SCCP client"); + exit (1); + } + sccp_test_user_vty_install(g_sccp, OSMO_SCCP_SSN_BSSAP); + } else { + g_sccp = sua_server_helper(local_port, local_address, local_pc, + remote_port, remote_address, remote_pc); + if (g_sccp == NULL) { + perror("Could not create SCCP server"); + exit(1); + } + sccp_test_server_init(g_sccp); + } + + while (1) { + osmo_select_main(0); + } +} -- cgit v1.2.3 From b241a2644922d87f5498bb301c06ec7d327ea0c3 Mon Sep 17 00:00:00 2001 From: Pau Espin Pedrol Date: Mon, 2 Jul 2018 16:44:39 +0200 Subject: build: Install example cfg files Change-Id: I93b73032b9a01a1e121ecf7c0cfcf3d5558efc7f --- Makefile.am | 2 +- configure.ac | 2 ++ doc/Makefile.am | 3 +++ doc/examples/Makefile.am | 4 ++++ 4 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 doc/Makefile.am create mode 100644 doc/examples/Makefile.am diff --git a/Makefile.am b/Makefile.am index 1ac8e11..3f4de13 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,7 +1,7 @@ AUTOMAKE_OPTIONS = foreign dist-bzip2 1.6 AM_CPPFLAGS = $(all_includes) -I$(top_srcdir)/include -SUBDIRS = include src tests examples stp +SUBDIRS = include src tests examples stp doc pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = libosmo-sccp.pc libosmo-mtp.pc libosmo-sigtran.pc libosmo-xua.pc diff --git a/configure.ac b/configure.ac index d2d4d02..ff9a1c4 100644 --- a/configure.ac +++ b/configure.ac @@ -120,5 +120,7 @@ AC_OUTPUT( tests/ss7/Makefile examples/Makefile stp/Makefile + doc/Makefile + doc/examples/Makefile Doxyfile Makefile) diff --git a/doc/Makefile.am b/doc/Makefile.am new file mode 100644 index 0000000..1d42b0a --- /dev/null +++ b/doc/Makefile.am @@ -0,0 +1,3 @@ +SUBDIRS = \ + examples \ + $(NULL) diff --git a/doc/examples/Makefile.am b/doc/examples/Makefile.am new file mode 100644 index 0000000..b1a7a0f --- /dev/null +++ b/doc/examples/Makefile.am @@ -0,0 +1,4 @@ +examples_stpdir = $(docdir)/examples/osmo-stp +examples_stp_DATA = osmo-stp.cfg + +EXTRA_DIST = $(examples_stp_DATA) -- cgit v1.2.3 From 15ffba535ba0e6b81411ad5726630c5934dece50 Mon Sep 17 00:00:00 2001 From: Pau Espin Pedrol Date: Mon, 2 Jul 2018 16:48:13 +0200 Subject: debian: Package installed example doc files Change-Id: I1d955ccf83c825d7a648a7e140bb20e10f5ddff3 --- debian/osmo-stp.install | 1 + 1 file changed, 1 insertion(+) diff --git a/debian/osmo-stp.install b/debian/osmo-stp.install index 74ce048..b2f8077 100644 --- a/debian/osmo-stp.install +++ b/debian/osmo-stp.install @@ -1 +1,2 @@ /usr/bin/osmo-stp +/usr/share/doc/libosmo-sccp/examples/osmo-stp/osmo-stp.cfg -- cgit v1.2.3 From 37169067b7b5a03d824cf9e2c59418953eeca5d4 Mon Sep 17 00:00:00 2001 From: Neels Hofmeyr Date: Wed, 11 Jul 2018 02:29:34 +0200 Subject: fix memleak in ipa_rx_msg_sccp After m3ua_xfer_from_data() has copied the msgb data, we need to free the msgb. Change-Id: I2263751c0aa3ae32455847c7622af8be0a1e7802 --- src/ipa.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/ipa.c b/src/ipa.c index 0e6f683..e15b1d8 100644 --- a/src/ipa.c +++ b/src/ipa.c @@ -258,6 +258,7 @@ static int ipa_rx_msg_sccp(struct osmo_ss7_asp *asp, struct msgb *msg) data_hdr.dpc = osmo_htonl(dpc); /* Create M3UA message in XUA structure */ xua = m3ua_xfer_from_data(&data_hdr, msgb_l2(msg), msgb_l2len(msg)); + msgb_free(msg); /* Update xua->mtp with values from data_hdr */ m3ua_dh_to_xfer_param(&xua->mtp, &data_hdr); -- cgit v1.2.3 From 6f103ae2b57f769d1e2f4193f26de5c414ae0d94 Mon Sep 17 00:00:00 2001 From: Neels Hofmeyr Date: Wed, 11 Jul 2018 02:30:38 +0200 Subject: cosmetic: sccp2sua.c: log the IEI for parsed SCCP addr Before this, the log looked like it parsed the same address twice with differing results: DLSUA DEBUG sccp2sua.c:333 Parsed Addr: RI=2,PC=1196,SSN=254 DLSUA DEBUG sccp2sua.c:333 Parsed Addr: RI=2,PC=100,SSN=254 Adding the IEI clarifies this: DLSUA DEBUG sccp2sua.c:333 IEI 259: Parsed Addr: RI=2,PC=1196,SSN=254 DLSUA DEBUG sccp2sua.c:333 IEI 258: Parsed Addr: RI=2,PC=100,SSN=254 (I'd have liked to print the IEI name from sua_iei_names, but I frankly can't figure out how to reach that value_string array "hidden" behind a xua_msg_class struct, and neither can I find any other code doing so.) Change-Id: I64adb31129684b2eb66fff581040017ce2f6d163 --- src/sccp2sua.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sccp2sua.c b/src/sccp2sua.c index afc38c7..2f5b687 100644 --- a/src/sccp2sua.c +++ b/src/sccp2sua.c @@ -330,7 +330,7 @@ static int sccp_addr_to_sua(struct xua_msg *xua, uint16_t iei, const uint8_t *ad if (rc < 0) return rc; - LOGP(DLSUA, LOGL_DEBUG, "Parsed Addr: %s\n", osmo_sccp_addr_dump(&osa)); + LOGP(DLSUA, LOGL_DEBUG, "IEI %u: Parsed Addr: %s\n", iei, osmo_sccp_addr_dump(&osa)); /* Then re-encode it as SUA address */ return xua_msg_add_sccp_addr(xua, iei, &osa); -- cgit v1.2.3 From 28c8a4bf2fbee013a2c82e19063940ec4cc80414 Mon Sep 17 00:00:00 2001 From: Neels Hofmeyr Date: Wed, 11 Jul 2018 02:58:00 +0200 Subject: add osmo_xua_msg_tall_ctx_init() So far the tall_xua ctx used to allocate from in xua_msg_alloc() was never initialized, actually hiding memory leaks from the talloc report. Add this API to allow branching the xua_msg ctx off a sane root ctx. Explicitly initialize tall_xua to NULL, so that, if xua_msg_ctx_init() isn't called, tall_xua is still guaranteed to not be a random pointer. osmo-bsc will use this function to hook the tall_xua ctx to osmo-bsc's own root ctx. Change-Id: I618878680a096a7f7fc2d83098590f2e4cb08870 --- include/osmocom/sigtran/xua_msg.h | 2 ++ src/xua_msg.c | 8 +++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/include/osmocom/sigtran/xua_msg.h b/include/osmocom/sigtran/xua_msg.h index 423adbc..e912e02 100644 --- a/include/osmocom/sigtran/xua_msg.h +++ b/include/osmocom/sigtran/xua_msg.h @@ -69,6 +69,8 @@ struct xua_msg_event_map { extern const struct xua_dialect xua_dialect_sua; extern const struct xua_dialect xua_dialect_m3ua; +void osmo_xua_msg_tall_ctx_init(void *ctx); + struct xua_msg *xua_msg_alloc(void); void xua_msg_free(struct xua_msg *msg); diff --git a/src/xua_msg.c b/src/xua_msg.c index d56009f..ed0cdc7 100644 --- a/src/xua_msg.c +++ b/src/xua_msg.c @@ -33,7 +33,13 @@ #include #include -static void *tall_xua; +static void *tall_xua = NULL; + +/* Allocate the root talloc context used for xua_msg_alloc(). */ +void osmo_xua_msg_tall_ctx_init(void *ctx) +{ + tall_xua = talloc_named_const(ctx, 0, "xua_msg"); +} struct xua_msg *xua_msg_alloc(void) { -- cgit v1.2.3 From bf4392c2baff6eac938edf71450f85ef48c311f6 Mon Sep 17 00:00:00 2001 From: Neels Hofmeyr Date: Wed, 11 Jul 2018 05:01:26 +0200 Subject: fix two memleaks in ipa_rx_msg_sccp() 1: Do not call xua_msg_alloc() which is later bluntly overwritten by m3ua_xfer_from_data(). 2: After dispatching to m3ua_hmdc_rx_from_l2(), call xua_msg_free(). Related: OS#3393 Change-Id: I0918f9bbc15b036619f1c25a133b69819b2a30fa --- src/ipa.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/ipa.c b/src/ipa.c index e15b1d8..f3a7a52 100644 --- a/src/ipa.c +++ b/src/ipa.c @@ -202,8 +202,9 @@ static struct msgb *patch_sccp_with_pc(struct osmo_ss7_asp *asp, struct msgb *sc static int ipa_rx_msg_sccp(struct osmo_ss7_asp *asp, struct msgb *msg) { + int rc; struct m3ua_data_hdr data_hdr; - struct xua_msg *xua = xua_msg_alloc(); + struct xua_msg *xua; struct osmo_ss7_as *as = find_as_for_asp(asp); uint32_t opc, dpc; @@ -263,7 +264,9 @@ static int ipa_rx_msg_sccp(struct osmo_ss7_asp *asp, struct msgb *msg) m3ua_dh_to_xfer_param(&xua->mtp, &data_hdr); /* Pass on as if we had received it from an M3UA ASP */ - return m3ua_hmdc_rx_from_l2(asp->inst, xua); + rc = m3ua_hmdc_rx_from_l2(asp->inst, xua); + xua_msg_free(xua); + return rc; } /*! \brief process M3UA message received from socket -- cgit v1.2.3 From 5a188137dc0dced617c2a4a0bf2e9484e7187be2 Mon Sep 17 00:00:00 2001 From: Neels Hofmeyr Date: Wed, 11 Jul 2018 05:23:05 +0200 Subject: comment: explain xua_msg free in m3ua_rx_xfer() Change-Id: I6211c8809eefeb94289c4c497553561b043ee619 --- src/m3ua.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/m3ua.c b/src/m3ua.c index f1fe3f1..d7ede40 100644 --- a/src/m3ua.c +++ b/src/m3ua.c @@ -584,6 +584,7 @@ static int m3ua_rx_xfer(struct osmo_ss7_asp *asp, struct xua_msg *xua) xua_msg_free_tag(xua, M3UA_IEI_ROUTE_CTX); return m3ua_hmdc_rx_from_l2(asp->inst, xua); + /* xua will be freed by caller m3ua_rx_msg() */ } static int m3ua_rx_mgmt_err(struct osmo_ss7_asp *asp, struct xua_msg *xua) -- cgit v1.2.3 From 118fc8a708c8053a808b3204d6254240ed2d4081 Mon Sep 17 00:00:00 2001 From: Stefan Sperling Date: Sat, 16 Jun 2018 11:30:47 +0200 Subject: sccp_demo_user: use point code 23 for server and 1 for client Fix previous commit 4dc9088cabedc40cb9072814237ad5926b12bd35 which broke this by using -1 for local and 23 for remote PC, for both server and client. Change-Id: I7432e6fc2617e0fd77a098fcd7d14abc40db7229 Related: OS#2666 --- examples/sccp_demo_user.c | 67 +++++++++++++++++++++++++++++++++-------------- 1 file changed, 48 insertions(+), 19 deletions(-) diff --git a/examples/sccp_demo_user.c b/examples/sccp_demo_user.c index f0b1a3e..9a9d6eb 100644 --- a/examples/sccp_demo_user.c +++ b/examples/sccp_demo_user.c @@ -82,12 +82,17 @@ static struct vty_app_info vty_info = { .version = 0, }; -#define DEFAULT_LOCAL_PC -1 -#define DEFAULT_LOCAL_ADDRESS "127.0.0.2" -#define DEFAULT_LOCAL_PORT M3UA_PORT -#define DEFAULT_REMOTE_PC 23 -#define DEFAULT_REMOTE_ADDRESS "127.0.0.1" -#define DEFAULT_REMOTE_PORT M3UA_PORT +#define DEFAULT_LOCAL_ADDRESS_SERVER "127.0.0.1" +#define DEFAULT_LOCAL_ADDRESS_CLIENT "127.0.0.2" +#define DEFAULT_REMOTE_ADDRESS_CLIENT DEFAULT_LOCAL_ADDRESS_SERVER +#define DEFAULT_REMOTE_ADDRESS_SERVER DEFAULT_LOCAL_ADDRESS_CLIENT +#define DEFAULT_LOCAL_PORT_SERVER M3UA_PORT +#define DEFAULT_LOCAL_PORT_CLIENT M3UA_PORT +#define DEFAULT_REMOTE_PORT_CLIENT DEFAULT_LOCAL_PORT_SERVER +#define DEFAULT_REMOTE_PORT_SERVER DEFAULT_LOCAL_PORT_CLIENT +#define DEFAULT_REMOTE_PORT_SERVER_STR DEFAULT_LOCAL_PORT_CLIENT_STR +#define DEFAULT_PC_SERVER 1 +#define DEFAULT_PC_CLIENT 23 static void usage(void) { fprintf(stderr, "sccp_demo_user [-c] [-l LOCAL_ADDRESS[:LOCAL_PORT]]\n" @@ -95,13 +100,18 @@ static void usage(void) { " [-L LOCAL_POINT_CODE] [-R REMOTE_POINT_CODE]\n" "Options:\n" " -c: Run in client mode (default is server mode)\n" - " -l: local IP address and SCTP port (default is %s:%d)\n" - " -r: remote IP address and SCTP port (default is %s:%d)\n" - " -L: local point code (default is %d)\n" - " -R: remote point code (default is %d)\n", - DEFAULT_LOCAL_ADDRESS, DEFAULT_LOCAL_PORT, - DEFAULT_REMOTE_ADDRESS, DEFAULT_REMOTE_PORT, - DEFAULT_LOCAL_PC, DEFAULT_REMOTE_PC); + " -l: local IP address and SCTP port (default is %s:%d in server mode,\n" + " %s:%d in client mode)\n" + " -r: remote IP address and SCTP port (default is %s:%d in server mode,\n" + " %s:%d in client mode)\n" + " -L: local point code (default is %d in server mode, %d in client mode)\n" + " -R: remote point code (default is %d in server mode, %d in client mode)\n", + DEFAULT_LOCAL_ADDRESS_SERVER, DEFAULT_LOCAL_PORT_SERVER, + DEFAULT_LOCAL_ADDRESS_CLIENT, DEFAULT_LOCAL_PORT_CLIENT, + DEFAULT_REMOTE_ADDRESS_SERVER, DEFAULT_REMOTE_PORT_SERVER, + DEFAULT_REMOTE_ADDRESS_CLIENT, DEFAULT_REMOTE_PORT_CLIENT, + DEFAULT_PC_SERVER, DEFAULT_PC_CLIENT, + DEFAULT_PC_CLIENT, DEFAULT_PC_SERVER); exit(1); } @@ -151,25 +161,42 @@ int main(int argc, char **argv) { bool client = false; int rc, ch; - char *local_address = DEFAULT_LOCAL_ADDRESS; - int local_port = DEFAULT_LOCAL_PORT; - int local_pc = DEFAULT_LOCAL_PC; - char *remote_address = DEFAULT_REMOTE_ADDRESS; - int remote_port = DEFAULT_LOCAL_PORT; - int remote_pc = DEFAULT_REMOTE_PC; + char *local_address = DEFAULT_LOCAL_ADDRESS_SERVER; + int local_port = DEFAULT_LOCAL_PORT_SERVER; + int local_pc = DEFAULT_PC_SERVER; + char *remote_address = DEFAULT_REMOTE_ADDRESS_SERVER; + int remote_port = DEFAULT_REMOTE_PORT_SERVER; + int remote_pc = DEFAULT_PC_CLIENT; + bool lflag = false, rflag = false, Lflag = false, Rflag = false; while ((ch = getopt(argc, argv, "cl:r:p:L:R:")) != -1) { switch (ch) { case 'c': client = true; + + /* Set client-mode defaults unless already overridden during option parsing. */ + if (!lflag) { + local_address = DEFAULT_LOCAL_ADDRESS_CLIENT; + local_port = DEFAULT_LOCAL_PORT_CLIENT; + } + if (!Lflag) + local_pc = DEFAULT_PC_CLIENT; + if (!rflag) { + remote_address = DEFAULT_REMOTE_ADDRESS_CLIENT; + remote_port = DEFAULT_REMOTE_PORT_CLIENT; + } + if (!Rflag) + remote_pc = DEFAULT_PC_SERVER; break; case 'l': if (parse_address_port(&local_address, &local_port, optarg)) exit(1); + lflag = true; break; case 'r': if (parse_address_port(&remote_address, &remote_port, optarg)) exit(1); + rflag = true; break; case 'L': if (!is_decimal_string(optarg)) { @@ -177,6 +204,7 @@ int main(int argc, char **argv) exit(1); } local_pc = atoi(optarg); + Lflag = true; break; case 'R': if (!is_decimal_string(optarg)) { @@ -184,6 +212,7 @@ int main(int argc, char **argv) exit(1); } remote_pc = atoi(optarg); + Rflag = true; break; default: usage(); -- cgit v1.2.3 From b3d32cd25efc05f1b6a2266767070b14e6d8966f Mon Sep 17 00:00:00 2001 From: Stefan Sperling Date: Fri, 20 Jul 2018 13:40:05 +0200 Subject: remove unused -p option from getopt() call in sccp_demo_user Change-Id: I31f30d8c855cb5faf3173987bfe5b36f5a585d02 Depends: I7432e6fc2617e0fd77a098fcd7d14abc40db7229 --- examples/sccp_demo_user.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/sccp_demo_user.c b/examples/sccp_demo_user.c index 9a9d6eb..28dd166 100644 --- a/examples/sccp_demo_user.c +++ b/examples/sccp_demo_user.c @@ -169,7 +169,7 @@ int main(int argc, char **argv) int remote_pc = DEFAULT_PC_CLIENT; bool lflag = false, rflag = false, Lflag = false, Rflag = false; - while ((ch = getopt(argc, argv, "cl:r:p:L:R:")) != -1) { + while ((ch = getopt(argc, argv, "cl:r:L:R:")) != -1) { switch (ch) { case 'c': client = true; -- cgit v1.2.3 From 6265190fc611e468cebadb4eaf41ceb2f7e2095b Mon Sep 17 00:00:00 2001 From: Daniel Willmann Date: Tue, 24 Jul 2018 17:51:58 +0200 Subject: git-version-gen: Don't check for .git directory This check is not in all our repos that use git-version-gen. Indeed it seems to be a leftover of openbsc where I think it wanted to ensure being called in the openbsc subfolder or something? libosmocore e.g. doesn't have it. In any case .git being a directory is not always true (if using git worktree) so remove this check. Change-Id: Ic14561f3b041bb94d1b60e477b18e37077ce4c32 --- git-version-gen | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/git-version-gen b/git-version-gen index 8e59c5a..42cf3d2 100755 --- a/git-version-gen +++ b/git-version-gen @@ -92,8 +92,8 @@ fi if test -n "$v" then : # use $v -elif test -d ./.git \ - && v=`git describe --abbrev=4 --match='v*' HEAD 2>/dev/null \ +elif + v=`git describe --abbrev=4 --match='v*' HEAD 2>/dev/null \ || git describe --abbrev=4 HEAD 2>/dev/null` \ && case $v in [0-9]*) ;; -- cgit v1.2.3 From 688f2304056029f47073a549d7e41043eab5a0fd Mon Sep 17 00:00:00 2001 From: Pau Espin Pedrol Date: Fri, 27 Jul 2018 18:45:40 +0200 Subject: =?UTF-8?q?Bump=20version:=200.9.0.20-6265-dirty=20=E2=86=92=200.1?= =?UTF-8?q?0.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Ia087b9f03a73a08f0eaa461f61c6244aaf13e3d4 --- configure.ac | 8 ++++---- debian/changelog | 34 ++++++++++++++++++++++++++++++++++ debian/control | 4 ++-- src/Makefile.am | 2 +- 4 files changed, 41 insertions(+), 7 deletions(-) diff --git a/configure.ac b/configure.ac index ff9a1c4..c0cc488 100644 --- a/configure.ac +++ b/configure.ac @@ -29,10 +29,10 @@ if test "x$PKG_CONFIG_INSTALLED" = "xno"; then fi PKG_PROG_PKG_CONFIG([0.20]) -PKG_CHECK_MODULES(LIBOSMOCORE, libosmocore >= 0.11.0) -PKG_CHECK_MODULES(LIBOSMOVTY, libosmovty >= 0.11.0) -PKG_CHECK_MODULES(LIBOSMOGSM, libosmogsm >= 0.11.0) -PKG_CHECK_MODULES(LIBOSMONETIF, libosmo-netif >= 0.2.0) +PKG_CHECK_MODULES(LIBOSMOCORE, libosmocore >= 0.12.0) +PKG_CHECK_MODULES(LIBOSMOVTY, libosmovty >= 0.12.0) +PKG_CHECK_MODULES(LIBOSMOGSM, libosmogsm >= 0.12.0) +PKG_CHECK_MODULES(LIBOSMONETIF, libosmo-netif >= 0.3.0) old_LIBS=$LIBS AC_SEARCH_LIBS([sctp_send], [sctp], [ diff --git a/debian/changelog b/debian/changelog index 9d582a3..135d08e 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,37 @@ +libosmo-sccp (0.10.0) unstable; urgency=medium + + [ Harald Welte ] + * debian/control: match build dependency versions with configure.ac + * osmo_ss7: Register 5000 as default port for IPA/SCCPlite + * Introduce osmo_ss7_register_rx_unknown_cb() for unknown PPID/StreamID + + [ Stefan Sperling ] + * free msgb for primitive allocated in lm_timer_cb() of lm_fsm + * fix infinite recursion with routing by global title + * fix use after free in osmo_sccp_simple_server_add_clnt() + * make it possible to pass parameters to m3ua_example + * rename m3ua_example to sccp_demo_user + * sccp_demo_user: use point code 23 for server and 1 for client + * remove unused -p option from getopt() call in sccp_demo_user + + [ Pau Espin Pedrol ] + * tests: xua_test: Fix use of wrong buffer for dest addr + * tests: xua_test: Fix array len computation + * build: Install example cfg files + * debian: Package installed example doc files + + [ Neels Hofmeyr ] + * fix memleak in ipa_rx_msg_sccp + * cosmetic: sccp2sua.c: log the IEI for parsed SCCP addr + * add osmo_xua_msg_tall_ctx_init() + * fix two memleaks in ipa_rx_msg_sccp() + * comment: explain xua_msg free in m3ua_rx_xfer() + + [ Daniel Willmann ] + * git-version-gen: Don't check for .git directory + + -- Pau Espin Pedrol Fri, 27 Jul 2018 18:45:39 +0200 + libosmo-sccp (0.9.0) unstable; urgency=medium [ Neels Hofmeyr ] diff --git a/debian/control b/debian/control index b1949cd..8680bba 100644 --- a/debian/control +++ b/debian/control @@ -5,7 +5,7 @@ Priority: optional Build-Depends: debhelper (>= 9), autotools-dev, pkg-config, - libosmocore-dev (>= 0.11.0), + libosmocore-dev (>= 0.12.0), autoconf, automake, libtool, @@ -13,7 +13,7 @@ Build-Depends: debhelper (>= 9), git, doxygen, libdpkg-perl, - libosmo-netif-dev (>= 0.2.0), + libosmo-netif-dev (>= 0.3.0), libsctp-dev Standards-Version: 3.9.7 Vcs-Git: git://git.osmocom.org/libosmo-sccp.git diff --git a/src/Makefile.am b/src/Makefile.am index 3af23d1..9cea642 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -25,7 +25,7 @@ lib_LTLIBRARIES = libosmo-sigtran.la # This is _NOT_ the library release version, it's an API version. # Please read Chapter 6 "Library interface versions" of the libtool # documentation before making any modification -LIBVERSION=1:0:1 +LIBVERSION=2:0:2 libosmo_sigtran_la_SOURCES = sccp_sap.c sua.c m3ua.c xua_msg.c sccp_helpers.c \ sccp2sua.c sccp_scrc.c sccp_sclc.c sccp_scoc.c \ -- cgit v1.2.3 From 1a0d15305d4c973949d3f9491bd42d170d670900 Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Wed, 1 Aug 2018 13:34:08 +0200 Subject: Migrate from ipa_ccm_idtag_parse() to ipa_ccm_id_resp_parse() In libosmocore Change-ID I1834d90fbcdbfcb05f5b8cfe39bfe9543737ef8f we have introduced ipa_ccm_id_resp_parse() as a bugfixed replacement of ipa_ccm_idtag_parse(). The main difference is that the returned "value" parts now have a correct reported "length", whereas before this commit they all reported a one-byte too-long "length" for each IE. Change-Id: I3c79d3bb56cc1370b9922e64d13d2d5508fd8039 --- src/xua_asp_fsm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/xua_asp_fsm.c b/src/xua_asp_fsm.c index 93c76cb..78a4f25 100644 --- a/src/xua_asp_fsm.c +++ b/src/xua_asp_fsm.c @@ -806,7 +806,7 @@ static void ipa_asp_fsm_wait_id_resp(struct osmo_fsm_inst *fi, uint32_t event, v case IPA_ASP_E_ID_RESP: /* resolve the AS based on the identity provided by peer. */ msg = data; - rc = ipa_ccm_idtag_parse(&tp, msgb_l2(msg)+2, msgb_l2len(msg)-2); + rc = ipa_ccm_id_resp_parse(&tp, msgb_l2(msg)+1, msgb_l2len(msg)-1); if (rc < 0) { LOGPFSML(fi, LOGL_ERROR, "Error %d parsing ID_RESP TLV: %s\n", rc, msgb_hexdump(msg)); -- cgit v1.2.3 From c3b1f636c94c01bf190713e2d17e2ffd1a58be9a Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Mon, 6 Aug 2018 11:12:33 +0200 Subject: debian/rules: Don't overwrite .tarball-version The .tarball-version file should contain the *source version* uniquely identifying the git commit, and not the Debian package name. With https://gerrit.osmocom.org/#/c/osmo-ci/+/10343/ there is a correct .tarball-version file in the .tar.xz of the nightly source packages. Change-Id: I620c96eb311be6fdd4187bdcc311ea893ad93614 Related: OS#3449 --- debian/rules | 4 ---- 1 file changed, 4 deletions(-) diff --git a/debian/rules b/debian/rules index 279568f..bea0a76 100755 --- a/debian/rules +++ b/debian/rules @@ -23,10 +23,6 @@ override_dh_install: override_dh_auto_test: dh_auto_test || (find . -name testsuite.log -exec cat {} \; ; false) -override_dh_autoreconf: - echo $(VERSION) > .tarball-version - dh_autoreconf - override_dh_auto_configure: dh_auto_configure -- --enable-static -- cgit v1.2.3 From 9c3baa89fb6b3fc1ef588930f361d013f98a1e39 Mon Sep 17 00:00:00 2001 From: Pau Espin Pedrol Date: Mon, 13 Aug 2018 17:24:41 +0200 Subject: sscp_scrc: Fix memleak of xua_msg when handing it to scrc_rx_mtp_xfer_ind_xua Fixes following error provided by LeakSanitizer: Indirect leak of 1496 byte(s) in 11 object(s) allocated from: #0 0x7f1eb3332d99 in __interceptor_malloc /build/gcc/src/gcc/libsanitizer/asan/asan_malloc_linux.cc:86 #1 0x7f1eae617b61 in _talloc_zero (/usr/lib/libtalloc.so.2+0x5b61) #2 0x7f1eb063e365 in xua_msg_alloc /home/pespin/dev/sysmocom/git/libosmo-sccp/src/xua_msg.c:49 #3 0x7f1eb0650ee3 in osmo_sccp_to_xua /home/pespin/dev/sysmocom/git/libosmo-sccp/src/sccp2sua.c:1298 #4 0x7f1eb0668d6a in mtp_user_prim_cb /home/pespin/dev/sysmocom/git/libosmo-sccp/src/sccp_user.c:173 #5 0x7f1eb068ba86 in deliver_to_mtp_user /home/pespin/dev/sysmocom/git/libosmo-sccp/src/osmo_ss7_hmrt.c:94 #6 0x7f1eb068bf00 in hmdt_message_for_distribution /home/pespin/dev/sysmocom/git/libosmo-sccp/src/osmo_ss7_hmrt.c:133 #7 0x7f1eb068d345 in m3ua_hmdc_rx_from_l2 /home/pespin/dev/sysmocom/git/libosmo-sccp/src/osmo_ss7_hmrt.c:275 #8 0x7f1eb063c08f in m3ua_rx_xfer /home/pespin/dev/sysmocom/git/libosmo-sccp/src/m3ua.c:586 #9 0x7f1eb063cea6 in m3ua_rx_msg /home/pespin/dev/sysmocom/git/libosmo-sccp/src/m3ua.c:739 #10 0x7f1eb0687188 in xua_cli_read_cb /home/pespin/dev/sysmocom/git/libosmo-sccp/src/osmo_ss7.c:1590 #11 0x7f1eaff77db4 in osmo_stream_cli_read /home/pespin/dev/sysmocom/git/libosmo-netif/src/stream.c:192 #12 0x7f1eaff79091 in osmo_stream_cli_fd_cb /home/pespin/dev/sysmocom/git/libosmo-netif/src/stream.c:276 #13 0x7f1eaf259795 in osmo_fd_disp_fds /home/pespin/dev/sysmocom/git/libosmocore/src/select.c:217 #14 0x7f1eaf259abb in osmo_select_main /home/pespin/dev/sysmocom/git/libosmocore/src/select.c:257 #15 0x55666c1bebd3 in main /home/pespin/dev/sysmocom/git/osmo-msc/src/osmo-msc/msc_main.c:697 #16 0x7f1ead1c306a in __libc_start_main (/usr/lib/libc.so.6+0x2306a) #17 0x55666c1bc649 in _start (/home/pespin/dev/sysmocom/build/new/out/bin/osmo-msc+0x185649) The code path is the following, starting from mpt_user_prim_cb: mtp_user_prim_cb osmo_sccp_to_xua xua_msg_alloc scrc_rx_mtp_xfer_ind_xua sccp_scoc_rx_from_scrc scrc_node_6 scrc_node_4 scrc_translate_node_9 So the xua_msg is created in mtp_user_prim_cb through osmo_sccp_to_xua and then handed over to scrc_rx_mtp_xfer_ind_xua which transfers the xua_msg and thus should take ownserhip of it, and consecuently freeing it once it's done using it. Change-Id: I43e159c82b64bd85b185f77ee19b6455a96e082f --- src/sccp_scrc.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/sccp_scrc.c b/src/sccp_scrc.c index cd01774..9005dc7 100644 --- a/src/sccp_scrc.c +++ b/src/sccp_scrc.c @@ -438,13 +438,14 @@ int sccp_scrc_rx_sclc_msg(struct osmo_sccp_instance *inst, } /* Figure C.1/Q.714 Sheet 1 of 12, after we converted the - * MTP-TRANSFER.ind to SUA */ + * MTP-TRANSFER.ind to SUA. Takes ownership of \a xua and frees it once processed. */ int scrc_rx_mtp_xfer_ind_xua(struct osmo_sccp_instance *inst, struct xua_msg *xua) { struct osmo_sccp_addr called; uint32_t proto_class; struct xua_msg_part *hop_ctr_part; + int rc; LOGP(DLSS7, LOGL_DEBUG, "%s: %s\n", __func__, xua_msg_dump(xua, &xua_dialect_sua)); /* TODO: SCCP or nodal congestion? */ @@ -454,6 +455,7 @@ int scrc_rx_mtp_xfer_ind_xua(struct osmo_sccp_instance *inst, /* Node 1 (Sheet 3) */ /* deliver to SCOC */ sccp_scoc_rx_from_scrc(inst, xua); + xua_msg_free(xua); return 0; } /* We only treat connectionless and CR below */ @@ -463,7 +465,9 @@ int scrc_rx_mtp_xfer_ind_xua(struct osmo_sccp_instance *inst, /* Route on GT? */ if (called.ri != OSMO_SCCP_RI_GT) { /* Node 6 (Sheet 3) */ - return scrc_node_6(inst, xua, &called); + rc = scrc_node_6(inst, xua, &called); + xua_msg_free(xua); + return rc; } /* Message with hop-counter? */ hop_ctr_part = xua_msg_find_tag(xua, SUA_IEI_S7_HOP_CTR); @@ -472,7 +476,9 @@ int scrc_rx_mtp_xfer_ind_xua(struct osmo_sccp_instance *inst, if (hop_counter <= 1) { /* Error: hop-counter violation */ /* node 4 */ - return scrc_node_4(inst, xua, SCCP_RETURN_CAUSE_HOP_COUNTER_VIOLATION); + rc = scrc_node_4(inst, xua, SCCP_RETURN_CAUSE_HOP_COUNTER_VIOLATION); + xua_msg_free(xua); + return rc; } /* Decrement hop-counter */ hop_counter--; @@ -492,5 +498,7 @@ int scrc_rx_mtp_xfer_ind_xua(struct osmo_sccp_instance *inst, default: break; } - return scrc_translate_node_9(inst, xua, &called); + rc = scrc_translate_node_9(inst, xua, &called); + xua_msg_free(xua); + return rc; } -- cgit v1.2.3 From 39fdaf62ba724c1e343ab281911ba844b6b88989 Mon Sep 17 00:00:00 2001 From: Pau Espin Pedrol Date: Mon, 13 Aug 2018 17:51:35 +0200 Subject: xua_rkm: Fix xua_msg memleank in handle_rkey_reg_resp From LeakSanitizer report: Indirect leak of 384 byte(s) in 3 object(s) allocated from: #0 0x7f986da27d99 in __interceptor_malloc /build/gcc/src/gcc/libsanitizer/asan/asan_malloc_linux.cc:86 #1 0x7f9868d0cb61 in _talloc_zero (/usr/lib/libtalloc.so.2+0x5b61) #2 0x7f986ad33766 in xua_msg_add_data /home/pespin/dev/sysmocom/git/libosmo-sccp/src/xua_msg.c:73 #3 0x7f986ad343c3 in xua_from_msg_common /home/pespin/dev/sysmocom/git/libosmo-sccp/src/xua_msg.c:143 #4 0x7f986ad347d2 in xua_from_nested /home/pespin/dev/sysmocom/git/libosmo-sccp/src/xua_msg.c:201 #5 0x7f986ad65563 in m3ua_rx_rkm_reg_rsp /home/pespin/dev/sysmocom/git/libosmo-sccp/src/xua_rkm.c:431 #6 0x7f986ad65f96 in m3ua_rx_rkm /home/pespin/dev/sysmocom/git/libosmo-sccp/src/xua_rkm.c:510 #7 0x7f986ad31ef7 in m3ua_rx_msg /home/pespin/dev/sysmocom/git/libosmo-sccp/src/m3ua.c:749 #8 0x7f986ad7c1e8 in xua_cli_read_cb /home/pespin/dev/sysmocom/git/libosmo-sccp/src/osmo_ss7.c:1590 #9 0x7f986a66cdb4 in osmo_stream_cli_read /home/pespin/dev/sysmocom/git/libosmo-netif/src/stream.c:192 #10 0x7f986a66e091 in osmo_stream_cli_fd_cb /home/pespin/dev/sysmocom/git/libosmo-netif/src/stream.c:276 #11 0x7f986994e795 in osmo_fd_disp_fds /home/pespin/dev/sysmocom/git/libosmocore/src/select.c:217 #12 0x7f986994eabb in osmo_select_main /home/pespin/dev/sysmocom/git/libosmocore/src/select.c:257 #13 0x5630cb294bd3 in main /home/pespin/dev/sysmocom/git/osmo-msc/src/osmo-msc/msc_main.c:697 #14 0x7f98678b806a in __libc_start_main (/usr/lib/libc.so.6+0x2306a) #15 0x5630cb292649 in _start (/home/pespin/dev/sysmocom/build/new/out/bin/osmo-msc+0x185649) Following code paths: m3ua_rx_rkm_reg_rsp xua_from_nested xua_from_msg_common xua_msg_add_data talloc_zero (part) handle_rkey_reg_resp Take the chance to fix the same issue in m3ua_rx_rkm_dereg_rsp. Change-Id: I0b15d81099a9f8274b7e39962caa339da644e0dc --- src/xua_rkm.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/xua_rkm.c b/src/xua_rkm.c index b79f7f3..a77460d 100644 --- a/src/xua_rkm.c +++ b/src/xua_rkm.c @@ -433,6 +433,7 @@ static int m3ua_rx_rkm_reg_rsp(struct osmo_ss7_asp *asp, struct xua_msg *xua) continue; handle_rkey_reg_resp(asp, inner); + xua_msg_free(inner); } return 0; } @@ -485,6 +486,7 @@ static int m3ua_rx_rkm_dereg_rsp(struct osmo_ss7_asp *asp, struct xua_msg *xua) continue; handle_rkey_dereg_resp(asp, inner); + xua_msg_free(inner); } return 0; } -- cgit v1.2.3 From a0dd986f5506ee8a625e827bc029d1aa962b6f65 Mon Sep 17 00:00:00 2001 From: Neels Hofmeyr Date: Tue, 10 Jul 2018 17:22:03 +0200 Subject: ipa_asp_fsm: init: expect IPA ID ACK, not GET Testing with an actual SCCPlite MSC, I see the IPA connection starting out by the MSC sending an IPA ID ACK. Make the ipa_asp_fsm match that. Change-Id: Icffda98579e676ab6ca63c9c22cf5d151c4fe95f --- src/xua_asp_fsm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/xua_asp_fsm.c b/src/xua_asp_fsm.c index 78a4f25..d6edac0 100644 --- a/src/xua_asp_fsm.c +++ b/src/xua_asp_fsm.c @@ -785,7 +785,7 @@ static void ipa_asp_fsm_down(struct osmo_fsm_inst *fi, uint32_t event, void *dat } } else { /* Client: We simply wait for an ID GET */ - osmo_fsm_inst_state_chg(fi, IPA_ASP_S_WAIT_ID_GET, 10, T_WAIT_ID_GET); + osmo_fsm_inst_state_chg(fi, IPA_ASP_S_WAIT_ID_ACK, 10, T_WAIT_ID_ACK); } break; } @@ -985,7 +985,7 @@ static const struct osmo_fsm_state ipa_asp_states[] = { [IPA_ASP_S_DOWN] = { .in_event_mask = S(XUA_ASP_E_M_ASP_UP_REQ) | S(XUA_ASP_E_SCTP_EST_IND), - .out_state_mask = S(IPA_ASP_S_WAIT_ID_GET) | + .out_state_mask = S(IPA_ASP_S_WAIT_ID_ACK) | S(IPA_ASP_S_WAIT_ID_RESP), .name = "ASP_DOWN", .action = ipa_asp_fsm_down, -- cgit v1.2.3