private bool InitCombobox() { var tool = new clrtool.mytool(); IntPtr pint = tool.alldevs_lode(); var tmp = new pcap_if_c(); tmp.UnmanagedPtr2ManagedStru(pint); for (; ; tmp.UnmanagedPtr2ManagedStru(tmp.next)) { Network_card_data _Card_Data = new Network_card_data() { netmask = tool.getnetmask(tmp.addresses), lpv4 = tool.getlpv4(tmp.addresses), Name = tmp.cname, Description = tmp.cdescription }; networl_list.Add(_Card_Data); // Console.WriteLine(tmp.cname + tmp.cdescription); if (tmp.next.ToInt64() == 0) { break; } } if (networl_list.Count > 0) { tool.dev_free(pint); } return(networl_list.Count > 0 ? true : false); }
private void msegloop(object param) { clrtool.mytool tool = (clrtool.mytool)param; while (thread_br) { pcap_data data = tool.read(); if (data.res == 0) { continue; } if (data.res == -1) { return; } OutputAction(data); // Console.WriteLine(data.time + " " + data.len.ToString() +" "+data.source_ip + ":" + data.source_port.ToString()+"-->"+data.dest_ip+":"+data.dest_port.ToString()); } }
private void Onclick_stars(object sender, RoutedEventArgs e) { if (myCombobox.SelectedIndex == -1) { return; } Network_card_data _Card_Data = (Network_card_data)myCombobox.SelectedItem; Console.WriteLine(_Card_Data.Name + _Card_Data.Description); var tool = new clrtool.mytool(); var ahandle = tool.open(_Card_Data.Name, _Card_Data.netmask, filter_text.Text); lpv4 = _Card_Data.lpv4; if (ahandle) { thread_br = true; Thread threadHand1 = new Thread(delegate() { msegloop(tool); }); threadHand1.Start(); } }