forked from osmocom/pysim
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
utils: add EF [H|O]PLMNwAcT decoding.
Allow decoding and pretty printing of PLMNwAcT, HPLMNwAcT and OPLMNwAct. Includes unit tests for the added functions. Change-Id: I9b8ca6ffd98f665690b84239d9a228e2c72c6ff9
- Loading branch information
Showing
4 changed files
with
195 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
#!/usr/bin/pyton | ||
|
||
import unittest | ||
import utils | ||
|
||
class DecTestCase(unittest.TestCase): | ||
|
||
def testSplitHexStringToListOf5ByteEntries(self): | ||
input_str = "ffffff0003ffffff0002ffffff0001" | ||
expected = [ | ||
"ffffff0003", | ||
"ffffff0002", | ||
"ffffff0001", | ||
] | ||
self.assertEqual(utils.hexstr_to_fivebytearr(input_str), expected) | ||
|
||
def testDecMCCfromPLMN(self): | ||
self.assertEqual(utils.dec_mcc_from_plmn("92f501"), 295) | ||
|
||
def testDecMCCfromPLMN_unused(self): | ||
self.assertEqual(utils.dec_mcc_from_plmn("ff0f00"), 4095) | ||
|
||
def testDecMNCfromPLMN_twoDigitMNC(self): | ||
self.assertEqual(utils.dec_mnc_from_plmn("92f501"), 10) | ||
|
||
def testDecMNCfromPLMN_threeDigitMNC(self): | ||
self.assertEqual(utils.dec_mnc_from_plmn("031263"), 361) | ||
|
||
def testDecMNCfromPLMN_unused(self): | ||
self.assertEqual(utils.dec_mnc_from_plmn("00f0ff"), 4095) | ||
|
||
def testDecAct_noneSet(self): | ||
self.assertEqual(utils.dec_act("0000"), []) | ||
|
||
def testDecAct_onlyUtran(self): | ||
self.assertEqual(utils.dec_act("8000"), ["UTRAN"]) | ||
|
||
def testDecAct_onlyEUtran(self): | ||
self.assertEqual(utils.dec_act("4000"), ["E-UTRAN"]) | ||
|
||
def testDecAct_onlyGsm(self): | ||
self.assertEqual(utils.dec_act("0080"), ["GSM"]) | ||
|
||
def testDecAct_onlyGsmCompact(self): | ||
self.assertEqual(utils.dec_act("0040"), ["GSM COMPACT"]) | ||
|
||
def testDecAct_onlyCdma2000HRPD(self): | ||
self.assertEqual(utils.dec_act("0020"), ["cdma2000 HRPD"]) | ||
|
||
def testDecAct_onlyCdma20001xRTT(self): | ||
self.assertEqual(utils.dec_act("0010"), ["cdma2000 1xRTT"]) | ||
|
||
def testDecAct_allSet(self): | ||
self.assertEqual(utils.dec_act("ffff"), ["UTRAN", "E-UTRAN", "GSM", "GSM COMPACT", "cdma2000 HRPD", "cdma2000 1xRTT"]) | ||
|
||
def testDecxPlmn_w_act(self): | ||
expected = {'mcc': 295, 'mnc': 10, 'act': ["UTRAN"]} | ||
self.assertEqual(utils.dec_xplmn_w_act("92f5018000"), expected) | ||
|
||
def testFormatxPlmn_w_act(self): | ||
input_str = "92f501800092f5508000ffffff0000ffffff0000ffffff0000ffffff0000ffffff0000ffffff0000ffffff0000ffffff0000" | ||
expected = '''92f5018000 # MCC: 295 MNC: 10 AcT: UTRAN | ||
92f5508000 # MCC: 295 MNC: 5 AcT: UTRAN | ||
ffffff0000 # unused | ||
ffffff0000 # unused | ||
ffffff0000 # unused | ||
ffffff0000 # unused | ||
ffffff0000 # unused | ||
ffffff0000 # unused | ||
ffffff0000 # unused | ||
ffffff0000 # unused | ||
''' | ||
self.assertEqual(utils.format_xplmn_w_act(input_str), expected) | ||
|
||
if __name__ == "__main__": | ||
unittest.main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters