common.h.in 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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. #ifdef OPENSSL_V3
  30. # define OPENSSL_API_COMPAT 10002
  31. # define OPENSSL_NO_DEPRECATED
  32. #endif
  33. #include <@SSL_INC_PREFIX@@SSL_HDR@>
  34. # ifdef SSL_TYPE_openssl
  35. # include <@SSL_INC_PREFIX@err.h>
  36. # include <@SSL_INC_PREFIX@rand.h>
  37. # include <@SSL_INC_PREFIX@engine.h>
  38. # endif
  39. #endif
  40. #define PROGRAM_VERSION "4.1.0RC1"
  41. #define MODIFICATION_DATE "2022-06-08"
  42. #define OK 0
  43. #define ERROR -1
  44. #define TRUE 1
  45. #define FALSE 0
  46. #define STATE_UNKNOWN 3 /* service state return codes */
  47. #define STATE_CRITICAL 2
  48. #define STATE_WARNING 1
  49. #define STATE_OK 0
  50. #define DEFAULT_SOCKET_TIMEOUT 10 /* timeout after 10 seconds */
  51. #define DEFAULT_CONNECTION_TIMEOUT 300 /* timeout if daemon is waiting for connection more than this time */
  52. #define MAX_INPUT_BUFFER 2048 /* max size of most buffers we use */
  53. #define MAX_FILENAME_LENGTH 256
  54. #define MAX_HOST_ADDRESS_LENGTH 256 /* max size of a host address */
  55. #define MAX_COMMAND_ARGUMENTS 16
  56. #define NRPE_HELLO_COMMAND "_NRPE_CHECK"
  57. /**************** PACKET STRUCTURE DEFINITION **********/
  58. #define QUERY_PACKET 1 /* id code for a packet containing a query */
  59. #define RESPONSE_PACKET 2 /* id code for a packet containing a response */
  60. /* v4 takes struct padding into account, so the buffer "takes" 4 bytes
  61. * v3 removes the 1 byte that "should" be allocated to buffer.
  62. */
  63. #define NRPE_V4_PACKET_SIZE_OFFSET 4
  64. #define NRPE_V3_PACKET_SIZE_OFFSET 1
  65. /* packet version identifiers */
  66. #define NRPE_PACKET_VERSION_4 4 /* Same as version 3, but accounts for struct padding in network code */
  67. #define NRPE_PACKET_VERSION_3 3 /* Allows for variable-length buffer */
  68. #define NRPE_PACKET_VERSION_2 2
  69. #define NRPE_PACKET_VERSION_1 1 /* older packet version identifiers (no longer supported) */
  70. #define MAX_PACKETBUFFER_LENGTH 1024 /* amount of data to send in one query/response vor version 2 */
  71. #define NRPE_DEFAULT_PACKET_VERSION NRPE_PACKET_VERSION_4
  72. typedef struct _v2_packet {
  73. int16_t packet_version;
  74. int16_t packet_type;
  75. u_int32_t crc32_value;
  76. int16_t result_code;
  77. char buffer[MAX_PACKETBUFFER_LENGTH];
  78. } v2_packet;
  79. typedef struct _v3_packet {
  80. int16_t packet_version;
  81. int16_t packet_type;
  82. u_int32_t crc32_value;
  83. int16_t result_code;
  84. int16_t alignment;
  85. int32_t buffer_length;
  86. char buffer[1];
  87. } v3_packet;
  88. typedef v3_packet v4_packet;
  89. /**************** OPERATING SYSTEM SPECIFIC DEFINITIONS **********/
  90. #if defined(__sun) || defined(__hpux)
  91. # ifndef LOG_AUTHPRIV
  92. # define LOG_AUTHPRIV LOG_AUTH
  93. # endif
  94. # ifndef LOG_FTP
  95. # define LOG_FTP LOG_DAEMON
  96. # endif
  97. #elif defined(_AIX)
  98. # include <sys/select.h>
  99. # ifndef LOG_FTP
  100. # define LOG_FTP LOG_DAEMON
  101. # endif
  102. #endif