Esempio n. 1
0
        internal SmppQuerySmRes(ByteBuilder bb)
        {
            _Header = new SmppHeader(bb);
            int lastBytePosition = 0x10;

            _Body = new BodyPdu(bb, ref lastBytePosition);
        }
Esempio n. 2
0
 public SmppDeliverSmReq(ByteBuilder bb) {
   _Header = new SmppHeader(bb);
   int startPosition = 0x10;
   _Body = new BodyPdu(bb, ref startPosition);
   if (bb.Count > startPosition)
     _Tlv = new SmppTlv(bb, startPosition);
 }
Esempio n. 3
0
        internal SmppQuerySmReq(ByteBuilder bb)
        {
            int startPosition = 0x10;

            _Header = new SmppHeader(bb);
            _Body   = new BodyPdu(bb, ref startPosition);
        }
Esempio n. 4
0
 internal SmppBindRes(ByteBuilder bb) {
   int startPosition = 0x10;
   _Header = new SmppHeader(bb);
   if (bb.Count > 0x10)
     _Body = new BodyPdu(bb, ref startPosition);
   if (bb.Count > startPosition)
     _Tlv = new SmppTlv(bb, startPosition);
 }
Esempio n. 5
0
        internal SmppDeliverSmRes(ByteBuilder bb)
        {
            int startPosition = 0x10;

            _Header = new SmppHeader(bb);
            _Body   = new BodyPdu(bb, ref startPosition);
            _Tlv    = new SmppTlv(bb, startPosition);
        }
Esempio n. 6
0
        public SmppDeliverSmReq(ByteBuilder bb)
        {
            _Header = new SmppHeader(bb);
            int startPosition = 0x10;

            _Body = new BodyPdu(bb, ref startPosition);
            if (bb.Count > startPosition)
            {
                _Tlv = new SmppTlv(bb, startPosition);
            }
        }
Esempio n. 7
0
 internal SmppSubmitSmRes(ByteBuilder bb) {
   if (bb.Count >= 0x10) {
     _Header = new SmppHeader(bb);
     if (bb.Count != 0x10) {
       int lastBytePosition = 0x10;
       _Body = new BodyPdu(bb, ref lastBytePosition);
       if (bb.Count >= lastBytePosition)
         _Tlv = new SmppTlv(bb, lastBytePosition);
     }
   }
 }
Esempio n. 8
0
        internal SmppBindRes(ByteBuilder bb)
        {
            int startPosition = 0x10;

            _Header = new SmppHeader(bb);
            if (bb.Count > 0x10)
            {
                _Body = new BodyPdu(bb, ref startPosition);
            }
            if (bb.Count > startPosition)
            {
                _Tlv = new SmppTlv(bb, startPosition);
            }
        }
Esempio n. 9
0
 internal SmppSubmitSmRes(ByteBuilder bb)
 {
     if (bb.Count >= 0x10)
     {
         _Header = new SmppHeader(bb);
         if (bb.Count != 0x10)
         {
             int lastBytePosition = 0x10;
             _Body = new BodyPdu(bb, ref lastBytePosition);
             if (bb.Count >= lastBytePosition)
             {
                 _Tlv = new SmppTlv(bb, lastBytePosition);
             }
         }
     }
 }
Esempio n. 10
0
 internal static byte[] GetPduByteArray(ref SmppHeader Header, ISmppBasic Body, SmppTlv Tlv) {
   byte[] c = null;
   byte[] buffer2 = null;
   byte[] arrayObj = null;
   buffer2 = Body.ToByteArray();
   Header.CommandLength = 0x10 + buffer2.Length;
   if (Tlv != null) {
     arrayObj = Tlv.ToByteArray();
     Header.CommandLength += arrayObj.Length;
   }
   c = Header.ToByteArray();
   var builder = new ByteBuilder((c.Length + buffer2.Length) + GetArrayLength(arrayObj));
   builder.AddRange(c);
   builder.AddRange(buffer2);
   if (arrayObj != null)
     builder.AddRange(arrayObj);
   return builder.ToArray();
 }
Esempio n. 11
0
    void ProcessPdu(Guid ConnGuid, ByteBuilder bb) {
      var header = new SmppHeader(bb);
      if (bb.Count > 0x10)
        bb.ToArray(0x10, bb.Count - 0x10);
      if (((header.CommandId == 2) || (header.CommandId == 1)) || (header.CommandId == 9))
        try {
          var pdu = new SmppBindReq(bb);
          if (OnBindReq != null)
            OnBindReq(this, new SmppBindEventArgs(ConnGuid, pdu));
        } catch {}
      else {
        int commandId = header.CommandId;
        if (commandId <= -2147483627)
          switch (commandId) {
            case -2147483643: {
              var res = new SmppDeliverSmRes(bb);
              if (OnDeliverSmRes != null)
                OnDeliverSmRes(this, new SmppDeliverSmResEventArgs(ConnGuid, res));
              return;
            }
            case -2147483627: {
              var res2 = new SmppEnquireLinkRes(bb);
              if (OnEnquireLinkRes != null) {
                OnEnquireLinkRes(this, new SmppEnquireLinkResEventArgs(ConnGuid, res2));
                return;
              }
              break;
            }
          }
        else
          switch (commandId) {
            case 3: {
              var req4 = new SmppQuerySmReq(bb);
              if (OnQuerySmReq != null)
                OnQuerySmReq(this, new SmppQuerySmEventArgs(req4, ConnGuid));
              return;
            }
            case 4: {
              var req2 = new SmppSubmitSmReq(bb);
              if (OnSubmitSmReq != null)
                OnSubmitSmReq(this, new SmppSubmitSmEventArgs(ConnGuid, req2));
              return;
            }
            case 5:
              return;

            case 6: {
              var req5 = new SmppUnBindReq(bb);
              if (OnUnBindReq != null)
                OnUnBindReq(this, new SmppUnBindEventArgs(ConnGuid, req5));
              return;
            }
            case 0x15: {
              var req3 = new SmppEnquireLinkReq(bb);
              if (OnEnquireLinkReq != null)
                OnEnquireLinkReq(this, new SmppEnquireLinkEventArgs(ConnGuid, req3));
              return;
            }
            default:
              return;
          }
      }
    }
Esempio n. 12
0
 internal SmppUnBindReq(ByteBuilder bb) {
   _Header = new SmppHeader(bb);
 }
Esempio n. 13
0
 public SmppEnquireLinkReq(SmppHeader Header) {
   _Header = Header;
 }
Esempio n. 14
0
 public SmppDataSmReq(SmppHeader Header, BodyPdu Body, SmppTlv Tlv)
 {
     _Header = Header;
     _Body   = Body;
     _Tlv    = Tlv;
 }
Esempio n. 15
0
 public SmppGenericNackReq(SmppHeader Header) {
   _Header = Header;
 }
Esempio n. 16
0
 public SmppUnBindReq()
 {
     _Header = new SmppHeader(6, 0);
 }
Esempio n. 17
0
 public SmppDeliverSmRes(int SequenceNumber, string MessageId) {
   _Header = new SmppHeader(-2147483643, SequenceNumber);
   _Body = new BodyPdu(MessageId);
 }
Esempio n. 18
0
 public SmppSubmitSmRes(int SequenceNumber) {
   _Header = new SmppHeader(-2147483644, SequenceNumber);
   _Body = new BodyPdu();
 }
Esempio n. 19
0
 public SmppDataSmReq(SmppHeader Header, BodyPdu Body, SmppTlv Tlv) {
   _Header = Header;
   _Body = Body;
   _Tlv = Tlv;
 }
Esempio n. 20
0
 internal SmppDeliverSmRes(ByteBuilder bb) {
   int startPosition = 0x10;
   _Header = new SmppHeader(bb);
   _Body = new BodyPdu(bb, ref startPosition);
   _Tlv = new SmppTlv(bb, startPosition);
 }
Esempio n. 21
0
 public SmppBindReq(SmppHeader Header, BodyPdu Body)
 {
     _Header = Header;
     _Body   = Body;
 }
Esempio n. 22
0
 void TcpConnection_DataReceived(object sender, SockClient.DataReceivedEventArgs e) {
   LastReceptionTime = DateTime.Now;
   while (TcpConnection.ReadSize() >= 0x10) {
     int bytes = SmppConverter.FromByteArrayToInt32(TcpConnection.PeekBytes(4));
     if (bytes > Settings.MaxPduSize) {
       TcpConnection.Disconnect();
       return;
     }
     if (bytes > TcpConnection.ReadSize())
       break;
     var bb = new ByteBuilder(TcpConnection.ReadByteArray(bytes, 0));
     var header = new SmppHeader(bb);
     SmppAsyncObject asyncObject = FindAsyncObject(header.SequenceNumber);
     if (asyncObject != null) {
       asyncObject.PduRes = bb;
       if (asyncObject.mre != null)
         asyncObject.mre.Set();
       else if (asyncObject.Callback != null)
         new SmppCompletionCallbackHandler(ProcessAsyncPdu).BeginInvoke(asyncObject,
                                                                        SmppAsyncObject.SmppAsyncCompleted.Response,
                                                                        null, null);
     } else
       ProcessPdu(bb);
   }
 }
Esempio n. 23
0
 void SendReqPdu(ISmppPdu RequestPdu, ref SmppAsyncObject AsyncObject) {
   if (RequestPdu.Header.SequenceNumber == 0)
     RequestPdu.Header.SequenceNumber = GetSequenceNumber();
   AsyncObject.mre = new ManualResetEvent(false);
   AddPendingResponse(RequestPdu.Header.SequenceNumber, AsyncObject);
   if (TcpConnection.Send(RequestPdu.ToByteArray()) <= 0) {
     RemovePendingResponse(RequestPdu.Header.SequenceNumber);
     TcpConnection.Disconnect();
     throw new Exception("Invalid connection State");
   }
   if (!AsyncObject.mre.WaitOne(Settings.Timeout, false) || (AsyncObject.PduRes == null)) {
     RemovePendingResponse(RequestPdu.Header.SequenceNumber);
     if (Settings.DisconnectOnTimeout)
       TcpConnection.Disconnect();
     throw new SmppTimeOutException();
   }
   var header = new SmppHeader(AsyncObject.PduRes);
   if (header.CommandId == -2147483648) {
     RemovePendingResponse(RequestPdu.Header.SequenceNumber);
     throw new SmppGenericNackException(SmppStatusCodes.GetDescription(RequestPdu.Header.CommandStatus));
   }
   RemovePendingResponse(RequestPdu.Header.SequenceNumber);
 }
Esempio n. 24
0
    void ProcessPdu(ByteBuilder bb) {
      var header = new SmppHeader(bb);
      switch (header.CommandId) {
        case 5: {
          var pdu = new SmppDeliverSmReq(bb);
          RaiseDeliverSmReq(new SmppDeliverSmEventArgs(pdu));
          return;
        }
        case 6:
          TcpConnection.Disconnect();
          return;

        case 0x15:
          EnquireLinkRes(new SmppEnquireLinkRes(new SmppHeader(0x10, -2147483627, 0, header.SequenceNumber)));
          RaiseEnquireLinkReq(new SmppEnquireLinkEventArgs(ClientGuid, new SmppEnquireLinkReq(header)));
          return;
      }
    }
Esempio n. 25
0
 internal SmppCancelSmRes(ByteBuilder bb)
 {
     _Header = new SmppHeader(bb);
 }
Esempio n. 26
0
 public SmppEnquireLinkRes(SmppHeader Header)
 {
     _Header = Header;
 }
Esempio n. 27
0
 public SmppQuerySmReq(int SequenceNumber, BodyPdu Body)
 {
     _Header = new SmppHeader(3, SequenceNumber);
     _Body   = Body;
 }
Esempio n. 28
0
 public SmppQuerySmRes(SmppHeader Header)
 {
     _Header = Header;
     _Body   = new BodyPdu();
 }
Esempio n. 29
0
 public SmppBindRes(SmppHeader Header)
 {
     _Header = Header;
     _Body   = new BodyPdu();
 }
Esempio n. 30
0
 internal SmppUnBindReq(ByteBuilder bb)
 {
     _Header = new SmppHeader(bb);
 }
Esempio n. 31
0
 internal SmppCancelSmRes(ByteBuilder bb) {
   _Header = new SmppHeader(bb);
 }
Esempio n. 32
0
 internal SmppEnquireLinkReq(ByteBuilder bb) {
   _Header = new SmppHeader(bb);
 }
Esempio n. 33
0
 public SmppCancelSmReq(SmppHeader Header, BodyPdu Body)
 {
     _Header = Header;
     _Body   = Body;
 }
Esempio n. 34
0
 public SmppUnknownPduEventArgs(SmppHeader Header, byte[] BodyByteArray) {
   this.BodyByteArray = BodyByteArray;
   this.Header = Header;
 }
Esempio n. 35
0
 public SmppQuerySmRes(SmppHeader Header) {
   _Header = Header;
   _Body = new BodyPdu();
 }
Esempio n. 36
0
 public SmppCancelSmReq(SmppHeader Header, BodyPdu Body) {
   _Header = Header;
   _Body = Body;
 }
Esempio n. 37
0
 internal SmppBindReq(ByteBuilder bb) {
   int startPosition = 0x10;
   _Header = new SmppHeader(bb);
   _Body = new BodyPdu(bb, ref startPosition);
 }
Esempio n. 38
0
 public SmppSubmitSmRes(int SequenceNumber)
 {
     _Header = new SmppHeader(-2147483644, SequenceNumber);
     _Body   = new BodyPdu();
 }
Esempio n. 39
0
 public SmppDeliverSmReq() {
   _Header = new SmppHeader(5);
   _Body = new BodyPdu();
 }
Esempio n. 40
0
 public SmppUnBindReq() {
   _Header = new SmppHeader(6, 0);
 }
Esempio n. 41
0
    void ProcessAsyncPdu(SmppAsyncObject AsyncObject, SmppAsyncObject.SmppAsyncCompleted CompletionReason) {
      try {
        Exception exception = null;
        object obj2 = null;
        FindAndRemoveTransaction(AsyncObject);
        switch (CompletionReason) {
          case SmppAsyncObject.SmppAsyncCompleted.Response: {
            var header = new SmppHeader(AsyncObject.PduRes);
            if (header.CommandId != -2147483648)
              break;
            exception = new SmppGenericNackException();
            goto Label_008E;
          }
          case SmppAsyncObject.SmppAsyncCompleted.Timeout:
            exception = new SmppTimeOutException();
            Interlocked.Increment(ref ConsecutiveTimeouts);
            if (ConsecutiveTimeouts > Settings.WindowSize)
              BeginUnBind();
            goto Label_008E;

          case SmppAsyncObject.SmppAsyncCompleted.Disconnection:
            exception = new SmppInvalidConnectionStateException();
            goto Label_008E;

          default:
            goto Label_008E;
        }
        obj2 = new SmppSubmitSmRes(AsyncObject.PduRes);
        ConsecutiveTimeouts = 0;
        Label_008E:
        switch (AsyncObject.Request.Header.CommandId) {
          case 3: {
            var args3 = new SmppAsyncQuerySmResEventArgs();
            args3._State = AsyncObject.State;
            args3._ProcessException = exception;
            args3._RequestPdu = AsyncObject.Request as SmppQuerySmReq;
            args3._ResponsePdu = obj2 as SmppQuerySmRes;
            var handler3 = AsyncObject.Callback as SmppQuerySmResHandler;
            handler3(this, args3);
            return;
          }
          case 4: {
            var args = new SmppAsyncSubmitSmResEventArgs();
            args._State = AsyncObject.State;
            args._ProcessException = exception;
            args._RequestPdu = AsyncObject.Request as SmppSubmitSmReq;
            args._ResponsePdu = obj2 as SmppSubmitSmRes;
            var handler = AsyncObject.Callback as SmppSubmitSmResHandler;
            handler(this, args);
            return;
          }
          case 0x15:
            break;

          default:
            return;
        }
        var e = new SmppAsyncEnquireLinkResEventArgs();
        e._State = AsyncObject.State;
        e._ProcessException = exception;
        e._RequestPdu = AsyncObject.Request as SmppEnquireLinkReq;
        e._ResponsePdu = obj2 as SmppEnquireLinkRes;
        var callback = AsyncObject.Callback as SmppAsyncEnquireLinkResHandler;
        callback(this, e);
      } catch (Exception exception2) {
        log.Error("Devshock: " + exception2);
      }
    }
Esempio n. 42
0
 public SmppBindRes(SmppHeader Header) {
   _Header = Header;
   _Body = new BodyPdu();
 }
Esempio n. 43
0
 public SmppDeliverSmRes(int SequenceNumber, string MessageId)
 {
     _Header = new SmppHeader(-2147483643, SequenceNumber);
     _Body   = new BodyPdu(MessageId);
 }
Esempio n. 44
0
 public SmppDeliverSmReq()
 {
     _Header = new SmppHeader(5);
     _Body   = new BodyPdu();
 }
Esempio n. 45
0
 internal SmppSubmitSmReq(SmppHeader Header, BodyPdu Body, SmppTlv Tlv)
 {
     _Header = Header;
     _Body   = Body;
     _Tlv    = Tlv;
 }
Esempio n. 46
0
 internal SmppQuerySmRes(ByteBuilder bb) {
   _Header = new SmppHeader(bb);
   int lastBytePosition = 0x10;
   _Body = new BodyPdu(bb, ref lastBytePosition);
 }
Esempio n. 47
0
 public SmppGenericNackReq(SmppHeader Header)
 {
     _Header = Header;
 }
Esempio n. 48
0
 public SmppQuerySmReq(int SequenceNumber, BodyPdu Body) {
   _Header = new SmppHeader(3, SequenceNumber);
   _Body = Body;
 }
Esempio n. 49
0
 internal SmppEnquireLinkRes(ByteBuilder bb)
 {
     _Header = new SmppHeader(bb);
 }
Esempio n. 50
0
 public SmppBindReq(SmppHeader Header, BodyPdu Body) {
   _Header = Header;
   _Body = Body;
 }
Esempio n. 51
0
 internal SmppSubmitSmReq(SmppHeader Header, BodyPdu Body, SmppTlv Tlv) {
   _Header = Header;
   _Body = Body;
   _Tlv = Tlv;
 }