Example #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);
        }
Example #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);
        }
Example #3
0
 protected void _ProcessWontCommand(byte Option)
 {
     if (_Options.ContainsKey(Option) == false)
     {
         _LogDebug("(WONT?)OptionCode: " + Option.ToString() + "(0x" + Option.ToString("X") + ") not supported.");
         SendToNetwork(TelnetOption.GetNegotiationResponseDont(Option));
         return;
     }
     if (!_Options[Option].IsNegotiatedSuccessfully())
     {
         _LogDebug("(WONT?)OptionCode: " + Option.ToString() + "(0x" + Option.ToString("X") + ") negotiated OK.");
         byte[] Response = _Options[Option].GetNegotiationResponsePacket(TelnetOption.OptionNegotiationType.WONT);
         if (Response != null)
         {
             SendToNetwork(Response);
         }
     }
 }