-
Notifications
You must be signed in to change notification settings - Fork 0
/
headend.c
186 lines (170 loc) · 5.12 KB
/
headend.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
/*
* Copyright (C) 2002 John Todd Larason <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include <stdlib.h>
#include <string.h>
#include "rtv.h"
#include "headend.h"
#include "dump.h"
struct mapping device_mapping[] = { /* combines both numeric and text keys */
{ 0, "Standard" },
{ 1, "A Lineup" },
{ 2, "B Lineup" },
{ 3, "C" },
{ 4, "Rebuild Lineup" },
{ 5, "E" },
{ 6, "F" },
{ 7, "Non-Addressable Converter" },
{ 8, "Hamlin" },
{ 9, "Jerrold Impulse" },
{ 10, "Jerrold" },
{ 11, "K" },
{ 12, "Digital Rebuild" },
{ 13, "Multiple Converters" },
{ 14, "Pioneer" },
{ 15, "Oak" },
{ 16, "Premium" },
{ 17, "Q" },
{ 18, "Cable-ready-TV" },
{ 19, "Converter Switch" },
{ 20, "Tocom" },
{ 21, "A Lineup Cable-ready-TV" },
{ 22, "B Lineup Cable-ready-TV" },
{ 23, "Scientific-Atlanta" },
{ 24, "Digital" },
{ 25, "Y" },
{ 26, "Zenith" },
{ '@', "Standard" },
{ 'A', "A Lineup" },
{ 'B', "B Lineup" },
{ 'C', "C" },
{ 'D', "Rebuild Lineup" },
{ 'E', "E" },
{ 'F', "F" },
{ 'G', "Non-Addressable Converter" },
{ 'H', "Hamlin" },
{ 'I', "Jerrold Impulse" },
{ 'J', "Jerrold" },
{ 'K', "K" },
{ 'L', "Digital Rebuild" },
{ 'M', "Multiple Converters" },
{ 'N', "Pioneer" },
{ 'O', "Oak" },
{ 'P', "Premium" },
{ 'Q', "Q" },
{ 'R', "Cable-ready-TV" },
{ 'S', "Converter Switch" },
{ 'T', "Tocom" },
{ 'U', "A Lineup Cable-ready-TV" },
{ 'V', "B Lineup Cable-ready-TV" },
{ 'W', "Scientific-Atlanta" },
{ 'X', "Digital" },
{ 'Y', "Y" },
{ 'Z', "Zenith" },
{ -1, NULL}
};
struct mapping device_bitmapping[] = { /* just like the above, but the
shifted-bit version */
{ 1 << 0, "Standard" },
{ 1 << 1, "A Lineup" },
{ 1 << 2, "B Lineup" },
{ 1 << 3, "C" },
{ 1 << 4, "Rebuild Lineup" },
{ 1 << 5, "E" },
{ 1 << 6, "F" },
{ 1 << 7, "Non-Addressable Converter" },
{ 1 << 8, "Hamlin" },
{ 1 << 9, "Jerrold Impulse" },
{ 1 << 10, "Jerrold" },
{ 1 << 11, "K" },
{ 1 << 12, "Digital Rebuild" },
{ 1 << 13, "Multiple Converters" },
{ 1 << 14, "Pioneer" },
{ 1 << 15, "Oak" },
{ 1 << 16, "Premium" },
{ 1 << 17, "Q" },
{ 1 << 18, "Cable-ready-TV" },
{ 1 << 19, "Converter Switch" },
{ 1 << 20, "Tocom" },
{ 1 << 21, "A Lineup Cable-ready-TV" },
{ 1 << 22, "B Lineup Cable-ready-TV" },
{ 1 << 23, "Scientific-Atlanta" },
{ 1 << 24, "Digital" },
{ 1 << 25, "Y" },
{ 1 << 26, "Zenith" },
{ -1, NULL}
};
struct mapping service_tier_mapping[] = {
{ 1, "Basic" },
{ 2, "Extended Basic" },
{ 3, "Premium" },
{ 4, "Pay-Per-View" },
{ 5, "Music" },
{-1, NULL }
};
int parse_headend_header(unsigned char ** pp, struct headend_header * h)
{
unsigned char * p = *pp;
h->device_bitmap = rtv_to_u32(&p);
memcpy(h->max_tier, p, 32); p += 32;
*pp = p;
return 0;
}
int parse_headend_channel(unsigned char ** pp, struct headend_channel * hc)
{
unsigned char * p = *pp;
hc->tmsid = rtv_to_u32(&p);
hc->tuning = rtv_to_u16(&p);
hc->device = *p++;
hc->service_tier = *p++;
memcpy(hc->name, p, 16); p += 16;
memcpy(hc->description, p, 32); p += 32;
*pp = p;
return 0;
}
void dump_headend_header(struct headend_header * h)
{
int i;
dump_group_start ("Headend Header");
dump_bitmapping ("Expected Devices", h->device_bitmap, device_bitmapping);
if (h->device_bitmap) {
dump_group_start("Maximum Device Service Tier");
for (i = 0; i < 32; i++)
if (h->device_bitmap & (1 << i))
dump_mapping(lookup_mapping(i, device_mapping),
h->max_tier[i], service_tier_mapping);
dump_group_end ();
}
dump_group_end ();
}
void dump_headend_channel(struct headend_channel * hc)
{
dump_group_start ("Headend Channel");
dump_u32 ("TMS ID", hc->tmsid);
dump_u16 ("Tuning", hc->tuning);
dump_mapping ("Device", hc->device, device_mapping);
dump_mapping ("Service Tier", hc->service_tier, service_tier_mapping);
dump_string ("Name", hc->name);
dump_string ("Description", hc->description);
dump_group_end ();
#if 0
printf("%-16s %3d %-8s %5d %-8.8s %s\n",
device_name(device),
channel,
tier_name(tier),
tmsid,
name,
description
);
#endif
}