snmpGetIP (Function)

Top  Previous  Next

Architecture:

NX32L

Firmware version:

1.50.00


This function will read an IP address value from a managed device.

 

Input:

Handle : SYSHANDLE

The handle to the connection established from snmpConnect.

 

OID : STRING

The OID for the value to read.

 

Output:

V : STRING

The value read.

 

Returns: INT

1

- Success.

0

- This function is not supported.

-1

- Invalid handle.

-8

- Communication error.

-9

- Invalid variable type received.

-10

- Invalid OID.

 

Declaration

FUNCTION snmpGetIP : INT;
VAR_INPUT
   Handle  : MANDATORY SYSHANDLE;
   OID     : MANDATORY STRING;
   V       : ACCESS STRING;
END_VAR;

 

 

Example:

INCLUDE rtcu.inc
 
VAR
   iface    : SINT := 2;
END_VAR;
 
PROGRAM test;
VAR
   rc       : INT;
   snmplabs : SYSHANDLE;
   var_str  : STRING;
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;
 
   // Establish connection with client host.
   rc := snmpConnect(
                     handle    := snmplabs,
                     community := "public",
                     host      := "demo.snmplabs.com"
                    );
   IF rc = 1 THEN
      // Read IP address
      rc := snmpGetIP(
                      handle := snmplabs,
                      oid    := "1.3.6.1.2.1.3.1.1.3.2.1.195.218.254.97",
                      v      := var_str
                     );
      IF rc = 1 THEN
         DebugMsg(message := "snmpGetIP : returned : '" + var_str + "'");
      ELSE
         DebugFmt(message := "snmpGetIP (rc=\1)", v1 := rc);
      END_IF;
   ELSE
      DebugFmt(message := "snmpConnect failed (rc=\1)", v1 := rc);
   END_IF;
   ...
BEGIN
   ...
END;
END_PROGRAM;