parent
f8c01c285a
commit
780f9f3569
|
@ -51,10 +51,9 @@ void Dhcp::SendDhcp(byte* buf, uint len)
|
|||
name.Append(Sys.ID[0]);
|
||||
|
||||
opt = opt->Next()->SetData(DHCP_OPT_HostName, name);
|
||||
String vendor = "http://www.NewLifeX.com";
|
||||
String vendor = "www.NewLifeX.com";
|
||||
opt = opt->Next()->SetData(DHCP_OPT_Vendor, vendor);
|
||||
byte ps[] = { 0x01, 0x06, 0x03, 0x2b}; // 需要参数 Mask/DNS/Router/Vendor
|
||||
//ByteArray bs(ps, ArrayLength(ps));
|
||||
opt = opt->Next()->SetData(DHCP_OPT_ParameterList, CArray(ps));
|
||||
opt = opt->Next()->End();
|
||||
|
||||
|
@ -76,6 +75,7 @@ void Dhcp::Discover()
|
|||
DHCP_HEADER* dhcp = (DHCP_HEADER*)buf;
|
||||
|
||||
debug_printf("DHCP::Discover...\r\n");
|
||||
dhcpid = Sys.Ms();
|
||||
dhcp->Init(dhcpid, false);
|
||||
|
||||
byte* p = dhcp->Next();
|
||||
|
@ -114,6 +114,9 @@ void Dhcp::Start()
|
|||
ITransport* port = dynamic_cast<ITransport*>(Socket);
|
||||
if(port) port->Open();
|
||||
|
||||
// 使用DHCP之前最好清空本地IP地址,KWF等软路由要求非常严格
|
||||
Host->IP = IPAddress::Any();
|
||||
|
||||
// 创建任务,每秒发送一次Discover
|
||||
if(!taskID)
|
||||
taskID = Sys.AddTask(SendDiscover, this, 0, 1000, "DHCP获取");
|
||||
|
|
|
@ -296,7 +296,7 @@ typedef struct _DHCP_HEADER
|
|||
HardLength = 6;
|
||||
Hops = 0;
|
||||
TransID = __REV(dhcpid);
|
||||
Flags = 0x80; // 从0-15bits,最左一bit为1时表示server将以广播方式传送封包给 client,其余尚未使用
|
||||
//Flags = 0x80; // 从0-15bits,最左一bit为1时表示server将以广播方式传送封包给 client,其余尚未使用
|
||||
SetMagic();
|
||||
|
||||
if(recursion) Prev()->Init(recursion);
|
||||
|
|
Loading…
Reference in New Issue