public void InvalidKindTest() { const DataLinkKind InvalidKind = (DataLinkKind)100; IDataLink dataLink = new PcapDataLink(InvalidKind); Assert.IsNotNull(dataLink); Assert.Fail(); }
private static int KindToValue(DataLinkKind kind) { if (kind == DataLinkKind.Ethernet) { return(1); } if (kind == DataLinkKind.IpV4) { return(12); } if (kind != DataLinkKind.Docsis) { throw new NotSupportedException(typeof(PcapDataLink).Name + " kind " + kind.ToString() + " is unsupported"); } return(143); }
public static Packet FromHexadecimalString(string value, DateTime timestamp, DataLinkKind dataLink) { if (value == null) { throw new ArgumentNullException("value"); } byte[] data = new byte[value.Length / 2]; int startIndex = 0; while (startIndex < value.Length) { data[startIndex / 2] = Convert.ToByte(value.Substring(startIndex, 2), 16); startIndex += 2; } return(new Packet(data, timestamp, dataLink)); }
/// <summary> /// Create a packet from an array of bytes. /// </summary> /// <param name="data">The bytes of the packet. This array should not be changed after creating the packet until the packet is no longer used.</param> /// <param name="timestamp">A timestamp of the packet - when it was captured.</param> /// <param name="dataLink">The type of the datalink of the packet.</param> public Packet(byte[] data, DateTime timestamp, DataLinkKind dataLink) : this(data, timestamp, new DataLink(dataLink)) { }
/// <summary> /// Creates a packet from a string that represents bytes in a hexadecimal format. /// </summary> public static Packet FromHexadecimalString(string value, DateTime timestamp, DataLinkKind dataLink) { return(FromHexadecimalString(value, timestamp, new DataLink(dataLink))); }
private static Packet HexToPacket(string hexString, DataLinkKind dataLinkKind) { return Packet.FromHexadecimalString(hexString, DateTime.MinValue, dataLinkKind); }
/// <summary> /// Create a packet from an array of bytes, assuming original length is equal to the data size. /// </summary> /// <param name="data">The bytes of the packet. This array should not be changed after creating the packet until the packet is no longer used.</param> /// <param name="timestamp">A timestamp of the packet - when it was captured.</param> /// <param name="dataLink">The type of the datalink of the packet.</param> /// <param name="originalLength"> /// Length this packet (off wire). /// If the value is less than the data size, it is ignored and the original length is considered to be equal to the data size. /// </param> public Packet(byte[] data, DateTime timestamp, DataLinkKind dataLink, uint originalLength) : this(data, timestamp, new DataLink(dataLink), originalLength) { }
public static void Dump(string fileName, DataLinkKind dataLink, int snapshotLength, IEnumerable <Packet> packets) { PcapDataLink dataLink1 = new PcapDataLink(dataLink); PacketDumpFile.Dump(fileName, dataLink1, snapshotLength, packets); }
private static Packet HexToPacket(string hexString, DataLinkKind dataLinkKind) { return(Packet.FromHexadecimalString(hexString, DateTime.MinValue, dataLinkKind)); }
public BerkeleyPacketFilter(string filterValue, int snapshotLength, DataLinkKind kind, IpV4SocketAddress netmask) { this.Initialize(filterValue, snapshotLength, kind, netmask); }
public DataLink(DataLinkKind kind) { this._kind = kind; }
/// <summary> /// Create the DataLink from a kind. /// </summary> public DataLink(DataLinkKind kind) { _kind = kind; }
public PcapDataLink(DataLinkKind kind) { this._value = PcapDataLink.KindToValue(kind); }
public Packet(byte[] data, DateTime timestamp, DataLinkKind dataLink) : this(data, timestamp, (IDataLink) new PcapDotNet.Packets.DataLink(dataLink)) { }