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
Asuro.iso

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.

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.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -18,10 +18,19 @@ type
Destination : TIPv4Address; Destination : TIPv4Address;
end; end;
TProtocol = record
L1 : uint16;
L2 : uint16;
L3 : uint16;
L4 : uint16;
end;
PPacketContext = ^TPacketContext; PPacketContext = ^TPacketContext;
TPacketContext = record TPacketContext = record
MAC : TMACPair; MAC : TMACPair;
IP : TIPv4Pair; IP : TIPv4Pair;
Protocol : TProtocol;
TTL : uint8;
end; end;
PIPv4Configuration = ^TIPv4Configuration; PIPv4Configuration = ^TIPv4Configuration;

View File

@ -23,12 +23,74 @@ var
Registered : Boolean = false; Registered : Boolean = false;
Protocols : Array[0..255] of TRecvCallback; Protocols : Array[0..255] of TRecvCallback;
Config : TIPv4Configuration; Config : TIPv4Configuration;
CurrentID : uint16 = 0;
function getIPv4Config : PIPv4Configuration; function getIPv4Config : PIPv4Configuration;
begin begin
getIPv4Config:= @Config; getIPv4Config:= @Config;
end; 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); procedure recv(p_data : void; p_len : uint16; p_context : PPacketContext);
var var
Header : PIPV4Header; Header : PIPV4Header;

View File

@ -556,7 +556,6 @@ begin
net.registerNetworkCard(@sendPacket, getMACAddress()); net.registerNetworkCard(@sendPacket, getMACAddress());
isrmanager.registerISR(32 + PCI_Info^.interrupt_line, @fire); isrmanager.registerISR(32 + PCI_Info^.interrupt_line, @fire);
//IDT.set_gate(32 + PCI_Info^.interrupt_line, uint32(@fire), $08, ISR_RING_0);
enableInturrupt(); enableInturrupt();
rxinit(); rxinit();

View File

@ -3,20 +3,20 @@ unit asuro;
interface interface
const const
VERSION = '1.0.1-677ia'; VERSION = '1.0.1-726ia';
VERSION_MAJOR = '1'; VERSION_MAJOR = '1';
VERSION_MINOR = '0'; VERSION_MINOR = '0';
VERSION_SUB = '1'; VERSION_SUB = '1';
REVISION = '677'; REVISION = '726';
RELEASE = 'ia'; RELEASE = 'ia';
LINE_COUNT = 28115; LINE_COUNT = 28185;
FILE_COUNT = 90; FILE_COUNT = 90;
DRIVER_COUNT = 32; DRIVER_COUNT = 32;
FPC_VERSION = '2.6.4'; FPC_VERSION = '2.6.4';
NASM_VERSION = '2.10.09'; NASM_VERSION = '2.10.09';
MAKE_VERSION = '3.81'; MAKE_VERSION = '3.81';
COMPILE_DATE = '12/05/18'; COMPILE_DATE = '12/05/18';
COMPILE_TIME = '11:08:14'; COMPILE_TIME = '16:05:29';
implementation implementation