diff options
author | Sylvain Munaut <tnt@246tNt.com> | 2010-07-27 20:44:46 +0200 |
---|---|---|
committer | Sylvain Munaut <tnt@246tNt.com> | 2010-07-27 20:49:27 +0200 |
commit | 9e9f99c0a094a3b82a75bbac33cabc2be8a6bacb (patch) | |
tree | 24f420eb61d8204c93ae1f369221626e2c27a948 /src/host/layer23/include/osmocom/bb/common | |
parent | de21ca4aaf999b15caca686b217708111117789b (diff) |
layer23: Split [2/2] -> The header files
This split the headers and adapt the source.
We use osmocom/bb as a prefix because libosomore also
uses osmocom and generic names such as misc & common could
conflict in the future.
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
Diffstat (limited to 'src/host/layer23/include/osmocom/bb/common')
8 files changed, 299 insertions, 0 deletions
diff --git a/src/host/layer23/include/osmocom/bb/common/Makefile.am b/src/host/layer23/include/osmocom/bb/common/Makefile.am new file mode 100644 index 00000000..fa467575 --- /dev/null +++ b/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 \ + osmocom_data.h diff --git a/src/host/layer23/include/osmocom/bb/common/l1ctl.h b/src/host/layer23/include/osmocom/bb/common/l1ctl.h new file mode 100644 index 00000000..75551abe --- /dev/null +++ b/src/host/layer23/include/osmocom/bb/common/l1ctl.h @@ -0,0 +1,48 @@ +#ifndef osmocom_l1ctl_h +#define osmocom_l1ctl_h + +#include <osmocore/msgb.h> +#include <osmocom/bb/common/osmocom_data.h> + +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 tx_ph_data_req(struct osmocom_ms *ms, struct msgb *msg, uint8_t chan_nr, + uint8_t link_id); + +/* Transmit L1CTL_PARAM_REQ */ +int l1ctl_tx_ph_param_req(struct osmocom_ms *ms, uint8_t ta, uint8_t tx_power); + +/* Transmit L1CTL_RACH_REQ */ +int tx_ph_rach_req(struct osmocom_ms *ms, uint8_t ra, uint8_t fn51, + uint8_t mf_off); + +/* Transmit L1CTL_DM_EST_REQ */ +int tx_ph_dm_est_req_h0(struct osmocom_ms *ms, uint16_t band_arfcn, + uint8_t chan_nr, uint8_t tsc); +int tx_ph_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); + +/* Transmit L1CTL_DM_REL_REQ */ +int tx_ph_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); + +int l1ctl_tx_ccch_mode_req(struct osmocom_ms *ms, uint8_t ccch_mode); + +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); + +#endif diff --git a/src/host/layer23/include/osmocom/bb/common/l1l2_interface.h b/src/host/layer23/include/osmocom/bb/common/l1l2_interface.h new file mode 100644 index 00000000..41403d87 --- /dev/null +++ b/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/host/layer23/include/osmocom/bb/common/l23_app.h b/src/host/layer23/include/osmocom/bb/common/l23_app.h new file mode 100644 index 00000000..1a228567 --- /dev/null +++ b/src/host/layer23/include/osmocom/bb/common/l23_app.h @@ -0,0 +1,10 @@ +#ifndef _L23_APP_H +#define _L23_APP_H + +/* 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); + +#endif /* _L23_APP_H */ diff --git a/src/host/layer23/include/osmocom/bb/common/lapdm.h b/src/host/layer23/include/osmocom/bb/common/lapdm.h new file mode 100644 index 00000000..ab048b8a --- /dev/null +++ b/src/host/layer23/include/osmocom/bb/common/lapdm.h @@ -0,0 +1,100 @@ +#ifndef _OSMOCOM_LAPDM_H +#define _OSMOCOM_LAPDM_H + +#include <stdint.h> + +#include <osmocore/timer.h> +#include <osmocore/msgb.h> + +#include <l1a_l23_interface.h> + +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 osmocom_ms; + +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 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 +}; + +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 */ + struct osmocom_ms *ms; +}; + +const char *get_rsl_name(int value); +extern const char *lapdm_state_names[]; + +/* initialize a LAPDm entity */ +void lapdm_init(struct lapdm_entity *le, struct osmocom_ms *ms); + +/* deinitialize a LAPDm entity */ +void lapdm_exit(struct lapdm_entity *le); + +/* input into layer2 (from layer 1) */ +int l2_ph_data_ind(struct msgb *msg, struct lapdm_entity *le, struct l1ctl_info_dl *l1i); +int l2_ph_data_conf(struct msgb *msg, struct lapdm_entity *le); + +/* L1 confirms channel request */ +int l2_ph_chan_conf(struct msgb *msg, struct osmocom_ms *ms, + struct l1ctl_info_dl *dl); + +/* input into layer2 (from layer 3) */ +int rslms_recvmsg(struct msgb *msg, struct osmocom_ms *ms); + +/* sending messages up from L2 to L3 */ +int rslms_sendmsg(struct msgb *msg, struct osmocom_ms *ms); + +typedef int (*osmol2_cb_t)(struct msgb *msg, struct osmocom_ms *ms); + +/* register message handler for messages that are sent from L2->L3 */ +int osmol2_register_handler(struct osmocom_ms *ms, osmol2_cb_t cb); + +#endif /* _OSMOCOM_LAPDM_H */ diff --git a/src/host/layer23/include/osmocom/bb/common/logging.h b/src/host/layer23/include/osmocom/bb/common/logging.h new file mode 100644 index 00000000..1a11cf9d --- /dev/null +++ b/src/host/layer23/include/osmocom/bb/common/logging.h @@ -0,0 +1,25 @@ +#ifndef _LOGGING_H +#define _LOGGING_H + +#define DEBUG +#include <osmocore/logging.h> + +enum { + DRSL, + DRR, + DPLMN, + DCS, + DMM, + DCC, + DSMS, + DMNCC, + DMEAS, + DPAG, + DLAPDM, + DL1C, + DSUM, +}; + +extern const struct log_info log_info; + +#endif /* _LOGGING_H */ diff --git a/src/host/layer23/include/osmocom/bb/common/networks.h b/src/host/layer23/include/osmocom/bb/common/networks.h new file mode 100644 index 00000000..e8c1b18e --- /dev/null +++ b/src/host/layer23/include/osmocom/bb/common/networks.h @@ -0,0 +1,22 @@ +#ifndef _NETWORKS_H +#define _NETWORKS_H + +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/host/layer23/include/osmocom/bb/common/osmocom_data.h b/src/host/layer23/include/osmocom/bb/common/osmocom_data.h new file mode 100644 index 00000000..dc7ba11d --- /dev/null +++ b/src/host/layer23/include/osmocom/bb/common/osmocom_data.h @@ -0,0 +1,84 @@ +#ifndef osmocom_data_h +#define osmocom_data_h + +#include <osmocore/select.h> +#include <osmocore/gsm_utils.h> +#include <osmocore/write_queue.h> + +struct osmocom_ms; + + /* FIXME no 'mobile' specific stuff should be here */ +#include <osmocom/bb/mobile/support.h> +#include <osmocom/bb/mobile/settings.h> +#include <osmocom/bb/mobile/subscriber.h> +#include <osmocom/bb/common/lapdm.h> +#include <osmocom/bb/mobile/gsm48_rr.h> +#include <osmocom/bb/mobile/sysinfo.h> +#include <osmocom/bb/mobile/gsm322.h> +#include <osmocom/bb/mobile/gsm48_mm.h> +#include <osmocom/bb/mobile/gsm48_cc.h> + +/* A layer2 entity */ +struct osmol2_entity { + struct lapdm_entity lapdm_dcch; + struct lapdm_entity lapdm_acch; + osmol2_cb_t msg_handler; +}; + +/* RX measurement statistics */ +struct rx_meas_stat { + uint32_t frames; + uint32_t berr; + uint32_t rxlev; +}; + +/* One Mobilestation for osmocom */ +struct osmocom_ms { + struct llist_head entity; + char name[32]; + struct write_queue wq; + uint16_t test_arfcn; + + struct gsm_support support; + + struct gsm_settings settings; + + struct gsm_subscriber subscr; + + struct osmol2_entity l2_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 llist_head trans_list; +}; + +enum osmobb_sig_subsys { + SS_L1CTL, +}; + +enum osmobb_meas_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, +}; + +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; +}; + +#endif |