imv_session.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. /*
  2. * Copyright (C) 2013-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. *
  17. * @defgroup imv_session_t imv_session
  18. * @{ @ingroup libimcv_imv
  19. */
  20. #ifndef IMV_SESSION_H_
  21. #define IMV_SESSION_H_
  22. #include "imv_workitem.h"
  23. #include "imv_os_info.h"
  24. #include <tncifimv.h>
  25. #include <library.h>
  26. #include <time.h>
  27. typedef struct imv_session_t imv_session_t;
  28. /**
  29. * IMV session interface
  30. */
  31. struct imv_session_t {
  32. /**
  33. * Set unique session ID
  34. *
  35. * @param session_id primary key into sessions table
  36. * @param pid primary key into products table
  37. * @param did Primary key into devices table
  38. */
  39. void (*set_session_id)(imv_session_t *this, int session_id, int pid, int did);
  40. /**
  41. * Get unique session ID
  42. *
  43. * @param pid primary key into products table
  44. * @param did Primary key into devices table
  45. * @return primary key into sessions table
  46. */
  47. int (*get_session_id)(imv_session_t *this, int *pid, int *did);
  48. /**
  49. * Get TNCCS Connection ID
  50. *
  51. * @return TNCCS Connection ID
  52. */
  53. TNC_ConnectionID (*get_connection_id)(imv_session_t *this);
  54. /**
  55. * Set session creation time
  56. *
  57. * @param created Session creation time
  58. */
  59. void (*set_creation_time)(imv_session_t *this, time_t created);
  60. /**
  61. * Get session creation time
  62. *
  63. * @return Session creation time
  64. */
  65. time_t (*get_creation_time)(imv_session_t *this);
  66. /**
  67. * Get list of Access Requestor identities
  68. *
  69. * @return List of Access Requestor identities
  70. */
  71. enumerator_t* (*create_ar_identities_enumerator)(imv_session_t *this);
  72. /**
  73. * Get OS Information
  74. *
  75. * @return OS info object
  76. */
  77. imv_os_info_t* (*get_os_info)(imv_session_t *this);
  78. /**
  79. * Set Device ID
  80. *
  81. * @param device_id Device ID
  82. */
  83. void (*set_device_id)(imv_session_t *this, chunk_t device_id);
  84. /**
  85. * Get Device ID
  86. *
  87. * @param device_id Device ID
  88. * @return TRUE if Device ID has already been set
  89. */
  90. bool (*get_device_id)(imv_session_t *this, chunk_t *device_id);
  91. /**
  92. * Set trust into Device ID
  93. *
  94. * @param trusted TRUE if Device ID is trusted
  95. */
  96. void (*set_device_trust)(imv_session_t *this, bool trusted);
  97. /**
  98. * Get device ID trust (needed for TPM-based attestation)
  99. *
  100. * @return TRUE if Device ID is trusted
  101. */
  102. bool (*get_device_trust)(imv_session_t *this);
  103. /**
  104. * Set policy_started status
  105. *
  106. * @param start TRUE if policy started, FALSE if policy stopped
  107. */
  108. void (*set_policy_started)(imv_session_t *this, bool start);
  109. /**
  110. * Get policy_started status
  111. *
  112. * @return TRUE if policy started, FALSE if policy stopped
  113. */
  114. bool (*get_policy_started)(imv_session_t *this);
  115. /**
  116. * Insert workitem into list
  117. *
  118. * @param workitem Workitem to be inserted
  119. */
  120. void (*insert_workitem)(imv_session_t *this, imv_workitem_t *workitem);
  121. /**
  122. * Remove workitem from list
  123. *
  124. * @param enumerator Enumerator pointing to workitem to be removed
  125. */
  126. void (*remove_workitem)(imv_session_t *this, enumerator_t *enumerator);
  127. /**
  128. * Create workitem enumerator
  129. *
  130. */
  131. enumerator_t* (*create_workitem_enumerator)(imv_session_t *this);
  132. /**
  133. * Get number of workitem allocated to a given IMV
  134. *
  135. * @param imv_id IMV ID
  136. * @return Number of workitems assigned to given IMV
  137. */
  138. int (*get_workitem_count)(imv_session_t *this, TNC_IMVID imv_id);
  139. /**
  140. * Get reference to session
  141. */
  142. imv_session_t* (*get_ref)(imv_session_t*);
  143. /**
  144. * Destroys an imv_session_t object
  145. */
  146. void (*destroy)(imv_session_t *this);
  147. };
  148. /**
  149. * Create an imv_session_t instance
  150. *
  151. * @param id Associated Connection ID
  152. * @param ar_identities List of Access Requestor identities
  153. */
  154. imv_session_t* imv_session_create(TNC_ConnectionID id,
  155. linked_list_t *ar_identities);
  156. #endif /** IMV_SESSION_H_ @}*/