diff options
author | Harald Welte <laforge@netfilter.org> | 2010-02-20 16:24:02 +0100 |
---|---|---|
committer | Harald Welte <laforge@netfilter.org> | 2010-02-20 16:27:23 +0100 |
commit | dfe6c7d910edbba238751d0cfddbb627bb08ef54 (patch) | |
tree | c4836091b0d65187ee50c52060d51117b21ac873 /libosmocore/include/osmocore/gsm_utils.h | |
parent | 9442c1b9bad3426ece07edc7fa2dca7464fc302a (diff) |
split 'libosmocore' from openbsc codebase
This library is intended to collect all generic/common funcitionality
of all Osmocom.org projects, including OpenBSC but also OsmocomBB
The library currently includes the following modules:
bitvec, comp128, gsm_utils, msgb, select, signal, statistics, talloc, timer,
tlv_parse, linuxlist
msgb allocation error debugging had to be temporarily disabled as it depends on
'debug.c' functionality which at the moment remains in OpenBSC
Diffstat (limited to 'libosmocore/include/osmocore/gsm_utils.h')
-rw-r--r-- | libosmocore/include/osmocore/gsm_utils.h | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/libosmocore/include/osmocore/gsm_utils.h b/libosmocore/include/osmocore/gsm_utils.h new file mode 100644 index 000000000..c770cc900 --- /dev/null +++ b/libosmocore/include/osmocore/gsm_utils.h @@ -0,0 +1,59 @@ +/* GSM utility functions, e.g. coding and decoding */ +/* + * (C) 2008 by Daniel Willmann <daniel@totalueberwachung.de> + * (C) 2009 by Holger Hans Peter Freyther <zecke@selfish.org> + * (C) 2009 by Harald Welte <laforge@gnumonks.org> + * + * All Rights Reserved + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + */ + +#ifndef GSM_UTILS_H +#define GSM_UTILS_H + +#include <sys/types.h> + +enum gsm_band { + GSM_BAND_850 = 1, + GSM_BAND_900 = 2, + GSM_BAND_1800 = 4, + GSM_BAND_1900 = 8, + GSM_BAND_450 = 0x10, + GSM_BAND_480 = 0x20, + GSM_BAND_750 = 0x40, + GSM_BAND_810 = 0x80, +}; + +int gsm_7bit_decode(char *decoded, const u_int8_t *user_data, u_int8_t length); +int gsm_7bit_encode(u_int8_t *result, const char *data); + +int ms_pwr_ctl_lvl(enum gsm_band band, unsigned int dbm); +int ms_pwr_dbm(enum gsm_band band, u_int8_t lvl); + +/* According to TS 08.05 Chapter 8.1.4 */ +int rxlev2dbm(u_int8_t rxlev); +u_int8_t dbm2rxlev(int dbm); + +/* According to GSM 04.08 Chapter 10.5.2.29 */ +static inline int rach_max_trans_val2raw(int val) { return (val >> 1) & 3; } +static inline int rach_max_trans_raw2val(int raw) { + const int tbl[4] = { 1, 2, 4, 7 }; + return tbl[raw & 3]; +} + +void generate_backtrace(); +#endif |