pespin has uploaded this change for review.

View Change

gmm: Implement rx Attach Reject

Relaed: OS#5501
Depends: libosmogore.git Change-Id I2d36d76ee6fe8ed1a36e37a7d74fbbdc9c27c2c7
Change-Id: Id4ad73ea25a380db9692892422e76ba44084649c
---
M include/osmocom/gprs/gmm/gmm_ms_fsm.h
M include/osmocom/gprs/gmm/gmm_private.h
M src/gmm/gmm.c
M src/gmm/gmm_ms_fsm.c
M src/gmm/gmm_pdu.c
5 files changed, 66 insertions(+), 7 deletions(-)

git pull ssh://gerrit.osmocom.org:29418/libosmo-gprs refs/changes/89/32289/1
diff --git a/include/osmocom/gprs/gmm/gmm_ms_fsm.h b/include/osmocom/gprs/gmm/gmm_ms_fsm.h
index 38399b3..16bd022 100644
--- a/include/osmocom/gprs/gmm/gmm_ms_fsm.h
+++ b/include/osmocom/gprs/gmm/gmm_ms_fsm.h
@@ -28,7 +28,7 @@
GPRS_GMM_MS_EV_ENABLE_GPRS_MODE,
GPRS_GMM_MS_EV_DISABLE_GPRS_MODE,
GPRS_GMM_MS_EV_ATTACH_REQUESTED,
- GPRS_GMM_MS_EV_ATTACH_REJECTED,
+ GPRS_GMM_MS_EV_ATTACH_REJECTED, /* data: ptr to "uint8_t cause" */
GPRS_GMM_MS_EV_ATTACH_ACCEPTED,
GPRS_GMM_MS_EV_DETACH_REQUESTED, /* also network initiated. */
GPRS_GMM_MS_EV_DETACH_REQUESTED_POWEROFF,
diff --git a/include/osmocom/gprs/gmm/gmm_private.h b/include/osmocom/gprs/gmm/gmm_private.h
index 2f6eb8c..473c670 100644
--- a/include/osmocom/gprs/gmm/gmm_private.h
+++ b/include/osmocom/gprs/gmm/gmm_private.h
@@ -65,6 +65,9 @@

uint8_t gea; /* GEA/0 = 0, GEA/1 = 1, ... */
uint8_t kc[16]; /* max 16 * 8 = 128 bits */
+
+ unsigned long t3302;
+ unsigned long t3346;
};

/* gmm_prim.c: */
diff --git a/src/gmm/gmm.c b/src/gmm/gmm.c
index f9e2645..e97b398 100644
--- a/src/gmm/gmm.c
+++ b/src/gmm/gmm.c
@@ -149,6 +149,11 @@
return NULL;
}

+ /* Initialize timers to default values. They may be overwritten by the
+ * network later on: */
+ gmme->t3302 = osmo_tdef_get(g_ctx->T_defs, 3302, OSMO_TDEF_S, -1);
+ gmme->t3346 = osmo_tdef_get(g_ctx->T_defs, 3346, OSMO_TDEF_S, -1);
+
llist_add(&gmme->list, &g_ctx->gmme_list);

return gmme;
@@ -444,6 +449,9 @@
gmme->old_ptmsi = gmme->ptmsi;
gmme->ptmsi = mi.tmsi;
}
+
+ if (TLVP_PRES_LEN(&tp, GSM48_IE_GMM_TIMER_T3302, 1))
+ gmme->t3302 = *TLVP_VAL(&tp, GSM48_IE_GMM_TIMER_T3302);
}

/* Submit LLGMM-ASSIGN-REQ as per TS 24.007 Annex C.1 */
@@ -468,11 +476,45 @@
return -EINVAL; /* TODO: what to do on error? */
}

-
+/* Rx GMM Attach Reject, 9.4.4 */
static int gprs_gmm_rx_att_rej(struct gprs_gmm_entity *gmme, struct gsm48_hdr *gh, unsigned int len)
{
- LOGGMME(gmme, LOGL_ERROR, "Rx GMM ATTACH REJECT not implemented!\n");
- return 0; /* TODO */
+ uint8_t *arej = &gh->data[0];
+ struct tlv_parsed tp;
+ uint8_t cause;
+ int rc;
+
+ if (len < sizeof(*gh) + 1) {
+ LOGGMME(gmme, LOGL_ERROR, "Rx GMM ATTACH REJECT with wrong size %u\n", len);
+ goto rejected;
+ }
+
+ cause = *arej;
+ arej++;
+
+ LOGGMME(gmme, LOGL_DEBUG, "Rx GMM ATTACH REJECT cause='%s' (%u)\n",
+ get_value_string(gsm48_gmm_cause_names, cause), cause);
+
+ if (len > sizeof(*gh) + 1) {
+ rc = gprs_gmm_tlv_parse(&tp, arej, len - (sizeof(*gh) + 1));
+ if (rc < 0) {
+ LOGGMME(gmme, LOGL_ERROR, "Rx GMM ATTACH REJECT: failed to parse TLVs %d\n", rc);
+ goto rejected;
+ }
+
+ if (TLVP_PRES_LEN(&tp, GSM48_IE_GMM_TIMER_T3302, 1))
+ gmme->t3302 = *TLVP_VAL(&tp, GSM48_IE_GMM_TIMER_T3302);
+
+ if (TLVP_PRES_LEN(&tp, GSM48_IE_GMM_TIMER_T3302, 1))
+ gmme->t3346 = *TLVP_VAL(&tp, GSM48_IE_GMM_TIMER_T3346);
+ }
+
+ rc = osmo_fsm_inst_dispatch(gmme->ms_fsm.fi, GPRS_GMM_MS_EV_ATTACH_REJECTED, &cause);
+
+ return rc;
+
+rejected:
+ return -EINVAL;
}

/* Rx GMM Detach Accept (mobile originating detach), 9.4.6.2 */
diff --git a/src/gmm/gmm_ms_fsm.c b/src/gmm/gmm_ms_fsm.c
index f59e92e..92bf6f2 100644
--- a/src/gmm/gmm_ms_fsm.c
+++ b/src/gmm/gmm_ms_fsm.c
@@ -111,10 +111,11 @@
reinit_attach_proc(ctx);
break;
case GPRS_GMM_MS_EV_ATTACH_REJECTED:
+ cause = *(uint8_t *)data;
+ /* fall-through */
case GPRS_GMM_MS_EV_LOW_LVL_FAIL:
- /* TODO: in AttachReject, take cause from rx msg. */
- cause = (event == GPRS_GMM_MS_EV_LOW_LVL_FAIL) ?
- GMM_CAUSE_MAC_FAIL : GMM_CAUSE_NET_FAIL;
+ if (event == GPRS_GMM_MS_EV_LOW_LVL_FAIL)
+ cause = GMM_CAUSE_MAC_FAIL;
if (ctx->attach.explicit_att) {
/* Submit GMMREG-ATTACH-REJ as per TS 24.007 Annex C.1 */
rc = gprs_gmm_submit_gmmreg_attach_cnf(ctx->gmme, false, cause);
diff --git a/src/gmm/gmm_pdu.c b/src/gmm/gmm_pdu.c
index b8bea9d..4123e24 100644
--- a/src/gmm/gmm_pdu.c
+++ b/src/gmm/gmm_pdu.c
@@ -138,12 +138,14 @@
[GSM48_IE_GMM_AUTH_RAND] = { TLV_TYPE_FIXED, 16 },
[GSM48_IE_GMM_AUTH_SRES] = { TLV_TYPE_FIXED, 4 },
[GSM48_IE_GMM_AUTH_RES_EXT] = { TLV_TYPE_TLV, 0 },
+ [GSM48_IE_GMM_TIMER_T3302] = { TLV_TYPE_TLV, 0 },
[GSM48_IE_GMM_AUTH_FAIL_PAR] = { TLV_TYPE_TLV, 0 },
[GSM48_IE_GMM_IMEISV] = { TLV_TYPE_TLV, 0 },
[GSM48_IE_GMM_DRX_PARAM] = { TLV_TYPE_FIXED, 2 },
[GSM48_IE_GMM_MS_NET_CAPA] = { TLV_TYPE_TLV, 0 },
[GSM48_IE_GMM_PDP_CTX_STATUS] = { TLV_TYPE_TLV, 0 },
[GSM48_IE_GMM_PS_LCS_CAPA] = { TLV_TYPE_TLV, 0 },
+ [GSM48_IE_GMM_TIMER_T3346] = { TLV_TYPE_TLV, 0 },
[GSM48_IE_GMM_GMM_MBMS_CTX_ST] = { TLV_TYPE_TLV, 0 },
},
};

To view, visit change 32289. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: libosmo-gprs
Gerrit-Branch: master
Gerrit-Change-Id: Id4ad73ea25a380db9692892422e76ba44084649c
Gerrit-Change-Number: 32289
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin@sysmocom.de>
Gerrit-MessageType: newchange