Even if doing a fast reset the baudrate for the ATR itself is still the default one
cryptoworks/viaccess: Allow EMMs that are reassembled by the client to work.

ACamd, mgcamd and possibly other clients reassemble and filter EMMs
before sending them to OSCam. When EMM reassembly was moved on the
local reader side in r8377, EMMs were stopped from reaching the card
until they were reassembled.

But if the EMM is already reassembled then no EMM-SH packets are
comming so the reassembly never succeeded.

With this change all EMMs reach the card even if they are not
reassembled. This allows already reassembled EMMs to work and EMM
reassembly to work.

The downside is that there would be some EMM writing errors because
the reader would try to write not assembled EMMs instead of waiting
for reassembly.
irdeto: Enable shared EMM filter.

See ticket #3198.

Patch by StEVE^qSR.
webif: Optimize images.

Use pngcrush and gimp to slim down PNGs and GIFs. This saves ~1.2k
binary size with no visual changes.

{{{
 webif/images/ICARRL.gif | Bin 527 -> 476 bytes
 webif/images/ICARRR.gif | Bin 521 -> 470 bytes
 webif/images/ICDEL.png  | Bin 404 -> 286 bytes
 webif/images/ICDIS.png  | Bin 216 -> 184 bytes
 webif/images/ICEDI.png  | Bin 342 -> 256 bytes
 webif/images/ICENA.png  | Bin 251 -> 161 bytes
 webif/images/ICENT.png  | Bin 294 -> 226 bytes
 webif/images/ICHID.png  | Bin 529 -> 443 bytes
 webif/images/ICKIL.png  | Bin 558 -> 463 bytes
 webif/images/ICREF.png  | Bin 499 -> 368 bytes
 webif/images/ICRES.png  | Bin 415 -> 316 bytes
 webif/images/ICSTA.png  | Bin 387 -> 347 bytes
}}}
- Added srvidholdseconds to ratelimiter (experimental)
  a srvid will be kept in slot for additional srvidholdseconds
  if used with enabled ecmunique, the ecm in slot must be ratelimitseconds unique

  E.G. CDS NL 0100:00006A
  
  ratelimitecm = 4
  ratelimitseconds = 10
  srvidholdseconds = 5
  ecmunique = 1

  Assign 4 srvid slots
  Ecm for srvid in slot is unique for 10 seconds
  Slotted srvid will be released after 10+5 = 15 seconds of inactivity
webif: Do not store images in templates array as base64.

Save a little bit of binary size.

This commit introduces no user visible changes.
webif: Compress built-in templates.

Use the minilzo code that we already have to compress the built-in
templates. This saves ~90k binary size on 32bit defconfig. As the
tool reports:

> Compressed 148820 template bytes into 51619 bytes. 97201 saved bytes (65.31%).

The old code that works with non-compressed templates is still here,
to use it, comment `#define USE_COMPRESSION 1` in webif/pages_gen.c
and recompile.

Once we establish that template compression works fine the old
code can be removed.

This commit introduces no user visible changes.
gc: Add static declarations where needed.
log: Free log history on exit.

Make valgrind a little bit happier.
readers: Do not leak entitlements on card change and reader freeing.

Reader entitlements are leaken when card is changed. Probably nobody
noticed because changing cards is not an event that happen often.
readers: Free configured readers on exit.

Make valgrind a little bit happier.
fixed emm filter in request_mode 1
Do not forget to close open file on error.

Patch by DaytonaHack.
webif: Align fields in templates data before compression.

This prevents crashes on architectures that do not allow unaligned access.
We lose a litlle bit of binary size (~520 bytes) but this is unavoidable
because unaligned access causes crashes.

This fixes crash on DD-WRT reported by basta2k.
Add emmreassembly reader setting.

Unfortunately r8441 causes too many errors for clients that do not
try to be smart (like dvbapi, see ticket #3204) so this commit reverts
r8441.

I can't see how to make non assembled and assembled emms to work both,
so I'm forced to introduce reader setting that turns off emm reassembly.

For the documentation:

emmreassembly = [0|1], Default: 1 (EMM reassembly is enabled).

emmreassembly = 0 (disable) should be set for viaccess and cryptoworks
readers if the client that you are using to send EMMs is reassembling
them instead of just sending them to OSCam for processing.

Two such clients are mgcamd and ACamd (over newcamd).
Make ptab in struct s_module embedded not a pointer.

This blows up bss (static) memory nearly twice but we'll get that
back and lots more once we slim down struct s_port in the next
commit.
Slim down struct s_port.

struct s_port contains filter array and couple of other fields that are
used only for newcamd and nothing else. They waste more than 2k in common
case.

To stop losing this much space, create private structure only for
newcamd fields and allocate it dynamically. This lowers struct s_port
size a lot and of course struct s_ptab even more because it contains
array of struct s_ports's.

New structure sizes (32-bit):
{{{
                  before  after
  struct s_port     2144     12
  struct s_ptab    68612    388
  struct s_config 141260   4812
}}}

Size report (32-bit):

{{{
    text     data      bss      dec    hex filename
  998222     1944   602344  1602510 1873ce before/oscam-1.20-unstable_svn8453-i486-slackware-linux
  998174     1944    61800  1061918 10341e  after/oscam-1.20-unstable_svn8453-i486-slackware-linux
}}}

bloat-o-meter report (32-bit):

{{{
  add/remove: 0/1 grow/shrink: 13/16 up/down: 7897/-548383 (-540486)
  function                                     old     new   delta
  modules                                     1840    9520   +7680
  ...
  cfg                                       141260    4812 -136448
  static.ptab                               411672       - -411672
}}}
newcamd: Add paranoid checks for per port newcamd data.

Better safe than sorry.
irdeto: Fix EMM filters.

What this commit does:
  - Allow shared to hex serial only for betacrypt. This allows one more
    free filter slot for Irdeto.
  - Skip not initialised providers. They always have first and third byte 0x00.
  - Improve exit conditions from provider loop. Previous patch could result
    in memory overwrite.
  - Only display "could not start all emm filters" if we break out of the
    provider loop. Previously it would display this message even if we
    haven't skipped emm filters.

Patch by malakudi posted in ticket #3198.
revert commit 7941
csp don't check ist beta or not
after commt 7990 is not more need 
when cacheex is on while ecmd5 check first.