Beispiel #1
0
        private void 开始ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.停止ToolStripMenuItem.Enabled = true;
            this.开始ToolStripMenuItem.Enabled = false;
            //设置状态信息
            StringBuilder sb = new StringBuilder();

            sb.Append("当前网卡:" + SharpShark.configClass.NICName);
            sb.Append("    当前捕获模式:" + SharpShark.configClass.deviceModeDescription);
            sb.Append("    捕获正在进行……");
            this.lblStatus.Text = sb.ToString();
            //确定目标设备
            device = utility.getLiveDevice();
            device.OnPacketArrival += new PacketArrivalEventHandler(device_OnPacketArrival);
            int readTimeoutMilliseconds = 1000;

            //读取设备模式
            device.Open(SharpShark.configClass.deviceMode, readTimeoutMilliseconds);
            //设置过滤器
            if (this.toolStripCmbFilter.Text != "")
            {
                device.Filter = this.toolStripCmbFilter.Text.ToString();
            }
            //设置捕获数据包存储路径
            string dumpFilePath = configClass.fileStorePath;

            device.DumpOpen(dumpFilePath);
            device.StartCapture();
        }
Beispiel #2
0
 private void 开始ToolStripMenuItem_Click(object sender, EventArgs e)
 {
     this.停止ToolStripMenuItem.Enabled = true;
     this.开始ToolStripMenuItem.Enabled = false;
     //设置状态信息
     StringBuilder sb = new StringBuilder();
     sb.Append("当前网卡:" + SharpShark.configClass.NICName);
     sb.Append("    当前捕获模式:" + SharpShark.configClass.deviceModeDescription);
     sb.Append("    捕获正在进行……");
     this.lblStatus.Text = sb.ToString();
     //确定目标设备
     device = utility.getLiveDevice();
     device.OnPacketArrival += new PacketArrivalEventHandler(device_OnPacketArrival);
     int readTimeoutMilliseconds = 1000;
     //读取设备模式
     device.Open(SharpShark.configClass.deviceMode, readTimeoutMilliseconds);
     //设置过滤器
     if (this.toolStripCmbFilter.Text != "")
     {
         device.Filter = this.toolStripCmbFilter.Text.ToString();
     }
     //设置捕获数据包存储路径
     string dumpFilePath = configClass.fileStorePath;
     device.DumpOpen(dumpFilePath);
     device.StartCapture();
 }