Example #1
0
        /// <summary>
        /// Decodes a UdpDatagram Datagram
        /// </summary>
        public UdpDatagram(IpPacket ReceivedPacket) : base(ReceivedPacket)
        {
            if (Protocol != ProtocolType.Udp)
            {
                throw new ArgumentException("Received Packet is not UDP");
            }

            IsUdp   = true;
            UdpData = new byte[PacketData.Length - 8];
            Array.Copy(PacketData, 8, UdpData, 0, PacketData.Length - 8);

            if (PacketData.Length > 8)
            {
                SourcePort      = PacketData.ReadNetOrderUShort(0);
                DestinationPort = PacketData.ReadNetOrderUShort(2);
                UdpLength       = PacketData.ReadNetOrderUShort(4);
                UdpCheckSum     = PacketData.ReadNetOrderUShort(6);
            }
        }