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.

60 lines
1.5 KiB

  1. // wsnmp_sp.c
  2. //
  3. // Special functions for the WinSNMP library
  4. // Copyright 1998 ACE*COMM Corp
  5. //
  6. // Bob Natale ([email protected])
  7. //
  8. #include "winsnmp.inc"
  9. __declspec(dllexport)
  10. SNMPAPI_STATUS SNMPAPI_CALL
  11. SnmpSetAgentAddress (LPSTR agentAddress)
  12. {
  13. DWORD tmpAddress = 0;
  14. SNMPAPI_STATUS lError;
  15. if (TaskData.hTask == 0)
  16. {
  17. lError = SNMPAPI_NOT_INITIALIZED;
  18. goto ERROR_OUT;
  19. }
  20. // A null arg resets the localAddress trigger value
  21. if (agentAddress == NULL)
  22. goto DONE;
  23. // Otherwise, convert to IP address
  24. tmpAddress = inet_addr (agentAddress);
  25. if (tmpAddress == INADDR_NONE)
  26. { // Invalid IP addresses cannot be accepted
  27. lError = SNMPAPI_MODE_INVALID;
  28. goto ERROR_OUT;
  29. }
  30. DONE:
  31. // Plug new agent_address value into localAddress
  32. // for future v1 trap sends
  33. EnterCriticalSection (&cs_TASK);
  34. TaskData.localAddress = tmpAddress;
  35. LeaveCriticalSection (&cs_TASK);
  36. return (SNMPAPI_SUCCESS);
  37. ERROR_OUT:
  38. return (SaveError (0, lError));
  39. }
  40. __declspec(dllexport)
  41. SNMPAPI_STATUS SNMPAPI_CALL
  42. SnmpConveyAgentAddress (SNMPAPI_STATUS mode)
  43. {
  44. SNMPAPI_STATUS lError;
  45. if (TaskData.hTask == 0)
  46. {
  47. lError = SNMPAPI_NOT_INITIALIZED;
  48. goto ERROR_OUT;
  49. }
  50. // mode can only be on or off...
  51. if (mode != SNMPAPI_ON)
  52. mode = SNMPAPI_OFF; // ...force off if not on
  53. EnterCriticalSection (&cs_TASK);
  54. TaskData.conveyAddress = mode;
  55. LeaveCriticalSection (&cs_TASK);
  56. return (SNMPAPI_SUCCESS);
  57. ERROR_OUT:
  58. return (SaveError (0, lError));
  59. }