Changeset aebe08c71f4704914c2af40620d0675cf29d2639

Show
Ignore:
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:
2 modified

Legend:

Unmodified
Added
Removed
  • include/osmocore/gsm_utils.h

    rec8b450 raebe08c7  
    33 * (C) 2008 by Daniel Willmann <daniel@totalueberwachung.de> 
    44 * (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> 
    66 * 
    77 * All Rights Reserved 
     
    3939}; 
    4040 
     41char *gsm_band_name(enum gsm_band band); 
     42enum gsm_band gsm_band_parse(const char *mhz); 
     43 
    4144int gsm_7bit_decode(char *decoded, const uint8_t *user_data, uint8_t length); 
    4245int gsm_7bit_encode(uint8_t *result, const char *data); 
  • src/gsm_utils.c

    rec8b450 raebe08c7  
    3131#include <stdio.h> 
    3232#include <errno.h> 
     33#include <ctype.h> 
    3334 
    3435#include "../config.h" 
     
    193194} 
    194195 
     196char *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 
     219enum 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 
    195250#ifdef HAVE_EXECINFO_H 
    196251#include <execinfo.h>