Release 17

git-svn-id: https://svn.code.sf.net/p/synalist/code/trunk@37 7c85be65-684b-0410-a082-b2ed4fbef004
This commit is contained in:
geby 2008-04-24 06:44:13 +00:00
parent a68b85e498
commit a644f1e5b4
4 changed files with 55 additions and 23 deletions

View File

@ -1,5 +1,5 @@
{==============================================================================|
| Project : Delphree - Synapse | 001.003.000 |
| Project : Delphree - Synapse | 001.003.001 |
|==============================================================================|
| Content: support for ASN.1 coding and decoding |
|==============================================================================|
@ -14,7 +14,7 @@
| The Original Code is Synapse Delphi Library. |
|==============================================================================|
| The Initial Developer of the Original Code is Lukas Gebauer (Czech Republic).|
| Portions created by Lukas Gebauer are Copyright (c) 1999, 2000. |
| Portions created by Lukas Gebauer are Copyright (c) 1999,2000,2001. |
| Portions created by Hernan Sanchez are Copyright (c) 2000. |
| All Rights Reserved. |
|==============================================================================|
@ -207,12 +207,19 @@ var
s: string;
c: char;
neg: boolean;
l:integer;
begin
Result:='';
ValueType:=ASN1_NULL;
l:=length(buffer);
if l<(start+1)
then exit;
ASNType := Ord(Buffer[Start]);
Valuetype:=ASNType;
Inc(start);
ASNSize := ASNDecLen(Start, Buffer);
Result := '';
if (Start+ASNSize-1)>l
then exit;
if ((ASNType and $20) > 0) then
begin
Result := '$' + IntToHex(ASNType, 2);

View File

@ -1,5 +1,5 @@
{==============================================================================|
| Project : Delphree - Synapse | 002.000.000 |
| Project : Delphree - Synapse | 002.000.001 |
|==============================================================================|
| Content: Library base |
|==============================================================================|
@ -14,7 +14,7 @@
| The Original Code is Synapse Delphi Library. |
|==============================================================================|
| The Initial Developer of the Original Code is Lukas Gebauer (Czech Republic).|
| Portions created by Lukas Gebauer are Copyright (c)1999,2000. |
| Portions created by Lukas Gebauer are Copyright (c)1999,2000,2001. |
| All Rights Reserved. |
|==============================================================================|
| Contributor(s): |
@ -91,6 +91,7 @@ published
property RemoteSin:TSockAddrIn read FRemoteSin;
property LastError:integer read FLastError;
property Protocol:integer read FProtocol;
property LineBuffer:string read FBuffer write FBuffer;
property RaiseExcept:boolean read FRaiseExcept write FRaiseExcept;
end;
@ -120,6 +121,7 @@ begin
FRaiseExcept:=false;
FSocket:=INVALID_SOCKET;
FProtocol:=IPPROTO_IP;
Fbuffer:='';
SockCheck(winsock.WSAStartup($101, FWsaData));
ExceptCheck;
end;
@ -181,6 +183,7 @@ end;
{TBlockSocket.CreateSocket}
Procedure TBlockSocket.CreateSocket;
begin
Fbuffer:='';
if FSocket=INVALID_SOCKET then FLastError:=winsock.WSAGetLastError
else FLastError:=0;
ExceptCheck;
@ -203,6 +206,7 @@ begin
SockCheck(winsock.bind(FSocket,sin,sizeof(sin)));
len:=sizeof(FLocalSin);
Winsock.GetSockName(FSocket,FLocalSin,Len);
Fbuffer:='';
ExceptCheck;
end;
@ -214,6 +218,7 @@ begin
SetSin(sin,ip,port);
SockCheck(winsock.connect(FSocket,sin,sizeof(sin)));
GetSins;
Fbuffer:='';
ExceptCheck;
end;
@ -286,13 +291,10 @@ const
var
x:integer;
s:string;
bp:array[0..maxbuf] of char;
c:char;
pp:pchar;
r:integer;
begin
s:='';
pp:=bp;
FLastError:=0;
c:=#0;
repeat
@ -309,12 +311,11 @@ begin
end
else
begin
r:=Winsock.recv(FSocket,pp^,x,0);
setlength(Fbuffer,x);
r:=Winsock.recv(FSocket,pointer(FBuffer)^,x,0);
SockCheck(r);
if r=0 then FLastError:=WSAENOTCONN;
if FLastError<>0 then break;
bp[r]:=#0;
Fbuffer:=pp;
end;
end;
x:=pos(#10,Fbuffer);

View File

@ -1,5 +1,5 @@
{==============================================================================|
| Project : Delphree - Synapse | 002.002.000 |
| Project : Delphree - Synapse | 002.003.000 |
|==============================================================================|
| Content: SNMP client |
|==============================================================================|
@ -14,7 +14,7 @@
| The Original Code is Synapse Delphi Library. |
|==============================================================================|
| The Initial Developer of the Original Code is Lukas Gebauer (Czech Republic).|
| Portions created by Lukas Gebauer are Copyright (c)2000. |
| Portions created by Lukas Gebauer are Copyright (c)2000,2001. |
| All Rights Reserved. |
|==============================================================================|
| Contributor(s): |
@ -67,7 +67,7 @@ TSNMPRec=class(TObject)
SNMPMibList: TList;
constructor Create;
destructor Destroy; override;
procedure DecodeBuf(Buffer:string);
function DecodeBuf(Buffer:string):boolean;
function EncodeBuf:string;
procedure Clear;
procedure MIBAdd(MIB,Value:string; ValueType:integer);
@ -82,6 +82,7 @@ TSNMPSend=class(TObject)
public
Timeout:integer;
Host:string;
HostIP:string;
Query:TSNMPrec;
Reply:TSNMPrec;
constructor Create;
@ -106,21 +107,32 @@ end;
{TSNMPRec.Destroy}
destructor TSNMPRec.Destroy;
var
i:integer;
begin
for i := 0 to SNMPMibList.count - 1 do
TSNMPMib(SNMPMibList[i]).Free;
SNMPMibList.free;
inherited destroy;
end;
{TSNMPRec.DecodeBuf}
procedure TSNMPRec.DecodeBuf(Buffer:string);
function TSNMPRec.DecodeBuf(Buffer:string):boolean;
var
Pos:integer;
endpos:integer;
sm,sv:string;
svt: integer;
begin
result:=false;
if length(buffer)<2
then exit;
if (ord(buffer[1]) and $20)=0
then exit;
Pos:=2;
Endpos:=ASNDecLen(Pos,buffer);
if length(buffer)<(Endpos+2)
then exit;
Self.version:=StrToIntDef(ASNItem(Pos,buffer,svt),0);
Self.community:=ASNItem(Pos,buffer,svt);
Self.PDUType:=StrToIntDef(ASNItem(Pos,buffer,svt),0);
@ -135,6 +147,7 @@ begin
Sv:=ASNItem(Pos,buffer,svt);
Self.MIBadd(sm,sv, svt);
end;
result:=true;
end;
{TSNMPRec.EncodeBuf}
@ -256,6 +269,7 @@ begin
sock.createsocket;
timeout:=5000;
host:='localhost';
HostIP:='';
end;
{TSNMPSend.Destroy}
@ -276,6 +290,7 @@ begin
reply.clear;
Buffer:=Query.Encodebuf;
sock.connect(host,'161');
HostIP:=sock.GetRemoteSinIP;
sock.SendBuffer(PChar(Buffer),Length(Buffer));
if sock.canread(timeout)
then begin
@ -288,7 +303,7 @@ begin
end;
end;
if Result
then reply.DecodeBuf(Buffer);
then result:=reply.DecodeBuf(Buffer);
end;
{==============================================================================}

View File

@ -1,5 +1,5 @@
{==============================================================================|
| Project : Delphree - Synapse | 002.001.000 |
| Project : Delphree - Synapse | 002.002.000 |
|==============================================================================|
| Content: SNMP traps |
|==============================================================================|
@ -14,7 +14,7 @@
| The Original Code is Synapse Delphi Library. |
|==============================================================================|
| The Initial Developer of the Original Code is Lukas Gebauer (Czech Republic).|
| Portions created by Hernan Sanchez are Copyright (c) 2000. |
| Portions created by Hernan Sanchez are Copyright (c)2000,2001. |
| All Rights Reserved. |
|==============================================================================|
| Contributor(s): |
@ -65,7 +65,7 @@ type
procedure MIBDelete(Index: integer);
function MIBGet(MIB: string): string;
function EncodeTrap: integer;
function DecodeTrap: integer;
function DecodeTrap: boolean;
end;
TTrapSNMP = class(TObject)
@ -99,7 +99,11 @@ begin
end;
destructor TTrapPDU.Destroy;
var
i:integer;
begin
for i := 0 to SNMPMibList.count - 1 do
TSNMPMib(SNMPMibList[i]).Free;
SNMPMibList.free;
inherited Destroy;
end;
@ -205,13 +209,18 @@ begin
Result := 1;
end;
function TTrapPDU.DecodeTrap: integer;
function TTrapPDU.DecodeTrap: boolean;
var
Pos, EndPos: integer;
Sm, Sv: string;
Svt:integer;
begin
clear;
result:=false;
if length(buffer)<2
then exit;
if (ord(buffer[1]) and $20)=0
then exit;
Pos := 2;
EndPos := ASNDecLen(Pos, Buffer);
Version := StrToIntDef(ASNItem(Pos, Buffer,svt), 0);
@ -230,7 +239,7 @@ begin
Sv := ASNItem(Pos, Buffer,svt);
MIBAdd(Sm, Sv, svt);
end;
Result := 1;
Result := true;
end;
constructor TTrapSNMP.Create;
@ -271,8 +280,8 @@ begin
begin
SetLength(Trap.Buffer, x);
Sock.RecvBuffer(PChar(Trap.Buffer), x);
Trap.DecodeTrap;
Result := 1;
if Trap.DecodeTrap
then Result:=1;
end;
end;
end;