Signed-off-by: Max max.suraev@fairwaves.co --- 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;