Harald Welte | 55d724a | 2017-10-16 18:25:45 +0200 | [diff] [blame] | 1 | /*! \addtogroup sms |
| 2 | * @{ |
| 3 | * \file gsm0411_smc.h */ |
Neels Hofmeyr | 17518fe | 2017-06-20 04:35:06 +0200 | [diff] [blame] | 4 | |
Sylvain Munaut | 12ba778 | 2014-06-16 10:13:40 +0200 | [diff] [blame] | 5 | #pragma once |
Andreas Eversberg | bbf9034 | 2011-10-28 03:55:37 +0200 | [diff] [blame] | 6 | |
Holger Hans Peter Freyther | d38e0ef | 2012-11-13 22:28:05 +0100 | [diff] [blame] | 7 | #include <osmocom/core/timer.h> |
Andreas Eversberg | bbf9034 | 2011-10-28 03:55:37 +0200 | [diff] [blame] | 8 | #include <osmocom/gsm/protocol/gsm_04_11.h> |
| 9 | |
| 10 | #define GSM411_MMSMS_EST_REQ 0x310 |
| 11 | #define GSM411_MMSMS_EST_IND 0x312 |
| 12 | #define GSM411_MMSMS_EST_CNF 0x311 |
| 13 | #define GSM411_MMSMS_REL_REQ 0x320 |
| 14 | #define GSM411_MMSMS_REL_IND 0x322 |
| 15 | #define GSM411_MMSMS_DATA_REQ 0x330 |
| 16 | #define GSM411_MMSMS_DATA_IND 0x332 |
| 17 | #define GSM411_MMSMS_UNIT_DATA_REQ 0x340 |
| 18 | #define GSM411_MMSMS_UNIT_DATA_IND 0x342 |
| 19 | #define GSM411_MMSMS_ERR_IND 0x372 |
| 20 | |
| 21 | #define GSM411_MNSMS_ABORT_REQ 0x101 |
| 22 | #define GSM411_MNSMS_DATA_REQ 0x102 |
| 23 | #define GSM411_MNSMS_DATA_IND 0x103 |
| 24 | #define GSM411_MNSMS_EST_REQ 0x104 |
| 25 | #define GSM411_MNSMS_EST_IND 0x105 |
| 26 | #define GSM411_MNSMS_ERROR_IND 0x106 |
| 27 | #define GSM411_MNSMS_REL_REQ 0x107 |
| 28 | |
| 29 | struct gsm411_smc_inst { |
Holger Hans Peter Freyther | 33e8a87 | 2012-11-14 06:07:47 +0100 | [diff] [blame] | 30 | uint64_t id; /* a unique id for the SMS */ |
Andreas Eversberg | bbf9034 | 2011-10-28 03:55:37 +0200 | [diff] [blame] | 31 | int network; /* is this a MO (0) or MT (1) transfer */ |
| 32 | int (*mn_recv) (struct gsm411_smc_inst *inst, int msg_type, |
| 33 | struct msgb *msg); |
| 34 | int (*mm_send) (struct gsm411_smc_inst *inst, int msg_type, |
| 35 | struct msgb *msg, int cp_msg_type); |
| 36 | |
| 37 | enum gsm411_cp_state cp_state; |
| 38 | struct osmo_timer_list cp_timer; |
| 39 | struct msgb *cp_msg; /* store pending message */ |
| 40 | int cp_rel; /* store pending release */ |
| 41 | int cp_retx; /* retry counter */ |
| 42 | int cp_max_retr; /* maximum retry */ |
| 43 | int cp_tc1; /* timer value TC1* */ |
| 44 | |
| 45 | }; |
| 46 | |
| 47 | extern const struct value_string gsm411_cp_cause_strs[]; |
| 48 | |
| 49 | /* init a new instance */ |
Holger Hans Peter Freyther | 33e8a87 | 2012-11-14 06:07:47 +0100 | [diff] [blame] | 50 | void gsm411_smc_init(struct gsm411_smc_inst *inst, uint64_t id, int network, |
Andreas Eversberg | bbf9034 | 2011-10-28 03:55:37 +0200 | [diff] [blame] | 51 | int (*mn_recv) (struct gsm411_smc_inst *inst, int msg_type, |
| 52 | struct msgb *msg), |
| 53 | int (*mm_send) (struct gsm411_smc_inst *inst, int msg_type, |
| 54 | struct msgb *msg, int cp_msg_type)); |
| 55 | |
| 56 | /* clear instance */ |
| 57 | void gsm411_smc_clear(struct gsm411_smc_inst *inst); |
| 58 | |
| 59 | /* message from upper layer */ |
| 60 | int gsm411_smc_send(struct gsm411_smc_inst *inst, int msg_type, |
| 61 | struct msgb *msg); |
| 62 | |
| 63 | /* message from lower layer */ |
| 64 | int gsm411_smc_recv(struct gsm411_smc_inst *inst, int msg_type, |
| 65 | struct msgb *msg, int cp_msg_type); |
Harald Welte | 55d724a | 2017-10-16 18:25:45 +0200 | [diff] [blame] | 66 | |
Harald Welte | d60e17a | 2018-01-24 16:50:11 +0100 | [diff] [blame] | 67 | extern const struct value_string gsm411_cp_state_names[]; |
| 68 | |
| 69 | static inline const char *gsm411_cp_state_name(enum gsm411_cp_state cp_state) { |
| 70 | return get_value_string(gsm411_cp_state_names, cp_state); |
| 71 | } |
Harald Welte | 55d724a | 2017-10-16 18:25:45 +0200 | [diff] [blame] | 72 | /*! @} */ |