git-svn-id: https://spexeah.com:8443/svn/Asuro@733 6dbc8c32-bb84-406f-8558-d1cf31a0ab0c
This commit is contained in:
@ -46,6 +46,18 @@ type
|
||||
UP : Boolean;
|
||||
end;
|
||||
|
||||
{ ICMP }
|
||||
|
||||
PICMPHeader = ^TICMPHeader;
|
||||
TICMPHeader = record
|
||||
ICMP_Type : uint8;
|
||||
ICMP_Code : uint8;
|
||||
ICMP_CHK_Hi : uint8;
|
||||
ICMP_CHK_Lo : uint8;
|
||||
Identifier : uint16;
|
||||
Sequence : uint16;
|
||||
end;
|
||||
|
||||
{ ARP }
|
||||
|
||||
TARPAbstractHeader = record
|
||||
@ -139,10 +151,17 @@ type
|
||||
{ Constants }
|
||||
|
||||
const
|
||||
{ MACs }
|
||||
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);
|
||||
FORCE_MAC : Array[0..5] of uint8 = ($08, $00, $27, $E6, $3F, $81);
|
||||
|
||||
{ ICMP Data }
|
||||
ICMP_DATA_GENERIC : Array[0..31] of uint8 = ( $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 );
|
||||
|
||||
implementation
|
||||
|
||||
end.
|
@ -19,9 +19,46 @@ function newPacketContext : PPacketContext;
|
||||
procedure freePacketContext(p_context : PPacketContext);
|
||||
function calculateChecksum(p_data : puint16; p_len : uint16) : uint16;
|
||||
function verifyChecksum(p_data : puint16; p_len : uint16) : boolean;
|
||||
function sameSubnetIPv4(ip1, ip2, netmask : puint8) : boolean;
|
||||
procedure contextMACSwitch(p_context : PPacketContext);
|
||||
procedure contextIPv4Switch(p_context : PPacketContext);
|
||||
|
||||
implementation
|
||||
|
||||
function sameSubnetIPv4(ip1, ip2, netmask : puint8) : boolean;
|
||||
var
|
||||
_ip1, _ip2, _netmask : puint32;
|
||||
c1, c2 : uint32;
|
||||
|
||||
begin
|
||||
_ip1:= puint32(ip1);
|
||||
_ip2:= puint32(ip2);
|
||||
_netmask:= puint32(netmask);
|
||||
c1:= _ip1^ AND _netmask^;
|
||||
c2:= _ip2^ AND _netmask^;
|
||||
sameSubnetIPv4:= c1 = c2;
|
||||
end;
|
||||
|
||||
procedure contextMACSwitch(p_context : PPacketContext);
|
||||
var
|
||||
tmp : TMACAddress;
|
||||
|
||||
begin
|
||||
copyMAC(@p_context^.MAC.Source[0], @tmp[0]);
|
||||
copyMAC(@p_context^.MAC.Destination[0], @p_context^.MAC.Source[0]);
|
||||
copyMAC(@tmp[0], @p_context^.MAC.Destination[0]);
|
||||
end;
|
||||
|
||||
procedure contextIPv4Switch(p_context : PPacketContext);
|
||||
var
|
||||
tmp : TIPv4Address;
|
||||
|
||||
begin
|
||||
copyIPv4(@p_context^.IP.Source[0], @tmp[0]);
|
||||
copyIPv4(@p_context^.IP.Destination[0], @p_context^.IP.Source[0]);
|
||||
copyIPv4(@tmp[0], @p_context^.IP.Destination[0]);
|
||||
end;
|
||||
|
||||
function calculateChecksum(p_data : puint16; p_len : uint16) : uint16;
|
||||
var
|
||||
sum : uint32;
|
||||
|
Reference in New Issue
Block a user