Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

61 lines
1.5 KiB

// wsnmp_sp.c
//
// Special functions for the WinSNMP library
// Copyright 1998 ACE*COMM Corp
//
// Bob Natale ([email protected])
//
#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));
}