Add support for IPv6 and for multiple CAMD addresses.
This patch adds support for connecting to CAMD over IPv6. Nice addition
is that now tsdecrypt tries each of the addresses returned when CAMD
hostname is resolved and connects to the one that works. Resolving
of the server address is done before each connect, which allows for
uninterupted migration of CAMD servers by just changing their DNS
record.
IPv6 functionality can be disabled by using -4/--ipv4 options or
if you fancy only IPv6 servers -6/--ipv6 can be used.
Flush request queue to prevent collecting too much data.
Since it is possible for EMMs and ECMs to be removed from
the queues when hard limits are reached, it is a good idea
to clear the request queue too. Without this when queues
reach their hard limits, request queue will grow slowly eating
a bit of memory. It is not much but it is wasted memory.
camd: Do not stop ECM/EMM processing thread when the incomming message is NULL.
If the message is NULL just continue. Breaking out of the loop is
wrong because it stops the ecm/processing thread and leaves tsdecrypt
in a non working state.
This way it works better when many packets are sended. Without
NODELAY, OSCAM sometimes gets packets boundaries wrong especially
when there are lots of packets (test with emm stream of 16000+
packets per minute).
Raise errors flags for ecm/emm processing only after couple of bad events.
This prevents unnececary warnings. Sometimes OSCAM responds with error
and on the next query everything is OK. So before raising errors flags
try a couple of times.
Use different queues for ECMs and EMMs. This allows to process
ECMs before EMMs, preventing the case where too much incoming
EMMs slow down ECM processing and interfere with getting the code
words on time.
This fixes Sky Italia HD channels. When they send new
code word the one that is about to expire is set to 0
and this causes short decryption failures. Now if code
word is all zeroes it is not set.