« clib/dvb_ts_lib/descriptors/parse_desc_cable_delivery_system.c
↑ Summary
clib/dvb_ts_lib/descriptors/parse_desc_component.c »
| 1 | /* | ||||||||||
| 2 | * parse_desc_cell_frequency_link.c | ||||||||||
| 3 | * | ||||||||||
| 4 | * Created by: si_desc.pl | ||||||||||
| 5 | * Created on: 20-May-2011 | ||||||||||
| 6 | * Author: sdprice1 | ||||||||||
| 7 | */ | ||||||||||
| 8 | |||||||||||
| 9 | |||||||||||
| 10 | // VERSION = 1.00 | ||||||||||
| 11 | |||||||||||
| 12 | /*=============================================================================================*/ | ||||||||||
| 13 | // USES | ||||||||||
| 14 | /*=============================================================================================*/ | ||||||||||
| 15 | |||||||||||
| 16 | #include <stdio.h> | ||||||||||
| 17 | #include <stdlib.h> | ||||||||||
| 18 | #include <unistd.h> | ||||||||||
| 19 | #include <string.h> | ||||||||||
| 20 | #include <errno.h> | ||||||||||
| 21 | #include <ctype.h> | ||||||||||
| 22 | #include <fcntl.h> | ||||||||||
| 23 | #include <inttypes.h> | ||||||||||
| 24 | |||||||||||
| 25 | #include "parse_desc_cell_frequency_link.h" | ||||||||||
| 26 | #include "descriptors/parse_desc.h" | ||||||||||
| 27 | |||||||||||
| 28 | /*=============================================================================================*/ | ||||||||||
| 29 | // CONSTANTS | ||||||||||
| 30 | /*=============================================================================================*/ | ||||||||||
| 31 | |||||||||||
| 32 | /*=============================================================================================*/ | ||||||||||
| 33 | // MACROS | ||||||||||
| 34 | /*=============================================================================================*/ | ||||||||||
| 35 | |||||||||||
| 36 | /*=============================================================================================*/ | ||||||||||
| 37 | // FUNCTIONS | ||||||||||
| 38 | /*=============================================================================================*/ | ||||||||||
| 39 | |||||||||||
| 40 | /* ----------------------------------------------------------------------- */ | ||||||||||
| 41 | // | ||||||||||
| 42 | // cell_frequency_link_descriptor(){ | ||||||||||
| 43 | // descriptor_tag 8 uimsbf | ||||||||||
| 44 | // descriptor_length 8 uimsbf | ||||||||||
| 45 | // for (i=0;i<N;i++){ | ||||||||||
| 46 | // cell_id 16 uimsbf | ||||||||||
| 47 | // frequency 32 uimsbf | ||||||||||
| 48 | // subcell_info_loop_length 8 uimsbf | ||||||||||
| 49 | // for (j=0;j<N;j++){ | ||||||||||
| 50 | // cell_id_extension 8 uimsbf | ||||||||||
| 51 | // transposer_frequency 32 uimsbf | ||||||||||
| 52 | // } | ||||||||||
| 53 | // } | ||||||||||
| 54 | // } | ||||||||||
| 55 | |||||||||||
| 56 | |||||||||||
| 57 | /* ----------------------------------------------------------------------- */ | ||||||||||
| 58 | 0 | void print_cell_frequency_link(struct Descriptor_cell_frequency_link *cfld, int level) | |||||||||
| 59 | { | ||||||||||
| 60 | struct list_head *item, *safe; | ||||||||||
| 61 | struct list_head *item1, *safe1; | ||||||||||
| 62 | |||||||||||
| 63 | 0 | printf(" Descriptor: cell_frequency_link [0x%02x]\n", cfld->descriptor_tag) ; | |||||||||
| 64 | 0 | printf(" Length: %d\n", cfld->descriptor_length) ; | |||||||||
| 65 | |||||||||||
| 66 | |||||||||||
| 67 | 0 | ▶ | list_for_each_safe(item,safe,&cfld->cfld_array) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 68 | 0 | struct CFLD_entry *cfld_entry = list_entry(item, struct CFLD_entry, next); | |||||||||
| 69 | |||||||||||
| 70 | // CFLD entry | ||||||||||
| 71 | 0 | printf(" -CFLD entry-\n") ; | |||||||||
| 72 | |||||||||||
| 73 | 0 | printf(" cell_id = %d\n", cfld_entry->cell_id) ; | |||||||||
| 74 | 0 | printf(" frequency = %d\n", cfld_entry->frequency) ; | |||||||||
| 75 | 0 | printf(" subcell_info_loop_length = %d\n", cfld_entry->subcell_info_loop_length) ; | |||||||||
| 76 | |||||||||||
| 77 | 0 | ▶ | list_for_each_safe(item1,safe1,&cfld_entry->cfld1_array) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 78 | 0 | struct CFLD1_entry *cfld1_entry = list_entry(item, struct CFLD1_entry, next); | |||||||||
| 79 | |||||||||||
| 80 | // CFLD entry | ||||||||||
| 81 | 0 | printf(" -CFLD entry-\n") ; | |||||||||
| 82 | |||||||||||
| 83 | 0 | printf(" cell_id_extension = %d\n", cfld1_entry->cell_id_extension) ; | |||||||||
| 84 | 0 | printf(" transposer_frequency = %d\n", cfld1_entry->transposer_frequency) ; | |||||||||
| 85 | } | ||||||||||
| 86 | |||||||||||
| 87 | } | ||||||||||
| 88 | |||||||||||
| 89 | 0 | } | |||||||||
| 90 | |||||||||||
| 91 | /* ----------------------------------------------------------------------- */ | ||||||||||
| 92 | 0 | struct Descriptor *parse_cell_frequency_link(struct TS_bits *bits, unsigned tag, unsigned len) | |||||||||
| 93 | { | ||||||||||
| 94 | struct Descriptor_cell_frequency_link *cfld ; | ||||||||||
| 95 | unsigned byte ; | ||||||||||
| 96 | int end_buff_len ; | ||||||||||
| 97 | |||||||||||
| 98 | 0 | cfld = (struct Descriptor_cell_frequency_link *)malloc( sizeof(*cfld) ) ; | |||||||||
| 99 | 0 | memset(cfld,0,sizeof(*cfld)); | |||||||||
| 100 | |||||||||||
| 101 | //== Parse data == | ||||||||||
| 102 | 0 | INIT_LIST_HEAD(&cfld->next); | |||||||||
| 103 | 0 | cfld->descriptor_tag = tag ; // already extracted by parse_desc() | |||||||||
| 104 | 0 | cfld->descriptor_length = len ; // already extracted by parse_desc() | |||||||||
| 105 | |||||||||||
| 106 | 0 | INIT_LIST_HEAD(&cfld->cfld_array) ; | |||||||||
| 107 | 0 | end_buff_len = bits_len_calc(bits, -cfld->descriptor_length ) ; | |||||||||
| 108 | 0 | ▶ | while (bits->buff_len > end_buff_len) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 109 | { | ||||||||||
| 110 | 0 | struct CFLD_entry *cfld_entry = malloc(sizeof(*cfld_entry)); | |||||||||
| 111 | 0 | memset(cfld_entry,0,sizeof(*cfld_entry)); | |||||||||
| 112 | 0 | list_add_tail(&cfld_entry->next,&cfld->cfld_array); | |||||||||
| 113 | |||||||||||
| 114 | 0 | cfld_entry->cell_id = bits_get(bits, 16) ; | |||||||||
| 115 | 0 | cfld_entry->frequency = bits_get(bits, 32) ; | |||||||||
| 116 | 0 | cfld_entry->subcell_info_loop_length = bits_get(bits, 8) ; | |||||||||
| 117 | |||||||||||
| 118 | 0 | INIT_LIST_HEAD(&cfld_entry->cfld1_array) ; | |||||||||
| 119 | 0 | ▶ | while (bits->buff_len >= 5) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 120 | { | ||||||||||
| 121 | 0 | struct CFLD1_entry *cfld1_entry = malloc(sizeof(*cfld1_entry)); | |||||||||
| 122 | 0 | memset(cfld1_entry,0,sizeof(*cfld1_entry)); | |||||||||
| 123 | 0 | list_add_tail(&cfld1_entry->next,&cfld_entry->cfld1_array); | |||||||||
| 124 | |||||||||||
| 125 | 0 | cfld1_entry->cell_id_extension = bits_get(bits, 8) ; | |||||||||
| 126 | 0 | cfld1_entry->transposer_frequency = bits_get(bits, 32) ; | |||||||||
| 127 | } | ||||||||||
| 128 | |||||||||||
| 129 | } | ||||||||||
| 130 | |||||||||||
| 131 | |||||||||||
| 132 | 0 | return (struct Descriptor *)cfld ; | |||||||||
| 133 | } | ||||||||||
| 134 | |||||||||||
| 135 | /* ----------------------------------------------------------------------- */ | ||||||||||
| 136 | 0 | void free_cell_frequency_link(struct Descriptor_cell_frequency_link *cfld) | |||||||||
| 137 | { | ||||||||||
| 138 | struct list_head *item, *safe; | ||||||||||
| 139 | struct list_head *item1, *safe1; | ||||||||||
| 140 | |||||||||||
| 141 | 0 | ▶ | list_for_each_safe(item,safe,&cfld->cfld_array) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 142 | 0 | struct CFLD_entry *cfld_entry = list_entry(item, struct CFLD_entry, next); | |||||||||
| 143 | |||||||||||
| 144 | 0 | ▶ | list_for_each_safe(item1,safe1,&cfld_entry->cfld1_array) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 145 | 0 | struct CFLD1_entry *cfld1_entry = list_entry(item, struct CFLD1_entry, next); | |||||||||
| 146 | 0 | free(cfld1_entry) ; | |||||||||
| 147 | } | ||||||||||
| 148 | |||||||||||
| 149 | 0 | free(cfld_entry) ; | |||||||||
| 150 | } | ||||||||||
| 151 | |||||||||||
| 152 | |||||||||||
| 153 | 0 | free(cfld) ; | |||||||||
| 154 | 0 | } | |||||||||