From b84e2f4f1b6c4f9d902ed2d23fe340b304b21fbd Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Sun, 28 Dec 2008 23:42:04 +0000 Subject: [PATCH] * use 16bit for network and country code * use aligned attribute for more data structures * add command line arguments for operator/country code --- include/openbsc/gsm_04_08.h | 6 +++--- include/openbsc/gsm_data.h | 8 ++++---- src/bsc_hack.c | 15 ++++++++------- src/gsm_data.c | 4 ++-- 4 files changed, 17 insertions(+), 16 deletions(-) diff --git a/include/openbsc/gsm_04_08.h b/include/openbsc/gsm_04_08.h index 1513aded0..920d84c91 100644 --- a/include/openbsc/gsm_04_08.h +++ b/include/openbsc/gsm_04_08.h @@ -22,7 +22,7 @@ struct gsm48_chan_desc { u_int8_t arfcn_low; } h0; }; -}; +} __attribute__ ((packed)); /* Chapter 10.5.2.30 */ struct gsm48_req_ref { @@ -31,7 +31,7 @@ struct gsm48_req_ref { t1_:5; u_int8_t t2:5, t3_low:3; -}; +} __attribute__ ((packed)); /* Chapter 9.1.18 */ struct gsm48_imm_ass { @@ -44,7 +44,7 @@ struct gsm48_imm_ass { u_int8_t timing_advance; u_int8_t mob_alloc_len; u_int8_t mob_alloc[0]; -}; +} __attribute__ ((packed)); /* Chapter 10.5.1.3 */ struct gsm48_loc_area_id { diff --git a/include/openbsc/gsm_data.h b/include/openbsc/gsm_data.h index 2d0c3c53b..c0c431eda 100644 --- a/include/openbsc/gsm_data.h +++ b/include/openbsc/gsm_data.h @@ -126,8 +126,8 @@ struct gsm_ms { struct gsm_network { /* global parameters */ - u_int8_t country_code; - u_int8_t network_code; + u_int16_t country_code; + u_int16_t network_code; unsigned int num_bts; /* private lists */ @@ -136,8 +136,8 @@ struct gsm_network { struct gsm_subscriber *subscriber; }; -struct gsm_network *gsm_network_init(unsigned int num_bts, u_int8_t country_code, - u_int8_t network_code); +struct gsm_network *gsm_network_init(unsigned int num_bts, u_int16_t country_code, + u_int16_t network_code); enum gsm_e1_event { EVT_E1_NONE, diff --git a/src/bsc_hack.c b/src/bsc_hack.c index 3076758ef..aab4d0feb 100644 --- a/src/bsc_hack.c +++ b/src/bsc_hack.c @@ -587,20 +587,21 @@ static void patch_tables(struct gsm_bts *bts) (struct gsm48_system_information_type_4*)&si4; struct gsm48_system_information_type_6 *type_6 = (struct gsm48_system_information_type_6*)&si6; + struct gsm48_loc_area_id lai; + + gsm0408_generate_lai(&lai, bts->network->country_code, + bts->network->network_code, bts->location_area_code); /* assign the MCC and MNC */ - gsm0408_generate_lai(&type_3->lai, bts->network->country_code, - bts->network->network_code, bts->location_area_code); - gsm0408_generate_lai(&type_4->lai, bts->network->country_code, - bts->network->network_code, bts->location_area_code); - gsm0408_generate_lai(&type_6->lai, bts->network->country_code, - bts->network->network_code, bts->location_area_code); + type_3->lai = lai; + type_4->lai = lai; + type_6->lai = lai; } static void bootstrap_rsl(struct gsm_bts *bts) { - fprintf(stdout, "bootstrapping RSL\n"); + fprintf(stdout, "bootstrapping RSL MCC=%u MNC=%u\n", MCC, MNC); patch_tables(bts); set_system_infos(bts); diff --git a/src/gsm_data.c b/src/gsm_data.c index 61f868214..ed81954df 100644 --- a/src/gsm_data.c +++ b/src/gsm_data.c @@ -24,8 +24,8 @@ #include -struct gsm_network *gsm_network_init(unsigned int num_bts, u_int8_t country_code, - u_int8_t network_code) +struct gsm_network *gsm_network_init(unsigned int num_bts, u_int16_t country_code, + u_int16_t network_code) { int i; struct gsm_network *net;