From daf753477e52f744de428a64e68462e3f898f31c Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Mon, 26 Jul 2010 20:01:07 +0800 Subject: [PATCH] gsm_04_80: Add untested code for USSD notification... One should be able to send a USSD Notification to a given subscriber if we has an active link... --- openbsc/include/openbsc/gsm_04_80.h | 2 ++ openbsc/src/gsm_04_80.c | 20 +++++++++++++ openbsc/src/vty_interface_layer3.c | 44 +++++++++++++++++++++++++++++ 3 files changed, 66 insertions(+) diff --git a/openbsc/include/openbsc/gsm_04_80.h b/openbsc/include/openbsc/gsm_04_80.h index e0a7c3623..8215ca736 100644 --- a/openbsc/include/openbsc/gsm_04_80.h +++ b/openbsc/include/openbsc/gsm_04_80.h @@ -29,4 +29,6 @@ struct msgb *gsm0480_create_unstructuredSS_Notify(const char *text); int gsm0480_wrap_invoke(struct msgb *msg, int op, int link_id); int gsm0480_wrap_facility(struct msgb *msg); +int gsm0480_send_ussdNotify(struct gsm_subscriber_connection *conn, const char *text); + #endif diff --git a/openbsc/src/gsm_04_80.c b/openbsc/src/gsm_04_80.c index 462d9789e..135582d1d 100644 --- a/openbsc/src/gsm_04_80.c +++ b/openbsc/src/gsm_04_80.c @@ -449,3 +449,23 @@ int gsm0480_send_ussd_reject(struct gsm_subscriber_connection *conn, return gsm0808_submit_dtap(conn, msg, 0); } + +int gsm0480_send_ussdNotify(struct gsm_subscriber_connection *conn, const char *text) +{ + struct gsm48_hdr *gh; + struct msgb *msg; + + msg = gsm0480_create_unstructuredSS_Notify(text); + if (!msg) + return -1; + + gsm0480_wrap_invoke(msg, GSM0480_OP_CODE_USS_NOTIFY, 0); + gsm0480_wrap_facility(msg); + + /* And finally pre-pend the L3 header */ + gh = (struct gsm48_hdr *) msgb_push(msg, sizeof(*gh)); + gh->proto_discr = GSM48_PDISC_NC_SS; + gh->msg_type = GSM0480_MTYPE_REGISTER; + + return gsm0808_submit_dtap(conn, msg, 0); +} diff --git a/openbsc/src/vty_interface_layer3.c b/openbsc/src/vty_interface_layer3.c index 157260a59..34e61bb5b 100644 --- a/openbsc/src/vty_interface_layer3.c +++ b/openbsc/src/vty_interface_layer3.c @@ -42,6 +42,8 @@ #include #include #include +#include +#include extern struct gsm_network *gsmnet_from_vty(struct vty *v); @@ -371,6 +373,47 @@ DEFUN(subscriber_silent_call_stop, return CMD_SUCCESS; } +DEFUN(subscriber_ussd_notify, + subscriber_ussd_notify_cmd, + "subscriber " SUBSCR_TYPES " ID ussd-notify .TEXT", + SUBSCR_HELP "USSD Notify\n" + "Subscriber ID\n" + "Text Message to send\n") +{ + char *text; + struct gsm_subscriber_connection *conn; + struct gsm_network *gsmnet = gsmnet_from_vty(vty); + struct gsm_subscriber *subscr = get_subscr_by_argv(gsmnet, argv[0], argv[1]); + int rc; + + if (!subscr) { + vty_out(vty, "%% No subscriber found for %s %s%s", + argv[0], argv[1], VTY_NEWLINE); + return CMD_WARNING; + } + + text = argv_concat(argv, argc, 2); + if (!text) { + subscr_put(subscr); + return CMD_WARNING; + } + + conn = connection_for_subscr(subscr); + if (!conn) { + vty_out(vty, "%% An active connection is required for %s %s%s", + argv[0], argv[1], VTY_NEWLINE); + subscr_put(subscr); + talloc_free(text); + return CMD_WARNING; + } + + gsm0480_send_ussdNotify(conn, text); + + subscr_put(subscr); + talloc_free(text); + return CMD_SUCCESS; +} + DEFUN(ena_subscr_authorizde, ena_subscr_authorized_cmd, "subscriber " SUBSCR_TYPES " ID authorized (0|1)", @@ -582,6 +625,7 @@ int bsc_vty_init_extra(void) install_element_ve(&subscriber_silent_sms_cmd); install_element_ve(&subscriber_silent_call_start_cmd); install_element_ve(&subscriber_silent_call_stop_cmd); + install_element_ve(&subscriber_ussd_notify_cmd); install_element_ve(&show_stats_cmd); install_element(ENABLE_NODE, &ena_subscr_name_cmd);