def ue_decode_nas(self, pdu): if pdu[1]['procedureCode'] not in S1AP_NAS_OFFSET: return nas_ie = pdu[1]['value'][1]['protocolIEs'][S1AP_NAS_OFFSET[pdu[1]['procedureCode']]] if nas_ie['value'][0] == 'NAS-PDU': # OCTET STRING, to be parsed nas_ie['value'] = ('NAS-PDU', parse_L3(nas_ie['value'][1]))
def ue_decode_nas(self, pdu): if pdu[1]["procedureCode"] not in S1AP_NAS_OFFSET: return nas_ie = pdu[1]["value"][1]["protocolIEs"][S1AP_NAS_OFFSET[pdu[1]["procedureCode"]]] if nas_ie["value"][0] == "NAS-PDU": # OCTET STRING, to be parsed nas_ie["value"] = ("NAS-PDU", parse_L3(nas_ie["value"][1]))
def map(self, s=''): Layer.map(self, s) # try to parse it as L3Mobile try: nas = parse_L3(self.naspdu()) except: pass else: self.naspdu.Pt = nas self.naspdu.Val = None self.naspdu.Repr = 'hum'
def ue_retrieve_imsi(self, pdu, enb_gid): # retrieve the IMSI from the NAS-PDU response if pdu[1]['procedureCode'] not in S1AP_NAS_OFFSET: return nas_ie = pdu[1]['value'][1]['protocolIEs'][S1AP_NAS_OFFSET[pdu[1]['procedureCode']]] if nas_ie['value'][0] == 'NAS-PDU': naspdu = parse_L3(nas_ie['value'][1]) self._log('TRACE_NAS_UL', '[eNB {0}] [UE: ]\n{1}'.format(enb_gid, naspdu.show())) try: ident = naspdu.ID.getobj() except: pass else: return ident.get_imsi() return None
def ue_get_imsi(self, pdu): # collect S-TMSI and NAS-PDU in the S1AP PDU pIEs = pdu[1]['value'][1]['protocolIEs'] for pIE in pIEs: if pIE['id'] == 26: # NAS-PDU nas = parse_L3(pIE['value'][1]) tmsi = get_tmsi(nas) if tmsi is not None: if tmsi in self.TMSI: return self.TMSI[tmsi] else: imsi = get_imsi(nas) if imsi is not None: return imsi elif pIE['id'] == 96: # S-TMSI, nly m-TMSI is processed, mMEC is ignored tmsi = pIE['value'][1]['m-TMSI'] if tmsi in self.TMSI: return self.TMSI[tmsi] return None
def parse(self, s='', mode='control'): # map GA header, after checking the protocol discriminator value pd = ord(s[2]) & 0x0F Block.__init__(self, Name='UMA') if pd in hdrCall.keys(): # now easy way to distinguish CP from UP at the UMA layer # (may depend if its carried over TCP or UDP?) self.append( hdrCall[pd]() ) else: self.append( GA_RC_hdr() ) self[0].map(s) s = s[ len(self[0]) : ] # map iteratively the TLV Information Element while len(s) > 0: if self._IE_type == 'old': self < UMA_IE_old() else: self < UMA_IE() self[-1].map(s) s = s[ len(self[-1]) : ] # check if can also handle V with L3Mobile_IE: if self[-1].T() == IEType['Location Area Identification']: self.map_last_to_IE(LAI) elif self[-1].T() == IEType['Mobile Identity']: self.map_last_to_IE(ID) elif self[-1].T() == IEType['Mobile Station Classmark 2']: self.map_last_to_IE(MSCm2) elif self[-1].T() == IEType['GAN PLMN List']: self.map_last_to_IE(PLMNList) elif self.process_L3 and self[-1].T() == IEType['L3 Message']: l3 = parse_L3(self[-1].V()) if isinstance(l3, Layer3): # otherwise, cill get a RawLayer() self[-1].V < None self[-1].V > l3
def parse(self, s='', mode='control'): # map GA header, after checking the protocol discriminator value pd = ord(s[2]) & 0x0F Block.__init__(self, Name='UMA') if pd in hdrCall.keys(): # now easy way to distinguish CP from UP at the UMA layer # (may depend if its carried over TCP or UDP?) self.append(hdrCall[pd]()) else: self.append(GA_RC_hdr()) self[0].map(s) s = s[len(self[0]):] # map iteratively the TLV Information Element while len(s) > 0: if self._IE_type == 'old': self < UMA_IE_old() else: self < UMA_IE() self[-1].map(s) s = s[len(self[-1]):] # check if can also handle V with L3Mobile_IE: if self[-1].T() == IEType['Location Area Identification']: self.map_last_to_IE(LAI) elif self[-1].T() == IEType['Mobile Identity']: self.map_last_to_IE(ID) elif self[-1].T() == IEType['Mobile Station Classmark 2']: self.map_last_to_IE(MSCm2) elif self[-1].T() == IEType['GAN PLMN List']: self.map_last_to_IE(PLMNList) elif self.process_L3 and self[-1].T() == IEType['L3 Message']: l3 = parse_L3(self[-1].V()) if isinstance(l3, Layer3): # otherwise, cill get a RawLayer() self[-1].V < None self[-1].V > l3