internal static PacketOrByteArraySegment ParseEncapsulatedBytes(ByteArraySegment Header, NullPacketType Protocol) { // slice off the payload var payload = Header.EncapsulatedBytes(); log.DebugFormat("Protocol: {0}, payload: {1}", Protocol, payload); var payloadPacketOrData = new PacketOrByteArraySegment(); switch (Protocol) { case NullPacketType.IpV4: payloadPacketOrData.ThePacket = new IPv4Packet(payload); break; case NullPacketType.IpV6: case NullPacketType.IpV6_28: case NullPacketType.IpV6_30: payloadPacketOrData.ThePacket = new IPv6Packet(payload); break; case NullPacketType.IPX: default: throw new System.NotImplementedException("Protocol of " + Protocol + " is not implemented"); } return(payloadPacketOrData); }
#pragma warning restore 0169, 0649 #endif /// <summary> /// Construct a new NullPacket from source and destination mac addresses /// </summary> public NullPacket(NullPacketType nullPacketType) { Log.Debug(""); // allocate memory for this packet var length = NullFields.HeaderLength; var headerBytes = new byte[length]; Header = new ByteArraySegment(headerBytes, 0, length); // setup some typical values and default values Protocol = nullPacketType; }
/// <summary> /// Construct a new NullPacket from source and destination mac addresses /// </summary> public NullPacket(NullPacketType TheType) { log.Debug(""); // allocate memory for this packet int offset = 0; int length = NullFields.HeaderLength; var headerBytes = new byte[length]; header = new ByteArraySegment(headerBytes, offset, length); // setup some typical values and default values this.Protocol = TheType; }