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)); }
// MACアドレスに対応するレコードがあって自動応答か? public bool AutoReply(PhysicalAddress chaddr) { DhcpLeaseItem searchitem = SearchItem(chaddr); // 見つかれば、自動応答かを返却 if (searchitem != null) { return(searchitem.autoreply_); } // 見つからないときは「自動応答ではない」とする return(false); }
// MACアドレスから取得対象のレコードを返却。なければ新規に作成して返却。 public DhcpLeaseItem GetItem(PhysicalAddress chaddr) { DhcpLeaseItem searchitem = SearchItem(chaddr); // 見つかれば返却 if (searchitem != null) { return(searchitem); } // なければ新規に作成 DhcpLeaseItem newitem = new DhcpLeaseItem(chaddr); this.items_.Add(newitem); return(newitem); }
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 ); }
// MACアドレスに対応するレコードがあるか? public bool Matches(PhysicalAddress chaddr) { DhcpLeaseItem searchitem = SearchItem(chaddr); return(searchitem != null); }