git-svn-id: https://spexeah.com:8443/svn/Asuro@692 6dbc8c32-bb84-406f-8558-d1cf31a0ab0c
This commit is contained in:
parent
2d91631c3d
commit
35edc9e455
BIN
bin/kernel.bin
BIN
bin/kernel.bin
Binary file not shown.
Binary file not shown.
BIN
lib/E1000.ppu
BIN
lib/E1000.ppu
Binary file not shown.
BIN
lib/arp.ppu
BIN
lib/arp.ppu
Binary file not shown.
BIN
lib/asuro.ppu
BIN
lib/asuro.ppu
Binary file not shown.
BIN
lib/eth2.ppu
BIN
lib/eth2.ppu
Binary file not shown.
BIN
lib/ipv4.ppu
BIN
lib/ipv4.ppu
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
lib/libpsystem.a
BIN
lib/libpsystem.a
Binary file not shown.
BIN
lib/net.ppu
BIN
lib/net.ppu
Binary file not shown.
BIN
lib/nettypes.ppu
BIN
lib/nettypes.ppu
Binary file not shown.
BIN
lib/netutils.ppu
BIN
lib/netutils.ppu
Binary file not shown.
BIN
lib/shell.ppu
BIN
lib/shell.ppu
Binary file not shown.
BIN
lib/terminal.ppu
BIN
lib/terminal.ppu
Binary file not shown.
@ -116,6 +116,7 @@ type
|
||||
|
||||
const
|
||||
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
|
||||
|
||||
|
@ -3,10 +3,12 @@ unit netutils;
|
||||
interface
|
||||
|
||||
uses
|
||||
tracer, util, nettypes, console, lmemorymanager;
|
||||
tracer, util, nettypes, console, lmemorymanager, lists, strings;
|
||||
|
||||
procedure copyMAC(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 writeIPv4Address(ip : puint8; WND : HWND);
|
||||
function MACEqual(mac1 : puint8; mac2 : puint8) : boolean;
|
||||
@ -16,6 +18,36 @@ procedure freePacketContext(p_context : PPacketContext);
|
||||
|
||||
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;
|
||||
var
|
||||
i : uint8;
|
||||
|
@ -16,6 +16,9 @@ procedure register;
|
||||
|
||||
implementation
|
||||
|
||||
uses
|
||||
arp;
|
||||
|
||||
var
|
||||
Registered : Boolean = false;
|
||||
EthTypes : Array[0..65535] of TRecvCallback;
|
||||
@ -59,28 +62,17 @@ var
|
||||
begin
|
||||
push_trace('eth2.recv');
|
||||
writeToLogLn(' L2: eth2.recv');
|
||||
//console.outputln('net.eth2', 'RECV.');
|
||||
buf:= puint8(p_data);
|
||||
|
||||
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:= proto_type + Header^.EthTypeLo;
|
||||
//console.output('net.eth2', 'PROTO: ');
|
||||
//console.writehexln(proto_type);
|
||||
|
||||
buf:= buf + 14;
|
||||
|
||||
copyMAC(@Header^.src[0], @p_context^.MAC.Source[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
|
||||
//console.outputln('net.eth2', 'MAC HIT');
|
||||
if EthTypes[proto_type] <> nil then begin
|
||||
EthTypes[proto_type](void(buf), p_len - 14, p_context);
|
||||
end;
|
||||
|
@ -19,6 +19,7 @@ type
|
||||
procedure register;
|
||||
function IPv4ToMAC(ip : puint8) : puint8;
|
||||
function MACToIIPv4(mac : puint8) : puint8;
|
||||
procedure send(hType : uint16; pType : uint16; op : uint16; p_context : PPacketContext);
|
||||
|
||||
implementation
|
||||
|
||||
@ -97,6 +98,9 @@ begin
|
||||
copyIPv4(@p_context^.IP.Source[0], @hdr^.Source_Protocol[0]);
|
||||
copyMAC(@p_context^.MAC.Destination[0], @hdr^.Destination_Hardware[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);
|
||||
end;
|
||||
kfree(buf);
|
||||
|
@ -3,10 +3,11 @@ unit ipv4;
|
||||
interface
|
||||
|
||||
uses
|
||||
tracer,
|
||||
util, console, terminal,
|
||||
tracer, lmemorymanager,
|
||||
util, console, terminal, strings,
|
||||
net, nettypes, netutils,
|
||||
netlog,
|
||||
lists,
|
||||
eth2;
|
||||
|
||||
procedure registerProtocol(Protocol_ID : uint8; recv_callback : TRecvCallback);
|
||||
@ -15,6 +16,9 @@ procedure register;
|
||||
|
||||
implementation
|
||||
|
||||
uses
|
||||
arp;
|
||||
|
||||
var
|
||||
Registered : Boolean = false;
|
||||
Protocols : Array[0..255] of TRecvCallback;
|
||||
@ -74,9 +78,49 @@ begin
|
||||
end;
|
||||
|
||||
procedure terminal_command_ifconfig(params : PParamList);
|
||||
var
|
||||
Command, Sub, Address, Gateway, Netmask : pchar;
|
||||
_Address, _Gateway, _Netmask : puint8;
|
||||
context : PPacketContext;
|
||||
|
||||
begin
|
||||
push_trace('ipv4.terminal_command_ifconfig');
|
||||
if paramCount(params) > 2 then begin
|
||||
if paramCount(params) > 1 then begin
|
||||
Command:= GetParam(0, Params);
|
||||
if StringEquals(Command, 'set') then begin
|
||||
if paramCount(params) > 3 then begin
|
||||
Address:= GetParam(1, Params);
|
||||
Gateway:= GetParam(2, Params);
|
||||
Netmask:= GetParam(3, Params);
|
||||
_Address:= stringToIPv4(Address);
|
||||
_Gateway:= stringToIPv4(Gateway);
|
||||
_Netmask:= stringToIPv4(Netmask);
|
||||
copyIPv4(_Address, @Config.Address[0]);
|
||||
copyIPv4(_Gateway, @Config.Gateway[0]);
|
||||
copyIPv4(_Netmask, @Config.Netmask[0]);
|
||||
kfree(void(_Address));
|
||||
kfree(void(_Gateway));
|
||||
kfree(void(_Netmask));
|
||||
end else begin
|
||||
writestringlnWND('Invalid number of params to call ''set''.', getTerminalHWND);
|
||||
end;
|
||||
end;
|
||||
if StringEquals(Command, 'net') then begin
|
||||
Sub:= GetParam(1, Params);
|
||||
if StringEquals(Sub, 'up') then begin
|
||||
Config.UP:= true;
|
||||
end;
|
||||
if StringEquals(Sub, 'down') then begin
|
||||
Config.UP:= false;
|
||||
end;
|
||||
end;
|
||||
context:= newPacketContext;
|
||||
CopyIPv4(@Config.Gateway[0], @context^.IP.Destination[0]);
|
||||
CopyIPv4(@Config.Address[0], @context^.IP.Source[0]);
|
||||
CopyMAC(GetMAC, @context^.MAC.Source[0]);
|
||||
CopyMAC(@NULL_MAC[0], @context^.MAC.Destination[0]);
|
||||
arp.send($1, $8000, $1, context);
|
||||
freePacketContext(context);
|
||||
end else begin
|
||||
writestringWND(' MAC: ', getTerminalHWND);
|
||||
writeMACAddress(net.GetMAC, getTerminalHWND);
|
||||
|
@ -605,6 +605,7 @@ end;
|
||||
function sendPacket(p_data : void; p_len : uint16) : sint32;
|
||||
var
|
||||
old_cur : uint8;
|
||||
timeout : uint32;
|
||||
|
||||
begin
|
||||
push_trace('E1000.sendPacket');
|
||||
@ -615,9 +616,12 @@ begin
|
||||
old_cur:= tx_curr;
|
||||
tx_curr:= (tx_curr + 1) MOD E1000_NUM_TX_DESC;
|
||||
writeCommand(REG_TXDESCTAIL, tx_curr);
|
||||
while (tx_descs[old_cur]^.status AND $FF) = 0 do begin
|
||||
timeout:= 10000;
|
||||
while ((tx_descs[old_cur]^.status AND $FF) = 0) and (timeout > 0) do begin
|
||||
dec(timeout);
|
||||
end;
|
||||
sendPacket:= 0;
|
||||
sendPacket:= 1;
|
||||
if timeout > 0 then sendPacket:= 0;
|
||||
pop_trace;
|
||||
end;
|
||||
|
||||
|
@ -9,14 +9,14 @@ const
|
||||
VERSION_SUB = '1';
|
||||
REVISION = '677';
|
||||
RELEASE = 'ia';
|
||||
LINE_COUNT = 27778;
|
||||
LINE_COUNT = 27855;
|
||||
FILE_COUNT = 89;
|
||||
DRIVER_COUNT = 32;
|
||||
FPC_VERSION = '2.6.4';
|
||||
NASM_VERSION = '2.10.09';
|
||||
MAKE_VERSION = '3.81';
|
||||
COMPILE_DATE = '10/05/18';
|
||||
COMPILE_TIME = '12:19:23';
|
||||
COMPILE_TIME = '13:17:01';
|
||||
|
||||
implementation
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user