DHCP Works now.
git-svn-id: https://spexeah.com:8443/svn/Asuro@1034 6dbc8c32-bb84-406f-8558-d1cf31a0ab0c
This commit is contained in:
1 parent
46cb414b43
commit
fbc59a1617
12 files changed
+389
-166
No files matched your search
@@ -36,7 +36,7 @@ uses
|
||||
var
|
||||
CBSend : TNetSendCallback = nil;
|
||||
CBNext : TRecvCallback = nil;
|
||||
MAC : puint8 = @NULL_MAC[0];
|
||||
MAC : puint8 = @NULL_MAC[0];
|
||||
|
||||
procedure writeToLog(str : pchar);
|
||||
var
|
||||
@@ -92,8 +92,8 @@ end;
|
||||
|
||||
procedure send(p_data : void; p_len : uint16);
|
||||
begin
|
||||
push_trace('net.send');
|
||||
writeToLogLn('L1: net.send');
|
||||
//push_trace('net.send');
|
||||
//writeToLogLn('L1: net.send');
|
||||
if CBSend <> nil then CBSend(p_data, p_len);
|
||||
pop_trace;
|
||||
end;
|
||||
@@ -103,8 +103,8 @@ var
|
||||
context : PPacketContext;
|
||||
|
||||
begin
|
||||
push_trace('net.recv');
|
||||
writeToLogLn('L1: net.recv');
|
||||
//push_trace('net.recv');
|
||||
//writeToLogLn('L1: net.recv');
|
||||
context:= newPacketContext;
|
||||
if CBNext <> nil then CBNext(p_data, p_len, context);
|
||||
freePacketContext(context);
|
||||
|
||||
@@ -34,7 +34,6 @@ var
|
||||
|
||||
procedure registerTypePromisc(eType : uint16; RecvCB : TRecvCallback);
|
||||
begin
|
||||
push_trace('eth2.registerType');
|
||||
register;
|
||||
if EthTypes[eType] = nil then EthTypes[eType]:= RecvCB;
|
||||
Promisc[eType]:= true;
|
||||
@@ -42,7 +41,6 @@ end;
|
||||
|
||||
procedure registerType(eType : uint16; RecvCB : TRecvCallback);
|
||||
begin
|
||||
push_trace('eth2.registerType');
|
||||
register;
|
||||
if EthTypes[eType] = nil then EthTypes[eType]:= RecvCB;
|
||||
end;
|
||||
@@ -83,8 +81,7 @@ var
|
||||
buf : puint8;
|
||||
|
||||
begin
|
||||
push_trace('eth2.recv');
|
||||
writeToLogLn(' L2: eth2.recv');
|
||||
//writeToLogLn(' L2: eth2.recv');
|
||||
buf:= puint8(p_data);
|
||||
|
||||
Header:= PEthernetHeader(buf);
|
||||
@@ -102,7 +99,6 @@ begin
|
||||
EthTypes[proto_type](void(buf), p_len - 14, p_context);
|
||||
end;
|
||||
end;
|
||||
pop_trace;
|
||||
end;
|
||||
|
||||
procedure register;
|
||||
|
||||
@@ -80,8 +80,6 @@ var
|
||||
hSize, pSize : uint8;
|
||||
|
||||
begin
|
||||
push_trace('arp.send');
|
||||
writeToLogLn(' L3: arp.send');
|
||||
if p_context <> nil then begin
|
||||
buf:= kalloc(sizeof(TARPHeader));
|
||||
hdr:= PARPHeader(buf);
|
||||
@@ -189,10 +187,6 @@ var
|
||||
context : PPacketContext;
|
||||
|
||||
begin
|
||||
push_trace('arp.recv');
|
||||
writeToLogLn(' L3: arp.recv');
|
||||
console.redrawWindows;
|
||||
|
||||
{ Get our converted Header }
|
||||
Header:= PARPHeader(p_data);
|
||||
AHeader.Hardware_Type:= (Header^.Hardware_Type_Hi SHL 8) + Header^.Hardware_Type_Lo;
|
||||
@@ -219,7 +213,6 @@ begin
|
||||
if IPEqual(@AHeader.Destination_Protocol[0], @getIPv4Config^.Address[0]) then begin
|
||||
case AHeader.Operation of
|
||||
$1:begin { ARP Request }
|
||||
writeToLogLn(' arp.recv.arp.req');
|
||||
context:= newPacketContext;
|
||||
copyMAC(@AHeader.Source_Hardware[0], @context^.MAC.Destination[0]);
|
||||
copyIPv4(@AHeader.Source_Protocol[0], @context^.IP.Destination[0]);
|
||||
@@ -229,28 +222,28 @@ begin
|
||||
freePacketContext(context);
|
||||
end;
|
||||
$2:begin { ARP Reply }
|
||||
writeToLogLn(' arp.recv.arp.rep');
|
||||
|
||||
end;
|
||||
$3:begin { RARP Request }
|
||||
writeToLogLn(' arp.recv.rarp.req');
|
||||
|
||||
end;
|
||||
$4:begin { RARP Reply }
|
||||
writeToLogLn(' arp.recv.rarp.rep');
|
||||
|
||||
end;
|
||||
$5:begin { DRARP Request }
|
||||
writeToLogLn(' arp.recv.drarp.req');
|
||||
|
||||
end;
|
||||
$6:begin { DRARP Reply }
|
||||
writeToLogLn(' arp.recv.drarp.rep');
|
||||
|
||||
end;
|
||||
$7:begin { DRARP Error }
|
||||
writeToLogLn(' arp.recv.drarp.err');
|
||||
|
||||
end;
|
||||
$8:begin { InARP Request }
|
||||
writeToLogLn(' arp.recv.inarp.req');
|
||||
|
||||
end;
|
||||
$9:begin { InARP Reply }
|
||||
writeToLogLn(' arp.recv.inarp.rep');
|
||||
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
@@ -44,7 +44,6 @@ var
|
||||
buffer : void;
|
||||
|
||||
begin
|
||||
writeToLogLn(' L3: ipv4.send');
|
||||
inc(CurrentID);
|
||||
Header.version:= 4;
|
||||
Header.header_len:= 5;
|
||||
@@ -83,8 +82,6 @@ var
|
||||
len : uint16;
|
||||
|
||||
begin
|
||||
push_trace('ipv4.recv');
|
||||
writeToLogLn(' L3: ipv4.recv');
|
||||
Header:= PIPV4Header(p_data);
|
||||
AHeader.version:= Header^.version;
|
||||
AHeader.header_len:= Header^.header_len;
|
||||
@@ -112,7 +109,7 @@ begin
|
||||
copyIPv4(@AHeader.Dst[0], @p_context^.IP.Destination[0]);
|
||||
|
||||
if Config.UP then begin
|
||||
if (IPEqual(@Config.Address[0], @AHeader.Dst[0])) OR (AHeader.Dst[3] = 255) then begin
|
||||
if (IPEqual(@Config.Address[0], @AHeader.Dst[0])) OR (AHeader.Dst[3] = 255) OR (IPEqual(@Config.Address[0], @NULL_IP[0])) then begin
|
||||
if Protocols[AHeader.Protocol] <> nil then begin
|
||||
Protocols[AHeader.Protocol](void(buf), len, p_context);
|
||||
end;
|
||||
@@ -130,7 +127,6 @@ var
|
||||
i : uint32;
|
||||
|
||||
begin
|
||||
push_trace('ipv4.terminal_command_ifconfig');
|
||||
if paramCount(params) > 1 then begin
|
||||
Command:= GetParam(0, Params);
|
||||
if StringEquals(Command, 'set') then begin
|
||||
@@ -177,7 +173,6 @@ begin
|
||||
else
|
||||
writestringlnWND(' NetUP: false', getTerminalHWND);
|
||||
end;
|
||||
pop_trace;
|
||||
end;
|
||||
|
||||
procedure register;
|
||||
@@ -205,7 +200,6 @@ end;
|
||||
|
||||
procedure registerProtocol(Protocol_ID : uint8; recv_callback : TRecvCallback);
|
||||
begin
|
||||
push_trace('ipv4.registerProtocol');
|
||||
register;
|
||||
if Protocols[Protocol_ID] = nil then Protocols[Protocol_ID]:= recv_callback;
|
||||
pop_trace;
|
||||
|
||||
@@ -118,12 +118,10 @@ var
|
||||
Handle : uint8;
|
||||
|
||||
begin
|
||||
writeToLogLn(' L4: icmp.recv');
|
||||
Header:= PICMPHeader(p_data);
|
||||
//writehexlnWND(Header^.ICMP_Type, getTerminalHWND);
|
||||
case Header^.ICMP_Type of
|
||||
$08:Begin //Request
|
||||
writeToLogLn(' L4: icmp.request');
|
||||
contextMACSwitch(p_context);
|
||||
contextIPv4Switch(p_context);
|
||||
Header^.ICMP_Type:= 0;
|
||||
@@ -137,7 +135,6 @@ begin
|
||||
ipv4.send(p_data, p_len, p_context);
|
||||
end;
|
||||
$00:begin //Reply
|
||||
writeToLogLn(' L4: icmp.reply');
|
||||
Handle:= Header^.Identifier;
|
||||
if (Handle > 0) and (Handle < 256) then begin
|
||||
If Handlers[Handle].Active then begin
|
||||
|
||||
@@ -123,20 +123,6 @@ begin
|
||||
memcpy(uint32(hdr), uint32(buffer), sizeof(TUDPHeader));
|
||||
memcpy(uint32(p_data), uint32(buffer) + sizeof(TUDPHeader), p_len);
|
||||
|
||||
writehexln(uint32(buffer) + sizeof(TUDPHeader));
|
||||
for i:=0 to p_len-1 do begin
|
||||
writehexpair(puint8(p_data)[i]);
|
||||
end;
|
||||
writestringln(' ');
|
||||
for i:=0 to p_len-1 do begin
|
||||
writechar(pchar(p_data)[i]);
|
||||
end;
|
||||
writestringln(' ');
|
||||
for i:=0 to size-1 do begin
|
||||
writehexpair(puint8(buffer)[i]);
|
||||
end;
|
||||
writestringln(' ');
|
||||
|
||||
udpContext^.context^.Protocol.L4:= $11;
|
||||
|
||||
ipv4.send(buffer, size, udpContext^.context);
|
||||
@@ -203,7 +189,6 @@ var
|
||||
size : uint16;
|
||||
|
||||
begin
|
||||
writeToLogLn(' L4: udp.recv');
|
||||
header:= PUDPHeader(p_data);
|
||||
if Ports[switchendian16(header^.DstPort)] <> nil then begin
|
||||
context:= PUDPPacketContext(kalloc(sizeof(TUDPPacketContext)));
|
||||
|
||||
+353
-47
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user