private void UDPHandler(ref byte[] PacketData) { UDPData UDP = new UDPData(); IPHandler(UDP, ref PacketData); byte[] p_UDPData = new byte[PacketData.Length - UDP.IP_IHL]; UDP.UDP_SourcePort = (ushort)IPAddress.NetworkToHostOrder(BitConverter.ToInt16(p_UDPData, 0)); UDP.UDP_DestinationPort = (ushort)IPAddress.NetworkToHostOrder(BitConverter.ToInt16(p_UDPData, 2)); UDP.UDP_Length = (ushort)IPAddress.NetworkToHostOrder(BitConverter.ToInt16(p_UDPData, 4)); UDP.UDP_Checksum = (ushort)IPAddress.NetworkToHostOrder(BitConverter.ToInt16(p_UDPData, 6)); if (!((UDP.IP_TotalLength - (UDP.IP_IHL + 8)) <= 0)) { byte[] p_DataSend = new byte[UDP.IP_TotalLength - (8 + UDP.IP_IHL)]; Buffer.BlockCopy(p_UDPData, 8, p_DataSend, 0, p_DataSend.Length); UDP.PacketDataCreate(ref p_DataSend); PRE.fire(UDP); }else return; }
private void UDPHandler(ref byte[] PacketData) { UDPData UDP = new UDPData(); IPHandler(UDP, ref PacketData); byte[] p_UDPData = new byte[PacketData.Length - UDP.IP_IHL]; UDP.UDP_SourcePort = (ushort)IPAddress.NetworkToHostOrder(BitConverter.ToInt16(p_UDPData, 0)); UDP.UDP_DestinationPort = (ushort)IPAddress.NetworkToHostOrder(BitConverter.ToInt16(p_UDPData, 2)); UDP.UDP_Length = (ushort)IPAddress.NetworkToHostOrder(BitConverter.ToInt16(p_UDPData, 4)); UDP.UDP_Checksum = (ushort)IPAddress.NetworkToHostOrder(BitConverter.ToInt16(p_UDPData, 6)); if (!((UDP.IP_TotalLength - (UDP.IP_IHL + 8)) <= 0)) { byte[] p_DataSend = new byte[UDP.IP_TotalLength - (8 + UDP.IP_IHL)]; Buffer.BlockCopy(p_UDPData, 8, p_DataSend, 0, p_DataSend.Length); UDP.PacketDataCreate(ref p_DataSend); PRE.fire(UDP); } else { return; } }