From bbf9034eaab39ad637ef9a3a1fd935d624dcdba8 Mon Sep 17 00:00:00 2001 From: Andreas Eversberg Date: Fri, 28 Oct 2011 03:55:37 +0200 Subject: gsm/sms: Rewrite of SMC process, extracted from OpenBSC The SMC process is used to transfer RP frames. It is now extracted from OpenBSC. It includes a real state machine now for easier debugging. Written-by: Andreas Eversberg Signed-off-by: Sylvain Munaut --- include/osmocom/gsm/Makefile.am | 2 +- include/osmocom/gsm/gsm0411_smc.h | 62 ++++++++++++++++++++++++++++++++ include/osmocom/gsm/protocol/gsm_04_11.h | 7 ++-- 3 files changed, 67 insertions(+), 4 deletions(-) create mode 100644 include/osmocom/gsm/gsm0411_smc.h (limited to 'include/osmocom/gsm') diff --git a/include/osmocom/gsm/Makefile.am b/include/osmocom/gsm/Makefile.am index 3dbbad5f..49a2ec48 100644 --- a/include/osmocom/gsm/Makefile.am +++ b/include/osmocom/gsm/Makefile.am @@ -1,7 +1,7 @@ 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 gsm0502.h lapd_core.h lapdm.h \ - gsm0411_utils.h + gsm0411_utils.h gsm0411_smc.h SUBDIRS = protocol diff --git a/include/osmocom/gsm/gsm0411_smc.h b/include/osmocom/gsm/gsm0411_smc.h new file mode 100644 index 00000000..e1508a2d --- /dev/null +++ b/include/osmocom/gsm/gsm0411_smc.h @@ -0,0 +1,62 @@ +#ifndef _GSM0411_SMC_H +#define _GSM0411_SMC_H + +#include + +#define GSM411_MMSMS_EST_REQ 0x310 +#define GSM411_MMSMS_EST_IND 0x312 +#define GSM411_MMSMS_EST_CNF 0x311 +#define GSM411_MMSMS_REL_REQ 0x320 +#define GSM411_MMSMS_REL_IND 0x322 +#define GSM411_MMSMS_DATA_REQ 0x330 +#define GSM411_MMSMS_DATA_IND 0x332 +#define GSM411_MMSMS_UNIT_DATA_REQ 0x340 +#define GSM411_MMSMS_UNIT_DATA_IND 0x342 +#define GSM411_MMSMS_ERR_IND 0x372 + +#define GSM411_MNSMS_ABORT_REQ 0x101 +#define GSM411_MNSMS_DATA_REQ 0x102 +#define GSM411_MNSMS_DATA_IND 0x103 +#define GSM411_MNSMS_EST_REQ 0x104 +#define GSM411_MNSMS_EST_IND 0x105 +#define GSM411_MNSMS_ERROR_IND 0x106 +#define GSM411_MNSMS_REL_REQ 0x107 + +struct gsm411_smc_inst { + int network; /* is this a MO (0) or MT (1) transfer */ + int (*mn_recv) (struct gsm411_smc_inst *inst, int msg_type, + struct msgb *msg); + int (*mm_send) (struct gsm411_smc_inst *inst, int msg_type, + struct msgb *msg, int cp_msg_type); + + enum gsm411_cp_state cp_state; + struct osmo_timer_list cp_timer; + struct msgb *cp_msg; /* store pending message */ + int cp_rel; /* store pending release */ + int cp_retx; /* retry counter */ + int cp_max_retr; /* maximum retry */ + int cp_tc1; /* timer value TC1* */ + +}; + +extern const struct value_string gsm411_cp_cause_strs[]; + +/* init a new instance */ +void gsm411_smc_init(struct gsm411_smc_inst *inst, int network, + int (*mn_recv) (struct gsm411_smc_inst *inst, int msg_type, + struct msgb *msg), + int (*mm_send) (struct gsm411_smc_inst *inst, int msg_type, + struct msgb *msg, int cp_msg_type)); + +/* clear instance */ +void gsm411_smc_clear(struct gsm411_smc_inst *inst); + +/* message from upper layer */ +int gsm411_smc_send(struct gsm411_smc_inst *inst, int msg_type, + struct msgb *msg); + +/* message from lower layer */ +int gsm411_smc_recv(struct gsm411_smc_inst *inst, int msg_type, + struct msgb *msg, int cp_msg_type); + +#endif /* _GSM0411_SMC_H */ diff --git a/include/osmocom/gsm/protocol/gsm_04_11.h b/include/osmocom/gsm/protocol/gsm_04_11.h index c6a2b193..905ea9cb 100644 --- a/include/osmocom/gsm/protocol/gsm_04_11.h +++ b/include/osmocom/gsm/protocol/gsm_04_11.h @@ -5,7 +5,7 @@ /* GSM TS 04.11 definitions */ -/* Chapter 5.2.3: SMC-CS states at the network side */ +/* Chapter 5.2.3: SMC-CS states at the user/network side */ enum gsm411_cp_state { GSM411_CPS_IDLE = 0, GSM411_CPS_MM_CONN_PENDING = 1, /* only MT ! */ @@ -13,11 +13,12 @@ enum gsm411_cp_state { GSM411_CPS_MM_ESTABLISHED = 3, }; -/* Chapter 6.2.2: SMR states at the network side */ +/* Chapter 6.2.2: SMR states at the user/network side */ enum gsm411_rp_state { GSM411_RPS_IDLE = 0, GSM411_RPS_WAIT_FOR_RP_ACK = 1, GSM411_RPS_WAIT_TO_TX_RP_ACK = 3, + GSM411_RPS_WAIT_FOR_RETRANS_T = 4, }; /* Chapter 8.1.2 (refers to GSM 04.07 Chapter 11.2.3.1.1 */ @@ -95,7 +96,7 @@ enum gsm411_rp_cause { #define GSM411_TMR_TRAM 30, 0 /* 25 < x < 35 seconds */ #define GSM411_TMR_TR2M 15, 0 /* 12 < x < 20 seconds */ -#define GSM411_TMR_TC1A 30, 0 +#define GSM411_TMR_TC1A 30 /* TR1M - 10 */ /* Chapter 8.2.1 */ struct gsm411_rp_hdr { -- cgit v1.2.3