gsm48: Separate CM Service Reject sending and creation.

Split out the msg generation from the sending, this will
be used by the nat to send a refusal message.
This commit is contained in:
Holger Hans Peter Freyther 2010-06-15 19:39:27 +08:00
parent 580cb83ae3
commit 2c0f16699e
3 changed files with 25 additions and 9 deletions

View File

@ -60,5 +60,6 @@ int gsm48_lchan_modify(struct gsm_lchan *lchan, u_int8_t lchan_mode);
int gsm48_rx_rr_modif_ack(struct msgb *msg);
int gsm48_parse_meas_rep(struct gsm_meas_rep *rep, struct msgb *msg);
struct msgb *gsm48_create_mm_serv_rej(enum gsm48_reject_value value);
#endif

View File

@ -709,19 +709,17 @@ static int gsm48_tx_mm_serv_ack(struct gsm_lchan *lchan)
static int gsm48_tx_mm_serv_rej(struct gsm_subscriber_connection *conn,
enum gsm48_reject_value value)
{
struct msgb *msg = gsm48_msgb_alloc();
struct gsm48_hdr *gh;
struct msgb *msg;
gh = (struct gsm48_hdr *) msgb_put(msg, sizeof(*gh) + 1);
msg = gsm48_create_mm_serv_rej(value);
if (!msg) {
LOGP(DMM, LOGL_ERROR, "Failed to allocate CM Service Reject.\n");
return -1;
}
DEBUGP(DMM, "-> CM SERVICE Reject cause: %d\n", value);
msg->lchan = conn->lchan;
use_subscr_con(conn);
gh->proto_discr = GSM48_PDISC_MM;
gh->msg_type = GSM48_MT_MM_CM_SERV_REJ;
gh->data[0] = value;
DEBUGP(DMM, "-> CM SERVICE Reject cause: %d\n", value);
return gsm48_conn_sendmsg(msg, conn, NULL);
}

View File

@ -564,3 +564,20 @@ int gsm48_parse_meas_rep(struct gsm_meas_rep *rep, struct msgb *msg)
return 0;
}
struct msgb *gsm48_create_mm_serv_rej(enum gsm48_reject_value value)
{
struct msgb *msg;
struct gsm48_hdr *gh;
msg = gsm48_msgb_alloc();
if (!msg)
return NULL;
gh = (struct gsm48_hdr *) msgb_put(msg, sizeof(*gh) + 1);
gh->proto_discr = GSM48_PDISC_MM;
gh->msg_type = GSM48_MT_MM_CM_SERV_REJ;
gh->data[0] = value;
return msg;
}