en50221_app_auth.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. /*
  2. en50221 encoder An implementation for libdvb
  3. an implementation for the en50221 transport layer
  4. Copyright (C) 2004, 2005 Manu Abraham <abraham.manu@gmail.com>
  5. Copyright (C) 2005 Julian Scheel (julian at jusst dot de)
  6. Copyright (C) 2006 Andrew de Quincey (adq_dvb@lidskialf.net)
  7. This library is free software; you can redistribute it and/or modify
  8. it under the terms of the GNU Lesser General Public License as
  9. published by the Free Software Foundation; either version 2.1 of
  10. the License, or (at your option) any later version.
  11. This program is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. GNU Lesser General Public License for more details.
  15. You should have received a copy of the GNU Lesser General Public
  16. License along with this library; if not, write to the Free Software
  17. Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  18. */
  19. #ifndef __EN50221_APPLICATION_auth_H__
  20. #define __EN50221_APPLICATION_auth_H__
  21. #ifdef __cplusplus
  22. extern "C" {
  23. #endif
  24. #include <stdlib.h>
  25. #include <stdint.h>
  26. #include <libdvben50221/en50221_app_utils.h>
  27. #define EN50221_APP_AUTH_RESOURCEID MKRID(16,1,1)
  28. /**
  29. * Type definition for request - called when we receive a auth request from a CAM.
  30. *
  31. * @param arg Private argument.
  32. * @param slot_id Slot id concerned.
  33. * @param session_number Session number concerned.
  34. * @param auth_protocol_id Auth protocol id.
  35. * @param auth_data Data for the request.
  36. * @param auth_data_lenghth Number of bytes.
  37. * @return 0 on success, -1 on failure.
  38. */
  39. typedef int (*en50221_app_auth_request_callback) (void *arg,
  40. uint8_t slot_id,
  41. uint16_t session_number,
  42. uint16_t auth_protcol_id,
  43. uint8_t *auth_data,
  44. uint32_t auth_data_length);
  45. /**
  46. * Opaque type representing a auth resource.
  47. */
  48. struct en50221_app_auth;
  49. /**
  50. * Create an instance of the auth resource.
  51. *
  52. * @param funcs Send functions to use.
  53. * @return Instance, or NULL on failure.
  54. */
  55. extern struct en50221_app_auth *en50221_app_auth_create(struct en50221_app_send_functions *funcs);
  56. /**
  57. * Destroy an instance of the auth resource.
  58. *
  59. * @param auth Instance to destroy.
  60. */
  61. extern void en50221_app_auth_destroy(struct en50221_app_auth *auth);
  62. /**
  63. * Register the callback for when we receive a request.
  64. *
  65. * @param auth auth resource instance.
  66. * @param callback The callback. Set to NULL to remove the callback completely.
  67. * @param arg Private data passed as arg0 of the callback.
  68. */
  69. extern void en50221_app_auth_register_request_callback(struct en50221_app_auth *auth,
  70. en50221_app_auth_request_callback callback,
  71. void *arg);
  72. /**
  73. * Send an auth response to the CAM.
  74. *
  75. * @param auth auth resource instance.
  76. * @param session_number Session number to send it on.
  77. * @param auth_protocol_id Auth protocol id.
  78. * @param auth_data Auth data.
  79. * @param auth_data_length Number of bytes.
  80. * @return 0 on success, -1 on failure.
  81. */
  82. extern int en50221_app_auth_send(struct en50221_app_auth *auth,
  83. uint16_t session_number,
  84. uint16_t auth_protocol_id,
  85. uint8_t *auth_data,
  86. uint32_t auth_data_length);
  87. /**
  88. * Pass data received for this resource into it for parsing.
  89. *
  90. * @param auth Authentication instance.
  91. * @param slot_id Slot ID concerned.
  92. * @param session_number Session number concerned.
  93. * @param resource_id Resource ID concerned.
  94. * @param data The data.
  95. * @param data_length Length of data in bytes.
  96. * @return 0 on success, -1 on failure.
  97. */
  98. extern int en50221_app_auth_message(struct en50221_app_auth *auth,
  99. uint8_t slot_id,
  100. uint16_t session_number,
  101. uint32_t resource_id,
  102. uint8_t *data,
  103. uint32_t data_length);
  104. #ifdef __cplusplus
  105. }
  106. #endif
  107. #endif