git-svn-id: https://spexeah.com:8443/svn/Asuro@1045 6dbc8c32-bb84-406f-8558-d1cf31a0ab0c
This commit is contained in:
parent
70593b1c18
commit
03f7d618cb
@ -217,6 +217,22 @@ begin
|
|||||||
readOption32:= read32^;
|
readOption32:= read32^;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function getOptionByOpcode(Options : PDHCPOptions; Opcode : TDHCPOpCode) : PDHCPOption;
|
||||||
|
var
|
||||||
|
Option : PDHCPOption;
|
||||||
|
i : uint16;
|
||||||
|
|
||||||
|
begin
|
||||||
|
getOptionByOpcode:= nil;
|
||||||
|
for i:=0 to getOptionsCount(Options)-1 do begin
|
||||||
|
Option:= getOption(Options, i);
|
||||||
|
if Option^.Opcode = Opcode then begin
|
||||||
|
getOptionByOpcode:= Option;
|
||||||
|
break;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
function writeOptions(Header : PDHCPHeader; Options : PDHCPOptions; newLength : puint16) : PDHCPHeader;
|
function writeOptions(Header : PDHCPHeader; Options : PDHCPOptions; newLength : puint16) : PDHCPHeader;
|
||||||
var
|
var
|
||||||
OptionsSize : uint16;
|
OptionsSize : uint16;
|
||||||
@ -414,11 +430,15 @@ Var
|
|||||||
NewSendHeader : PDHCPHeader;
|
NewSendHeader : PDHCPHeader;
|
||||||
NewHeaderSize : uint32;
|
NewHeaderSize : uint32;
|
||||||
|
|
||||||
|
RequestParams : Array[0..3] of uint8;
|
||||||
|
|
||||||
SendCtx : PUDPSendContext;
|
SendCtx : PUDPSendContext;
|
||||||
PacketCtx : PPacketContext;
|
PacketCtx : PPacketContext;
|
||||||
|
|
||||||
MAC : puint8;
|
MAC : puint8;
|
||||||
|
|
||||||
|
Option : PDHCPOption;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
console.outputln('DHCP', 'Process OFFER.');
|
console.outputln('DHCP', 'Process OFFER.');
|
||||||
|
|
||||||
@ -433,9 +453,21 @@ begin
|
|||||||
|
|
||||||
SendOptions:= newOptions();
|
SendOptions:= newOptions();
|
||||||
SendMsgType:= ord(TDHCPMessageType.REQUEST);
|
SendMsgType:= ord(TDHCPMessageType.REQUEST);
|
||||||
|
|
||||||
NewOption(SendOptions, TDHCPOpCode.DHCP_MESSAGE_TYPE, void(@SendMsgType), 1, false);
|
NewOption(SendOptions, TDHCPOpCode.DHCP_MESSAGE_TYPE, void(@SendMsgType), 1, false);
|
||||||
|
|
||||||
NewOption(SendOptions, TDHCPOpCode.REQUESTED_IP_ADDRESS, void(@SendHeader^.Client_IP[0]), 4, false);
|
NewOption(SendOptions, TDHCPOpCode.REQUESTED_IP_ADDRESS, void(@SendHeader^.Client_IP[0]), 4, false);
|
||||||
NewOption(SendOptions, TDHCPOpCode.SERVER_IDENTIFIER, void(@SendHeader^.Server_IP[0]), 4, false);
|
|
||||||
|
Option:= getOptionByOpcode(Options, TDHCPOpCode.SERVER_IDENTIFIER);
|
||||||
|
if Option <> nil then begin
|
||||||
|
NewOption(SendOptions, TDHCPOpCode.SERVER_IDENTIFIER, void(@Option^.Value[0]), 4, false);
|
||||||
|
end;
|
||||||
|
|
||||||
|
RequestParams[0]:= Ord(TDHCPOpCode.SUBNET_MASK);
|
||||||
|
RequestParams[1]:= Ord(TDHCPOpCode.ROUTER);
|
||||||
|
RequestParams[2]:= Ord(TDHCPOpCode.DOMAIN_NAME);
|
||||||
|
RequestParams[3]:= Ord(TDHCPOpCode.DNS_SERVER);
|
||||||
|
NewOption(SendOptions, TDHCPOpCode.PARAMETER_REQUEST_LIST, void(@RequestParams[0]), 4, false);
|
||||||
NewOption(SendOptions, TDHCPOpCode.END_VENDOR_OPTIONS, nil, 0, false);
|
NewOption(SendOptions, TDHCPOpCode.END_VENDOR_OPTIONS, nil, 0, false);
|
||||||
|
|
||||||
NewSendHeader:= writeOptions(SendHeader, SendOptions, @NewHeaderSize);
|
NewSendHeader:= writeOptions(SendHeader, SendOptions, @NewHeaderSize);
|
||||||
@ -526,6 +558,8 @@ begin
|
|||||||
{ Packet is intended for a DHCP server }
|
{ Packet is intended for a DHCP server }
|
||||||
Outputln('DHCP','Packet is a server packet.');
|
Outputln('DHCP','Packet is a server packet.');
|
||||||
end;
|
end;
|
||||||
|
end else begin
|
||||||
|
Outputln('DHCP', 'Packet is not addressed to us.');
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user