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

This commit is contained in:
kieron
2018-05-12 15:23:38 +00:00
parent 24027a3109
commit fd2364ecaf
21 changed files with 75 additions and 5 deletions
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
+9
View File
@@ -18,10 +18,19 @@ type
Destination : TIPv4Address;
end;
TProtocol = record
L1 : uint16;
L2 : uint16;
L3 : uint16;
L4 : uint16;
end;
PPacketContext = ^TPacketContext;
TPacketContext = record
MAC : TMACPair;
IP : TIPv4Pair;
Protocol : TProtocol;
TTL : uint8;
end;
PIPv4Configuration = ^TIPv4Configuration;
+62
View File
@@ -23,12 +23,74 @@ var
Registered : Boolean = false;
Protocols : Array[0..255] of TRecvCallback;
Config : TIPv4Configuration;
CurrentID : uint16 = 0;
function getIPv4Config : PIPv4Configuration;
begin
getIPv4Config:= @Config;
end;
function calculateChecksum(p_data : puint16; p_len : uint16) : uint16;
var
sum : uint32;
dat : puint16;
carry : uint16;
i : uint32;
l : uint32;
begin
dat:= p_data;
sum:= 0;
l:= p_len div 2;
for i:=1 to l do begin
sum:= sum + p_data^;
inc(p_data);
end;
while (sum > $FFFF) do begin
carry:= (sum AND $FFFF0000) SHR 16;
sum:= sum + carry;
end;
calculateChecksum:= not sum;
end;
procedure send(p_data : void; p_len : uint16; p_context : PPacketContext);
var
Header : TIPV4Header;
Len : uint16;
CHK : uint16;
buffer : void;
begin
writeToLogLn(' L3: ipv4.send');
inc(CurrentID);
Header.version:= 4;
Header.header_len:= 5;
Header.ToS:= 0;
Len:= 20 + p_len;
Header.total_len_Hi:= Len SHR 8;
Header.total_len_Lo:= Len AND $FF;
Header.identifier_Hi:= CurrentID SHR 8;
Header.identifier_Lo:= CurrentID AND $FF;
Header.Flags:= 0;
Header.Fragment_Off:= 0;
Header.TTL:= p_context^.TTL;
Header.Protocol:= p_context^.Protocol.L4 AND $FF;
Header.HDR_CHK_Hi:= 0;
Header.HDR_CHK_Lo:= 0;
CopyIPv4(@getIPv4Config^.Address[0], @Header.Src[0]);
CopyIPv4(@p_context^.IP.Destination[0], @Header.Dst[0]);
Header.Options:= 0;
Header.Padding:= 0;
CHK:= calculateChecksum(puint16(@Header), sizeof(TIPV4Header));
Header.HDR_CHK_Hi:= CHK SHR 8;
Header.HDR_CHK_Lo:= CHK AND $FF;
Buffer:= kalloc(Len);
memcpy(uint32(@Header), uint32(Buffer), Header.header_len * 4);
memcpy(uint32(p_data), uint32(Buffer) + (Header.header_len * 4), p_len);
eth2.send(Buffer, (Header.header_len * 4) + p_len, $0800, p_context);
kfree(Buffer);
end;
procedure recv(p_data : void; p_len : uint16; p_context : PPacketContext);
var
Header : PIPV4Header;
-1
View File
@@ -556,7 +556,6 @@ begin
net.registerNetworkCard(@sendPacket, getMACAddress());
isrmanager.registerISR(32 + PCI_Info^.interrupt_line, @fire);
//IDT.set_gate(32 + PCI_Info^.interrupt_line, uint32(@fire), $08, ISR_RING_0);
enableInturrupt();
rxinit();

Some files were not shown because too many files have changed in this diff Show More