snmpRegisterTrap (Function)

Top  Previous  Next

Architecture:

NX32L

Firmware version:

1.50.00


This function will register a trap. Only registered traps will generate a trap event in the snmpWaitEvent function.

 

Input:

OID : STRING

The OID of the trap.

 

Returns: INT

1

- Success.

0

- This function is not supported.

-3

- Too many traps are registered. See limitations on overview page.

-4

- The trap is already registered.

-10

- Illegal OID

-20

- Manager not running.

 

Declaration

FUNCTION snmpRegisterTrap : INT;
VAR_INPUT
   OID : STRING;
END_VAR;

 

Example:

INCLUDE rtcu.inc
 
VAR
   iface    : SINT := 2;
END_VAR;
 
PROGRAM test;
VAR
   rc       : INT;
END_VAR;
   // Open net interface.
   rc := netOpen(iface := iface);
   DebugFmt(Message := "netOpen (rc=\1)", v1 := rc);
   WHILE NOT netConnected(iface := ifaceDO
      Sleep(Delay := 2000);
   END_WHILE;
   ...
   rc := snmpStartListen(handle := handle, community := "public");
   DebugFmt(message := "snmpStartListen (rc=\1)", v1 := rc);
   // Listen for some trap OID on community net 'public'
   rc := snmpRegisterTrap(oid := "1.3.6.1.4.1.6101.1.8.8.2.6");
   DebugFmt(message := "snmpRegisterTrap (rc=\1)", v1 := rc);
   ...
BEGIN
   ...
END;
END_PROGRAM;