Started work on DHCP.
git-svn-id: https://spexeah.com:8443/svn/Asuro@926 6dbc8c32-bb84-406f-8558-d1cf31a0ab0c
This commit is contained in:
55
src/driver/net/l5/dhcp.pas
Normal file
55
src/driver/net/l5/dhcp.pas
Normal file
@ -0,0 +1,55 @@
|
||||
unit dhcp;
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
lmemorymanager, console,
|
||||
nettypes, netutils, udp, netlog, net,
|
||||
util, rand, lists;
|
||||
|
||||
type
|
||||
TDHCPOptions = PLinkedListBase;
|
||||
PDHCPOptions = ^PLinkedListBase;
|
||||
TDHCPOption = record
|
||||
Opcode : TDHCPOpCode;
|
||||
Size : uint32;
|
||||
Value : void;
|
||||
Header_Location : void;
|
||||
Reverse_Endian : boolean;
|
||||
end;
|
||||
PDHCPOption = ^TDHCPOption;
|
||||
|
||||
procedure register();
|
||||
procedure DHCPDiscover();
|
||||
|
||||
implementation
|
||||
|
||||
var
|
||||
XID : uint32;
|
||||
Socket : PUDPBindContext;
|
||||
|
||||
procedure processPacket(p_data : void; p_len : uint16; context : PUDPPacketContext);
|
||||
begin
|
||||
|
||||
end;
|
||||
|
||||
procedure DHCPDiscover();
|
||||
begin
|
||||
|
||||
end;
|
||||
|
||||
procedure register();
|
||||
begin
|
||||
console.outputln('DHCP', 'Register begin.');
|
||||
Socket:= PUDPBindContext(Kalloc(sizeof(TUDPBindContext)));
|
||||
Socket^.Port:= 68;
|
||||
Socket^.Callback:= @processPacket;
|
||||
Socket^.UID:= rand32;
|
||||
case UDP.bind(Socket) of
|
||||
tueOK:console.outputln('DHCP', 'Successfully bound port 68.');
|
||||
else console.outputln('DHCP', 'Failed to bind port 68.');
|
||||
end;
|
||||
console.outputln('DHCP', 'Register end.');
|
||||
end;
|
||||
|
||||
end.
|
Reference in New Issue
Block a user