While running Cell-Log application, I found that the main branch of OsmocomBB gives wrong value of MCC/MNC in hex (but correct one in decimal), but the Sylvain testing branch gives correct value.
In practice this means compiling Cell-Log in testing branch gives the name of the country, but the compiling it in main branch does not recognise the country. Other side-effects are unknown to me at present.
Tracing through the source leads to the "gsm48_decode_lai" as the culprit. The code seems correct in the testing branch, but has not been updated in the main. Moreover, the code is shifted out from gsm48.c to sysinfo.c in the testing branch.
Testing branch decodes MCC/MNC to hex: *mcc = ((lai->digits[0] & 0x0f) << 8) | (lai->digits[0] & 0xf0) | (lai->digits[1] & 0x0f);
But main branch decodes MCC/MNC to decimal: *mcc = (lai->digits[0] & 0x0f) * 100 + (lai->digits[0] >> 4) * 10 + (lai->digits[1] & 0x0f); The comment in main branch states that "/* Attention: this function retunrs true integers, not hex! */". There is no such comment in the testing branch.
So is this a problem because Cell_Log wrongly uses gsm48_decode_lai? Or does gsm48_decode_lai need to be updated in the main branch?
B.
On Sun, Dec 2, 2012 at 7:49 AM, Bhaskar11 niceguy108@gmail.com wrote:
While running Cell-Log application, I found that the main branch of OsmocomBB gives wrong value of MCC/MNC in hex (but correct one in decimal), but the Sylvain testing branch gives correct value.
Your branches are not up to date ... testing has only two commits added to it and they have nothing to do with gsm48_decode_lai. So please update and re-test.
Now when looking at the history of this function, it looks very weird to me :
You find:
---- commit a8ce4ea4696a385d18beb785eef8f510c6fed143 Author: Harald Welte laforge@gnumonks.org Date: Sat Sep 8 22:43:50 2012 +0200
layer23: gsm48_decode_lai() is now in libosmogsm ----
followed by:
---- commit 07f83456460a2cdb8d288ac647f04a5bc09dc1cf Author: Andreas Eversberg jolly@eversberg.eu Date: Tue Oct 30 10:26:20 2012 +0100
Fixed decoding of hexadecimal LAI components
libosmocore has changed its LAI decoding from hex to decimal. This caused wrong decoding of MCC and MNC. In order to provide required hex transcoding, special hex encoding and decoding function are added to mobile/sysinfo.c. ----
and in libosmocore:
--- commit 774a9de8b36a53c9e4e4dca4efbb9944cd39ff65 Author: Harald Welte laforge@gnumonks.org Date: Fri Jul 13 21:35:13 2012 +0200
import gsm48_decode_lai() function from osmocom-bb/mobile sysinfo.c
commit a9250b9ebcdab7134e5d062e8ca37f9532eca5e8 Author: Harald Welte laforge@gnumonks.org Date: Fri Jul 13 22:57:31 2012 +0200
gsm48_decode_lai(): return real integers for mcc/mnc, not hex!
This is to make it orthogonal with gsm48_encode_lai() ---
Now ... this look a little bit like a SNAFU. Now if the goal was to put common code in libosmocore, that didn't quite endup like that because now osmocom-bb has a gsm48_decode_lai_hex function that does the exact same thing as the previous gsm48_decode_lai function and it doesn't use the libosmocore gsm48_decode_lai function at all. And having those two different interface looks silly to me ... So which one is the more practical ?
Cheers,
Sylvain
Sylvain Munaut wrote:
Now ... this look a little bit like a SNAFU.
hi sylvain,
i don't like having two functions with different results too. the problem is that osmocom-bb uses hex lai everywhere, and openbsc uses decimal lai. changing osmocom-bb would result in loosing support for 3-digits-MNC. (02 is not 002 and neither 02x) harald mentioned to maybe change lai at openbsc in the future, so 3-digits-MNC are correctly supported there too. then i would suggest to use hex MCC also. also it would make sense to move the "input" and "print" functions for hex type MCC/MNC to libosmocore too.
regards,
andreas
i don't like having two functions with different results too. the problem is that osmocom-bb uses hex lai everywhere, and openbsc uses decimal lai. changing osmocom-bb would result in loosing support for 3-digits-MNC. (02 is not 002 and neither 02x) harald mentioned to maybe change lai at openbsc in the future, so 3-digits-MNC are correctly supported there too. then i would suggest to use hex MCC also. also it would make sense to move the "input" and "print" functions for hex type MCC/MNC to libosmocore too.
Ok thanks for the explanation, that makes it clear why and this certainly indicates that the hex version are the "right" way.
Then I'd suggest to put both encode_hex decode_hex version in libosmocore and put a note deprecating use of the decimal version since they can't be used to support all mnc/mcc combination like they should. This way we avoid writing new software against functions that have these limitations.
Sounds good to everyone ? If no objections, I'll do that.
Cheers,
Sylvain
On Thu, Dec 06, 2012 at 09:14:15PM +0100, Sylvain Munaut wrote:
Then I'd suggest to put both encode_hex decode_hex version in libosmocore and put a note deprecating use of the decimal version since they can't be used to support all mnc/mcc combination like they should. This way we avoid writing new software against functions that have these limitations.
agreed.
Sounds good to everyone ? If no objections, I'll do that.
yes. Will you also check for any users of the decimal version and convert them to the hex version?
Regards, Harald
baseband-devel@lists.osmocom.org