aboutsummaryrefslogtreecommitdiffstats
path: root/tests/gb/gprs_ns_test.c
diff options
context:
space:
mode:
authorJacob Erlbeck <jerlbeck@sysmocom.de>2013-10-09 11:27:04 +0200
committerHolger Hans Peter Freyther <holger@moiji-mobile.com>2013-10-11 14:41:40 +0200
commit34fc4701c7681a4855534c20a6f59d12c4c81521 (patch)
treea4911e712727211828200038bd1439b7bb0a5069 /tests/gb/gprs_ns_test.c
parent2c9168cf34d370b4ea2b21177402d01a7cfffea8 (diff)
tests/gb: Show invoked signals in test output
Register an osmo signal handler to print a short notice about every SS_L_NS signal that is generated while processing the tests. Sponsored-by: On-Waves ehf
Diffstat (limited to 'tests/gb/gprs_ns_test.c')
-rw-r--r--tests/gb/gprs_ns_test.c47
1 files changed, 46 insertions, 1 deletions
diff --git a/tests/gb/gprs_ns_test.c b/tests/gb/gprs_ns_test.c
index d07cc3de..c4fc228a 100644
--- a/tests/gb/gprs_ns_test.c
+++ b/tests/gb/gprs_ns_test.c
@@ -20,11 +20,11 @@
#include <osmocom/core/utils.h>
#include <osmocom/core/logging.h>
#include <osmocom/core/talloc.h>
+#include <osmocom/core/signal.h>
#include <osmocom/gprs/gprs_msgb.h>
#include <osmocom/gprs/gprs_ns.h>
#include <osmocom/gprs/gprs_bssgp.h>
-
/* GPRS Network Service, PDU type: NS_RESET,
* Cause: O&M intervention, NS VCI: 0x1122, NSEI 0x1122
*/
@@ -121,6 +121,50 @@ ssize_t sendto(int sockfd, const void *buf, size_t len, int flags,
return len;
}
+/* Signal handler for signals from NS layer */
+static int test_signal(unsigned int subsys, unsigned int signal,
+ void *handler_data, void *signal_data)
+{
+ struct ns_signal_data *nssd = signal_data;
+
+ if (subsys != SS_L_NS)
+ return 0;
+
+ switch (signal) {
+ case S_NS_RESET:
+ printf("==> got signal NS_RESET, NS-VC 0x%04x/%s\n",
+ nssd->nsvc->nsvci,
+ gprs_ns_format_peer(nssd->nsvc));
+ break;
+
+ case S_NS_ALIVE_EXP:
+ printf("==> got signal NS_ALIVE_EXP, NS-VC 0x%04x/%s\n",
+ nssd->nsvc->nsvci,
+ gprs_ns_format_peer(nssd->nsvc));
+ break;
+
+ case S_NS_BLOCK:
+ printf("==> got signal NS_BLOCK, NS-VC 0x%04x/%s\n",
+ nssd->nsvc->nsvci,
+ gprs_ns_format_peer(nssd->nsvc));
+ break;
+
+ case S_NS_UNBLOCK:
+ printf("==> got signal NS_UNBLOCK, NS-VC 0x%04x/%s\n",
+ nssd->nsvc->nsvci,
+ gprs_ns_format_peer(nssd->nsvc));
+ break;
+
+ default:
+ printf("==> got signal %d, NS-VC 0x%04x/%s\n", signal,
+ nssd->nsvc->nsvci,
+ gprs_ns_format_peer(nssd->nsvc));
+ break;
+ }
+
+ return 0;
+}
+
static int gprs_process_message(struct gprs_ns_inst *nsi, const char *text, struct sockaddr_in *peer, const unsigned char* data, size_t data_len)
{
struct msgb *msg;
@@ -238,6 +282,7 @@ int main(int argc, char **argv)
osmo_init_logging(&info);
log_set_use_color(osmo_stderr_target, 0);
log_set_print_filename(osmo_stderr_target, 0);
+ osmo_signal_register_handler(SS_L_NS, &test_signal, NULL);
printf("===== NS protocol test START\n");
test_ns();