git-svn-id: https://spexeah.com:8443/svn/Asuro@692 6dbc8c32-bb84-406f-8558-d1cf31a0ab0c
This commit is contained in:
1 parent
2d91631c3d
commit
35edc9e455
23 files changed
+100
-23
No files matched your search
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -116,6 +116,7 @@ type
|
|||||||
|
|
||||||
const
|
const
|
||||||
BROADCAST_MAC : Array[0..5] of uint8 = ($FF, $FF, $FF, $FF, $FF, $FF);
|
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
|
implementation
|
||||||
|
|
||||||
|
|||||||
@@ -3,10 +3,12 @@ unit netutils;
|
|||||||
interface
|
interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
tracer, util, nettypes, console, lmemorymanager;
|
tracer, util, nettypes, console, lmemorymanager, lists, strings;
|
||||||
|
|
||||||
procedure copyMAC(src : puint8; dst : puint8);
|
procedure copyMAC(src : puint8; dst : puint8);
|
||||||
procedure copyIPv4(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 writeMACAddress(mac : puint8; WND : HWND);
|
||||||
procedure writeIPv4Address(ip : puint8; WND : HWND);
|
procedure writeIPv4Address(ip : puint8; WND : HWND);
|
||||||
function MACEqual(mac1 : puint8; mac2 : puint8) : boolean;
|
function MACEqual(mac1 : puint8; mac2 : puint8) : boolean;
|
||||||
@@ -16,6 +18,36 @@ procedure freePacketContext(p_context : PPacketContext);
|
|||||||
|
|
||||||
implementation
|
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;
|
function IPEqual(ip1 : puint8; ip2 : puint8) : boolean;
|
||||||
var
|
var
|
||||||
i : uint8;
|
i : uint8;
|
||||||
|
|||||||
@@ -16,6 +16,9 @@ procedure register;
|
|||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
|
uses
|
||||||
|
arp;
|
||||||
|
|
||||||
var
|
var
|
||||||
Registered : Boolean = false;
|
Registered : Boolean = false;
|
||||||
EthTypes : Array[0..65535] of TRecvCallback;
|
EthTypes : Array[0..65535] of TRecvCallback;
|
||||||
@@ -59,28 +62,17 @@ var
|
|||||||
begin
|
begin
|
||||||
push_trace('eth2.recv');
|
push_trace('eth2.recv');
|
||||||
writeToLogLn(' L2: eth2.recv');
|
writeToLogLn(' L2: eth2.recv');
|
||||||
//console.outputln('net.eth2', 'RECV.');
|
|
||||||
buf:= puint8(p_data);
|
buf:= puint8(p_data);
|
||||||
|
|
||||||
Header:= PEthernetHeader(buf);
|
Header:= PEthernetHeader(buf);
|
||||||
|
|
||||||
//console.output('net.eth2', 'DEST: ');
|
|
||||||
//writeMACAddress(@Header^.dst[0]);
|
|
||||||
//console.output('net.eth2', 'SRC: ');
|
|
||||||
//writeMACAddress(@Header^.src[0]);
|
|
||||||
|
|
||||||
proto_type:= Header^.EthTypeHi SHL 8;
|
proto_type:= Header^.EthTypeHi SHL 8;
|
||||||
proto_type:= proto_type + Header^.EthTypeLo;
|
proto_type:= proto_type + Header^.EthTypeLo;
|
||||||
//console.output('net.eth2', 'PROTO: ');
|
|
||||||
//console.writehexln(proto_type);
|
|
||||||
|
|
||||||
buf:= buf + 14;
|
buf:= buf + 14;
|
||||||
|
|
||||||
copyMAC(@Header^.src[0], @p_context^.MAC.Source[0]);
|
copyMAC(@Header^.src[0], @p_context^.MAC.Source[0]);
|
||||||
copyMAC(@Header^.dst[0], @p_context^.MAC.Destination[0]);
|
copyMAC(@Header^.dst[0], @p_context^.MAC.Destination[0]);
|
||||||
|
|
||||||
if MACEqual(@Header^.dst[0], @Header^.src[0]) or MACEqual(@Header^.dst[0], @BROADCAST_MAC[0]) then begin
|
if MACEqual(@Header^.dst[0], @Header^.src[0]) or MACEqual(@Header^.dst[0], @BROADCAST_MAC[0]) then begin
|
||||||
//console.outputln('net.eth2', 'MAC HIT');
|
|
||||||
if EthTypes[proto_type] <> nil then begin
|
if EthTypes[proto_type] <> nil then begin
|
||||||
EthTypes[proto_type](void(buf), p_len - 14, p_context);
|
EthTypes[proto_type](void(buf), p_len - 14, p_context);
|
||||||
end;
|
end;
|
||||||
|
|||||||
@@ -17,8 +17,9 @@ type
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
procedure register;
|
procedure register;
|
||||||
function IPv4ToMAC(ip : puint8) : puint8;
|
function IPv4ToMAC(ip : puint8) : puint8;
|
||||||
function MACToIIPv4(mac : puint8) : puint8;
|
function MACToIIPv4(mac : puint8) : puint8;
|
||||||
|
procedure send(hType : uint16; pType : uint16; op : uint16; p_context : PPacketContext);
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
@@ -97,6 +98,9 @@ begin
|
|||||||
copyIPv4(@p_context^.IP.Source[0], @hdr^.Source_Protocol[0]);
|
copyIPv4(@p_context^.IP.Source[0], @hdr^.Source_Protocol[0]);
|
||||||
copyMAC(@p_context^.MAC.Destination[0], @hdr^.Destination_Hardware[0]);
|
copyMAC(@p_context^.MAC.Destination[0], @hdr^.Destination_Hardware[0]);
|
||||||
copyIPv4(@p_context^.IP.Destination[0], @hdr^.Destination_Protocol[0]);
|
copyIPv4(@p_context^.IP.Destination[0], @hdr^.Destination_Protocol[0]);
|
||||||
|
if MACEqual(@p_context^.MAC.Destination[0], @NULL_MAC[0]) then begin
|
||||||
|
CopyMAC(@BROADCAST_MAC[0], @p_context^.MAC.Destination[0]);
|
||||||
|
end;
|
||||||
eth2.send(buf, sizeof(TARPHeader), p_context);
|
eth2.send(buf, sizeof(TARPHeader), p_context);
|
||||||
end;
|
end;
|
||||||
kfree(buf);
|
kfree(buf);
|
||||||
|
|||||||
Loaded 20 of 23 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user