Changeset aebe08c71f4704914c2af40620d0675cf29d2639
- Timestamp:
- 03/04/10 10:39:17 (6 months ago)
- Author:
- Harald Welte <laforge@gnumonks.org>
- Parents:
- eb8bf3915cb4733e4e4357252893686f0d9d9d72
- Children:
- a73e2f9acb839a1f08d8bc5c7e6074c16f0cf1fe
- git-committer:
- Harald Welte <laforge@gnumonks.org> / 2010-03-04T10:39:17Z+0100
- Message:
-
import gsm_band_name() and gsm_band_parse() from OpenBSC
- Files:
-
Legend:
- Unmodified
- Added
- Removed
-
|
rec8b450
|
raebe08c7
|
|
| 3 | 3 | * (C) 2008 by Daniel Willmann <daniel@totalueberwachung.de> |
| 4 | 4 | * (C) 2009 by Holger Hans Peter Freyther <zecke@selfish.org> |
| 5 | | * (C) 2009 by Harald Welte <laforge@gnumonks.org> |
| | 5 | * (C) 2009-2010 by Harald Welte <laforge@gnumonks.org> |
| 6 | 6 | * |
| 7 | 7 | * All Rights Reserved |
| … |
… |
|
| 39 | 39 | }; |
| 40 | 40 | |
| | 41 | char *gsm_band_name(enum gsm_band band); |
| | 42 | enum gsm_band gsm_band_parse(const char *mhz); |
| | 43 | |
| 41 | 44 | int gsm_7bit_decode(char *decoded, const uint8_t *user_data, uint8_t length); |
| 42 | 45 | int gsm_7bit_encode(uint8_t *result, const char *data); |
-
|
rec8b450
|
raebe08c7
|
|
| 31 | 31 | #include <stdio.h> |
| 32 | 32 | #include <errno.h> |
| | 33 | #include <ctype.h> |
| 33 | 34 | |
| 34 | 35 | #include "../config.h" |
| … |
… |
|
| 193 | 194 | } |
| 194 | 195 | |
| | 196 | char *gsm_band_name(enum gsm_band band) |
| | 197 | { |
| | 198 | switch (band) { |
| | 199 | case GSM_BAND_450: |
| | 200 | return "GSM450"; |
| | 201 | case GSM_BAND_480: |
| | 202 | return "GSM450"; |
| | 203 | case GSM_BAND_750: |
| | 204 | return "GSM750"; |
| | 205 | case GSM_BAND_810: |
| | 206 | return "GSM810"; |
| | 207 | case GSM_BAND_850: |
| | 208 | return "GSM850"; |
| | 209 | case GSM_BAND_900: |
| | 210 | return "GSM900"; |
| | 211 | case GSM_BAND_1800: |
| | 212 | return "DCS1800"; |
| | 213 | case GSM_BAND_1900: |
| | 214 | return "PCS1900"; |
| | 215 | } |
| | 216 | return "invalid"; |
| | 217 | } |
| | 218 | |
| | 219 | enum gsm_band gsm_band_parse(const char* mhz) |
| | 220 | { |
| | 221 | while (*mhz && !isdigit(*mhz)) |
| | 222 | mhz++; |
| | 223 | |
| | 224 | if (*mhz == '\0') |
| | 225 | return -EINVAL; |
| | 226 | |
| | 227 | switch (atoi(mhz)) { |
| | 228 | case 450: |
| | 229 | return GSM_BAND_450; |
| | 230 | case 480: |
| | 231 | return GSM_BAND_480; |
| | 232 | case 750: |
| | 233 | return GSM_BAND_750; |
| | 234 | case 810: |
| | 235 | return GSM_BAND_810; |
| | 236 | case 850: |
| | 237 | return GSM_BAND_850; |
| | 238 | case 900: |
| | 239 | return GSM_BAND_900; |
| | 240 | case 1800: |
| | 241 | return GSM_BAND_1800; |
| | 242 | case 1900: |
| | 243 | return GSM_BAND_1900; |
| | 244 | default: |
| | 245 | return -EINVAL; |
| | 246 | } |
| | 247 | } |
| | 248 | |
| | 249 | |
| 195 | 250 | #ifdef HAVE_EXECINFO_H |
| 196 | 251 | #include <execinfo.h> |