Harald Welte | c436245 | 2010-03-22 22:25:13 +0800 | [diff] [blame] | 1 | #ifndef PROTO_GSM_04_11_H |
| 2 | #define PROTO_GSM_04_11_H |
| 3 | |
| 4 | #include <stdint.h> |
| 5 | |
| 6 | /* GSM TS 04.11 definitions */ |
| 7 | |
| 8 | /* Chapter 5.2.3: SMC-CS states at the network side */ |
| 9 | enum gsm411_cp_state { |
| 10 | GSM411_CPS_IDLE = 0, |
| 11 | GSM411_CPS_MM_CONN_PENDING = 1, /* only MT ! */ |
| 12 | GSM411_CPS_WAIT_CP_ACK = 2, |
| 13 | GSM411_CPS_MM_ESTABLISHED = 3, |
| 14 | }; |
| 15 | |
| 16 | /* Chapter 6.2.2: SMR states at the network side */ |
| 17 | enum gsm411_rp_state { |
| 18 | GSM411_RPS_IDLE = 0, |
| 19 | GSM411_RPS_WAIT_FOR_RP_ACK = 1, |
| 20 | GSM411_RPS_WAIT_TO_TX_RP_ACK = 3, |
| 21 | }; |
| 22 | |
| 23 | /* Chapter 8.1.2 (refers to GSM 04.07 Chapter 11.2.3.1.1 */ |
| 24 | #define GSM411_PDISC_SMS 0x09 |
| 25 | |
| 26 | /* Chapter 8.1.3 */ |
| 27 | #define GSM411_MT_CP_DATA 0x01 |
| 28 | #define GSM411_MT_CP_ACK 0x04 |
| 29 | #define GSM411_MT_CP_ERROR 0x10 |
| 30 | |
| 31 | enum gsm411_cp_ie { |
| 32 | GSM411_CP_IE_USER_DATA = 0x01, /* 8.1.4.1 */ |
| 33 | GSM411_CP_IE_CAUSE = 0x02, /* 8.1.4.2. */ |
| 34 | }; |
| 35 | |
| 36 | /* Section 8.1.4.2 / Table 8.2 */ |
| 37 | enum gsm411_cp_cause { |
| 38 | GSM411_CP_CAUSE_NET_FAIL = 17, |
| 39 | GSM411_CP_CAUSE_CONGESTION = 22, |
| 40 | GSM411_CP_CAUSE_INV_TRANS_ID = 81, |
| 41 | GSM411_CP_CAUSE_SEMANT_INC_MSG = 95, |
| 42 | GSM411_CP_CAUSE_INV_MAND_INF = 96, |
| 43 | GSM411_CP_CAUSE_MSGTYPE_NOTEXIST= 97, |
| 44 | GSM411_CP_CAUSE_MSG_INCOMP_STATE= 98, |
| 45 | GSM411_CP_CAUSE_IE_NOTEXIST = 99, |
| 46 | GSM411_CP_CAUSE_PROTOCOL_ERR = 111, |
| 47 | }; |
| 48 | |
| 49 | /* Chapter 8.2.2 */ |
| 50 | #define GSM411_MT_RP_DATA_MO 0x00 |
| 51 | #define GSM411_MT_RP_DATA_MT 0x01 |
| 52 | #define GSM411_MT_RP_ACK_MO 0x02 |
| 53 | #define GSM411_MT_RP_ACK_MT 0x03 |
| 54 | #define GSM411_MT_RP_ERROR_MO 0x04 |
| 55 | #define GSM411_MT_RP_ERROR_MT 0x05 |
| 56 | #define GSM411_MT_RP_SMMA_MO 0x06 |
| 57 | |
| 58 | enum gsm411_rp_ie { |
| 59 | GSM411_IE_RP_USER_DATA = 0x41, /* 8.2.5.3 */ |
| 60 | GSM411_IE_RP_CAUSE = 0x42, /* 8.2.5.4 */ |
| 61 | }; |
| 62 | |
| 63 | /* Chapter 8.2.5.4 Table 8.4 */ |
| 64 | enum gsm411_rp_cause { |
| 65 | /* valid only for MO */ |
| 66 | GSM411_RP_CAUSE_MO_NUM_UNASSIGNED = 1, |
| 67 | GSM411_RP_CAUSE_MO_OP_DET_BARR = 8, |
| 68 | GSM411_RP_CAUSE_MO_CALL_BARRED = 10, |
| 69 | GSM411_RP_CAUSE_MO_SMS_REJECTED = 21, |
| 70 | GSM411_RP_CAUSE_MO_DEST_OUT_OF_ORDER = 27, |
| 71 | GSM411_RP_CAUSE_MO_UNIDENTIFIED_SUBSCR = 28, |
| 72 | GSM411_RP_CAUSE_MO_FACILITY_REJ = 29, |
| 73 | GSM411_RP_CAUSE_MO_UNKNOWN_SUBSCR = 30, |
| 74 | GSM411_RP_CAUSE_MO_NET_OUT_OF_ORDER = 38, |
| 75 | GSM411_RP_CAUSE_MO_TEMP_FAIL = 41, |
| 76 | GSM411_RP_CAUSE_MO_CONGESTION = 42, |
| 77 | GSM411_RP_CAUSE_MO_RES_UNAVAIL = 47, |
| 78 | GSM411_RP_CAUSE_MO_REQ_FAC_NOTSUBSCR = 50, |
| 79 | GSM411_RP_CAUSE_MO_REQ_FAC_NOTIMPL = 69, |
| 80 | GSM411_RP_CAUSE_MO_INTERWORKING = 127, |
| 81 | /* valid only for MT */ |
| 82 | GSM411_RP_CAUSE_MT_MEM_EXCEEDED = 22, |
| 83 | /* valid for both directions */ |
| 84 | GSM411_RP_CAUSE_INV_TRANS_REF = 81, |
| 85 | GSM411_RP_CAUSE_SEMANT_INC_MSG = 95, |
| 86 | GSM411_RP_CAUSE_INV_MAND_INF = 96, |
| 87 | GSM411_RP_CAUSE_MSGTYPE_NOTEXIST = 97, |
| 88 | GSM411_RP_CAUSE_MSG_INCOMP_STATE = 98, |
| 89 | GSM411_RP_CAUSE_IE_NOTEXIST = 99, |
| 90 | GSM411_RP_CAUSE_PROTOCOL_ERR = 111, |
| 91 | }; |
| 92 | |
| 93 | /* Chapter 10: Timers */ |
| 94 | #define GSM411_TMR_TR1M 40, 0 /* 35 < x < 45 seconds */ |
| 95 | #define GSM411_TMR_TRAM 30, 0 /* 25 < x < 35 seconds */ |
| 96 | #define GSM411_TMR_TR2M 15, 0 /* 12 < x < 20 seconds */ |
| 97 | |
| 98 | #define GSM411_TMR_TC1A 30, 0 |
| 99 | |
| 100 | /* Chapter 8.2.1 */ |
| 101 | struct gsm411_rp_hdr { |
| 102 | uint8_t len; |
| 103 | uint8_t msg_type; |
| 104 | uint8_t msg_ref; |
| 105 | uint8_t data[0]; |
| 106 | } __attribute__ ((packed)); |
| 107 | |
| 108 | /* our own enum, not related to on-air protocol */ |
| 109 | enum sms_alphabet { |
| 110 | DCS_NONE, |
| 111 | DCS_7BIT_DEFAULT, |
| 112 | DCS_UCS2, |
| 113 | DCS_8BIT_DATA, |
| 114 | }; |
| 115 | |
| 116 | /* GSM 03.40 / Chapter 9.2.3.1: TP-Message-Type-Indicator */ |
| 117 | #define GSM340_SMS_DELIVER_SC2MS 0x00 |
| 118 | #define GSM340_SMS_DELIVER_REP_MS2SC 0x00 |
| 119 | #define GSM340_SMS_STATUS_REP_SC2MS 0x02 |
| 120 | #define GSM340_SMS_COMMAND_MS2SC 0x02 |
| 121 | #define GSM340_SMS_SUBMIT_MS2SC 0x01 |
| 122 | #define GSM340_SMS_SUBMIT_REP_SC2MS 0x01 |
| 123 | #define GSM340_SMS_RESSERVED 0x03 |
| 124 | |
| 125 | /* GSM 03.40 / Chapter 9.2.3.2: TP-More-Messages-to-Send */ |
| 126 | #define GSM340_TP_MMS_MORE 0 |
| 127 | #define GSM340_TP_MMS_NO_MORE 1 |
| 128 | |
| 129 | /* GSM 03.40 / Chapter 9.2.3.3: TP-Validity-Period-Format */ |
| 130 | #define GSM340_TP_VPF_NONE 0 |
| 131 | #define GSM340_TP_VPF_RELATIVE 2 |
| 132 | #define GSM340_TP_VPF_ENHANCED 1 |
| 133 | #define GSM340_TP_VPF_ABSOLUTE 3 |
| 134 | |
| 135 | /* GSM 03.40 / Chapter 9.2.3.4: TP-Status-Report-Indication */ |
| 136 | #define GSM340_TP_SRI_NONE 0 |
| 137 | #define GSM340_TP_SRI_PRESENT 1 |
| 138 | |
| 139 | /* GSM 03.40 / Chapter 9.2.3.5: TP-Status-Report-Request */ |
| 140 | #define GSM340_TP_SRR_NONE 0 |
| 141 | #define GSM340_TP_SRR_REQUESTED 1 |
| 142 | |
| 143 | /* GSM 03.40 / Chapter 9.2.3.9: TP-Protocol-Identifier */ |
| 144 | /* telematic interworking (001 or 111 in bits 7-5) */ |
| 145 | #define GSM340_TP_PID_IMPLICIT 0x00 |
| 146 | #define GSM340_TP_PID_TELEX 0x01 |
| 147 | #define GSM340_TP_PID_FAX_G3 0x02 |
| 148 | #define GSM340_TP_PID_FAX_G4 0x03 |
| 149 | #define GSM340_TP_PID_VOICE 0x04 |
| 150 | #define GSM430_TP_PID_ERMES 0x05 |
| 151 | #define GSM430_TP_PID_NATIONAL_PAGING 0x06 |
| 152 | #define GSM430_TP_PID_VIDEOTEX 0x07 |
| 153 | #define GSM430_TP_PID_TELETEX_UNSPEC 0x08 |
| 154 | #define GSM430_TP_PID_TELETEX_PSPDN 0x09 |
| 155 | #define GSM430_TP_PID_TELETEX_CSPDN 0x0a |
| 156 | #define GSM430_TP_PID_TELETEX_PSTN 0x0b |
| 157 | #define GSM430_TP_PID_TELETEX_ISDN 0x0c |
| 158 | #define GSM430_TP_PID_TELETEX_UCI 0x0d |
| 159 | #define GSM430_TP_PID_MSG_HANDLING 0x10 |
| 160 | #define GSM430_TP_PID_MSG_X400 0x11 |
| 161 | #define GSM430_TP_PID_EMAIL 0x12 |
| 162 | #define GSM430_TP_PID_GSM_MS 0x1f |
| 163 | /* if bit 7 = 0 and bit 6 = 1 */ |
| 164 | #define GSM430_TP_PID_SMS_TYPE_0 0 |
| 165 | #define GSM430_TP_PID_SMS_TYPE_1 1 |
| 166 | #define GSM430_TP_PID_SMS_TYPE_2 2 |
| 167 | #define GSM430_TP_PID_SMS_TYPE_3 3 |
| 168 | #define GSM430_TP_PID_SMS_TYPE_4 4 |
| 169 | #define GSM430_TP_PID_SMS_TYPE_5 5 |
| 170 | #define GSM430_TP_PID_SMS_TYPE_6 6 |
| 171 | #define GSM430_TP_PID_SMS_TYPE_7 7 |
| 172 | #define GSM430_TP_PID_RETURN_CALL_MSG 0x1f |
| 173 | #define GSM430_TP_PID_ME_DATA_DNLOAD 0x3d |
| 174 | #define GSM430_TP_PID_ME_DE_PERSONAL 0x3e |
| 175 | #define GSM430_TP_PID_ME_SIM_DNLOAD 0x3f |
| 176 | |
| 177 | /* GSM 03.38 Chapter 4: SMS Data Coding Scheme */ |
| 178 | #define GSM338_DCS_00_ |
| 179 | |
| 180 | #define GSM338_DCS_1110_7BIT (0 << 2) |
| 181 | #define GSM338_DCS_1111_7BIT (0 << 2) |
| 182 | #define GSM338_DCS_1111_8BIT_DATA (1 << 2) |
| 183 | #define GSM338_DCS_1111_CLASS0 0 |
| 184 | #define GSM338_DCS_1111_CLASS1_ME 1 |
| 185 | #define GSM338_DCS_1111_CLASS2_SIM 2 |
| 186 | #define GSM338_DCS_1111_CLASS3_TE 3 /* See TS 07.05 */ |
| 187 | |
| 188 | #endif /* PROTO_GSM_04_11_H */ |