Ejemplo n.º 1
0
        private void BuildDHCPACK(PhysicalAddress chaddr, DhcpOption55 dhcpoption55, DhcpLeases dhcplease)
        {
            DhcpLeaseItem item = dhcplease.GetItem(chaddr);

            // 必須
            this.dhcpoptions_.Add(new DhcpOption53(DhcpPacket.MessageType.DHCPACK));
            this.dhcpoptions_.Add(new DhcpOption(54, item.server_identifier_));
            this.dhcpoptions_.Add(new DhcpOption(51, item.lease_time_));

            // 任意
            if (dhcpoption55.parameter_request_list_ != null)
            {
                foreach (byte b in dhcpoption55.parameter_request_list_)
                {
                    switch (b)
                    {
                    case 1: this.dhcpoptions_.Add(new DhcpOption(1, item.subnet_mask_)); break;

                    case 3: this.dhcpoptions_.Add(new DhcpOption(3, item.router_)); break;

                    case 6: this.dhcpoptions_.Add(new DhcpOption(6, item.domain_name_server_)); break;

                    case 58: this.dhcpoptions_.Add(new DhcpOption(58, item.renewal_time_)); break;

                    case 59: this.dhcpoptions_.Add(new DhcpOption(59, item.rebinding_time_)); break;

                    default: break;
                    }
                }
            }

            // 必須(最後必ず)
            this.dhcpoptions_.Add(new DhcpOption(255));
        }
Ejemplo n.º 2
0
        private void BuildDHCPACK(DhcpPacket basePacket, DhcpLeases dhcplease)
        {
            DhcpLeaseItem item = dhcplease.GetItem(basePacket.chaddr_);

            this.op_     = OP.BOOTREPLY;
            this.htype_  = basePacket.htype_;
            this.hlen_   = basePacket.hlen_;
            this.xid_    = basePacket.xid_;
            this.ciaddr_ = basePacket.ciaddr_;
            this.yiaddr_ = item.yiaddr_;
            this.siaddr_ = new IPAddress(0); // 仮
            this.giaddr_ = basePacket.giaddr_;
            this.chaddr_ = basePacket.chaddr_;

            this.options_ = new DhcpOptions(
                DhcpPacket.MessageType.DHCPACK,
                basePacket.chaddr_,
                basePacket.dhcpoption55_,
                dhcplease
                );
        }
Ejemplo n.º 3
0
 // コンストラクタ
 // 受信パケットの Parameter Request List ベース
 public DhcpOptions(DhcpPacket.MessageType message_type, PhysicalAddress chaddr, DhcpOption55 dhcpoption55, DhcpLeases dhcplease)
     : this()
 {
     if (message_type == DhcpPacket.MessageType.DHCPOFFER)
     {
         BuildDHCPOFFER(chaddr, dhcpoption55, dhcplease);
     }
     if (message_type == DhcpPacket.MessageType.DHCPACK)
     {
         BuildDHCPACK(chaddr, dhcpoption55, dhcplease);
     }
 }
Ejemplo n.º 4
0
 // コンストラクタ
 // その他のパケットをベースに作成
 public DhcpPacket(DhcpPacket basePacket, DhcpPacket.MessageType message_type, DhcpLeases dhcplease)
     : this()
 {
     if (message_type == MessageType.DHCPOFFER)
     {
         BuildDHCPOFFER(basePacket, dhcplease);
     }
     if (message_type == MessageType.DHCPACK)
     {
         BuildDHCPACK(basePacket, dhcplease);
     }
 }