blob: 12c607f54ce2d837a5bc7951d0f58bf9fe791787 [file] [log] [blame]
Daniel Willmann8b3390e2008-12-28 00:31:09 +00001#ifndef _GSM_04_11_H
2#define _GSM_04_11_H
3
4/* GSM TS 04.11 definitions */
5
6/* Chapter 8.1.2 (refers to GSM 04.07 Chapter 11.2.3.1.1 */
7#define GSM411_PDISC_SMS 0x09
8
9/* Chapter 8.1.3 */
10#define GSM411_MT_CP_DATA 0x01
11#define GSM411_MT_CP_ACK 0x04
12#define GSM411_MT_CP_ERROR 0x10
13
Harald Weltee1b13382009-02-16 22:32:17 +000014enum gsm411_cp_ie {
15 GSM411_CP_IE_USER_DATA = 0x01, /* 8.1.4.1 */
16 GSM411_CP_IE_CAUSE = 0x02, /* 8.1.4.2. */
17};
18
Daniel Willmann8b3390e2008-12-28 00:31:09 +000019/* Chapter 8.2.2 */
20#define GSM411_MT_RP_DATA_MO 0x00
21#define GSM411_MT_RP_DATA_MT 0x01
22#define GSM411_MT_RP_ACK_MO 0x02
23#define GSM411_MT_RP_ACK_MT 0x03
24#define GSM411_MT_RP_ERROR_MO 0x04
25#define GSM411_MT_RP_ERROR_MT 0x04
26#define GSM411_MT_RP_SMMA_MO 0x05
27
Harald Weltee1b13382009-02-16 22:32:17 +000028enum gsm411_rp_ie {
29 GSM411_IE_RP_USER_DATA = 0x41, /* 8.2.5.3 */
30 GSM411_IE_RP_CAUSE = 0x42, /* 8.2.5.4 */
31};
32
Daniel Willmann471712b2008-12-29 01:54:02 +000033/* Chapter 8.2.1 */
34struct gsm411_rp_hdr {
Daniel Willmanne0fbec82008-12-29 00:44:41 +000035 u_int8_t len;
36 u_int8_t msg_type;
Daniel Willmann8b3390e2008-12-28 00:31:09 +000037 u_int8_t msg_ref;
38 u_int8_t data[0];
39} __attribute__ ((packed));
40
Harald Welte7e310b12009-03-30 20:56:32 +000041/* our own enum, not related to on-air protocol */
42enum sms_alphabet {
43 DCS_NONE,
44 DCS_7BIT_DEFAULT,
45 DCS_UCS2,
46 DCS_8BIT_DATA,
47};
48
Daniel Willmanne0fbec82008-12-29 00:44:41 +000049/* SMS submit PDU */
50struct sms_submit {
51 u_int8_t *smsc;
52 u_int8_t mti:2;
Daniel Willmanne0fbec82008-12-29 00:44:41 +000053 u_int8_t vpf:2;
Harald Welte7e310b12009-03-30 20:56:32 +000054 u_int8_t msg_ref;
55 u_int8_t pid;
56 u_int8_t dcs;
57 u_int8_t *vp;
58 u_int8_t ud_len;
59 u_int8_t *user_data;
60
61 /* interpreted */
62 u_int8_t mms:1;
Daniel Willmanne0fbec82008-12-29 00:44:41 +000063 u_int8_t sri:1;
64 u_int8_t udhi:1;
65 u_int8_t rp:1;
Harald Welte7e310b12009-03-30 20:56:32 +000066 enum sms_alphabet alphabet;
67 char dest_addr[20+1]; /* DA LV is 12 bytes max, i.e. 10 bytes BCD == 20 bytes string */
68 unsigned long validity_mins;
69 char decoded[256];
Daniel Willmanne0fbec82008-12-29 00:44:41 +000070};
71
Harald Welte7e310b12009-03-30 20:56:32 +000072/* GSM 03.40 / Chapter 9.2.3.1: TP-Message-Type-Indicator */
73#define GSM340_SMS_DELIVER_SC2MS 0x00
74#define GSM340_SMS_DELIVER_REP_MS2SC 0x00
75#define GSM340_SMS_STATUS_REP_SC2MS 0x02
76#define GSM340_SMS_COMMAND_MS2SC 0x02
77#define GSM340_SMS_SUBMIT_MS2SC 0x01
78#define GSM340_SMS_SUBMIT_REP_SC2MS 0x01
79#define GSM340_SMS_RESSERVED 0x03
80
81/* GSM 03.40 / Chapter 9.2.3.2: TP-More-Messages-to-Send */
82#define GSM340_TP_MMS_MORE 0
83#define GSM340_TP_MMS_NO_MORE 1
84
85/* GSM 03.40 / Chapter 9.2.3.3: TP-Validity-Period-Format */
86#define GSM340_TP_VPF_NONE 0
87#define GSM340_TP_VPF_RELATIVE 2
88#define GSM340_TP_VPF_ENHANCED 1
89#define GSM340_TP_VPF_ABSOLUTE 3
90
91/* GSM 03.40 / Chapter 9.2.3.4: TP-Status-Report-Indication */
92#define GSM340_TP_SRI_NONE 0
93#define GSM340_TP_SRI_PRESENT 1
94
95/* GSM 03.40 / Chapter 9.2.3.5: TP-Status-Report-Request */
96#define GSM340_TP_SRR_NONE 0
97#define GSM340_TP_SRR_REQUESTED 1
98
99/* GSM 03.40 / Chapter 9.2.3.9: TP-Protocol-Identifier */
100/* telematic interworking (001 or 111 in bits 7-5) */
101#define GSM340_TP_PID_IMPLICIT 0x00
102#define GSM340_TP_PID_TELEX 0x01
103#define GSM340_TP_PID_FAX_G3 0x02
104#define GSM340_TP_PID_FAX_G4 0x03
105#define GSM340_TP_PID_VOICE 0x04
106#define GSM430_TP_PID_ERMES 0x05
107#define GSM430_TP_PID_NATIONAL_PAGING 0x06
108#define GSM430_TP_PID_VIDEOTEX 0x07
109#define GSM430_TP_PID_TELETEX_UNSPEC 0x08
110#define GSM430_TP_PID_TELETEX_PSPDN 0x09
111#define GSM430_TP_PID_TELETEX_CSPDN 0x0a
112#define GSM430_TP_PID_TELETEX_PSTN 0x0b
113#define GSM430_TP_PID_TELETEX_ISDN 0x0c
114#define GSM430_TP_PID_TELETEX_UCI 0x0d
115#define GSM430_TP_PID_MSG_HANDLING 0x10
116#define GSM430_TP_PID_MSG_X400 0x11
117#define GSM430_TP_PID_EMAIL 0x12
118#define GSM430_TP_PID_GSM_MS 0x1f
119/* if bit 7 = 0 and bit 6 = 1 */
120#define GSM430_TP_PID_SMS_TYPE_0 0
121#define GSM430_TP_PID_SMS_TYPE_1 1
122#define GSM430_TP_PID_SMS_TYPE_2 2
123#define GSM430_TP_PID_SMS_TYPE_3 3
124#define GSM430_TP_PID_SMS_TYPE_4 4
125#define GSM430_TP_PID_SMS_TYPE_5 5
126#define GSM430_TP_PID_SMS_TYPE_6 6
127#define GSM430_TP_PID_SMS_TYPE_7 7
128#define GSM430_TP_PID_RETURN_CALL_MSG 0x1f
129#define GSM430_TP_PID_ME_DATA_DNLOAD 0x3d
130#define GSM430_TP_PID_ME_DE_PERSONAL 0x3e
131#define GSM430_TP_PID_ME_SIM_DNLOAD 0x3f
132
133/* GSM 03.38 Chapter 4: SMS Data Coding Scheme */
134#define GSM338_DCS_00_
135
136#define GSM338_DCS_1110_7BIT (0 << 2)
137#define GSM338_DCS_1111_7BIT (0 << 2)
138#define GSM338_DCS_1111_8BIT_DATA (1 << 2)
139#define GSM338_DCS_1111_CLASS0 0
140#define GSM338_DCS_1111_CLASS1_ME 1
141#define GSM338_DCS_1111_CLASS2_SIM 2
142#define GSM338_DCS_1111_CLASS3_TE 3 /* See TS 07.05 */
143
144
Daniel Willmann6fe997e2008-12-29 04:20:41 +0000145/* SMS deliver PDU */
146struct sms_deliver {
147 u_int8_t *smsc;
148 u_int8_t mti:2;
149 u_int8_t rd:1;
150 u_int8_t vpf:2;
151 u_int8_t srr:1;
152 u_int8_t udhi:1;
153 u_int8_t rp:1;
154 u_int8_t msg_ref;
155 u_int8_t *orig_addr;
156 u_int8_t pid;
157 u_int8_t dcs;
158 u_int8_t vp;
159 u_int8_t ud_len;
160 u_int8_t *user_data;
161};
162
Daniel Willmann8b3390e2008-12-28 00:31:09 +0000163struct msgb;
164
165int gsm0411_rcv_sms(struct msgb *msg);
166
Daniel Willmann6fe997e2008-12-29 04:20:41 +0000167int gsm0411_send_sms(struct gsm_lchan *lchan, struct sms_deliver *sms);
168
Holger Freythera553d092009-01-04 20:16:25 +0000169struct msgb *gsm411_msgb_alloc(void);
170int gsm0411_sendmsg(struct msgb *msg);
171
Daniel Willmann8b3390e2008-12-28 00:31:09 +0000172#endif