/// <summary>
        /// Pushes this frame to the output queue and adds the ethernet component of this frame according to the given destination address and interface properties.<br />
        /// If fFrame contains an Ethernet component, the Ethernet component is removed.
        /// </summary>
        /// <param name="fFrame">The frame to send.</param>
        /// <param name="ipaDestination">The next hop's IP address of the given frame</param>
        /// <param name="ethType">The ether type of fFrame</param>
        public void Send(Frame fFrame, IPAddress ipaDestination, EtherType ethType)
        {
            EthernetFrame ethFrame = this.GetEthernetFrame(fFrame);

            if (ethFrame != null)
            {
                fFrame = ethFrame.EncapsulatedFrame;
            }
            ethFrame = new EthernetFrame();

            if (ipaDestination.Equals(IPAddress.Broadcast))
            {
                ethFrame.Destination = new MACAddress(new byte[] { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF });
            }
            else if (this.arpHostTable.Contains(ipaDestination))
            {
                ethFrame.Destination = arpHostTable.GetEntry(ipaDestination).MAC;
            }
            else
            {
                StartResolve(ipaDestination);
                ethFrame.Destination = new MACAddress(new byte[] { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF });
            }

            ethFrame.EtherType         = ethType;
            ethFrame.EncapsulatedFrame = fFrame;

            if (!lmacSpoofAdresses.Contains(ethFrame.Source))
            {
                ethFrame.Source = this.PrimaryMACAddress;
            }

            Send(ethFrame);
        }
Exemple #2
0
    public static void ApproximateConvert(double valueGiven, out double resultValue, EtherType givenType, EtherType wantedType)
    {
        HashValue(givenType, out double multiGiven);
        double given = valueGiven * multiGiven;

        HashValue(wantedType, out double multiTo);
        resultValue = given / multiTo;
    }
Exemple #3
0
 /// <summary>
 /// Creates a new instance of this class
 /// </summary>
 public EthernetFrame()
 {
     maSource                 = new MACAddress();
     maDestination            = new MACAddress();
     bVlanTagExists           = false;
     iVlanID                  = 0;
     iVlanPriotity            = 0;
     bCanocialFormatIndicator = false;
     etEtherType              = EtherType.IPv4;
 }
Exemple #4
0
 /// <summary>
 /// Initializes a new instance of the EthernetFrame class using the
 /// specified values.
 /// </summary>
 /// <param name="destination">The physical address of the destination
 /// host.</param>
 /// <param name="source">The physical address of the source host.</param>
 /// <param name="payload">The data transmitted in the frame's payload
 /// field.</param>
 /// <param name="checkSequence">The value to set as the frame's
 /// check sequence.</param>
 /// <param name="type">The type of the encapsulated protocol.</param>
 /// <exception cref="ArgumentNullException">Thrown if any of the
 /// arguments is null.</exception>
 /// <remarks>This is a private constructor solely used for
 /// deserialization.</remarks>
 private Frame(MacAddress destination, MacAddress source,
               byte[] payload, uint checkSequence, EtherType type)
 {
     destination.ThrowIfNull("destination");
     source.ThrowIfNull("source");
     payload.ThrowIfNull("payload");
     Destination   = destination;
     Source        = source;
     Payload       = payload;
     Type          = type;
     CheckSequence = checkSequence;
 }
Exemple #5
0
        /// <summary>
        /// Creates a new instance of this class
        /// </summary>
        public ARPFrame()
        {
            arpHardwareAddressType = HardwareAddressType.Ethernet;
            arpProtocolAddressType = EtherType.IPv4;
            arpOperation           = ARPOperation.Request;

            macSource               = new MACAddress();
            macDestination          = new MACAddress();
            ipaSource               = IPAddress.Any;
            ipaDestination          = IPAddress.Any;
            this.fEncapsulatedFrame = null;
        }
Exemple #6
0
 public static void TryParse(string inValue, out string outValue, EtherType inType, EtherType outType)
 {
     decimal.TryParse(inValue, out decimal inValueDeci);
     ApproximateConvert(inValueDeci, out decimal outValueDeci, inType, outType);
     if (outType == EtherType.Wei)
     {
         outValue = string.Format("{0:0}", outValueDeci);
     }
     else
     {
         outValue = string.Format("{0}", outValueDeci);
     }
 }
Exemple #7
0
 /// <summary>
 /// Wraps the specified data into an Ethernet frame and queues it
 /// for transmission.
 /// </summary>
 /// <param name="destination">The MAC address of the destination
 /// host.</param>
 /// <param name="data">The data to transmit as part of the frame's
 /// payload.</param>
 /// <param name="type">The type of the data.</param>
 public override void Output(MacAddress destination, byte[] data,
                             EtherType type = EtherType.IPv4)
 {
     destination.ThrowIfNull("destination");
     data.ThrowIfNull("data");
     // Start emptying the FIFO, if we're not already doing it.
     if (emptyingFifo == false)
     {
         Simulation.Callback(0, EmptySendFifo);
     }
     // Enqueue the data.
     sendFifo.Enqueue(new Frame(destination, MacAddress, data, type));
 }
        public EthernetPacket(BinaryReader binaryReader, uint Length)
        {
            Dest   = new MACAddress(binaryReader);
            Source = new MACAddress(binaryReader);
            Proto  = (EtherType)BitConverter.ToUInt16(Util.ReverseBytes(binaryReader.ReadBytes(2)), 0);

            if (Proto == EtherType.IPv4) // IPv4
            {
                Data = new IPv4Packet(binaryReader, Length);
            }
            else if (Proto == EtherType.IPv6) // IPv6
            {
            }
        }
Exemple #9
0
    public static void HashValue(EtherType type, out decimal value)
    {
        switch (type)
        {
        case EtherType.Wei: value = 1; return;

        case EtherType.GWei: value = 1000000000; return;

        case EtherType.Ether: value = 1000000000000000000; return;

        default:
            break;
        }
        throw new Exception("Should not be reach");
    }
Exemple #10
0
    public static string GetStringCompressionOf(EtherType type)
    {
        switch (type)
        {
        case EtherType.Wei:
            return("Wei");

        case EtherType.GWei:
            return("GWei");

        case EtherType.Ether:
            return("ETH");

        default:
            break;
        }
        return("");
    }
Exemple #11
0
        /// <summary>
        /// Interrupt method invoked on behalf of the link-layer of the specified
        /// interface whenever frame payload data can be delivered to the network
        /// layer.
        /// </summary>
        /// <param name="ifc">The interface through which the data was received.</param>
        /// <param name="type">The type of the received data.</param>
        /// <param name="data">A sequence of bytes received.</param>
        /// <exception cref="ArgumentNullException">Thrown if the ifc or the data
        /// argument is null.</exception>
        /// <remarks>This API is exposed to the data-link layer.</remarks>
        public void OnInput(Interface ifc, byte[] data, EtherType type)
        {
            ifc.ThrowIfNull("ifc");
            data.ThrowIfNull("data");
            switch (type)
            {
            case EtherType.ARP:
                OnArpInput(ifc, data);
                break;

            case EtherType.IPv4:
                OnIpInput(ifc, data);
                break;

            default:
                WriteLine("Unsupported Ethertype (" + type + "), ignoring data");
                break;
            }
        }
        /// <summary>
        ///   Инициализация фрейма.
        /// </summary>
        /// <param name = "packet">Данные.</param>
        /// <param name = "proto">Тип данных (протокол).</param>
        /// <param name = "source">MAC-адрес источника.</param>
        /// <param name = "destination">MAC-адрес назначения.</param>
        /// <exception cref = "ArgumentNullException"><paramref name = "packet" /> является <c>null</c>.</exception>
        /// <exception cref = "ArgumentNullException"><paramref name = "source" /> является <c>null</c>.</exception>
        /// <exception cref = "ArgumentNullException"><paramref name = "destination" /> является <c>null</c>.</exception>
        protected EthernetFrameBase(IPacket packet, EtherType proto, MACAddress source, MACAddress destination)
        {
            if (packet == null)
                throw new ArgumentNullException ("packet");

            if (source == null)
                throw new ArgumentNullException ("source");

            if (destination == null)
                throw new ArgumentNullException ("destination");

            this.Data = new Array <byte> (new byte[14 + packet.Data.Length]);

            this.Destination = destination;
            this.Source = source;
            this.SetType (proto);

            for (var i = 0; i < packet.Data.Length; ++i)
                this.Data [14 + i] = packet.Data [i];
        }
        /// <summary>
        ///   Инициализация фрейма.
        /// </summary>
        /// <param name = "packet">Данные.</param>
        /// <param name = "proto">Тип данных (протокол).</param>
        /// <param name = "vlan">Номер vlan.</param>
        /// <param name = "source">MAC-адрес источника.</param>
        /// <param name = "destination">MAC-адрес назначения.</param>
        /// <exception cref = "ArgumentNullException"><paramref name = "packet" /> является <c>null</c>.</exception>
        /// <exception cref = "ArgumentNullException"><paramref name = "source" /> является <c>null</c>.</exception>
        /// <exception cref = "ArgumentNullException"><paramref name = "destination" /> является <c>null</c>.</exception>
        public TaggedEthernetFrame(IPacket packet,
            EtherType proto,
            short vlan,
            MACAddress source,
            MACAddress destination)
            : base(packet == null ? 0 : (packet.Data.Length + 4), EtherType.Tagged, source, destination)
        {
            if (packet == null)
                throw new ArgumentNullException ("packet");

            this.Data [14] = this.Data [15] = 0;
            this.CanonicalFormatIndicator = false;
            this.PriorityCodePoint = 0;

            this.VlanID = vlan;
            this.Type = proto;

            for (var i = 0; i < packet.Data.Length; ++i)
                this.Data [18 + i] = packet.Data [i];
        }
Exemple #14
0
		/// <summary>
		/// Initializes a new EthernetFrame instance using the specified values.
		/// </summary>
		/// <param name="destination">The physical address of the destination
		/// host.</param>
		/// <param name="source">The physical address of the source host.</param>
		/// <param name="payload">The data transmitted in the frame's payload
		/// field.</param>
		/// <param name="type">The type of the encapsulated protocol.</param>
		/// <exception cref="ArgumentNullException">Thrown if any of the
		/// arguments is null.</exception>
		/// <exception cref="ArgumentException">Thrown if the payload parameter
		/// does not satisfy the Ethernet 802.3 length requirements.</exception>
		public Frame(MacAddress destination, MacAddress source,
			byte[] payload, EtherType type) {
				destination.ThrowIfNull("destination");
				source.ThrowIfNull("source");
				payload.ThrowIfNull("payload");
				if (payload.Length > MaximumPayloadSize)
					throw new ArgumentException("The frame payload data must " +
						"not exceed 1500 bytes of data.", nameof(payload));
				Destination = destination;
				Source = source;
				Payload = payload;
				Type = type;
				CheckSequence = Crc32.Compute(
					new ByteBuilder()
					.Append(Destination.Bytes)
					.Append(Source.Bytes)
					.Append((short)Type)
					.Append(Payload)
					.ToArray()
				);
		}
Exemple #15
0
        /// <summary>
        /// Creates a new instance of this class by parsing the given data
        /// </summary>
        /// <param name="bData">The data to parse</param>
        public EthernetFrame(byte[] bData)
        {
            //Pad is not used by pcap.
            //if (bData.Length < 64)
            //{
            //    throw new ArgumentException("Invalid packet length");
            //}
            byte[] bSourceAddressbytes      = new byte[6];
            byte[] bDestinationAddressbytes = new byte[6];
            byte[] bEncapsulatedData        = null;

            for (int iC1 = 0; iC1 < 6; iC1++)
            {
                bDestinationAddressbytes[iC1] = bData[iC1];
                bSourceAddressbytes[iC1]      = bData[iC1 + 6];
            }

            maSource      = new MACAddress(bSourceAddressbytes);
            maDestination = new MACAddress(bDestinationAddressbytes);


            etEtherType = (EtherType)((bData[12] << 8) + bData[13]);

            if (etEtherType == EtherType.VLANTag)
            {
                bVlanTagExists           = true;
                bCanocialFormatIndicator = (bData[14] & 0x80) > 0 ? true : false;
                iVlanPriotity            = (bData[14] & 0x70) >> 4;
                iVlanID     = (bData[14] & 0x0F) * 256 + bData[15];
                etEtherType = (EtherType)(bData[16] * 256 + bData[17]);

                bEncapsulatedData = new byte[bData.Length - 18];
                Encapsulate(bData, 18);
            }
            else
            {
                bVlanTagExists = false;
                Encapsulate(bData, 14);
            }
        }
Exemple #16
0
 /// <summary>
 /// Initializes a new EthernetFrame instance using the specified values.
 /// </summary>
 /// <param name="destination">The physical address of the destination
 /// host.</param>
 /// <param name="source">The physical address of the source host.</param>
 /// <param name="payload">The data transmitted in the frame's payload
 /// field.</param>
 /// <param name="type">The type of the encapsulated protocol.</param>
 /// <exception cref="ArgumentNullException">Thrown if any of the
 /// arguments is null.</exception>
 /// <exception cref="ArgumentException">Thrown if the payload parameter
 /// does not satisfy the Ethernet 802.3 length requirements.</exception>
 public Frame(MacAddress destination, MacAddress source,
              byte[] payload, EtherType type)
 {
     destination.ThrowIfNull("destination");
     source.ThrowIfNull("source");
     payload.ThrowIfNull("payload");
     if (payload.Length > MaximumPayloadSize)
     {
         throw new ArgumentException("The frame payload data must " +
                                     "not exceed 1500 bytes of data.", nameof(payload));
     }
     Destination   = destination;
     Source        = source;
     Payload       = payload;
     Type          = type;
     CheckSequence = Crc32.Compute(
         new ByteBuilder()
         .Append(Destination.Bytes)
         .Append(Source.Bytes)
         .Append((short)Type)
         .Append(Payload)
         .ToArray()
         );
 }
Exemple #17
0
		/// <summary>
		/// Initializes a new instance of the EthernetFrame class using the
		/// specified values.
		/// </summary>
		/// <param name="destination">The physical address of the destination
		/// host.</param>
		/// <param name="source">The physical address of the source host.</param>
		/// <param name="payload">The data transmitted in the frame's payload
		/// field.</param>
		/// <param name="checkSequence">The value to set as the frame's
		/// check sequence.</param>
		/// <param name="type">The type of the encapsulated protocol.</param>
		/// <exception cref="ArgumentNullException">Thrown if any of the
		/// arguments is null.</exception>
		/// <remarks>This is a private constructor solely used for
		/// deserialization.</remarks>
		private Frame(MacAddress destination, MacAddress source,
			byte[] payload, uint checkSequence, EtherType type) {
				destination.ThrowIfNull("destination");
				source.ThrowIfNull("source");
				payload.ThrowIfNull("payload");
				Destination = destination;
				Source = source;
				Payload = payload;
				Type = type;
				CheckSequence = checkSequence;
		}
 /// <summary>
 /// Initializes a new instance of the DataReceivedEventArgs class.
 /// </summary>
 /// <param name="data">The data that was transmitted.</param>
 /// <param name="type">The protocol encapsulated in the payload of the Ethernet
 /// frame.</param>
 public DataReceivedEventArgs(byte[] data, EtherType type)
 {
     Data = data;
     Type = type;
 }
Exemple #19
0
        /// <summary>
        /// Creates a newinstance of this class from the given data.
        /// </summary>
        /// <param name="bData">The data to parse.</param>
        public ARPFrame(byte[] bData)
        {
            arpHardwareAddressType = (HardwareAddressType)((int)((bData[0] << 8) + bData[1]));
            arpProtocolAddressType = (EtherType)((int)((bData[2] << 8) + bData[3]));
            int iHardwareAddressLength = bData[4];
            int iProtocolAddressLength = bData[5];

            arpOperation = (ARPOperation)((int)((bData[6] << 8) + bData[7]));


            if (arpHardwareAddressType != HardwareAddressType.Ethernet || (arpProtocolAddressType != EtherType.IPv4 && arpProtocolAddressType != EtherType.IPv6))
            {
                throw new ArgumentException("Only IPv6 and IPv4 in conjunction with ethernet is supported at the moment.");
            }

            if (iHardwareAddressLength != 6 && arpHardwareAddressType != HardwareAddressType.Ethernet)
            {
                throw new ArgumentException("The hardware address type of the ARP frame indicates Ethernet, but the address data is not 6 bytes long.");
            }

            if (iProtocolAddressLength != 4 && EtherType.IPv4 == arpProtocolAddressType)
            {
                throw new ArgumentException("The protocol address type of the ARP frame indicates IPv4, but the address data is not 4 bytes long.");
            }
            if (iProtocolAddressLength != 16 && EtherType.IPv6 == arpProtocolAddressType)
            {
                throw new ArgumentException("The protocol address type of the ARP frame indicates IPv6, but the address data is not 16 bytes long.");
            }

            int iC1 = 8;

            byte[] bAddress = new byte[iHardwareAddressLength];

            for (int iC2 = 0; iC2 < iHardwareAddressLength; iC2++)
            {
                Array.Copy(bData, iC1, bAddress, 0, iHardwareAddressLength);
            }
            iC1      += iHardwareAddressLength;
            macSource = new MACAddress(bAddress);


            bAddress = new byte[iProtocolAddressLength];
            Array.Copy(bData, iC1, bAddress, 0, iProtocolAddressLength);
            iC1      += iProtocolAddressLength;
            ipaSource = new IPAddress(bAddress);


            bAddress = new byte[iHardwareAddressLength];
            Array.Copy(bData, iC1, bAddress, 0, iHardwareAddressLength);
            iC1           += iHardwareAddressLength;
            macDestination = new MACAddress(bAddress);

            bAddress = new byte[iProtocolAddressLength];
            Array.Copy(bData, iC1, bAddress, 0, iProtocolAddressLength);
            iC1           += iProtocolAddressLength;
            ipaDestination = new IPAddress(bAddress);

            byte[] bPad = new byte[bData.Length - iC1];

            for (int iC2 = 0; iC2 < bPad.Length; iC2++)
            {
                bPad[iC2] = bData[iC2 + iC1];
            }

            this.fEncapsulatedFrame = new RawDataFrame(bPad);
        }
 private void SetType(EtherType value)
 {
     this.Data [12] = (byte) ((ushort) value >> 8);
     this.Data [13] = (byte) ((ushort) value & 0xFF);
 }
Exemple #21
0
 /// <summary>
 /// Constructs a new data-link frame for the specified destination,
 /// containing the specified data as payload.
 /// </summary>
 /// <param name="destination">The phyical destination address.</param>
 /// <param name="data">The data to send as the frame's payload.</param>
 /// <param name="type">The type of the data.</param>
 /// <exception cref="ArgumentNullException">Thrown if the destination
 /// or the data parameter is null.</exception>
 public abstract void Output(MacAddress destination, byte[] data,
                             EtherType type);
Exemple #22
0
		/// <summary>
		/// Wraps the specified data into an Ethernet frame and queues it
		/// for transmission.
		/// </summary>
		/// <param name="destination">The MAC address of the destination
		/// host.</param>
		/// <param name="data">The data to transmit as part of the frame's
		/// payload.</param>
		/// <param name="type">The type of the data.</param>
		public override void Output(MacAddress destination, byte[] data,
			EtherType type = EtherType.IPv4) {
			destination.ThrowIfNull("destination");
			data.ThrowIfNull("data");
			// Start emptying the FIFO, if we're not already doing it.
			if (emptyingFifo == false)
				Simulation.Callback(0, EmptySendFifo);
			// Enqueue the data.
			sendFifo.Enqueue(new Frame(destination, MacAddress, data, type));
		}
Exemple #23
0
    public static void ApproximateConvert(decimal valueGiven, out decimal resultValue, EtherType givenType, EtherType wantedType)
    {
        HashValue(givenType, out decimal multiGiven);
        decimal given = (valueGiven) * multiGiven;

        HashValue(wantedType, out decimal multiTo);
        resultValue = given / multiTo;
    }
Exemple #24
0
 public EthereumDecimalValue(decimal value, EtherType sourceType)
 {
     m_value      = value;
     m_sourceType = sourceType;
 }
 /// <summary>
 ///   Инициализация фрейма.
 /// </summary>
 /// <param name = "packet">Данные.</param>
 /// <param name = "proto">Тип данных (протокол).</param>
 /// <param name = "source">MAC-адрес источника.</param>
 /// <param name = "destination">MAC-адрес назначения.</param>
 /// <exception cref = "ArgumentNullException"><paramref name = "packet" /> является <c>null</c>.</exception>
 /// <exception cref = "ArgumentNullException"><paramref name = "source" /> является <c>null</c>.</exception>
 /// <exception cref = "ArgumentNullException"><paramref name = "destination" /> является <c>null</c>.</exception>
 public EthernetFrame(IPacket packet, EtherType proto, MACAddress source, MACAddress destination)
     : base(packet, proto, source, destination)
 {
 }
Exemple #26
0
 public void SetWith(IEtherValue value)
 {
     value.Get(out EtherType t, out decimal v);
     this.m_sourceType = t;
     this.m_value      = (double)v;
 }
Exemple #27
0
 /// <summary>
 /// Hands down the specified data to the data-link layer implementation of the NIC.
 /// </summary>
 /// <param name="destination">The phyical destination address.</param>
 /// <param name="data">The data to send as the frame's payload.</param>
 /// <param name="type">The type of the data.</param>
 public void Output(MacAddress destination, byte[] data, EtherType type =
                    EtherType.IPv4)
 {
     Nic.Output(destination, data, type);
 }
Exemple #28
0
 public void Get(out EtherType typeUsedToStore, out double storedValue)
 {
     typeUsedToStore = m_sourceType;
     storedValue     = (double)m_value;
 }
Exemple #29
0
 private void WriteEthernetHeader(EtherType etherType)
 {
     writter.Write(mac1);
     writter.Write(mac2);
     writter.Write(IPAddress.HostToNetworkOrder((short)etherType));
 }
Exemple #30
0
		/// <summary>
		/// Constructs a new data-link frame for the specified destination,
		/// containing the specified data as payload.
		/// </summary>
		/// <param name="destination">The phyical destination address.</param>
		/// <param name="data">The data to send as the frame's payload.</param>
		/// <param name="type">The type of the data.</param>
		/// <exception cref="ArgumentNullException">Thrown if the destination
		/// or the data parameter is null.</exception>
		public abstract void Output(MacAddress destination, byte[] data,
			EtherType type);
        /// <summary>
        /// Initializes a new instance of the DataReceivedEventArgs class.
        /// </summary>
        /// <param name="data">The data that was transmitted.</param>
        /// <param name="type">The protocol encapsulated in the payload of the Ethernet
        /// frame.</param>
		public DataReceivedEventArgs(byte[] data, EtherType type) {
			Data = data;
			Type = type;
		}
Exemple #32
0
        /// <summary>
        /// Hands down the specified data to the data-link layer implementation of the NIC.
        /// </summary>
		/// <param name="destination">The phyical destination address.</param>
		/// <param name="data">The data to send as the frame's payload.</param>
		/// <param name="type">The type of the data.</param>
		public void Output(MacAddress destination, byte[] data, EtherType type =
			EtherType.IPv4) {
				Nic.Output(destination, data, type);
		}
Exemple #33
0
 public void Get(out EtherType typeUsedToStore, out decimal storedValue)
 {
     typeUsedToStore = m_sourceType;
     storedValue     = (decimal)m_value;
 }
 private void WriteEthernetHeader(EtherType etherType)
 {
     writter.Write(mac1);
     writter.Write(mac2);
     writter.Write(IPAddress.HostToNetworkOrder((short)etherType));
 }
Exemple #35
0
 public void Get(EtherType type, out double approximation)
 {
     EthereumConverttion.ApproximateConvert(m_value, out approximation, m_sourceType, type);
 }
Exemple #36
0
 public EthereumDoubleValue(double value, EtherType sourecType)
 {
     m_value      = value;
     m_sourceType = sourecType;
 }
Exemple #37
0
 public static string ToString(IEtherValue ethereumDoubleValue, EtherType wantedType, string decimalFormat = "{0:0.00} {1}")
 {
     ethereumDoubleValue.Get(out EtherType currentValueType, out double currentvalue);
     ApproximateConvert(currentvalue, out double resultvalue, currentValueType, wantedType);
     return(string.Format(decimalFormat, resultvalue, wantedType));
 }
        /// <summary>
        ///   Инициализация фрейма.
        /// </summary>
        /// <param name = "length">Длина данных.</param>
        /// <param name = "proto">Тип данных (протокол).</param>
        /// <param name = "source">MAC-адрес источника.</param>
        /// <param name = "destination">MAC-адрес назначения.</param>
        /// <exception cref = "ArgumentNullException"><paramref name = "source" /> является <c>null</c>.</exception>
        /// <exception cref = "ArgumentNullException"><paramref name = "destination" /> является <c>null</c>.</exception>
        protected EthernetFrameBase(int length, EtherType proto, MACAddress source, MACAddress destination)
        {
            if (source == null)
                throw new ArgumentNullException ("source");

            if (destination == null)
                throw new ArgumentNullException ("destination");

            this.Data = new Array <byte> (new byte[14 + length]);

            this.Destination = destination;
            this.Source = source;
            this.SetType (proto);
        }
Exemple #39
-1
 public void FillWithChecksums(EtherType[] supportedEtherTypes, IPProtocolType[] supportedIpProtocolTypes)
 {
     var packetNetIpProtocols = supportedIpProtocolTypes.Select(x => (PacketDotNet.IPProtocolType)x).ToArray();
     var packetNetEtherTypes = supportedEtherTypes.Select(x => (EthernetPacketType)x).ToArray();
     packet.RecursivelyUpdateCalculatedValues(packetNetEtherTypes, packetNetIpProtocols);
 }