libdvbv5: improve CRC size handling
authorAndré Roth <neolynx@gmail.com>
Tue, 15 Apr 2014 20:33:01 +0000 (17:33 -0300)
committerMauro Carvalho Chehab <m.chehab@samsung.com>
Wed, 16 Apr 2014 12:52:11 +0000 (09:52 -0300)
- provide buffer without CRC to the table parsers
- remove unneeded defines

Signed-off-by: André Roth <neolynx@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
lib/include/libdvbv5/descriptors.h
lib/libdvbv5/dvb-scan.c
lib/libdvbv5/tables/atsc_eit.c
lib/libdvbv5/tables/cat.c
lib/libdvbv5/tables/eit.c
lib/libdvbv5/tables/mgt.c
lib/libdvbv5/tables/nit.c
lib/libdvbv5/tables/pat.c
lib/libdvbv5/tables/pmt.c
lib/libdvbv5/tables/sdt.c
lib/libdvbv5/tables/vct.c

index 66197f6..94d85a9 100644 (file)
@@ -31,8 +31,7 @@
 #include <stdint.h>
 
 #define DVB_MAX_PAYLOAD_PACKET_SIZE 4096
-#define DVB_PID_SDT      17
-#define DVB_PMT_TABLE_ID 2
+#define DVB_CRC_SIZE 4
 
 struct dvb_v5_fe_parms;
 
index 5cd38f8..b16f4c4 100644 (file)
@@ -222,7 +222,7 @@ static int dvb_parse_section(struct dvb_v5_fe_parms *parms,
                set_bit(h->section_id, priv->is_read_bits);
 
        if (dvb_table_initializers[tid])
-               dvb_table_initializers[tid](parms, buf, buf_length,
+               dvb_table_initializers[tid](parms, buf, buf_length - DVB_CRC_SIZE,
                                                 sect->table);
        else
                dvb_logerr("%s: no initializer for table %d",
index 83a495c..cf69fff 100644 (file)
@@ -25,7 +25,7 @@
 ssize_t atsc_table_eit_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf,
                ssize_t buflen, struct atsc_table_eit **table)
 {
-       const uint8_t *p = buf, *endbuf = buf + buflen - 4; /* minus CRC */;
+       const uint8_t *p = buf, *endbuf = buf + buflen;
        struct atsc_table_eit *eit;
        struct atsc_table_eit_event **head;
        size_t size;
index 394eb3c..f5887b2 100644 (file)
@@ -25,7 +25,7 @@
 ssize_t dvb_table_cat_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf,
                ssize_t buflen, struct dvb_table_cat **table)
 {
-       const uint8_t *p = buf, *endbuf = buf + buflen - 4;
+       const uint8_t *p = buf, *endbuf = buf + buflen;
        struct dvb_table_cat *cat;
        struct dvb_desc **head_desc;
        size_t size;
@@ -59,7 +59,7 @@ ssize_t dvb_table_cat_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf,
        while (*head_desc != NULL)
                head_desc = &(*head_desc)->next;
 
-       size = cat->header.section_length + 3 - 4; /* plus header, minus CRC */
+       size = cat->header.section_length + 3 - DVB_CRC_SIZE; /* plus header, minus CRC */
        if (buf + size > endbuf) {
                dvb_logerr("%s: short read %zd/%zd bytes", __func__,
                           endbuf - buf, size);
index 1870722..ff68536 100644 (file)
@@ -25,7 +25,7 @@
 ssize_t dvb_table_eit_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf,
                ssize_t buflen, struct dvb_table_eit **table)
 {
-       const uint8_t *p = buf, *endbuf = buf + buflen - 4; /* minus CRC */
+       const uint8_t *p = buf, *endbuf = buf + buflen;
        struct dvb_table_eit *eit;
        struct dvb_table_eit_event **head;
        size_t size;
index bf77348..ffdea53 100644 (file)
@@ -25,7 +25,7 @@
 ssize_t atsc_table_mgt_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf,
                ssize_t buflen, struct atsc_table_mgt **table)
 {
-       const uint8_t *p = buf, *endbuf = buf + buflen - 4; /* minus CRC */
+       const uint8_t *p = buf, *endbuf = buf + buflen;
        struct atsc_table_mgt *mgt;
        struct atsc_table_mgt_table **head;
        struct dvb_desc **head_desc;
index 054b36b..243506d 100644 (file)
@@ -25,7 +25,7 @@
 ssize_t dvb_table_nit_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf,
                        ssize_t buflen, struct dvb_table_nit **table)
 {
-       const uint8_t *p = buf, *endbuf = buf + buflen - 4;
+       const uint8_t *p = buf, *endbuf = buf + buflen;
        struct dvb_table_nit *nit;
        struct dvb_table_nit_transport **head;
        struct dvb_desc **head_desc;
index 544bac4..29dbfff 100644 (file)
@@ -26,7 +26,7 @@
 ssize_t dvb_table_pat_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf,
                        ssize_t buflen, struct dvb_table_pat **table)
 {
-       const uint8_t *p = buf, *endbuf = buf + buflen - 4;
+       const uint8_t *p = buf, *endbuf = buf + buflen;
        struct dvb_table_pat *pat;
        struct dvb_table_pat_program **head;
        size_t size;
index b81dad7..305d9e8 100644 (file)
@@ -28,7 +28,7 @@
 ssize_t dvb_table_pmt_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf,
                        ssize_t buflen, struct dvb_table_pmt **table)
 {
-       const uint8_t *p = buf, *endbuf = buf + buflen - 4;
+       const uint8_t *p = buf, *endbuf = buf + buflen;
        struct dvb_table_pmt *pmt;
        struct dvb_table_pmt_stream **head;
        struct dvb_desc **head_desc;
@@ -68,7 +68,7 @@ ssize_t dvb_table_pmt_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf,
        while (*head_desc != NULL)
                head_desc = &(*head_desc)->next;
 
-       size = pmt->header.section_length + 3 - 4; /* plus header, minus CRC */
+       size = pmt->header.section_length + 3 - DVB_CRC_SIZE; /* plus header, minus CRC */
        if (buf + size > endbuf) {
                dvb_logerr("%s: short read %zd/%zd bytes", __func__,
                           endbuf - buf, size);
index a64726f..4285a9a 100644 (file)
@@ -26,7 +26,7 @@
 ssize_t dvb_table_sdt_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf,
                        ssize_t buflen, struct dvb_table_sdt **table)
 {
-       const uint8_t *p = buf, *endbuf = buf + buflen - 4;
+       const uint8_t *p = buf, *endbuf = buf + buflen;
        struct dvb_table_sdt *sdt;
        struct dvb_table_sdt_service **head;
        size_t size;
@@ -61,7 +61,7 @@ ssize_t dvb_table_sdt_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf,
        while (*head != NULL)
                head = &(*head)->next;
 
-       size = sdt->header.section_length + 3 - 4; /* plus header, minus CRC */
+       size = sdt->header.section_length + 3 - DVB_CRC_SIZE; /* plus header, minus CRC */
        if (buf + size > endbuf) {
                dvb_logerr("%s: short read %zd/%zd bytes", __func__,
                           endbuf - buf, size);
index 970023d..e6bc1a2 100644 (file)
@@ -27,7 +27,7 @@
 ssize_t atsc_table_vct_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf,
                        ssize_t buflen, struct atsc_table_vct **table)
 {
-       const uint8_t *p = buf, *endbuf = buf + buflen - 4;
+       const uint8_t *p = buf, *endbuf = buf + buflen;
        struct atsc_table_vct *vct;
        struct atsc_table_vct_channel **head;
        size_t size;