common.h.in 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. /****************************************************************************
  2. *
  3. * common.h - NRPE Common header file
  4. *
  5. * License: GPLv2
  6. * Copyright (c) 2006-2017 Nagios Enterprises
  7. * 1999-2006 Ethan Galstad (nagios@nagios.org)
  8. *
  9. * License Notice:
  10. *
  11. * This program is free software; you can redistribute it and/or modify
  12. * it under the terms of the GNU General Public License as published by
  13. * the Free Software Foundation; either version 2 of the License, or
  14. * (at your option) any later version.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU General Public License
  22. * along with this program; if not, write to the Free Software
  23. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  24. *
  25. ****************************************************************************/
  26. #include "config.h"
  27. #define SSL_TYPE_@SSL_TYPE@
  28. #ifdef HAVE_SSL
  29. #include <@SSL_INC_PREFIX@@SSL_HDR@>
  30. # ifdef SSL_TYPE_openssl
  31. # include <@SSL_INC_PREFIX@err.h>
  32. # include <@SSL_INC_PREFIX@rand.h>
  33. # include <@SSL_INC_PREFIX@engine.h>
  34. # include <@SSL_INC_PREFIX@evp.h>
  35. # endif
  36. #endif
  37. #define PROGRAM_VERSION "4.1.1"
  38. #define MODIFICATION_DATE "2024-08-01"
  39. #define OK 0
  40. #define ERROR -1
  41. #define TRUE 1
  42. #define FALSE 0
  43. #define STATE_UNKNOWN 3 /* service state return codes */
  44. #define STATE_CRITICAL 2
  45. #define STATE_WARNING 1
  46. #define STATE_OK 0
  47. #define DEFAULT_SOCKET_TIMEOUT 10 /* timeout after 10 seconds */
  48. #define DEFAULT_CONNECTION_TIMEOUT 300 /* timeout if daemon is waiting for connection more than this time */
  49. #define MAX_INPUT_BUFFER 2048 /* max size of most buffers we use */
  50. #define MAX_FILENAME_LENGTH 256
  51. #define MAX_HOST_ADDRESS_LENGTH 256 /* max size of a host address */
  52. #define MAX_COMMAND_ARGUMENTS 16
  53. #define NRPE_HELLO_COMMAND "_NRPE_CHECK"
  54. /**************** PACKET STRUCTURE DEFINITION **********/
  55. #define QUERY_PACKET 1 /* id code for a packet containing a query */
  56. #define RESPONSE_PACKET 2 /* id code for a packet containing a response */
  57. /* v4 takes struct padding into account, so the buffer "takes" 4 bytes
  58. * v3 removes the 1 byte that "should" be allocated to buffer.
  59. */
  60. #define NRPE_V4_PACKET_SIZE_OFFSET 4
  61. #define NRPE_V3_PACKET_SIZE_OFFSET 1
  62. /* packet version identifiers */
  63. #define NRPE_PACKET_VERSION_4 4 /* Same as version 3, but accounts for struct padding in network code */
  64. #define NRPE_PACKET_VERSION_3 3 /* Allows for variable-length buffer */
  65. #define NRPE_PACKET_VERSION_2 2
  66. #define NRPE_PACKET_VERSION_1 1 /* older packet version identifiers (no longer supported) */
  67. #define MAX_PACKETBUFFER_LENGTH 1024 /* amount of data to send in one query/response vor version 2 */
  68. #define NRPE_DEFAULT_PACKET_VERSION NRPE_PACKET_VERSION_4
  69. typedef struct _v2_packet {
  70. int16_t packet_version;
  71. int16_t packet_type;
  72. u_int32_t crc32_value;
  73. int16_t result_code;
  74. char buffer[MAX_PACKETBUFFER_LENGTH];
  75. } v2_packet;
  76. typedef struct _v3_packet {
  77. int16_t packet_version;
  78. int16_t packet_type;
  79. u_int32_t crc32_value;
  80. int16_t result_code;
  81. int16_t alignment;
  82. int32_t buffer_length;
  83. char buffer[1];
  84. } v3_packet;
  85. typedef v3_packet v4_packet;
  86. /**************** OPERATING SYSTEM SPECIFIC DEFINITIONS **********/
  87. #if defined(__sun) || defined(__hpux)
  88. # ifndef LOG_AUTHPRIV
  89. # define LOG_AUTHPRIV LOG_AUTH
  90. # endif
  91. # ifndef LOG_FTP
  92. # define LOG_FTP LOG_DAEMON
  93. # endif
  94. #elif defined(_AIX)
  95. # include <sys/select.h>
  96. # ifndef LOG_FTP
  97. # define LOG_FTP LOG_DAEMON
  98. # endif
  99. #endif