Beispiel #1
0
        /// <summary>
        /// 通过TwzyProtocol实现
        /// </summary>
        /// <param name="ppp"></param>
        private void PPP(TwzyProtocol.PPPPacket ppp)
        {
            if (PPPNode == null)
            {
                PPPNode = CreatNode("PPP", 10);
            }
            PPPNode.Text = "PPP [0x" + ((ushort)ppp.Protocol).ToString("X4") + "]";
            PPPNode.Nodes.Clear();

            PPPNode.Nodes.Add("Protocol: " + ppp.Protocol.ToString() + " [0x" + ppp.Protocol.ToString("X") + "]");
            Tree.Nodes.Add(PPPNode);
            switch (ppp.Protocol)
            {
            case PPPProType.IPv4:
            case PPPProType.IPv6:
                IpPacket ip = IpPacket.GetEncapsulated(packet);
                IP(ip);
                break;

            case PPPProType.LCP:
                LCPPacket lcp = LCPPacket.GetEncapsulated(packet);
                LCP(lcp);
                break;

            case PPPProType.CompressedDatagram:
                ExtraData(ppp.PayloadData);
                return;

            case PPPProType.Padding:    //填充
                break;
            }
        }
Beispiel #2
0
        private void PPPOE(PPPoEPacket pppoe)
        {
            if (PPPoENode == null)
            {
                PPPoENode = CreatNode("PPPoE", 11);
            }
            PPPoENode.Nodes.Clear();

            PPPoENode.Nodes.Add(Convert.ToString(pppoe.Version, 2).PadLeft(4, '0') + " .... = Version: " + pppoe.Version.ToString());
            PPPoENode.Nodes.Add(".... " + Convert.ToString(pppoe.Type, 2).PadLeft(4, '0') + " = Type: " + pppoe.Type.ToString());
            PPPoENode.Nodes.Add("Code: 0x" + pppoe.Code.ToString("X") + " (" + pppoe.Code + ")");
            PPPoENode.Nodes.Add("Session Id: " + pppoe.SessionId.ToString() + " [0x" + pppoe.SessionId.ToString("X4") + "]");
            PPPoENode.Nodes.Add("Payload Length: " + pppoe.Length.ToString());
            Tree.Nodes.Add(PPPoENode);


            //查看数据
            var ppp = PacketDotNet.PPPPacket.GetEncapsulated(packet);

            if (ppp.Bytes.Length > 0)
            {
                var tmpPPP = new TwzyProtocol.PPPPacket(ppp.Bytes);
                PPP(tmpPPP);
            }
        }
Beispiel #3
0
        /// <summary>
        /// GRE封装的下层协议
        /// </summary>
        /// <param name="data"></param>
        /// <param name="e"></param>
        private void NextGRE(byte[] data, EthernetProtocolType e)
        {
            if (data.Length <= 0)
            {
                return;
            }
            switch (e)
            {
            case EthernetProtocolType.PPP:
                var ppp = new TwzyProtocol.PPPPacket(data);
                if (ppp != null)
                {
                    PPP(ppp);
                }
                break;

            case EthernetProtocolType.Arp:    //ARP协议
                ARPPacket arp = ARPPacket.GetEncapsulated(packet);
                Arp(arp);
                break;

            case EthernetProtocolType.IpV4:    //IP协议
            case EthernetProtocolType.IpV6:
                IpPacket ip = IpPacket.GetEncapsulated(packet);
                IP(ip);
                break;

            case EthernetProtocolType.WakeOnLan:    //网络唤醒协议
                WakeOnLanPacket wake = WakeOnLanPacket.GetEncapsulated(packet);
                Wake_on_Lan(wake);
                break;

            case EthernetProtocolType.LLDP:    //链路层发现协议
                LLDPPacket ll = LLDPPacket.GetEncapsulated(packet);
                LLDPProtocol(ll);
                break;

            case EthernetProtocolType.PointToPointProtocolOverEthernetDiscoveryStage:
            case EthernetProtocolType.PPPoE:
                PPPoEPacket pppoe = PPPoEPacket.GetEncapsulated(packet);
                PPPOE(pppoe);
                break;

            case EthernetProtocolType.None:    //无可用协议
                break;
            }
        }