From 7984d5c2604131f9e44cc5a23672b6790d41754f Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Wed, 12 Aug 2009 22:56:50 +0200 Subject: [PATCH] add functions to send AUTH REQ and REJECT --- openbsc/include/openbsc/gsm_04_08.h | 2 ++ openbsc/src/gsm_04_08.c | 28 ++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/openbsc/include/openbsc/gsm_04_08.h b/openbsc/include/openbsc/gsm_04_08.h index 0d83cfb08..75d93fb93 100644 --- a/openbsc/include/openbsc/gsm_04_08.h +++ b/openbsc/include/openbsc/gsm_04_08.h @@ -698,6 +698,8 @@ enum gsm_chan_t get_ctype_by_chreq(struct gsm_bts *bts, u_int8_t ra); enum gsm_chreq_reason_t get_reason_by_chreq(struct gsm_bts *bts, u_int8_t ra); int gsm48_tx_mm_info(struct gsm_lchan *lchan); +int gsm48_tx_mm_auth_req(struct gsm_lchan *lchan, u_int8_t *rand); +int gsm48_tx_mm_auth_rej(struct gsm_lchan *lchan); struct msgb *gsm48_msgb_alloc(void); int gsm48_sendmsg(struct msgb *msg, struct gsm_trans *trans); int generate_mid_from_tmsi(u_int8_t *buf, u_int32_t tmsi); diff --git a/openbsc/src/gsm_04_08.c b/openbsc/src/gsm_04_08.c index 0523538a8..f0ec3ff96 100644 --- a/openbsc/src/gsm_04_08.c +++ b/openbsc/src/gsm_04_08.c @@ -1408,6 +1408,34 @@ int gsm48_tx_mm_info(struct gsm_lchan *lchan) return gsm48_sendmsg(msg, NULL); } +/* Section 9.2.2 */ +int gsm48_tx_mm_auth_req(struct gsm_lchan *lchan, u_int8_t *rand) +{ + struct msgb *msg = gsm48_msgb_alloc(); + struct gsm48_hdr *gh = (struct gsm48_hdr *) msgb_put(msg, sizeof(*gh)); + u_int8_t *r; + + DEBUGP(DMM, "-> AUTH REQ\n"); + + msg->lchan = lchan; + gh->proto_discr = GSM48_PDISC_MM; + gh->msg_type = GSM48_MT_MM_AUTH_REQ; + + /* 16 bytes RAND parameters */ + r = msgb_put(msg, 16); + if (rand) + memcpy(r, rand, 16); + + return gsm48_sendmsg(msg, NULL); +} + +/* Section 9.2.1 */ +int gsm48_tx_mm_auth_rej(struct gsm_lchan *lchan) +{ + DEBUGP(DMM, "-> AUTH REJECT\n"); + return gsm48_tx_simple(lchan, GSM48_PDISC_MM, GSM48_MT_MM_AUTH_REJ); +} + static int gsm48_tx_mm_serv_ack(struct gsm_lchan *lchan) { DEBUGP(DMM, "-> CM SERVICE ACK\n");