bsc_api: Remove the lchan from the USSD code...
This commit is contained in:
parent
3f122bed1e
commit
d42c3f25a6
|
@ -6,6 +6,8 @@
|
||||||
|
|
||||||
#define MAX_LEN_USSD_STRING 31
|
#define MAX_LEN_USSD_STRING 31
|
||||||
|
|
||||||
|
struct gsm_subscriber_connection;
|
||||||
|
|
||||||
struct ussd_request {
|
struct ussd_request {
|
||||||
char text[MAX_LEN_USSD_STRING + 1];
|
char text[MAX_LEN_USSD_STRING + 1];
|
||||||
u_int8_t transaction_id;
|
u_int8_t transaction_id;
|
||||||
|
@ -14,9 +16,11 @@ struct ussd_request {
|
||||||
|
|
||||||
int gsm0480_decode_ussd_request(const struct msgb *msg,
|
int gsm0480_decode_ussd_request(const struct msgb *msg,
|
||||||
struct ussd_request *request);
|
struct ussd_request *request);
|
||||||
int gsm0480_send_ussd_response(const struct msgb *in_msg, const char* response_text,
|
int gsm0480_send_ussd_response(struct gsm_subscriber_connection *conn,
|
||||||
const struct ussd_request *req);
|
const struct msgb *in_msg, const char* response_text,
|
||||||
int gsm0480_send_ussd_reject(const struct msgb *msg,
|
const struct ussd_request *req);
|
||||||
const struct ussd_request *request);
|
int gsm0480_send_ussd_reject(struct gsm_subscriber_connection *conn,
|
||||||
|
const struct msgb *msg,
|
||||||
|
const struct ussd_request *request);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -5,6 +5,6 @@
|
||||||
|
|
||||||
#include <osmocore/msgb.h>
|
#include <osmocore/msgb.h>
|
||||||
|
|
||||||
int handle_rcv_ussd(struct msgb *msg);
|
int handle_rcv_ussd(struct gsm_subscriber_connection *conn, struct msgb *msg);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -3113,7 +3113,7 @@ int gsm0408_dispatch(struct gsm_subscriber_connection *conn, struct msgb *msg)
|
||||||
"GSM 04.08 discriminator 0x%02x\n", pdisc);
|
"GSM 04.08 discriminator 0x%02x\n", pdisc);
|
||||||
break;
|
break;
|
||||||
case GSM48_PDISC_NC_SS:
|
case GSM48_PDISC_NC_SS:
|
||||||
rc = handle_rcv_ussd(msg);
|
rc = handle_rcv_ussd(conn, msg);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
LOGP(DRLL, LOGL_NOTICE, "Unknown "
|
LOGP(DRLL, LOGL_NOTICE, "Unknown "
|
||||||
|
|
|
@ -246,8 +246,9 @@ static int parse_process_uss_req(u_int8_t *uss_req_data, u_int8_t length,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Send response to a mobile-originated ProcessUnstructuredSS-Request */
|
/* Send response to a mobile-originated ProcessUnstructuredSS-Request */
|
||||||
int gsm0480_send_ussd_response(const struct msgb *in_msg, const char *response_text,
|
int gsm0480_send_ussd_response(struct gsm_subscriber_connection *conn,
|
||||||
const struct ussd_request *req)
|
const struct msgb *in_msg, const char *response_text,
|
||||||
|
const struct ussd_request *req)
|
||||||
{
|
{
|
||||||
struct msgb *msg = gsm48_msgb_alloc();
|
struct msgb *msg = gsm48_msgb_alloc();
|
||||||
struct gsm48_hdr *gh;
|
struct gsm48_hdr *gh;
|
||||||
|
@ -258,8 +259,6 @@ int gsm0480_send_ussd_response(const struct msgb *in_msg, const char *response_t
|
||||||
if (((strlen(response_text) * 7) % 8) != 0)
|
if (((strlen(response_text) * 7) % 8) != 0)
|
||||||
response_len += 1;
|
response_len += 1;
|
||||||
|
|
||||||
msg->lchan = in_msg->lchan;
|
|
||||||
|
|
||||||
/* First put the payload text into the message */
|
/* First put the payload text into the message */
|
||||||
ptr8 = msgb_put(msg, response_len);
|
ptr8 = msgb_put(msg, response_len);
|
||||||
gsm_7bit_encode(ptr8, response_text);
|
gsm_7bit_encode(ptr8, response_text);
|
||||||
|
@ -295,17 +294,16 @@ int gsm0480_send_ussd_response(const struct msgb *in_msg, const char *response_t
|
||||||
| (1<<7); /* TI direction = 1 */
|
| (1<<7); /* TI direction = 1 */
|
||||||
gh->msg_type = GSM0480_MTYPE_RELEASE_COMPLETE;
|
gh->msg_type = GSM0480_MTYPE_RELEASE_COMPLETE;
|
||||||
|
|
||||||
return gsm0808_submit_dtap(&msg->lchan->conn, msg, 0);
|
return gsm0808_submit_dtap(conn, msg, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int gsm0480_send_ussd_reject(const struct msgb *in_msg,
|
int gsm0480_send_ussd_reject(struct gsm_subscriber_connection *conn,
|
||||||
const struct ussd_request *req)
|
const struct msgb *in_msg,
|
||||||
|
const struct ussd_request *req)
|
||||||
{
|
{
|
||||||
struct msgb *msg = gsm48_msgb_alloc();
|
struct msgb *msg = gsm48_msgb_alloc();
|
||||||
struct gsm48_hdr *gh;
|
struct gsm48_hdr *gh;
|
||||||
|
|
||||||
msg->lchan = in_msg->lchan;
|
|
||||||
|
|
||||||
/* First insert the problem code */
|
/* First insert the problem code */
|
||||||
msgb_push_TLV1(msg, GSM_0480_PROBLEM_CODE_TAG_GENERAL,
|
msgb_push_TLV1(msg, GSM_0480_PROBLEM_CODE_TAG_GENERAL,
|
||||||
GSM_0480_GEN_PROB_CODE_UNRECOGNISED);
|
GSM_0480_GEN_PROB_CODE_UNRECOGNISED);
|
||||||
|
@ -325,5 +323,5 @@ int gsm0480_send_ussd_reject(const struct msgb *in_msg,
|
||||||
gh->proto_discr |= req->transaction_id | (1<<7); /* TI direction = 1 */
|
gh->proto_discr |= req->transaction_id | (1<<7); /* TI direction = 1 */
|
||||||
gh->msg_type = GSM0480_MTYPE_RELEASE_COMPLETE;
|
gh->msg_type = GSM0480_MTYPE_RELEASE_COMPLETE;
|
||||||
|
|
||||||
return gsm0808_submit_dtap(&msg->lchan->conn, msg, 0);
|
return gsm0808_submit_dtap(conn, msg, 0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,11 +38,11 @@
|
||||||
const char USSD_TEXT_OWN_NUMBER[] = "*#100#";
|
const char USSD_TEXT_OWN_NUMBER[] = "*#100#";
|
||||||
|
|
||||||
/* Forward declarations of network-specific handler functions */
|
/* Forward declarations of network-specific handler functions */
|
||||||
static int send_own_number(const struct msgb *msg, const struct ussd_request *req);
|
static int send_own_number(struct gsm_subscriber_connection *conn, const struct msgb *msg, const struct ussd_request *req);
|
||||||
|
|
||||||
|
|
||||||
/* Entrypoint - handler function common to all mobile-originated USSDs */
|
/* Entrypoint - handler function common to all mobile-originated USSDs */
|
||||||
int handle_rcv_ussd(struct msgb *msg)
|
int handle_rcv_ussd(struct gsm_subscriber_connection *conn, struct msgb *msg)
|
||||||
{
|
{
|
||||||
struct ussd_request req;
|
struct ussd_request req;
|
||||||
|
|
||||||
|
@ -52,20 +52,20 @@ int handle_rcv_ussd(struct msgb *msg)
|
||||||
|
|
||||||
if (strstr(USSD_TEXT_OWN_NUMBER, req.text) != NULL) {
|
if (strstr(USSD_TEXT_OWN_NUMBER, req.text) != NULL) {
|
||||||
DEBUGP(DMM, "USSD: Own number requested\n");
|
DEBUGP(DMM, "USSD: Own number requested\n");
|
||||||
return send_own_number(msg, &req);
|
return send_own_number(conn, msg, &req);
|
||||||
} else {
|
} else {
|
||||||
DEBUGP(DMM, "Unhandled USSD %s\n", req.text);
|
DEBUGP(DMM, "Unhandled USSD %s\n", req.text);
|
||||||
return gsm0480_send_ussd_reject(msg, &req);
|
return gsm0480_send_ussd_reject(conn, msg, &req);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* A network-specific handler function */
|
/* A network-specific handler function */
|
||||||
static int send_own_number(const struct msgb *msg, const struct ussd_request *req)
|
static int send_own_number(struct gsm_subscriber_connection *conn, const struct msgb *msg, const struct ussd_request *req)
|
||||||
{
|
{
|
||||||
char *own_number = msg->lchan->conn.subscr->extension;
|
char *own_number = conn->subscr->extension;
|
||||||
char response_string[GSM_EXTENSION_LENGTH + 20];
|
char response_string[GSM_EXTENSION_LENGTH + 20];
|
||||||
|
|
||||||
/* Need trailing CR as EOT character */
|
/* Need trailing CR as EOT character */
|
||||||
snprintf(response_string, sizeof(response_string), "Your extension is %s\r", own_number);
|
snprintf(response_string, sizeof(response_string), "Your extension is %s\r", own_number);
|
||||||
return gsm0480_send_ussd_response(msg, response_string, req);
|
return gsm0480_send_ussd_response(conn, msg, response_string, req);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue