From patchwork Thu Jul 9 19:02:23 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max X-Patchwork-Id: 493521 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.osmocom.org (unknown [IPv6:2a01:4f8:191:444b::2:7]) by ozlabs.org (Postfix) with ESMTP id 227661402B8 for ; Fri, 10 Jul 2015 05:11:59 +1000 (AEST) Received: from lists.osmocom.org (lists.osmocom.org [144.76.43.76]) by lists.osmocom.org (Postfix) with ESMTP id 5C3FB7621; Thu, 9 Jul 2015 19:11:56 +0000 (UTC) X-Original-To: openbsc@lists.osmocom.org Delivered-To: openbsc@lists.osmocom.org X-Greylist: delayed 525 seconds by postgrey-1.34 at lists.osmocom.org; Thu, 09 Jul 2015 19:11:54 UTC Received: from hylle05.itea.ntnu.no (hylle05.itea.ntnu.no [IPv6:2001:700:300:3::225]) by lists.osmocom.org (Postfix) with ESMTP id DF2877618 for ; Thu, 9 Jul 2015 19:11:54 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by hylle05.itea.ntnu.no (Postfix) with ESMTP id 013F9913A8C for ; Thu, 9 Jul 2015 21:03:08 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at hylle05.itea.ntnu.no Received: from alumnimail01.it.ntnu.no (unknown [IPv6:2001:700:300:4::54]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hylle05.itea.ntnu.no (Postfix) with ESMTPS id 1878D913A88 for ; Thu, 9 Jul 2015 21:03:07 +0200 (CEST) Received: from localhost (dslb-094-223-143-244.094.223.pools.vodafone-ip.de [94.223.143.244]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) (Authenticated sender: suraev) by alumnimail01.it.ntnu.no (Postfix) with ESMTPSA id C391C55260 for ; Thu, 9 Jul 2015 21:03:06 +0200 (CEST) From: Max To: openbsc@lists.osmocom.org Subject: [PATCH 3/4] SS: add Return Error component Date: Thu, 9 Jul 2015 21:02:23 +0200 Message-Id: <1436468544-20989-3-git-send-email-max.suraev@fairwaves.co> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1436468544-20989-1-git-send-email-max.suraev@fairwaves.co> References: <1436468544-20989-1-git-send-email-max.suraev@fairwaves.co> X-BeenThere: openbsc@lists.osmocom.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Development of the OpenBSC GSM base station controller List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: openbsc-bounces@lists.osmocom.org Sender: "OpenBSC" Signed-off-by: Max --- openbsc/include/openbsc/gsm_04_80.h | 4 ++++ openbsc/src/libmsc/gsm_04_80.c | 36 ++++++++++++++++++++++++++++++++++-- 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/openbsc/include/openbsc/gsm_04_80.h b/openbsc/include/openbsc/gsm_04_80.h index 7139f95..20ec3ab 100644 --- a/openbsc/include/openbsc/gsm_04_80.h +++ b/openbsc/include/openbsc/gsm_04_80.h @@ -39,6 +39,10 @@ int gsm0480_send_ss_reject(struct gsm_subscriber_connection *conn, const struct ss_request *request, uint8_t problem_category, uint8_t problem_code); +int gsm0480_send_ss_return_error(struct gsm_subscriber_connection *conn, + const struct ss_request *req, + uint8_t error_code, + struct msgb *parameters); int gsm0480_send_ussdNotify(struct gsm_subscriber_connection *conn, int level, const char *text); int gsm0480_send_releaseComplete(struct gsm_subscriber_connection *conn); diff --git a/openbsc/src/libmsc/gsm_04_80.c b/openbsc/src/libmsc/gsm_04_80.c index b20521a..82b5623 100644 --- a/openbsc/src/libmsc/gsm_04_80.c +++ b/openbsc/src/libmsc/gsm_04_80.c @@ -91,8 +91,8 @@ int gsm0480_send_ussd_response(struct gsm_subscriber_connection *conn, /* Send response to a mobile-originated Invoke */ int gsm0480_send_ss_return_result(struct gsm_subscriber_connection *conn, - const struct ss_request *req, - struct msgb *msg) + const struct ss_request *req, + struct msgb *msg) { struct gsm48_hdr *gh; @@ -149,6 +149,38 @@ int gsm0480_send_ss_reject(struct gsm_subscriber_connection *conn, return gsm0808_submit_dtap(conn, msg, 0, 0); } +int gsm0480_send_ss_return_error(struct gsm_subscriber_connection *conn, + const struct ss_request *req, + uint8_t error_code, + struct msgb *parameters) +{ + struct msgb *msg = parameters; + struct gsm48_hdr *gh; + + if(!msg) + msg = gsm48_msgb_alloc(); + + /* Pre-pend the error code */ + msgb_push_TLV1(msg, GSM_0480_ERROR_CODE_TAG, error_code); + + /* Before it insert the invoke ID */ + msgb_push_TLV1(msg, GSM0480_COMPIDTAG_INVOKE_ID, req->invoke_id); + + /* Wrap this up as a Reject component */ + msgb_wrap_with_TL(msg, GSM0480_CTYPE_RETURN_ERROR); + + /* Wrap the component in a Facility message */ + msgb_wrap_with_TL(msg, GSM0480_IE_FACILITY); + + /* And finally pre-pend the L3 header */ + gh = (struct gsm48_hdr *) msgb_push(msg, sizeof(*gh)); + gh->proto_discr = GSM48_PDISC_NC_SS; + gh->proto_discr |= req->transaction_id | (1<<7); /* TI direction = 1 */ + gh->msg_type = GSM0480_MTYPE_RELEASE_COMPLETE; + + return gsm0808_submit_dtap(conn, msg, 0, 0); +} + int gsm0480_send_ussdNotify(struct gsm_subscriber_connection *conn, int level, const char *text) { struct gsm48_hdr *gh;