def sendPdnConnectivityReq(self, ue_id, apn, pdn_type=1, pcscf_addr_type=None): req = s1ap_types.uepdnConReq_t() req.ue_Id = ue_id # Initial Request req.reqType = 1 req.pdnType_pr.pres = 1 # PDN Type 1 = IPv4, 2 = IPv6, 3 = IPv4v6 req.pdnType_pr.pdn_type = pdn_type req.pdnAPN_pr.pres = 1 req.pdnAPN_pr.len = len(apn) req.pdnAPN_pr.pdn_apn = (ctypes.c_ubyte * 100)( *[ctypes.c_ubyte(ord(c)) for c in apn[:100]]) print("********* PDN type", pdn_type) # Populate PCO if pcscf_addr_type is set if pcscf_addr_type: print("********* pcscf_addr_type", pcscf_addr_type) self._s1_util.populate_pco(req.protCfgOpts_pr, pcscf_addr_type) self.s1_util.issue_cmd(s1ap_types.tfwCmd.UE_PDN_CONN_REQ, req) print("************* Sending Standalone PDN Connectivity Request\n")
def test_standalone_pdn_conn_req(self): """ Attach a single UE and send standalone PDN Connectivity Request """ self._s1ap_wrapper.configUEDevice(1) req = self._s1ap_wrapper.ue_req ue_id = req.ue_id print( "************************* Running End to End attach for UE id ", ue_id, ) # Now actually complete the attach self._s1ap_wrapper.s1_util.attach( ue_id, s1ap_types.tfwCmd.UE_END_TO_END_ATTACH_REQUEST, s1ap_types.tfwCmd.UE_ATTACH_ACCEPT_IND, s1ap_types.ueAttachAccept_t, ) # Wait on EMM Information from MME self._s1ap_wrapper._s1_util.receive_emm_info() print( "************************* Sending PDN Connectivity Request ", "for UE id ", ue_id, ) req = s1ap_types.uepdnConReq_t() req.ue_Id = ue_id # Request type = Initial Request req.reqType = 1 req.pdnType_pr.pres = 1 # PDN Type = IPv4 req.pdnType_pr.pdn_type = 1 req.pdnAPN_pr.pres = 1 s = 'internet.mnc012.mcc345.gprs' req.pdnAPN_pr.len = len(s) req.pdnAPN_pr.pdn_apn = (ctypes.c_ubyte * 100)(*[ctypes.c_ubyte(ord(c)) for c in s[:100]]) self._s1ap_wrapper.s1_util.issue_cmd( s1ap_types.tfwCmd.UE_PDN_CONN_REQ, req, ) # Receive PDN Connectivity Reject response = self._s1ap_wrapper.s1_util.get_response() self.assertEqual( response.msg_type, s1ap_types.tfwCmd.UE_PDN_CONN_RSP_IND.value, ) print("Received PDN CONNECTIVITY REJECT") print( "************************* Running UE detach (switch-off) for ", "UE id ", ue_id, ) # Now detach the UE self._s1ap_wrapper.s1_util.detach( ue_id, s1ap_types.ueDetachType_t.UE_SWITCHOFF_DETACH.value, False, )
def sendPdnConnectivityReq(self, ue_id, apn): req = s1ap_types.uepdnConReq_t() req.ue_Id = ue_id # Initial Request req.reqType = 1 req.pdnType_pr.pres = 1 # PDN Type = IPv4 req.pdnType_pr.pdn_type = 1 req.pdnAPN_pr.pres = 1 req.pdnAPN_pr.len = len(apn) req.pdnAPN_pr.pdn_apn = (ctypes.c_ubyte * 100)( *[ctypes.c_ubyte(ord(c)) for c in apn[:100]]) self.s1_util.issue_cmd(s1ap_types.tfwCmd.UE_PDN_CONN_REQ, req) print("************* Sending Standalone PDN Connectivity Request\n")
def test_standalone_pdn_conn_req_with_apn_correction(self): """ Attach a single UE and send standalone PDN Connectivity Request with wrong APN and use APN correction feature to override it""" num_ues = 1 print('************************* restarting mme') self._s1ap_wrapper.magmad_util.restart_services(['mme']) for j in range(15): print("Waiting mme restart for", j, "seconds") time.sleep(1) self._s1ap_wrapper.configUEDevice(num_ues) req = self._s1ap_wrapper.ue_req ue_id = req.ue_id print( "************************* Running End to End attach for UE id ", ue_id, ) # Now actually complete the attach self._s1ap_wrapper.s1_util.attach( ue_id, s1ap_types.tfwCmd.UE_END_TO_END_ATTACH_REQUEST, s1ap_types.tfwCmd.UE_ATTACH_ACCEPT_IND, s1ap_types.ueAttachAccept_t, ) # Wait on EMM Information from MME self._s1ap_wrapper._s1_util.receive_emm_info() print( "************************* Sending PDN Connectivity Request ", "for UE id ", ue_id, ) req = s1ap_types.uepdnConReq_t() req.ue_Id = ue_id # Request type = Initial Request req.reqType = 1 req.pdnType_pr.pres = 1 # PDN Type = IPv4 req.pdnType_pr.pdn_type = 1 req.pdnAPN_pr.pres = 1 s = 'internet.mnc012.mcc345.gprs' req.pdnAPN_pr.len = len(s) req.pdnAPN_pr.pdn_apn = (ctypes.c_ubyte * 100)( *[ctypes.c_ubyte(ord(c)) for c in s[:100]]) self._s1ap_wrapper.s1_util.issue_cmd( s1ap_types.tfwCmd.UE_PDN_CONN_REQ, req, ) # Receive PDN Connectivity Reject response = self._s1ap_wrapper.s1_util.get_response() self.assertEqual( response.msg_type, s1ap_types.tfwCmd.UE_PDN_CONN_RSP_IND.value, ) # self.assertEqual( # response.msg_type, s1ap_types.tfwCmd.UE_ATTACH_FAIL_IND.value) print("Received PDN CONNECTIVITY REJECT") print( "************************* Running UE detach (switch-off) for ", "UE id ", ue_id, ) # Now detach the UE self._s1ap_wrapper.s1_util.detach( ue_id, s1ap_types.ueDetachType_t.UE_SWITCHOFF_DETACH.value, False, ) # Disable APN correction self._s1ap_wrapper.magmad_util.config_apn_correction( MagmadUtil.apn_correction_cmds.DISABLE, ) self._s1ap_wrapper.magmad_util.restart_services(['mme']) for j in range(10): print("Waiting mme restart for", j, "seconds") time.sleep(1)