📄 u_packet.pas
字号:
(*
* One Way Network Sniffer (OWNS)
* Copyright (C) 2001-2002 OWNS
*
* http://owns.sourceforge.net/
* http://www.owns.st
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*)
(*
* $Id: u_Packet.pas,v 1.2 2002/11/23 21:49:50 owns Exp $
* determines which type of packet is contained in the data
*)
unit u_Packet;
interface
uses u_EthernetFrame, u_IPPacket, u_TCPPacket;
function getPacket(uBuffer: PChar) : TEthernetFrame;
implementation
// return a TPacketTCP, TPacketIp or TPacketEthernet
function getPacket(uBuffer: PChar) : TEthernetFrame;
var
pEthernetHdr: PETHERNET_HDR;
pIPHeader: PIP_RHDR;
nProto, nIPProto: integer;
begin
pEthernetHdr := PETHERNET_HDR(uBuffer);
nProto := TOUSHORT(@(pEthernetHdr^.Protocol[0]));
case nProto of
PROTO_IP:
begin
pIPHeader := PIP_RHDR(@(pEthernetHdr^.Data[0]));
nIPProto := pIPHeader^.Protocol;
case nIPProto of
//TCP
6: result := TTCPPacket.Create(uBuffer);
else
result := TIPPacket.Create(uBuffer);
end;
end;
else
result := TEthernetFrame.Create(uBuffer);
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -