<p>lynxis lazus has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.osmocom.org/9258">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">WIP: tests: remove gmm unit tests<br><br>The TTCN3 tests should replace all of the GMM unit tests.<br>The GMM unit tests uses send/recieve LLME while TTCN3 is using BSSGP<br>tx/rx to the same.<br>TTCN3 has better tooling and can handle packets more easier.<br>The unittests expect the package in a specific order and do checks<br>the internal state, which is now changing because of the new FSM.<br><br>TODO: compare TTCN3 <> unit tests and add missing checks.<br><br>Change-Id: Iac1c8854b5ea4aa03279990390ebc110c979aac2<br>---<br>M tests/sgsn/sgsn_test.c<br>1 file changed, 0 insertions(+), 818 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.osmocom.org:29418/osmo-sgsn refs/changes/58/9258/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/tests/sgsn/sgsn_test.c b/tests/sgsn/sgsn_test.c</span><br><span>index 0e5267b..3e86266 100644</span><br><span>--- a/tests/sgsn/sgsn_test.c</span><br><span>+++ b/tests/sgsn/sgsn_test.c</span><br><span>@@ -925,166 +925,6 @@</span><br><span>    cleanup_test();</span><br><span> }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-/*</span><br><span style="color: hsl(0, 100%, 40%);">- * Test the GMM Attach procedure</span><br><span style="color: hsl(0, 100%, 40%);">- */</span><br><span style="color: hsl(0, 100%, 40%);">-static void test_gmm_attach(int retry)</span><br><span style="color: hsl(0, 100%, 40%);">-{</span><br><span style="color: hsl(0, 100%, 40%);">-    struct gprs_ra_id raid = { 0, };</span><br><span style="color: hsl(0, 100%, 40%);">-        struct sgsn_mm_ctx *ctx = NULL;</span><br><span style="color: hsl(0, 100%, 40%);">- struct sgsn_mm_ctx *ictx;</span><br><span style="color: hsl(0, 100%, 40%);">-       uint32_t ptmsi1;</span><br><span style="color: hsl(0, 100%, 40%);">-        uint32_t foreign_tlli;</span><br><span style="color: hsl(0, 100%, 40%);">-  uint32_t local_tlli = 0;</span><br><span style="color: hsl(0, 100%, 40%);">-        struct gprs_llc_lle *lle;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-       /* DTAP - Attach Request */</span><br><span style="color: hsl(0, 100%, 40%);">-     /* The P-TMSI is not known by the SGSN */</span><br><span style="color: hsl(0, 100%, 40%);">-       static const unsigned char attach_req[] = {</span><br><span style="color: hsl(0, 100%, 40%);">-             0x08, 0x01, 0x02, 0xf5, 0xe0, 0x21, 0x08, 0x02, 0x05, 0xf4,</span><br><span style="color: hsl(0, 100%, 40%);">-             0xfb, 0xc5, 0x46, 0x79, 0x11, 0x22, 0x33, 0x40, 0x50, 0x60,</span><br><span style="color: hsl(0, 100%, 40%);">-             0x19, 0x18, 0xb3, 0x43, 0x2b, 0x25, 0x96, 0x62, 0x00, 0x60,</span><br><span style="color: hsl(0, 100%, 40%);">-             0x80, 0x9a, 0xc2, 0xc6, 0x62, 0x00, 0x60, 0x80, 0xba, 0xc8,</span><br><span style="color: hsl(0, 100%, 40%);">-             0xc6, 0x62, 0x00, 0x60, 0x80, 0x00</span><br><span style="color: hsl(0, 100%, 40%);">-      };</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-      /* DTAP - Identity Response IMEI */</span><br><span style="color: hsl(0, 100%, 40%);">-     static const unsigned char ident_resp_imei[] = {</span><br><span style="color: hsl(0, 100%, 40%);">-                0x08, 0x16, 0x08, 0x9a, 0x78, 0x56, 0x34, 0x12, 0x90, 0x78,</span><br><span style="color: hsl(0, 100%, 40%);">-             0x56</span><br><span style="color: hsl(0, 100%, 40%);">-    };</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-      /* DTAP - Identity Response IMSI */</span><br><span style="color: hsl(0, 100%, 40%);">-     static const unsigned char ident_resp_imsi[] = {</span><br><span style="color: hsl(0, 100%, 40%);">-                0x08, 0x16, 0x08, 0x19, 0x32, 0x54, 0x76, 0x98, 0x10, 0x32,</span><br><span style="color: hsl(0, 100%, 40%);">-             0x54</span><br><span style="color: hsl(0, 100%, 40%);">-    };</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-      /* DTAP - Authentication and Ciphering Resp */</span><br><span style="color: hsl(0, 100%, 40%);">-  static const unsigned char auth_ciph_resp[] = {</span><br><span style="color: hsl(0, 100%, 40%);">-         0x08, 0x13, 0x00, 0x22, 0x51, 0xe5, 0x51, 0xe5, 0x23, 0x09,</span><br><span style="color: hsl(0, 100%, 40%);">-             0x9a, 0x78, 0x56, 0x34, 0x12, 0x90, 0x78, 0x56, 0x01</span><br><span style="color: hsl(0, 100%, 40%);">-    };</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-      /* DTAP - Attach Complete */</span><br><span style="color: hsl(0, 100%, 40%);">-    static const unsigned char attach_compl[] = {</span><br><span style="color: hsl(0, 100%, 40%);">-           0x08, 0x03</span><br><span style="color: hsl(0, 100%, 40%);">-      };</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-      /* DTAP - Detach Request (MO) */</span><br><span style="color: hsl(0, 100%, 40%);">-        /* normal detach, power_off = 0 */</span><br><span style="color: hsl(0, 100%, 40%);">-      static const unsigned char detach_req[] = {</span><br><span style="color: hsl(0, 100%, 40%);">-             0x08, 0x05, 0x01, 0x18, 0x05, 0xf4, 0xeb, 0x8b,</span><br><span style="color: hsl(0, 100%, 40%);">-         0x45, 0x67, 0x19, 0x03, 0xb9, 0x97, 0xcb</span><br><span style="color: hsl(0, 100%, 40%);">-        };</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-      printf("Testing GMM attach%s\n", retry ? " with retry" : "");</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-     foreign_tlli = gprs_tmsi2tlli(0xc0000023, TLLI_FOREIGN);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-        /* Create a LLE/LLME */</span><br><span style="color: hsl(0, 100%, 40%);">- OSMO_ASSERT(count(gprs_llme_list()) == 0);</span><br><span style="color: hsl(0, 100%, 40%);">-      lle = gprs_lle_get_or_create(foreign_tlli, 3);</span><br><span style="color: hsl(0, 100%, 40%);">-  OSMO_ASSERT(count(gprs_llme_list()) == 1);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-      /* inject the attach request */</span><br><span style="color: hsl(0, 100%, 40%);">- send_0408_message(lle->llme, foreign_tlli, &raid,</span><br><span style="color: hsl(0, 100%, 40%);">-                          attach_req, ARRAY_SIZE(attach_req));</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-  ctx = sgsn_mm_ctx_by_tlli(foreign_tlli, &raid);</span><br><span style="color: hsl(0, 100%, 40%);">-     OSMO_ASSERT(ctx != NULL);</span><br><span style="color: hsl(0, 100%, 40%);">-       OSMO_ASSERT(ctx->gmm_state == GMM_COMMON_PROC_INIT);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">- /* we expect an identity request (IMEI) */</span><br><span style="color: hsl(0, 100%, 40%);">-      OSMO_ASSERT(sgsn_tx_counter == 1);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-      /* inject the identity response (IMEI) */</span><br><span style="color: hsl(0, 100%, 40%);">-       send_0408_message(ctx->gb.llme, foreign_tlli, &raid,</span><br><span style="color: hsl(0, 100%, 40%);">-                       ident_resp_imei, ARRAY_SIZE(ident_resp_imei));</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-        /* we expect an identity request (IMSI) */</span><br><span style="color: hsl(0, 100%, 40%);">-      OSMO_ASSERT(sgsn_tx_counter == 1);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-      /* inject the identity response (IMSI) */</span><br><span style="color: hsl(0, 100%, 40%);">-       send_0408_message(ctx->gb.llme, foreign_tlli, &raid,</span><br><span style="color: hsl(0, 100%, 40%);">-                       ident_resp_imsi, ARRAY_SIZE(ident_resp_imsi));</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-        /* check that the MM context has not been removed due to a failed</span><br><span style="color: hsl(0, 100%, 40%);">-        * authorization */</span><br><span style="color: hsl(0, 100%, 40%);">-     OSMO_ASSERT(ctx == sgsn_mm_ctx_by_tlli(foreign_tlli, &raid));</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-       OSMO_ASSERT(ctx->gmm_state == GMM_COMMON_PROC_INIT);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-retry_attach_req:</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-        if (retry && sgsn_tx_counter == 0) {</span><br><span style="color: hsl(0, 100%, 40%);">-            fprintf(stderr, "Retrying attach request\n");</span><br><span style="color: hsl(0, 100%, 40%);">-         /* re-inject the attach request */</span><br><span style="color: hsl(0, 100%, 40%);">-              send_0408_message(lle->llme, foreign_tlli, &raid,</span><br><span style="color: hsl(0, 100%, 40%);">-                                  attach_req, ARRAY_SIZE(attach_req));</span><br><span style="color: hsl(0, 100%, 40%);">-  }</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-       if (ctx->auth_state == SGSN_AUTH_AUTHENTICATE && sgsn_tx_counter == 1) {</span><br><span style="color: hsl(0, 100%, 40%);">-             /* we got an auth & ciph request */</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-         /* inject the auth & ciph response */</span><br><span style="color: hsl(0, 100%, 40%);">-               send_0408_message(ctx->gb.llme, foreign_tlli, &raid,</span><br><span style="color: hsl(0, 100%, 40%);">-                               auth_ciph_resp, ARRAY_SIZE(auth_ciph_resp));</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-          /* check that the MM context has not been removed due to a</span><br><span style="color: hsl(0, 100%, 40%);">-               * failed authorization */</span><br><span style="color: hsl(0, 100%, 40%);">-              OSMO_ASSERT(ctx == sgsn_mm_ctx_by_tlli(foreign_tlli, &raid));</span><br><span style="color: hsl(0, 100%, 40%);">-               if (ctx->subscr && ctx->subscr->sgsn_data->msisdn_len > 0)</span><br><span style="color: hsl(0, 100%, 40%);">-                       OSMO_ASSERT(strcmp(ctx->msisdn, "+49166213323") == 0);</span><br><span style="color: hsl(0, 100%, 40%);">-     }</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-       if (retry && sgsn_tx_counter == 0)</span><br><span style="color: hsl(0, 100%, 40%);">-              goto retry_attach_req;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-  /* we expect an attach accept/reject */</span><br><span style="color: hsl(0, 100%, 40%);">- OSMO_ASSERT(sgsn_tx_counter == 1);</span><br><span style="color: hsl(0, 100%, 40%);">-      ptmsi1 = get_new_ptmsi(&last_dl_parse_ctx);</span><br><span style="color: hsl(0, 100%, 40%);">- OSMO_ASSERT(ptmsi1 != GSM_RESERVED_TMSI);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-       /* this has been randomly assigned by the SGSN */</span><br><span style="color: hsl(0, 100%, 40%);">-       local_tlli = gprs_tmsi2tlli(ptmsi1, TLLI_LOCAL);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-        /* inject the attach complete */</span><br><span style="color: hsl(0, 100%, 40%);">-        send_0408_message(ctx->gb.llme, local_tlli, &raid,</span><br><span style="color: hsl(0, 100%, 40%);">-                         attach_compl, ARRAY_SIZE(attach_compl));</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-      OSMO_ASSERT(ctx->gmm_state == GMM_REGISTERED_NORMAL);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-        /* we don't expect a response */</span><br><span style="color: hsl(0, 100%, 40%);">-    OSMO_ASSERT(sgsn_tx_counter == 0);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-      /* inject the detach */</span><br><span style="color: hsl(0, 100%, 40%);">- send_0408_message(ctx->gb.llme, local_tlli, &raid,</span><br><span style="color: hsl(0, 100%, 40%);">-                         detach_req, ARRAY_SIZE(detach_req));</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-  /* verify that things are gone */</span><br><span style="color: hsl(0, 100%, 40%);">-       OSMO_ASSERT(count(gprs_llme_list()) == 0);</span><br><span style="color: hsl(0, 100%, 40%);">-      ictx = sgsn_mm_ctx_by_tlli(local_tlli, &raid);</span><br><span style="color: hsl(0, 100%, 40%);">-      OSMO_ASSERT(!ictx);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-     cleanup_test();</span><br><span style="color: hsl(0, 100%, 40%);">-}</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-static void test_gmm_attach_acl(void)</span><br><span style="color: hsl(0, 100%, 40%);">-{</span><br><span style="color: hsl(0, 100%, 40%);">-  const enum sgsn_auth_policy saved_auth_policy = sgsn->cfg.auth_policy;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-       sgsn_inst.cfg.auth_policy = SGSN_AUTH_POLICY_CLOSED;</span><br><span style="color: hsl(0, 100%, 40%);">-    sgsn_acl_add("123456789012345", &sgsn->cfg);</span><br><span style="color: hsl(0, 100%, 40%);">-   printf("Auth policy 'closed': ");</span><br><span style="color: hsl(0, 100%, 40%);">-     test_gmm_attach(0);</span><br><span style="color: hsl(0, 100%, 40%);">-     sgsn_acl_del("123456789012345", &sgsn->cfg);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-   sgsn->cfg.auth_policy = saved_auth_policy;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-   cleanup_test();</span><br><span style="color: hsl(0, 100%, 40%);">-}</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span> int my_subscr_request_update_location(struct sgsn_mm_ctx *mmctx)</span><br><span> {</span><br><span>    int rc;</span><br><span>@@ -1103,30 +943,6 @@</span><br><span>      return 0;</span><br><span> }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-static void test_gmm_attach_subscr(void)</span><br><span style="color: hsl(0, 100%, 40%);">-{</span><br><span style="color: hsl(0, 100%, 40%);">-     const enum sgsn_auth_policy saved_auth_policy = sgsn->cfg.auth_policy;</span><br><span style="color: hsl(0, 100%, 40%);">-       struct gprs_subscr *subscr;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-     sgsn_inst.cfg.auth_policy = SGSN_AUTH_POLICY_REMOTE;</span><br><span style="color: hsl(0, 100%, 40%);">-    subscr_request_update_location_cb = my_subscr_request_update_location;</span><br><span style="color: hsl(0, 100%, 40%);">-  subscr_request_auth_info_cb = my_subscr_request_auth_info;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-      subscr = gprs_subscr_get_or_create("123456789012345");</span><br><span style="color: hsl(0, 100%, 40%);">-        subscr->authorized = 1;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-      printf("Auth policy 'remote': ");</span><br><span style="color: hsl(0, 100%, 40%);">-     test_gmm_attach(0);</span><br><span style="color: hsl(0, 100%, 40%);">-     gprs_subscr_put(subscr);</span><br><span style="color: hsl(0, 100%, 40%);">-        assert_no_subscrs();</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-    sgsn->cfg.auth_policy = saved_auth_policy;</span><br><span style="color: hsl(0, 100%, 40%);">-   subscr_request_update_location_cb = __real_gprs_subscr_request_update_location;</span><br><span style="color: hsl(0, 100%, 40%);">- subscr_request_auth_info_cb = __real_gprs_subscr_request_auth_info;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-     cleanup_test();</span><br><span style="color: hsl(0, 100%, 40%);">-}</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span> int my_subscr_request_auth_info_fake_auth(struct sgsn_mm_ctx *mmctx, const uint8_t *auts,</span><br><span>                                                const uint8_t *auts_rand)</span><br><span> {</span><br><span>@@ -1138,32 +954,6 @@</span><br><span>       return 0;</span><br><span> }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-static void test_gmm_attach_subscr_fake_auth(void)</span><br><span style="color: hsl(0, 100%, 40%);">-{</span><br><span style="color: hsl(0, 100%, 40%);">-   const enum sgsn_auth_policy saved_auth_policy = sgsn->cfg.auth_policy;</span><br><span style="color: hsl(0, 100%, 40%);">-       struct gprs_subscr *subscr;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-     sgsn_inst.cfg.auth_policy = SGSN_AUTH_POLICY_REMOTE;</span><br><span style="color: hsl(0, 100%, 40%);">-    subscr_request_update_location_cb = my_subscr_request_update_location;</span><br><span style="color: hsl(0, 100%, 40%);">-  subscr_request_auth_info_cb = my_subscr_request_auth_info_fake_auth;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-    subscr = gprs_subscr_get_or_create("123456789012345");</span><br><span style="color: hsl(0, 100%, 40%);">-        subscr->authorized = 1;</span><br><span style="color: hsl(0, 100%, 40%);">-      sgsn->cfg.require_authentication = 1;</span><br><span style="color: hsl(0, 100%, 40%);">-        sgsn->cfg.require_update_location = 1;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-       printf("Auth policy 'remote', auth faked: ");</span><br><span style="color: hsl(0, 100%, 40%);">- test_gmm_attach(0);</span><br><span style="color: hsl(0, 100%, 40%);">-     gprs_subscr_put(subscr);</span><br><span style="color: hsl(0, 100%, 40%);">-        assert_no_subscrs();</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-    sgsn->cfg.auth_policy = saved_auth_policy;</span><br><span style="color: hsl(0, 100%, 40%);">-   subscr_request_update_location_cb = __real_gprs_subscr_request_update_location;</span><br><span style="color: hsl(0, 100%, 40%);">- subscr_request_auth_info_cb = __real_gprs_subscr_request_auth_info;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-     cleanup_test();</span><br><span style="color: hsl(0, 100%, 40%);">-}</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span> int my_subscr_request_auth_info_real_auth(struct sgsn_mm_ctx *mmctx, const uint8_t *auts, const uint8_t *auts_rand)</span><br><span> {</span><br><span>         struct gsm_auth_tuple at = {</span><br><span>@@ -1181,33 +971,6 @@</span><br><span>         return 0;</span><br><span> }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-static void test_gmm_attach_subscr_real_auth(void)</span><br><span style="color: hsl(0, 100%, 40%);">-{</span><br><span style="color: hsl(0, 100%, 40%);">-   const enum sgsn_auth_policy saved_auth_policy = sgsn->cfg.auth_policy;</span><br><span style="color: hsl(0, 100%, 40%);">-       struct gprs_subscr *subscr;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-     sgsn_inst.cfg.auth_policy = SGSN_AUTH_POLICY_REMOTE;</span><br><span style="color: hsl(0, 100%, 40%);">-    subscr_request_update_location_cb = my_subscr_request_update_location;</span><br><span style="color: hsl(0, 100%, 40%);">-  subscr_request_auth_info_cb = my_subscr_request_auth_info_real_auth;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-    subscr = gprs_subscr_get_or_create("123456789012345");</span><br><span style="color: hsl(0, 100%, 40%);">-        subscr->authorized = 1;</span><br><span style="color: hsl(0, 100%, 40%);">-      sgsn->cfg.require_authentication = 1;</span><br><span style="color: hsl(0, 100%, 40%);">-        sgsn->cfg.require_update_location = 1;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-       printf("Auth policy 'remote', triplet based auth: ");</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">- test_gmm_attach(0);</span><br><span style="color: hsl(0, 100%, 40%);">-     gprs_subscr_put(subscr);</span><br><span style="color: hsl(0, 100%, 40%);">-        assert_no_subscrs();</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-    sgsn->cfg.auth_policy = saved_auth_policy;</span><br><span style="color: hsl(0, 100%, 40%);">-   subscr_request_update_location_cb = __real_gprs_subscr_request_update_location;</span><br><span style="color: hsl(0, 100%, 40%);">- subscr_request_auth_info_cb = __real_gprs_subscr_request_auth_info;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-     cleanup_test();</span><br><span style="color: hsl(0, 100%, 40%);">-}</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span> #define TEST_GSUP_IMSI_LONG_IE 0x01, 0x08, \</span><br><span>                            0x21, 0x43, 0x65, 0x87, 0x09, 0x21, 0x43, 0xf5</span><br><span> </span><br><span>@@ -1269,39 +1032,6 @@</span><br><span>   return rx_gsup_message(update_location_res, sizeof(update_location_res));</span><br><span> };</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-static void test_gmm_attach_subscr_gsup_auth(int retry)</span><br><span style="color: hsl(0, 100%, 40%);">-{</span><br><span style="color: hsl(0, 100%, 40%);">-     const enum sgsn_auth_policy saved_auth_policy = sgsn->cfg.auth_policy;</span><br><span style="color: hsl(0, 100%, 40%);">-       struct gprs_subscr *subscr;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-     sgsn_inst.cfg.auth_policy = SGSN_AUTH_POLICY_REMOTE;</span><br><span style="color: hsl(0, 100%, 40%);">-    subscr_request_update_location_cb = my_subscr_request_update_gsup_auth;</span><br><span style="color: hsl(0, 100%, 40%);">- subscr_request_auth_info_cb = my_subscr_request_auth_info_gsup_auth;</span><br><span style="color: hsl(0, 100%, 40%);">-    if (retry) {</span><br><span style="color: hsl(0, 100%, 40%);">-            upd_loc_skip = 3;</span><br><span style="color: hsl(0, 100%, 40%);">-               auth_info_skip = 3;</span><br><span style="color: hsl(0, 100%, 40%);">-     }</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-       subscr = gprs_subscr_get_or_create("123456789012345");</span><br><span style="color: hsl(0, 100%, 40%);">-        subscr->authorized = 1;</span><br><span style="color: hsl(0, 100%, 40%);">-      sgsn->cfg.require_authentication = 1;</span><br><span style="color: hsl(0, 100%, 40%);">-        sgsn->cfg.require_update_location = 1;</span><br><span style="color: hsl(0, 100%, 40%);">-       gprs_subscr_put(subscr);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-        printf("Auth policy 'remote', GSUP based auth: ");</span><br><span style="color: hsl(0, 100%, 40%);">-    test_gmm_attach(retry);</span><br><span style="color: hsl(0, 100%, 40%);">- assert_no_subscrs();</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-    sgsn->cfg.auth_policy = saved_auth_policy;</span><br><span style="color: hsl(0, 100%, 40%);">-   subscr_request_update_location_cb = __real_gprs_subscr_request_update_location;</span><br><span style="color: hsl(0, 100%, 40%);">- subscr_request_auth_info_cb = __real_gprs_subscr_request_auth_info;</span><br><span style="color: hsl(0, 100%, 40%);">-     upd_loc_skip = 0;</span><br><span style="color: hsl(0, 100%, 40%);">-       auth_info_skip = 0;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-     cleanup_test();</span><br><span style="color: hsl(0, 100%, 40%);">-}</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span> int my_gsup_client_send(struct gsup_client *gsupc, struct msgb *msg)</span><br><span> {</span><br><span>        struct osmo_gsup_message to_peer = {0};</span><br><span>@@ -1353,38 +1083,6 @@</span><br><span>     return 0;</span><br><span> };</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-static void test_gmm_attach_subscr_real_gsup_auth(int retry)</span><br><span style="color: hsl(0, 100%, 40%);">-{</span><br><span style="color: hsl(0, 100%, 40%);">-        const enum sgsn_auth_policy saved_auth_policy = sgsn->cfg.auth_policy;</span><br><span style="color: hsl(0, 100%, 40%);">-       struct gprs_subscr *subscr;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-     sgsn_inst.cfg.auth_policy = SGSN_AUTH_POLICY_REMOTE;</span><br><span style="color: hsl(0, 100%, 40%);">-    gsup_client_send_cb = my_gsup_client_send;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-      sgsn->gsup_client = talloc_zero(tall_bsc_ctx, struct gsup_client);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-   if (retry) {</span><br><span style="color: hsl(0, 100%, 40%);">-            upd_loc_skip = 3;</span><br><span style="color: hsl(0, 100%, 40%);">-               auth_info_skip = 3;</span><br><span style="color: hsl(0, 100%, 40%);">-     }</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-       printf("Auth policy 'remote', real GSUP based auth: ");</span><br><span style="color: hsl(0, 100%, 40%);">-       test_gmm_attach(retry);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">- subscr = gprs_subscr_get_by_imsi("123456789012345");</span><br><span style="color: hsl(0, 100%, 40%);">-  OSMO_ASSERT(subscr == NULL);</span><br><span style="color: hsl(0, 100%, 40%);">-    assert_no_subscrs();</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-    sgsn->cfg.auth_policy = saved_auth_policy;</span><br><span style="color: hsl(0, 100%, 40%);">-   gsup_client_send_cb = __real_gsup_client_send;</span><br><span style="color: hsl(0, 100%, 40%);">-  upd_loc_skip = 0;</span><br><span style="color: hsl(0, 100%, 40%);">-       auth_info_skip = 0;</span><br><span style="color: hsl(0, 100%, 40%);">-     talloc_free(sgsn->gsup_client);</span><br><span style="color: hsl(0, 100%, 40%);">-      sgsn->gsup_client = NULL;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-    cleanup_test();</span><br><span style="color: hsl(0, 100%, 40%);">-}</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span> /*</span><br><span>  * Test the GMM Rejects</span><br><span>  */</span><br><span>@@ -1639,513 +1337,6 @@</span><br><span>   cleanup_test();</span><br><span> }</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-/*</span><br><span style="color: hsl(0, 100%, 40%);">- * Test the dynamic allocation of P-TMSIs</span><br><span style="color: hsl(0, 100%, 40%);">- */</span><br><span style="color: hsl(0, 100%, 40%);">-static void test_gmm_ptmsi_allocation(void)</span><br><span style="color: hsl(0, 100%, 40%);">-{</span><br><span style="color: hsl(0, 100%, 40%);">-      struct gprs_ra_id raid = { .mnc=332, .mcc=112, .lac=16464, .rac=96};</span><br><span style="color: hsl(0, 100%, 40%);">-    struct sgsn_mm_ctx *ctx = NULL;</span><br><span style="color: hsl(0, 100%, 40%);">- struct sgsn_mm_ctx *ictx;</span><br><span style="color: hsl(0, 100%, 40%);">-       uint32_t foreign_tlli;</span><br><span style="color: hsl(0, 100%, 40%);">-  uint32_t ptmsi1;</span><br><span style="color: hsl(0, 100%, 40%);">-        uint32_t ptmsi2;</span><br><span style="color: hsl(0, 100%, 40%);">-        uint32_t received_ptmsi;</span><br><span style="color: hsl(0, 100%, 40%);">-        uint32_t old_ptmsi;</span><br><span style="color: hsl(0, 100%, 40%);">-     uint32_t local_tlli = 0;</span><br><span style="color: hsl(0, 100%, 40%);">-        struct gprs_llc_lle *lle;</span><br><span style="color: hsl(0, 100%, 40%);">-       const enum sgsn_auth_policy saved_auth_policy = sgsn->cfg.auth_policy;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-       /* DTAP - Attach Request (IMSI 12131415161718) */</span><br><span style="color: hsl(0, 100%, 40%);">-       static const unsigned char attach_req[] = {</span><br><span style="color: hsl(0, 100%, 40%);">-             0x08, 0x01, 0x02, 0xf5, 0xe0, 0x21, 0x08, 0x02,</span><br><span style="color: hsl(0, 100%, 40%);">-         0x08, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,</span><br><span style="color: hsl(0, 100%, 40%);">-         0x18, 0x11, 0x22, 0x33, 0x40, 0x50, 0x60, 0x19,</span><br><span style="color: hsl(0, 100%, 40%);">-         0x18, 0xb3, 0x43, 0x2b, 0x25, 0x96, 0x62, 0x00,</span><br><span style="color: hsl(0, 100%, 40%);">-         0x60, 0x80, 0x9a, 0xc2, 0xc6, 0x62, 0x00, 0x60,</span><br><span style="color: hsl(0, 100%, 40%);">-         0x80, 0xba, 0xc8, 0xc6, 0x62, 0x00, 0x60, 0x80,</span><br><span style="color: hsl(0, 100%, 40%);">-         0x00,</span><br><span style="color: hsl(0, 100%, 40%);">-   };</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-      /* DTAP - Identity Response IMEI */</span><br><span style="color: hsl(0, 100%, 40%);">-     static const unsigned char ident_resp_imei[] = {</span><br><span style="color: hsl(0, 100%, 40%);">-                0x08, 0x16, 0x08, 0x9a, 0x78, 0x56, 0x34, 0x12, 0x90, 0x78,</span><br><span style="color: hsl(0, 100%, 40%);">-             0x56</span><br><span style="color: hsl(0, 100%, 40%);">-    };</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-      /* DTAP - Attach Complete */</span><br><span style="color: hsl(0, 100%, 40%);">-    static const unsigned char attach_compl[] = {</span><br><span style="color: hsl(0, 100%, 40%);">-           0x08, 0x03</span><br><span style="color: hsl(0, 100%, 40%);">-      };</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-      /* DTAP - Routing Area Update Request */</span><br><span style="color: hsl(0, 100%, 40%);">-        static const unsigned char ra_upd_req[] = {</span><br><span style="color: hsl(0, 100%, 40%);">-             0x08, 0x08, 0x10, 0x11, 0x22, 0x33, 0x40, 0x50,</span><br><span style="color: hsl(0, 100%, 40%);">-         0x60, 0x1d, 0x19, 0x13, 0x42, 0x33, 0x57, 0x2b,</span><br><span style="color: hsl(0, 100%, 40%);">-         0xf7, 0xc8, 0x48, 0x02, 0x13, 0x48, 0x50, 0xc8,</span><br><span style="color: hsl(0, 100%, 40%);">-         0x48, 0x02, 0x14, 0x48, 0x50, 0xc8, 0x48, 0x02,</span><br><span style="color: hsl(0, 100%, 40%);">-         0x17, 0x49, 0x10, 0xc8, 0x48, 0x02, 0x00, 0x19,</span><br><span style="color: hsl(0, 100%, 40%);">-         0x8b, 0xb2, 0x92, 0x17, 0x16, 0x27, 0x07, 0x04,</span><br><span style="color: hsl(0, 100%, 40%);">-         0x31, 0x02, 0xe5, 0xe0, 0x32, 0x02, 0x20, 0x00</span><br><span style="color: hsl(0, 100%, 40%);">-  };</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-      /* DTAP - Routing Area Update Complete */</span><br><span style="color: hsl(0, 100%, 40%);">-       static const unsigned char ra_upd_complete[] = {</span><br><span style="color: hsl(0, 100%, 40%);">-                0x08, 0x0a</span><br><span style="color: hsl(0, 100%, 40%);">-      };</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-      /* DTAP - Detach Request (MO) */</span><br><span style="color: hsl(0, 100%, 40%);">-        /* normal detach, power_off = 1 */</span><br><span style="color: hsl(0, 100%, 40%);">-      static const unsigned char detach_req[] = {</span><br><span style="color: hsl(0, 100%, 40%);">-             0x08, 0x05, 0x09, 0x18, 0x05, 0xf4, 0xef, 0xe2,</span><br><span style="color: hsl(0, 100%, 40%);">-         0xb7, 0x00, 0x19, 0x03, 0xb9, 0x97, 0xcb</span><br><span style="color: hsl(0, 100%, 40%);">-        };</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-      sgsn->cfg.auth_policy = SGSN_AUTH_POLICY_OPEN;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-       printf("Testing P-TMSI allocation\n");</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-        printf("  - sgsn_alloc_ptmsi\n");</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-     /* reset the PRNG used by sgsn_alloc_ptmsi */</span><br><span style="color: hsl(0, 100%, 40%);">-   srand(1);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-       ptmsi1 = sgsn_alloc_ptmsi();</span><br><span style="color: hsl(0, 100%, 40%);">-    OSMO_ASSERT(ptmsi1 != GSM_RESERVED_TMSI);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-       ptmsi2 = sgsn_alloc_ptmsi();</span><br><span style="color: hsl(0, 100%, 40%);">-    OSMO_ASSERT(ptmsi2 != GSM_RESERVED_TMSI);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-       OSMO_ASSERT(ptmsi1 != ptmsi2);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-  ptmsi1 = ptmsi2 = GSM_RESERVED_TMSI;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-    printf("  - Repeated Attach Request\n");</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-      foreign_tlli = gprs_tmsi2tlli(0xc0000023, TLLI_FOREIGN);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-        /* Create a LLE/LLME */</span><br><span style="color: hsl(0, 100%, 40%);">- OSMO_ASSERT(count(gprs_llme_list()) == 0);</span><br><span style="color: hsl(0, 100%, 40%);">-      lle = gprs_lle_get_or_create(foreign_tlli, 3);</span><br><span style="color: hsl(0, 100%, 40%);">-  OSMO_ASSERT(count(gprs_llme_list()) == 1);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-      /* inject the attach request */</span><br><span style="color: hsl(0, 100%, 40%);">- send_0408_message(lle->llme, foreign_tlli, &raid,</span><br><span style="color: hsl(0, 100%, 40%);">-                          attach_req, ARRAY_SIZE(attach_req));</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-  ctx = sgsn_mm_ctx_by_tlli(foreign_tlli, &raid);</span><br><span style="color: hsl(0, 100%, 40%);">-     OSMO_ASSERT(ctx != NULL);</span><br><span style="color: hsl(0, 100%, 40%);">-       OSMO_ASSERT(ctx->gmm_state == GMM_COMMON_PROC_INIT);</span><br><span style="color: hsl(0, 100%, 40%);">- OSMO_ASSERT(ctx->p_tmsi != GSM_RESERVED_TMSI);</span><br><span style="color: hsl(0, 100%, 40%);">-       ptmsi1 = ctx->p_tmsi;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-        old_ptmsi = ctx->p_tmsi_old;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">- /* we expect an identity request (IMEI) */</span><br><span style="color: hsl(0, 100%, 40%);">-      OSMO_ASSERT(sgsn_tx_counter == 1);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-      /* inject the identity response (IMEI) */</span><br><span style="color: hsl(0, 100%, 40%);">-       send_0408_message(ctx->gb.llme, foreign_tlli, &raid,</span><br><span style="color: hsl(0, 100%, 40%);">-                       ident_resp_imei, ARRAY_SIZE(ident_resp_imei));</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-        /* check that the MM context has not been removed due to a failed</span><br><span style="color: hsl(0, 100%, 40%);">-        * authorization */</span><br><span style="color: hsl(0, 100%, 40%);">-     OSMO_ASSERT(ctx == sgsn_mm_ctx_by_tlli(foreign_tlli, &raid));</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-       OSMO_ASSERT(ctx->gmm_state == GMM_COMMON_PROC_INIT);</span><br><span style="color: hsl(0, 100%, 40%);">- OSMO_ASSERT(ctx->p_tmsi == ptmsi1);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-  /* we expect an attach accept */</span><br><span style="color: hsl(0, 100%, 40%);">-        OSMO_ASSERT(sgsn_tx_counter == 1);</span><br><span style="color: hsl(0, 100%, 40%);">-      received_ptmsi = get_new_ptmsi(&last_dl_parse_ctx);</span><br><span style="color: hsl(0, 100%, 40%);">- OSMO_ASSERT(received_ptmsi == ptmsi1);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-  /* we ignore this and send the attach again */</span><br><span style="color: hsl(0, 100%, 40%);">-  send_0408_message(lle->llme, foreign_tlli, &raid,</span><br><span style="color: hsl(0, 100%, 40%);">-                          attach_req, ARRAY_SIZE(attach_req));</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-  /* the allocated P-TMSI should be the same */</span><br><span style="color: hsl(0, 100%, 40%);">-   ctx = sgsn_mm_ctx_by_tlli(foreign_tlli, &raid);</span><br><span style="color: hsl(0, 100%, 40%);">-     OSMO_ASSERT(ctx != NULL);</span><br><span style="color: hsl(0, 100%, 40%);">-       OSMO_ASSERT(ctx->gmm_state == GMM_COMMON_PROC_INIT);</span><br><span style="color: hsl(0, 100%, 40%);">- OSMO_ASSERT(ctx->p_tmsi_old == old_ptmsi);</span><br><span style="color: hsl(0, 100%, 40%);">-   OSMO_ASSERT(ctx->p_tmsi == ptmsi1);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-  /* we expect an attach accept */</span><br><span style="color: hsl(0, 100%, 40%);">-        OSMO_ASSERT(sgsn_tx_counter == 1);</span><br><span style="color: hsl(0, 100%, 40%);">-      received_ptmsi = get_new_ptmsi(&last_dl_parse_ctx);</span><br><span style="color: hsl(0, 100%, 40%);">- OSMO_ASSERT(received_ptmsi == ptmsi1);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-  /* inject the attach complete */</span><br><span style="color: hsl(0, 100%, 40%);">-        local_tlli = gprs_tmsi2tlli(ptmsi1, TLLI_LOCAL);</span><br><span style="color: hsl(0, 100%, 40%);">-        send_0408_message(ctx->gb.llme, local_tlli, &raid,</span><br><span style="color: hsl(0, 100%, 40%);">-                         attach_compl, ARRAY_SIZE(attach_compl));</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-      /* we don't expect a response */</span><br><span style="color: hsl(0, 100%, 40%);">-    OSMO_ASSERT(sgsn_tx_counter == 0);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-      OSMO_ASSERT(ctx->gmm_state == GMM_REGISTERED_NORMAL);</span><br><span style="color: hsl(0, 100%, 40%);">-        OSMO_ASSERT(ctx->p_tmsi_old == 0);</span><br><span style="color: hsl(0, 100%, 40%);">-   OSMO_ASSERT(ctx->p_tmsi == ptmsi1);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-  printf("  - Repeated RA Update Request\n");</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-   /* inject the RA update request */</span><br><span style="color: hsl(0, 100%, 40%);">-      send_0408_message(ctx->gb.llme, local_tlli, &raid,</span><br><span style="color: hsl(0, 100%, 40%);">-                         ra_upd_req, ARRAY_SIZE(ra_upd_req));</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-  /* we expect an RA update accept */</span><br><span style="color: hsl(0, 100%, 40%);">-     OSMO_ASSERT(sgsn_tx_counter == 1);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-      OSMO_ASSERT(ctx->gmm_state == GMM_COMMON_PROC_INIT);</span><br><span style="color: hsl(0, 100%, 40%);">- OSMO_ASSERT(ctx->p_tmsi_old == ptmsi1);</span><br><span style="color: hsl(0, 100%, 40%);">-      OSMO_ASSERT(ctx->p_tmsi != GSM_RESERVED_TMSI);</span><br><span style="color: hsl(0, 100%, 40%);">-       OSMO_ASSERT(ctx->p_tmsi != ptmsi1);</span><br><span style="color: hsl(0, 100%, 40%);">-  ptmsi2 = ctx->p_tmsi;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-        /* repeat the RA update request */</span><br><span style="color: hsl(0, 100%, 40%);">-      send_0408_message(ctx->gb.llme, local_tlli, &raid,</span><br><span style="color: hsl(0, 100%, 40%);">-                         ra_upd_req, ARRAY_SIZE(ra_upd_req));</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-  /* we expect an RA update accept */</span><br><span style="color: hsl(0, 100%, 40%);">-     OSMO_ASSERT(sgsn_tx_counter == 1);</span><br><span style="color: hsl(0, 100%, 40%);">-      received_ptmsi = get_new_ptmsi(&last_dl_parse_ctx);</span><br><span style="color: hsl(0, 100%, 40%);">- OSMO_ASSERT(received_ptmsi == ptmsi2);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-  OSMO_ASSERT(ctx->gmm_state == GMM_COMMON_PROC_INIT);</span><br><span style="color: hsl(0, 100%, 40%);">- OSMO_ASSERT(ctx->p_tmsi_old == ptmsi1);</span><br><span style="color: hsl(0, 100%, 40%);">-      OSMO_ASSERT(ctx->p_tmsi == ptmsi2);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-  /* inject the RA update complete */</span><br><span style="color: hsl(0, 100%, 40%);">-     local_tlli = gprs_tmsi2tlli(ptmsi2, TLLI_LOCAL);</span><br><span style="color: hsl(0, 100%, 40%);">-        send_0408_message(ctx->gb.llme, local_tlli, &raid,</span><br><span style="color: hsl(0, 100%, 40%);">-                         ra_upd_complete, ARRAY_SIZE(ra_upd_complete));</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-        /* we don't expect a response */</span><br><span style="color: hsl(0, 100%, 40%);">-    OSMO_ASSERT(sgsn_tx_counter == 0);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-      OSMO_ASSERT(ctx->gmm_state == GMM_REGISTERED_NORMAL);</span><br><span style="color: hsl(0, 100%, 40%);">-        OSMO_ASSERT(ctx->p_tmsi_old == 0);</span><br><span style="color: hsl(0, 100%, 40%);">-   OSMO_ASSERT(ctx->p_tmsi == ptmsi2);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-  /* inject the detach */</span><br><span style="color: hsl(0, 100%, 40%);">- send_0408_message(ctx->gb.llme, local_tlli, &raid,</span><br><span style="color: hsl(0, 100%, 40%);">-                         detach_req, ARRAY_SIZE(detach_req));</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-  /* verify that things are gone */</span><br><span style="color: hsl(0, 100%, 40%);">-       OSMO_ASSERT(count(gprs_llme_list()) == 0);</span><br><span style="color: hsl(0, 100%, 40%);">-      ictx = sgsn_mm_ctx_by_tlli(local_tlli, &raid);</span><br><span style="color: hsl(0, 100%, 40%);">-      OSMO_ASSERT(!ictx);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-     sgsn->cfg.auth_policy = saved_auth_policy;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-   cleanup_test();</span><br><span style="color: hsl(0, 100%, 40%);">-}</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-/*</span><br><span style="color: hsl(0, 100%, 40%);">- * Test changing of routing areas</span><br><span style="color: hsl(0, 100%, 40%);">- */</span><br><span style="color: hsl(0, 100%, 40%);">-static void test_gmm_routing_areas(void)</span><br><span style="color: hsl(0, 100%, 40%);">-{</span><br><span style="color: hsl(0, 100%, 40%);">- struct gprs_ra_id raid1 = { .mnc=332, .mcc=112, .lac=16464, .rac=96};</span><br><span style="color: hsl(0, 100%, 40%);">-   struct gprs_ra_id raid2 = { .mnc=332, .mcc=112, .lac=16464, .rac=97};</span><br><span style="color: hsl(0, 100%, 40%);">-   struct sgsn_mm_ctx *ctx = NULL;</span><br><span style="color: hsl(0, 100%, 40%);">- struct sgsn_mm_ctx *ictx;</span><br><span style="color: hsl(0, 100%, 40%);">-       uint32_t ptmsi1;</span><br><span style="color: hsl(0, 100%, 40%);">-        uint32_t received_ptmsi;</span><br><span style="color: hsl(0, 100%, 40%);">-        uint32_t ms_tlli = 0;</span><br><span style="color: hsl(0, 100%, 40%);">-   struct gprs_llc_lle *lle;</span><br><span style="color: hsl(0, 100%, 40%);">-       const enum sgsn_auth_policy saved_auth_policy = sgsn->cfg.auth_policy;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-       /* DTAP - Attach Request (IMSI 12131415161718) */</span><br><span style="color: hsl(0, 100%, 40%);">-       static const unsigned char attach_req[] = {</span><br><span style="color: hsl(0, 100%, 40%);">-             0x08, 0x01, 0x02, 0xf5, 0xe0, 0x21, 0x08, 0x02,</span><br><span style="color: hsl(0, 100%, 40%);">-         0x08, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,</span><br><span style="color: hsl(0, 100%, 40%);">-         0x18, 0x11, 0x22, 0x33, 0x40, 0x50, 0x60, 0x19,</span><br><span style="color: hsl(0, 100%, 40%);">-         0x18, 0xb3, 0x43, 0x2b, 0x25, 0x96, 0x62, 0x00,</span><br><span style="color: hsl(0, 100%, 40%);">-         0x60, 0x80, 0x9a, 0xc2, 0xc6, 0x62, 0x00, 0x60,</span><br><span style="color: hsl(0, 100%, 40%);">-         0x80, 0xba, 0xc8, 0xc6, 0x62, 0x00, 0x60, 0x80,</span><br><span style="color: hsl(0, 100%, 40%);">-         0x00,</span><br><span style="color: hsl(0, 100%, 40%);">-   };</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-      /* DTAP - Attach Request (IMSI 12131415161718) (RA 2) */</span><br><span style="color: hsl(0, 100%, 40%);">-        static const unsigned char attach_req2[] = {</span><br><span style="color: hsl(0, 100%, 40%);">-            0x08, 0x01, 0x02, 0xf5, 0xe0, 0x21, 0x08, 0x02,</span><br><span style="color: hsl(0, 100%, 40%);">-         0x08, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,</span><br><span style="color: hsl(0, 100%, 40%);">-         0x18, 0x11, 0x22, 0x33, 0x40, 0x50, 0x61, 0x19,</span><br><span style="color: hsl(0, 100%, 40%);">-         0x18, 0xb3, 0x43, 0x2b, 0x25, 0x96, 0x62, 0x00,</span><br><span style="color: hsl(0, 100%, 40%);">-         0x60, 0x80, 0x9a, 0xc2, 0xc6, 0x62, 0x00, 0x60,</span><br><span style="color: hsl(0, 100%, 40%);">-         0x80, 0xba, 0xc8, 0xc6, 0x62, 0x00, 0x60, 0x80,</span><br><span style="color: hsl(0, 100%, 40%);">-         0x00,</span><br><span style="color: hsl(0, 100%, 40%);">-   };</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-      /* DTAP - Identity Response IMEI */</span><br><span style="color: hsl(0, 100%, 40%);">-     static const unsigned char ident_resp_imei[] = {</span><br><span style="color: hsl(0, 100%, 40%);">-                0x08, 0x16, 0x08, 0x9a, 0x78, 0x56, 0x34, 0x12, 0x90, 0x78,</span><br><span style="color: hsl(0, 100%, 40%);">-             0x56</span><br><span style="color: hsl(0, 100%, 40%);">-    };</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-      /* DTAP - Attach Complete */</span><br><span style="color: hsl(0, 100%, 40%);">-    static const unsigned char attach_compl[] = {</span><br><span style="color: hsl(0, 100%, 40%);">-           0x08, 0x03</span><br><span style="color: hsl(0, 100%, 40%);">-      };</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-      /* DTAP - Routing Area Update Request (coming from RA 1) */</span><br><span style="color: hsl(0, 100%, 40%);">-     static const unsigned char ra_upd_req1[] = {</span><br><span style="color: hsl(0, 100%, 40%);">-            0x08, 0x08, 0x10, 0x11, 0x22, 0x33, 0x40, 0x50,</span><br><span style="color: hsl(0, 100%, 40%);">-         0x60, 0x1d, 0x19, 0x13, 0x42, 0x33, 0x57, 0x2b,</span><br><span style="color: hsl(0, 100%, 40%);">-         0xf7, 0xc8, 0x48, 0x02, 0x13, 0x48, 0x50, 0xc8,</span><br><span style="color: hsl(0, 100%, 40%);">-         0x48, 0x02, 0x14, 0x48, 0x50, 0xc8, 0x48, 0x02,</span><br><span style="color: hsl(0, 100%, 40%);">-         0x17, 0x49, 0x10, 0xc8, 0x48, 0x02, 0x00, 0x19,</span><br><span style="color: hsl(0, 100%, 40%);">-         0x8b, 0xb2, 0x92, 0x17, 0x16, 0x27, 0x07, 0x04,</span><br><span style="color: hsl(0, 100%, 40%);">-         0x31, 0x02, 0xe5, 0xe0, 0x32, 0x02, 0x20, 0x00</span><br><span style="color: hsl(0, 100%, 40%);">-  };</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-      /* DTAP - Routing Area Update Request (coming from RA 2) */</span><br><span style="color: hsl(0, 100%, 40%);">-     static const unsigned char ra_upd_req2[] = {</span><br><span style="color: hsl(0, 100%, 40%);">-            0x08, 0x08, 0x10, 0x11, 0x22, 0x33, 0x40, 0x50,</span><br><span style="color: hsl(0, 100%, 40%);">-         0x61, 0x1d, 0x19, 0x13, 0x42, 0x33, 0x57, 0x2b,</span><br><span style="color: hsl(0, 100%, 40%);">-         0xf7, 0xc8, 0x48, 0x02, 0x13, 0x48, 0x50, 0xc8,</span><br><span style="color: hsl(0, 100%, 40%);">-         0x48, 0x02, 0x14, 0x48, 0x50, 0xc8, 0x48, 0x02,</span><br><span style="color: hsl(0, 100%, 40%);">-         0x17, 0x49, 0x10, 0xc8, 0x48, 0x02, 0x00, 0x19,</span><br><span style="color: hsl(0, 100%, 40%);">-         0x8b, 0xb2, 0x92, 0x17, 0x16, 0x27, 0x07, 0x04,</span><br><span style="color: hsl(0, 100%, 40%);">-         0x31, 0x02, 0xe5, 0xe0, 0x32, 0x02, 0x20, 0x00</span><br><span style="color: hsl(0, 100%, 40%);">-  };</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-      /* DTAP - Routing Area Update Request (coming from RA other) */</span><br><span style="color: hsl(0, 100%, 40%);">- /* raid_other = {443, 223, 16464, 98}; */</span><br><span style="color: hsl(0, 100%, 40%);">-       static const unsigned char ra_upd_req_other[] = {</span><br><span style="color: hsl(0, 100%, 40%);">-               0x08, 0x08, 0x10, 0x22, 0x33, 0x44, 0x40, 0x50,</span><br><span style="color: hsl(0, 100%, 40%);">-         0x62, 0x1d, 0x19, 0x13, 0x42, 0x33, 0x57, 0x2b,</span><br><span style="color: hsl(0, 100%, 40%);">-         0xf7, 0xc8, 0x48, 0x02, 0x13, 0x48, 0x50, 0xc8,</span><br><span style="color: hsl(0, 100%, 40%);">-         0x48, 0x02, 0x14, 0x48, 0x50, 0xc8, 0x48, 0x02,</span><br><span style="color: hsl(0, 100%, 40%);">-         0x17, 0x49, 0x10, 0xc8, 0x48, 0x02, 0x00, 0x19,</span><br><span style="color: hsl(0, 100%, 40%);">-         0x8b, 0xb2, 0x92, 0x17, 0x16, 0x27, 0x07, 0x04,</span><br><span style="color: hsl(0, 100%, 40%);">-         0x31, 0x02, 0xe5, 0xe0, 0x32, 0x02, 0x20, 0x00</span><br><span style="color: hsl(0, 100%, 40%);">-  };</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-      /* DTAP - Routing Area Update Complete */</span><br><span style="color: hsl(0, 100%, 40%);">-       static const unsigned char ra_upd_complete[] = {</span><br><span style="color: hsl(0, 100%, 40%);">-                0x08, 0x0a</span><br><span style="color: hsl(0, 100%, 40%);">-      };</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-      /* DTAP - Detach Request (MO) */</span><br><span style="color: hsl(0, 100%, 40%);">-        /* normal detach, power_off = 1 */</span><br><span style="color: hsl(0, 100%, 40%);">-      static const unsigned char detach_req[] = {</span><br><span style="color: hsl(0, 100%, 40%);">-             0x08, 0x05, 0x09, 0x18, 0x05, 0xf4, 0xef, 0xe2,</span><br><span style="color: hsl(0, 100%, 40%);">-         0xb7, 0x00, 0x19, 0x03, 0xb9, 0x97, 0xcb</span><br><span style="color: hsl(0, 100%, 40%);">-        };</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-      sgsn->cfg.auth_policy = SGSN_AUTH_POLICY_OPEN;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-       printf("Testing routing area changes\n");</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-     /* reset the PRNG used by sgsn_alloc_ptmsi */</span><br><span style="color: hsl(0, 100%, 40%);">-   srand(1);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-       ptmsi1 = GSM_RESERVED_TMSI;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-     printf("  - Attach Request (RA 1)\n");</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-        ms_tlli = gprs_tmsi2tlli(0x00000023, TLLI_RANDOM);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-      /* Create a LLE/LLME */</span><br><span style="color: hsl(0, 100%, 40%);">- OSMO_ASSERT(count(gprs_llme_list()) == 0);</span><br><span style="color: hsl(0, 100%, 40%);">-      lle = gprs_lle_get_or_create(ms_tlli, 3);</span><br><span style="color: hsl(0, 100%, 40%);">-       OSMO_ASSERT(count(gprs_llme_list()) == 1);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-      /* inject the attach request */</span><br><span style="color: hsl(0, 100%, 40%);">- send_0408_message(lle->llme, ms_tlli, &raid1,</span><br><span style="color: hsl(0, 100%, 40%);">-                      attach_req, ARRAY_SIZE(attach_req));</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-  ctx = sgsn_mm_ctx_by_tlli(ms_tlli, &raid1);</span><br><span style="color: hsl(0, 100%, 40%);">- OSMO_ASSERT(ctx != NULL);</span><br><span style="color: hsl(0, 100%, 40%);">-       OSMO_ASSERT(ctx->gmm_state == GMM_COMMON_PROC_INIT);</span><br><span style="color: hsl(0, 100%, 40%);">- OSMO_ASSERT(ctx->p_tmsi != GSM_RESERVED_TMSI);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-       /* we expect an identity request (IMEI) */</span><br><span style="color: hsl(0, 100%, 40%);">-      OSMO_ASSERT(sgsn_tx_counter == 1);</span><br><span style="color: hsl(0, 100%, 40%);">-      OSMO_ASSERT(last_dl_parse_ctx.g48_hdr->msg_type == GSM48_MT_GMM_ID_REQ);</span><br><span style="color: hsl(0, 100%, 40%);">-     OSMO_ASSERT(last_dl_parse_ctx.tlli == ms_tlli);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">- /* inject the identity response (IMEI) */</span><br><span style="color: hsl(0, 100%, 40%);">-       send_0408_message(ctx->gb.llme, ms_tlli, &raid1,</span><br><span style="color: hsl(0, 100%, 40%);">-                   ident_resp_imei, ARRAY_SIZE(ident_resp_imei));</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-        /* check that the MM context has not been removed due to a failed</span><br><span style="color: hsl(0, 100%, 40%);">-        * authorization */</span><br><span style="color: hsl(0, 100%, 40%);">-     OSMO_ASSERT(ctx == sgsn_mm_ctx_by_tlli(ms_tlli, &raid1));</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-   OSMO_ASSERT(ctx->gmm_state == GMM_COMMON_PROC_INIT);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">- /* we expect an attach accept */</span><br><span style="color: hsl(0, 100%, 40%);">-        OSMO_ASSERT(sgsn_tx_counter == 1);</span><br><span style="color: hsl(0, 100%, 40%);">-      OSMO_ASSERT(last_dl_parse_ctx.g48_hdr->msg_type == GSM48_MT_GMM_ATTACH_ACK);</span><br><span style="color: hsl(0, 100%, 40%);">- OSMO_ASSERT(last_dl_parse_ctx.tlli == ms_tlli);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">- received_ptmsi = get_new_ptmsi(&last_dl_parse_ctx);</span><br><span style="color: hsl(0, 100%, 40%);">- OSMO_ASSERT(received_ptmsi == ctx->p_tmsi);</span><br><span style="color: hsl(0, 100%, 40%);">-  ptmsi1 = received_ptmsi;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-        /* inject the attach complete */</span><br><span style="color: hsl(0, 100%, 40%);">-        ms_tlli = gprs_tmsi2tlli(ptmsi1, TLLI_LOCAL);</span><br><span style="color: hsl(0, 100%, 40%);">-   send_0408_message(ctx->gb.llme, ms_tlli, &raid1,</span><br><span style="color: hsl(0, 100%, 40%);">-                   attach_compl, ARRAY_SIZE(attach_compl));</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-      /* we don't expect a response */</span><br><span style="color: hsl(0, 100%, 40%);">-    OSMO_ASSERT(sgsn_tx_counter == 0);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-      OSMO_ASSERT(ctx->gmm_state == GMM_REGISTERED_NORMAL);</span><br><span style="color: hsl(0, 100%, 40%);">-        OSMO_ASSERT(ctx->p_tmsi_old == 0);</span><br><span style="color: hsl(0, 100%, 40%);">-   OSMO_ASSERT(ctx->p_tmsi == ptmsi1);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-  printf("  - RA Update Request (RA 1 -> RA 1)\n");</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-  /* inject the RA update request */</span><br><span style="color: hsl(0, 100%, 40%);">-      send_0408_message(ctx->gb.llme, ms_tlli, &raid1,</span><br><span style="color: hsl(0, 100%, 40%);">-                   ra_upd_req1, ARRAY_SIZE(ra_upd_req1));</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-        /* we expect an RA update accept */</span><br><span style="color: hsl(0, 100%, 40%);">-     OSMO_ASSERT(sgsn_tx_counter == 1);</span><br><span style="color: hsl(0, 100%, 40%);">-      OSMO_ASSERT(last_dl_parse_ctx.g48_hdr->msg_type == GSM48_MT_GMM_RA_UPD_ACK);</span><br><span style="color: hsl(0, 100%, 40%);">- // OSMO_ASSERT(last_dl_parse_ctx.tlli == ms_tlli);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-      OSMO_ASSERT(ctx->gmm_state == GMM_COMMON_PROC_INIT);</span><br><span style="color: hsl(0, 100%, 40%);">- OSMO_ASSERT(ctx->p_tmsi_old == ptmsi1);</span><br><span style="color: hsl(0, 100%, 40%);">-      OSMO_ASSERT(ctx->p_tmsi != GSM_RESERVED_TMSI);</span><br><span style="color: hsl(0, 100%, 40%);">-       OSMO_ASSERT(ctx->p_tmsi != ptmsi1);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-  received_ptmsi = get_new_ptmsi(&last_dl_parse_ctx);</span><br><span style="color: hsl(0, 100%, 40%);">- OSMO_ASSERT(received_ptmsi == ctx->p_tmsi);</span><br><span style="color: hsl(0, 100%, 40%);">-  ptmsi1 = received_ptmsi;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-        /* inject the RA update complete */</span><br><span style="color: hsl(0, 100%, 40%);">-     ms_tlli = gprs_tmsi2tlli(ptmsi1, TLLI_LOCAL);</span><br><span style="color: hsl(0, 100%, 40%);">-   send_0408_message(ctx->gb.llme, ms_tlli, &raid1,</span><br><span style="color: hsl(0, 100%, 40%);">-                   ra_upd_complete, ARRAY_SIZE(ra_upd_complete));</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-        /* we don't expect a response */</span><br><span style="color: hsl(0, 100%, 40%);">-    OSMO_ASSERT(sgsn_tx_counter == 0);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-      OSMO_ASSERT(ctx->gmm_state == GMM_REGISTERED_NORMAL);</span><br><span style="color: hsl(0, 100%, 40%);">-        OSMO_ASSERT(ctx->p_tmsi_old == 0);</span><br><span style="color: hsl(0, 100%, 40%);">-   OSMO_ASSERT(ctx->p_tmsi == ptmsi1);</span><br><span style="color: hsl(0, 100%, 40%);">-  OSMO_ASSERT(ctx->gb.tlli == ms_tlli);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-        printf("  - RA Update Request (RA 1 -> RA 2)\n");</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-  /* inject the RA update request */</span><br><span style="color: hsl(0, 100%, 40%);">-      ms_tlli = gprs_tmsi2tlli(ptmsi1, TLLI_FOREIGN);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">- /* It is coming from RA 1 => ra_upd_req1 */</span><br><span style="color: hsl(0, 100%, 40%);">-  send_0408_message(ctx->gb.llme, ms_tlli, &raid2,</span><br><span style="color: hsl(0, 100%, 40%);">-                   ra_upd_req1, ARRAY_SIZE(ra_upd_req1));</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-        /* we expect an RA update accept */</span><br><span style="color: hsl(0, 100%, 40%);">-     OSMO_ASSERT(sgsn_tx_counter == 1);</span><br><span style="color: hsl(0, 100%, 40%);">-      OSMO_ASSERT(last_dl_parse_ctx.g48_hdr->msg_type == GSM48_MT_GMM_RA_UPD_ACK);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">- printf("  - RA Update Request (RA other -> RA 2)\n");</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-      /* inject the RA update request */</span><br><span style="color: hsl(0, 100%, 40%);">-      ms_tlli = gprs_tmsi2tlli(0x12345678, TLLI_FOREIGN);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-     /* It is coming from RA 1 => ra_upd_req1 */</span><br><span style="color: hsl(0, 100%, 40%);">-  send_0408_message(ctx->gb.llme, ms_tlli, &raid2,</span><br><span style="color: hsl(0, 100%, 40%);">-                   ra_upd_req_other, ARRAY_SIZE(ra_upd_req_other));</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-      /* we expect an RA update reject (and a LLC XID RESET) */</span><br><span style="color: hsl(0, 100%, 40%);">-       OSMO_ASSERT(sgsn_tx_counter == 2);</span><br><span style="color: hsl(0, 100%, 40%);">-      OSMO_ASSERT(last_dl_parse_ctx.g48_hdr->msg_type == GSM48_MT_GMM_RA_UPD_REJ);</span><br><span style="color: hsl(0, 100%, 40%);">- /* this has killed the LLE/LLME */</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-      printf("  - Attach Request (RA 2)\n");</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-        /* Create a LLE/LLME */</span><br><span style="color: hsl(0, 100%, 40%);">- OSMO_ASSERT(count(gprs_llme_list()) == 1);</span><br><span style="color: hsl(0, 100%, 40%);">-      lle = gprs_lle_get_or_create(ms_tlli, 3);</span><br><span style="color: hsl(0, 100%, 40%);">-       OSMO_ASSERT(count(gprs_llme_list()) == 1);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-      /* inject the attach request */</span><br><span style="color: hsl(0, 100%, 40%);">- send_0408_message(lle->llme, ms_tlli, &raid2,</span><br><span style="color: hsl(0, 100%, 40%);">-                      attach_req2, ARRAY_SIZE(attach_req2));</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-        ctx = sgsn_mm_ctx_by_tlli(ms_tlli, &raid2);</span><br><span style="color: hsl(0, 100%, 40%);">- OSMO_ASSERT(ctx != NULL);</span><br><span style="color: hsl(0, 100%, 40%);">-       OSMO_ASSERT(ctx->gmm_state == GMM_COMMON_PROC_INIT);</span><br><span style="color: hsl(0, 100%, 40%);">- OSMO_ASSERT(ctx->p_tmsi != GSM_RESERVED_TMSI);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-       /* we expect an attach accept */</span><br><span style="color: hsl(0, 100%, 40%);">-        OSMO_ASSERT(sgsn_tx_counter == 1);</span><br><span style="color: hsl(0, 100%, 40%);">-      OSMO_ASSERT(last_dl_parse_ctx.g48_hdr->msg_type == GSM48_MT_GMM_ATTACH_ACK);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">- received_ptmsi = get_new_ptmsi(&last_dl_parse_ctx);</span><br><span style="color: hsl(0, 100%, 40%);">- OSMO_ASSERT(received_ptmsi == ctx->p_tmsi);</span><br><span style="color: hsl(0, 100%, 40%);">-  ptmsi1 = received_ptmsi;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-        /* inject the attach complete */</span><br><span style="color: hsl(0, 100%, 40%);">-        ms_tlli = gprs_tmsi2tlli(ptmsi1, TLLI_LOCAL);</span><br><span style="color: hsl(0, 100%, 40%);">-   ictx = sgsn_mm_ctx_by_tlli(ms_tlli, &raid2);</span><br><span style="color: hsl(0, 100%, 40%);">-        OSMO_ASSERT(ictx != NULL);</span><br><span style="color: hsl(0, 100%, 40%);">-      OSMO_ASSERT(ictx == ctx);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-       send_0408_message(ctx->gb.llme, ms_tlli, &raid2,</span><br><span style="color: hsl(0, 100%, 40%);">-                   attach_compl, ARRAY_SIZE(attach_compl));</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-      /* we don't expect a response */</span><br><span style="color: hsl(0, 100%, 40%);">-    OSMO_ASSERT(sgsn_tx_counter == 0);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-      OSMO_ASSERT(ctx->gmm_state == GMM_REGISTERED_NORMAL);</span><br><span style="color: hsl(0, 100%, 40%);">-        OSMO_ASSERT(ctx->p_tmsi_old == 0);</span><br><span style="color: hsl(0, 100%, 40%);">-   OSMO_ASSERT(ctx->p_tmsi == ptmsi1);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-  printf("  - RA Update Request (RA 2 -> RA 2)\n");</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-  /* inject the RA update request */</span><br><span style="color: hsl(0, 100%, 40%);">-      send_0408_message(ctx->gb.llme, ms_tlli, &raid2,</span><br><span style="color: hsl(0, 100%, 40%);">-                   ra_upd_req2, ARRAY_SIZE(ra_upd_req2));</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-        /* we expect an RA update accept */</span><br><span style="color: hsl(0, 100%, 40%);">-     OSMO_ASSERT(sgsn_tx_counter == 1);</span><br><span style="color: hsl(0, 100%, 40%);">-      OSMO_ASSERT(last_dl_parse_ctx.g48_hdr->msg_type == GSM48_MT_GMM_RA_UPD_ACK);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">- OSMO_ASSERT(ctx->gmm_state == GMM_COMMON_PROC_INIT);</span><br><span style="color: hsl(0, 100%, 40%);">- OSMO_ASSERT(ctx->p_tmsi_old == ptmsi1);</span><br><span style="color: hsl(0, 100%, 40%);">-      OSMO_ASSERT(ctx->p_tmsi != GSM_RESERVED_TMSI);</span><br><span style="color: hsl(0, 100%, 40%);">-       OSMO_ASSERT(ctx->p_tmsi != ptmsi1);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-  received_ptmsi = get_new_ptmsi(&last_dl_parse_ctx);</span><br><span style="color: hsl(0, 100%, 40%);">- OSMO_ASSERT(received_ptmsi == ctx->p_tmsi);</span><br><span style="color: hsl(0, 100%, 40%);">-  ptmsi1 = received_ptmsi;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-        /* inject the RA update complete */</span><br><span style="color: hsl(0, 100%, 40%);">-     ms_tlli = gprs_tmsi2tlli(ptmsi1, TLLI_LOCAL);</span><br><span style="color: hsl(0, 100%, 40%);">-   send_0408_message(ctx->gb.llme, ms_tlli, &raid2,</span><br><span style="color: hsl(0, 100%, 40%);">-                   ra_upd_complete, ARRAY_SIZE(ra_upd_complete));</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-        /* we don't expect a response */</span><br><span style="color: hsl(0, 100%, 40%);">-    OSMO_ASSERT(sgsn_tx_counter == 0);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-      OSMO_ASSERT(ctx->gmm_state == GMM_REGISTERED_NORMAL);</span><br><span style="color: hsl(0, 100%, 40%);">-        OSMO_ASSERT(ctx->p_tmsi_old == 0);</span><br><span style="color: hsl(0, 100%, 40%);">-   OSMO_ASSERT(ctx->p_tmsi == ptmsi1);</span><br><span style="color: hsl(0, 100%, 40%);">-  OSMO_ASSERT(ctx->gb.tlli == ms_tlli);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-        /* inject the detach */</span><br><span style="color: hsl(0, 100%, 40%);">- send_0408_message(ctx->gb.llme, ms_tlli, &raid2,</span><br><span style="color: hsl(0, 100%, 40%);">-                   detach_req, ARRAY_SIZE(detach_req));</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-  /* verify that things are gone */</span><br><span style="color: hsl(0, 100%, 40%);">-       OSMO_ASSERT(count(gprs_llme_list()) == 0);</span><br><span style="color: hsl(0, 100%, 40%);">-      ictx = sgsn_mm_ctx_by_tlli(ms_tlli, &raid2);</span><br><span style="color: hsl(0, 100%, 40%);">-        OSMO_ASSERT(!ictx);</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-     sgsn->cfg.auth_policy = saved_auth_policy;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-   cleanup_test();</span><br><span style="color: hsl(0, 100%, 40%);">-}</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span> static void test_apn_matching(void)</span><br><span> {</span><br><span>         struct apn_ctx *actx, *actxs[9];</span><br><span>@@ -2462,17 +1653,8 @@</span><br><span>    test_gmm_detach_no_mmctx();</span><br><span>  test_gmm_detach_accept_unexpected();</span><br><span>         test_gmm_status_no_mmctx();</span><br><span style="color: hsl(0, 100%, 40%);">-     test_gmm_attach_acl();</span><br><span style="color: hsl(0, 100%, 40%);">-  test_gmm_attach_subscr();</span><br><span style="color: hsl(0, 100%, 40%);">-       test_gmm_attach_subscr_fake_auth();</span><br><span style="color: hsl(0, 100%, 40%);">-     test_gmm_attach_subscr_real_auth();</span><br><span style="color: hsl(0, 100%, 40%);">-     test_gmm_attach_subscr_gsup_auth(0);</span><br><span style="color: hsl(0, 100%, 40%);">-    test_gmm_attach_subscr_gsup_auth(1);</span><br><span style="color: hsl(0, 100%, 40%);">-    test_gmm_attach_subscr_real_gsup_auth(0);</span><br><span>    test_gmm_reject();</span><br><span>   test_gmm_cancel();</span><br><span style="color: hsl(0, 100%, 40%);">-      test_gmm_ptmsi_allocation();</span><br><span style="color: hsl(0, 100%, 40%);">-    test_gmm_routing_areas();</span><br><span>    test_apn_matching();</span><br><span>         test_ggsn_selection();</span><br><span>       printf("Done\n");</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/9258">change 9258</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.osmocom.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.osmocom.org/9258"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: osmo-sgsn </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: Iac1c8854b5ea4aa03279990390ebc110c979aac2 </div>
<div style="display:none"> Gerrit-Change-Number: 9258 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: lynxis lazus <lynxis@fe80.eu> </div>