pt_tls_dispatcher.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*
  2. * Copyright (C) 2012 Martin Willi
  3. * Copyright (C) 2012 revosec AG
  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 pt_tls_dispatcher pt_tls_dispatcher
  17. * @{ @ingroup pt_tls
  18. */
  19. #ifndef PT_TLS_DISPATCHER_H_
  20. #define PT_TLS_DISPATCHER_H_
  21. #include <networking/host.h>
  22. #include <utils/identification.h>
  23. #include <tnc/tnccs/tnccs.h>
  24. #include "pt_tls.h"
  25. typedef struct pt_tls_dispatcher_t pt_tls_dispatcher_t;
  26. /**
  27. * Constructor callback to create TNCCS to use within PT-TLS.
  28. *
  29. * @param server server identity
  30. * @param peer peer identity
  31. */
  32. typedef tnccs_t* (pt_tls_tnccs_constructor_t)(identification_t *server,
  33. identification_t *peer);
  34. /**
  35. * PT-TLS dispatcher service, handles PT-TLS connections as a server.
  36. */
  37. struct pt_tls_dispatcher_t {
  38. /**
  39. * Dispatch and handle PT-TLS connections.
  40. *
  41. * This call is blocking and a thread cancellation point. The passed
  42. * constructor gets called for each dispatched connection.
  43. *
  44. * @param create TNCCS constructor function to use
  45. */
  46. void (*dispatch)(pt_tls_dispatcher_t *this,
  47. pt_tls_tnccs_constructor_t *create);
  48. /**
  49. * Destroy a pt_tls_dispatcher_t.
  50. */
  51. void (*destroy)(pt_tls_dispatcher_t *this);
  52. };
  53. /**
  54. * Create a pt_tls_dispatcher instance.
  55. *
  56. * @param address server address with port to listen on, gets owned
  57. * @param id TLS server identity, gets owned
  58. * @param auth client authentication to perform
  59. * @return dispatcher service
  60. */
  61. pt_tls_dispatcher_t *pt_tls_dispatcher_create(host_t *address,
  62. identification_t *id, pt_tls_auth_t auth);
  63. #endif /** PT_TLS_DISPATCHER_H_ @}*/