git-svn-id: https://spexeah.com:8443/svn/Asuro@678 6dbc8c32-bb84-406f-8558-d1cf31a0ab0c

This commit is contained in:
kieron
2018-05-10 07:56:44 +00:00
parent fabe8bd6eb
commit 514b6a1683
24 changed files with 57 additions and 18 deletions

View File

@ -6,7 +6,8 @@ uses
tracer,
console,
nettypes, netutils,
netlog;
netlog,
RTC;
procedure init;
procedure registerNetworkCard(SendCallback : TNetSendCallback; _MAC : puint8);
@ -14,6 +15,8 @@ procedure registerNextLayer(RecvCallback : TRecvCallback);
procedure send(p_data : void; p_len : uint16);
procedure recv(p_data : void; p_len : uint16);
function getMAC : puint8;
procedure writeToLog(str : pchar);
procedure writeToLogLn(str : pchar);
implementation
@ -25,6 +28,39 @@ var
CBNext : TRecvCallback = nil;
MAC : puint8 = nil;
procedure writeToLog(str : pchar);
var
DateTime : TDateTime;
begin
if getNetlogHWND <> 0 then begin
DateTime:= getDateTime;
writeStringWND('[', getNetlogHWND);
if DateTime.Hours < 10 then writeIntWND(0, getNetlogHWND);
writeIntWND(DateTime.Hours, getNetlogHWND);
writeStringWND(':', getNetlogHWND);
if DateTime.Minutes < 10 then writeIntWND(0, getNetlogHWND);
writeIntWND(DateTime.Minutes, getNetlogHWND);
writeStringWND(':', getNetlogHWND);
if DateTime.Seconds < 10 then writeIntWND(0, getNetlogHWND);
writeIntWND(DateTime.Seconds, getNetlogHWND);
writeStringWND('] ', getNetlogHWND);
writeStringWND(str, getNetlogHWND);
end;
end;
procedure writeToLogLn(str : pchar);
begin
writeToLog(str);
if getNetlogHWND <> 0 then begin
writestringlnWND(' ', getNetlogHWND);
end;
end;
procedure registerNetworkCard(SendCallback : TNetSendCallback; _MAC : puint8);
begin
push_trace('net.registerNetworkCard');
@ -47,7 +83,7 @@ end;
procedure send(p_data : void; p_len : uint16);
begin
push_trace('net.send');
if getNetlogHWND <> 0 then writestringlnWND('net.send', getNetlogHWND);
writeToLogLn('net.send');
if CBSend <> nil then CBSend(p_data, p_len);
pop_trace;
end;
@ -58,7 +94,7 @@ var
begin
push_trace('net.recv');
if getNetlogHWND <> 0 then writestringlnWND('net.recv', getNetlogHWND);
writeToLogLn('net.recv');
context:= newPacketContext;
if CBNext <> nil then CBNext(p_data, p_len, context);
freePacketContext(context);

View File

@ -22,6 +22,9 @@ function MACToIIPv4(mac : puint8) : puint8;
implementation
uses
net;
var
Registered : Boolean = false;
Cache : PLinkedListBase;
@ -70,7 +73,7 @@ var
begin
push_trace('arp.recv');
if getNetlogHWND <> 0 then writestringlnWND('arp.recv', getNetlogHWND);
writeToLogLn('arp.recv');
{ Get our converted Header }
Header:= PARPHeader(p_data);
AHeader.Hardware_Type:= (Header^.Hardware_Type_Hi SHL 8) + Header^.Hardware_Type_Lo;
@ -84,31 +87,31 @@ begin
copyIPv4(@Header^.Destination_Protocol[0], @AHeader.Destination_Protocol[0]);
case AHeader.Operation of
$1:begin { ARP Request }
if getNetlogHWND <> 0 then writestringlnWND('arp.recv.arp.req', getNetlogHWND);
writeToLogLn('arp.recv.arp.req');
end;
$2:begin { ARP Reply }
if getNetlogHWND <> 0 then writestringlnWND('arp.recv.arp.rep', getNetlogHWND);
writeToLogLn('arp.recv.arp.rep');
end;
$3:begin { RARP Request }
if getNetlogHWND <> 0 then writestringlnWND('arp.recv.rarp.req', getNetlogHWND);
writeToLogLn('arp.recv.rarp.req');
end;
$4:begin { RARP Reply }
if getNetlogHWND <> 0 then writestringlnWND('arp.recv.rarp.rep', getNetlogHWND);
writeToLogLn('arp.recv.rarp.rep');
end;
$5:begin { DRARP Request }
if getNetlogHWND <> 0 then writestringlnWND('arp.recv.drarp.req', getNetlogHWND);
writeToLogLn('arp.recv.drarp.req');
end;
$6:begin { DRARP Reply }
if getNetlogHWND <> 0 then writestringlnWND('arp.recv.drarp.rep', getNetlogHWND);
writeToLogLn('arp.recv.drarp.rep');
end;
$7:begin { DRARP Error }
if getNetlogHWND <> 0 then writestringlnWND('arp.recv.drarp.err', getNetlogHWND);
writeToLogLn('arp.recv.drarp.err');
end;
$8:begin { InARP Request }
if getNetlogHWND <> 0 then writestringlnWND('arp.recv.inarp.req', getNetlogHWND);
writeToLogLn('arp.recv.inarp.req');
end;
$9:begin { InARP Reply }
if getNetlogHWND <> 0 then writestringlnWND('arp.recv.inarp.rep', getNetlogHWND);
writeToLogLn('arp.recv.inarp.rep');
end;
end;
pop_trace;

View File

@ -29,7 +29,7 @@ var
begin
push_trace('ipv4.recv');
if getNetlogHWND <> 0 then writestringlnWND('ipv4.recv', getNetlogHWND);
writeToLogLn('ipv4.recv');
Header:= PIPV4Header(p_data);
AHeader.version:= Header^.version;
AHeader.header_len:= Header^.header_len;

View File

@ -3,20 +3,20 @@ unit asuro;
interface
const
VERSION = '1.0.1-674ia';
VERSION = '1.0.1-677ia';
VERSION_MAJOR = '1';
VERSION_MINOR = '0';
VERSION_SUB = '1';
REVISION = '674';
REVISION = '677';
RELEASE = 'ia';
LINE_COUNT = 27628;
LINE_COUNT = 27664;
FILE_COUNT = 89;
DRIVER_COUNT = 32;
FPC_VERSION = '2.6.4';
NASM_VERSION = '2.10.09';
MAKE_VERSION = '3.81';
COMPILE_DATE = '10/05/18';
COMPILE_TIME = '08:36:31';
COMPILE_TIME = '08:56:35';
implementation