⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 packetdlsw.cs

📁 一个抓包工具
💻 CS
📖 第 1 页 / 共 2 页
字号:
					PDlsw.Reserved2 = Function.Get2Bytes( PacketData , ref Index , Const.NORMAL );
					Tmp = "Reserved : " + Function.ReFormatString( PDlsw.Reserved2 , null );
					mNode1.Nodes.Add( Tmp );
					Function.SetPosition( ref mNode1 , Index - 2 , 2 , false );
					PDlsw.LargestFrameSize = PacketData[ Index ++ ];
					Tmp = "Largest Frame Size : " + Function.ReFormatString( PDlsw.LargestFrameSize , null );
					mNode1.Nodes.Add( Tmp );
					Function.SetPosition( ref mNode1 , Index - 1 , 1 , false );
					PDlsw.SSPFlags = PacketData[ Index ++ ];
					Tmp = "SSP Flags : " + Function.ReFormatString( PDlsw.SSPFlags , null );
					mNode1.Nodes.Add( Tmp );
					Function.SetPosition( ref mNode1 , Index - 1 , 1 , false );
					PDlsw.CircuitPriority = PacketData[ Index ++ ];
					Tmp = "Circuit Priority : " + Function.ReFormatString( PDlsw.CircuitPriority , Const.GetDlswPriorityString( PDlsw.CircuitPriority ) );
					mNode1.Nodes.Add( Tmp );
					Function.SetPosition( ref mNode1 , Index - 1 , 1 , false );
					PDlsw.OldMessageType = PacketData[ Index ++ ];
					Tmp = "Old Message Type : " + Function.ReFormatString( PDlsw.OldMessageType , Const.GetDlswTypeString( PDlsw.OldMessageType ) );
					mNode1.Nodes.Add( Tmp );
					Function.SetPosition( ref mNode1 , Index - 1 , 1 , false );
					if( PDlsw.MessageType == Const.DLSW_CAP_EXCHANGE )					{						//PDlsw.ProtocolId = PacketData[ Index ++ ];
						Index += 14;
						Tmp = "Not used for CapEx" ;
						mNode1.Nodes.Add( Tmp );
						Function.SetPosition( ref mNode1 , Index - 14 , 14 , false );
						PDlsw.FrameDirector = PacketData[ Index ++ ];
						Tmp = "Frame Direction : " + Function.ReFormatString( PDlsw.FrameDirector , PDlsw.FrameDirector == 1 ? "Capabilities request":"Capabilities response" );
						mNode1.Nodes.Add( Tmp );
						Function.SetPosition( ref mNode1 , Index - 1 , 1 , false );
						//PDlsw.ProtocolId = PacketData[ Index ++ ];
						Index += 33;
						Tmp = "Not used for CapEx";
						mNode1.Nodes.Add( Tmp );
						Function.SetPosition( ref mNode1 , Index - 33 , 33 , false );
					}
					else
					{
						PDlsw.TargetMACAddress = Function.GetMACAddress( PacketData , ref Index );
						Tmp = "Target MAC Address : " + PDlsw.TargetMACAddress;
						mNode1.Nodes.Add( Tmp );
						Function.SetPosition( ref mNode1 , Index - 6 , 6 , false );
						PDlsw.OriginMACAddress = Function.GetMACAddress( PacketData , ref Index );
						Tmp = "Origin MAC Address : " + PDlsw.OriginMACAddress;
						mNode1.Nodes.Add( Tmp );
						Function.SetPosition( ref mNode1 , Index - 6 , 6 , false );
						PDlsw.OriginLSAP = PacketData[ Index ++ ];
						Tmp = "Origin Link SAP : " + Function.ReFormatString( PDlsw.OriginLSAP , null );
						mNode1.Nodes.Add( Tmp );
						Function.SetPosition( ref mNode1 , Index - 1 , 1 , false );
						PDlsw.TargetLSAP = PacketData[ Index ++ ];
						Tmp = "Target Link SAP : " + Function.ReFormatString( PDlsw.TargetLSAP , null );
						mNode1.Nodes.Add( Tmp );
						Function.SetPosition( ref mNode1 , Index - 1 , 1 , false );
						PDlsw.FrameDirector = PacketData[ Index ++ ];
						Tmp = "Frame Direction : " + Function.ReFormatString( PDlsw.FrameDirector , null );
						mNode1.Nodes.Add( Tmp );
						Function.SetPosition( ref mNode1 , Index - 1 , 1 , false );
						PDlsw.Reserved3 = PacketData[ Index ++ ];
						Tmp = "Reserved : " + Function.ReFormatString( PDlsw.Reserved3 , null );
						mNode1.Nodes.Add( Tmp );
						Function.SetPosition( ref mNode1 , Index - 1 , 1 , false );
						PDlsw.Reserved5 = Function.Get2Bytes( PacketData , ref Index , Const.NORMAL );
						Tmp = "Reserved : " + Function.ReFormatString( PDlsw.Reserved5 , null );
						mNode1.Nodes.Add( Tmp );
						Function.SetPosition( ref mNode1 , Index - 2 , 2 , false );
						PDlsw.DlcHeaderLength = Function.Get2Bytes( PacketData , ref Index , Const.NORMAL );
						Tmp = "DLC Header Length : " + Function.ReFormatString( PDlsw.DlcHeaderLength , null );
						mNode1.Nodes.Add( Tmp );
						Function.SetPosition( ref mNode1 , Index - 2 , 2 , false );
						PDlsw.OriginDLCPortId = Function.Get4Bytes( PacketData , ref Index , Const.NORMAL );
						Tmp = "Reserved : " + Function.ReFormatString( PDlsw.OriginDLCPortId , null );
						mNode1.Nodes.Add( Tmp );
						Function.SetPosition( ref mNode1 , Index - 4 , 4 , false );
						PDlsw.OriginDLC = Function.Get4Bytes( PacketData , ref Index , Const.NORMAL );
						Tmp = "Origin DLC : " + Function.ReFormatString( PDlsw.OriginDLC , null );
						mNode1.Nodes.Add( Tmp );
						Function.SetPosition( ref mNode1 , Index - 4 , 4 , false );
						PDlsw.OriginTransporter = Function.Get2Bytes( PacketData , ref Index , Const.NORMAL );
						Tmp = "Origin Transport ID : " + Function.ReFormatString( PDlsw.OriginTransporter , null );
						mNode1.Nodes.Add( Tmp );
						Function.SetPosition( ref mNode1 , Index - 4 , 4 , false );
						PDlsw.TargetDLCPortId = Function.Get4Bytes( PacketData , ref Index , Const.NORMAL );
						Tmp = "Target DLC Port ID : " + Function.ReFormatString( PDlsw.TargetDLCPortId , null );
						mNode1.Nodes.Add( Tmp );
						Function.SetPosition( ref mNode1 , Index - 4 , 4 , false );
						PDlsw.TargetDataLink = Function.Get4Bytes( PacketData , ref Index , Const.NORMAL );
						Tmp = "Target DLC : " + Function.ReFormatString( PDlsw.TargetDataLink , null );
						mNode1.Nodes.Add( Tmp );
						Function.SetPosition( ref mNode1 , Index - 4 , 4 , false );
						PDlsw.TargetTransportId = Function.Get4Bytes( PacketData , ref Index , Const.NORMAL );
						Tmp = "Target Transport ID : " + Function.ReFormatString( PDlsw.TargetTransportId , null );
						mNode1.Nodes.Add( Tmp );
						Function.SetPosition( ref mNode1 , Index - 4 , 4 , false );
						PDlsw.Reserved6 = Function.Get4Bytes( PacketData , ref Index , Const.NORMAL );
						Tmp = "Reserved : " + Function.ReFormatString( PDlsw.Reserved6 , null );
						mNode1.Nodes.Add( Tmp );
						Function.SetPosition( ref mNode1 , Index - 4 , 4 , false );
					}
				}

				Function.SetPosition( ref mNode1 , kk , Index - kk , false );
				mNodex.Nodes.Add( mNode1 );

				Tmp = "Dlsw Data ";
				mNode1.Nodes.Add( Tmp );

				switch( PDlsw.MessageType )				{					case Const.DLSW_CAP_EXCHANGE:						ParseCapEx( ref mNode , PacketData , ref Index , ref LItem );						break;					case Const.DLSW_IFCM:					case Const.DLSW_INFOFRAME:					case Const.DLSW_KEEPALIVE:						Tmp = "Data ";
						mNode1.Nodes.Add( Tmp );
						break;					default:						if( PDlsw.DlcHeaderLength != 0 )						{							Index = PDlsw.HeaderLength;							byteValue = PacketData[ Index ++ ];
							Tmp = "DLC Header - AC byte : " + Function.ReFormatString( byteValue , null );
							mNodex.Nodes.Add( Tmp );
							Function.SetPosition( ref mNodex , Index - 1 , 1 , false );
							byteValue = PacketData[ Index ++ ];
							Tmp = "DLC Header - FC byte : " + Function.ReFormatString( byteValue , null );
							mNodex.Nodes.Add( Tmp );
							Function.SetPosition( ref mNodex , Index - 1 , 1 , false );
							byteValue = PacketData[ Index ++ ];
							Tmp = "DLC Header - DA : " + Function.GetMACAddress( PacketData , ref Index );
							mNodex.Nodes.Add( Tmp );
							Function.SetPosition( ref mNodex , Index - 6 , 6 , false );
							Tmp = "DLC Header - SA : " + Function.GetMACAddress( PacketData , ref Index );
							mNodex.Nodes.Add( Tmp );
							Function.SetPosition( ref mNodex , Index - 6 , 6 , false );
							Tmp = "DLC Header - RIF : " + Function.GetString( PacketData , ref Index , 18 );
							mNodex.Nodes.Add( Tmp );
							Function.SetPosition( ref mNodex , Index - 18 , 18 , false );
							byteValue = PacketData[ Index ++ ];
							Tmp = "DLC Header - DSAP : " + Function.ReFormatString( byteValue , null );
							mNodex.Nodes.Add( Tmp );
							Function.SetPosition( ref mNodex , Index - 1 , 1 , false );
							byteValue = PacketData[ Index ++ ];
							Tmp = "DLC Header - SSAP : " + Function.ReFormatString( byteValue , null );
							mNodex.Nodes.Add( Tmp );
							Function.SetPosition( ref mNodex , Index - 1 , 1 , false );
							byteValue = PacketData[ Index ++ ];
							Tmp = "DLC Header - Ctrl : " + Function.ReFormatString( byteValue , null );
							mNodex.Nodes.Add( Tmp );
							Function.SetPosition( ref mNodex , Index - 1 , 1 , false );
						}
						Tmp = "Dlsw Data ";
						mNode1.Nodes.Add( Tmp );
						break;
				}

				Function.SetPosition( ref mNodex , kk , Index - kk , true );

				LItem.SubItems[ Const.LIST_VIEW_PROTOCOL_INDEX ].Text = "DLSw";
				Tmp = "DLSw " + PDlsw.Version.ToString() + " : " + Const.GetDlswVersionString( PDlsw.Version );
				Tmp += "," + PDlsw.MessageType.ToString() + " : " + Const.GetDlswTypeString( PDlsw.MessageType );
				LItem.SubItems[ Const.LIST_VIEW_INFO_INDEX ].Text = Tmp;

				mNode.Add( mNodex );
				
			}
			catch( Exception Ex )
			{
				mNode.Add( mNodex );
				Tmp = "[ Malformed DLSw packet. Remaining bytes don't fit an DLSw packet. Possibly due to bad decoding ]";
				mNode.Add( Tmp );
				Tmp = "[ Exception raised is <" + Ex.GetType().ToString() + "> at packet index <" + Index.ToString() + "> ]";
				mNode.Add( Tmp );
				LItem.SubItems[ Const.LIST_VIEW_INFO_INDEX ].Text = Tmp;

				return false;
			}

			return true;

		}




	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -