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

This commit is contained in:
kieron
2018-05-10 12:17:35 +00:00
parent 2d91631c3d
commit 35edc9e455
23 changed files with 100 additions and 23 deletions

View File

@ -116,6 +116,7 @@ type
const
BROADCAST_MAC : Array[0..5] of uint8 = ($FF, $FF, $FF, $FF, $FF, $FF);
NULL_MAC : Array[0..5] of uint8 = ($00, $00, $00, $00, $00, $00);
implementation

View File

@ -3,10 +3,12 @@ unit netutils;
interface
uses
tracer, util, nettypes, console, lmemorymanager;
tracer, util, nettypes, console, lmemorymanager, lists, strings;
procedure copyMAC(src : puint8; dst : puint8);
procedure copyIPv4(src : puint8; dst : puint8);
function stringToMAC(str : pchar) : puint8;
function stringToIPv4(str : pchar) : puint8;
procedure writeMACAddress(mac : puint8; WND : HWND);
procedure writeIPv4Address(ip : puint8; WND : HWND);
function MACEqual(mac1 : puint8; mac2 : puint8) : boolean;
@ -16,6 +18,36 @@ procedure freePacketContext(p_context : PPacketContext);
implementation
function stringToMAC(str : pchar) : puint8;
var
Mac_Delim : PLinkedListBase;
i : uint32;
begin
stringToMac:= puint8(kalloc(6));
Mac_Delim:= STRLL_FromString(str, ':');
if STRLL_Size(Mac_Delim) >= 6 then begin
for i:=0 to 5 do begin
stringToMAC[i]:= stringToInt(STRLL_Get(Mac_Delim, i));
end;
end;
end;
function stringToIPv4(str : pchar) : puint8;
var
IP_Delim : PLinkedListBase;
i : uint32;
begin
stringToIPv4:= puint8(kalloc(6));
IP_Delim:= STRLL_FromString(str, '.');
if STRLL_Size(IP_Delim) >= 4 then begin
for i:=0 to 3 do begin
stringToIPv4[i]:= stringToInt(STRLL_Get(IP_Delim, i));
end;
end;
end;
function IPEqual(ip1 : puint8; ip2 : puint8) : boolean;
var
i : uint8;