pa_tnc_msg.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. /*
  2. * Copyright (C) 2011-2015 Andreas Steffen
  3. * HSR Hochschule fuer Technik Rapperswil
  4. *
  5. * This program is free software; you can redistribute it and/or modify it
  6. * under the terms of the GNU General Public License as published by the
  7. * Free Software Foundation; either version 2 of the License, or (at your
  8. * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
  9. *
  10. * This program is distributed in the hope that it will be useful, but
  11. * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  12. * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  13. * for more details.
  14. */
  15. /**
  16. * @defgroup pa_tnc_msg pa_tnc_msg
  17. * @{ @ingroup pa_tnc
  18. */
  19. #ifndef PA_TNC_MSG_H_
  20. #define PA_TNC_MSG_H_
  21. typedef struct pa_tnc_msg_t pa_tnc_msg_t;
  22. #define PA_TNC_VERSION 0x01
  23. #define PA_TNC_HEADER_SIZE 8
  24. #include "pa_tnc_attr.h"
  25. #include <library.h>
  26. /**
  27. * Interface for the RFC 5792 PA-TNC Posture Attribute protocol.
  28. *
  29. */
  30. struct pa_tnc_msg_t {
  31. /**
  32. * Get the encoding of the PA-TNC message
  33. *
  34. * @return encoded PA-TNC message
  35. */
  36. chunk_t (*get_encoding)(pa_tnc_msg_t *this);
  37. /**
  38. * Get the remaining space in octets left in the PA-TNC message
  39. *
  40. * @return remaining space or 0 if max_msg_len is not set
  41. */
  42. size_t (*get_space)(pa_tnc_msg_t *this);
  43. /**
  44. * Add a PA-TNC attribute
  45. *
  46. * @param attr PA-TNC attribute to be added
  47. * @return TRUE if attribute fit into message and was added
  48. */
  49. bool (*add_attribute)(pa_tnc_msg_t *this, pa_tnc_attr_t* attr);
  50. /**
  51. * Build the PA-TNC message
  52. *
  53. * @return TRUE if PA-TNC message was built successfully
  54. */
  55. bool (*build)(pa_tnc_msg_t *this);
  56. /**
  57. * Process the PA-TNC message
  58. *
  59. * @return return processing status
  60. */
  61. status_t (*process)(pa_tnc_msg_t *this);
  62. /**
  63. * Process all IETF standard error PA-TNC attributes
  64. *
  65. * @param non_fatal_types list of non fatal unsupported attribute types
  66. * @return TRUE if at least one fatal error processed
  67. */
  68. bool (*process_ietf_std_errors)(pa_tnc_msg_t *this,
  69. linked_list_t *non_fatal_types);
  70. /**
  71. * Enumerates over all PA-TNC attributes
  72. *
  73. * @return return attribute enumerator
  74. */
  75. enumerator_t* (*create_attribute_enumerator)(pa_tnc_msg_t *this);
  76. /**
  77. * Enumerates over all parsing errors
  78. *
  79. * @return return error enumerator
  80. */
  81. enumerator_t* (*create_error_enumerator)(pa_tnc_msg_t *this);
  82. /**
  83. * Destroys a pa_tnc_msg_t object.
  84. */
  85. void (*destroy)(pa_tnc_msg_t *this);
  86. };
  87. /**
  88. * Create an empty PA-TNC message
  89. */
  90. pa_tnc_msg_t* pa_tnc_msg_create(size_t max_msg_len);
  91. /**
  92. * Create an unprocessed PA-TNC message from received data
  93. *
  94. * @param data PA-TNC message data
  95. */
  96. pa_tnc_msg_t* pa_tnc_msg_create_from_data(chunk_t data);
  97. #endif /** PA_TNC_MSG_H_ @}*/