コード例 #1
0
ファイル: Program.cs プロジェクト: NatChung/PacketTestTools
        private static void V6Solicit()
        {
            DhcpV6Message msg = new DhcpV6Message(IPAddress.Any, new IPEndPoint(serverAddr, serverPort));

            msg.SetTransactionId(-1729018559);
            DhcpV6ClientIdOption dhcpClientId = new DhcpV6ClientIdOption();

            dhcpClientId.GetOpaqueData().SetAscii("000100011dd31327001dbac1557b");

            msg.PutDhcpOption(dhcpClientId);

            DhcpV6ElapsedTimeOption dhcpElapsedTime = new DhcpV6ElapsedTimeOption();

            dhcpElapsedTime.SetUnsignedShort(1);
            msg.PutDhcpOption(dhcpElapsedTime);

            msg.SetMessageType(DhcpConstants.V6MESSAGE_TYPE_SOLICIT);
            msg.SetIaNaOptions(new List <DhcpV6IaNaOption>()
            {
                new DhcpV6IaNaOption(new v6IaNaOption()
                {
                    iaId = 285220282, t1 = 0, t2 = 0
                })
            });

            var message = DhcpV6MessageHandler.HandleMessage(serverAddr, msg);

            Console.WriteLine(message.ToString());
        }
コード例 #2
0
        public DHCPv6SendMessage(int transactionId)
        {
            DhcpV6MessagePacket = new DhcpV6Message(IPAddress.Any, new IPEndPoint(IPAddress.Parse("ff02::1:2"), DEST_PORT));
            DhcpV6MessagePacket.SetTransactionId(transactionId);

            DhcpV6ClientIdOption dhcpClientId = new DhcpV6ClientIdOption();

            dhcpClientId.GetOpaqueData().SetHex(new byte[] { 0x00, 0x01, 0x00, 0x01, 0x20, 0x39, 0xBB, 0x3F, 0x98, 0x5F, 0xD3, 0x58, 0x7D, ++duid }); //.SetAscii("000100011dd31327001dbac1557b");
            DhcpV6MessagePacket.PutDhcpOption(dhcpClientId);

            DhcpV6ElapsedTimeOption dhcpElapsedTime = new DhcpV6ElapsedTimeOption();

            dhcpElapsedTime.SetUnsignedShort(1);
            DhcpV6MessagePacket.PutDhcpOption(dhcpElapsedTime);
        }