1 /*
2  * Copyright (c) 2013 - Andre Roth <neolynx@gmail.com>
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License as published by
6  * the Free Software Foundation version 2.1 of the License.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11  * GNU Lesser General Public License for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public License
14  * along with this program; if not, write to the Free Software
15  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16  * Or, point your browser to http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
17  *
18  * Described at ETSI EN 300 468 V1.11.1 (2010-04)
19  */
20 
21 /**
22  * @file desc_ca_identifier.h
23  * @ingroup descriptors
24  * @brief Provides the descriptors for the Conditional Access identifier
25  * @copyright GNU Lesser General Public License version 2.1 (LGPLv2.1)
26  * @author Andre Roth
27  *
28  * @par Relevant specs
29  * The descriptor described herein is defined at:
30  * - ETSI EN 300 468 V1.11.1 (2010-04)
31  *
32  * @par Bug Report
33  * Please submit bug reports and patches to linux-media@vger.kernel.org
34  */
35 
36 #ifndef _CA_IDENTIFIER_H
37 #define _CA_IDENTIFIER_H
38 
39 #include <libdvbv5/descriptors.h>
40 
41 /**
42  * @struct dvb_desc_ca_identifier
43  * @ingroup descriptors
44  * @brief Indicates if a particular bouquet, service or event is associated
45  *	  with a CA system
46  *
47  * @param type			descriptor tag
48  * @param length		descriptor length
49  * @param next			pointer to struct dvb_desc
50  * @param caid_count		Number of CA IDs
51  * @param caids			CA Identifier IDs
52  */
53 struct dvb_desc_ca_identifier {
54 	uint8_t type;
55 	uint8_t length;
56 	struct dvb_desc *next;
57 
58 	uint8_t caid_count;
59 	uint16_t *caids;
60 
61 } __attribute__((packed));
62 
63 struct dvb_v5_fe_parms;
64 
65 /** @brief initial descriptor field at dvb_desc_ca_identifier struct */
66 #define dvb_desc_ca_identifier_field_first ca_id
67 /** @brief last descriptor field at dvb_desc_ca_identifier struct */
68 #define dvb_desc_ca_identifier_field_last  privdata
69 
70 #ifdef __cplusplus
71 extern "C" {
72 #endif
73 
74 /**
75  * @brief Initializes and parses the CA identifier descriptor
76  * @ingroup descriptors
77  *
78  * @param parms	struct dvb_v5_fe_parms pointer to the opened device
79  * @param buf	buffer containing the descriptor's raw data
80  * @param desc	pointer to struct dvb_desc to be allocated and filled
81  *
82  * This function allocates a the descriptor and fills the fields inside
83  * the struct. It also makes sure that all fields will follow the CPU
84  * endianness. Due to that, the content of the buffer may change.
85  *
86  * @return On success, it returns the size of the allocated struct.
87  *	   A negative value indicates an error.
88  */
89 int dvb_desc_ca_identifier_init(struct dvb_v5_fe_parms *parms,
90 				 const uint8_t *buf, struct dvb_desc *desc);
91 
92 /**
93  * @brief Prints the content of the CA identifier descriptor
94  * @ingroup descriptors
95  *
96  * @param parms	struct dvb_v5_fe_parms pointer to the opened device
97  * @param desc	pointer to struct dvb_desc
98  */
99 void dvb_desc_ca_identifier_print(struct dvb_v5_fe_parms *parms,
100 				  const struct dvb_desc *desc);
101 
102 /**
103  * @brief Frees all data allocated by the CA identifier descriptor
104  * @ingroup descriptors
105  *
106  * @param desc pointer to struct dvb_desc to be freed
107  */
108 void dvb_desc_ca_identifier_free(struct dvb_desc *desc);
109 
110 #ifdef __cplusplus
111 }
112 #endif
113 
114 #endif
115