neels has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-bsc/+/27250 )
Change subject: cosmetics around select_best_cipher() ...................................................................... cosmetics around select_best_cipher() Improve the function doc. Remove a comment at a caller, because that information is what the function doc is for. Rename the array to codec_by_strength, because it is not the codec strength but the codec number listed in the array. Change-Id: Iaed6b97c31e4ccb1f28ca7e64596d5e20563b392 --- M src/osmo-bsc/osmo_bsc_bssap.c 1 file changed, 5 insertions(+), 7 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmo-bsc refs/changes/50/27250/1 diff --git a/src/osmo-bsc/osmo_bsc_bssap.c b/src/osmo-bsc/osmo_bsc_bssap.c index 8acf293..cab78ed 100644 --- a/src/osmo-bsc/osmo_bsc_bssap.c +++ b/src/osmo-bsc/osmo_bsc_bssap.c @@ -393,17 +393,18 @@ return 0; } -/* select the best cipher permitted by the intersection of both masks */ +/* Select the best cipher permitted by the intersection of both masks. Return as the n in A5/n, or -1 if the + * intersection is empty. */ int select_best_cipher(uint8_t msc_mask, uint8_t bsc_mask) { /* A5/7 ... A5/3: We assume higher is better, * but: A5/1 is better than A5/2, which is better than A5/0 */ - const uint8_t codec_strength[8] = { 7, 6, 5, 4, 3, 1, 2, 0 }; + const uint8_t codec_by_strength[8] = { 7, 6, 5, 4, 3, 1, 2, 0 }; uint8_t intersection = msc_mask & bsc_mask; int i; - for (i = 0; i < ARRAY_SIZE(codec_strength); i++) { - uint8_t codec = codec_strength[i]; + for (i = 0; i < ARRAY_SIZE(codec_by_strength); i++) { + uint8_t codec = codec_by_strength[i]; if (intersection & (1 << codec)) return codec; } @@ -509,9 +510,6 @@ * a5_encryption == 2 --> 0x04 ... */ enc_bits_msc = data[0]; - /* The bit-mask of permitted ciphers from the MSC (sent in ASSIGNMENT COMMAND) is intersected - * with the vty-configured mask a the BSC. Finally, the best (highest) possible cipher is - * chosen. */ chosen_cipher = select_best_cipher(enc_bits_msc, bsc_gsmnet->a5_encryption_mask); if (chosen_cipher < 0) { LOGP(DMSC, LOGL_ERROR, "Reject: no overlapping A5 ciphers between BSC (0x%02x) " -- To view, visit https://gerrit.osmocom.org/c/osmo-bsc/+/27250 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-bsc Gerrit-Branch: master Gerrit-Change-Id: Iaed6b97c31e4ccb1f28ca7e64596d5e20563b392 Gerrit-Change-Number: 27250 Gerrit-PatchSet: 1 Gerrit-Owner: neels <nhofm...@sysmocom.de> Gerrit-MessageType: newchange