?? cap_main.~pas
字號:
unit cap_main;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
cap_ip, StdCtrls, ExtCtrls, Grids, ComCtrls, Buttons, Menus;
//type
// Tmy_data=record
// buf:array of char;
//end;
type
TForm1 = class(TForm)
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
BitBtn3: TBitBtn;
BitBtn4: TBitBtn;
PageControl1: TPageControl;
TabSheet1: TTabSheet;
StringGrid1: TStringGrid;
BitBtn5: TBitBtn;
TabSheet2: TTabSheet;
Panel1: TPanel;
ListView1: TListView;
PageControl2: TPageControl;
TabSheet3: TTabSheet;
TabSheet4: TTabSheet;
Memo1: TMemo;
Memo2: TMemo;
procedure FormCreate(Sender: TObject);
procedure LJNETDATA(ip, proto, sourceIP, destIP, SourcePort,
DestPort: String; header: PChar; header_size: Integer; data: PChar;
data_size: Integer);
procedure BitBtn1Click(Sender: TObject);
procedure BitBtn2Click(Sender: TObject);
procedure BitBtn3Click(Sender: TObject);
procedure BitBtn4Click(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure StringGrid1Click(Sender: TObject);
procedure BitBtn5Click(Sender: TObject);
private
{ Private declarations }
public
// function check_filter(proto, sourceIP, destIP, SourcePort,DestPort: String;data: PChar;data_size: Integer):boolean;
end;
var
Form1: TForm1;
// buf_list:array of Tmy_data;
// filter_str:string;
cap_ip1:Tcap_ip;
implementation
{$R *.DFM}
procedure TForm1.FormCreate(Sender: TObject);
begin
with StringGrid1.Rows[0] do
begin
Add('協議類型');
Add('源地址');
Add('源端口');
Add('目的地址');
Add('目的端口');
Add('數據大小');
Add('數據內容');
end;
// setlength(buf_list,200);
cap_ip1:=Tcap_ip.Create(self);
cap_ip1.OnCap:=LJNETDATA;
end;
procedure TForm1.LJNETDATA(ip, proto, sourceIP, destIP, SourcePort,
DestPort: String; header: PChar; header_size: Integer; data: PChar;
data_size: Integer);
begin
//if check_filter(proto,sourceIP, destIP, SourcePort,DestPort, data,data_size) then exit;
//IF (sourceIP <> '192.168.1.18') and (destIP <> '192.168.1.18') then
// exit;
IF (SourcePort <> '9998') and (DestPort <> '9998') then
exit;
if proto ='UDP' then exit;
with StringGrid1 do
begin
Cells[0,StringGrid1.RowCount-1]:=proto;
Cells[1,StringGrid1.RowCount-1]:=sourceIP;
Cells[2,StringGrid1.RowCount-1]:=SourcePort;
Cells[3,StringGrid1.RowCount-1]:=destIP;
Cells[4,StringGrid1.RowCount-1]:=DestPort;
Cells[5,StringGrid1.RowCount-1]:=inttostr(data_size);
Cells[6,StringGrid1.RowCount-1]:=data;
end;
// setlength(buf_list[StringGrid1.RowCount-2].buf,data_size);
// copymemory(buf_list[StringGrid1.RowCount-2].buf,data,data_size);
if (StringGrid1.RowCount>1000) then
StringGrid1.RowCount:=2
else
begin
StringGrid1.RowCount:=StringGrid1.RowCount+1;
StringGrid1.Rows[StringGrid1.RowCount].Clear;
end;
stringgrid1.toprow:=StringGrid1.RowCount- StringGrid1.VisibleRowCount;
end;
procedure TForm1.BitBtn1Click(Sender: TObject);
begin
cap_ip1.StartCap;
end;
procedure TForm1.BitBtn2Click(Sender: TObject);
begin
cap_ip1.pause;
if cap_ip1.Fpause then
BitBtn2.Caption:='繼續捕捉'
else
BitBtn2.Caption:='暫停捕捉';
end;
procedure TForm1.BitBtn3Click(Sender: TObject);
begin
cap_ip1.StopCap;
end;
procedure TForm1.BitBtn4Click(Sender: TObject);
begin
close;
end;
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
cap_ip1.Free;
end;
procedure TForm1.StringGrid1Click(Sender: TObject);
var
str,ShowStr:string;
i:integer;
begin
str := StringGrid1.Cells[6,StringGrid1.row];
memo1.text := str;
ShowStr:='';
for i :=1 to length(str) do
begin
ShowStr := ShowStr + ' '+ IntToHex(byte(str[i]),2);
end;
memo2.text := ShowStr;
end;
procedure TForm1.BitBtn5Click(Sender: TObject);
begin
stringGrid1.RowCount :=2;
with StringGrid1 do
begin
Cells[0,StringGrid1.RowCount-1]:='';
Cells[1,StringGrid1.RowCount-1]:='';
Cells[2,StringGrid1.RowCount-1]:='';
Cells[3,StringGrid1.RowCount-1]:='';
Cells[4,StringGrid1.RowCount-1]:='';
Cells[5,StringGrid1.RowCount-1]:='';
Cells[6,StringGrid1.RowCount-1]:='';
end;
end;
end.
///////公共
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -