From f910171deda0933e506cf3ffc216ee8daa418c24 Mon Sep 17 00:00:00 2001 From: Tom Date: Tue, 16 Aug 2011 15:41:46 +0200 Subject: corrected spelling mistake and added 2 new papers for gsm specs --- Src/osmoconbb/src/host/layer23/include/Makefile.am | 2 + .../src/host/layer23/include/l1ctl_proto.h | 1 + .../src/host/layer23/include/osmocom/Makefile.am | 1 + .../host/layer23/include/osmocom/bb/Makefile.am | 1 + .../layer23/include/osmocom/bb/common/Makefile.am | 2 + .../host/layer23/include/osmocom/bb/common/gps.h | 53 ++++ .../host/layer23/include/osmocom/bb/common/l1ctl.h | 76 ++++++ .../include/osmocom/bb/common/l1l2_interface.h | 8 + .../layer23/include/osmocom/bb/common/l23_app.h | 35 +++ .../host/layer23/include/osmocom/bb/common/lapdm.h | 186 ++++++++++++++ .../layer23/include/osmocom/bb/common/logging.h | 29 +++ .../layer23/include/osmocom/bb/common/networks.h | 24 ++ .../include/osmocom/bb/common/osmocom_data.h | 129 ++++++++++ .../include/osmocom/bb/common/sap_interface.h | 11 + .../host/layer23/include/osmocom/bb/common/sim.h | 274 +++++++++++++++++++++ .../layer23/include/osmocom/bb/common/sysinfo.h | 158 ++++++++++++ .../layer23/include/osmocom/bb/misc/Makefile.am | 1 + .../layer23/include/osmocom/bb/misc/cell_log.h | 25 ++ .../host/layer23/include/osmocom/bb/misc/layer3.h | 17 ++ .../host/layer23/include/osmocom/bb/misc/rslms.h | 23 ++ .../layer23/include/osmocom/bb/mobile/Makefile.am | 2 + .../layer23/include/osmocom/bb/mobile/app_mobile.h | 17 ++ .../layer23/include/osmocom/bb/mobile/gsm322.h | 255 +++++++++++++++++++ .../layer23/include/osmocom/bb/mobile/gsm48_cc.h | 17 ++ .../layer23/include/osmocom/bb/mobile/gsm48_mm.h | 230 +++++++++++++++++ .../layer23/include/osmocom/bb/mobile/gsm48_rr.h | 203 +++++++++++++++ .../host/layer23/include/osmocom/bb/mobile/mncc.h | 181 ++++++++++++++ .../layer23/include/osmocom/bb/mobile/settings.h | 120 +++++++++ .../layer23/include/osmocom/bb/mobile/subscriber.h | 107 ++++++++ .../layer23/include/osmocom/bb/mobile/support.h | 122 +++++++++ .../include/osmocom/bb/mobile/transaction.h | 71 ++++++ .../host/layer23/include/osmocom/bb/mobile/voice.h | 7 + .../host/layer23/include/osmocom/bb/mobile/vty.h | 20 ++ 33 files changed, 2408 insertions(+) create mode 100644 Src/osmoconbb/src/host/layer23/include/Makefile.am create mode 120000 Src/osmoconbb/src/host/layer23/include/l1ctl_proto.h create mode 100644 Src/osmoconbb/src/host/layer23/include/osmocom/Makefile.am create mode 100644 Src/osmoconbb/src/host/layer23/include/osmocom/bb/Makefile.am create mode 100644 Src/osmoconbb/src/host/layer23/include/osmocom/bb/common/Makefile.am create mode 100644 Src/osmoconbb/src/host/layer23/include/osmocom/bb/common/gps.h create mode 100644 Src/osmoconbb/src/host/layer23/include/osmocom/bb/common/l1ctl.h create mode 100644 Src/osmoconbb/src/host/layer23/include/osmocom/bb/common/l1l2_interface.h create mode 100644 Src/osmoconbb/src/host/layer23/include/osmocom/bb/common/l23_app.h create mode 100644 Src/osmoconbb/src/host/layer23/include/osmocom/bb/common/lapdm.h create mode 100644 Src/osmoconbb/src/host/layer23/include/osmocom/bb/common/logging.h create mode 100644 Src/osmoconbb/src/host/layer23/include/osmocom/bb/common/networks.h create mode 100644 Src/osmoconbb/src/host/layer23/include/osmocom/bb/common/osmocom_data.h create mode 100644 Src/osmoconbb/src/host/layer23/include/osmocom/bb/common/sap_interface.h create mode 100644 Src/osmoconbb/src/host/layer23/include/osmocom/bb/common/sim.h create mode 100644 Src/osmoconbb/src/host/layer23/include/osmocom/bb/common/sysinfo.h create mode 100644 Src/osmoconbb/src/host/layer23/include/osmocom/bb/misc/Makefile.am create mode 100644 Src/osmoconbb/src/host/layer23/include/osmocom/bb/misc/cell_log.h create mode 100644 Src/osmoconbb/src/host/layer23/include/osmocom/bb/misc/layer3.h create mode 100644 Src/osmoconbb/src/host/layer23/include/osmocom/bb/misc/rslms.h create mode 100644 Src/osmoconbb/src/host/layer23/include/osmocom/bb/mobile/Makefile.am create mode 100644 Src/osmoconbb/src/host/layer23/include/osmocom/bb/mobile/app_mobile.h create mode 100644 Src/osmoconbb/src/host/layer23/include/osmocom/bb/mobile/gsm322.h create mode 100644 Src/osmoconbb/src/host/layer23/include/osmocom/bb/mobile/gsm48_cc.h create mode 100644 Src/osmoconbb/src/host/layer23/include/osmocom/bb/mobile/gsm48_mm.h create mode 100644 Src/osmoconbb/src/host/layer23/include/osmocom/bb/mobile/gsm48_rr.h create mode 100644 Src/osmoconbb/src/host/layer23/include/osmocom/bb/mobile/mncc.h create mode 100644 Src/osmoconbb/src/host/layer23/include/osmocom/bb/mobile/settings.h create mode 100644 Src/osmoconbb/src/host/layer23/include/osmocom/bb/mobile/subscriber.h create mode 100644 Src/osmoconbb/src/host/layer23/include/osmocom/bb/mobile/support.h create mode 100644 Src/osmoconbb/src/host/layer23/include/osmocom/bb/mobile/transaction.h create mode 100644 Src/osmoconbb/src/host/layer23/include/osmocom/bb/mobile/voice.h create mode 100644 Src/osmoconbb/src/host/layer23/include/osmocom/bb/mobile/vty.h (limited to 'Src/osmoconbb/src/host/layer23/include') diff --git a/Src/osmoconbb/src/host/layer23/include/Makefile.am b/Src/osmoconbb/src/host/layer23/include/Makefile.am new file mode 100644 index 0000000..297ece9 --- /dev/null +++ b/Src/osmoconbb/src/host/layer23/include/Makefile.am @@ -0,0 +1,2 @@ +noinst_HEADERS = l1ctl_proto.h +SUBDIRS = osmocom diff --git a/Src/osmoconbb/src/host/layer23/include/l1ctl_proto.h b/Src/osmoconbb/src/host/layer23/include/l1ctl_proto.h new file mode 120000 index 0000000..f12ba71 --- /dev/null +++ b/Src/osmoconbb/src/host/layer23/include/l1ctl_proto.h @@ -0,0 +1 @@ +../../../../include/l1ctl_proto.h \ No newline at end of file diff --git a/Src/osmoconbb/src/host/layer23/include/osmocom/Makefile.am b/Src/osmoconbb/src/host/layer23/include/osmocom/Makefile.am new file mode 100644 index 0000000..5adf9df --- /dev/null +++ b/Src/osmoconbb/src/host/layer23/include/osmocom/Makefile.am @@ -0,0 +1 @@ +SUBDIRS = bb diff --git a/Src/osmoconbb/src/host/layer23/include/osmocom/bb/Makefile.am b/Src/osmoconbb/src/host/layer23/include/osmocom/bb/Makefile.am new file mode 100644 index 0000000..58a5f7f --- /dev/null +++ b/Src/osmoconbb/src/host/layer23/include/osmocom/bb/Makefile.am @@ -0,0 +1 @@ +SUBDIRS = common misc mobile diff --git a/Src/osmoconbb/src/host/layer23/include/osmocom/bb/common/Makefile.am b/Src/osmoconbb/src/host/layer23/include/osmocom/bb/common/Makefile.am new file mode 100644 index 0000000..26e63cf --- /dev/null +++ b/Src/osmoconbb/src/host/layer23/include/osmocom/bb/common/Makefile.am @@ -0,0 +1,2 @@ +noinst_HEADERS = l1ctl.h l1l2_interface.h l23_app.h lapdm.h logging.h \ + networks.h gps.h sysinfo.h osmocom_data.h diff --git a/Src/osmoconbb/src/host/layer23/include/osmocom/bb/common/gps.h b/Src/osmoconbb/src/host/layer23/include/osmocom/bb/common/gps.h new file mode 100644 index 0000000..58c0c53 --- /dev/null +++ b/Src/osmoconbb/src/host/layer23/include/osmocom/bb/common/gps.h @@ -0,0 +1,53 @@ +/* + * (C) 2010 by Andreas Eversberg + * + * 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. + * + */ + +enum { + GPS_TYPE_UNDEF, + GPS_TYPE_GPSD, + GPS_TYPE_SERIAL +}; + +struct osmo_gps { + /* GPS device */ + uint8_t enable; + uint8_t gps_type; + +#ifdef _HAVE_GPSD + char gpsd_host[32]; + char gpsd_port[6]; +#endif + + char device[32]; + uint32_t baud; + + /* current data */ + uint8_t valid; /* we have a fix */ + time_t gmt; /* GMT time when position was received */ + double latitude, longitude; +}; + +extern struct osmo_gps g; + +int osmo_gps_open(void); +void osmo_gps_close(void); +void osmo_gps_init(void); + + diff --git a/Src/osmoconbb/src/host/layer23/include/osmocom/bb/common/l1ctl.h b/Src/osmoconbb/src/host/layer23/include/osmocom/bb/common/l1ctl.h new file mode 100644 index 0000000..5ebea96 --- /dev/null +++ b/Src/osmoconbb/src/host/layer23/include/osmocom/bb/common/l1ctl.h @@ -0,0 +1,76 @@ +#ifndef osmocom_l1ctl_h +#define osmocom_l1ctl_h + +#include +#include + +struct osmocom_ms; + +/* Receive incoming data from L1 using L1CTL format */ +int l1ctl_recv(struct osmocom_ms *ms, struct msgb *msg); + +/* Transmit L1CTL_DATA_REQ */ +int l1ctl_tx_data_req(struct osmocom_ms *ms, struct msgb *msg, uint8_t chan_nr, + uint8_t link_id); + +/* Transmit L1CTL_PARAM_REQ */ +int l1ctl_tx_param_req(struct osmocom_ms *ms, uint8_t ta, uint8_t tx_power); + +int l1ctl_tx_crypto_req(struct osmocom_ms *ms, uint8_t algo, uint8_t *key, + uint8_t len); + +/* Transmit L1CTL_RACH_REQ */ +int l1ctl_tx_rach_req(struct osmocom_ms *ms, uint8_t ra, uint16_t offset, + uint8_t combined); + +/* Transmit L1CTL_DM_EST_REQ */ +int l1ctl_tx_dm_est_req_h0(struct osmocom_ms *ms, uint16_t band_arfcn, + uint8_t chan_nr, uint8_t tsc, uint8_t tch_mode, uint8_t audio_mode); +int l1ctl_tx_dm_est_req_h1(struct osmocom_ms *ms, uint8_t maio, uint8_t hsn, + uint16_t *ma, uint8_t ma_len, uint8_t chan_nr, uint8_t tsc, + uint8_t tch_mode, uint8_t audio_mode); + +/* Transmit L1CTL_DM_FREQ_REQ */ +int l1ctl_tx_dm_freq_req_h0(struct osmocom_ms *ms, uint16_t band_arfcn, + uint8_t tsc, uint16_t fn); +int l1ctl_tx_dm_freq_req_h1(struct osmocom_ms *ms, uint8_t maio, uint8_t hsn, + uint16_t *ma, uint8_t ma_len, uint8_t tsc, uint16_t fn); + +/* Transmit L1CTL_DM_REL_REQ */ +int l1ctl_tx_dm_rel_req(struct osmocom_ms *ms); + +/* Transmit FBSB_REQ */ +int l1ctl_tx_fbsb_req(struct osmocom_ms *ms, uint16_t arfcn, + uint8_t flags, uint16_t timeout, uint8_t sync_info_idx, + uint8_t ccch_mode); + +/* Transmit CCCH_MODE_REQ */ +int l1ctl_tx_ccch_mode_req(struct osmocom_ms *ms, uint8_t ccch_mode); + +/* Transmit TCH_MODE_REQ */ +int l1ctl_tx_tch_mode_req(struct osmocom_ms *ms, uint8_t tch_mode, + uint8_t audio_mode); + +/* Transmit ECHO_REQ */ +int l1ctl_tx_echo_req(struct osmocom_ms *ms, unsigned int len); + +/* Transmit L1CTL_RESET_REQ */ +int l1ctl_tx_reset_req(struct osmocom_ms *ms, uint8_t type); + +/* Transmit L1CTL_PM_REQ */ +int l1ctl_tx_pm_req_range(struct osmocom_ms *ms, uint16_t arfcn_from, + uint16_t arfcm_to); + +int l1ctl_tx_sim_req(struct osmocom_ms *ms, uint8_t *data, uint16_t length); + +/* Transmit L1CTL_VOICE_REQ */ +int l1ctl_tx_traffic_req(struct osmocom_ms *ms, struct msgb *msg, + uint8_t chan_nr, uint8_t link_id); + +/* LAPDm wants to send a PH-* primitive to the physical layer (L1) */ +int l1ctl_ph_prim_cb(struct osmo_prim_hdr *oph, void *ctx); + +/* Transmit L1CTL_NEIGH_PM_REQ */ +int l1ctl_tx_neigh_pm_req(struct osmocom_ms *ms, int num, uint16_t *arfcn); + +#endif diff --git a/Src/osmoconbb/src/host/layer23/include/osmocom/bb/common/l1l2_interface.h b/Src/osmoconbb/src/host/layer23/include/osmocom/bb/common/l1l2_interface.h new file mode 100644 index 0000000..41403d8 --- /dev/null +++ b/Src/osmoconbb/src/host/layer23/include/osmocom/bb/common/l1l2_interface.h @@ -0,0 +1,8 @@ +#ifndef _L1L2_INTERFACE_H +#define _L1L2_INTERFACE_H + +int layer2_open(struct osmocom_ms *ms, const char *socket_path); +int layer2_close(struct osmocom_ms *ms); +int osmo_send_l1(struct osmocom_ms *ms, struct msgb *msg); + +#endif /* _L1L2_INTERFACE_H */ diff --git a/Src/osmoconbb/src/host/layer23/include/osmocom/bb/common/l23_app.h b/Src/osmoconbb/src/host/layer23/include/osmocom/bb/common/l23_app.h new file mode 100644 index 0000000..e4c5d55 --- /dev/null +++ b/Src/osmoconbb/src/host/layer23/include/osmocom/bb/common/l23_app.h @@ -0,0 +1,35 @@ +#ifndef _L23_APP_H +#define _L23_APP_H + +struct option; + +/* Options supported by the l23 app */ +enum { + L23_OPT_SAP = 1, + L23_OPT_ARFCN = 2, + L23_OPT_TAP = 4, + L23_OPT_VTY = 8, + L23_OPT_DBG = 16, +}; + +/* initialization, called once when starting the app, before entering + * select loop */ +extern int l23_app_init(struct osmocom_ms *ms); +extern int (*l23_app_work) (struct osmocom_ms *ms); +extern int (*l23_app_exit) (struct osmocom_ms *ms); + +/* configuration options */ +struct l23_app_info { + const char *copyright; + const char *contribution; + + char *getopt_string; + int (*cfg_supported)(); + int (*cfg_print_help)(); + int (*cfg_getopt_opt)(struct option **options); + int (*cfg_handle_opt)(int c,const char *optarg); +}; + +extern struct l23_app_info *l23_app_info(); + +#endif /* _L23_APP_H */ diff --git a/Src/osmoconbb/src/host/layer23/include/osmocom/bb/common/lapdm.h b/Src/osmoconbb/src/host/layer23/include/osmocom/bb/common/lapdm.h new file mode 100644 index 0000000..2e78aee --- /dev/null +++ b/Src/osmoconbb/src/host/layer23/include/osmocom/bb/common/lapdm.h @@ -0,0 +1,186 @@ +#ifndef _OSMOCOM_LAPDM_H +#define _OSMOCOM_LAPDM_H + +#include + +#include +#include +#include + +/* primitive related sutff */ + +enum osmo_ph_prim { + PRIM_PH_DATA, /* PH-DATA */ + PRIM_PH_RACH, /* PH-RANDOM_ACCESS */ + PRIM_PH_CONN, /* PH-CONNECT */ + PRIM_PH_EMPTY_FRAME, /* PH-EMPTY_FRAME */ + PRIM_PH_RTS, /* PH-RTS */ +}; + +/* for PH-RANDOM_ACCESS.req */ +struct ph_rach_req_param { + uint8_t ra; + uint8_t ta; + uint8_t tx_power; + uint8_t is_combined_ccch; + uint16_t offset; +}; + +/* for PH-RANDOM_ACCESS.ind */ +struct ph_rach_ind_param { + uint8_t ra; + uint8_t acc_delay; + uint32_t fn; +}; + +/* for PH-[UNIT]DATA.{req,ind} */ +struct ph_data_param { + uint8_t link_id; + uint8_t chan_nr; +}; + +struct ph_conn_ind_param { + uint32_t fn; +}; + +struct osmo_phsap_prim { + struct osmo_prim_hdr oph; + union { + struct ph_data_param data; + struct ph_rach_req_param rach_req; + struct ph_rach_ind_param rach_ind; + struct ph_conn_ind_param conn_ind; + } u; +}; + +enum lapdm_mode { + LAPDM_MODE_MS, + LAPDM_MODE_BTS, +}; + +enum lapdm_state { + LAPDm_STATE_NULL = 0, + LAPDm_STATE_IDLE, + LAPDm_STATE_SABM_SENT, + LAPDm_STATE_MF_EST, + LAPDm_STATE_TIMER_RECOV, + LAPDm_STATE_DISC_SENT, +}; + +struct lapdm_entity; + +struct lapdm_msg_ctx { + struct lapdm_datalink *dl; + int lapdm_fmt; + uint8_t n201; + uint8_t chan_nr; + uint8_t link_id; + uint8_t addr; + uint8_t ctrl; + uint8_t ta_ind; + uint8_t tx_power_ind; +}; + +/* TS 04.06 / Section 3.5.2 */ +struct lapdm_datalink { + uint8_t V_send; /* seq nr of next I frame to be transmitted */ + uint8_t V_ack; /* last frame ACKed by peer */ + uint8_t N_send; /* ? set to V_send at Tx time*/ + uint8_t V_recv; /* seq nr of next I frame expected to be received */ + uint8_t N_recv; /* expected send seq nr of the next received I frame */ + uint32_t state; + int seq_err_cond; /* condition of sequence error */ + uint8_t own_busy, peer_busy; + struct osmo_timer_list t200; + uint8_t retrans_ctr; + struct llist_head send_queue; /* frames from L3 */ + struct msgb *send_buffer; /* current frame transmitting */ + int send_out; /* how much was sent from send_buffer */ + uint8_t tx_hist[8][200]; /* tx history buffer */ + int tx_length[8]; /* length in history buffer */ + struct llist_head tx_queue; /* frames to L1 */ + struct lapdm_msg_ctx mctx; /* context of established connection */ + struct msgb *rcv_buffer; /* buffer to assemble the received message */ + + struct lapdm_entity *entity; +}; + +enum lapdm_dl_sapi { + DL_SAPI0 = 0, + DL_SAPI3 = 1, + _NR_DL_SAPI +}; + +typedef int (*lapdm_cb_t)(struct msgb *msg, struct lapdm_entity *le, void *ctx); + +struct lapdm_cr_ent { + uint8_t cmd; + uint8_t resp; +}; + +#define LAPDM_ENT_F_EMPTY_FRAME 0x0001 +#define LAPDM_ENT_F_POLLING_ONLY 0x0002 + +/* register message handler for messages that are sent from L2->L3 */ +struct lapdm_entity { + struct lapdm_datalink datalink[_NR_DL_SAPI]; + int last_tx_dequeue; /* last entity that was dequeued */ + int tx_pending; /* currently a pending frame not confirmed by L1 */ + enum lapdm_mode mode; /* are we in BTS mode or MS mode */ + unsigned int flags; + + struct { + /* filled-in once we set the lapdm_mode above */ + struct lapdm_cr_ent loc2rem; + struct lapdm_cr_ent rem2loc; + } cr; + + void *l1_ctx; /* context for layer1 instance */ + void *l3_ctx; /* context for layer3 instance */ + + osmo_prim_cb l1_prim_cb; + lapdm_cb_t l3_cb; /* callback for sending stuff to L3 */ + + struct lapdm_channel *lapdm_ch; +}; + +/* the two lapdm_entities that form a GSM logical channel (ACCH + DCCH) */ +struct lapdm_channel { + struct llist_head list; + char *name; + struct lapdm_entity lapdm_acch; + struct lapdm_entity lapdm_dcch; +}; + +const char *get_rsl_name(int value); +extern const char *lapdm_state_names[]; + +/* initialize a LAPDm entity */ +void lapdm_entity_init(struct lapdm_entity *le, enum lapdm_mode mode); +void lapdm_channel_init(struct lapdm_channel *lc, enum lapdm_mode mode); + +/* deinitialize a LAPDm entity */ +void lapdm_entity_exit(struct lapdm_entity *le); +void lapdm_channel_exit(struct lapdm_channel *lc); + +/* input into layer2 (from layer 1) */ +int lapdm_phsap_up(struct osmo_prim_hdr *oph, struct lapdm_entity *le); + +/* input into layer2 (from layer 3) */ +int lapdm_rslms_recvmsg(struct msgb *msg, struct lapdm_channel *lc); + +void lapdm_channel_set_l3(struct lapdm_channel *lc, lapdm_cb_t cb, void *ctx); +void lapdm_channel_set_l1(struct lapdm_channel *lc, osmo_prim_cb cb, void *ctx); + +int lapdm_entity_set_mode(struct lapdm_entity *le, enum lapdm_mode mode); +int lapdm_channel_set_mode(struct lapdm_channel *lc, enum lapdm_mode mode); + +void lapdm_entity_reset(struct lapdm_entity *le); +void lapdm_channel_reset(struct lapdm_channel *lc); + +void lapdm_entity_set_flags(struct lapdm_entity *le, unsigned int flags); +void lapdm_channel_set_flags(struct lapdm_channel *lc, unsigned int flags); + +int lapdm_phsap_dequeue_prim(struct lapdm_entity *le, struct osmo_phsap_prim *pp); + +#endif /* _OSMOCOM_LAPDM_H */ diff --git a/Src/osmoconbb/src/host/layer23/include/osmocom/bb/common/logging.h b/Src/osmoconbb/src/host/layer23/include/osmocom/bb/common/logging.h new file mode 100644 index 0000000..554b767 --- /dev/null +++ b/Src/osmoconbb/src/host/layer23/include/osmocom/bb/common/logging.h @@ -0,0 +1,29 @@ +#ifndef _LOGGING_H +#define _LOGGING_H + +#define DEBUG +#include + +enum { + DRSL, + DRR, + DPLMN, + DCS, + DNB, + DMM, + DCC, + DSMS, + DMNCC, + DMEAS, + DPAG, + DLAPDM, + DL1C, + DSAP, + DSUM, + DSIM, + DGPS, +}; + +extern const struct log_info log_info; + +#endif /* _LOGGING_H */ diff --git a/Src/osmoconbb/src/host/layer23/include/osmocom/bb/common/networks.h b/Src/osmoconbb/src/host/layer23/include/osmocom/bb/common/networks.h new file mode 100644 index 0000000..e681216 --- /dev/null +++ b/Src/osmoconbb/src/host/layer23/include/osmocom/bb/common/networks.h @@ -0,0 +1,24 @@ +#ifndef _NETWORKS_H +#define _NETWORKS_H + +#define GSM_INPUT_INVALID 0xffff + +struct gsm_networks { + uint16_t mcc; + int16_t mnc; + const char *name; +}; + +int gsm_match_mcc(uint16_t mcc, char *imsi); +int gsm_match_mnc(uint16_t mcc, uint8_t mnc, char *imsi); +const char *gsm_print_mcc(uint16_t mcc); +const char *gsm_print_mnc(uint16_t mcc); +const char *gsm_get_mcc(uint16_t mcc); +const char *gsm_get_mnc(uint16_t mcc, uint16_t mnc); +const char *gsm_imsi_mcc(char *imsi); +const char *gsm_imsi_mnc(char *imsi); +const uint16_t gsm_input_mcc(char *string); +const uint16_t gsm_input_mnc(char *string); + +#endif /* _NETWORKS_H */ + diff --git a/Src/osmoconbb/src/host/layer23/include/osmocom/bb/common/osmocom_data.h b/Src/osmoconbb/src/host/layer23/include/osmocom/bb/common/osmocom_data.h new file mode 100644 index 0000000..6ad89cd --- /dev/null +++ b/Src/osmoconbb/src/host/layer23/include/osmocom/bb/common/osmocom_data.h @@ -0,0 +1,129 @@ +#ifndef osmocom_data_h +#define osmocom_data_h + +#include +#include +#include + +struct osmocom_ms; + + /* FIXME no 'mobile' specific stuff should be here */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +struct osmosap_entity { + osmosap_cb_t msg_handler; +}; + +struct osmol1_entity { + int (*l1_traffic_ind)(struct osmocom_ms *ms, struct msgb *msg); +}; + +struct osmomncc_entity { + int (*mncc_recv)(struct osmocom_ms *ms, int msg_type, void *arg); + uint32_t ref; +}; + + +/* RX measurement statistics */ +struct rx_meas_stat { + uint32_t last_fn; + + /* cumulated values of current cell from SACCH dl */ + uint32_t frames; + uint32_t snr; + uint32_t berr; + uint32_t rxlev; + + /* counters loss criterion */ + int16_t dsc, ds_fail; + int16_t s, rl_fail; +}; + +/* One Mobilestation for osmocom */ +struct osmocom_ms { + struct llist_head entity; + char name[32]; + struct osmo_wqueue l2_wq, sap_wq; + uint16_t test_arfcn; + struct osmol1_entity l1_entity; + + uint8_t deleting, shutdown, started; + struct gsm_support support; + struct gsm_settings settings; + struct gsm_subscriber subscr; + struct gsm_sim sim; + struct lapdm_channel lapdm_channel; + struct osmosap_entity sap_entity; + struct rx_meas_stat meas; + struct gsm48_rrlayer rrlayer; + struct gsm322_plmn plmn; + struct gsm322_cellsel cellsel; + struct gsm48_mmlayer mmlayer; + struct gsm48_cclayer cclayer; + struct osmomncc_entity mncc_entity; + struct llist_head trans_list; +}; + +enum osmobb_sig_subsys { + SS_L1CTL, + SS_GLOBAL, +}; + +enum osmobb_l1ctl_sig { + S_L1CTL_FBSB_ERR, + S_L1CTL_FBSB_RESP, + S_L1CTL_RESET, + S_L1CTL_PM_RES, + S_L1CTL_PM_DONE, + S_L1CTL_CCCH_MODE_CONF, + S_L1CTL_TCH_MODE_CONF, + S_L1CTL_LOSS_IND, + S_L1CTL_NEIGH_PM_IND, +}; + +enum osmobb_global_sig { + S_GLOBAL_SHUTDOWN, +}; + +struct osmobb_fbsb_res { + struct osmocom_ms *ms; + int8_t snr; + uint8_t bsic; + uint16_t band_arfcn; +}; + +struct osmobb_meas_res { + struct osmocom_ms *ms; + uint16_t band_arfcn; + uint8_t rx_lev; +}; + +struct osmobb_ccch_mode_conf { + struct osmocom_ms *ms; + uint8_t ccch_mode; +}; + +struct osmobb_tch_mode_conf { + struct osmocom_ms *ms; + uint8_t tch_mode; + uint8_t audio_mode; +}; + +struct osmobb_neigh_pm_ind { + struct osmocom_ms *ms; + uint16_t band_arfcn; + uint8_t rx_lev; +}; + +#endif diff --git a/Src/osmoconbb/src/host/layer23/include/osmocom/bb/common/sap_interface.h b/Src/osmoconbb/src/host/layer23/include/osmocom/bb/common/sap_interface.h new file mode 100644 index 0000000..f2f577a --- /dev/null +++ b/Src/osmoconbb/src/host/layer23/include/osmocom/bb/common/sap_interface.h @@ -0,0 +1,11 @@ +#ifndef _SAP_INTERFACE_H +#define _SAP_INTERFACE_H + +typedef int (*osmosap_cb_t)(struct msgb *msg, struct osmocom_ms *ms); + +int sap_open(struct osmocom_ms *ms, const char *socket_path); +int sap_close(struct osmocom_ms *ms); +int osmosap_send(struct osmocom_ms *ms, struct msgb *msg); +int osmosap_register_handler(struct osmocom_ms *ms, osmosap_cb_t cb); + +#endif /* _SAP_INTERFACE_H */ diff --git a/Src/osmoconbb/src/host/layer23/include/osmocom/bb/common/sim.h b/Src/osmoconbb/src/host/layer23/include/osmocom/bb/common/sim.h new file mode 100644 index 0000000..a676b92 --- /dev/null +++ b/Src/osmoconbb/src/host/layer23/include/osmocom/bb/common/sim.h @@ -0,0 +1,274 @@ +/* + * (C) 2010 by Andreas Eversberg + * + * 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. + * + */ + + +/* 9.2 commands */ +#define GSM1111_CLASS_GSM 0xa0 +#define GSM1111_INST_SELECT 0xa4 +#define GSM1111_INST_STATUS 0xf2 +#define GSM1111_INST_READ_BINARY 0xb0 +#define GSM1111_INST_UPDATE_BINARY 0xd6 +#define GSM1111_INST_READ_RECORD 0xb2 +#define GSM1111_INST_UPDATE_RECORD 0xdc +#define GSM1111_INST_SEEK 0xa2 +#define GSM1111_INST_INCREASE 0x32 +#define GSM1111_INST_VERIFY_CHV 0x20 +#define GSM1111_INST_CHANGE_CHV 0x24 +#define GSM1111_INST_DISABLE_CHV 0x26 +#define GSM1111_INST_ENABLE_CHV 0x28 +#define GSM1111_INST_UNBLOCK_CHV 0x2c +#define GSM1111_INST_INVALIDATE 0x04 +#define GSM1111_INST_REHABLILITATE 0x44 +#define GSM1111_INST_RUN_GSM_ALGO 0x88 +#define GSM1111_INST_SLEEP 0xfa +#define GSM1111_INST_GET_RESPONSE 0xc0 +#define GSM1111_INST_TERMINAL_PROFILE 0x10 +#define GSM1111_INST_ENVELOPE 0xc2 +#define GSM1111_INST_FETCH 0x12 +#define GSM1111_INST_TERMINAL_RESPONSE 0x14 + +/* 9.3 access conditions */ +#define GSM1111_ACC_ALWAYS 0x0 +#define GSM1111_ACC_CHV1 0x1 +#define GSM1111_ACC_CHV2 0x2 +#define GSM1111_ACC_RFU 0x3 +#define GSM1111_ACC_NEW 0xf +/* others are ADM */ + +/* 9.3 type of file */ +#define GSM1111_TOF_RFU 0x00 +#define GSM1111_TOF_MF 0x01 +#define GSM1111_TOF_DF 0x02 +#define GSM1111_TOF_EF 0x04 + +/* 9.3 struct of file */ +#define GSM1111_SOF_TRANSPARENT 0x00 +#define GSM1111_SOF_LINEAR 0x01 +#define GSM1111_SOF_CYCLIC 0x03 + +/* 9.4 status */ +#define GSM1111_STAT_NORMAL 0x90 +#define GSM1111_STAT_PROACTIVE 0x91 +#define GSM1111_STAT_DL_ERROR 0x9e +#define GSM1111_STAT_RESPONSE 0x9f +#define GSM1111_STAT_RESPONSE_TOO 0x61 +#define GSM1111_STAT_APP_TK_BUSY 0x93 +#define GSM1111_STAT_MEM_PROBLEM 0x92 +#define GSM1111_STAT_REFERENCING 0x94 +#define GSM1111_STAT_SECURITY 0x98 +#define GSM1111_STAT_INCORR_P3 0x67 +#define GSM1111_STAT_INCORR_P1_P2 0x6b +#define GSM1111_STAT_UKN_INST 0x6d +#define GSM1111_STAT_WRONG_CLASS 0x6e +#define GSM1111_STAT_TECH_PROBLEM 0x6f + +/* 9.4.4 Referencing management SW2 */ +#define GSM1111_REF_NO_EF 0x00 +#define GSM1111_REF_OUT_OF_RANGE 0x02 +#define GSM1111_REF_FILE_NOT_FOUND 0x04 +#define GSM1111_REF_FILE_INCONSI 0x08 + +/* 9.4.5 Security management SW2 */ +#define GSM1111_SEC_NO_CHV 0x02 +#define GSM1111_SEC_NO_ACCESS 0x04 +#define GSM1111_SEC_CONTRA_CHV 0x08 +#define GSM1111_SEC_CONTRA_INVAL 0x10 +#define GSM1111_SEC_BLOCKED 0x40 +#define GSM1111_SEC_MAX_VALUE 0x50 + +/* messages from application to sim client */ +enum { + /* requests */ + SIM_JOB_READ_BINARY, + SIM_JOB_UPDATE_BINARY, + SIM_JOB_READ_RECORD, + SIM_JOB_UPDATE_RECORD, + SIM_JOB_SEEK_RECORD, + SIM_JOB_INCREASE, + SIM_JOB_INVALIDATE, + SIM_JOB_REHABILITATE, + SIM_JOB_RUN_GSM_ALGO, + SIM_JOB_PIN1_UNLOCK, + SIM_JOB_PIN1_CHANGE, + SIM_JOB_PIN1_DISABLE, + SIM_JOB_PIN1_ENABLE, + SIM_JOB_PIN1_UNBLOCK, + SIM_JOB_PIN2_UNLOCK, + SIM_JOB_PIN2_CHANGE, + SIM_JOB_PIN2_UNBLOCK, + + /* results */ + SIM_JOB_OK, + SIM_JOB_ERROR, +}; + +/* messages from sim client to application */ +#define SIM_JOB_OK 0 +#define SIM_JOB_ERROR 1 + +/* error causes */ +#define SIM_CAUSE_NO_SIM 0 /* no SIM present, if detectable */ +#define SIM_CAUSE_SIM_ERROR 1 /* any error while reading SIM */ +#define SIM_CAUSE_REQUEST_ERROR 2 /* error in request */ +#define SIM_CAUSE_PIN1_REQUIRED 3 /* CHV1 is required for access */ +#define SIM_CAUSE_PIN2_REQUIRED 4 /* CHV2 is required for access */ +#define SIM_CAUSE_PIN1_BLOCKED 5 /* CHV1 was entered too many times */ +#define SIM_CAUSE_PIN2_BLOCKED 6 /* CHV2 was entered too many times */ +#define SIM_CAUSE_PUC_BLOCKED 7 /* unblock entered too many times */ + +/* job states */ +enum { + SIM_JST_IDLE = 0, + SIM_JST_SELECT_MFDF, /* SELECT sent */ + SIM_JST_SELECT_MFDF_RESP, /* GET RESPONSE sent */ + SIM_JST_SELECT_EF, /* SELECT sent */ + SIM_JST_SELECT_EF_RESP, /* GET RESPONSE sent */ + SIM_JST_WAIT_FILE, /* file command sent */ + SIM_JST_RUN_GSM_ALGO, /* wait for algorithm to process */ + SIM_JST_RUN_GSM_ALGO_RESP, /* wait for response */ + SIM_JST_PIN1_UNLOCK, + SIM_JST_PIN1_CHANGE, + SIM_JST_PIN1_DISABLE, + SIM_JST_PIN1_ENABLE, + SIM_JST_PIN1_UNBLOCK, + SIM_JST_PIN2_UNLOCK, + SIM_JST_PIN2_CHANGE, + SIM_JST_PIN2_UNBLOCK, +}; + +#define MAX_SIM_PATH_LENGTH 6 + 1 /* one for the termination */ + +struct gsm_sim_handler { + struct llist_head entry; + + uint32_t handle; + void (*cb)(struct osmocom_ms *ms, struct msgb *msg); +}; + +struct gsm_sim { + struct llist_head handlers; /* gsm_sim_handler */ + struct llist_head jobs; /* messages */ + uint16_t path[MAX_SIM_PATH_LENGTH]; + uint16_t file; + + struct msgb *job_msg; + uint32_t job_handle; + int job_state; + + uint8_t reset; + uint8_t chv1_remain, chv2_remain; + uint8_t unblk1_remain, unblk2_remain; +}; + +struct sim_hdr { + int handle; + uint8_t job_type; + uint16_t path[MAX_SIM_PATH_LENGTH]; + uint16_t file; + uint8_t rec_no, rec_mode; /* in case of record */ + uint8_t seek_type_mode; /* in case of seek command */ +}; + +#define SIM_ALLOC_SIZE 512 +#define SIM_ALLOC_HEADROOM 64 + +struct msgb *gsm_sim_msgb_alloc(uint32_t handle, uint8_t job_type); +uint32_t sim_open(struct osmocom_ms *ms, + void (*cb)(struct osmocom_ms *ms, struct msgb *msg)); +void sim_close(struct osmocom_ms *ms, uint32_t handle); +void sim_job(struct osmocom_ms *ms, struct msgb *msg); + +/* Section 9.2.1 (response to selecting DF or MF) */ +struct gsm1111_response_mfdf { + uint16_t rfu1; + uint16_t free_mem; + uint16_t file_id; + uint8_t tof; + uint8_t rfu2[5]; + uint8_t length; + uint8_t gsm_data[0]; +} __attribute__ ((packed)); + +struct gsm1111_response_mfdf_gsm { + uint8_t file_char; + uint8_t num_df; + uint8_t num_ef; + uint8_t num_codes; + uint8_t rfu1; + uint8_t chv1_remain:4, + rfu2:3, + chv1_init:1; + uint8_t unblk1_remain:4, + rfu3:3, + unblk1_init:1; + uint8_t chv2_remain:4, + rfu4:3, + chv2_init:1; + uint8_t unblk2_remain:4, + rfu5:3, + unblk2_init:1; + uint8_t more_data[0]; +} __attribute__ ((packed)); + +/* Section 9.2.1 (response to selecting EF) */ +struct gsm1111_response_ef { + uint16_t rfu1; + uint16_t file_size; + uint16_t file_id; + uint8_t tof; + uint8_t inc_allowed; + uint8_t acc_update:4, + acc_read:4; + uint8_t rfu2:4, + acc_inc:4; + uint8_t acc_inval:4, + acc_reha:4; + uint8_t not_inval:1, + rfu3:1, + ru_inval:1, + rfu4:5; + uint8_t length; + uint8_t structure; +} __attribute__ ((packed)); + +/* Section 10.3.17 */ +struct gsm1111_ef_loci { + uint32_t tmsi; + struct gsm48_loc_area_id lai; + uint8_t tmsi_time; + uint8_t lupd_status; +} __attribute__ ((packed)); + +/* Section 10.5.1 */ +struct gsm1111_ef_adn { + uint8_t len_bcd; + uint8_t ton_npi; + uint8_t number[10]; + uint8_t capa_conf; + uint8_t ext_id; +} __attribute__ ((packed)); + +int sim_apdu_resp(struct osmocom_ms *ms, struct msgb *msg); +int gsm_sim_init(struct osmocom_ms *ms); +int gsm_sim_exit(struct osmocom_ms *ms); +int gsm_sim_job_dequeue(struct osmocom_ms *ms); + + diff --git a/Src/osmoconbb/src/host/layer23/include/osmocom/bb/common/sysinfo.h b/Src/osmoconbb/src/host/layer23/include/osmocom/bb/common/sysinfo.h new file mode 100644 index 0000000..5d3ed59 --- /dev/null +++ b/Src/osmoconbb/src/host/layer23/include/osmocom/bb/common/sysinfo.h @@ -0,0 +1,158 @@ +#ifndef _SYSINFO_H +#define _SYSINFO_H + +#include + +/* collection of system information of the current cell */ + +/* frequency mask flags of frequency type */ +#define FREQ_TYPE_SERV 0x01 /* frequency of the serving cell */ +#define FREQ_TYPE_HOPP 0x02 /* frequency used for channel hopping */ +#define FREQ_TYPE_NCELL 0x1c /* frequency of the neighbor cell */ +#define FREQ_TYPE_NCELL_2 0x04 /* sub channel of SI 2 */ +#define FREQ_TYPE_NCELL_2bis 0x08 /* sub channel of SI 2bis */ +#define FREQ_TYPE_NCELL_2ter 0x10 /* sub channel of SI 2ter */ +#define FREQ_TYPE_REP 0xe0 /* frequency to be reported */ +#define FREQ_TYPE_REP_5 0x20 /* sub channel of SI 5 */ +#define FREQ_TYPE_REP_5bis 0x40 /* sub channel of SI 5bis */ +#define FREQ_TYPE_REP_5ter 0x80 /* sub channel of SI 5ter */ + +/* structure of all received system informations */ +struct gsm48_sysinfo { + /* flags of available information */ + uint8_t si1, si2, si2bis, si2ter, si3, + si4, si5, si5bis, si5ter, si6; + + /* memory maps to simply detect change in system info messages */ + uint8_t si1_msg[23]; + uint8_t si2_msg[23]; + uint8_t si2b_msg[23]; + uint8_t si2t_msg[23]; + uint8_t si3_msg[23]; + uint8_t si4_msg[23]; + uint8_t si5_msg[18]; + uint8_t si5b_msg[18]; + uint8_t si5t_msg[18]; + uint8_t si6_msg[18]; + + struct gsm_sysinfo_freq freq[1024]; /* all frequencies */ + uint16_t hopping[64]; /* hopping arfcn */ + uint8_t hopp_len; + + /* serving cell */ + uint8_t bsic; + uint16_t cell_id; + uint16_t mcc, mnc, lac; /* LAI */ + uint8_t max_retrans; /* decoded */ + uint8_t tx_integer; /* decoded */ + uint8_t reest_denied; /* 1 = denied */ + uint8_t cell_barr; /* 1 = barred */ + uint16_t class_barr; /* bit 10 is emergency */ + + /* si1 rest */ + uint8_t nch; + uint8_t nch_position; + uint8_t band_ind; /* set for DCS */ + + /* si3 rest */ + uint8_t sp; + uint8_t sp_cbq; + uint8_t sp_cro; + uint8_t sp_to; + uint8_t sp_pt; + uint8_t po; + uint8_t po_value; + uint8_t si2ter_ind; + uint8_t ecsm; + uint8_t sched; + uint8_t sched_where; + uint8_t gprs; + uint8_t gprs_ra_colour; + uint8_t gprs_si13_pos; + + /* cell selection */ + int8_t ms_txpwr_max_cch; + int8_t cell_resel_hyst_db; + int8_t rxlev_acc_min_db; + uint8_t neci; + uint8_t acs; + /* bcch options */ + uint8_t bcch_radio_link_timeout; + uint8_t bcch_dtx; + uint8_t bcch_pwrc; + /* sacch options */ + uint8_t sacch_radio_link_timeout; + uint8_t sacch_dtx; + uint8_t sacch_pwrc; + /* control channel */ + uint8_t ccch_conf; + uint8_t bs_ag_blks_res; + uint8_t att_allowed; + uint8_t pag_mf_periods; + int32_t t3212; /* real value in seconds */ + /* channel description */ + uint8_t tsc; + uint8_t h; /* using hopping */ + uint16_t arfcn; + uint8_t maio; + uint8_t hsn; + uint8_t chan_nr; /* type, slot, sub slot */ + + /* neighbor cell */ + uint8_t nb_ext_ind_si2; + uint8_t nb_ba_ind_si2; + uint8_t nb_ext_ind_si2bis; + uint8_t nb_ba_ind_si2bis; + uint8_t nb_multi_rep_si2ter; /* see GSM 05.08 8.4.3 */ + uint8_t nb_ba_ind_si2ter; + uint8_t nb_ext_ind_si5; + uint8_t nb_ba_ind_si5; + uint8_t nb_ext_ind_si5bis; + uint8_t nb_ba_ind_si5bis; + uint8_t nb_multi_rep_si5ter; + uint8_t nb_ba_ind_si5ter; + uint8_t nb_ncc_permitted_si2; + uint8_t nb_ncc_permitted_si6; + uint8_t nb_max_retrans; /* decoded */ + uint8_t nb_tx_integer; /* decoded */ + uint8_t nb_reest_denied; /* 1 = denied */ + uint8_t nb_cell_barr; /* 1 = barred */ + uint16_t nb_class_barr; /* bit 10 is emergency */ +}; + +char *gsm_print_arfcn(uint16_t arfcn); +uint8_t gsm_refer_pcs(uint16_t arfcn, struct gsm48_sysinfo *s); +int gsm48_sysinfo_dump(struct gsm48_sysinfo *s, uint16_t arfcn, + void (*print)(void *, const char *, ...), void *priv, + uint8_t *freq_map); +int gsm48_decode_lai(struct gsm48_loc_area_id *lai, uint16_t *mcc, + uint16_t *mnc, uint16_t *lac); +int gsm48_decode_chan_h0(struct gsm48_chan_desc *cd, uint8_t *tsc, + uint16_t *arfcn); +int gsm48_decode_chan_h1(struct gsm48_chan_desc *cd, uint8_t *tsc, + uint8_t *maio, uint8_t *hsn); +int gsm48_decode_sysinfo1(struct gsm48_sysinfo *s, + struct gsm48_system_information_type_1 *si, int len); +int gsm48_decode_sysinfo2(struct gsm48_sysinfo *s, + struct gsm48_system_information_type_2 *si, int len); +int gsm48_decode_sysinfo2bis(struct gsm48_sysinfo *s, + struct gsm48_system_information_type_2bis *si, int len); +int gsm48_decode_sysinfo2ter(struct gsm48_sysinfo *s, + struct gsm48_system_information_type_2ter *si, int len); +int gsm48_decode_sysinfo3(struct gsm48_sysinfo *s, + struct gsm48_system_information_type_3 *si, int len); +int gsm48_decode_sysinfo4(struct gsm48_sysinfo *s, + struct gsm48_system_information_type_4 *si, int len); +int gsm48_decode_sysinfo5(struct gsm48_sysinfo *s, + struct gsm48_system_information_type_5 *si, int len); +int gsm48_decode_sysinfo5bis(struct gsm48_sysinfo *s, + struct gsm48_system_information_type_5bis *si, int len); +int gsm48_decode_sysinfo5ter(struct gsm48_sysinfo *s, + struct gsm48_system_information_type_5ter *si, int len); +int gsm48_decode_sysinfo6(struct gsm48_sysinfo *s, + struct gsm48_system_information_type_6 *si, int len); +int gsm48_decode_mobile_alloc(struct gsm_sysinfo_freq *freq, + uint8_t *ma, uint8_t len, uint16_t *hopping, uint8_t *hopp_len, + int si4); + +#endif /* _SYSINFO_H */ diff --git a/Src/osmoconbb/src/host/layer23/include/osmocom/bb/misc/Makefile.am b/Src/osmoconbb/src/host/layer23/include/osmocom/bb/misc/Makefile.am new file mode 100644 index 0000000..71c9d38 --- /dev/null +++ b/Src/osmoconbb/src/host/layer23/include/osmocom/bb/misc/Makefile.am @@ -0,0 +1 @@ +noinst_HEADERS = layer3.h rslms.h diff --git a/Src/osmoconbb/src/host/layer23/include/osmocom/bb/misc/cell_log.h b/Src/osmoconbb/src/host/layer23/include/osmocom/bb/misc/cell_log.h new file mode 100644 index 0000000..bce066e --- /dev/null +++ b/Src/osmoconbb/src/host/layer23/include/osmocom/bb/misc/cell_log.h @@ -0,0 +1,25 @@ +/* Cell Scanning code for OsmocomBB */ + +/* (C) 2010 by Andreas Eversberg + * + * 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. + * + */ + +int scan_init(struct osmocom_ms *_ms); +int scan_exit(void); + diff --git a/Src/osmoconbb/src/host/layer23/include/osmocom/bb/misc/layer3.h b/Src/osmoconbb/src/host/layer23/include/osmocom/bb/misc/layer3.h new file mode 100644 index 0000000..bbf242d --- /dev/null +++ b/Src/osmoconbb/src/host/layer23/include/osmocom/bb/misc/layer3.h @@ -0,0 +1,17 @@ +#ifndef _OSMOCOM_L3_H +#define _OSMOCOM_L3_H + +#include +#include + +int gsm48_rx_ccch(struct msgb *msg, struct osmocom_ms *ms); +int gsm48_rx_dcch(struct msgb *msg, struct osmocom_ms *ms); +int gsm48_rx_bcch(struct msgb *msg, struct osmocom_ms *ms); + +/* Initialize layer3 for the MS, hook it to L2 */ +int layer3_init(struct osmocom_ms *ms); + +/* Reset the 'aplication' state */ +void layer3_app_reset(void); + +#endif diff --git a/Src/osmoconbb/src/host/layer23/include/osmocom/bb/misc/rslms.h b/Src/osmoconbb/src/host/layer23/include/osmocom/bb/misc/rslms.h new file mode 100644 index 0000000..94fe99c --- /dev/null +++ b/Src/osmoconbb/src/host/layer23/include/osmocom/bb/misc/rslms.h @@ -0,0 +1,23 @@ +#ifndef _OSMOCOM_RSLMS_H +#define _OSMOCOM_RSLMS_H + +#include +#include + +/* From L3 into RSLMS (direction -> L2) */ + +/* Send a 'simple' RLL request to L2 */ +int rslms_tx_rll_req(struct osmocom_ms *ms, uint8_t msg_type, + uint8_t chan_nr, uint8_t link_id); + +/* Send a RLL request (including L3 info) to L2 */ +int rslms_tx_rll_req_l3(struct osmocom_ms *ms, uint8_t msg_type, + uint8_t chan_nr, uint8_t link_id, struct msgb *msg); + + +/* From L2 into RSLMS (direction -> L3) */ + +/* input function that L2 calls when sending messages up to L3 */ +//int rslms_sendmsg(struct msgb *msg, struct osmocom_ms *ms); + +#endif /* _OSMOCOM_RSLMS_H */ diff --git a/Src/osmoconbb/src/host/layer23/include/osmocom/bb/mobile/Makefile.am b/Src/osmoconbb/src/host/layer23/include/osmocom/bb/mobile/Makefile.am new file mode 100644 index 0000000..951e4d1 --- /dev/null +++ b/Src/osmoconbb/src/host/layer23/include/osmocom/bb/mobile/Makefile.am @@ -0,0 +1,2 @@ +noinst_HEADERS = gsm322.h gsm48_cc.h gsm48_mm.h gsm48_rr.h mncc.h settings.h \ + subscriber.h support.h transaction.h vty.h diff --git a/Src/osmoconbb/src/host/layer23/include/osmocom/bb/mobile/app_mobile.h b/Src/osmoconbb/src/host/layer23/include/osmocom/bb/mobile/app_mobile.h new file mode 100644 index 0000000..4010a68 --- /dev/null +++ b/Src/osmoconbb/src/host/layer23/include/osmocom/bb/mobile/app_mobile.h @@ -0,0 +1,17 @@ +#ifndef APP_MOBILE_H +#define APP_MOBILE_H + +char *config_dir; + +int l23_app_init(int (*mncc_recv)(struct osmocom_ms *ms, int, void *), + const char *config_file, uint16_t vty_port); +int l23_app_exit(void); +int l23_app_work(int *quit); +int mobile_delete(struct osmocom_ms *ms, int force); +struct osmocom_ms *mobile_new(char *name); +int mobile_init(struct osmocom_ms *ms); +int mobile_exit(struct osmocom_ms *ms, int force); +int mobile_work(struct osmocom_ms *ms); + +#endif + diff --git a/Src/osmoconbb/src/host/layer23/include/osmocom/bb/mobile/gsm322.h b/Src/osmoconbb/src/host/layer23/include/osmocom/bb/mobile/gsm322.h new file mode 100644 index 0000000..f39e566 --- /dev/null +++ b/Src/osmoconbb/src/host/layer23/include/osmocom/bb/mobile/gsm322.h @@ -0,0 +1,255 @@ +#ifndef _GSM322_H +#define _GSM322_H + +/* 4.3.1.1 List of states for PLMN slection process (automatic mode) */ +#define GSM322_A0_NULL 0 +#define GSM322_A1_TRYING_RPLMN 1 +#define GSM322_A2_ON_PLMN 2 +#define GSM322_A3_TRYING_PLMN 3 +#define GSM322_A4_WAIT_FOR_PLMN 4 +#define GSM322_A5_HPLMN_SEARCH 5 +#define GSM322_A6_NO_SIM 6 + +/* 4.3.1.2 List of states for PLMN slection process (manual mode) */ +#define GSM322_M0_NULL 0 +#define GSM322_M1_TRYING_RPLMN 1 +#define GSM322_M2_ON_PLMN 2 +#define GSM322_M3_NOT_ON_PLMN 3 +#define GSM322_M4_TRYING_PLMN 4 +#define GSM322_M5_NO_SIM 5 + +/* 4.3.2 List of states for cell selection process */ +#define GSM322_C0_NULL 0 +#define GSM322_C1_NORMAL_CELL_SEL 1 +#define GSM322_C2_STORED_CELL_SEL 2 +#define GSM322_C3_CAMPED_NORMALLY 3 +#define GSM322_C4_NORMAL_CELL_RESEL 4 +#define GSM322_C5_CHOOSE_CELL 5 +#define GSM322_C6_ANY_CELL_SEL 6 +#define GSM322_C7_CAMPED_ANY_CELL 7 +#define GSM322_C8_ANY_CELL_RESEL 8 +#define GSM322_C9_CHOOSE_ANY_CELL 9 +#define GSM322_CONNECTED_MODE_1 10 +#define GSM322_CONNECTED_MODE_2 11 +#define GSM322_PLMN_SEARCH 12 +#define GSM322_HPLMN_SEARCH 13 +#define GSM322_ANY_SEARCH 14 + +/* GSM 03.22 events */ +#define GSM322_EVENT_SWITCH_ON 1 +#define GSM322_EVENT_SWITCH_OFF 2 +#define GSM322_EVENT_SIM_INSERT 3 +#define GSM322_EVENT_SIM_REMOVE 4 +#define GSM322_EVENT_REG_SUCCESS 5 +#define GSM322_EVENT_REG_FAILED 6 +#define GSM322_EVENT_ROAMING_NA 7 +#define GSM322_EVENT_INVALID_SIM 8 +#define GSM322_EVENT_NEW_PLMN 9 +#define GSM322_EVENT_ON_PLMN 10 +#define GSM322_EVENT_PLMN_SEARCH_START 11 +#define GSM322_EVENT_PLMN_SEARCH_END 12 +#define GSM322_EVENT_USER_RESEL 13 +#define GSM322_EVENT_PLMN_AVAIL 14 +#define GSM322_EVENT_CHOOSE_PLMN 15 +#define GSM322_EVENT_SEL_MANUAL 16 +#define GSM322_EVENT_SEL_AUTO 17 +#define GSM322_EVENT_CELL_FOUND 18 +#define GSM322_EVENT_NO_CELL_FOUND 19 +#define GSM322_EVENT_LEAVE_IDLE 20 +#define GSM322_EVENT_RET_IDLE 21 +#define GSM322_EVENT_CELL_RESEL 22 +#define GSM322_EVENT_SYSINFO 23 +#define GSM322_EVENT_HPLMN_SEARCH 24 + +enum { + PLMN_MODE_MANUAL, + PLMN_MODE_AUTO +}; + +/* node for each PLMN */ +struct gsm322_plmn_list { + struct llist_head entry; + uint16_t mcc, mnc; + int8_t rxlev; /* rx level in range format */ + uint8_t cause; /* cause value, if PLMN is not allowed */ +}; + +/* node for each forbidden LA */ +struct gsm322_la_list { + struct llist_head entry; + uint16_t mcc, mnc, lac; + uint8_t cause; +}; + +/* node for each BA-List */ +struct gsm322_ba_list { + struct llist_head entry; + uint16_t mcc, mnc; + /* Band allocation for 1024+299 frequencies. + * First bit of first index is frequency 0. + */ + uint8_t freq[128+38]; +}; + +#define GSM322_CS_FLAG_SUPPORT 0x01 /* frequency is supported by radio */ +#define GSM322_CS_FLAG_BA 0x02 /* frequency is part of the current ba */ +#define GSM322_CS_FLAG_POWER 0x04 /* frequency was power scanned */ +#define GSM322_CS_FLAG_SIGNAL 0x08 /* valid signal detected */ +#define GSM322_CS_FLAG_SYSINFO 0x10 /* complete sysinfo received */ +#define GSM322_CS_FLAG_BARRED 0x20 /* cell is barred */ +#define GSM322_CS_FLAG_FORBIDD 0x40 /* cell in list of forbidden LAs */ +#define GSM322_CS_FLAG_TEMP_AA 0x80 /* if temporary available and allowable */ + +/* Cell selection list */ +struct gsm322_cs_list { + uint8_t flags; /* see GSM322_CS_FLAG_* */ + int8_t rxlev; /* rx level range format */ + struct gsm48_sysinfo *sysinfo; +}; + +/* PLMN search process */ +struct gsm322_plmn { + struct osmocom_ms *ms; + int state; /* GSM322_Ax_* or GSM322_Mx_* */ + + struct llist_head event_queue; /* event messages */ + struct llist_head sorted_plmn; /* list of sorted PLMN */ + struct llist_head forbidden_la; /* forbidden LAs */ + + struct osmo_timer_list timer; + + int plmn_curr; /* current index in sorted_plmn */ + uint16_t mcc, mnc; /* current network selected */ +}; + +/* state of CCCH activation */ +#define GSM322_CCCH_ST_IDLE 0 /* no connection */ +#define GSM322_CCCH_ST_INIT 1 /* initalized */ +#define GSM322_CCCH_ST_SYNC 2 /* got sync */ +#define GSM322_CCCH_ST_DATA 3 /* receiveing data */ + +/* neighbour cell info list entry */ +struct gsm322_neighbour { + struct llist_head entry; + struct gsm322_cellsel *cs; + uint16_t arfcn; /* ARFCN identity of that neighbour */ + + uint8_t state; /* GSM322_NB_* */ + time_t created; /* when was this neighbour created */ + time_t when; /* when did we sync / read */ + int16_t rxlev_dbm; /* sum of received levels */ + uint8_t rxlev_count; /* number of received levels */ + int8_t rla_c_dbm; /* average of the reveive level */ + uint8_t c12_valid; /* both C1 and C2 are calculated */ + int16_t c1, c2, crh; + uint8_t checked_for_resel; + uint8_t suitable_allowable; + uint8_t prio_low; +}; + +#define GSM322_NB_NEW 0 /* new NB instance */ +#define GSM322_NB_NOT_SUP 1 /* ARFCN not supported */ +#define GSM322_NB_RLA_C 2 /* valid measurement available */ +#define GSM322_NB_NO_SYNC 3 /* cannot sync to neighbour */ +#define GSM322_NB_NO_BCCH 4 /* sync */ +#define GSM322_NB_SYSINFO 5 /* sysinfo */ + +struct gsm48_sysinfo; +/* Cell selection process */ +struct gsm322_cellsel { + struct osmocom_ms *ms; + int state; /* GSM322_Cx_* */ + + struct llist_head event_queue; /* event messages */ + struct llist_head ba_list; /* BCCH Allocation per PLMN */ + struct gsm322_cs_list list[1024+299]; + /* cell selection list per frequency. */ + /* scan and tune state */ + struct osmo_timer_list timer; /* cell selection timer */ + uint16_t mcc, mnc; /* current network to search for */ + uint8_t powerscan; /* currently scanning for power */ + uint8_t ccch_state; /* special state of current ccch */ + uint32_t scan_state; /* special state of current scan */ + uint16_t arfcn; /* current tuned idle mode arfcn */ + int arfci; /* list index of frequency above */ + uint8_t ccch_mode; /* curren CCCH_MODE_* */ + uint8_t sync_retries; /* number retries to sync */ + uint8_t sync_pending; /* to prevent double sync req. */ + struct gsm48_sysinfo *si; /* current sysinfo of tuned cell */ + uint8_t tuned; /* if a cell is selected */ + struct osmo_timer_list any_timer; /* restart search 'any cell' */ + + /* serving cell */ + uint8_t selected; /* if a cell is selected */ + uint16_t sel_arfcn; /* current selected serving cell! */ + struct gsm48_sysinfo sel_si; /* copy of selected cell, will update */ + uint16_t sel_mcc, sel_mnc, sel_lac, sel_id; + + /* cell re-selection */ + struct llist_head nb_list; /* list of neighbour cells */ + uint16_t last_serving_arfcn; /* the ARFCN of last cell */ + uint8_t last_serving_valid; /* there is a last cell */ + struct gsm322_neighbour *neighbour; /* when selecting neighbour cell */ + time_t resel_when; /* timestamp of last re-selection */ + int8_t nb_meas_set; + int16_t rxlev_dbm; /* sum of received levels */ + uint8_t rxlev_count; /* number of received levels */ + int8_t rla_c_dbm; /* average of received level */ + uint8_t c12_valid; /* both C1 and C2 values are + calculated */ + int16_t c1, c2; + uint8_t prio_low; +}; + +/* GSM 03.22 message */ +struct gsm322_msg { + int msg_type; + uint16_t mcc, mnc; + uint8_t sysinfo; /* system information type */ + uint8_t same_cell; /* select same cell when RET_IDLE */ + uint8_t reject; /* location update reject cause */ + uint8_t limited; /* trigger search for limited serv. */ +}; + +#define GSM322_ALLOC_SIZE sizeof(struct gsm322_msg) +#define GSM322_ALLOC_HEADROOM 0 + +uint16_t index2arfcn(int index); +int arfcn2index(uint16_t arfcn); +int gsm322_init(struct osmocom_ms *ms); +int gsm322_exit(struct osmocom_ms *ms); +struct msgb *gsm322_msgb_alloc(int msg_type); +int gsm322_plmn_sendmsg(struct osmocom_ms *ms, struct msgb *msg); +int gsm322_cs_sendmsg(struct osmocom_ms *ms, struct msgb *msg); +int gsm322_c_event(struct osmocom_ms *ms, struct msgb *msg); +int gsm322_plmn_dequeue(struct osmocom_ms *ms); +int gsm322_cs_dequeue(struct osmocom_ms *ms); +int gsm322_add_forbidden_la(struct osmocom_ms *ms, uint16_t mcc, + uint16_t mnc, uint16_t lac, uint8_t cause); +int gsm322_del_forbidden_la(struct osmocom_ms *ms, uint16_t mcc, + uint16_t mnc, uint16_t lac); +int gsm322_is_forbidden_la(struct osmocom_ms *ms, uint16_t mcc, uint16_t mnc, + uint16_t lac); +int gsm322_dump_sorted_plmn(struct osmocom_ms *ms); +int gsm322_dump_cs_list(struct gsm322_cellsel *cs, uint8_t flags, + void (*print)(void *, const char *, ...), void *priv); +int gsm322_dump_forbidden_la(struct osmocom_ms *ms, + void (*print)(void *, const char *, ...), void *priv); +int gsm322_dump_ba_list(struct gsm322_cellsel *cs, uint16_t mcc, uint16_t mnc, + void (*print)(void *, const char *, ...), void *priv); +int gsm322_dump_nb_list(struct gsm322_cellsel *cs, + void (*print)(void *, const char *, ...), void *priv); +void start_cs_timer(struct gsm322_cellsel *cs, int sec, int micro); +void start_loss_timer(struct gsm322_cellsel *cs, int sec, int micro); +const char *get_a_state_name(int value); +const char *get_m_state_name(int value); +const char *get_cs_state_name(int value); +int gsm322_l1_signal(unsigned int subsys, unsigned int signal, + void *handler_data, void *signal_data); + +int gsm322_meas(struct osmocom_ms *ms, uint8_t rx_lev); + +char *gsm_print_rxlev(uint8_t rxlev); + + +#endif /* _GSM322_H */ diff --git a/Src/osmoconbb/src/host/layer23/include/osmocom/bb/mobile/gsm48_cc.h b/Src/osmoconbb/src/host/layer23/include/osmocom/bb/mobile/gsm48_cc.h new file mode 100644 index 0000000..8cdd1c4 --- /dev/null +++ b/Src/osmoconbb/src/host/layer23/include/osmocom/bb/mobile/gsm48_cc.h @@ -0,0 +1,17 @@ +#ifndef _GSM48_CC_H +#define _GSM48_CC_H + +struct gsm48_cclayer { + struct osmocom_ms *ms; + + struct llist_head mncc_upqueue; +}; + +int gsm48_cc_init(struct osmocom_ms *ms); +int gsm48_cc_exit(struct osmocom_ms *ms); +int gsm48_rcv_cc(struct osmocom_ms *ms, struct msgb *msg); +int mncc_dequeue(struct osmocom_ms *ms); +int mncc_send(struct osmocom_ms *ms, int msg_type, void *arg); + +#endif /* _GSM48_CC_H */ + diff --git a/Src/osmoconbb/src/host/layer23/include/osmocom/bb/mobile/gsm48_mm.h b/Src/osmoconbb/src/host/layer23/include/osmocom/bb/mobile/gsm48_mm.h new file mode 100644 index 0000000..afdcf02 --- /dev/null +++ b/Src/osmoconbb/src/host/layer23/include/osmocom/bb/mobile/gsm48_mm.h @@ -0,0 +1,230 @@ +#ifndef _GSM48_MM_H +#define _GSM48_MM_H + +/* GSM 04.07 9.2.2 */ +#define GSM48_MMXX_MASK 0xf00 +#define GSM48_MMCC_CLASS 0x100 +#define GSM48_MMSS_CLASS 0x200 +#define GSM48_MMSMS_CLASS 0x300 +#define GSM48_MMCC_EST_REQ 0x110 +#define GSM48_MMCC_EST_IND 0x112 +#define GSM48_MMCC_EST_CNF 0x111 +#define GSM48_MMCC_REL_REQ 0x120 +#define GSM48_MMCC_REL_IND 0x122 +#define GSM48_MMCC_DATA_REQ 0x130 +#define GSM48_MMCC_DATA_IND 0x132 +#define GSM48_MMCC_UNIT_DATA_REQ 0x140 +#define GSM48_MMCC_UNIT_DATA_IND 0x142 +#define GSM48_MMCC_SYNC_IND 0x152 +#define GSM48_MMCC_REEST_REQ 0x160 +#define GSM48_MMCC_REEST_CNF 0x161 +#define GSM48_MMCC_ERR_IND 0x172 +#define GSM48_MMCC_PROMPT_IND 0x182 +#define GSM48_MMCC_PROMPT_REJ 0x184 +#define GSM48_MMSS_EST_REQ 0x210 +#define GSM48_MMSS_EST_IND 0x212 +#define GSM48_MMSS_EST_CNF 0x211 +#define GSM48_MMSS_REL_REQ 0x220 +#define GSM48_MMSS_REL_IND 0x222 +#define GSM48_MMSS_DATA_REQ 0x230 +#define GSM48_MMSS_DATA_IND 0x232 +#define GSM48_MMSS_UNIT_DATA_REQ 0x240 +#define GSM48_MMSS_UNIT_DATA_IND 0x242 +#define GSM48_MMSS_REEST_REQ 0x260 +#define GSM48_MMSS_REEST_CNF 0x261 +#define GSM48_MMSS_ERR_IND 0x272 +#define GSM48_MMSS_PROMPT_IND 0x282 +#define GSM48_MMSS_PROMPT_REJ 0x284 +#define GSM48_MMSMS_EST_REQ 0x310 +#define GSM48_MMSMS_EST_IND 0x312 +#define GSM48_MMSMS_EST_CNF 0x311 +#define GSM48_MMSMS_REL_REQ 0x320 +#define GSM48_MMSMS_REL_IND 0x322 +#define GSM48_MMSMS_DATA_REQ 0x330 +#define GSM48_MMSMS_DATA_IND 0x332 +#define GSM48_MMSMS_UNIT_DATA_REQ 0x340 +#define GSM48_MMSMS_UNIT_DATA_IND 0x342 +#define GSM48_MMSMS_REEST_REQ 0x360 +#define GSM48_MMSMS_REEST_CNF 0x361 +#define GSM48_MMSMS_ERR_IND 0x372 +#define GSM48_MMSMS_PROMPT_IND 0x382 +#define GSM48_MMSMS_PROMPT_REJ 0x384 + +#define MMXX_ALLOC_SIZE 256 +#define MMXX_ALLOC_HEADROOM 64 + +/* MMxx-SAP header */ +struct gsm48_mmxx_hdr { + int msg_type; /* MMxx_* primitive */ + uint32_t ref; /* reference to transaction */ + uint32_t transaction_id; /* transaction identifier */ + uint8_t emergency; /* emergency type of call */ + uint8_t cause; /* cause used for release */ +}; + +/* GSM 6.1.2 */ +#define GSM48_MMR_REG_REQ 0x01 +#define GSM48_MMR_REG_CNF 0x02 +#define GSM48_MMR_NREG_REQ 0x03 +#define GSM48_MMR_NREG_IND 0x04 + +/* MMR-SAP header */ +struct gsm48_mmr { + int msg_type; + + uint8_t cause; +}; + +/* GSM 04.07 9.2.1 */ +#define GSM48_MMXX_ST_IDLE 0 +#define GSM48_MMXX_ST_CONN_PEND 1 +#define GSM48_MMXX_ST_DEDICATED 2 +#define GSM48_MMXX_ST_CONN_SUSP 3 +#define GSM48_MMXX_ST_REESTPEND 4 + +/* GSM 04.08 4.1.2.1 */ +#define GSM48_MM_ST_NULL 0 +#define GSM48_MM_ST_LOC_UPD_INIT 3 +#define GSM48_MM_ST_WAIT_OUT_MM_CONN 5 +#define GSM48_MM_ST_MM_CONN_ACTIVE 6 +#define GSM48_MM_ST_IMSI_DETACH_INIT 7 +#define GSM48_MM_ST_PROCESS_CM_SERV_P 8 +#define GSM48_MM_ST_WAIT_NETWORK_CMD 9 +#define GSM48_MM_ST_LOC_UPD_REJ 10 +#define GSM48_MM_ST_WAIT_RR_CONN_LUPD 13 +#define GSM48_MM_ST_WAIT_RR_CONN_MM_CON 14 +#define GSM48_MM_ST_WAIT_RR_CONN_IMSI_D 15 +#define GSM48_MM_ST_WAIT_REEST 17 +#define GSM48_MM_ST_WAIT_RR_ACTIVE 18 +#define GSM48_MM_ST_MM_IDLE 19 +#define GSM48_MM_ST_WAIT_ADD_OUT_MM_CON 20 +#define GSM48_MM_ST_MM_CONN_ACTIVE_VGCS 21 +#define GSM48_MM_ST_WAIT_RR_CONN_VGCS 22 +#define GSM48_MM_ST_LOC_UPD_PEND 23 +#define GSM48_MM_ST_IMSI_DETACH_PEND 24 +#define GSM48_MM_ST_RR_CONN_RELEASE_NA 25 + +/* GSM 04.08 4.1.2.1 */ +#define GSM48_MM_SST_NORMAL_SERVICE 1 +#define GSM48_MM_SST_ATTEMPT_UPDATE 2 +#define GSM48_MM_SST_LIMITED_SERVICE 3 +#define GSM48_MM_SST_NO_IMSI 4 +#define GSM48_MM_SST_NO_CELL_AVAIL 5 +#define GSM48_MM_SST_LOC_UPD_NEEDED 6 +#define GSM48_MM_SST_PLMN_SEARCH 7 +#define GSM48_MM_SST_PLMN_SEARCH_NORMAL 8 +#define GSM48_MM_SST_RX_VGCS_NORMAL 9 +#define GSM48_MM_SST_RX_VGCS_LIMITED 10 + +/* MM events */ +#define GSM48_MM_EVENT_CELL_SELECTED 1 +#define GSM48_MM_EVENT_NO_CELL_FOUND 2 +#define GSM48_MM_EVENT_TIMEOUT_T3210 3 +#define GSM48_MM_EVENT_TIMEOUT_T3211 4 +#define GSM48_MM_EVENT_TIMEOUT_T3212 5 +#define GSM48_MM_EVENT_TIMEOUT_T3213 6 +#define GSM48_MM_EVENT_TIMEOUT_T3220 7 +#define GSM48_MM_EVENT_TIMEOUT_T3230 8 +#define GSM48_MM_EVENT_TIMEOUT_T3240 9 +#define GSM48_MM_EVENT_IMSI_DETACH 10 +#define GSM48_MM_EVENT_POWER_OFF 11 +#define GSM48_MM_EVENT_PAGING 12 +#define GSM48_MM_EVENT_AUTH_RESPONSE 13 +#define GSM48_MM_EVENT_SYSINFO 14 +#define GSM48_MM_EVENT_USER_PLMN_SEL 15 +#define GSM48_MM_EVENT_LOST_COVERAGE 16 + +/* message for MM events */ +struct gsm48_mm_event { + uint32_t msg_type; + + uint8_t sres[4]; +}; + +/* GSM 04.08 MM timers */ +#define GSM_T3210_MS 20, 0 +#define GSM_T3211_MS 15, 0 +/* T3212 is given by SYSTEM INFORMATION */ +#define GSM_T3213_MS 4, 0 +#define GSM_T3220_MS 5, 0 +#define GSM_T3230_MS 15, 0 +#define GSM_T3240_MS 10, 0 +#define GSM_T3241_MS 300, 0 + +/* MM sublayer instance */ +struct gsm48_mmlayer { + struct osmocom_ms *ms; + int state; + int substate; + + /* queue for RR-SAP, MMxx-SAP, MMR-SAP, events message upwards */ + struct llist_head rr_upqueue; + struct llist_head mmxx_upqueue; + struct llist_head mmr_downqueue; + struct llist_head event_queue; + + /* timers */ + struct osmo_timer_list t3210, t3211, t3212, t3213; + struct osmo_timer_list t3220, t3230, t3240; + int t3212_value; + int start_t3211; /* remember to start timer */ + + /* list of MM connections */ + struct llist_head mm_conn; + + /* network name */ + char name_short[32]; + char name_long[32]; + + /* location update */ + uint8_t lupd_pending; /* current pending loc. upd. */ + uint8_t lupd_type; /* current coded type */ + uint8_t lupd_attempt; /* attempt counter */ + uint8_t lupd_ra_failure;/* random access failed */ + uint8_t lupd_rej_cause; /* cause of last reject */ + uint8_t lupd_periodic; /* periodic update pending */ + uint8_t lupd_retry; /* pending T3211/T3213 to */ + uint16_t lupd_mcc, lupd_mnc, lupd_lac; + + /* imsi detach */ + uint8_t delay_detach; /* do detach when possible */ + + /* other */ + uint8_t est_cause; /* cause of establishment msg */ + int mr_substate; /* rem most recent substate */ + uint8_t power_off_idle; /* waits for IDLE before po */ +}; + +/* MM connection entry */ +struct gsm48_mm_conn { + struct llist_head list; + struct gsm48_mmlayer *mm; + + /* ref and type form a unique tupple */ + uint32_t ref; /* reference to trans */ + uint8_t protocol; + uint8_t transaction_id; + + int state; +}; + +uint8_t gsm48_current_pwr_lev(struct gsm_settings *set, uint16_t arfcn); +int gsm48_mm_init(struct osmocom_ms *ms); +int gsm48_mm_exit(struct osmocom_ms *ms); +struct msgb *gsm48_mmr_msgb_alloc(int msg_type); +struct msgb *gsm48_mmevent_msgb_alloc(int msg_type); +int gsm48_mmevent_msg(struct osmocom_ms *ms, struct msgb *msg); +int gsm48_mmr_downmsg(struct osmocom_ms *ms, struct msgb *msg); +int gsm48_rr_dequeue(struct osmocom_ms *ms); +int gsm48_mmxx_dequeue(struct osmocom_ms *ms); +int gsm48_mmr_dequeue(struct osmocom_ms *ms); +int gsm48_mmevent_dequeue(struct osmocom_ms *ms); +int gsm48_mmxx_downmsg(struct osmocom_ms *ms, struct msgb *msg); +struct msgb *gsm48_mmxx_msgb_alloc(int msg_type, uint32_t ref, + uint8_t transaction_id); +const char *get_mmr_name(int value); +const char *get_mmxx_name(int value); +extern const char *gsm48_mm_state_names[]; +extern const char *gsm48_mm_substate_names[]; + +#endif /* _GSM48_MM_H */ diff --git a/Src/osmoconbb/src/host/layer23/include/osmocom/bb/mobile/gsm48_rr.h b/Src/osmoconbb/src/host/layer23/include/osmocom/bb/mobile/gsm48_rr.h new file mode 100644 index 0000000..1af09f4 --- /dev/null +++ b/Src/osmoconbb/src/host/layer23/include/osmocom/bb/mobile/gsm48_rr.h @@ -0,0 +1,203 @@ +#ifndef _GSM48_RR_H +#define _GSM48_RR_H + +#include + +#define GSM_TA_CM 55385 + +/* GSM 04.07 9.1.2 */ +#define GSM48_RR_EST_REQ 0x10 +#define GSM48_RR_EST_IND 0x12 +#define GSM48_RR_EST_CNF 0x11 +#define GSM48_RR_REL_IND 0x22 +#define GSM48_RR_SYNC_IND 0x32 +#define GSM48_RR_DATA_REQ 0x40 +#define GSM48_RR_DATA_IND 0x42 +#define GSM48_RR_UNIT_DATA_IND 0x52 +#define GSM48_RR_ABORT_REQ 0x60 +#define GSM48_RR_ABORT_IND 0x62 +#define GSM48_RR_ACT_REQ 0x70 + +#define RR_EST_CAUSE_EMERGENCY 1 +#define RR_EST_CAUSE_REESTAB_TCH_F 2 +#define RR_EST_CAUSE_REESTAB_TCH_H 3 +#define RR_EST_CAUSE_REESTAB_2_TCH_H 4 +#define RR_EST_CAUSE_ANS_PAG_ANY 5 +#define RR_EST_CAUSE_ANS_PAG_SDCCH 6 +#define RR_EST_CAUSE_ANS_PAG_TCH_F 7 +#define RR_EST_CAUSE_ANS_PAG_TCH_ANY 8 +#define RR_EST_CAUSE_ORIG_TCHF 9 +#define RR_EST_CAUSE_LOC_UPD 12 +#define RR_EST_CAUSE_OTHER_SDCCH 13 + +#define RR_REL_CAUSE_UNDEFINED 0 +#define RR_REL_CAUSE_NORMAL 1 +#define RR_REL_CAUSE_NOT_AUTHORIZED 2 +#define RR_REL_CAUSE_RA_FAILURE 3 +#define RR_REL_CAUSE_T3122 4 +#define RR_REL_CAUSE_TRY_LATER 5 +#define RR_REL_CAUSE_EMERGENCY_ONLY 6 +#define RR_REL_CAUSE_LOST_SIGNAL 7 +#define RR_REL_CAUSE_LINK_FAILURE 8 + +#define RR_SYNC_CAUSE_CIPHERING 1 + +#define L3_ALLOC_SIZE 256 +#define L3_ALLOC_HEADROOM 64 + +#define RSL_ALLOC_SIZE 256 +#define RSL_ALLOC_HEADROOM 64 + +#define RR_ALLOC_SIZE 256 +#define RR_ALLOC_HEADROOM 64 + +/* GSM 04.08 RR-SAP header */ +struct gsm48_rr_hdr { + uint32_t msg_type; /* RR-* primitive */ + uint8_t cause; +}; + +/* GSM 04.07 9.1.1 */ +#define GSM48_RR_ST_IDLE 0 +#define GSM48_RR_ST_CONN_PEND 1 +#define GSM48_RR_ST_DEDICATED 2 +#define GSM48_RR_ST_REL_PEND 3 + +/* modify state */ +#define GSM48_RR_MOD_NONE 0 +#define GSM48_RR_MOD_IMM_ASS 1 +#define GSM48_RR_MOD_ASSIGN 2 +#define GSM48_RR_MOD_HANDO 3 +#define GSM48_RR_MOD_ASSIGN_RESUME 4 +#define GSM48_RR_MOD_HANDO_RESUME 5 + +/* channel description */ +struct gsm48_rr_cd { + uint8_t tsc; + uint8_t h; /* using hopping */ + uint16_t arfcn; /* dedicated mode */ + uint8_t maio; + uint8_t hsn; + uint8_t chan_nr; /* type, slot, sub slot */ + uint8_t link_id; + uint8_t ind_tx_power; /* last indicated power */ + uint8_t ind_ta; /* last indicated ta */ + uint8_t mob_alloc_lv[9]; /* len + up to 64 bits */ + uint8_t freq_list_lv[131]; /* len + 130 octets */ + uint8_t freq_seq_lv[10]; /* len + 9 octets */ + uint8_t cell_desc_lv[17]; /* len + 16 octets */ + uint8_t start; /* start time available */ + struct gsm_time start_tm; /* start time */ + uint8_t mode; /* mode of channel */ + uint8_t cipher; /* ciphering of channel */ +}; + +struct gsm48_cr_hist { + uint8_t valid; + struct gsm48_req_ref ref; +}; + +/* neighbor cell measurements */ +struct gsm48_rr_meas { + /* note: must be sorted by arfcn 1..1023,0 according to SI5* */ + uint8_t nc_num; /* number of measured cells (32 max) */ + int8_t nc_rxlev[32]; /* -128 = no value */ + uint8_t nc_bsic[32]; + uint16_t nc_arfcn[32]; +}; + +/* RR sublayer instance */ +struct gsm48_rrlayer { + struct osmocom_ms *ms; + int state; + + /* queue for RSL-SAP message upwards */ + struct llist_head rsl_upqueue; + + /* queue for messages while RR connection is built up */ + struct llist_head downqueue; + + /* timers */ + struct osmo_timer_list t_starting; /* starting time for chan. access */ + struct osmo_timer_list t_rel_wait; /* wait for L2 to transmit UA */ + struct osmo_timer_list t3110; + struct osmo_timer_list t3122; + struct osmo_timer_list t3124; + struct osmo_timer_list t3126; + int t3126_value; +#ifndef TODO + struct osmo_timer_list temp_rach_ti; /* temporary timer */ +#endif + + /* states if RR-EST-REQ was used */ + uint8_t rr_est_req; + struct msgb *rr_est_msg; + uint8_t est_cause; /* cause used for establishment */ + + /* channel request states */ + uint8_t wait_assign; /* waiting for assignment state */ + uint8_t n_chan_req; /* number left, incl. current */ + uint8_t chan_req_val; /* current request value */ + uint8_t chan_req_mask; /* mask of random bits */ + + /* state of dedicated mdoe */ + uint8_t dm_est; + + /* cr_hist */ + uint8_t cr_ra; /* stores requested ra until confirmed */ + struct gsm48_cr_hist cr_hist[3]; + + /* V(SD) sequence numbers */ + uint16_t v_sd; /* 16 PD 1-bit sequence numbers packed */ + + /* current channel descriptions */ + struct gsm48_rr_cd cd_now; + + /* current cipering */ + uint8_t cipher_on; + uint8_t cipher_type; /* 10.5.2.9 */ + + /* special states when assigning channel */ + uint8_t modify_state; + uint8_t hando_sync_ind, hando_rot, hando_nci, hando_act; + struct gsm48_rr_cd cd_last; /* store last cd in case of failure */ + struct gsm48_rr_cd cd_before; /* before start time */ + struct gsm48_rr_cd cd_after; /* after start time */ + + /* BA range */ + uint8_t ba_ranges; + uint32_t ba_range[16]; + + /* measurements */ + struct osmo_timer_list t_meas; + struct gsm48_rr_meas meas; + uint8_t monitor; + + /* audio flow */ + uint8_t audio_mode; +}; + +const char *get_rr_name(int value); +extern int gsm48_rr_init(struct osmocom_ms *ms); +extern int gsm48_rr_exit(struct osmocom_ms *ms); +int gsm48_rsl_dequeue(struct osmocom_ms *ms); +int gsm48_rr_downmsg(struct osmocom_ms *ms, struct msgb *msg); +struct msgb *gsm48_l3_msgb_alloc(void); +struct msgb *gsm48_rr_msgb_alloc(int msg_type); +int gsm48_decode_lai(struct gsm48_loc_area_id *lai, uint16_t *mcc, + uint16_t *mnc, uint16_t *lac); +int gsm48_encode_lai(struct gsm48_loc_area_id *lai, uint16_t mcc, + uint16_t mnc, uint16_t lac); +int gsm48_rr_enc_cm2(struct osmocom_ms *ms, struct gsm48_classmark2 *cm, + uint16_t arfcn); +int gsm48_rr_tx_rand_acc(struct osmocom_ms *ms, struct msgb *msg); +int gsm48_rr_los(struct osmocom_ms *ms); +int gsm48_rr_rach_conf(struct osmocom_ms *ms, uint32_t fn); +extern const char *gsm48_rr_state_names[]; +int gsm48_rr_start_monitor(struct osmocom_ms *ms); +int gsm48_rr_stop_monitor(struct osmocom_ms *ms); +int gsm48_rr_alter_delay(struct osmocom_ms *ms); +int gsm48_rr_tx_voice(struct osmocom_ms *ms, struct msgb *msg); +int gsm48_rr_audio_mode(struct osmocom_ms *ms, uint8_t mode); + +#endif /* _GSM48_RR_H */ diff --git a/Src/osmoconbb/src/host/layer23/include/osmocom/bb/mobile/mncc.h b/Src/osmoconbb/src/host/layer23/include/osmocom/bb/mobile/mncc.h new file mode 100644 index 0000000..a2b48cf --- /dev/null +++ b/Src/osmoconbb/src/host/layer23/include/osmocom/bb/mobile/mncc.h @@ -0,0 +1,181 @@ +/* GSM Mobile Radio Interface Layer 3 messages on the A-bis interface + * 3GPP TS 04.08 version 7.21.0 Release 1998 / ETSI TS 100 940 V7.21.0 */ + +/* (C) 2008-2009 by Harald Welte + * (C) 2008, 2009 by Holger Hans Peter Freyther + * (C) 2009 by Andreas Eversberg + * + * 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 _MNCC_H +#define _MNCC_H + +#include +#include + +struct gsm_call { + struct llist_head entry; + + struct osmocom_ms *ms; + + uint32_t callref; + + uint8_t init; /* call initiated, no response yet */ + uint8_t hold; /* call on hold */ + uint8_t ring; /* call ringing/knocking */ + + struct osmo_timer_list dtmf_timer; + uint8_t dtmf_state; + uint8_t dtmf_index; + char dtmf[32]; /* dtmf sequence */ +}; + +#define DTMF_ST_IDLE 0 /* no DTMF active */ +#define DTMF_ST_START 1 /* DTMF started, waiting for resp. */ +#define DTMF_ST_MARK 2 /* wait tone duration */ +#define DTMF_ST_STOP 3 /* DTMF stopped, waiting for resp. */ +#define DTMF_ST_SPACE 4 /* wait space between tones */ + +#define MNCC_SETUP_REQ 0x0101 +#define MNCC_SETUP_IND 0x0102 +#define MNCC_SETUP_RSP 0x0103 +#define MNCC_SETUP_CNF 0x0104 +#define MNCC_SETUP_COMPL_REQ 0x0105 +#define MNCC_SETUP_COMPL_IND 0x0106 +/* MNCC_REJ_* is perfomed via MNCC_REL_* */ +#define MNCC_CALL_CONF_IND 0x0107 +#define MNCC_CALL_PROC_REQ 0x0108 +#define MNCC_PROGRESS_REQ 0x0109 +#define MNCC_ALERT_REQ 0x010a +#define MNCC_ALERT_IND 0x010b +#define MNCC_NOTIFY_REQ 0x010c +#define MNCC_NOTIFY_IND 0x010d +#define MNCC_DISC_REQ 0x010e +#define MNCC_DISC_IND 0x010f +#define MNCC_REL_REQ 0x0110 +#define MNCC_REL_IND 0x0111 +#define MNCC_REL_CNF 0x0112 +#define MNCC_FACILITY_REQ 0x0113 +#define MNCC_FACILITY_IND 0x0114 +#define MNCC_START_DTMF_IND 0x0115 +#define MNCC_START_DTMF_RSP 0x0116 +#define MNCC_START_DTMF_REJ 0x0117 +#define MNCC_STOP_DTMF_IND 0x0118 +#define MNCC_STOP_DTMF_RSP 0x0119 +#define MNCC_MODIFY_REQ 0x011a +#define MNCC_MODIFY_IND 0x011b +#define MNCC_MODIFY_RSP 0x011c +#define MNCC_MODIFY_CNF 0x011d +#define MNCC_MODIFY_REJ 0x011e +#define MNCC_HOLD_IND 0x011f +#define MNCC_HOLD_CNF 0x0120 +#define MNCC_HOLD_REJ 0x0121 +#define MNCC_RETRIEVE_IND 0x0122 +#define MNCC_RETRIEVE_CNF 0x0123 +#define MNCC_RETRIEVE_REJ 0x0124 +#define MNCC_USERINFO_REQ 0x0125 +#define MNCC_USERINFO_IND 0x0126 +#define MNCC_REJ_REQ 0x0127 +#define MNCC_REJ_IND 0x0128 +#define MNCC_PROGRESS_IND 0x0129 +#define MNCC_CALL_PROC_IND 0x012a +#define MNCC_CALL_CONF_REQ 0x012b +#define MNCC_START_DTMF_REQ 0x012c +#define MNCC_STOP_DTMF_REQ 0x012d +#define MNCC_HOLD_REQ 0x012e +#define MNCC_RETRIEVE_REQ 0x012f + +#define MNCC_BRIDGE 0x0200 +#define MNCC_FRAME_RECV 0x0201 +#define MNCC_FRAME_DROP 0x0202 +#define MNCC_LCHAN_MODIFY 0x0203 + +#define GSM_TCHF_FRAME 0x0300 +#define GSM_TCHF_FRAME_EFR 0x0301 + +#define MS_NEW 0x0400 +#define MS_DELETE 0x0401 + +#define GSM_MAX_FACILITY 128 +#define GSM_MAX_SSVERSION 128 +#define GSM_MAX_USERUSER 128 + +#define MNCC_F_BEARER_CAP 0x0001 +#define MNCC_F_CALLED 0x0002 +#define MNCC_F_CALLING 0x0004 +#define MNCC_F_REDIRECTING 0x0008 +#define MNCC_F_CONNECTED 0x0010 +#define MNCC_F_CAUSE 0x0020 +#define MNCC_F_USERUSER 0x0040 +#define MNCC_F_PROGRESS 0x0080 +#define MNCC_F_EMERGENCY 0x0100 +#define MNCC_F_FACILITY 0x0200 +#define MNCC_F_SSVERSION 0x0400 +#define MNCC_F_CCCAP 0x0800 +#define MNCC_F_KEYPAD 0x1000 +#define MNCC_F_SIGNAL 0x2000 + +struct gsm_mncc { + /* context based information */ + u_int32_t msg_type; + u_int32_t callref; + + /* which fields are present */ + u_int32_t fields; + + /* data derived informations (MNCC_F_ based) */ + struct gsm_mncc_bearer_cap bearer_cap; + struct gsm_mncc_number called; + struct gsm_mncc_number calling; + struct gsm_mncc_number redirecting; + struct gsm_mncc_number connected; + struct gsm_mncc_cause cause; + struct gsm_mncc_progress progress; + struct gsm_mncc_useruser useruser; + struct gsm_mncc_facility facility; + struct gsm_mncc_cccap cccap; + struct gsm_mncc_ssversion ssversion; + struct { + int sup; + int inv; + } clir; + int signal; + + /* data derived information, not MNCC_F based */ + int keypad; + int more; + int notify; /* 0..127 */ + int emergency; + char imsi[16]; + + unsigned char lchan_mode; +}; + +struct gsm_data_frame { + u_int32_t msg_type; + u_int32_t callref; + unsigned char data[0]; +}; + +const char *get_mncc_name(int value); +int mncc_recv(struct osmocom_ms *ms, int msg_type, void *arg); +void mncc_set_cause(struct gsm_mncc *data, int loc, int val); + +#endif + diff --git a/Src/osmoconbb/src/host/layer23/include/osmocom/bb/mobile/settings.h b/Src/osmoconbb/src/host/layer23/include/osmocom/bb/mobile/settings.h new file mode 100644 index 0000000..cd1b800 --- /dev/null +++ b/Src/osmoconbb/src/host/layer23/include/osmocom/bb/mobile/settings.h @@ -0,0 +1,120 @@ +#ifndef _settings_h +#define _settings_h + +/* type of test SIM key */ +enum { + GSM_SIM_KEY_XOR = 0, + GSM_SIM_KEY_COMP128 +}; + +struct gsm_settings { + char layer2_socket_path[128]; + char sap_socket_path[128]; + + /* IMEI */ + char imei[16]; + char imeisv[17]; + char imei_random; + + /* network search */ + int plmn_mode; /* PLMN_MODE_* */ + + /* SIM */ + int sim_type; /* selects card on power on */ + char emergency_imsi[16]; + + /* test card simulator settings */ + char test_imsi[16]; + uint32_t test_tmsi; + uint8_t test_ki_type; + uint8_t test_ki[16]; /* 128 bit max */ + uint8_t test_barr; + uint8_t test_rplmn_valid; + uint16_t test_rplmn_mcc, test_rplmn_mnc; + uint16_t test_lac; + uint8_t test_always; /* ...search hplmn... */ + + /* call related settings */ + uint8_t cw; /* set if call-waiting is allowed */ + uint8_t auto_answer; + uint8_t clip, clir; + uint8_t half, half_prefer; + + /* changing default behavior */ + uint8_t alter_tx_power; + uint8_t alter_tx_power_value; + int8_t alter_delay; + uint8_t stick; + uint16_t stick_arfcn; + uint8_t skip_max_per_band; + uint8_t no_lupd; + uint8_t no_neighbour; + + /* supported by configuration */ + uint8_t cc_dtmf; + uint8_t sms_ptp; + uint8_t a5_1; + uint8_t a5_2; + uint8_t a5_3; + uint8_t a5_4; + uint8_t a5_5; + uint8_t a5_6; + uint8_t a5_7; + uint8_t p_gsm; + uint8_t e_gsm; + uint8_t r_gsm; + uint8_t dcs; + uint8_t gsm_850; + uint8_t pcs; + uint8_t gsm_480; + uint8_t gsm_450; + uint8_t class_900; + uint8_t class_dcs; + uint8_t class_850; + uint8_t class_pcs; + uint8_t class_400; + uint8_t freq_map[128+38]; + uint8_t full_v1; + uint8_t full_v2; + uint8_t full_v3; + uint8_t half_v1; + uint8_t half_v3; + uint8_t ch_cap; /* channel capability */ + int8_t min_rxlev_db; /* min DB to access */ + + /* radio */ + uint16_t dsc_max; + + /* dialing */ + struct llist_head abbrev; + + /* EDGE / UMTS / CDMA */ + uint8_t edge_ms_sup; + uint8_t edge_psk_sup; + uint8_t edge_psk_uplink; + uint8_t class_900_edge; + uint8_t class_dcs_pcs_edge; + uint8_t umts_fdd; + uint8_t umts_tdd; + uint8_t cdma_2000; + uint8_t dtm; + uint8_t class_dtm; + uint8_t dtm_mac; + uint8_t dtm_egprs; +}; + +struct gsm_settings_abbrev { + struct llist_head list; + char abbrev[4]; + char number[32]; + char name[32]; +}; + +int gsm_settings_arfcn(struct osmocom_ms *ms); +int gsm_settings_init(struct osmocom_ms *ms); +int gsm_settings_exit(struct osmocom_ms *ms); +char *gsm_check_imei(const char *imei, const char *sv); +int gsm_random_imei(struct gsm_settings *set); + +#endif /* _settings_h */ + diff --git a/Src/osmoconbb/src/host/layer23/include/osmocom/bb/mobile/subscriber.h b/Src/osmoconbb/src/host/layer23/include/osmocom/bb/mobile/subscriber.h new file mode 100644 index 0000000..cc0cfac --- /dev/null +++ b/Src/osmoconbb/src/host/layer23/include/osmocom/bb/mobile/subscriber.h @@ -0,0 +1,107 @@ +#ifndef _SUBSCRIBER_H +#define _SUBSCRIBER_H + +/* GSM 04.08 4.1.2.2 SIM update status */ +#define GSM_SIM_U0_NULL 0 +#define GSM_SIM_U1_UPDATED 1 +#define GSM_SIM_U2_NOT_UPDATED 2 +#define GSM_SIM_U3_ROAMING_NA 3 + +struct gsm_sub_plmn_list { + struct llist_head entry; + uint16_t mcc, mnc; +}; + +struct gsm_sub_plmn_na { + struct llist_head entry; + uint16_t mcc, mnc; + uint8_t cause; +}; + +#define GSM_IMSI_LENGTH 16 + +enum { + GSM_SIM_TYPE_NONE = 0, + GSM_SIM_TYPE_READER, + GSM_SIM_TYPE_TEST +}; + +struct gsm_subscriber { + struct osmocom_ms *ms; + + /* status */ + uint8_t sim_type; /* type of sim */ + uint8_t sim_valid; /* sim inserted and valid */ + uint8_t ustate; /* update status */ + uint8_t imsi_attached; /* attached state */ + + /* IMSI & co */ + char imsi[GSM_IMSI_LENGTH]; + char msisdn[31]; /* may include access codes */ + char iccid[21]; /* 20 + termination */ + + /* TMSI / LAI */ + uint32_t tmsi; /* invalid tmsi: 0xffffffff */ + uint16_t mcc, mnc, lac; /* invalid lac: 0x0000 */ + + + /* key */ + uint8_t key_seq; /* ciphering key sequence number */ + uint8_t key[8]; /* 64 bit */ + + /* other */ + struct llist_head plmn_list; /* PLMN Selector field */ + struct llist_head plmn_na; /* not allowed PLMNs */ + uint8_t t6m_hplmn; /* timer for hplmn search */ + + /* special things */ + uint8_t always_search_hplmn; + /* search hplmn in other countries also (for test cards) */ + uint8_t any_timeout; + /* timer to restart 'any cell selection' */ + char sim_name[31]; /* name to load/save sim */ + char sim_spn[17]; /* name of service privider */ + + /* PLMN last registered */ + uint8_t plmn_valid; + uint16_t plmn_mcc, plmn_mnc; + + /* our access */ + uint8_t acc_barr; /* if we may access, if cell barred */ + uint16_t acc_class; /* bitmask of what we may access */ + + /* talk to SIM */ + uint8_t sim_state; + uint8_t sim_pin_required; /* state: wait for PIN */ + uint8_t sim_file_index; + uint32_t sim_handle_query; + uint32_t sim_handle_update; + uint32_t sim_handle_key; +}; + +int gsm_subscr_init(struct osmocom_ms *ms); +int gsm_subscr_exit(struct osmocom_ms *ms); +int gsm_subscr_testcard(struct osmocom_ms *ms, uint16_t mcc, uint16_t mnc, + uint16_t lac, uint32_t tmsi); +int gsm_subscr_simcard(struct osmocom_ms *ms); +void gsm_subscr_sim_pin(struct osmocom_ms *ms, char *pin1, char *pin2, + int8_t mode); +int gsm_subscr_write_loci(struct osmocom_ms *ms); +int gsm_subscr_generate_kc(struct osmocom_ms *ms, uint8_t key_seq, + uint8_t *rand, uint8_t no_sim); +int gsm_subscr_remove(struct osmocom_ms *ms); +void new_sim_ustate(struct gsm_subscriber *subscr, int state); +int gsm_subscr_del_forbidden_plmn(struct gsm_subscriber *subscr, uint16_t mcc, + uint16_t mnc); +int gsm_subscr_add_forbidden_plmn(struct gsm_subscriber *subscr, uint16_t mcc, + uint16_t mnc, uint8_t cause); +int gsm_subscr_is_forbidden_plmn(struct gsm_subscriber *subscr, uint16_t mcc, + uint16_t mnc); +int gsm_subscr_dump_forbidden_plmn(struct osmocom_ms *ms, + void (*print)(void *, const char *, ...), void *priv); +void gsm_subscr_dump(struct gsm_subscriber *subscr, + void (*print)(void *, const char *, ...), void *priv); +char *gsm_check_imsi(const char *imsi); + +#endif /* _SUBSCRIBER_H */ + diff --git a/Src/osmoconbb/src/host/layer23/include/osmocom/bb/mobile/support.h b/Src/osmoconbb/src/host/layer23/include/osmocom/bb/mobile/support.h new file mode 100644 index 0000000..035e10a --- /dev/null +++ b/Src/osmoconbb/src/host/layer23/include/osmocom/bb/mobile/support.h @@ -0,0 +1,122 @@ +#ifndef _SUPPORT_H +#define _SUPPORT_H + +#define GSM_CIPHER_A5_1 0 +#define GSM_CIPHER_A5_2 1 +#define GSM_CIPHER_A5_3 2 +#define GSM_CIPHER_A5_4 3 +#define GSM_CIPHER_A5_5 4 +#define GSM_CIPHER_A5_6 5 +#define GSM_CIPHER_A5_7 6 +#define GSM_CIPHER_RESERVED 7 + +#define GSM_CAP_SDCCH 0 +#define GSM_CAP_SDCCH_TCHF 1 +#define GSM_CAP_SDCCH_TCHF_TCHH 2 + +struct gsm_support { + struct osmocom_ms *ms; + + /* controlled early classmark sending */ + uint8_t es_ind; + /* revision level */ + uint8_t rev_lev; + /* support of VGCS */ + uint8_t vgcs; + /* support of VBS */ + uint8_t vbs; + /* support of SMS */ + uint8_t sms_ptp; + /* screening indicator */ + uint8_t ss_ind; + /* pseudo synchronised capability */ + uint8_t ps_cap; + /* CM service prompt */ + uint8_t cmsp; + /* solsa support */ + uint8_t solsa; + /* location service support */ + uint8_t lcsva; + /* codec supprot */ + uint8_t a5_1; + uint8_t a5_2; + uint8_t a5_3; + uint8_t a5_4; + uint8_t a5_5; + uint8_t a5_6; + uint8_t a5_7; + /* radio support */ + uint8_t p_gsm; + uint8_t e_gsm; + uint8_t r_gsm; + uint8_t dcs; + uint8_t gsm_850; + uint8_t pcs; + uint8_t gsm_480; + uint8_t gsm_450; + uint8_t class_900; + uint8_t class_dcs; + uint8_t class_850; + uint8_t class_pcs; + uint8_t class_400; + /* multi slot support */ + uint8_t ms_sup; + /* ucs2 treatment */ + uint8_t ucs2_treat; + /* support extended measurements */ + uint8_t ext_meas; + /* support switched measurement capability */ + uint8_t meas_cap; + uint8_t sms_val; + uint8_t sm_val; + /* positioning method capability */ + uint8_t loc_serv; + uint8_t e_otd_ass; + uint8_t e_otd_based; + uint8_t gps_ass; + uint8_t gps_based; + uint8_t gps_conv; + + /* radio */ + uint8_t ch_cap; /* channel capability */ + int8_t min_rxlev_db; + uint8_t scan_to; + uint8_t sync_to; + uint16_t dsc_max; /* maximum dl signal failure counter */ + + /* codecs */ + uint8_t full_v1; + uint8_t full_v2; + uint8_t full_v3; + uint8_t half_v1; + uint8_t half_v3; + + /* EDGE / UMTS / CDMA */ + uint8_t edge_ms_sup; + uint8_t edge_psk_sup; + uint8_t edge_psk_uplink; + uint8_t class_900_edge; + uint8_t class_dcs_pcs_edge; + uint8_t umts_fdd; + uint8_t umts_tdd; + uint8_t cdma_2000; + uint8_t dtm; + uint8_t class_dtm; + uint8_t dtm_mac; + uint8_t dtm_egprs; +}; + +struct gsm_support_scan_max { + uint16_t start; + uint16_t end; + uint16_t max; + uint16_t temp; +}; +extern struct gsm_support_scan_max gsm_sup_smax[]; + +void gsm_support_init(struct osmocom_ms *ms); +void gsm_support_dump(struct osmocom_ms *ms, + void (*print)(void *, const char *, ...), void *priv); + +#endif /* _SUPPORT_H */ + diff --git a/Src/osmoconbb/src/host/layer23/include/osmocom/bb/mobile/transaction.h b/Src/osmoconbb/src/host/layer23/include/osmocom/bb/mobile/transaction.h new file mode 100644 index 0000000..aa62f46 --- /dev/null +++ b/Src/osmoconbb/src/host/layer23/include/osmocom/bb/mobile/transaction.h @@ -0,0 +1,71 @@ +#ifndef _TRANSACT_H +#define _TRANSACT_H + +#include + +/* One transaction */ +struct gsm_trans { + /* Entry in list of all transactions */ + struct llist_head entry; + + /* The protocol within which we live */ + uint8_t protocol; + + /* The current transaction ID */ + uint8_t transaction_id; + + /* To whom we belong */ + struct osmocom_ms *ms; + + /* reference from MNCC or other application */ + uint32_t callref; + + /* if traffic channel receive was requested */ + int tch_recv; + + union { + struct { + + /* current call state */ + int state; + + /* most recent progress indicator */ + uint8_t prog_ind; + + /* current timer and message queue */ + int Tcurrent; /* current CC timer */ + int T308_second; /* used to send release again */ + struct osmo_timer_list timer; + struct gsm_mncc msg; /* stores setup/disconnect/release message */ + } cc; +#if 0 + struct { + uint8_t link_id; /* RSL Link ID to be used for this trans */ + int is_mt; /* is this a MO (0) or MT (1) transfer */ + enum gsm411_cp_state cp_state; + struct osmo_timer_list cp_timer; + + enum gsm411_rp_state rp_state; + + struct gsm_sms *sms; + } sms; +#endif + }; +}; + + + +struct gsm_trans *trans_find_by_id(struct osmocom_ms *ms, + uint8_t proto, uint8_t trans_id); +struct gsm_trans *trans_find_by_callref(struct osmocom_ms *ms, + uint32_t callref); + +struct gsm_trans *trans_alloc(struct osmocom_ms *ms, + uint8_t protocol, uint8_t trans_id, + uint32_t callref); +void trans_free(struct gsm_trans *trans); + +int trans_assign_trans_id(struct osmocom_ms *ms, + uint8_t protocol, uint8_t ti_flag); + +#endif diff --git a/Src/osmoconbb/src/host/layer23/include/osmocom/bb/mobile/voice.h b/Src/osmoconbb/src/host/layer23/include/osmocom/bb/mobile/voice.h new file mode 100644 index 0000000..a052418 --- /dev/null +++ b/Src/osmoconbb/src/host/layer23/include/osmocom/bb/mobile/voice.h @@ -0,0 +1,7 @@ +#ifndef _voice_h +#define _voice_h + +int gsm_voice_init(struct osmocom_ms *ms); +int gsm_send_voice(struct osmocom_ms *ms, struct gsm_data_frame *data); + +#endif /* _voice_h */ diff --git a/Src/osmoconbb/src/host/layer23/include/osmocom/bb/mobile/vty.h b/Src/osmoconbb/src/host/layer23/include/osmocom/bb/mobile/vty.h new file mode 100644 index 0000000..1f1341b --- /dev/null +++ b/Src/osmoconbb/src/host/layer23/include/osmocom/bb/mobile/vty.h @@ -0,0 +1,20 @@ +#ifndef OSMOCOM_VTY_H +#define OSMOCOM_VTY_H + +#include +#include +#include +#include + +enum ms_vty_node { + MS_NODE = _LAST_OSMOVTY_NODE + 1, + TESTSIM_NODE, + SUPPORT_NODE, +}; + +enum node_type ms_vty_go_parent(struct vty *vty); +int ms_vty_init(void); +extern void vty_notify(struct osmocom_ms *ms, const char *fmt, ...) __attribute__ ((format (printf, 2, 3))); + +#endif + -- cgit v1.2.3-55-g7522