Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Apr 30th, 2012  |  syntax: None  |  size: 1.15 KB  |  hits: 24  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1.         public static void device_PcapOnPacketArrival(object sender, CaptureEventArgs e)
  2.         {
  3.             try
  4.             {
  5.                 var packet = Packet.ParsePacket(LinkLayers.Ethernet, e.Packet.Data);
  6.                 if (packet.PayloadPacket == null) return;
  7.             }
  8.             catch
  9.             {
  10.                 return;
  11.             }
  12.             TcpPacket tcpPacket = Packet.ParsePacket(LinkLayers.Ethernet, e.Packet.Data).PayloadPacket.PayloadPacket as TcpPacket;
  13.  
  14.             // THIS FILTERS D3 TRAFFIC, GS AS WELL AS MOONET
  15.             if ((tcpPacket != null) && (tcpPacket.SourcePort == 1119 || tcpPacket.DestinationPort == 1119))
  16.             {
  17.                 Connection c = new Connection(tcpPacket);
  18.                 if (!sharpPcapDict.ContainsKey(c))
  19.                 {
  20.                     string fileName = c.getFileName(path);
  21.                     TcpRecon tcpRecon = new TcpRecon(fileName);
  22.                     sharpPcapDict.Add(c, tcpRecon);
  23.                 }
  24.  
  25.                 // Use the TcpRecon class to reconstruct the session
  26.                 sharpPcapDict[c].ReassemblePacket(tcpPacket);
  27.             }
  28.         }