diff options
author | Harald Welte <laforge@gnumonks.org> | 2010-03-14 15:37:43 +0800 |
---|---|---|
committer | Harald Welte <laforge@gnumonks.org> | 2010-03-22 19:02:04 +0800 |
commit | 97a282b037408438a876af81e2e9c5194c2bb69e (patch) | |
tree | 4b7bc0f413a75d02d8402bf724b889c74d6a93ad /openbsc/src/gsm_data.c | |
parent | d859a24f7d1dca2aed4e69330124e52d674d1589 (diff) |
Create new gprs-conf branch with the non-SGSN part of the gprs branch
This new gprs-conf branch is intended to contain everything needed
to configure GPRS in the nanoBTS, but without implementing the SGSN/GGSN
functionality.
The SGSN/GGSN development will happen in a branch based on this branch
called "gprs-sgsn"
Diffstat (limited to 'openbsc/src/gsm_data.c')
-rw-r--r-- | openbsc/src/gsm_data.c | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/openbsc/src/gsm_data.c b/openbsc/src/gsm_data.c index a951821fe..5314d1212 100644 --- a/openbsc/src/gsm_data.c +++ b/openbsc/src/gsm_data.c @@ -25,6 +25,8 @@ #include <errno.h> #include <ctype.h> +#include <netinet/in.h> + #include <openbsc/gsm_data.h> #include <osmocore/talloc.h> #include <osmocore/gsm_utils.h> @@ -459,6 +461,50 @@ const char *gsm_auth_policy_name(enum gsm_auth_policy policy) return gsm_auth_policy_names[policy]; } +/* this should not be here but in gsm_04_08... but that creates + in turn a dependency nightmare (abis_nm depending on 04_08, ...) */ +static int gsm48_construct_ra(u_int8_t *buf, const struct gprs_ra_id *raid) +{ + u_int16_t mcc = raid->mcc; + u_int16_t mnc = raid->mnc; + + buf[0] = ((mcc / 100) % 10) | (((mcc / 10) % 10) << 4); + buf[1] = (mcc % 10); + + /* I wonder who came up with the stupidity of encoding the MNC + * differently depending on how many digits its decimal number has! */ + if (mnc < 100) { + buf[1] |= 0xf0; + buf[2] = ((mnc / 10) % 10) | ((mnc % 10) << 4); + } else { + buf[1] |= (mnc % 10) << 4; + buf[2] = ((mnc / 100) % 10) | (((mcc / 10) % 10) << 4); + } + + *(u_int16_t *)(buf+3) = htons(raid->lac); + + buf[5] = raid->rac; + + return 6; +} + +void gprs_ra_id_by_bts(struct gprs_ra_id *raid, struct gsm_bts *bts) +{ + raid->mcc = bts->network->country_code; + raid->mnc = bts->network->network_code; + raid->lac = bts->location_area_code; + raid->rac = bts->gprs.rac; +} + +int gsm48_ra_id_by_bts(u_int8_t *buf, struct gsm_bts *bts) +{ + struct gprs_ra_id raid; + + gprs_ra_id_by_bts(&raid, bts); + + return gsm48_construct_ra(buf, &raid); +} + static const char *rrlp_mode_names[] = { [RRLP_MODE_NONE] = "none", [RRLP_MODE_MS_BASED] = "ms-based", |