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

This commit is contained in:
kieron
2018-04-11 14:21:06 +00:00
parent 3bed07c80a
commit c8b3b14893
43 changed files with 340 additions and 108 deletions

View File

@ -3,7 +3,7 @@ unit netutils;
interface
uses
util, nettypes, console, lmemorymanager;
tracer, util, nettypes, console, lmemorymanager;
procedure copyMAC(src : puint8; dst : puint8);
procedure copyIPv4(src : puint8; dst : puint8);
@ -21,13 +21,15 @@ var
i : uint8;
begin
push_trace('netutils.IPEqual');
IPEqual:= true;
for i:=0 to 3 do begin
if ip1[i] <> ip2[i] then begin
IPEqual:= false;
exit;
break;
end;
end;
pop_trace;
end;
function MACEqual(mac1 : puint8; mac2 : puint8) : boolean;
@ -35,13 +37,15 @@ var
i : uint8;
begin
push_trace('netutils.MACEqual');
MACEqual:= true;
for i:=0 to 5 do begin
if mac1[i] <> mac2[i] then begin
MACEqual:= false;
exit;
break;
end;
end;
pop_trace;
end;
procedure writeIPv4Address(ip : puint8);
@ -49,12 +53,14 @@ var
i : integer;
begin
push_trace('netutils.writeIPv4Address');
console.writeint(ip[0]);
for i:=1 to 3 do begin
console.writestring('.');
console.writeint(ip[i]);
end;
console.writestringln(' ');
pop_trace;
end;
procedure writeMACAddress(mac : puint8);
@ -62,23 +68,29 @@ var
i : integer;
begin
push_trace('netutils.writeMACAddress');
console.writehexpair(mac[0]);
for i:=1 to 5 do begin
console.writestring(':');
console.writehexpair(mac[i]);
end;
console.writestringln(' ');
pop_trace;
end;
function newPacketContext : PPacketContext;
begin
push_trace('netutils.newPacketContext');
newPacketContext:= PPacketContext(kalloc(sizeof(TPacketContext)));
memset(uint32(newPacketContext), 0, sizeof(TPacketContext));
pop_trace;
end;
procedure freePacketContext(p_context : PPacketContext);
begin
push_trace('netutils.freePacketContext');
kfree(void(p_context));
pop_trace;
end;
procedure copyMAC(src : puint8; dst : puint8);
@ -86,9 +98,11 @@ var
i : uint8;
begin
push_trace('netutils.copyMAC');
for i:=0 to 5 do begin
dst[i]:= src[i];
end;
pop_trace;
end;
procedure copyIPv4(src : puint8; dst : puint8);
@ -96,9 +110,11 @@ var
i : uint8;
begin
push_trace('netutils.copyIPv4');
for i:=0 to 3 do begin
dst[i]:= src[i];
end;
pop_trace;
end;
end.