Browse Source

Add --output-tos option.

Georgi Chorbadzhiyski 12 years ago
parent
commit
83207bd4e2
7 changed files with 24 additions and 2 deletions
  1. 3
    0
      ChangeLog
  2. 1
    0
      README
  3. 1
    0
      data.c
  4. 1
    0
      data.h
  5. 3
    0
      tsdecrypt.1
  6. 9
    2
      tsdecrypt.c
  7. 6
    0
      udp.c

+ 3
- 0
ChangeLog View File

@@ -1,3 +1,6 @@
1
+next : Version next
2
+ * Add --output-tos (-g) option used to set output TOS value.
3
+
1 4
 2011-12-23 : Version 5.0
2 5
  * Add --bench (-b) option that benchmarks libdvbcsa decryption.
3 6
  * Remove --camd-pkt-delay (-y) option. This workaround is no longer needed.

+ 1
- 0
README View File

@@ -45,6 +45,7 @@ Output options:
45 45
                             .    -O -              (write to stdout) (default)
46 46
  -o --output-intf <addr>    | Set multicast output interface. Default: 0.0.0.0
47 47
  -t --output-ttl <ttl>      | Set multicast ttl. Default: 1
48
+ -g --output-tos <tos>      | Set TOS value of output packets. Default: none
48 49
  -p --no-output-filter      | Disable output filtering. Default: enabled
49 50
  -y --output-nit-pass       | Pass through NIT.
50 51
  -w --output-eit-pass       | Pass through EIT (EPG).

+ 1
- 0
data.c View File

@@ -97,6 +97,7 @@ void data_init(struct ts *ts) {
97 97
 	ts->output.fd   = 1; // STDOUT
98 98
 	ts->output.type = FILE_IO;
99 99
 	ts->output.ttl  = 1;
100
+	ts->output.tos  = -1;
100 101
 
101 102
 	ts->decode_buf  = cbuf_init((7 * dvbcsa_bs_batch_size() * 188) * 16, "decode"); // ~658Kb
102 103
 	ts->write_buf   = cbuf_init((7 * dvbcsa_bs_batch_size() * 188) *  8, "write");  // ~324Kb

+ 1
- 0
data.h View File

@@ -169,6 +169,7 @@ struct io {
169 169
 	unsigned int		port;
170 170
 	// Used only for output
171 171
 	int					ttl;
172
+	int					tos;
172 173
 	struct in_addr		intf;
173 174
 };
174 175
 

+ 3
- 0
tsdecrypt.1 View File

@@ -92,6 +92,9 @@ Set multicast output interface.
92 92
 \fB\-t\fR, \fB\-\-output\-ttl\fR
93 93
 Set multicast ttl. The default value is \fB1\fR.
94 94
 .TP
95
+\fB\-g\fR, \fB\-\-output\-tos\fR
96
+Set TOS value of output packets. The default is not to set any specific TOS.
97
+.TP
95 98
 \fB\-p\fR, \fB\-\-no\-output\-filter\fR
96 99
 Disable output filtering. By default the output filter is enabled and only
97 100
 PAT/PMT/SDT and data packets are left in the output. Everything else not

+ 9
- 2
tsdecrypt.c View File

@@ -103,7 +103,7 @@ void run_benchmark(void) {
103 103
 	puts("* Done *");
104 104
 }
105 105
 
106
-// Unused short options: FQTWYagjkmnqruv0123456789
106
+// Unused short options: FQTWYajkmnqruv0123456789
107 107
 static const struct option long_options[] = {
108 108
 	{ "ident",				required_argument, NULL, 'i' },
109 109
 	{ "daemon",				required_argument, NULL, 'd' },
@@ -120,6 +120,7 @@ static const struct option long_options[] = {
120 120
 	{ "output",				required_argument, NULL, 'O' },
121 121
 	{ "output-intf",		required_argument, NULL, 'o' },
122 122
 	{ "output-ttl",			required_argument, NULL, 't' },
123
+	{ "output-tos",			required_argument, NULL, 'g' },
123 124
 	{ "output-filter",		no_argument,       NULL, 'p' },
124 125
 	{ "no-output-filter",	no_argument,       NULL, 'p' },
125 126
 	{ "output-nit-pass",	no_argument,       NULL, 'y' },
@@ -185,6 +186,7 @@ static void show_help(struct ts *ts) {
185 186
 	printf("                            .    -O -              (write to stdout) (default)\n");
186 187
 	printf(" -o --output-intf <addr>    | Set multicast output interface. Default: %s\n", inet_ntoa(ts->output.intf));
187 188
 	printf(" -t --output-ttl <ttl>      | Set multicast ttl. Default: %d\n", ts->output.ttl);
189
+	printf(" -g --output-tos <tos>      | Set TOS value of output packets. Default: none\n");
188 190
 	printf(" -p --no-output-filter      | Disable output filtering. Default: %s\n", ts->pid_filter ? "enabled" : "disabled");
189 191
 	printf(" -y --output-nit-pass       | Pass through NIT.\n");
190 192
 	printf(" -w --output-eit-pass       | Pass through EIT (EPG).\n");
@@ -264,7 +266,7 @@ static int parse_io_param(struct io *io, char *opt, int open_flags, mode_t open_
264 266
 
265 267
 static void parse_options(struct ts *ts, int argc, char **argv) {
266 268
 	int j, i, ca_err = 0, server_err = 1, input_addr_err = 0, output_addr_err = 0, output_intf_err = 0, ident_err = 0, port_set = 0;
267
-	while ( (j = getopt_long(argc, argv, "i:d:N:Sl:L:I:RzM:O:o:t:pwxyc:C:A:s:U:P:B:eZ:Ef:X:H:G:KJ:D:bhV", long_options, NULL)) != -1 ) {
269
+	while ( (j = getopt_long(argc, argv, "i:d:N:Sl:L:I:RzM:O:o:t:g:pwxyc:C:A:s:U:P:B:eZ:Ef:X:H:G:KJ:D:bhV", long_options, NULL)) != -1 ) {
268 270
 		char *p = NULL;
269 271
 		switch (j) {
270 272
 			case 'i':
@@ -320,6 +322,9 @@ static void parse_options(struct ts *ts, int argc, char **argv) {
320 322
 			case 't':
321 323
 				ts->output.ttl = atoi(optarg);
322 324
 				break;
325
+			case 'g':
326
+				ts->output.tos = (uint8_t)strtol(optarg, NULL, 0);
327
+				break;
323 328
 			case 'p':
324 329
 				ts->pid_filter = 0;
325 330
 				break;
@@ -519,6 +524,8 @@ static void parse_options(struct ts *ts, int argc, char **argv) {
519 524
 			ts_LOGf("Output addr: udp://%s:%u/\n", inet_ntoa(ts->output.addr), ts->output.port);
520 525
 			ts_LOGf("Output intf: %s\n", inet_ntoa(ts->output.intf));
521 526
 			ts_LOGf("Output ttl : %d\n", ts->output.ttl);
527
+			if (ts->output.tos > -1)
528
+				ts_LOGf("Output TOS : %u (0x%02x)\n", ts->output.tos, ts->output.tos);
522 529
 		} else if (ts->output.type == FILE_IO) {
523 530
 			ts_LOGf("Output file: %s\n", ts->output.fd == 1 ? "STDOUT" : ts->output.fname);
524 531
 		}

+ 6
- 0
udp.c View File

@@ -104,6 +104,12 @@ int udp_connect_output(struct io *io) {
104 104
 		}
105 105
 	}
106 106
 
107
+	if (io->tos > -1) {
108
+		if (setsockopt(sock, IPPROTO_IP, IP_TOS, &io->tos, sizeof(io->tos)) < 0) {
109
+			ts_LOGf("setsockopt(IP_TOS 0x%02x): %s\n", io->tos, strerror(errno));
110
+		}
111
+	}
112
+
107 113
 	struct sockaddr_in sockaddr;
108 114
 	memset(&sockaddr, 0, sizeof(sockaddr));
109 115
 	sockaddr.sin_family			= AF_INET;

Loading…
Cancel
Save