rusmpp_core/command_status.rs
1use rusmpp_macros::Rusmpp;
2
3/// Represents the means by which an ESME or MC sends an error code
4/// to its peer.
5///
6/// This field is only relevant in response PDUs. Thus PDU requests always have this
7/// field set to NULL (0x00000000).
8///
9/// The [`CommandStatus`] field of a `SMPP` message response indicates the success or failure of
10/// a `SMPP` request. It is relevant only in the `SMPP` response message and should be set to
11/// NULL in `SMPP` request messages.
12///
13/// The `SMPP` Error status codes are returned by the MC in the [`CommandStatus`] field of the
14/// `SMPP` message header and in the error_status_code field of a submit_multi_resp message.
15#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord, Default, Rusmpp)]
16#[repr(u32)]
17#[cfg_attr(feature = "arbitrary", derive(::arbitrary::Arbitrary))]
18#[cfg_attr(feature = "serde", derive(::serde::Serialize))]
19#[cfg_attr(feature = "serde-deserialize-unchecked", derive(::serde::Deserialize))]
20pub enum CommandStatus {
21 /// No Error.
22 ///
23 /// Specified in a response PDU to indicate
24 /// the success of the corresponding request
25 /// PDU.
26 #[default]
27 EsmeRok = 0x00000000,
28 /// Message Length is invalid.
29 ///
30 /// short_message field or
31 /// message_payload TLV has an invalid
32 /// length (usually too long for the given MC
33 /// or underlying network technology).
34 EsmeRinvmsglen = 0x00000001,
35 /// Command Length is invalid.
36 ///
37 /// PDU length is considered invalid, either
38 /// because the value is too short or too
39 /// large for the given PDU.
40 EsmeRinvcmdlen = 0x00000002,
41 /// Invalid Command ID.
42 ///
43 /// Command ID is not recognized, either
44 /// because the operation is not supported
45 /// or unknown.
46 EsmeRinvcmdid = 0x00000003,
47 /// Incorrect BIND Status for given command.
48 ///
49 /// PDU has been sent in the wrong session
50 /// state. E.g. sending a submit_sm without
51 /// first establishing a Bound_TX session
52 /// state.
53 EsmeRinvbndsts = 0x00000004,
54 /// ESME Already in Bound State.
55 ///
56 /// A bind request has been issued within a
57 /// session that is already bound.
58 EsmeRalybnd = 0x00000005,
59 /// Invalid Priority Flag.
60 ///
61 /// Priority flag contains an illegal or
62 /// unsupported value.
63 EsmeRinvprtflg = 0x00000006,
64 /// Invalid Registered Delivery Flag.
65 ///
66 /// Registered field contains an invalid
67 /// setting.
68 EsmeRinvregdlvflg = 0x00000007,
69 /// System Error.
70 ///
71 /// MC system error indicating that all or part
72 /// of the MC is currently unavailable. This
73 /// can be returned in any response PDU.
74 EsmeRsyserr = 0x00000008,
75 /// Invalid Source Address.
76 ///
77 /// Source address of message is
78 /// considered invalid. Usually this is
79 /// because the field is either too long or
80 /// contains invalid characters.
81 EsmeRinvsrcadr = 0x0000000A,
82 /// Invalid Destination Address.
83 ///
84 /// Destination address of message is
85 /// considered invalid. Usually this is
86 /// because the field is either zero length,
87 /// too long or contains invalid characters.
88 EsmeRinvdstadr = 0x0000000B,
89 /// Message ID is invalid.
90 ///
91 /// Message ID specified in cancel_sm,
92 /// query_sm or other operations is invalid.
93 EsmeRinvmsgid = 0x0000000C,
94 /// Bind Failed.
95 ///
96 /// A generic failure scenario for a bind
97 /// attempt. This may be due to a
98 /// provisioning error, incorrect password or
99 /// other reason. A MC will typically return
100 /// this error for an invalid system_id,
101 /// system_type, password or other attribute
102 /// that may cause a bind failure.
103 EsmeRbindfail = 0x0000000D,
104 /// Invalid Password.
105 ///
106 /// Password field in bind PDU is invalid.
107 /// This is usually returned when the length
108 /// is too short or too long. It is not supposed
109 /// to be returned when the ESME has
110 /// specified the incorrect password.
111 EsmeRinvpaswd = 0x0000000E,
112 /// Invalid System ID.
113 ///
114 /// The System ID field in bind PDU is
115 /// invalid. This is usually returned when the
116 /// length is too short or too long. It is not
117 /// supposed to be returned when the ESME
118 /// has specified the incorrect system id.
119 EsmeRinvsysid = 0x0000000F,
120 /// Cancel SM Failed.
121 ///
122 /// Generic failure error for cancel_sm
123 /// operation.
124 EsmeRcancelfail = 0x00000011,
125 /// Replace SM Failed.
126 ///
127 /// Generic failure for replace_sm operation.
128 EsmeRreplacefail = 0x00000013,
129 /// Message Queue Full.
130 ///
131 /// Used to indicate a resource error within
132 /// the MC. This may be interpreted as the
133 /// maximum number of messages
134 /// addressed to a single destination or a
135 /// global maximum of undelivered
136 /// messages within the MC.
137 EsmeRmsgqful = 0x00000014,
138 /// Invalid Service Type.
139 ///
140 /// Service type is rejected either because it
141 /// is not recognized by the MC or because
142 /// its length is not within the defined range.
143 EsmeRinvsertyp = 0x00000015,
144 /// Invalid number of destinations.
145 ///
146 /// The number_of_dests field in the
147 /// submit_multi PDU is invalid.
148 EsmeRinvnumdests = 0x00000033,
149 /// Invalid Distribution List name.
150 ///
151 /// The dl_name field specified in the
152 /// submit_multi PDU is either invalid, or
153 /// non-existent.
154 EsmeRinvdlname = 0x00000034,
155 /// Destination flag is invalid (submit_multi).
156 ///
157 /// The dest_flag field in the submit_multi
158 /// PDU has been encoded with an invalid
159 /// setting.
160 EsmeRinvdestflag = 0x00000040,
161 /// Submit w/replace functionality has been
162 /// requested where it is either unsupported
163 /// or inappropriate for the particular MC.
164 /// This can typically occur with submit_multi
165 /// where the context of “replace if present”
166 /// is often a best effort operation and MCs
167 /// may not support the feature in
168 /// submit_multi.
169 ///
170 /// Another reason for returning this error
171 /// would be where the feature has been
172 /// denied to an ESME.
173 EsmeRinvsubrep = 0x00000042,
174 /// Invalid esm_class field data.
175 ///
176 /// The esm_class field has an unsupported
177 /// setting.
178 EsmeRinvesmclass = 0x00000043,
179 /// Cannot Submit to Distribution List.
180 ///
181 /// Distribution lists are not supported, are
182 /// denied or unavailable.
183 EsmeRcntsubdl = 0x00000044,
184 /// submit_sm, data_sm or submit_multi
185 /// failed.
186 ///
187 /// Generic failure error for submission
188 /// operations.
189 EsmeRsubmitfail = 0x00000045,
190 /// Invalid Source address TON.
191 ///
192 /// The source TON of the message is either
193 /// invalid or unsupported.
194 EsmeRinvsrcton = 0x00000048,
195 /// Invalid Source address NPI.
196 ///
197 /// The source NPI of the message is either
198 /// invalid or unsupported.
199 EsmeRinvsrcnpi = 0x00000049,
200 /// Invalid Destination address TON.
201 ///
202 /// The destination TON of the message is
203 /// either invalid or unsupported.
204 EsmeRinvdstton = 0x00000050,
205 /// Invalid Destination address NPI.
206 ///
207 /// The destination NPI of the message is
208 /// either invalid or unsupported.
209 EsmeRinvdstnpi = 0x00000051,
210 /// Invalid system_type field.
211 ///
212 /// The System type of bind PDU has an
213 /// incorrect length or contains illegal
214 /// characters.
215 EsmeRinvsystyp = 0x00000053,
216 /// Invalid replace_if_present flag.
217 ///
218 /// The replace_if_present flag has been
219 /// encoded with an invalid or unsupported
220 /// setting.
221 EsmeRinvrepflag = 0x00000054,
222 /// Invalid number of messages.
223 EsmeRinvnummsgs = 0x00000055,
224 /// Throttling error (ESME has exceeded
225 /// allowed message limits).
226 ///
227 /// This type of error is usually returned
228 /// where an ESME has exceeded a
229 /// predefined messaging rate restriction
230 /// applied by the operator.
231 EsmeRthrottled = 0x00000058,
232 /// Invalid Scheduled Delivery Time.
233 ///
234 /// Scheduled delivery time is either the
235 /// incorrect length or is invalid.
236 EsmeRinvsched = 0x00000061,
237 /// Invalid message validity period (Expiry
238 /// time).
239 ///
240 /// Expiry time is either the incorrect length
241 /// or is invalid.
242 EsmeRinvexpiry = 0x00000062,
243 /// Predefined Message ID is Invalid or
244 /// specified predefined message was not
245 /// found.
246 ///
247 /// The default (pre-defined) message id is
248 /// either invalid or refers to a non-existent
249 /// pre-defined message.
250 EsmeRinvdftmsgid = 0x00000063,
251 /// ESME Receiver Temporary App Error
252 /// Code.
253 ///
254 /// Rx or Trx ESME is unable to process a
255 /// delivery due to a temporary problem and
256 /// is requesting that the message be retried
257 /// at some future point.
258 EsmeRxTAppn = 0x00000064,
259 /// ESME Receiver Permanent App Error
260 /// Code.
261 ///
262 /// Rx or Trx ESME is unable to process a
263 /// delivery due to a permanent problem
264 /// relating to the given destination address
265 /// and is requesting that the message and
266 /// all other messages queued to the same
267 /// destination should NOT be retried any
268 /// further.
269 EsmeRxPAppn = 0x00000065,
270 /// ESME Receiver Reject Message Error
271 /// Code.
272 ///
273 /// Rx or Trx ESME is unable to process a
274 /// delivery due to a problem relating to the
275 /// given message and is requesting that the
276 /// message is rejected and not retried. This
277 /// does not affect other messages queued
278 /// for the same ESME or destination
279 /// address.
280 EsmeRxRAppn = 0x00000066,
281 /// query_sm request failed.
282 ///
283 /// Generic failure scenario for a query
284 /// request.
285 EsmeRqueryfail = 0x00000067,
286 /// Error in the optional part of the PDU
287 /// Body.
288 ///
289 /// Decoding of TLVs (Optional Parameters)
290 /// has resulted in one of the following
291 /// scenarios:
292 /// • PDU decoding completed with 1-
293 /// 3 octets of data remaining,
294 /// indicating a corrupt PDU.
295 ///
296 /// • A TLV indicated a length that
297 /// was not present in the remaining
298 /// PDU data (e.g. a TLV specifying
299 /// a length of 10 where only 6
300 /// octets of PDU data remain).
301 EsmeRinvtlvstream = 0x000000C0,
302 /// TLV not allowed.
303 ///
304 /// A TLV has been used in an invalid
305 /// context, either inappropriate or
306 /// deliberately rejected by the operator.
307 EsmeRtlvnotallwd = 0x000000C1,
308 /// Invalid Parameter Length.
309 ///
310 /// A TLV has specified a length that is
311 /// considered invalid
312 EsmeRinvtlvlen = 0x000000C2,
313 /// Expected TLV missing.
314 ///
315 /// A mandatory TLV such as the
316 /// message_payload TLV within a data_sm
317 /// PDU is missing.
318 EsmeRmissingtlv = 0x000000C3,
319 /// Invalid TLV Value.
320 ///
321 /// The data content of a TLV is invalid and
322 /// cannot be decoded.
323 EsmeRinvtlvval = 0x000000C4,
324 /// Transaction Delivery Failure.
325 ///
326 /// A data_sm or submit_sm operation
327 /// issued in transaction mode has resulted
328 /// in a failed delivery.
329 EsmeRdeliveryfailure = 0x000000FE,
330 /// Unknown Error.
331 ///
332 /// Some unexpected error has occurred.
333 EsmeRunknownerr = 0x000000FF,
334 /// ESME Not authorized to use specified
335 /// service_type.
336 ///
337 /// Specific service_type has been denied
338 /// for use by the given ESME.
339 EsmeRsertypunauth = 0x00000100,
340 /// ESME Prohibited from using specified
341 /// operation.
342 ///
343 /// The PDU request was recognized but is
344 /// denied to the ESME.
345 EsmeRprohibited = 0x00000101,
346 /// Specified service_type is unavailable.
347 ///
348 /// Due to a service outage within the MC, a
349 /// service is unavailable.
350 EsmeRsertypunavail = 0x00000102,
351 /// Specified service_type is denied.
352 ///
353 /// Due to inappropriate message content
354 /// wrt. the selected service_type.
355 EsmeRsertypdenied = 0x00000103,
356 /// Invalid Data Coding Scheme.
357 ///
358 /// Specified DCS is invalid or MC does not
359 /// support it.
360 EsmeRinvdcs = 0x00000104,
361 /// Source Address Sub unit is Invalid.
362 EsmeRinvsrcaddrsubunit = 0x00000105,
363 /// Destination Address Sub unit is Invalid.
364 EsmeRinvdstaddrsubunit = 0x00000106,
365 /// Broadcast Frequency Interval is invalid.
366 ///
367 /// Specified value is either invalid or not
368 /// supported.
369 EsmeRinvbcastfreqint = 0x00000107,
370 /// Broadcast Alias Name is invalid.
371 ///
372 /// Specified value has an incorrect length
373 /// or contains invalid/unsupported
374 /// characters.
375 EsmeRinvbcastaliasName = 0x00000108,
376 /// Broadcast Area Format is invalid.
377 ///
378 /// Specified value violates protocol or is
379 /// unsupported.
380 EsmeRinvbcastareafmt = 0x00000109,
381 /// Number of Broadcast Areas is invalid.
382 ///
383 /// Specified value violates protocol or is
384 /// unsupported.
385 EsmeRinvnumbcastAreas = 0x0000010A,
386 /// Broadcast Content Type is invalid.
387 ///
388 /// Specified value violates protocol or is
389 /// unsupported.
390 EsmeRinvbcastcnttype = 0x0000010B,
391 /// Broadcast Message Class is invalid.
392 ///
393 /// Specified value violates protocol or is
394 /// unsupported.
395 EsmeRinvbcastmsgclass = 0x0000010C,
396 /// broadcast_sm operation failed.
397 EsmeRbcastfail = 0x0000010D,
398 /// query_broadcast_sm operation failed.
399 EsmeRbcastqueryfail = 0x0000010E,
400 /// cancel_broadcast_sm operation failed.
401 EsmeRbcastcancelfail = 0x0000010F,
402 /// Number of Repeated Broadcasts is
403 /// invalid.
404 ///
405 /// Specified value violates protocol or is
406 /// unsupported.
407 EsmeRinvbcastRep = 0x00000110,
408 /// Broadcast Service Group is invalid.
409 ///
410 /// Specified value violates protocol or is
411 /// unsupported.
412 EsmeRinvbcastsrvgrp = 0x00000111,
413 /// Broadcast Channel Indicator is invalid.
414 ///
415 /// Specified value violates protocol or is
416 /// unsupported.
417 EsmeRinvbcastchanind = 0x00000112,
418 Other(u32),
419}
420
421#[cfg(test)]
422mod tests {
423 use super::*;
424
425 #[test]
426 fn into() {
427 let status: u32 = CommandStatus::EsmeRok.into();
428 assert_eq!(status, 0x00000000);
429
430 let status: u32 = CommandStatus::Other(0x00000115).into();
431 assert_eq!(status, 0x00000115);
432 }
433
434 #[test]
435 fn from() {
436 let status = CommandStatus::from(0x00000000);
437 assert_eq!(status, CommandStatus::EsmeRok);
438
439 let status = CommandStatus::from(0x00000115);
440 assert_eq!(status, CommandStatus::Other(0x00000115));
441 }
442
443 #[test]
444 fn encode_decode() {
445 #[cfg(feature = "alloc")]
446 crate::tests::owned::encode_decode_test_instances::<CommandStatus>();
447 crate::tests::borrowed::encode_decode_test_instances::<CommandStatus>();
448 }
449}