git-svn-id: https://spexeah.com:8443/svn/Asuro@682 6dbc8c32-bb84-406f-8558-d1cf31a0ab0c
This commit is contained in:
1 parent
b050773dda
commit
b03ae36a9a
17 files changed
+126
-32
No files matched your search
@@ -3,12 +3,14 @@ unit eth2;
|
||||
interface
|
||||
|
||||
uses
|
||||
lmemorymanager, util,
|
||||
tracer,
|
||||
nettypes, netutils,
|
||||
net,
|
||||
netlog,
|
||||
console;
|
||||
|
||||
procedure send(p_data : void; p_len : uint16; p_context : PPacketContext);
|
||||
procedure registerType(eType : uint16; RecvCB : TRecvCallback);
|
||||
procedure register;
|
||||
|
||||
@@ -27,6 +29,27 @@ begin
|
||||
pop_trace;
|
||||
end;
|
||||
|
||||
procedure send(p_data : void; p_len : uint16; p_context : PPacketContext);
|
||||
var
|
||||
buffer : void;
|
||||
hdr : TEthernetHeader;
|
||||
|
||||
begin
|
||||
push_trace('eth2.send');
|
||||
writeToLogLn(' L2: eth2.send');
|
||||
if p_context <> nil then begin
|
||||
buffer:= kalloc(p_len + sizeof(TEthernetHeader));
|
||||
copyMAC(@p_context^.MAC.Source[0], @hdr.src[0]);
|
||||
copyMAC(@p_context^.MAC.Destination[0], @hdr.dst[0]);
|
||||
hdr.EthTypeHi:= 0;
|
||||
hdr.EthTypeLo:= 1;
|
||||
memcpy(uint32(@hdr), uint32(buffer), sizeof(TEthernetHeader));
|
||||
memcpy(uint32(p_data), uint32(buffer+sizeof(TEthernetHeader)), p_len);
|
||||
net.send(buffer, p_len + sizeof(TEthernetHeader));
|
||||
kfree(buffer);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure recv(p_data : void; p_len : uint16; p_context : PPacketContext);
|
||||
var
|
||||
Header : PEthernetHeader;
|
||||
|
||||
+95
-30
File diff suppressed because it is too large.
Load diff
@@ -10,6 +10,7 @@ uses
|
||||
eth2;
|
||||
|
||||
procedure registerProtocol(Protocol_ID : uint8; recv_callback : TRecvCallback);
|
||||
function getIPv4Config : PIPv4Configuration;
|
||||
procedure register;
|
||||
|
||||
implementation
|
||||
@@ -19,6 +20,11 @@ var
|
||||
Protocols : Array[0..255] of TRecvCallback;
|
||||
Config : TIPv4Configuration;
|
||||
|
||||
function getIPv4Config : PIPv4Configuration;
|
||||
begin
|
||||
getIPv4Config:= @Config;
|
||||
end;
|
||||
|
||||
procedure recv(p_data : void; p_len : uint16; p_context : PPacketContext);
|
||||
var
|
||||
Header : PIPV4Header;
|
||||
|
||||
Reference in new issue
Block a user