dvbca.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. /*
  2. * libdvbca - interface onto raw CA devices
  3. *
  4. * Copyright (C) 2006 Andrew de Quincey (adq_dvb@lidskialf.net)
  5. *
  6. * This library is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 2.1 of the License, or (at your option) any later version.
  10. *
  11. * This library 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 GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public
  17. * License along with this library; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  19. */
  20. #ifndef LIBDVBCA_H
  21. #define LIBDVBCA_H 1
  22. #ifdef __cplusplus
  23. extern "C"
  24. {
  25. #endif
  26. #include <stdint.h>
  27. /**
  28. * The types of CA interface we support.
  29. */
  30. #define DVBCA_INTERFACE_LINK 0
  31. #define DVBCA_INTERFACE_HLCI 1
  32. /**
  33. * States a CAM in a slot can be in.
  34. */
  35. #define DVBCA_CAMSTATE_MISSING 0
  36. #define DVBCA_CAMSTATE_INITIALISING 1
  37. #define DVBCA_CAMSTATE_READY 2
  38. /**
  39. * Open a CA device. Multiple CAMs can be accessed through a CA device.
  40. *
  41. * @param adapter Index of the DVB adapter.
  42. * @param cadevice Index of the CA device on that adapter (usually 0).
  43. * @return A unix file descriptor on success, or -1 on failure.
  44. */
  45. extern int dvbca_open(int adapter, int cadevice);
  46. /**
  47. * Reset a CAM.
  48. *
  49. * @param fd File handle opened with dvbca_open.
  50. * @param slot Slot where the requested CAM is in.
  51. * @return 0 on success, -1 on failure.
  52. */
  53. extern int dvbca_reset(int fd, uint8_t slot);
  54. /**
  55. * Get the interface type of a CAM.
  56. *
  57. * @param fd File handle opened with dvbca_open.
  58. * @param slot Slot where the requested CAM is in.
  59. * @return One of the DVBCA_INTERFACE_* values, or -1 on failure.
  60. */
  61. extern int dvbca_get_interface_type(int fd, uint8_t slot);
  62. /**
  63. * Get the state of a CAM.
  64. *
  65. * @param fd File handle opened with dvbca_open.
  66. * @param slot Slot where the requested CAM is in.
  67. * @return One of the DVBCA_CAMSTATE_* values, or -1 on failure.
  68. */
  69. extern int dvbca_get_cam_state(int fd, uint8_t slot);
  70. /**
  71. * Write a message to a CAM using a link-layer interface.
  72. *
  73. * @param fd File handle opened with dvbca_open.
  74. * @param slot Slot where the requested CAM is in.
  75. * @param connection_id Connection ID of the message.
  76. * @param data Data to write.
  77. * @param data_length Number of bytes to write.
  78. * @return 0 on success, or -1 on failure.
  79. */
  80. extern int dvbca_link_write(int fd, uint8_t slot, uint8_t connection_id,
  81. uint8_t *data, uint16_t data_length);
  82. /**
  83. * Read a message from a CAM using a link-layer interface.
  84. *
  85. * @param fd File handle opened with dvbca_open.
  86. * @param slot Slot where the responding CAM is in.
  87. * @param connection_id Destination for the connection ID the message came from.
  88. * @param data Data that was read.
  89. * @param data_length Max number of bytes to read.
  90. * @return Number of bytes read on success, or -1 on failure.
  91. */
  92. extern int dvbca_link_read(int fd, uint8_t *slot, uint8_t *connection_id,
  93. uint8_t *data, uint16_t data_length);
  94. // FIXME how do we determine which CAM slot of a CA is meant?
  95. /**
  96. * Write a message to a CAM using an HLCI interface.
  97. *
  98. * @param fd File handle opened with dvbca_open.
  99. * @param data Data to write.
  100. * @param data_length Number of bytes to write.
  101. * @return 0 on success, or -1 on failure.
  102. */
  103. extern int dvbca_hlci_write(int fd, uint8_t *data, uint16_t data_length);
  104. // FIXME how do we determine which CAM slot of a CA is meant?
  105. /**
  106. * Read a message from a CAM using an HLCI interface.
  107. *
  108. * @param fd File handle opened with dvbca_open.
  109. * @param app_tag Application layer tag giving the message type to read.
  110. * @param data Data that was read.
  111. * @param data_length Max number of bytes to read.
  112. * @return Number of bytes read on success, or -1 on failure.
  113. */
  114. extern int dvbca_hlci_read(int fd, uint32_t app_tag, uint8_t *data,
  115. uint16_t data_length);
  116. #ifdef __cplusplus
  117. }
  118. #endif
  119. #endif // LIBDVBCA_H