PacketForm.cs 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. /*
  2. * Mentalis.org Packet Monitor
  3. *
  4. * Copyright ?2003, The KPD-Team
  5. * All rights reserved.
  6. * http://www.mentalis.org/
  7. *
  8. * Redistribution and use in source and binary forms, with or without
  9. * modification, are permitted provided that the following conditions
  10. * are met:
  11. *
  12. * - Redistributions of source code must retain the above copyright
  13. * notice, this list of conditions and the following disclaimer.
  14. *
  15. * - Neither the name of the KPD-Team, nor the names of its contributors
  16. * may be used to endorse or promote products derived from this
  17. * software without specific prior written permission.
  18. *
  19. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  20. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  21. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  22. * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
  23. * THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
  24. * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  25. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  26. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  27. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  28. * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  29. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
  30. * OF THE POSSIBILITY OF SUCH DAMAGE.
  31. */
  32. using System;
  33. using System.Drawing;
  34. using System.Collections;
  35. using System.ComponentModel;
  36. using System.Windows.Forms;
  37. namespace Org.Mentalis.Network.PacketMonitor {
  38. public class PacketForm : System.Windows.Forms.Form {
  39. private System.Windows.Forms.Panel panel1;
  40. private System.Windows.Forms.Splitter splitter1;
  41. private System.Windows.Forms.TextBox RawText;
  42. private System.Windows.Forms.ColumnHeader InfoHeader;
  43. private System.Windows.Forms.ColumnHeader ValueHeader;
  44. private System.Windows.Forms.ListView InfoList;
  45. private System.ComponentModel.Container components = null;
  46. public PacketForm(Packet p) {
  47. if (p == null)
  48. throw new ArgumentNullException();
  49. // Required for Windows Form Designer support
  50. InitializeComponent();
  51. m_Packet = p;
  52. }
  53. protected override void Dispose( bool disposing ) {
  54. if(disposing) {
  55. if(components != null) {
  56. components.Dispose();
  57. }
  58. }
  59. base.Dispose( disposing );
  60. }
  61. #region Windows Form Designer generated code
  62. /// <summary>
  63. /// Required method for Designer support - do not modify
  64. /// the contents of this method with the code editor.
  65. /// </summary>
  66. private void InitializeComponent() {
  67. this.panel1 = new System.Windows.Forms.Panel();
  68. this.InfoList = new System.Windows.Forms.ListView();
  69. this.InfoHeader = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
  70. this.ValueHeader = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
  71. this.splitter1 = new System.Windows.Forms.Splitter();
  72. this.RawText = new System.Windows.Forms.TextBox();
  73. this.panel1.SuspendLayout();
  74. this.SuspendLayout();
  75. //
  76. // panel1
  77. //
  78. this.panel1.Controls.Add(this.InfoList);
  79. this.panel1.Dock = System.Windows.Forms.DockStyle.Top;
  80. this.panel1.Location = new System.Drawing.Point(0, 0);
  81. this.panel1.Name = "panel1";
  82. this.panel1.Size = new System.Drawing.Size(480, 224);
  83. this.panel1.TabIndex = 2;
  84. //
  85. // InfoList
  86. //
  87. this.InfoList.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
  88. this.InfoHeader,
  89. this.ValueHeader});
  90. this.InfoList.Dock = System.Windows.Forms.DockStyle.Fill;
  91. this.InfoList.FullRowSelect = true;
  92. this.InfoList.GridLines = true;
  93. this.InfoList.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable;
  94. this.InfoList.Location = new System.Drawing.Point(0, 0);
  95. this.InfoList.Name = "InfoList";
  96. this.InfoList.Size = new System.Drawing.Size(480, 224);
  97. this.InfoList.TabIndex = 0;
  98. this.InfoList.UseCompatibleStateImageBehavior = false;
  99. this.InfoList.View = System.Windows.Forms.View.Details;
  100. //
  101. // InfoHeader
  102. //
  103. this.InfoHeader.Text = "Information Type";
  104. this.InfoHeader.Width = 237;
  105. //
  106. // ValueHeader
  107. //
  108. this.ValueHeader.Text = "Value";
  109. this.ValueHeader.Width = 210;
  110. //
  111. // splitter1
  112. //
  113. this.splitter1.Cursor = System.Windows.Forms.Cursors.NoMoveVert;
  114. this.splitter1.Dock = System.Windows.Forms.DockStyle.Top;
  115. this.splitter1.Location = new System.Drawing.Point(0, 224);
  116. this.splitter1.Name = "splitter1";
  117. this.splitter1.Size = new System.Drawing.Size(480, 9);
  118. this.splitter1.TabIndex = 3;
  119. this.splitter1.TabStop = false;
  120. //
  121. // RawText
  122. //
  123. this.RawText.Dock = System.Windows.Forms.DockStyle.Fill;
  124. this.RawText.Font = new System.Drawing.Font("Courier New", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
  125. this.RawText.Location = new System.Drawing.Point(0, 233);
  126. this.RawText.Multiline = true;
  127. this.RawText.Name = "RawText";
  128. this.RawText.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
  129. this.RawText.Size = new System.Drawing.Size(480, 215);
  130. this.RawText.TabIndex = 4;
  131. //
  132. // PacketForm
  133. //
  134. this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
  135. this.ClientSize = new System.Drawing.Size(480, 448);
  136. this.Controls.Add(this.RawText);
  137. this.Controls.Add(this.splitter1);
  138. this.Controls.Add(this.panel1);
  139. this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
  140. this.MaximizeBox = false;
  141. this.MinimizeBox = false;
  142. this.Name = "PacketForm";
  143. this.Text = "Detailed Packet Information";
  144. this.Load += new System.EventHandler(this.PacketForm_Load);
  145. this.panel1.ResumeLayout(false);
  146. this.ResumeLayout(false);
  147. this.PerformLayout();
  148. }
  149. #endregion
  150. private void PacketForm_Load(object sender, System.EventArgs e) {
  151. RawText.Text = m_Packet.ToString();
  152. InfoList.Items.Add(new ListViewItem(new string[] {"Time", m_Packet.Time.ToString()}));
  153. InfoList.Items.Add(new ListViewItem(new string[] {"Source", m_Packet.Source}));
  154. InfoList.Items.Add(new ListViewItem(new string[] {"Destination", m_Packet.Destination}));
  155. InfoList.Items.Add(new ListViewItem(new string[] {"Protocol", m_Packet.Protocol.ToString()}));
  156. InfoList.Items.Add(new ListViewItem(new string[] {"Time To Live", m_Packet.TimeToLive.ToString()}));
  157. InfoList.Items.Add(new ListViewItem(new string[] {"Version", m_Packet.Version.ToString()}));
  158. InfoList.Items.Add(new ListViewItem(new string[] {"Header Length", m_Packet.HeaderLength.ToString()}));
  159. InfoList.Items.Add(new ListViewItem(new string[] {"Precedence", m_Packet.Precedence.ToString()}));
  160. InfoList.Items.Add(new ListViewItem(new string[] {"Delay", m_Packet.Delay.ToString()}));
  161. InfoList.Items.Add(new ListViewItem(new string[] {"Throughput", m_Packet.Throughput.ToString()}));
  162. InfoList.Items.Add(new ListViewItem(new string[] {"Reliability", m_Packet.Reliability.ToString()}));
  163. InfoList.Items.Add(new ListViewItem(new string[] {"Total Length", m_Packet.TotalLength.ToString()}));
  164. InfoList.Items.Add(new ListViewItem(new string[] {"Identification", m_Packet.Identification.ToString()}));
  165. InfoList.Items.Add(new ListViewItem(new string[] {"Checksum", m_Packet.Checksum[0].ToString("X2") + m_Packet.Checksum[1].ToString("X2")}));
  166. }
  167. private Packet m_Packet;
  168. }
  169. }