LUALoriotPro WEB site

LoriotPro scripting documentation
Extensions for LUA language

Table of contents Search function

Print the current page Mail this  link UTUBE Channel version française

lp.HexToOID - Convert an Hexa decimal to an OID string

LoriotPro has extended the LUA sripting language by providing its own LUA libraries. The new functions provided are dedicated to the creation of monitoring and SNMP automation application.

Syntax

.oid-string = lp.HexToOID(‘xx:xx:xx:xx:xx:xx:xx:’);

Description

HexToOID conver a hexadecimal number, a MAC address for example in a character string.

Parameters

‘xx:xx:xx:xx:xx:xx:xx:’ An hexdecimal number in the format xy:xy:

Return Values

.oid-string - A SNMP OID in a character string format

Example

This code uses the lp.HexToOID to built a request on the SNMP object dot1dtpfdbport of the BRIDGE-MIB.

--ip switch address
--Vlan to search
--mac 00:0D:56:79:C0:7F:
function FindSWIfFromMac(ip,vlan,mac)
if mac == nil or ip==nil or vlan==nil then return "No Found","no index" end
oid="dot1dtpfdbport"..lp.HexToOID(mac);
--lp.Trace(oid,"\n");
if (vlan==0) then
      a,index=lp.Get(ip,oid);
      else
      a,index=lp.GetBRC(ip,oid,vlan);
end

--lp.Trace(a);
--lp.Trace("buffer",buffer);
      if a~=nil thenµ
      oid="dot1dBasePortIfIndex."..index;
      --lp.Trace(oid);
            if (vlan==0) then
                  a,index=lp.Get(ip,oid);
                  else
                  a,index=lp.GetBRC(ip,oid,vlan);
            end
      --lp.Trace(port);
            if a~= nil then
            oid="ifname."..index;
            --lp.Trace(oid);
                  if (vlan==0) then
                        a,buffer=lp.Get(ip,oid);
                        else
                        a,buffer=lp.GetBRC(ip,oid,vlan);
                  end
            --lp.Trace(port);
                  return buffer,index;
            end
      end
return "No Found","no index"
end

hex to oid




www.loriotpro.com