Exemplo n.º 1
0
        protected virtual int HandleOutgoingCallRequest(byte[] buffer, int len)
        {
            fixed(byte *p = buffer)
            {
                OutgoingCallRequest.OCRC *o = (OutgoingCallRequest.OCRC *)p;
                if (len < 168)
                {
                    return(-2101);
                }

                if (ntohs(o->Length) < 168)
                {
                    return(-2101);
                }

                if (7 != ntohs(o->ControlMessageType))
                {
                    return(-2102);
                }

                RasdialClient                   = m_pListener.CreateClient();
                RasdialClient.BindId            = ntohs(o->CallSerialNumber);
                RasdialClient.PeersCallId       = ntohs(o->CallID);
                RasdialClient.ReceiveBufferSize = ntohs(o->PacketRecvWindowSize);
                RasdialClient.MinBytesPerSecond = ntohl(o->MinBPS);
                RasdialClient.MaxBytesPerSecond = ntohl(o->MaxBPS);

                byte[] message = new byte[sizeof(OutgoingCallReply)];
                fixed(byte *pxm = message)
                {
                    OutgoingCallReply *r = (OutgoingCallReply *)pxm;

                    r->Length                = ntohs((ushort)sizeof(OutgoingCallReply));
                    r->PPTPMessageType       = o->PPTPMessageType;
                    r->ControlMessageType    = ntohs(8);
                    r->PeersCallID           = ntohs(RasdialClient.PeersCallId);
                    r->ResultCode            = 1;
                    r->ErrorCode             = 0;
                    r->CauseCode             = 0;
                    r->Reserved0             = 0;
                    r->MagicCookie           = o->MagicCookie;
                    r->ConnectSpeed          = ntohl(RasdialClient.MaxBytesPerSecond);
                    r->RevWindowSize         = ntohs((ushort)m_pSocket.ReceiveBufferSize);
                    r->PacketProcessingDelay = 0;
                    r->CallID                = ntohs(RasdialClient.PeersCallId);
                    r->PhysicalChannelId     = ntohl(RasdialClient.PhysicalChannelId);
                }

                SendMessage(message, 0, message.Length);
                m_bState++;
            }

            return(0);
        }
Exemplo n.º 2
0
        public virtual PptpRasdialClient CreateClient()
        {
            PptpRasdialClient rasdial = new PptpRasdialClient();

            do
            {
                rasdial.PhysicalChannelId = (uint)Interlocked.Increment(ref m_dwPCID);
            } while (0 == rasdial.PhysicalChannelId);
            rasdial.SelfCallId = (ushort)rasdial.PhysicalChannelId;
            return(rasdial);
        }