forked from fiorix/go-smpp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
types.go
410 lines (356 loc) · 8.94 KB
/
types.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
// Copyright 2015 go-smpp authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package pdu
import (
"github.com/fiorix/go-smpp/smpp/pdu/pdufield"
"github.com/fiorix/go-smpp/smpp/pdu/pdutlv"
)
// PDU Types.
const (
GenericNACKID ID = 0x80000000
BindReceiverID ID = 0x00000001
BindReceiverRespID ID = 0x80000001
BindTransmitterID ID = 0x00000002
BindTransmitterRespID ID = 0x80000002
QuerySMID ID = 0x00000003
QuerySMRespID ID = 0x80000003
SubmitSMID ID = 0x00000004
SubmitSMRespID ID = 0x80000004
DeliverSMID ID = 0x00000005
DeliverSMRespID ID = 0x80000005
UnbindID ID = 0x00000006
UnbindRespID ID = 0x80000006
ReplaceSMID ID = 0x00000007
ReplaceSMRespID ID = 0x80000007
CancelSMID ID = 0x00000008
CancelSMRespID ID = 0x80000008
BindTransceiverID ID = 0x00000009
BindTransceiverRespID ID = 0x80000009
OutbindID ID = 0x0000000B
EnquireLinkID ID = 0x00000015
EnquireLinkRespID ID = 0x80000015
SubmitMultiID ID = 0x00000021
SubmitMultiRespID ID = 0x80000021
AlertNotificationID ID = 0x00000102
DataSMID ID = 0x00000103
DataSMRespID ID = 0x80000103
)
// GenericNACK PDU.
type GenericNACK struct{ *codec }
func newGenericNACK(hdr *Header) *codec {
return &codec{h: hdr}
}
// NewGenericNACK creates and initializes a GenericNACK PDU.
func NewGenericNACK() Body {
b := newGenericNACK(&Header{ID: GenericNACKID})
b.init()
return b
}
// Bind PDU.
type Bind struct{ *codec }
func newBind(hdr *Header) *codec {
return &codec{
h: hdr,
l: pdufield.List{
pdufield.SystemID,
pdufield.Password,
pdufield.SystemType,
pdufield.InterfaceVersion,
pdufield.AddrTON,
pdufield.AddrNPI,
pdufield.AddressRange,
}}
}
// NewBindReceiver creates a new Bind PDU.
func NewBindReceiver() Body {
b := newBind(&Header{ID: BindReceiverID})
b.init()
return b
}
// NewBindTransceiver creates a new Bind PDU.
func NewBindTransceiver() Body {
b := newBind(&Header{ID: BindTransceiverID})
b.init()
return b
}
// NewBindTransmitter creates a new Bind PDU.
func NewBindTransmitter() Body {
b := newBind(&Header{ID: BindTransmitterID})
b.init()
return b
}
// BindResp PDU.
type BindResp struct{ *codec }
func newBindResp(hdr *Header) *codec {
return &codec{
h: hdr,
l: pdufield.List{pdufield.SystemID},
}
}
// NewBindReceiverResp creates and initializes a new BindResp PDU.
func NewBindReceiverResp() Body {
b := newBindResp(&Header{ID: BindReceiverRespID})
b.init()
return b
}
// NewBindTransceiverResp creates and initializes a new BindResp PDU.
func NewBindTransceiverResp() Body {
b := newBindResp(&Header{ID: BindTransceiverRespID})
b.init()
return b
}
// NewBindTransmitterResp creates and initializes a new BindResp PDU.
func NewBindTransmitterResp() Body {
b := newBindResp(&Header{ID: BindTransmitterRespID})
b.init()
return b
}
// QuerySM PDU.
type QuerySM struct{ *codec }
func newQuerySM(hdr *Header) *codec {
return &codec{
h: hdr,
l: pdufield.List{
pdufield.MessageID,
pdufield.SourceAddrTON,
pdufield.SourceAddrNPI,
pdufield.SourceAddr,
},
}
}
// NewQuerySM creates and initializes a new QuerySM PDU.
func NewQuerySM() Body {
b := newQuerySM(&Header{ID: QuerySMID})
b.init()
return b
}
// QuerySMResp PDU.
type QuerySMResp struct{ *codec }
func newQuerySMResp(hdr *Header) *codec {
return &codec{
h: hdr,
l: pdufield.List{
pdufield.MessageID,
pdufield.FinalDate,
pdufield.MessageState,
pdufield.ErrorCode,
},
}
}
// NewQuerySMResp creates and initializes a new QuerySMResp PDU.
func NewQuerySMResp() Body {
b := newQuerySMResp(&Header{ID: QuerySMRespID})
b.init()
return b
}
// SubmitSM PDU.
type SubmitSM struct{ *codec }
func newSubmitSM(hdr *Header) *codec {
return &codec{
h: hdr,
l: pdufield.List{
pdufield.ServiceType,
pdufield.SourceAddrTON,
pdufield.SourceAddrNPI,
pdufield.SourceAddr,
pdufield.DestAddrTON,
pdufield.DestAddrNPI,
pdufield.DestinationAddr,
pdufield.ESMClass,
pdufield.ProtocolID,
pdufield.PriorityFlag,
pdufield.ScheduleDeliveryTime,
pdufield.ValidityPeriod,
pdufield.RegisteredDelivery,
pdufield.ReplaceIfPresentFlag,
pdufield.DataCoding,
pdufield.SMDefaultMsgID,
pdufield.SMLength,
pdufield.ShortMessage,
},
}
}
// NewSubmitSM creates and initializes a new SubmitSM PDU.
func NewSubmitSM(fields pdutlv.Fields) Body {
b := newSubmitSM(&Header{ID: SubmitSMID})
b.init()
for tag, value := range fields {
b.t.Set(tag, value)
}
return b
}
// SubmitSMResp PDU.
type SubmitSMResp struct{ *codec }
func newSubmitSMResp(hdr *Header) *codec {
return &codec{
h: hdr,
l: pdufield.List{
pdufield.MessageID,
},
}
}
// NewSubmitSMResp creates and initializes a new SubmitSMResp PDU.
func NewSubmitSMResp() Body {
b := newSubmitSMResp(&Header{ID: SubmitSMRespID})
b.init()
return b
}
// SubmitMulti PDU.
type SubmitMulti struct{ *codec }
func newSubmitMulti(hdr *Header) *codec {
return &codec{
h: hdr,
l: pdufield.List{
pdufield.ServiceType,
pdufield.SourceAddrTON,
pdufield.SourceAddrNPI,
pdufield.SourceAddr,
pdufield.NumberDests,
pdufield.DestinationList, // contains DestFlag, DestAddrTON and DestAddrNPI for each address
pdufield.ESMClass,
pdufield.ProtocolID,
pdufield.PriorityFlag,
pdufield.ScheduleDeliveryTime,
pdufield.ValidityPeriod,
pdufield.RegisteredDelivery,
pdufield.ReplaceIfPresentFlag,
pdufield.DataCoding,
pdufield.SMDefaultMsgID,
pdufield.SMLength,
pdufield.ShortMessage,
},
}
}
// NewSubmitMulti creates and initializes a new SubmitMulti PDU.
func NewSubmitMulti(fields pdutlv.Fields) Body {
b := newSubmitMulti(&Header{ID: SubmitMultiID})
b.init()
for tag, value := range fields {
b.t.Set(tag, value)
}
return b
}
// SubmitMultiResp PDU.
type SubmitMultiResp struct{ *codec }
func newSubmitMultiResp(hdr *Header) *codec {
return &codec{
h: hdr,
l: pdufield.List{
pdufield.MessageID,
pdufield.NoUnsuccess,
pdufield.UnsuccessSme,
},
}
}
// NewSubmitMultiResp creates and initializes a new SubmitMultiResp PDU.
func NewSubmitMultiResp() Body {
b := newSubmitMultiResp(&Header{ID: SubmitMultiRespID})
b.init()
return b
}
// DeliverSM PDU.
type DeliverSM struct{ *codec }
func newDeliverSM(hdr *Header) *codec {
return &codec{
h: hdr,
l: pdufield.List{
pdufield.ServiceType,
pdufield.SourceAddrTON,
pdufield.SourceAddrNPI,
pdufield.SourceAddr,
pdufield.DestAddrTON,
pdufield.DestAddrNPI,
pdufield.DestinationAddr,
pdufield.ESMClass,
pdufield.ProtocolID,
pdufield.PriorityFlag,
pdufield.ScheduleDeliveryTime,
pdufield.ValidityPeriod,
pdufield.RegisteredDelivery,
pdufield.ReplaceIfPresentFlag,
pdufield.DataCoding,
pdufield.SMDefaultMsgID,
pdufield.SMLength,
pdufield.ShortMessage,
},
}
}
// NewDeliverSM creates and initializes a new DeliverSM PDU.
func NewDeliverSM() Body {
b := newDeliverSM(&Header{ID: DeliverSMID})
b.init()
return b
}
// DeliverSMResp PDU.
type DeliverSMResp struct{ *codec }
func newDeliverSMResp(hdr *Header) *codec {
return &codec{
h: hdr,
l: pdufield.List{
pdufield.MessageID,
},
}
}
// NewDeliverSMResp creates and initializes a new DeliverSMResp PDU.
func NewDeliverSMResp() Body {
b := newDeliverSMResp(&Header{ID: DeliverSMRespID})
b.init()
return b
}
// NewDeliverSMRespSeq creates and initializes a new DeliverSMResp PDU for a specific seq.
func NewDeliverSMRespSeq(seq uint32) Body {
b := newDeliverSMResp(&Header{ID: DeliverSMRespID, Seq: seq})
b.init()
return b
}
// Unbind PDU.
type Unbind struct{ *codec }
func newUnbind(hdr *Header) *codec {
return &codec{h: hdr}
}
// NewUnbind creates and initializes a Unbind PDU.
func NewUnbind() Body {
b := newUnbind(&Header{ID: UnbindID})
b.init()
return b
}
// UnbindResp PDU.
type UnbindResp struct{ *codec }
func newUnbindResp(hdr *Header) *codec {
return &codec{h: hdr}
}
// NewUnbindResp creates and initializes a UnbindResp PDU.
func NewUnbindResp() Body {
b := newUnbindResp(&Header{ID: UnbindRespID})
b.init()
return b
}
// EnquireLink PDU.
type EnquireLink struct{ *codec }
func newEnquireLink(hdr *Header) *codec {
return &codec{h: hdr}
}
// NewEnquireLink creates and initializes a EnquireLink PDU.
func NewEnquireLink() Body {
b := newEnquireLink(&Header{ID: EnquireLinkID})
b.init()
return b
}
// EnquireLinkResp PDU.
type EnquireLinkResp struct{ *codec }
func newEnquireLinkResp(hdr *Header) *codec {
return &codec{h: hdr}
}
// NewEnquireLinkResp creates and initializes a EnquireLinkResp PDU.
func NewEnquireLinkResp() Body {
b := newEnquireLinkResp(&Header{ID: EnquireLinkRespID})
b.init()
return b
}
// NewEnquireLinkRespSeq creates and initializes a EnquireLinkResp PDU for a specific seq.
func NewEnquireLinkRespSeq(seq uint32) Body {
b := newEnquireLinkResp(&Header{ID: EnquireLinkRespID, Seq: seq})
b.init()
return b
}