[gsm_04_08] Fix gsm48_tx_mm_auth_req implementation

It was mainly missing the key_seq field, causing the
command to just be rejected by the ME.

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
diff --git a/openbsc/include/openbsc/gsm_04_08.h b/openbsc/include/openbsc/gsm_04_08.h
index 6f36786..185d760 100644
--- a/openbsc/include/openbsc/gsm_04_08.h
+++ b/openbsc/include/openbsc/gsm_04_08.h
@@ -78,6 +78,13 @@
 	u_int16_t lac;
 } __attribute__ ((packed));
 
+/* Section 9.2.2 */
+struct gsm48_auth_req {
+	u_int8_t key_seq:4,
+	         spare:4;
+	u_int8_t rand[16];
+} __attribute__ ((packed));
+
 /* Section 9.2.15 */
 struct gsm48_loc_upd_req {
 	u_int8_t type:4,
diff --git a/openbsc/src/gsm_04_08.c b/openbsc/src/gsm_04_08.c
index b3f2878..dc85670 100644
--- a/openbsc/src/gsm_04_08.c
+++ b/openbsc/src/gsm_04_08.c
@@ -1233,7 +1233,7 @@
 {
 	struct msgb *msg = gsm48_msgb_alloc();
 	struct gsm48_hdr *gh = (struct gsm48_hdr *) msgb_put(msg, sizeof(*gh));
-	u_int8_t *r;
+	struct gsm48_auth_req *ar = (struct gsm48_auth_req *) msgb_put(msg, sizeof(*ar));
 
 	DEBUGP(DMM, "-> AUTH REQ\n");
 
@@ -1241,10 +1241,12 @@
 	gh->proto_discr = GSM48_PDISC_MM;
 	gh->msg_type = GSM48_MT_MM_AUTH_REQ;
 
+	/* Key Sequence: FIXME fixed to 0 */
+	ar->key_seq = 0;
+
 	/* 16 bytes RAND parameters */
-	r = msgb_put(msg, 16);
 	if (rand)
-		memcpy(r, rand, 16);
+		memcpy(ar->rand, rand, 16);
 
 	return gsm48_sendmsg(msg, NULL);
 }