diff options
author | Harald Welte <laforge@gnumonks.org> | 2010-06-25 02:55:59 +0200 |
---|---|---|
committer | Harald Welte <laforge@gnumonks.org> | 2010-06-25 02:58:15 +0200 |
commit | f0e18a70586ad265edb81855f6e3cd6f784b89df (patch) | |
tree | 40dba6a4814fcef3218395c42a0c71d05c00b5c4 /src/shared/libosmocore/src/gsm_utils.c | |
parent | bc860c43c291304866cc6fc5ca9acc9499853d06 (diff) | |
parent | 816e24cb4296d6b7110da4a89661bbac8dc7af21 (diff) |
Merge commit '816e24cb4296d6b7110da4a89661bbac8dc7af21' into libosmocore
Conflicts:
src/shared/libosmocore/include/osmocore/protocol/gsm_04_08.h
Diffstat (limited to 'src/shared/libosmocore/src/gsm_utils.c')
-rw-r--r-- | src/shared/libosmocore/src/gsm_utils.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/shared/libosmocore/src/gsm_utils.c b/src/shared/libosmocore/src/gsm_utils.c index 593dd5c9..913946ed 100644 --- a/src/shared/libosmocore/src/gsm_utils.c +++ b/src/shared/libosmocore/src/gsm_utils.c @@ -359,3 +359,35 @@ uint32_t gsm_gsmtime2fn(struct gsm_time *time) /* TS 05.02 Chapter 4.3.3 TDMA frame number */ return (51 * ((time->t3 - time->t2 + 26) % 26) + time->t3 + (26 * 51 * time->t1)); } + +/* TS 03.03 Chapter 2.6 */ +int gprs_tlli_type(uint32_t tlli) +{ + if ((tlli & 0xc0000000) == 0xc0000000) + return TLLI_LOCAL; + else if ((tlli & 0xc0000000) == 0x80000000) + return TLLI_FOREIGN; + else if ((tlli & 0xf8000000) == 0x78000000) + return TLLI_RANDOM; + else if ((tlli & 0xf8000000) == 0x70000000) + return TLLI_AUXILIARY; + + return TLLI_RESERVED; +} + +uint32_t gprs_tmsi2tlli(uint32_t p_tmsi, enum gprs_tlli_type type) +{ + uint32_t tlli; + switch (type) { + case TLLI_LOCAL: + tlli = p_tmsi | 0xc0000000; + break; + case TLLI_FOREIGN: + tlli = (p_tmsi & 0x3fffffff) | 0x80000000; + break; + default: + tlli = 0; + break; + } + return tlli; +} |