def sendGtp(requestType, msgData, msgHeirarchy, ieUpdateValDict=None): igniteLogger.logger.info(f"Gtp Message type : {requestType}") updateMessageFromContextData(requestType, msgData) if ieUpdateValDict != None: icu.setValueFromTC(msgData, ieUpdateValDict) if requestType == mt.create_session_response.name: setContextData(requestType, msgData) igniteLogger.logger.info(f"Gtp data received : {msgData}") send_response = requests.post(url=url["send_url"], json=[msgData, S11CTXDATA, "gtp"]) igniteLogger.logger.info( f"URL response for send gtp data : {str(send_response)}")
def sendS6aMsg(requestType,msgData,userName,ieUpdateValDict=None): global IMSI igniteLogger.logger.info(f"Diameter message Type : {requestType}") if requestType == mt.update_location_response.name: response = requests.get(url["s1ap_ctx_data_url"]) if response.json()!={} and response.json().get(IMSI,None)!=None: s1ap_data = response.json()[IMSI] icu.updateKeyValueInDict(msgData,"service-selection",s1ap_data[mt.esm_information_response.name]["apn"]) updateMessageFromContextData(requestType,msgData) if ieUpdateValDict != None: icu.setValueFromTC(msgData,ieUpdateValDict) setContextData(requestType,msgData) igniteLogger.logger.info(f"Data to be sent : {msgData}") send_response = requests.post(url=url["send_url"], json=[msgData,S6ACTXDATA,"diameter"]) igniteLogger.logger.info(f"URL response for send diameter data: {str(send_response)}")
def sendS1ap(requestType,s1apData,enbUeS1apId,nasData={},imsi=None,ieUpdateValDict=None): global SERFLAG global TIMEOUTFLAG global IMSI igniteLogger.logger.info(f"s1ap message type : {requestType}") s1apData["NAS-MESSAGE"] = nasData count=0 if enbUeS1apId !=None: if requestType == mt.attach_request.name: icu.updateKeyValueInDict(s1apData, "ENB-UE-S1AP-ID", enbUeS1apId) nu.setImsi(imsi,nasData) if imsi ==None: S1APCTXDATA[enbUeS1apId]={} else: if S1APCTXDATA.get(IMSI,None)==None: IMSI=imsi S1APCTXDATA[IMSI]={} S1APCTXDATA[IMSI][requestType]={'imsi':str(imsi)} elif requestType == mt.identity_response.name: IMSI=imsi nu.setImsi(imsi,nasData) if S1APCTXDATA.get(enbUeS1apId,None)!=None: S1APCTXDATA[IMSI]=S1APCTXDATA[enbUeS1apId].copy() del S1APCTXDATA[enbUeS1apId] S1APCTXDATA[IMSI][requestType]={'imsi':str(imsi)} updateMessageFromContextData(s1apData,requestType) elif requestType == mt.attach_request_guti.name: icu.updateKeyValueInDict(s1apData, "ENB-UE-S1AP-ID", enbUeS1apId) S1APCTXDATA[enbUeS1apId]={} if imsi!=None: nu.setGuti(imsi,s1apData) else: nu.setGuti(S1APCTXDATA[IMSI][mt.attach_accept.name]["guti_list"],s1apData) elif requestType==mt.service_request.name: SERFLAG=True icu.updateKeyValueInDict(s1apData, "ENB-UE-S1AP-ID", enbUeS1apId) icu.updateKeyValueInDict(s1apData,"m-TMSI", icu.formatHex(S1APCTXDATA[IMSI][mt.attach_accept.name]["m_tmsi"])) icu.updateKeyValueInDict(s1apData,"mMEC", '0'+str(S1APCTXDATA[IMSI][mt.attach_accept.name]["mme_code"])) else: if requestType == mt.initial_context_setup_response.name: if count == 0: gtp_teid=icu.generateUniqueId('gTP-TEID') S1APCTXDATA[IMSI]["gTP_TEID"]=gtp_teid icu.updateKeyValueInDict(s1apData, "gTP-TEID", gtp_teid) count+=1 else: gtp_teid=S1APCTXDATA[IMSI]["gTP_TEID"] gtp_teid=icu.icrementGtpTeid(gtp_teid) S1APCTXDATA[IMSI]["gTP_TEID"]=gtp_teid icu.updateKeyValueInDict(s1apData, "gTP-TEID", gtp_teid) count+=1 icu.updateKeyValueInDict(s1apData, "transportLayerAddress",transportLayerAddressUpdate()) elif requestType==mt.authentication_response.name: TIMEOUTFLAG=False elif requestType==mt.ue_context_release_complete.name: SERFLAG=False updateMessageFromContextData(s1apData,requestType) if ieUpdateValDict != None: icu.setValueFromTC(s1apData,ieUpdateValDict) setContextData(s1apData,requestType) igniteLogger.logger.info(f"s1ap data send : {s1apData}") send_response = requests.post(url["send_url"], json=[s1apData,S1APCTXDATA,"s1ap"]) igniteLogger.logger.info(f"URL response for send s1ap data : {str(send_response)}")
def sendS1ap(requestType,s1apData,enbUeS1apId,nasData={},imsi=None,ieUpdateValDict=None): global SERFLAG global TIMEOUTFLAG global IMSI igniteLogger.logger.info(f"s1ap message type : {requestType}") s1apData["NAS-MESSAGE"] = nasData count=0 if enbUeS1apId !=None: if requestType == mt.attach_request.name: icu.updateKeyValueInDict(s1apData, "ENB-UE-S1AP-ID", enbUeS1apId) nu.setImsi(imsi,nasData) if imsi ==None: S1APCTXDATA[enbUeS1apId]={} else: if S1APCTXDATA.get(IMSI,None)==None: IMSI=imsi S1APCTXDATA[IMSI]={} S1APCTXDATA[IMSI][requestType]={'imsi':str(imsi)} elif requestType == mt.identity_response.name: IMSI=imsi nu.setImsi(imsi,nasData) if S1APCTXDATA.get(enbUeS1apId,None)!=None: S1APCTXDATA[IMSI]=S1APCTXDATA[enbUeS1apId].copy() del S1APCTXDATA[enbUeS1apId] S1APCTXDATA[IMSI][requestType]={'imsi':str(imsi)} updateMessageFromContextData(s1apData,requestType) elif requestType == mt.attach_request_guti.name: icu.updateKeyValueInDict(s1apData, "ENB-UE-S1AP-ID", enbUeS1apId) S1APCTXDATA[enbUeS1apId]={} if imsi!=None: nu.setGuti(imsi,s1apData) else: nu.setGuti(S1APCTXDATA[IMSI][mt.attach_accept.name]["guti_list"],s1apData) elif requestType==mt.service_request.name: SERFLAG=True icu.updateKeyValueInDict(s1apData, "ENB-UE-S1AP-ID", enbUeS1apId) icu.updateKeyValueInDict(s1apData,"m-TMSI", icu.formatHex(S1APCTXDATA[IMSI][mt.attach_accept.name]["m_tmsi"])) icu.updateKeyValueInDict(s1apData,"mMEC", '0'+str(S1APCTXDATA[IMSI][mt.attach_accept.name]["mme_code"])) else: if requestType == mt.initial_context_setup_response.name: if count == 0: gtp_teid=icu.generateUniqueId('gTP-TEID') S1APCTXDATA[IMSI]["gTP_TEID"]=gtp_teid icu.updateKeyValueInDict(s1apData, "gTP-TEID", gtp_teid) count+=1 else: gtp_teid=S1APCTXDATA[IMSI]["gTP_TEID"] gtp_teid=icu.icrementGtpTeid(gtp_teid) S1APCTXDATA[IMSI]["gTP_TEID"]=gtp_teid icu.updateKeyValueInDict(s1apData, "gTP-TEID", gtp_teid) count+=1 icu.updateKeyValueInDict(s1apData, "transportLayerAddress",transportLayerAddressUpdate()) elif requestType == mt.handover_request_acknowledge.name: gtp_teid=icu.generateUniqueId('gTP-TEID') gtp_teid_1=icu.generateUniqueId('gTP-TEID') S1APCTXDATA[IMSI]["gTP_TEID_2"]=gtp_teid icu.updateKeyValueInDict(s1apData, "gTP-TEID", gtp_teid) icu.updateKeyValueInDict(s1apData, "transportLayerAddress",transportLayerAddressUpdate()) icu.updateKeyValueInDict(s1apData, "dL-transportLayerAddress",transportLayerAddressUpdate()) icu.updateKeyValueInDict(s1apData, "gTP-TEID", gtp_teid_1) elif requestType == mt.erab_modification_indication.name: tl_address=transportLayerAddressUpdate() generateIeValueForErabModInd(s1apData,tl_address,GTP_TEID_LIST) S1APCTXDATA[IMSI]["gTP_TEID"]=GTP_TEID_LIST elif requestType==mt.authentication_response.name: TIMEOUTFLAG=False elif requestType==mt.ue_context_release_complete.name: SERFLAG=False updateMessageFromContextData(s1apData,requestType) if ieUpdateValDict != None: icu.setValueFromTC(s1apData,ieUpdateValDict) setContextData(s1apData,requestType) igniteLogger.logger.info(f"s1ap data send : {s1apData}") if requestType in [mt.s1_setup_request_target.name,mt.handover_request_acknowledge.name,mt.handover_notify.name]: send_url = "http://"+str(config_file["s1ap_target"]["ignite_ip"])+":"+str(config_file["s1ap_target"]["tc_port"])+"/sendMessagesToProxy" send_response = requests.post(url["send_url"], json=[None,S1APCTXDATA,"s1ap"]) else: send_url = url["send_url"] send_response = requests.post(send_url, json=[s1apData,S1APCTXDATA,"s1ap"]) igniteLogger.logger.info(f"URL response for send s1ap data : {str(send_response)}")