Welcome to mirror list, hosted at ThFree Co, Russian Federation.

SmppPduCancelSm.cs « SmppServerLib - github.com/ClusterM/smpp-sharp-lib.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: a43ba7267859dea71295e83c3dae7c0bca79c547 (plain)
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Flex.Cluster.Smpp
{
    public class SmppPduCancelSm : SmppPdu
    {
        uint offsetServiceType, offsetMessageId, offsetSourceAddrTon, offsetSourceAddrNpi, offsetSourceAddr,
            offsetDestAddrTon, offsetDestAddrNpi, offsetDestAddr;

        public string ServiceType
        {
            get { return ReadCString(offsetServiceType); }
        }
        public string MessageId
        {
            get { return ReadCString(offsetMessageId); }
        }
        public byte SourceAddrTon
        {
            get { return ReadByte(offsetSourceAddrTon); }
        }
        public byte SourceAddrNpi
        {
            get { return ReadByte(offsetSourceAddrNpi); }
        }
        public string SourceAddr
        {
            get { return ReadCString(offsetSourceAddr); }
        }
        public byte DestAddrTon
        {
            get { return ReadByte(offsetDestAddrTon); }
        }
        public byte DestAddrNpi
        {
            get { return ReadByte(offsetDestAddrNpi); }
        }
        public string DestAddr
        {
            get { return ReadCString(offsetDestAddr); }
        }

        public SmppPduCancelSm(string serviceType, string messageId, byte sourceAddrTon, byte sourceAddrNpi, string sourceAddr,
            byte destAddrTon, byte destAddrNpi, string destAddr)
            : base(SmppCommandType.cancel_sm)
        {
            if (serviceType.Length > 5) throw new ArgumentOutOfRangeException("serviceType");
            offsetServiceType = CurrentOffset;
            WriteCString(serviceType);

            if (messageId.Length > 64) throw new ArgumentOutOfRangeException("messageId");
            offsetMessageId = CurrentOffset;
            WriteCString(messageId);

            offsetSourceAddrTon = CurrentOffset;
            WriteByte(sourceAddrTon);

            offsetSourceAddrNpi = CurrentOffset;
            WriteByte(sourceAddrNpi);

            if (sourceAddr.Length > 20) throw new ArgumentOutOfRangeException("sourceAddr");
            offsetSourceAddr = CurrentOffset;
            WriteCString(sourceAddr);

            offsetDestAddrTon = CurrentOffset;
            WriteByte(destAddrTon);

            offsetDestAddrNpi = CurrentOffset;
            WriteByte(destAddrTon);

            if (destAddr.Length > 20) throw new ArgumentOutOfRangeException("destAddr");
            offsetDestAddr = CurrentOffset;
            WriteCString(destAddr);
        }

        public SmppPduCancelSm(byte[] bytes) : this(bytes, (uint)bytes.Length) { }
        public SmppPduCancelSm(byte[] bytes, uint length)
            : base(bytes, length)
        {
            if (CommandId != SmppCommandType.cancel_sm) throw new Exception("Invaid command ID");
            offsetServiceType = 12;
            offsetMessageId = FindCStringEnd(offsetServiceType);
            offsetSourceAddrTon = FindCStringEnd(offsetMessageId);
            offsetSourceAddrNpi = offsetSourceAddrTon + 1;
            offsetSourceAddr = offsetSourceAddrNpi + 1;
            offsetDestAddrTon = FindCStringEnd(offsetSourceAddr);
            offsetDestAddrNpi = offsetDestAddrTon + 1;
            offsetDestAddr = offsetDestAddrNpi + 1;
        }
    }
}