diff options
author | Andreas.Eversberg <jolly@eversberg.eu> | 2011-07-28 21:02:38 +0200 |
---|---|---|
committer | Sylvain Munaut <tnt@246tNt.com> | 2011-07-28 21:02:38 +0200 |
commit | 7a9b3f45b278c5664bd8f76b692febb84dee6a71 (patch) | |
tree | f8fcee858a6008300d42d170739bdbd4ead740c8 /src/shared/libosmocore/include/osmocom/gsm | |
parent | 8d24b2f3953cf6c02ec3ec09a88d152d6993470a (diff) | |
parent | 430be849945688ae107b079db1e216329b1a1f06 (diff) |
Merge commit '430be849945688ae107b079db1e216329b1a1f06'
Diffstat (limited to 'src/shared/libosmocore/include/osmocom/gsm')
10 files changed, 242 insertions, 6 deletions
diff --git a/src/shared/libosmocore/include/osmocom/gsm/Makefile.am b/src/shared/libosmocore/include/osmocom/gsm/Makefile.am index aa7b1a9a..90f19bc5 100644 --- a/src/shared/libosmocore/include/osmocom/gsm/Makefile.am +++ b/src/shared/libosmocore/include/osmocom/gsm/Makefile.am @@ -1,6 +1,6 @@ osmogsm_HEADERS = a5.h comp128.h gsm0808.h gsm48_ie.h mncc.h rxlev_stat.h \ gsm0480.h gsm48.h gsm_utils.h rsl.h tlv.h abis_nm.h \ - sysinfo.h prim.h + sysinfo.h prim.h gsm0502.h lapdm.h SUBDIRS = protocol diff --git a/src/shared/libosmocore/include/osmocom/gsm/gsm0480.h b/src/shared/libosmocore/include/osmocom/gsm/gsm0480.h index d6626d60..f6c37340 100644 --- a/src/shared/libosmocore/include/osmocom/gsm/gsm0480.h +++ b/src/shared/libosmocore/include/osmocom/gsm/gsm0480.h @@ -8,7 +8,7 @@ #define MAX_LEN_USSD_STRING 31 struct ussd_request { - char text[MAX_LEN_USSD_STRING + 1]; + uint8_t text[MAX_LEN_USSD_STRING + 1]; uint8_t transaction_id; uint8_t invoke_id; }; diff --git a/src/shared/libosmocore/include/osmocom/gsm/gsm0502.h b/src/shared/libosmocore/include/osmocom/gsm/gsm0502.h new file mode 100644 index 00000000..46b629e4 --- /dev/null +++ b/src/shared/libosmocore/include/osmocom/gsm/gsm0502.h @@ -0,0 +1,38 @@ +#ifndef OSMOCOM_GSM_0502_H +#define OSMOCOM_GSM_0502_H + +#include <stdint.h> + +#include <osmocom/gsm/protocol/gsm_04_08.h> +#include <osmocom/gsm/protocol/gsm_08_58.h> + +/* Table 5 Clause 7 TS 05.02 */ +static inline unsigned int +gsm0502_get_n_pag_blocks(struct gsm48_control_channel_descr *chan_desc) +{ + if (chan_desc->ccch_conf == RSL_BCCH_CCCH_CONF_1_C) + return 3 - chan_desc->bs_ag_blks_res; + else + return 9 - chan_desc->bs_ag_blks_res; +} + +/* Chapter 6.5.2 of TS 05.02 */ +static inline unsigned int +gsm0502_get_ccch_group(uint64_t imsi, unsigned int bs_cc_chans, + unsigned int n_pag_blocks) +{ + return (imsi % 1000) % (bs_cc_chans * n_pag_blocks) / n_pag_blocks; +} + +/* Chapter 6.5.2 of TS 05.02 */ +static inline unsigned int +gsm0502_get_paging_group(uint64_t imsi, unsigned int bs_cc_chans, + int n_pag_blocks) +{ + return (imsi % 1000) % (bs_cc_chans * n_pag_blocks) % n_pag_blocks; +} + +unsigned int +gsm0502_calc_paging_group(struct gsm48_control_channel_descr *chan_desc, uint64_t imsi); + +#endif diff --git a/src/shared/libosmocore/include/osmocom/gsm/gsm0808.h b/src/shared/libosmocore/include/osmocom/gsm/gsm0808.h index 1d853775..38d88ef9 100644 --- a/src/shared/libosmocore/include/osmocom/gsm/gsm0808.h +++ b/src/shared/libosmocore/include/osmocom/gsm/gsm0808.h @@ -41,6 +41,9 @@ struct msgb *gsm0808_create_clear_rqst(uint8_t cause); struct msgb *gsm0808_create_dtap(struct msgb *msg, uint8_t link_id); void gsm0808_prepend_dtap_header(struct msgb *msg, uint8_t link_id); -const struct tlv_definition *gsm0808_att_tlvdef(); +const struct tlv_definition *gsm0808_att_tlvdef(void); + +const char *gsm0808_bssmap_name(uint8_t msg_type); +const char *gsm0808_bssap_name(uint8_t msg_type); #endif diff --git a/src/shared/libosmocore/include/osmocom/gsm/gsm48.h b/src/shared/libosmocore/include/osmocom/gsm/gsm48.h index 1e9403bc..16a625aa 100644 --- a/src/shared/libosmocore/include/osmocom/gsm/gsm48.h +++ b/src/shared/libosmocore/include/osmocom/gsm/gsm48.h @@ -33,4 +33,6 @@ int gsm48_mi_to_string(char *string, const int str_len, void gsm48_parse_ra(struct gprs_ra_id *raid, const uint8_t *buf); int gsm48_construct_ra(uint8_t *buf, const struct gprs_ra_id *raid); +int gsm48_number_of_paging_subchannels(struct gsm48_control_channel_descr *chan_desc); + #endif diff --git a/src/shared/libosmocore/include/osmocom/gsm/gsm_utils.h b/src/shared/libosmocore/include/osmocom/gsm/gsm_utils.h index 405dfe32..c9a31016 100644 --- a/src/shared/libosmocore/include/osmocom/gsm/gsm_utils.h +++ b/src/shared/libosmocore/include/osmocom/gsm/gsm_utils.h @@ -57,9 +57,14 @@ const char *gsm_band_name(enum gsm_band band); enum gsm_band gsm_band_parse(const char *mhz); int gsm_7bit_decode(char *decoded, const uint8_t *user_data, uint8_t length); +int gsm_7bit_decode_hdr(char *decoded, const uint8_t *user_data, uint8_t length, uint8_t ud_hdr_ind); int gsm_7bit_encode(uint8_t *result, const char *data); -unsigned int ms_class_gmsk_dbm(enum gsm_band band, int class); +int gsm_septets2octets(uint8_t *result, uint8_t *rdata, uint8_t septet_len, uint8_t padding); +int gsm_septet_encode(uint8_t *result, const char *data); +uint8_t gsm_get_octet_len(const uint8_t sept_len); + +unsigned int ms_class_gmsk_dbm(enum gsm_band band, int ms_class); int ms_pwr_ctl_lvl(enum gsm_band band, unsigned int dbm); int ms_pwr_dbm(enum gsm_band band, uint8_t lvl); diff --git a/src/shared/libosmocore/include/osmocom/gsm/lapdm.h b/src/shared/libosmocore/include/osmocom/gsm/lapdm.h new file mode 100644 index 00000000..2e78aeee --- /dev/null +++ b/src/shared/libosmocore/include/osmocom/gsm/lapdm.h @@ -0,0 +1,186 @@ +#ifndef _OSMOCOM_LAPDM_H +#define _OSMOCOM_LAPDM_H + +#include <stdint.h> + +#include <osmocom/core/timer.h> +#include <osmocom/core/msgb.h> +#include <osmocom/gsm/prim.h> + +/* 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/shared/libosmocore/include/osmocom/gsm/protocol/ipaccess.h b/src/shared/libosmocore/include/osmocom/gsm/protocol/ipaccess.h index 27925725..5d98a21f 100644 --- a/src/shared/libosmocore/include/osmocom/gsm/protocol/ipaccess.h +++ b/src/shared/libosmocore/include/osmocom/gsm/protocol/ipaccess.h @@ -33,6 +33,7 @@ enum ipaccess_proto_ext { IPAC_PROTO_EXT_CTRL = 0x00, IPAC_PROTO_EXT_MGCP = 0x01, IPAC_PROTO_EXT_LAC = 0x02, + IPAC_PROTO_EXT_SMSC = 0x03, }; enum ipaccess_msgtype { diff --git a/src/shared/libosmocore/include/osmocom/gsm/rsl.h b/src/shared/libosmocore/include/osmocom/gsm/rsl.h index 2eb045f2..44ded1b1 100644 --- a/src/shared/libosmocore/include/osmocom/gsm/rsl.h +++ b/src/shared/libosmocore/include/osmocom/gsm/rsl.h @@ -3,6 +3,7 @@ #include <stdint.h> #include <osmocom/core/utils.h> +#include <osmocom/core/msgb.h> #include <osmocom/gsm/protocol/gsm_08_58.h> void rsl_init_rll_hdr(struct abis_rsl_rll_hdr *dh, uint8_t msg_type); diff --git a/src/shared/libosmocore/include/osmocom/gsm/tlv.h b/src/shared/libosmocore/include/osmocom/gsm/tlv.h index 552af2bd..f659411f 100644 --- a/src/shared/libosmocore/include/osmocom/gsm/tlv.h +++ b/src/shared/libosmocore/include/osmocom/gsm/tlv.h @@ -236,11 +236,11 @@ struct tlv_def { }; struct tlv_definition { - struct tlv_def def[0xff]; + struct tlv_def def[256]; }; struct tlv_parsed { - struct tlv_p_entry lv[0xff]; + struct tlv_p_entry lv[256]; }; extern struct tlv_definition tvlv_att_def; |