+ else
+ {
+ unsigned session_nb;
+ session_nb=pkt[hlen-2]<<8;
+ session_nb|=pkt[hlen-1]&0xFF;
+
+ if ((!session_nb) || (session_nb >= SLMS))
+ {
+ eDebug("PROTOCOL: illegal session number %x", session_nb);
+ return;
+ }
+
+ session=sessions[session_nb-1];
+ if (!session)
+ {
+ eDebug("PROTOCOL: data on closed session %x", session_nb);
+ return;
+ }
+
+ switch (tag)
+ {
+ case 0x90:
+ break;
+ case 0x94:
+ session->recvCreateSessionResponse(pkt);
+ break;
+ case 0x95:
+ eDebug("recvCloseSessionRequest");
+ session->recvCloseSessionRequest(pkt);
+ break;
+ default:
+ eDebug("INTERNAL: nyi, tag %02x.", tag);
+ return;
+ }
+ }
+
+ hlen += llen + 1; // lengthfield and tag
+
+ pkt = ((const unsigned char*)ptr) + hlen;
+ len -= hlen;
+
+ if (session)
+ while (len > 0)
+ {
+ int alen;
+ const unsigned char *tag=pkt;
+ pkt+=3; // tag
+ len-=3;
+ hlen=parseLengthField(pkt, alen);
+ pkt+=hlen;
+ len-=hlen;
+
+ //if (eDVBCIModule::getInstance()->workarounds_active & eDVBCIModule::workaroundMagicAPDULength)
+ {
+ if (((len-alen) > 0) && ((len - alen) < 3))
+ {
+ eDebug("WORKAROUND: applying work around MagicAPDULength");
+ alen=len;
+ }
+ }
+ if (session->receivedAPDU(tag, pkt, alen))
+ session->action = 1;
+ pkt+=alen;
+ len-=alen;
+ }
+
+ if (len)
+ eDebug("PROTOCOL: warning, TL-Data has invalid length");