Ejemplo n.º 1
0
	def update_impi(self, impi=None):
		hex_str = ""
		if impi:
			hex_str = s2h(impi)
		# Build TLV
		tlv = TLV(['80'])
		content = tlv.build({'80': hex_str})

		bin_size_bytes = self._scc.binary_size(EF_ISIM_ADF_map['IMPI'])
		data, sw = self._scc.update_binary(EF_ISIM_ADF_map['IMPI'], rpad(content, bin_size_bytes*2))
		return sw
Ejemplo n.º 2
0
	def update_impu(self, impu=None):
		hex_str = ""
		if impu:
			hex_str = s2h(impu)
		# Build TLV
		tlv = TLV(['80'])
		content = tlv.build({'80': hex_str})

		rec_size_bytes = self._scc.record_size(EF_ISIM_ADF_map['IMPU'])
		impu_tlv = rpad(content, rec_size_bytes*2)
		data, sw = self._scc.update_record(EF_ISIM_ADF_map['IMPU'], 1, impu_tlv)
		return sw
Ejemplo n.º 3
0
	def update_domain(self, domain=None, mcc=None, mnc=None):
		hex_str = ""
		if domain:
			hex_str = s2h(domain)
		elif mcc and mnc:
			# MCC and MNC always has 3 digits in domain form
			plmn_str = 'mnc' + lpad(mnc, 3, "0") + '.mcc' + lpad(mcc, 3, "0")
			hex_str = s2h('ims.' + plmn_str + '.3gppnetwork.org')

		# Build TLV
		tlv = TLV(['80'])
		content = tlv.build({'80': hex_str})

		bin_size_bytes = self._scc.binary_size(EF_ISIM_ADF_map['DOMAIN'])
		data, sw = self._scc.update_binary(EF_ISIM_ADF_map['DOMAIN'], rpad(content, bin_size_bytes*2))
		return sw
Ejemplo n.º 4
0
def server_target(s):
    try:
        # 采用循环不断地从socket中读取客户端发送过来的数据
        while True:
            #line = input()
            data = {"username": "******", "age": 16}
            jsondata = json.dumps(data)
            if jsondata is None or jsondata == 'exit':
                break
            tlv = TLV(['89ABCDEF', '9F04'])
            test = '1234567890'
            print(len(test))
            data = tlv.build({'89ABCDEF': test})
            print(data)
            time.sleep(2)
            #s.send('hello world'.encode('utf-8'))
            s.send(data.encode('utf-8'))
    except Exception:
        print(Exception.with_traceback())
Ejemplo n.º 5
0
from pytlv.TLV import *
import json

data = {"Username": "******", "age": 16}
jsondata = json.dumps(data)
print(jsondata)
tlv = TLV(['89ABCDEF', '9F04'])
test = '1234567890' + repr(jsondata)
print(len(test))
print(test)
data = tlv.build({'89ABCDEF': test})
print(data)
text = tlv.parse(data)
print(text)
'''
test1 = 'Ab0000'
print(len(test1))
data1 = tlv.build({'9f04': test1 + jsondata})
print(data1)
text1 = tlv.parse(data1)
print(text1)
'''