Exemplo n.º 1
0
        public byte[] GetNegotiationResponsePacket(OptionNegotiationType RequestType)
        {
            byte[] ResponsePacket = null;

            switch (RequestType)
            {
            case OptionNegotiationType.WILL:
                if (RespondedWillWont == false)
                {
                    if (_bWILL)
                    {
                        ResponsePacket = TelnetOption.GetNegotiationResponseDo(OptionCode);
                    }
                    else
                    {
                        ResponsePacket = TelnetOption.GetNegotiationResponseDont(OptionCode);
                    }
                    RespondedDoDont = true;
                }
                break;

            case OptionNegotiationType.WONT:
                if (RespondedWillWont == false)
                {
                    _bWILL          = false;
                    ResponsePacket  = TelnetOption.GetNegotiationResponseDont(OptionCode);
                    RespondedDoDont = true;
                }
                break;

            case OptionNegotiationType.DO:
                if (RespondedDoDont == false)
                {
                    if (_bDO)
                    {
                        ResponsePacket = TelnetOption.GetNegotiationResponseWill(OptionCode);
                    }
                    else
                    {
                        ResponsePacket = TelnetOption.GetNegotiationResponseWont(OptionCode);
                    }
                    RespondedWillWont = true;
                }
                break;

            case OptionNegotiationType.DONT:
                if (RespondedDoDont == false)
                {
                    _bDO              = false;
                    ResponsePacket    = TelnetOption.GetNegotiationResponseWont(OptionCode);
                    RespondedWillWont = true;
                }
                break;

            default:
                break;
            }

            return(ResponsePacket);
        }
Exemplo n.º 2
0
        public byte[] GetNegotiationPacket()
        {
            byte[] ResponsePacket = null;

            if (SendDoDont)
            {
                if (_bDO)
                {
                    ResponsePacket = TelnetOption.GetNegotiationResponseDo(OptionCode);
                }
                else
                {
                    ResponsePacket = TelnetOption.GetNegotiationResponseDont(OptionCode);
                }
            }
            else if (SendWillWont)
            {
                if (_bWILL)
                {
                    ResponsePacket = TelnetOption.GetNegotiationResponseWill(OptionCode);
                }
                else
                {
                    ResponsePacket = TelnetOption.GetNegotiationResponseWont(OptionCode);
                }
            }

            return(ResponsePacket);
        }
Exemplo n.º 3
0
 protected void _ProcessDontCommand(byte Option)
 {
     if (_Options.ContainsKey(Option) == false)
     {
         _LogDebug("(DONT?)OptionCode: " + Option.ToString() + "(0x" + Option.ToString("X") + ") not supported.");
         SendToNetwork(TelnetOption.GetNegotiationResponseWont(Option));
         return;
     }
     if (!_Options[Option].IsNegotiatedSuccessfully())
     {
         _LogDebug("(DONT?)OptionCode: " + Option.ToString() + "(0x" + Option.ToString("X") + ") negotiated OK.");
         byte[] Response = _Options[Option].GetNegotiationResponsePacket(TelnetOption.OptionNegotiationType.DONT);
         if (Response != null)
         {
             SendToNetwork(Response);
         }
     }
 }