common.h.in 3.6 KB

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