fix f_enc_IMEI_L3() oddevenIndicator
f_gen_imei() calls f_enc_IMEI_L3() with a 14 digits argument, but the IMEI_L3 template used is hardcoded to 15 digits. So the oddevenIndicator must always indicate odd, not depend on the digits argument. f_gen_imei() should probably also compose a Luhn checksum, leaving that to another patch. Found by using the new osmo_mobile_identity API in osmo-msc, which is stricter about odd/even and filler digits than our previous implementations. See osmo-msc Idfc8e576e10756aeaacf5569f6178068313eb7ea . Change-Id: Iaa9ba1214c4c15fd9620e68fe2e842fdf52912c0
This commit is contained in:
parent
15a8501232
commit
1661781611
|
@ -184,11 +184,20 @@ private function f_enc_IMSI_L3(hexstring digits) return IMSI_L3 {
|
|||
private function f_enc_IMEI_L3(hexstring digits) return IMEI_L3 {
|
||||
var IMEI_L3 l3;
|
||||
var integer len := lengthof(digits);
|
||||
if (len rem 2 == 1) { /* modulo remainder */
|
||||
l3.oddevenIndicator := '1'B;
|
||||
} else {
|
||||
l3.oddevenIndicator := '0'B;
|
||||
}
|
||||
/* IMEI_L3 is always 15 digits. That is actually a 14 digit IMEI + a Luhn checksum digit (see
|
||||
* libosmocore/include/osmocom/gsm/protocol/gsm_23_003.h)
|
||||
*
|
||||
* Here, we must not make the oddevenIndicator depend on the 'digits' parameter, because:
|
||||
* - The IMEI_L3 template assumes always 15 digits.
|
||||
* - The 'digits' parameter, however, may also contain less digits, 14 in the case of
|
||||
* f_gen_imei().
|
||||
* - The IMEI_L3 template will then fill up with zeros to make 15 digits.
|
||||
* Hence oddevenIndicator must always indicate 'odd' == '1'B.
|
||||
*
|
||||
* FIXME: if the caller passes less than 15 digits, the Luhn checksum digit then ends up zero == most probably
|
||||
* wrong.
|
||||
*/
|
||||
l3.oddevenIndicator := '1'B;
|
||||
l3.digits := digits;
|
||||
return l3;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue