⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wsnmp_sp.c

📁 windows的snmp api源码
💻 C
字号:
// wsnmp_sp.c
//
// Special functions for the WinSNMP library
// Copyright 1998 ACE*COMM Corp
//
// Bob Natale (bnatale@acecomm.com)
//
#include "winsnmp.inc"

__declspec(dllexport)
SNMPAPI_STATUS SNMPAPI_CALL
   SnmpSetAgentAddress (LPSTR agentAddress)
{
DWORD tmpAddress = 0;
SNMPAPI_STATUS lError;
if (TaskData.hTask == 0)
   {
   lError = SNMPAPI_NOT_INITIALIZED;
   goto ERROR_OUT;
   }
// A null arg resets the localAddress trigger value
if (agentAddress == NULL)
   goto DONE;
// Otherwise, convert to IP address
tmpAddress = inet_addr (agentAddress);
if (tmpAddress == INADDR_NONE)
   { // Invalid IP addresses cannot be accepted
   lError = SNMPAPI_MODE_INVALID;
   goto ERROR_OUT;
   }
DONE:
// Plug new agent_address value into localAddress
// for future v1 trap sends
EnterCriticalSection (&cs_TASK);
TaskData.localAddress = tmpAddress;
LeaveCriticalSection (&cs_TASK);
return (SNMPAPI_SUCCESS);
ERROR_OUT:
return (SaveError (0, lError));
}

__declspec(dllexport)
SNMPAPI_STATUS SNMPAPI_CALL
   SnmpConveyAgentAddress (SNMPAPI_STATUS mode)
{
SNMPAPI_STATUS lError;
if (TaskData.hTask == 0)
   {
   lError = SNMPAPI_NOT_INITIALIZED;
   goto ERROR_OUT;
   }
// mode can only be on or off...
if (mode != SNMPAPI_ON)
   mode = SNMPAPI_OFF;  // ...force off if not on
EnterCriticalSection (&cs_TASK);
TaskData.conveyAddress = mode;
LeaveCriticalSection (&cs_TASK);
return (SNMPAPI_SUCCESS);
ERROR_OUT:
return (SaveError (0, lError));
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -