Ejemplo n.º 1
0
        public static string OidToString(ref SMIOID oid)
        {
            string soid      = null;
            IntPtr OTSBuffer = Marshal.AllocHGlobal(1408);


            try
            {
                SNMPAPI_STATUS rc = SnmpAPI.SnmpOidToStr(ref oid, 1408, OTSBuffer);
                if (rc != SNMPAPI_STATUS.SNMPAPI_FAILURE)
                {
                    soid = Marshal.PtrToStringAnsi(OTSBuffer);
                }
                SnmpAPI.SnmpFreeDescriptor((int)SNMPAPI_SYNTAX.SNMP_SYNTAX_OID, ref oid);
            }
            catch (Exception e)
            {
                Console.WriteLine("OidToString Exception:\n" + e.Message + "\n" + e.StackTrace);
            }
            //Free
            Marshal.FreeHGlobal(OTSBuffer);
            return(soid);
        }