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

            _Body = new BodyPdu(bb, ref lastBytePosition);
        }
Ejemplo 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);
 }
Ejemplo n.º 3
0
        internal SmppQuerySmReq(ByteBuilder bb)
        {
            int startPosition = 0x10;

            _Header = new SmppHeader(bb);
            _Body   = new BodyPdu(bb, ref startPosition);
        }
Ejemplo 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);
 }
Ejemplo 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);
        }
Ejemplo 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);
            }
        }
Ejemplo 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);
     }
   }
 }
Ejemplo 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);
            }
        }
Ejemplo 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);
             }
         }
     }
 }
Ejemplo 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();
 }
Ejemplo 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;
          }
      }
    }
Ejemplo n.º 12
0
 internal SmppUnBindReq(ByteBuilder bb) {
   _Header = new SmppHeader(bb);
 }
Ejemplo n.º 13
0
 public SmppEnquireLinkReq(SmppHeader Header) {
   _Header = Header;
 }
Ejemplo n.º 14
0
 public SmppDataSmReq(SmppHeader Header, BodyPdu Body, SmppTlv Tlv)
 {
     _Header = Header;
     _Body   = Body;
     _Tlv    = Tlv;
 }
Ejemplo n.º 15
0
 public SmppGenericNackReq(SmppHeader Header) {
   _Header = Header;
 }
Ejemplo n.º 16
0
 public SmppUnBindReq()
 {
     _Header = new SmppHeader(6, 0);
 }
Ejemplo n.º 17
0
 public SmppDeliverSmRes(int SequenceNumber, string MessageId) {
   _Header = new SmppHeader(-2147483643, SequenceNumber);
   _Body = new BodyPdu(MessageId);
 }
Ejemplo n.º 18
0
 public SmppSubmitSmRes(int SequenceNumber) {
   _Header = new SmppHeader(-2147483644, SequenceNumber);
   _Body = new BodyPdu();
 }
Ejemplo n.º 19
0
 public SmppDataSmReq(SmppHeader Header, BodyPdu Body, SmppTlv Tlv) {
   _Header = Header;
   _Body = Body;
   _Tlv = Tlv;
 }
Ejemplo 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);
 }
Ejemplo n.º 21
0
 public SmppBindReq(SmppHeader Header, BodyPdu Body)
 {
     _Header = Header;
     _Body   = Body;
 }
Ejemplo 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);
   }
 }
Ejemplo 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);
 }
Ejemplo 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;
      }
    }
Ejemplo n.º 25
0
 internal SmppCancelSmRes(ByteBuilder bb)
 {
     _Header = new SmppHeader(bb);
 }
Ejemplo n.º 26
0
 public SmppEnquireLinkRes(SmppHeader Header)
 {
     _Header = Header;
 }
Ejemplo n.º 27
0
 public SmppQuerySmReq(int SequenceNumber, BodyPdu Body)
 {
     _Header = new SmppHeader(3, SequenceNumber);
     _Body   = Body;
 }
Ejemplo n.º 28
0
 public SmppQuerySmRes(SmppHeader Header)
 {
     _Header = Header;
     _Body   = new BodyPdu();
 }
Ejemplo n.º 29
0
 public SmppBindRes(SmppHeader Header)
 {
     _Header = Header;
     _Body   = new BodyPdu();
 }
Ejemplo n.º 30
0
 internal SmppUnBindReq(ByteBuilder bb)
 {
     _Header = new SmppHeader(bb);
 }
Ejemplo n.º 31
0
 internal SmppCancelSmRes(ByteBuilder bb) {
   _Header = new SmppHeader(bb);
 }
Ejemplo n.º 32
0
 internal SmppEnquireLinkReq(ByteBuilder bb) {
   _Header = new SmppHeader(bb);
 }
Ejemplo n.º 33
0
 public SmppCancelSmReq(SmppHeader Header, BodyPdu Body)
 {
     _Header = Header;
     _Body   = Body;
 }
Ejemplo n.º 34
0
 public SmppUnknownPduEventArgs(SmppHeader Header, byte[] BodyByteArray) {
   this.BodyByteArray = BodyByteArray;
   this.Header = Header;
 }
Ejemplo n.º 35
0
 public SmppQuerySmRes(SmppHeader Header) {
   _Header = Header;
   _Body = new BodyPdu();
 }
Ejemplo n.º 36
0
 public SmppCancelSmReq(SmppHeader Header, BodyPdu Body) {
   _Header = Header;
   _Body = Body;
 }
Ejemplo n.º 37
0
 internal SmppBindReq(ByteBuilder bb) {
   int startPosition = 0x10;
   _Header = new SmppHeader(bb);
   _Body = new BodyPdu(bb, ref startPosition);
 }
Ejemplo n.º 38
0
 public SmppSubmitSmRes(int SequenceNumber)
 {
     _Header = new SmppHeader(-2147483644, SequenceNumber);
     _Body   = new BodyPdu();
 }
Ejemplo n.º 39
0
 public SmppDeliverSmReq() {
   _Header = new SmppHeader(5);
   _Body = new BodyPdu();
 }
Ejemplo n.º 40
0
 public SmppUnBindReq() {
   _Header = new SmppHeader(6, 0);
 }
Ejemplo 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);
      }
    }
Ejemplo n.º 42
0
 public SmppBindRes(SmppHeader Header) {
   _Header = Header;
   _Body = new BodyPdu();
 }
Ejemplo n.º 43
0
 public SmppDeliverSmRes(int SequenceNumber, string MessageId)
 {
     _Header = new SmppHeader(-2147483643, SequenceNumber);
     _Body   = new BodyPdu(MessageId);
 }
Ejemplo n.º 44
0
 public SmppDeliverSmReq()
 {
     _Header = new SmppHeader(5);
     _Body   = new BodyPdu();
 }
Ejemplo n.º 45
0
 internal SmppSubmitSmReq(SmppHeader Header, BodyPdu Body, SmppTlv Tlv)
 {
     _Header = Header;
     _Body   = Body;
     _Tlv    = Tlv;
 }
Ejemplo n.º 46
0
 internal SmppQuerySmRes(ByteBuilder bb) {
   _Header = new SmppHeader(bb);
   int lastBytePosition = 0x10;
   _Body = new BodyPdu(bb, ref lastBytePosition);
 }
Ejemplo n.º 47
0
 public SmppGenericNackReq(SmppHeader Header)
 {
     _Header = Header;
 }
Ejemplo n.º 48
0
 public SmppQuerySmReq(int SequenceNumber, BodyPdu Body) {
   _Header = new SmppHeader(3, SequenceNumber);
   _Body = Body;
 }
Ejemplo n.º 49
0
 internal SmppEnquireLinkRes(ByteBuilder bb)
 {
     _Header = new SmppHeader(bb);
 }
Ejemplo n.º 50
0
 public SmppBindReq(SmppHeader Header, BodyPdu Body) {
   _Header = Header;
   _Body = Body;
 }
Ejemplo n.º 51
0
 internal SmppSubmitSmReq(SmppHeader Header, BodyPdu Body, SmppTlv Tlv) {
   _Header = Header;
   _Body = Body;
   _Tlv = Tlv;
 }