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

This commit is contained in:
kieron
2018-05-13 19:43:43 +00:00
parent a7c568b06a
commit 17f41d9794
27 changed files with 54 additions and 49 deletions

View File

@ -102,8 +102,8 @@ type
PIPV4Header = ^TIPV4Header;
TIPV4Header = bitpacked record
version : ubit4;
header_len : ubit4;
version : ubit4;
ToS : uint8;
total_len_Hi : uint8;
total_len_Lo : uint8;

View File

@ -70,17 +70,20 @@ var
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);
l:= p_len;
while l > 1 do begin
sum:= sum + dat^;
inc(dat);
l:= l - 2;
end;
while (sum > $FFFF) do begin
carry:= (sum AND $FFFF0000) SHR 16;
sum:= (sum AND $FFFF);
sum:= sum + carry;
if l > 0 then sum:= sum + puint8(dat)^;
while (sum AND $FFFF0000) > 0 do begin
sum:= (sum AND $FFFF) + (sum SHR 16);
end;
calculateChecksum:= not (sum AND $FFFF);
calculateChecksum:= not(sum);
end;
function verifyChecksum(p_data : puint16; p_len : uint16) : boolean;

View File

@ -83,7 +83,7 @@ end;
procedure send(p_data : void; p_len : uint16);
begin
push_trace('net.send');
//writeToLogLn('L1: net.send');
writeToLogLn('L1: net.send');
if CBSend <> nil then CBSend(p_data, p_len);
pop_trace;
end;
@ -94,7 +94,7 @@ var
begin
push_trace('net.recv');
//writeToLogLn('L1: net.recv');
writeToLogLn('L1: net.recv');
context:= newPacketContext;
if CBNext <> nil then CBNext(p_data, p_len, context);
freePacketContext(context);

View File

@ -54,7 +54,7 @@ begin
pad:= 46 - p_len;
if pad < 0 then pad:= 0;
push_trace('eth2.send');
//writeToLogLn(' L2: eth2.send');
writeToLogLn(' L2: eth2.send');
if p_context <> nil then begin
size:= sizeof(TEthernetHeader) + p_len + pad;// + 4;
buffer:= kalloc(size);
@ -79,7 +79,7 @@ var
begin
push_trace('eth2.recv');
//writeToLogLn(' L2: eth2.recv');
writeToLogLn(' L2: eth2.recv');
buf:= puint8(p_data);
Header:= PEthernetHeader(buf);

View File

@ -181,7 +181,7 @@ var
begin
push_trace('arp.recv');
//writeToLogLn(' L3: arp.recv');
writeToLogLn(' L3: arp.recv');
console.redrawWindows;
{ Get our converted Header }
@ -210,7 +210,7 @@ begin
if IPEqual(@AHeader.Destination_Protocol[0], @getIPv4Config^.Address[0]) then begin
case AHeader.Operation of
$1:begin { ARP Request }
//writeToLogLn(' arp.recv.arp.req');
writeToLogLn(' arp.recv.arp.req');
context:= newPacketContext;
copyMAC(@AHeader.Source_Hardware[0], @context^.MAC.Destination[0]);
copyIPv4(@AHeader.Source_Protocol[0], @context^.IP.Destination[0]);
@ -220,28 +220,28 @@ begin
freePacketContext(context);
end;
$2:begin { ARP Reply }
//writeToLogLn(' arp.recv.arp.rep');
writeToLogLn(' arp.recv.arp.rep');
end;
$3:begin { RARP Request }
//writeToLogLn(' arp.recv.rarp.req');
writeToLogLn(' arp.recv.rarp.req');
end;
$4:begin { RARP Reply }
//writeToLogLn(' arp.recv.rarp.rep');
writeToLogLn(' arp.recv.rarp.rep');
end;
$5:begin { DRARP Request }
//writeToLogLn(' arp.recv.drarp.req');
writeToLogLn(' arp.recv.drarp.req');
end;
$6:begin { DRARP Reply }
//writeToLogLn(' arp.recv.drarp.rep');
writeToLogLn(' arp.recv.drarp.rep');
end;
$7:begin { DRARP Error }
//writeToLogLn(' arp.recv.drarp.err');
writeToLogLn(' arp.recv.drarp.err');
end;
$8:begin { InARP Request }
//writeToLogLn(' arp.recv.inarp.req');
writeToLogLn(' arp.recv.inarp.req');
end;
$9:begin { InARP Reply }
//writeToLogLn(' arp.recv.inarp.rep');
writeToLogLn(' arp.recv.inarp.rep');
end;
end;
end;

View File

@ -39,7 +39,7 @@ var
buffer : void;
begin
//writeToLogLn(' L3: ipv4.send');
writeToLogLn(' L3: ipv4.send');
inc(CurrentID);
Header.version:= 4;
Header.header_len:= 5;
@ -60,8 +60,8 @@ begin
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;
Header.HDR_CHK_Hi:= CHK AND $FF;//CHK SHR 8;
Header.HDR_CHK_Lo:= CHK SHR 8;//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);
@ -79,7 +79,7 @@ var
begin
push_trace('ipv4.recv');
//writeToLogLn(' L3: ipv4.recv');
writeToLogLn(' L3: ipv4.recv');
Header:= PIPV4Header(p_data);
AHeader.version:= Header^.version;
AHeader.header_len:= Header^.header_len;
@ -108,7 +108,9 @@ begin
if Config.UP then begin
if (IPEqual(@Config.Address[0], @AHeader.Dst[0])) OR (AHeader.Dst[3] = 255) then begin
if Protocols[AHeader.Protocol] <> nil then Protocols[AHeader.Protocol](void(buf), len, p_context);
if Protocols[AHeader.Protocol] <> nil then begin
Protocols[AHeader.Protocol](void(buf), len, p_context);
end;
end;
end;
pop_trace;

View File

@ -3,7 +3,7 @@ unit icmp;
interface
uses
net, nettypes, netutils, ipv4, console;
net, nettypes, netutils, ipv4, console, terminal;
procedure register;
@ -25,23 +25,26 @@ var
CHK : uint16;
begin
writeToLogLn(' L4: icmp.recv');
writeToLogLn(' L4: icmp.recv');
Header:= PICMPHeader(p_data);
//writehexlnWND(Header^.ICMP_Type, getTerminalHWND);
case Header^.ICMP_Type of
$08:Begin //Request
writeToLogLn(' L4: icmp.request');
contextMACSwitch(p_context);
contextIPv4Switch(p_context);
Header^.ICMP_Type:= 0;
Header^.ICMP_CHK_Hi:= 0;
Header^.ICMP_CHK_Lo:= 0;
CHK:= calculateChecksum(puint16(p_data), sizeof(TICMPHeader));
Header^.ICMP_CHK_Hi:= CHK SHR 8;
Header^.ICMP_CHK_Lo:= CHK AND $FF;
CHK:= calculateChecksum(puint16(p_data), p_len);
Header^.ICMP_CHK_Hi:= CHK AND $FF;
Header^.ICMP_CHK_Lo:= CHK SHR 8;
p_context^.Protocol.L4:= $01;
p_context^.TTL:= 128;
ipv4.send(p_data, p_len, p_context);
end;
$00:begin //Reply
writeToLogLn(' L4: icmp.reply');
end;
end;
end;

View File

@ -417,7 +417,7 @@ var
begin
push_trace('E1000.fire');
//writeToLogLn('L0: E1000 Fire');
writeToLogLn('L0: E1000 Fire');
status:= readCommand($C0);
if (status AND $04) > 0 then begin
startLink();

View File

@ -9,14 +9,14 @@ const
VERSION_SUB = '1';
REVISION = '728';
RELEASE = 'ia';
LINE_COUNT = 28519;
LINE_COUNT = 28522;
FILE_COUNT = 90;
DRIVER_COUNT = 32;
FPC_VERSION = '2.6.4';
NASM_VERSION = '2.10.09';
MAKE_VERSION = '3.81';
COMPILE_DATE = '13/05/18';
COMPILE_TIME = '15:24:12';
COMPILE_TIME = '16:34:39';
implementation

View File

@ -509,19 +509,14 @@ end;
procedure teapot(Params : PParamList);
var
ip1, ip2, ip3 : pchar;
packet : array[0..39] of uint8 = ( $00, $00, $00, $00, $00, $01, $00, $f3, $61, $62, $63, $64, $65, $66, $67, $68,
$69, $6a, $6b, $6c, $6d, $6e, $6f, $70, $71, $72, $73, $74, $75, $76, $77, $61,
$62, $63, $64, $65, $66, $67, $68, $69);
CHK : uint16;
begin
if paramCount(Params) > 2 then begin
ip1:= getParam(0, Params);
ip2:= getParam(1, Params);
ip3:= getParam(2, Params);
if sameSubnetIPv4(stringToIPv4(ip1), stringToIPv4(ip2), stringToIPv4(ip3)) then begin
console.writeStringlnWND('Same.', getTerminalHWND);
end else begin
console.writeStringlnWND('Different', getTerminalHWND);
end;
end;
CHK:= calculateChecksum(puint16(@packet[0]), 40);
writehexlnWND(CHK, getTerminalHWND);
terminal.halt(555, @teapot_halt);
end;