Browse Source

Add internal camd settings (no_reconnect and emm_check_errors).

Georgi Chorbadzhiyski 11 years ago
parent
commit
6981585c4a
2 changed files with 13 additions and 4 deletions
  1. 10
    4
      camd.c
  2. 3
    0
      data.h

+ 10
- 4
camd.c View File

@@ -58,6 +58,12 @@ int camd_tcp_connect(struct in_addr ip, int port) {
58 58
 	return fd;
59 59
 }
60 60
 
61
+static inline void camd_reconnect(struct camd *c) {
62
+	if (c->no_reconnect)
63
+		return;
64
+	c->ops.reconnect(c);
65
+}
66
+
61 67
 void camd_set_cw(struct ts *ts, uint8_t *new_cw, int check_validity) {
62 68
 	struct camd *c = &ts->camd;
63 69
 
@@ -88,7 +94,7 @@ static int camd_recv_cw(struct ts *ts) {
88 94
 	if (ret <= 0) {
89 95
 		if (ret == -1) { // Fatal error it is better to reconnect to server.
90 96
 			ts_LOGf("ERR | No code word has been received (ret = %d)\n", ret);
91
-			c->ops.reconnect(c);
97
+			camd_reconnect(c);
92 98
 		}
93 99
 		c->ecm_recv_errors++;
94 100
 		if (c->ecm_recv_errors >= ECM_RECV_ERRORS_LIMIT) {
@@ -134,7 +140,7 @@ static int camd_send_ecm(struct ts *ts, struct camd_msg *msg) {
134 140
 	if (ret <= 0) {
135 141
 		ts_LOGf("ERR | Error sending ecm packet, reconnecting to camd.\n");
136 142
 		ts->is_cw_error = 1;
137
-		c->ops.reconnect(c);
143
+		camd_reconnect(c);
138 144
 		return ret;
139 145
 	}
140 146
 
@@ -167,9 +173,9 @@ static int camd_send_emm(struct ts *ts, struct camd_msg *msg) {
167 173
 	int ret = c->ops.do_emm(c, msg);
168 174
 	if (ret < 1) {
169 175
 		c->emm_recv_errors++;
170
-		if (c->emm_recv_errors >= EMM_RECV_ERRORS_LIMIT) {
176
+		if (c->check_emm_errors || c->emm_recv_errors >= EMM_RECV_ERRORS_LIMIT) {
171 177
 			ts_LOGf("ERR | Error sending emm packet, reconnecting to camd.\n");
172
-			c->ops.reconnect(c);
178
+			camd_reconnect(c);
173 179
 			c->emm_recv_errors = 0;
174 180
 		}
175 181
 	} else {

+ 3
- 0
data.h View File

@@ -146,6 +146,9 @@ struct camd {
146 146
 	unsigned int	ecm_recv_errors; // Error counter, reset on successful send/recv
147 147
 	unsigned int	emm_recv_errors; // Error counter, reset on successful send/recv
148 148
 
149
+	unsigned int	no_reconnect;
150
+	unsigned int	check_emm_errors;
151
+
149 152
 	struct key		*key;
150 153
 	unsigned int	constant_codeword; // The codeword is set on the command line once, no ecm processing is done.
151 154
 

Loading…
Cancel
Save