Exemple #1
0
        public override Int32 GetAsStream(Byte[] packetAsByteStream, Int32 offset)
        {
            packetAsByteStream[0 + offset] = (Byte)PacketType;
            packetAsByteStream[1 + offset] = HopCount;

            Int32 pointer = 2 + offset;

            var addresses = new IPv6Address[] { LinkAddress, PeerAddress };

            foreach (IPv6Address item in addresses)
            {
                Byte[] addressBytes = item.GetBytes();
                for (int i = 0; i < 16; i++)
                {
                    packetAsByteStream[pointer++] = addressBytes[i];
                }
            }

            Byte[] innerPacket       = new Byte[1500];
            Int32  innerPacketLength = InnerPacket.GetAsStream(innerPacket);

            DHCPv6PacketByteArrayOption relayOption = new DHCPv6PacketByteArrayOption(
                DHCPv6PacketOptionTypes.RelayMessage, innerPacket, innerPacketLength);

            foreach (DHCPv6PacketOption option in Options.Union(new DHCPv6PacketOption[] { relayOption }))
            {
                pointer += option.AppendToStream(packetAsByteStream, pointer);
            }

            return(pointer);
        }
Exemple #2
0
 static DHCPv6PacketOptionFactory()
 {
     _constructorDict = new Dictionary <ushort, Func <byte[], DHCPv6PacketOption> >
     {
         { (UInt16)DHCPv6PacketOptionTypes.ClientIdentifier, (data) => DHCPv6PacketIdentifierOption.FromByteArray(data, 0) },
         { (UInt16)DHCPv6PacketOptionTypes.ServerIdentifer, (data) => DHCPv6PacketIdentifierOption.FromByteArray(data, 0) },
         { (UInt16)DHCPv6PacketOptionTypes.IdentityAssociation_NonTemporary, (data) => DHCPv6PacketIdentityAssociationNonTemporaryAddressesOption.FromByteArray(data, 0) },
         { (UInt16)DHCPv6PacketOptionTypes.IdentityAssociation_Temporary, (data) => DHCPv6PacketIdentityAssociationTemporaryAddressesOption.FromByteArray(data, 0) },
         { (UInt16)DHCPv6PacketOptionTypes.OptionRequest, (data) => DHCPv6PacketOptionRequestOption.FromByteArray(data, 0) },
         { (UInt16)DHCPv6PacketOptionTypes.Preference, (data) => DHCPv6PacketByteOption.FromByteArray(data, 0) },
         { (UInt16)DHCPv6PacketOptionTypes.ElapsedTime, (data) => DHCPv6PacketTimeOption.FromByteArray(data, 0, DHCPv6PacketTimeOption.DHCPv6PacketTimeOptionUnits.HundredsOfSeconds) },
         { (UInt16)DHCPv6PacketOptionTypes.ServerUnicast, (data) => DHCPv6PacketIPAddressOption.FromByteArray(data, 0) },
         { (UInt16)DHCPv6PacketOptionTypes.RapitCommit, (data) => DHCPv6PacketTrueOption.FromByteArray(data, 0) },
         { (UInt16)DHCPv6PacketOptionTypes.UserClass, (data) => DHCPv6PacketUserClassOption.FromByteArray(data, 0) },
         { (UInt16)DHCPv6PacketOptionTypes.VendorClass, (data) => DHCPv6PacketVendorClassOption.FromByteArray(data, 0) },
         { (UInt16)DHCPv6PacketOptionTypes.VendorOptions, (data) => DHCPv6PacketVendorSpecificInformationOption.FromByteArray(data, 0) },
         { (UInt16)DHCPv6PacketOptionTypes.InterfaceId, (data) => DHCPv6PacketByteArrayOption.FromByteArray(data, 0) },
         { (UInt16)DHCPv6PacketOptionTypes.Reconfigure, (data) => DHCPv6PacketReconfigureOption.FromByteArray(data, 0) },
         { (UInt16)DHCPv6PacketOptionTypes.ReconfigureAccepte, (data) => DHCPv6PacketTrueOption.FromByteArray(data, 0) },
         { (UInt16)DHCPv6PacketOptionTypes.IdentityAssociation_PrefixDelegation, (data) => DHCPv6PacketIdentityAssociationPrefixDelegationOption.FromByteArray(data, 0) },
         { (UInt16)DHCPv6PacketOptionTypes.InformationRefreshTime, (data) => DHCPv6PacketTimeOption.FromByteArray(data, 0, DHCPv6PacketTimeOption.DHCPv6PacketTimeOptionUnits.Seconds) },
         { (UInt16)DHCPv6PacketOptionTypes.RemoteIdentifier, (data) => DHCPv6PacketRemoteIdentifierOption.FromByteArray(data, 0) },
         { (UInt16)DHCPv6PacketOptionTypes.SOL_MAX_RT, (data) => DHCPv6PacketUInt32Option.FromByteArray(data, 0) },
         { (UInt16)DHCPv6PacketOptionTypes.INF_MAX_RT, (data) => DHCPv6PacketUInt32Option.FromByteArray(data, 0) },
         { (UInt16)DHCPv6PacketOptionTypes.DNSServer, (data) => DHCPv6PacketIPAddressListOption.FromByteArray(data, 0) },
         { (UInt16)DHCPv6PacketOptionTypes.NTPServer, (data) => DHCPv6PacketIPAddressListOption.FromByteArray(data, 0) },
         { (UInt16)DHCPv6PacketOptionTypes.SNTPServer, (data) => DHCPv6PacketIPAddressListOption.FromByteArray(data, 0) },
     };
 }