6

http://synapse.ararat.cz/files/contrib/Trap.zipからダウンロードした TrapSend.dpr サンプル プロジェクトを変更して、SNMP v2 トラップを送信しようとしましたが、成功しませんでした。注: サンプルを使用して SNMP v1 トラップを正常に送信できました。

これは、SNMPTrap.pas の元の関数 SendTrap です。

function SendTrap(Dest, Source, Enterprise, Community: string;
  Generic, Specific, Seconds: integer; MIBName, MIBValue: string; MIBtype:integer): integer;
var
  SNMP: TTrapSNMP;
begin
  SNMP := TTrapSNMP.Create;
  try
    SNMP.SNMPHost := Dest;
    SNMP.Trap.TrapHost := Source;
    SNMP.Trap.Enterprise := Enterprise;
    SNMP.Trap.Community := Community;
    SNMP.Trap.GenTrap := Generic;
    SNMP.Trap.SpecTrap := Specific;
    SNMP.Trap.TimeTicks := Seconds;
    SNMP.Trap.MIBAdd(MIBName,MIBValue,MIBType);
    Result := SNMP.Send;
  finally
    SNMP.Free;
  end;
end;

http://en.it-usenet.org/thread/14303/3313/の例を読んだ後、SNMPTrap.pas を次のように変更して、一般的なリンクダウン SNMP v2 トラップを送信しましたが、機能しませんでした。

function SendTrap(Dest, Source, Enterprise, Community: string;
  Generic, Specific, Seconds: integer; MIBName, MIBValue: string; MIBtype:integer): integer;
var
  SNMP: TTrapSNMP;
begin
  SNMP := TTrapSNMP.Create;
  try
    SNMP.SNMPHost := Dest;
  //  SNMP.Trap.TrapHost := Source;
  //  SNMP.Trap.Enterprise := Enterprise;
    SNMP.Trap.Community := Community;
  //  SNMP.Trap.GenTrap := Generic;
  //  SNMP.Trap.SpecTrap := Specific;
   // SNMP.Trap.TimeTicks := Seconds;

  SNMP.Trap.Version := SNMP_V2C;
  SNMP.Trap.PDUType := PDUTrapV2;

   // SNMP.Trap.MIBAdd(MIBName,MIBValue,MIBType);
    SNMP.Trap.MIBAdd('1.3.6.1.2.1.1.3.0','0',ASN1_TIMETICKS);
    SNMP.Trap.MIBAdd('1.3.6.1.6.3.1.1.4.1.0','1.3.6.1.6.3.1.1.5.3',ASN1_OBJID);
    Result := SNMP.Send;
  finally
    SNMP.Free;
  end;
end;

Wireshark から次のエラーが返されました。

No.     Time           Source                Destination           Protocol Length Info
  50494 2016.821366000 192.168.0.125         192.168.0.10          SNMP     117    snmpV2-trap

Frame 50494: 117 bytes on wire (936 bits), 117 bytes captured (936 bits) on interface 0
Ethernet II, Src: IntelCor_0b:d9:b8 (00:24:d7:0b:d9:b8), Dst: Hewlett-_48:5c:54 (00:23:7d:48:5c:54)
Internet Protocol Version 4, Src: 192.168.0.125 (192.168.0.125), Dst: 192.168.0.10 (192.168.0.10)
User Datagram Protocol, Src Port: 63309 (63309), Dst Port: snmptrap (162)
Simple Network Management Protocol
    version: v2c (1)
    community: public
    data: snmpV2-trap (7)
        snmpV2-trap
            BER Error: Wrong field in sequence  expected class:UNIVERSAL(0) tag:2(INTEGER) but found class:UNIVERSAL(0) tag:6
                [Expert Info (Warn/Malformed): BER Error: Wrong field in sequence]
                    [Message: BER Error: Wrong field in sequence]
                    [Severity level: Warn]
                    [Group: Malformed]
            BER Error: Wrong field in sequence  expected class:UNIVERSAL(0) tag:2(INTEGER) but found class:APPLICATION(1) tag:0
                [Expert Info (Warn/Malformed): BER Error: Wrong field in sequence]
                    [Message: BER Error: Wrong field in sequence]
                    [Severity level: Warn]
                    [Group: Malformed]
            error-index: 0
            BER Error: Wrong field in sequence  expected class:UNIVERSAL(0) tag:16(SEQUENCE) but found class:UNIVERSAL(0) tag:2
                [Expert Info (Warn/Malformed): BER Error: Wrong field in sequence]
                    [Message: BER Error: Wrong field in sequence]
                    [Severity level: Warn]
                    [Group: Malformed]
            BER Error: This field lies beyond the end of the known sequence definition.
                [Expert Info (Warn/Malformed): BER Error: Unknown field in Sequence]
                    [Message: BER Error: Unknown field in Sequence]
                    [Severity level: Warn]
                    [Group: Malformed]
            BER Error: This field lies beyond the end of the known sequence definition.
                [Expert Info (Warn/Malformed): BER Error: Unknown field in Sequence]
                    [Message: BER Error: Unknown field in Sequence]
                    [Severity level: Warn]
                    [Group: Malformed]

比較のために、正しい形式の v2 SNMP トラップを含めました (これは ireasoning のトラップ送信者を使用して送信しました)。

No.     Time           Source                Destination           Protocol Length Info
     54 7.697996000    192.168.0.125         192.168.0.10          SNMP     111    snmpV2-trap SNMPv2-MIB::sysUpTime.0 SNMPv2-MIB::snmpTrapOID.0

Frame 54: 111 bytes on wire (888 bits), 111 bytes captured (888 bits) on interface 0
Ethernet II, Src: IntelCor_0b:d9:b8 (00:24:d7:0b:d9:b8), Dst: Hewlett-_48:5c:54 (00:23:7d:48:5c:54)
Internet Protocol Version 4, Src: 192.168.0.125 (192.168.0.125), Dst: 192.168.0.10 (192.168.0.10)
User Datagram Protocol, Src Port: 53423 (53423), Dst Port: snmptrap (162)
Simple Network Management Protocol
    version: v2c (1)
    community: public
    data: snmpV2-trap (7)
        snmpV2-trap
            request-id: 75820535
            error-status: noError (0)
            error-index: 0
            variable-bindings: 2 items
                SNMPv2-MIB::sysUpTime.0 (1.3.6.1.2.1.1.3.0): 0
                    Object Name: 1.3.6.1.2.1.1.3.0 (SNMPv2-MIB::sysUpTime.0)
                    Value (Timeticks): 0
                SNMPv2-MIB::snmpTrapOID.0 (1.3.6.1.6.3.1.1.4.1.0): 1.3.6.1.6.3.1.1.5.3 (IF-MIB::linkDown)
                    Object Name: 1.3.6.1.6.3.1.1.4.1.0 (SNMPv2-MIB::snmpTrapOID.0)
                    Value (OID): 1.3.6.1.6.3.1.1.5.3 (IF-MIB::linkDown)
4

0 に答える 0