MythTV  master
dvbci.cpp
Go to the documentation of this file.
1 /*
2  * ci.cc: Common Interface
3  *
4  * Copyright (C) 2000 Klaus Schmidinger
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
19  * Or, point your browser to http://www.gnu.org/copyleft/gpl.html
20  *
21  * The author can be reached at kls@cadsoft.de
22  *
23  * The project's page is at http://www.cadsoft.de/people/kls/vdr
24  *
25  */
26 
27 #include "dvbci.h"
28 
29 #include <array>
30 #include <cctype>
31 #include <cerrno>
32 #include <cstring>
33 #include <ctime>
34 #include <fcntl.h>
35 #include <linux/dvb/ca.h>
36 #include <netinet/in.h>
37 #include <poll.h>
38 #include <sys/ioctl.h>
39 #include <sys/time.h>
40 #include <unistd.h>
41 #ifdef __FreeBSD__
42 # include <stdlib.h>
43 #else
44 # include <malloc.h>
45 #endif
46 
47 #include <QString>
48 
50 
51 // NOLINTBEGIN(cppcoreguidelines-macro-usage)
52 #define esyslog(a...) LOG(VB_GENERAL, LOG_ERR, QString::asprintf(a))
53 #define isyslog(a...) LOG(VB_DVBCAM, LOG_INFO, QString::asprintf(a))
54 #define dsyslog(a...) LOG(VB_DVBCAM, LOG_DEBUG, QString::asprintf(a))
55 
56 #define LOG_ERROR esyslog("ERROR (%s,%d): %m", __FILE__, __LINE__)
57 #define LOG_ERROR_STR(s) esyslog("ERROR: %s: %m", s)
58 // NOLINTEND(cppcoreguidelines-macro-usage)
59 
60 
61 // Set these to 'true' for debug output:
62 static bool sDumpTPDUDataTransfer = false;
63 static bool sDebugProtocol = false;
64 static bool sConnected = false;
65 
66 // NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
67 #define dbgprotocol(a...) if (sDebugProtocol) LOG(VB_DVBCAM, LOG_DEBUG, QString::asprintf(a))
68 
69 static constexpr int OK { 0 };
70 static constexpr int TIMEOUT { -1 };
71 static constexpr int ERROR { -2 };
72 
73 // --- Workarounds -----------------------------------------------------------
74 
75 // The Irdeto AllCAM 4.7 (and maybe others, too) does not react on AOT_ENTER_MENU
76 // during the first few seconds of a newly established connection
77 static constexpr time_t WRKRND_TIME_BEFORE_ENTER_MENU { 15 }; // seconds
78 
79 // --- Helper functions ------------------------------------------------------
80 
81 static constexpr int SIZE_INDICATOR { 0x80 };
82 
83 static ssize_t safe_read(int filedes, void *buffer, size_t size)
84 {
85  for (;;) {
86  ssize_t p = read(filedes, buffer, size);
87  if (p < 0 && (errno == EINTR || errno == EAGAIN)) {
88  dsyslog("EINTR while reading from file handle %d - retrying", filedes);
89  continue;
90  }
91  return p;
92  }
93 }
94 
95 static const uint8_t *GetLength(const uint8_t *Data, int &Length)
106 {
107  Length = *Data++;
108  if ((Length & SIZE_INDICATOR) != 0) {
109  int l = Length & ~SIZE_INDICATOR;
110  Length = 0;
111  for (int i = 0; i < l; i++)
112  Length = (Length << 8) | *Data++;
113  }
114  return Data;
115 }
116 
117 static uint8_t *SetLength(uint8_t *Data, int Length)
127 {
128  uint8_t *p = Data;
129  if (Length < 128)
130  *p++ = Length;
131  else {
132  int n = sizeof(Length);
133  for (int i = n - 1; i >= 0; i--) {
134  int b = (Length >> (8 * i)) & 0xFF;
135  if (p != Data || b)
136  *++p = b;
137  }
138  *Data = (p - Data) | SIZE_INDICATOR;
139  p++;
140  }
141  return p;
142 }
143 
145 static void SetLength(std::vector<uint8_t> &Data, int Length)
146 {
147  if (Length < 128)
148  {
149  Data.push_back(Length);
150  return;
151  }
152 
153  // This will be replaced with the number of bytes in the length
154  size_t len_offset = Data.size();
155  Data.push_back(0);
156 
157  int n = sizeof(Length);
158  for (int i = n - 1; i >= 0; i--) {
159  int b = (Length >> (8 * i)) & 0xFF;
160  if ((len_offset != Data.size()) || b)
161  Data.push_back(b);
162  }
163  Data[len_offset] = (Data.size() - len_offset) | SIZE_INDICATOR;
164 }
165 
166 static char *CopyString(int Length, const uint8_t *Data)
171 {
172  char *s = (char *)malloc(Length + 1);
173  strncpy(s, (char *)Data, Length);
174  s[Length] = 0;
175  return s;
176 }
177 
178 static char *GetString(int &Length, const uint8_t **Data)
186 {
187  if (Length > 0 && Data && *Data) {
188  int l = 0;
189  const uint8_t *d = GetLength(*Data, l);
190  char *s = CopyString(l, d);
191  Length -= d - *Data + l;
192  *Data = d + l;
193  return s;
194  }
195  return nullptr;
196 }
197 
198 
199 
200 // --- cMutex ----------------------------------------------------------------
201 
202 void cMutex::Lock(void)
203 {
204  if (getpid() != m_lockingPid || !m_locked) {
205  pthread_mutex_lock(&m_mutex);
206  m_lockingPid = getpid();
207  }
208  m_locked++;
209 }
210 
211 void cMutex::Unlock(void)
212 {
213  if (--m_locked <= 0) {
214  if (m_locked < 0) {
215  esyslog("cMutex Lock inbalance detected");
216  m_locked = 0;
217  }
218  m_lockingPid = 0;
219  pthread_mutex_unlock(&m_mutex);
220  }
221 }
222 // --- cMutexLock ------------------------------------------------------------
223 
225 {
226  if (m_mutex && m_locked)
227  m_mutex->Unlock();
228 }
229 
231 {
232  if (Mutex && !m_mutex) {
233  m_mutex = Mutex;
234  Mutex->Lock();
235  m_locked = true;
236  return true;
237  }
238  return false;
239 }
240 
241 
242 
243 // --- cTPDU -----------------------------------------------------------------
244 
245 static constexpr size_t MAX_TPDU_SIZE { 2048 };
246 static constexpr int MAX_TPDU_DATA { MAX_TPDU_SIZE - 4 };
247 
248 static constexpr uint8_t DATA_INDICATOR { 0x80 };
249 
250 enum T_VALUES {
251  T_SB = 0x80,
252  T_RCV = 0x81,
253  T_CREATE_TC = 0x82,
254  T_CTC_REPLY = 0x83,
255  T_DELETE_TC = 0x84,
256  T_DTC_REPLY = 0x85,
257  T_REQUEST_TC = 0x86,
258  T_NEW_TC = 0x87,
259  T_TC_ERROR = 0x88,
260  T_DATA_LAST = 0xA0,
261  T_DATA_MORE = 0xA1,
262 };
263 
264 class cTPDU {
265 private:
266  ssize_t m_size {0};
267  std::array<uint8_t,MAX_TPDU_SIZE> m_data {0};
268  const uint8_t *GetData(const uint8_t *Data, int &Length) const;
269 public:
270  cTPDU(void) = default;
271  cTPDU(uint8_t Slot, uint8_t Tcid, uint8_t Tag, int Length = 0, const uint8_t *Data = nullptr);
272  uint8_t Slot(void) { return m_data[0]; }
273  uint8_t Tcid(void) { return m_data[1]; }
274  uint8_t Tag(void) { return m_data[2]; }
275  const uint8_t *Data(int &Length) { return GetData(m_data.data() + 3, Length); }
276  uint8_t Status(void);
277  int Write(int fd);
278  int Read(int fd);
279  void Dump(bool Outgoing);
280  };
281 
282 cTPDU::cTPDU(uint8_t Slot, uint8_t Tcid, uint8_t Tag, int Length, const uint8_t *Data)
283 {
284  m_data[0] = Slot;
285  m_data[1] = Tcid;
286  m_data[2] = Tag;
287  switch (Tag) {
288  case T_RCV:
289  case T_CREATE_TC:
290  case T_CTC_REPLY:
291  case T_DELETE_TC:
292  case T_DTC_REPLY:
293  case T_REQUEST_TC:
294  m_data[3] = 1; // length
295  m_data[4] = Tcid;
296  m_size = 5;
297  break;
298  case T_NEW_TC:
299  case T_TC_ERROR:
300  if (Length == 1) {
301  m_data[3] = 2; // length
302  m_data[4] = Tcid;
303  m_data[5] = Data[0];
304  m_size = 6;
305  }
306  else
307  esyslog("ERROR: illegal data length for TPDU tag 0x%02X: %d", Tag, Length);
308  break;
309  case T_DATA_LAST:
310  case T_DATA_MORE:
311  if (Length <= MAX_TPDU_DATA) {
312  uint8_t *p = m_data.data() + 3;
313  p = SetLength(p, Length + 1);
314  *p++ = Tcid;
315  if (Length)
316  memcpy(p, Data, Length);
317  m_size = Length + (p - m_data.data());
318  }
319  else
320  esyslog("ERROR: illegal data length for TPDU tag 0x%02X: %d", Tag, Length);
321  break;
322  default:
323  esyslog("ERROR: unknown TPDU tag: 0x%02X", Tag);
324  }
325  }
326 
327 int cTPDU::Write(int fd)
328 {
329  Dump(true);
330  if (m_size)
331  return write(fd, m_data.data(), m_size) == m_size ? OK : ERROR;
332  esyslog("ERROR: attemp to write TPDU with zero size");
333  return ERROR;
334 }
335 
336 int cTPDU::Read(int fd)
337 {
338  m_size = safe_read(fd, m_data.data(), m_data.size());
339  if (m_size < 0) {
340  esyslog("ERROR: %m");
341  m_size = 0;
342  return ERROR;
343  }
344  Dump(false);
345  return OK;
346 }
347 
348 void cTPDU::Dump(bool Outgoing)
349 {
350  if (sDumpTPDUDataTransfer) {
351  static constexpr ssize_t MAX_DUMP { 256 };
352  QString msg = QString("%1 ").arg(Outgoing ? "-->" : "<--");
353  for (int i = 0; i < m_size && i < MAX_DUMP; i++)
354  msg += QString("%1 ").arg((short int)m_data[i], 2, 16, QChar('0'));
355  if (m_size >= MAX_DUMP)
356  msg += "...";
357  LOG(VB_DVBCAM, LOG_INFO, msg);
358  if (!Outgoing) {
359  msg = QString(" ");
360  for (int i = 0; i < m_size && i < MAX_DUMP; i++)
361  msg += QString("%1 ").arg(isprint(m_data[i]) ? m_data[i] : '.', 2);
362  if (m_size >= MAX_DUMP)
363  msg += "...";
364  LOG(VB_DVBCAM, LOG_INFO, msg);
365  }
366  }
367 }
368 
369 const uint8_t *cTPDU::GetData(const uint8_t *Data, int &Length) const
370 {
371  if (m_size) {
372  Data = GetLength(Data, Length);
373  if (Length) {
374  Length--; // the first byte is always the tcid
375  return Data + 1;
376  }
377  }
378  return nullptr;
379 }
380 
381 uint8_t cTPDU::Status(void)
382 {
383  if (m_size >= 4 && m_data[m_size - 4] == T_SB && m_data[m_size - 3] == 2) {
384  //XXX test tcid???
385  return m_data[m_size - 1];
386  }
387  return 0;
388 }
389 
390 // --- cCiTransportConnection ------------------------------------------------
391 
393 
395  friend class cCiTransportLayer;
396 private:
397  int m_fd {-1};
398  uint8_t m_slot {0};
399  uint8_t m_tcid {0};
401  cTPDU *m_tpdu {nullptr};
402  std::chrono::milliseconds m_lastPoll {0ms};
404  bool m_dataAvailable {false};
405  void Init(int Fd, uint8_t Slot, uint8_t Tcid);
406  int SendTPDU(uint8_t Tag, int Length = 0, const uint8_t *Data = nullptr) const;
407  int RecvTPDU(void);
408  int CreateConnection(void);
409  int Poll(void);
410  eState State(void) { return m_state; }
411  int LastResponse(void) const { return m_lastResponse; }
412  bool DataAvailable(void) const { return m_dataAvailable; }
413 public:
416  int Slot(void) const { return m_slot; }
417  int SendData(int Length, const uint8_t *Data);
418  int SendData(std::vector<uint8_t> &Data)
419  { return SendData(Data.size(), Data.data()); }
420  int RecvData(void);
421  const uint8_t *Data(int &Length);
422  //XXX Close()
423  };
424 
426 {
427  Init(-1, 0, 0);
428 }
429 
431 {
432  delete m_tpdu;
433 }
434 
435 void cCiTransportConnection::Init(int Fd, uint8_t Slot, uint8_t Tcid)
436 {
437  m_fd = Fd;
438  m_slot = Slot;
439  m_tcid = Tcid;
440  m_state = stIDLE;
441  if (m_fd >= 0 && !m_tpdu)
442  m_tpdu = new cTPDU;
444  m_dataAvailable = false;
445 //XXX Clear()???
446 }
447 
448 int cCiTransportConnection::SendTPDU(uint8_t Tag, int Length, const uint8_t *Data) const
449 {
450  cTPDU TPDU(m_slot, m_tcid, Tag, Length, Data);
451  return TPDU.Write(m_fd);
452 }
453 
454 static constexpr int CAM_READ_TIMEOUT { 5000 }; // ms
455 
457 {
458  std::array<struct pollfd,1> pfd {};
459  pfd[0].fd = m_fd;
460  pfd[0].events = POLLIN;
462 
463  for (;;) {
464  int ret = poll(pfd.data(), 1, CAM_READ_TIMEOUT);
465  if (ret == -1 && (errno == EAGAIN || errno == EINTR))
466  continue;
467  break;
468  }
469 
470  if (
471  (pfd[0].revents & POLLIN) &&
472  m_tpdu->Read(m_fd) == OK &&
473  m_tpdu->Tcid() == m_tcid
474  )
475  {
476  switch (m_state) {
477  case stIDLE: break;
478  case stCREATION: if (m_tpdu->Tag() == T_CTC_REPLY) {
480  m_state = stACTIVE;
482  }
483  break;
484  case stACTIVE: switch (m_tpdu->Tag()) {
485  case T_SB:
486  case T_DATA_LAST:
487  case T_DATA_MORE:
488  case T_REQUEST_TC: break;
489  case T_DELETE_TC: if (SendTPDU(T_DTC_REPLY) != OK)
490  return ERROR;
491  Init(m_fd, m_slot, m_tcid);
492  break;
493  default: return ERROR;
494  }
497  break;
498  case stDELETION: if (m_tpdu->Tag() == T_DTC_REPLY) {
499  Init(m_fd, m_slot, m_tcid);
500  //XXX Status()???
502  }
503  break;
504  }
505  }
506  else {
507  esyslog("ERROR: CAM: Read failed: slot %d, tcid %d\n", m_slot, m_tcid);
508  if (m_tpdu->Tcid() == m_tcid)
509  Init(-1, m_slot, m_tcid);
510  }
511  return m_lastResponse;
512 }
513 
514 int cCiTransportConnection::SendData(int Length, const uint8_t *Data)
515 {
516  while (m_state == stACTIVE && Length > 0) {
517  uint8_t Tag = T_DATA_LAST;
518  int l = Length;
519  if (l > MAX_TPDU_DATA) {
520  Tag = T_DATA_MORE;
521  l = MAX_TPDU_DATA;
522  }
523  if (SendTPDU(Tag, l, Data) != OK || RecvTPDU() != T_SB)
524  break;
525  Length -= l;
526  Data += l;
527  }
528  return Length ? ERROR : OK;
529 }
530 
532 {
533  if (SendTPDU(T_RCV) == OK)
534  return RecvTPDU();
535  return ERROR;
536 }
537 
538 const uint8_t *cCiTransportConnection::Data(int &Length)
539 {
540  return m_tpdu->Data(Length);
541 }
542 
543 static constexpr int8_t MAX_CONNECT_RETRIES { 25 };
544 
546 {
547  if (m_state == stIDLE) {
548  if (SendTPDU(T_CREATE_TC) == OK) {
550  if (RecvTPDU() == T_CTC_REPLY) {
551  sConnected=true;
552  return OK;
553  // the following is a workaround for CAMs that don't quite follow the specs...
554  }
555 
556  for (int i = 0; i < MAX_CONNECT_RETRIES; i++) {
557  dsyslog("CAM: retrying to establish connection");
558  if (RecvTPDU() == T_CTC_REPLY) {
559  dsyslog("CAM: connection established");
560  sConnected=true;
561  return OK;
562  }
563  }
564  return ERROR;
565  }
566  }
567  return ERROR;
568 }
569 
570 // Polls can be done with a 100ms interval (EN50221 - A.4.1.12)
571 static constexpr std::chrono::milliseconds POLL_INTERVAL { 100ms };
572 
574 {
575  if (m_state != stACTIVE)
576  return ERROR;
577 
578  auto curr_time = nowAsDuration<std::chrono::milliseconds>();
579  std::chrono::milliseconds msdiff = curr_time - m_lastPoll;
580 
581  if (msdiff < POLL_INTERVAL)
582  return OK;
583 
584  m_lastPoll = curr_time;
585 
586  if (SendTPDU(T_DATA_LAST) != OK)
587  return ERROR;
588 
589  return RecvTPDU();
590 }
591 
592 // --- cCiTransportLayer -----------------------------------------------------
593 
594 static constexpr size_t MAX_CI_CONNECT { 16 }; // maximum possible value is 254
595 
597 private:
598  int m_fd;
600  std::array<cCiTransportConnection,MAX_CI_CONNECT> m_tc;
601 public:
602  cCiTransportLayer(int Fd, int NumSlots);
604  bool ResetSlot(int Slot) const;
605  bool ModuleReady(int Slot) const;
606  cCiTransportConnection *Process(int Slot);
607  };
608 
610 {
611  m_fd = Fd;
612  m_numSlots = NumSlots;
613  for (int s = 0; s < m_numSlots; s++)
614  ResetSlot(s);
615 }
616 
618 {
619  for (size_t i = 0; i < MAX_CI_CONNECT; i++) {
620  if (m_tc[i].State() == stIDLE) {
621  dbgprotocol("Creating connection: slot %d, tcid %zd\n", Slot, i + 1);
622  m_tc[i].Init(m_fd, Slot, i + 1);
623  if (m_tc[i].CreateConnection() == OK)
624  return &m_tc[i];
625  break;
626  }
627  }
628  return nullptr;
629 }
630 
631 bool cCiTransportLayer::ResetSlot(int Slot) const
632 {
633  dbgprotocol("Resetting slot %d...", Slot);
634  if (ioctl(m_fd, CA_RESET, 1 << Slot) != -1) {
635  dbgprotocol("ok.\n");
636  return true;
637  }
638  esyslog("ERROR: can't reset CAM slot %d: %m", Slot);
639  dbgprotocol("failed!\n");
640  return false;
641 }
642 
643 bool cCiTransportLayer::ModuleReady(int Slot) const
644 {
645  ca_slot_info_t sinfo;
646  sinfo.num = Slot;
647  if (ioctl(m_fd, CA_GET_SLOT_INFO, &sinfo) != -1)
648  return (sinfo.flags & CA_CI_MODULE_READY) != 0U;
649  esyslog("ERROR: can't get info on CAM slot %d: %m", Slot);
650  return false;
651 }
652 
654 {
655  for (auto & conn : m_tc) {
656  cCiTransportConnection *Tc = &conn;
657  if (Tc->Slot() == Slot) {
658  switch (Tc->State()) {
659  case stCREATION:
660  case stACTIVE:
661  if (!Tc->DataAvailable()) {
662  Tc->Poll();
663  }
664  switch (Tc->LastResponse()) {
665  case T_REQUEST_TC:
666  //XXX
667  break;
668  case T_DATA_MORE:
669  case T_DATA_LAST:
670  case T_CTC_REPLY:
671  case T_SB:
672  if (Tc->DataAvailable())
673  Tc->RecvData();
674  break;
675  case TIMEOUT:
676  case ERROR:
677  default:
678  //XXX Tc->state = stIDLE;//XXX Init()???
679  return nullptr;
680  break;
681  }
682  //XXX this will only work with _one_ transport connection per slot!
683  return Tc;
684  break;
685  default: ;
686  }
687  }
688  }
689  return nullptr;
690 }
691 
692 // -- cCiSession -------------------------------------------------------------
693 
694 // Session Tags:
695 
704 };
705 
706 // Session Status:
707 
709  SS_OK = 0x00,
711 };
712 
713 // Resource Identifiers:
714 
716  RI_RESOURCE_MANAGER = 0x00010041,
719  RI_HOST_CONTROL = 0x00200041,
720  RI_DATE_TIME = 0x00240041,
721  RI_MMI = 0x00400041,
722 };
723 
724 // Application Object Tags:
725 
727  AOT_NONE = 0x000000,
728  AOT_PROFILE_ENQ = 0x9F8010,
729  AOT_PROFILE = 0x9F8011,
730  AOT_PROFILE_CHANGE = 0x9F8012,
733  AOT_ENTER_MENU = 0x9F8022,
734  AOT_CA_INFO_ENQ = 0x9F8030,
735  AOT_CA_INFO = 0x9F8031,
736  AOT_CA_PMT = 0x9F8032,
737  AOT_CA_PMT_REPLY = 0x9F8033,
738  AOT_TUNE = 0x9F8400,
739  AOT_REPLACE = 0x9F8401,
740  AOT_CLEAR_REPLACE = 0x9F8402,
741  AOT_ASK_RELEASE = 0x9F8403,
742  AOT_DATE_TIME_ENQ = 0x9F8440,
743  AOT_DATE_TIME = 0x9F8441,
744  AOT_CLOSE_MMI = 0x9F8800,
746  AOT_DISPLAY_REPLY = 0x9F8802,
747  AOT_TEXT_LAST = 0x9F8803,
748  AOT_TEXT_MORE = 0x9F8804,
749  AOT_KEYPAD_CONTROL = 0x9F8805,
750  AOT_KEYPRESS = 0x9F8806,
751  AOT_ENQ = 0x9F8807,
752  AOT_ANSW = 0x9F8808,
753  AOT_MENU_LAST = 0x9F8809,
754  AOT_MENU_MORE = 0x9F880A,
755  AOT_MENU_ANSW = 0x9F880B,
756  AOT_LIST_LAST = 0x9F880C,
757  AOT_LIST_MORE = 0x9F880D,
761  AOT_SCENE_END_MARK = 0x9F8811,
762  AOT_SCENE_DONE = 0x9F8812,
763  AOT_SCENE_CONTROL = 0x9F8813,
766  AOT_FLUSH_DOWNLOAD = 0x9F8816,
767  AOT_DOWNLOAD_REPLY = 0x9F8817,
768  AOT_COMMS_CMD = 0x9F8C00,
770  AOT_COMMS_REPLY = 0x9F8C02,
773  AOT_COMMS_RCV_LAST = 0x9F8C05,
774  AOT_COMMS_RCV_MORE = 0x9F8C06,
775 };
776 
777 class cCiSession {
778 private:
782 protected:
783  static int GetTag(int &Length, const uint8_t **Data);
784  static const uint8_t *GetData(const uint8_t *Data, int &Length);
785  int SendData(int Tag, int Length = 0, const uint8_t *Data = nullptr);
786  int SendData(int Tag, std::vector<uint8_t> &Data)
787  { return SendData(Tag, Data.size(), Data.data()); };
788 public:
790  virtual ~cCiSession() = default;
791  const cCiTransportConnection *Tc(void) { return m_tc; }
792  int SessionId(void) const { return m_sessionId; }
793  int ResourceId(void) const { return m_resourceId; }
794  virtual bool HasUserIO(void) { return false; }
795  virtual bool Process(int Length = 0, const uint8_t *Data = nullptr);
796  };
797 
798 cCiSession::cCiSession(int SessionId, int ResourceId, cCiTransportConnection *Tc)
799 {
802  m_tc = Tc;
803 }
804 
805 int cCiSession::GetTag(int &Length, const uint8_t **Data)
813 {
814  if (Length >= 3 && Data && *Data) {
815  int t = 0;
816  for (int i = 0; i < 3; i++)
817  t = (t << 8) | *(*Data)++;
818  Length -= 3;
819  return t;
820  }
821  return AOT_NONE;
822 }
823 
824 const uint8_t *cCiSession::GetData(const uint8_t *Data, int &Length)
825 {
826  Data = GetLength(Data, Length);
827  return Length ? Data : nullptr;
828 }
829 
830 int cCiSession::SendData(int Tag, int Length, const uint8_t *Data)
831 {
832  if (Length < 0)
833  {
834  esyslog("ERROR: CAM: data length (%d) is negative", Length);
835  return ERROR;
836  }
837 
838  if ((Length > 0) && !Data)
839  {
840  esyslog("ERROR: CAM: Data pointer null");
841  return ERROR;
842  }
843 
844  std::vector<uint8_t> buffer {
845  ST_SESSION_NUMBER, 0x02,
846  static_cast<uint8_t>((m_sessionId >> 8) & 0xFF),
847  static_cast<uint8_t>((m_sessionId ) & 0xFF),
848  static_cast<uint8_t>((Tag >> 16) & 0xFF),
849  static_cast<uint8_t>((Tag >> 8) & 0xFF),
850  static_cast<uint8_t>((Tag ) & 0xFF)} ;
851  buffer.reserve(2048);
852 
853  SetLength(buffer, Length);
854  if (buffer.size() + Length >= buffer.capacity())
855  {
856  esyslog("ERROR: CAM: data length (%d) exceeds buffer size", Length);
857  return ERROR;
858  }
859 
860  if (Length != 0)
861  {
862  buffer.insert(buffer.end(), Data, Data + Length);
863  }
864  return m_tc->SendData(buffer);
865 }
866 
867 bool cCiSession::Process([[maybe_unused]] int Length,
868  [[maybe_unused]] const uint8_t *Data)
869 {
870  return true;
871 }
872 
873 // -- cCiResourceManager -----------------------------------------------------
874 
876 private:
877  int m_state;
878 public:
880  bool Process(int Length = 0, const uint8_t *Data = nullptr) override; // cCiSession
881  };
882 
884 :cCiSession(SessionId, RI_RESOURCE_MANAGER, Tc)
885 {
886  dbgprotocol("New Resource Manager (session id %d)\n", SessionId);
887  m_state = 0;
888 }
889 
890 bool cCiResourceManager::Process(int Length, const uint8_t *Data)
891 {
892  if (Data) {
893  int Tag = GetTag(Length, &Data);
894  switch (Tag) {
895  case AOT_PROFILE_ENQ: {
896  dbgprotocol("%d: <== Profile Enquiry\n", SessionId());
897  const std::array<const uint32_t,5> resources
898  {
899  htonl(RI_RESOURCE_MANAGER),
902  htonl(RI_DATE_TIME),
903  htonl(RI_MMI)
904  };
905  dbgprotocol("%d: ==> Profile\n", SessionId());
906  SendData(AOT_PROFILE, resources.size() * sizeof(uint32_t),
907  reinterpret_cast<const uint8_t*>(resources.data()));
908  m_state = 3;
909  }
910  break;
911  case AOT_PROFILE: {
912  dbgprotocol("%d: <== Profile\n", SessionId());
913  if (m_state == 1) {
914  int l = 0;
915  const uint8_t *d = GetData(Data, l);
916  if (l > 0 && d)
917  esyslog("CI resource manager: unexpected data");
918  dbgprotocol("%d: ==> Profile Change\n", SessionId());
920  m_state = 2;
921  }
922  else {
923  esyslog("ERROR: CI resource manager: unexpected tag %06X in state %d", Tag, m_state);
924  }
925  }
926  break;
927  default: esyslog("ERROR: CI resource manager: unknown tag %06X", Tag);
928  return false;
929  }
930  }
931  else if (m_state == 0) {
932  dbgprotocol("%d: ==> Profile Enq\n", SessionId());
934  m_state = 1;
935  }
936  return true;
937 }
938 
939 // --- cCiApplicationInformation ---------------------------------------------
940 
942 private:
943  int m_state;
949 public:
951  ~cCiApplicationInformation() override;
952  bool Process(int Length = 0, const uint8_t *Data = nullptr) override; // cCiSession
953  bool EnterMenu(void);
954  char *GetApplicationString() { return strdup(m_menuString); };
957  };
958 
960 :cCiSession(SessionId, RI_APPLICATION_INFORMATION, Tc)
961 {
962  dbgprotocol("New Application Information (session id %d)\n", SessionId);
963  m_state = 0;
964  m_creationTime = time(nullptr);
965  m_applicationType = 0;
967  m_manufacturerCode = 0;
968  m_menuString = nullptr;
969 }
970 
972 {
973  free(m_menuString);
974 }
975 
976 bool cCiApplicationInformation::Process(int Length, const uint8_t *Data)
977 {
978  if (Data) {
979  int Tag = GetTag(Length, &Data);
980  switch (Tag) {
981  case AOT_APPLICATION_INFO: {
982  dbgprotocol("%d: <== Application Info\n", SessionId());
983  int l = 0;
984  const uint8_t *d = GetData(Data, l);
985  if ((l -= 1) < 0) break;
986  m_applicationType = *d++;
987  if ((l -= 2) < 0) break;
988  m_applicationManufacturer = ntohs(*(uint16_t *)d);
989  d += 2;
990  if ((l -= 2) < 0) break;
991  m_manufacturerCode = ntohs(*(uint16_t *)d);
992  d += 2;
993  free(m_menuString);
994  m_menuString = GetString(l, &d);
995  isyslog("CAM: %s, %02X, %04X, %04X", m_menuString, m_applicationType,
997  }
998  m_state = 2;
999  break;
1000  default: esyslog("ERROR: CI application information: unknown tag %06X", Tag);
1001  return false;
1002  }
1003  }
1004  else if (m_state == 0) {
1005  dbgprotocol("%d: ==> Application Info Enq\n", SessionId());
1007  m_state = 1;
1008  }
1009  return true;
1010 }
1011 
1013 {
1014  if (m_state == 2 && time(nullptr) - m_creationTime > WRKRND_TIME_BEFORE_ENTER_MENU) {
1015  dbgprotocol("%d: ==> Enter Menu\n", SessionId());
1017  return true;//XXX
1018  }
1019  return false;
1020 }
1021 
1022 // --- cCiConditionalAccessSupport -------------------------------------------
1023 
1025 private:
1026  int m_state {0};
1028  bool m_needCaPmt {false};
1029 public:
1031  bool Process(int Length = 0, const uint8_t *Data = nullptr) override; // cCiSession
1033  bool SendPMT(const cCiCaPmt &CaPmt);
1034  bool NeedCaPmt(void) const { return m_needCaPmt; }
1035  };
1036 
1038  int SessionId, cCiTransportConnection *Tc) :
1040 {
1041  dbgprotocol("New Conditional Access Support (session id %d)\n", SessionId);
1042 }
1043 
1044 bool cCiConditionalAccessSupport::Process(int Length, const uint8_t *Data)
1045 {
1046  if (Data) {
1047  int Tag = GetTag(Length, &Data);
1048  switch (Tag) {
1049  case AOT_CA_INFO: {
1050  dbgprotocol("%d: <== Ca Info", SessionId());
1051  int l = 0;
1052  const uint8_t *d = GetData(Data, l);
1053  while (l > 1) {
1054  unsigned short id = ((unsigned short)(*d) << 8) | *(d + 1);
1055  dbgprotocol(" %04X", id);
1056  d += 2;
1057  l -= 2;
1058 
1059  // Make sure the id is not already present
1060  if (std::find(m_caSystemIds.cbegin(), m_caSystemIds.cend(), id)
1061  != m_caSystemIds.end())
1062  continue;
1063 
1064  // Insert before the last element.
1065  m_caSystemIds.emplace_back(id);
1066  }
1067 
1068  dbgprotocol("\n");
1069  }
1070  m_state = 2;
1071  m_needCaPmt = true;
1072  break;
1073  default: esyslog("ERROR: CI conditional access support: unknown tag %06X", Tag);
1074  return false;
1075  }
1076  }
1077  else if (m_state == 0) {
1078  dbgprotocol("%d: ==> Ca Info Enq\n", SessionId());
1080  m_state = 1;
1081  }
1082  return true;
1083 }
1084 
1086 {
1087  if (m_state == 2) {
1088  SendData(AOT_CA_PMT, CaPmt.m_length, CaPmt.m_capmt);
1089  m_needCaPmt = false;
1090  return true;
1091  }
1092  return false;
1093 }
1094 
1095 // --- cCiDateTime -----------------------------------------------------------
1096 
1097 class cCiDateTime : public cCiSession {
1098 private:
1099  int m_interval { 0 };
1100  time_t m_lastTime { 0 };
1101  int m_timeOffset { 0 };
1102  bool SendDateTime(void);
1103 public:
1105  bool Process(int Length = 0, const uint8_t *Data = nullptr) override; // cCiSession
1106  void SetTimeOffset(double offset);
1107  };
1108 
1110 :cCiSession(SessionId, RI_DATE_TIME, Tc)
1111 {
1112  dbgprotocol("New Date Time (session id %d)\n", SessionId);
1113 }
1114 
1115 void cCiDateTime::SetTimeOffset(double offset)
1116 {
1117  m_timeOffset = (int) offset;
1118  dbgprotocol("New Time Offset: %i secs\n", m_timeOffset);
1119 }
1120 
1121 static constexpr uint8_t DEC2BCD(uint8_t d)
1122  { return ((d / 10) << 4) + (d % 10); }
1123 static constexpr uint8_t BYTE0(uint16_t a)
1124  { return static_cast<uint8_t>(a & 0xFF); }
1125 static constexpr uint8_t BYTE1(uint16_t a)
1126  { return static_cast<uint8_t>((a >> 8) & 0xFF); }
1127 
1129 {
1130  time_t t = time(nullptr);
1131  struct tm tm_gmt {};
1132  struct tm tm_loc {};
1133 
1134  // Avoid using signed time_t types
1135  if (m_timeOffset < 0)
1136  t -= (time_t)(-m_timeOffset);
1137  else
1138  t += (time_t)(m_timeOffset);
1139 
1140  if (gmtime_r(&t, &tm_gmt) && localtime_r(&t, &tm_loc)) {
1141  int Y = tm_gmt.tm_year;
1142  int M = tm_gmt.tm_mon + 1;
1143  int D = tm_gmt.tm_mday;
1144  int L = (M == 1 || M == 2) ? 1 : 0;
1145  int MJD = 14956 + D + int((Y - L) * 365.25) + int((M + 1 + L * 12) * 30.6001);
1146  uint16_t mjd = htons(MJD);
1147  int16_t local_offset = htons(tm_loc.tm_gmtoff / 60);
1148  std::vector<uint8_t> T {
1149  BYTE0(mjd),
1150  BYTE1(mjd),
1151  DEC2BCD(tm_gmt.tm_hour),
1152  DEC2BCD(tm_gmt.tm_min),
1153  DEC2BCD(tm_gmt.tm_sec),
1154  BYTE0(local_offset),
1155  BYTE1(local_offset)
1156  };
1157 
1158  dbgprotocol("%d: ==> Date Time\n", SessionId());
1159  SendData(AOT_DATE_TIME, T);
1160  //XXX return value of all SendData() calls???
1161  return true;
1162  }
1163  return false;
1164 }
1165 
1166 bool cCiDateTime::Process(int Length, const uint8_t *Data)
1167 {
1168  if (Data) {
1169  int Tag = GetTag(Length, &Data);
1170  switch (Tag) {
1171  case AOT_DATE_TIME_ENQ: {
1172  m_interval = 0;
1173  int l = 0;
1174  const uint8_t *d = GetData(Data, l);
1175  if (l > 0)
1176  m_interval = *d;
1177  dbgprotocol("%d: <== Date Time Enq, interval = %d\n", SessionId(), m_interval);
1178  m_lastTime = time(nullptr);
1179  return SendDateTime();
1180  }
1181  break;
1182  default: esyslog("ERROR: CI date time: unknown tag %06X", Tag);
1183  return false;
1184  }
1185  }
1186  else if (m_interval && time(nullptr) - m_lastTime > m_interval) {
1187  m_lastTime = time(nullptr);
1188  return SendDateTime();
1189  }
1190  return true;
1191 }
1192 
1193 // --- cCiMMI ----------------------------------------------------------------
1194 
1195 // Close MMI Commands:
1196 
1200 };
1201 
1202 // Display Control Commands:
1203 
1210 };
1211 
1212 // MMI Modes:
1213 
1218 };
1219 
1220 // Display Reply IDs:
1221 
1231 };
1232 
1233 // Enquiry Flags:
1234 
1235 static constexpr uint8_t EF_BLIND { 0x01 };
1236 
1237 // Answer IDs:
1238 
1240  AI_CANCEL = 0x00,
1241  AI_ANSWER = 0x01,
1242 };
1243 
1244 class cCiMMI : public cCiSession {
1245 private:
1246  char *GetText(int &Length, const uint8_t **Data);
1249 public:
1251  ~cCiMMI() override;
1252  bool Process(int Length = 0, const uint8_t *Data = nullptr) override; // cCiSession
1253  bool HasUserIO(void) override { return m_menu || m_enquiry; } // cCiSession
1254  cCiMenu *Menu(void);
1255  cCiEnquiry *Enquiry(void);
1256  bool SendMenuAnswer(uint8_t Selection);
1257  bool SendAnswer(const char *Text);
1258  };
1259 
1261 :cCiSession(SessionId, RI_MMI, Tc)
1262 {
1263  dbgprotocol("New MMI (session id %d)\n", SessionId);
1264  m_menu = nullptr;
1265  m_enquiry = nullptr;
1266 }
1267 
1269 {
1270  delete m_menu;
1271  delete m_enquiry;
1272 }
1273 
1274 char *cCiMMI::GetText(int &Length, const uint8_t **Data)
1282 {
1283  int Tag = GetTag(Length, Data);
1284  if (Tag == AOT_TEXT_LAST) {
1285  char *s = GetString(Length, Data);
1286  dbgprotocol("%d: <== Text Last '%s'\n", SessionId(), s);
1287  return s;
1288  }
1289  esyslog("CI MMI: unexpected text tag: %06X", Tag);
1290  return nullptr;
1291 }
1292 
1293 bool cCiMMI::Process(int Length, const uint8_t *Data)
1294 {
1295  if (Data) {
1296  int Tag = GetTag(Length, &Data);
1297  switch (Tag) {
1298  case AOT_DISPLAY_CONTROL: {
1299  dbgprotocol("%d: <== Display Control\n", SessionId());
1300  int l = 0;
1301  const uint8_t *d = GetData(Data, l);
1302  if (l > 0) {
1303  switch (*d) {
1304  case DCC_SET_MMI_MODE:
1305  if (l == 2 && *++d == MM_HIGH_LEVEL) {
1306  struct tDisplayReply { uint8_t m_id; uint8_t m_mode; };
1307  tDisplayReply dr {};
1308  dr.m_id = DRI_MMI_MODE_ACK;
1309  dr.m_mode = MM_HIGH_LEVEL;
1310  dbgprotocol("%d: ==> Display Reply\n", SessionId());
1311  SendData(AOT_DISPLAY_REPLY, 2, (uint8_t *)&dr);
1312  }
1313  break;
1314  default: esyslog("CI MMI: unsupported display control command %02X", *d);
1315  return false;
1316  }
1317  }
1318  }
1319  break;
1320  case AOT_LIST_LAST:
1321  case AOT_MENU_LAST: {
1322  dbgprotocol("%d: <== Menu Last\n", SessionId());
1323  delete m_menu;
1324  m_menu = new cCiMenu(this, Tag == AOT_MENU_LAST);
1325  int l = 0;
1326  const uint8_t *d = GetData(Data, l);
1327  if (l > 0) {
1328  // since the specification allows choiceNb to be undefined it is useless, so let's just skip it:
1329  d++;
1330  l--;
1331  if (l > 0) m_menu->m_titleText = GetText(l, &d);
1332  if (l > 0) m_menu->m_subTitleText = GetText(l, &d);
1333  if (l > 0) m_menu->m_bottomText = GetText(l, &d);
1334  while (l > 0) {
1335  char *s = GetText(l, &d);
1336  if (s) {
1337  if (!m_menu->AddEntry(s))
1338  free(s);
1339  }
1340  else
1341  break;
1342  }
1343  }
1344  }
1345  break;
1346  case AOT_ENQ: {
1347  dbgprotocol("%d: <== Enq\n", SessionId());
1348  delete m_enquiry;
1349  m_enquiry = new cCiEnquiry(this);
1350  int l = 0;
1351  const uint8_t *d = GetData(Data, l);
1352  if (l > 0) {
1353  uint8_t blind = *d++;
1354  //XXX GetByte()???
1355  l--;
1356  m_enquiry->m_blind = ((blind & EF_BLIND) != 0);
1358  l--;
1359  // I really wonder why there is no text length field here...
1360  m_enquiry->m_text = CopyString(l, d);
1361  }
1362  }
1363  break;
1364  case AOT_CLOSE_MMI: {
1365  int l = 0;
1366  const uint8_t *d = GetData(Data, l);
1367 
1368  if(l > 0){
1369  switch(*d){
1370  case CLOSE_MMI_IMMEDIATE:
1371  dbgprotocol("%d <== Menu Close: immediate\n", SessionId());
1372  break;
1373  case CLOSE_MMI_DELAY:
1374  dbgprotocol("%d <== Menu Close: delay\n", SessionId());
1375  break;
1376  default: esyslog("ERROR: CI MMI: unknown close_mmi_cmd_id %02X", *d);
1377  return false;
1378  }
1379  }
1380 
1381  break;
1382  }
1383  default: esyslog("ERROR: CI MMI: unknown tag %06X", Tag);
1384  return false;
1385  }
1386  }
1387  return true;
1388 }
1389 
1391 {
1392  cCiMenu *m = m_menu;
1393  m_menu = nullptr;
1394  return m;
1395 }
1396 
1398 {
1399  cCiEnquiry *e = m_enquiry;
1400  m_enquiry = nullptr;
1401  return e;
1402 }
1403 
1404 bool cCiMMI::SendMenuAnswer(uint8_t Selection)
1405 {
1406  dbgprotocol("%d: ==> Menu Answ\n", SessionId());
1407  SendData(AOT_MENU_ANSW, 1, &Selection);
1408  //XXX return value of all SendData() calls???
1409  return true;
1410 }
1411 
1412 // Define protocol structure
1413 extern "C" {
1414  struct tAnswer { uint8_t m_id; char m_text[256]; };
1415 }
1416 
1417 bool cCiMMI::SendAnswer(const char *Text)
1418 {
1419  dbgprotocol("%d: ==> Answ\n", SessionId());
1420  tAnswer answer {};
1421  answer.m_id = Text ? AI_ANSWER : AI_CANCEL;
1422  if (Text) {
1423  strncpy(answer.m_text, Text, sizeof(answer.m_text) - 1);
1424  answer.m_text[255] = '\0';
1425  }
1426  SendData(AOT_ANSW, Text ? strlen(Text) + 1 : 1, (uint8_t *)&answer);
1427  //XXX return value of all SendData() calls???
1428  return true;
1429 }
1430 
1431 // --- cCiMenu ---------------------------------------------------------------
1432 
1433 cCiMenu::cCiMenu(cCiMMI *MMI, bool Selectable)
1434 {
1435  m_mmi = MMI;
1437 }
1438 
1440 {
1441  free(m_titleText);
1442  free(m_subTitleText);
1443  free(m_bottomText);
1444  for (int i = 0; i < m_numEntries; i++)
1445  free(m_entries[i]);
1446 }
1447 
1448 bool cCiMenu::AddEntry(char *s)
1449 {
1451  m_entries[m_numEntries++] = s;
1452  return true;
1453  }
1454  return false;
1455 }
1456 
1457 bool cCiMenu::Select(int Index)
1458 {
1459  if (m_mmi && -1 <= Index && Index < m_numEntries)
1460  return m_mmi->SendMenuAnswer(Index + 1);
1461  return false;
1462 }
1463 
1465 {
1466  return Select(-1);
1467 }
1468 
1469 // --- cCiEnquiry ------------------------------------------------------------
1470 
1472 {
1473  free(m_text);
1474 }
1475 
1476 bool cCiEnquiry::Reply(const char *s)
1477 {
1478  return m_mmi ? m_mmi->SendAnswer(s) : false;
1479 }
1480 
1482 {
1483  return Reply(nullptr);
1484 }
1485 
1486 // --- cCiCaPmt --------------------------------------------------------------
1487 
1488 // Ca Pmt Cmd Ids:
1489 
1490 enum CPCI_IDS {
1492  CPCI_OK_MMI = 0x02,
1493  CPCI_QUERY = 0x03,
1495 };
1496 
1497 cCiCaPmt::cCiCaPmt(int ProgramNumber, uint8_t cplm)
1498 {
1499  m_capmt[m_length++] = cplm; // ca_pmt_list_management
1500  m_capmt[m_length++] = (ProgramNumber >> 8) & 0xFF;
1501  m_capmt[m_length++] = ProgramNumber & 0xFF;
1502  m_capmt[m_length++] = 0x01; // version_number, current_next_indicator - apparently vn doesn't matter, but cni must be 1
1503 
1504  // program_info_length
1506  m_capmt[m_length++] = 0x00;
1507  m_capmt[m_length++] = 0x00;
1508 }
1509 
1511 {
1512  if (m_length + 5 > int(sizeof(m_capmt)))
1513  {
1514  esyslog("ERROR: buffer overflow in CA_PMT");
1515  return;
1516  }
1517 
1518  m_capmt[m_length++] = type & 0xFF;
1519  m_capmt[m_length++] = (pid >> 8) & 0xFF;
1520  m_capmt[m_length++] = pid & 0xFF;
1521 
1522  // ES_info_length
1524  m_capmt[m_length++] = 0x00;
1525  m_capmt[m_length++] = 0x00;
1526 }
1527 
1545 void cCiCaPmt::AddCaDescriptor(int ca_system_id, int ca_pid, int data_len,
1546  const uint8_t *data)
1547 {
1548  if (!m_infoLengthPos)
1549  {
1550  esyslog("ERROR: adding CA descriptor without program/stream!");
1551  return;
1552  }
1553 
1554  if (m_length + data_len + 7 > int(sizeof(m_capmt)))
1555  {
1556  esyslog("ERROR: buffer overflow in CA_PMT");
1557  return;
1558  }
1559 
1560  // We are either at start of program descriptors or stream descriptors.
1561  if (m_infoLengthPos + 2 == m_length)
1562  m_capmt[m_length++] = CPCI_OK_DESCRAMBLING; // ca_pmt_cmd_id
1563 
1564  m_capmt[m_length++] = 0x09; // CA descriptor tag
1565  m_capmt[m_length++] = 4 + data_len; // descriptor length
1566 
1567  m_capmt[m_length++] = (ca_system_id >> 8) & 0xFF;
1568  m_capmt[m_length++] = ca_system_id & 0xFF;
1569  m_capmt[m_length++] = (ca_pid >> 8) & 0xFF;
1570  m_capmt[m_length++] = ca_pid & 0xFF;
1571 
1572  if (data_len > 0)
1573  {
1574  memcpy(&m_capmt[m_length], data, data_len);
1575  m_length += data_len;
1576  }
1577 
1578  // update program_info_length/ES_info_length
1579  int l = m_length - m_infoLengthPos - 2;
1580  m_capmt[m_infoLengthPos] = (l >> 8) & 0xFF;
1581  m_capmt[m_infoLengthPos + 1] = l & 0xFF;
1582 }
1583 
1584 // -- cLlCiHandler -------------------------------------------------------------
1585 
1586 cLlCiHandler::cLlCiHandler(int Fd, int NumSlots)
1587 {
1588  m_numSlots = NumSlots;
1589  m_tpl = new cCiTransportLayer(Fd, m_numSlots);
1590  m_fdCa = Fd;
1591 }
1592 
1594 {
1595  cMutexLock MutexLock(&m_mutex);
1596  for (auto & session : m_sessions)
1597  delete session;
1598  delete m_tpl;
1599  close(m_fdCa);
1600 }
1601 
1603 {
1604  int fd_ca = open(FileName, O_RDWR);
1605  if (fd_ca >= 0)
1606  {
1607  ca_caps_t Caps;
1608  if (ioctl(fd_ca, CA_GET_CAP, &Caps) == 0)
1609  {
1610  int NumSlots = Caps.slot_num;
1611  if (NumSlots > 0)
1612  {
1613  if (Caps.slot_type & CA_CI_LINK)
1614  return new cLlCiHandler(fd_ca, NumSlots);
1615  if (Caps.slot_type & CA_CI)
1616  return new cHlCiHandler(fd_ca, NumSlots);
1617  isyslog("CAM doesn't support either high or low level CI,"
1618  " Caps.slot_type=%i", Caps.slot_type);
1619  }
1620  else
1621  esyslog("ERROR: no CAM slots found");
1622  }
1623  else
1624  LOG_ERROR_STR(FileName);
1625  close(fd_ca);
1626  }
1627  return nullptr;
1628 }
1629 
1630 int cLlCiHandler::ResourceIdToInt(const uint8_t *Data)
1631 {
1632  return (ntohl(*(int *)Data));
1633 }
1634 
1635 bool cLlCiHandler::Send(uint8_t Tag, int SessionId, int ResourceId, int Status)
1636 {
1637  std::vector<uint8_t> buffer {Tag, 0x00} ; // 0x00 will be replaced with length
1638  if (Status >= 0)
1639  buffer.push_back(Status);
1640  if (ResourceId) {
1641  buffer.push_back((ResourceId >> 24) & 0xFF);
1642  buffer.push_back((ResourceId >> 16) & 0xFF);
1643  buffer.push_back((ResourceId >> 8) & 0xFF);
1644  buffer.push_back( ResourceId & 0xFF);
1645  }
1646  buffer.push_back((SessionId >> 8) & 0xFF);
1647  buffer.push_back( SessionId & 0xFF);
1648  buffer[1] = buffer.size() - 2; // length
1649  return m_tc && m_tc->SendData(buffer) == OK;
1650 }
1651 
1653 {
1654  for (auto & session : m_sessions) {
1655  if (session && session->SessionId() == SessionId)
1656  return session;
1657  }
1658  return nullptr;
1659 }
1660 
1662 {
1663  for (auto & session : m_sessions) {
1664  if (session && session->Tc()->Slot() == Slot && session->ResourceId() == ResourceId)
1665  return session;
1666  }
1667  return nullptr;
1668 }
1669 
1671 {
1672  if (!GetSessionByResourceId(ResourceId, m_tc->Slot())) {
1673  for (int i = 0; i < MAX_CI_SESSION; i++) {
1674  if (!m_sessions[i]) {
1675  switch (ResourceId) {
1676  case RI_RESOURCE_MANAGER: return m_sessions[i] = new cCiResourceManager(i + 1, m_tc);
1679  return m_sessions[i] = new cCiConditionalAccessSupport(i + 1, m_tc);
1680  case RI_HOST_CONTROL: break; //XXX
1681  case RI_DATE_TIME: return m_sessions[i] = new cCiDateTime(i + 1, m_tc);
1682  case RI_MMI: return m_sessions[i] = new cCiMMI(i + 1, m_tc);
1683  }
1684  }
1685  }
1686  }
1687  return nullptr;
1688 }
1689 
1690 bool cLlCiHandler::OpenSession(int Length, const uint8_t *Data)
1691 {
1692  if (Length == 6 && *(Data + 1) == 0x04) {
1693  int ResourceId = ResourceIdToInt(Data + 2);
1694  dbgprotocol("OpenSession %08X\n", ResourceId);
1695  switch (ResourceId) {
1696  case RI_RESOURCE_MANAGER:
1699  case RI_HOST_CONTROL:
1700  case RI_DATE_TIME:
1701  case RI_MMI:
1702  {
1703  cCiSession *Session = CreateSession(ResourceId);
1704  if (Session)
1705  {
1707  Session->ResourceId(), SS_OK);
1708  return true;
1709  }
1710  esyslog("ERROR: can't create session for resource identifier: %08X",
1711  ResourceId);
1712  break;
1713  }
1714  default: esyslog("ERROR: unknown resource identifier: %08X", ResourceId);
1715  }
1716  }
1717  return false;
1718 }
1719 
1720 bool cLlCiHandler::CloseSession(int SessionId)
1721 {
1722  dbgprotocol("CloseSession %08X\n", SessionId);
1723  cCiSession *Session = GetSessionBySessionId(SessionId);
1724  if (Session && m_sessions[SessionId - 1] == Session) {
1725  delete Session;
1726  m_sessions[SessionId - 1] = nullptr;
1727  Send(ST_CLOSE_SESSION_RESPONSE, SessionId, 0, SS_OK);
1728  return true;
1729  }
1730 
1731  esyslog("ERROR: unknown session id: %d", SessionId);
1733  return false;
1734 }
1735 
1737 {
1738  int result = 0;
1739  for (auto & session : m_sessions) {
1740  if (session && session->Tc()->Slot() == Slot) {
1741  CloseSession(session->SessionId());
1742  result++;
1743  }
1744  }
1745  return result;
1746 }
1747 
1749 {
1750  bool result = true;
1751  cMutexLock MutexLock(&m_mutex);
1752 
1753  for (int Slot = 0; Slot < m_numSlots; Slot++)
1754  {
1755  m_tc = m_tpl->Process(Slot);
1756  if (m_tc)
1757  {
1758  int Length = 0;
1759  const uint8_t *Data = m_tc->Data(Length);
1760  if (Data && Length > 1)
1761  {
1762  switch (*Data)
1763  {
1764  case ST_SESSION_NUMBER:
1765  if (Length > 4)
1766  {
1767  int SessionId = ntohs(*(short *)&Data[2]);
1768  cCiSession *Session = GetSessionBySessionId(SessionId);
1769  if (Session)
1770  {
1771  Session->Process(Length - 4, Data + 4);
1772  if (Session->ResourceId() == RI_APPLICATION_INFORMATION)
1773  {
1774 #if 0
1775  esyslog("Test: %x",
1776  ((cCiApplicationInformation*)Session)->GetApplicationManufacturer());
1777 #endif
1778  }
1779  }
1780  else
1781  esyslog("ERROR: unknown session id: %d", SessionId);
1782  }
1783  break;
1784 
1786  OpenSession(Length, Data);
1787  break;
1788 
1790  if (Length == 4)
1791  CloseSession(ntohs(*(short *)&Data[2]));
1792  break;
1793 
1794  case ST_CREATE_SESSION_RESPONSE: //XXX fall through to default
1795  case ST_CLOSE_SESSION_RESPONSE: //XXX fall through to default
1796  default:
1797  esyslog("ERROR: unknown session tag: %02X", *Data);
1798  }
1799  }
1800  }
1801  else if (CloseAllSessions(Slot))
1802  {
1803  m_tpl->ResetSlot(Slot);
1804  result = false;
1805  }
1806  else if (m_tpl->ModuleReady(Slot))
1807  {
1808  dbgprotocol("Module ready in slot %d\n", Slot);
1809  m_tpl->NewConnection(Slot);
1810  }
1811  }
1812 
1813  bool UserIO = false;
1814  m_needCaPmt = false;
1815  for (auto & session : m_sessions)
1816  {
1817  if (session && session->Process())
1818  {
1819  UserIO |= session->HasUserIO();
1820  if (session->ResourceId() == RI_CONDITIONAL_ACCESS_SUPPORT)
1821  {
1822  auto *cas = dynamic_cast<cCiConditionalAccessSupport *>(session);
1823  if (cas == nullptr)
1824  continue;
1825  m_needCaPmt |= cas->NeedCaPmt();
1826  }
1827  }
1828  }
1829  m_hasUserIO = UserIO;
1830 
1831  if (m_newCaSupport)
1832  m_newCaSupport = result = false; // triggers new SetCaPmt at caller!
1833  return result;
1834 }
1835 
1837 {
1838  cMutexLock MutexLock(&m_mutex);
1840  return api ? api->EnterMenu() : false;
1841 }
1842 
1844 {
1845  cMutexLock MutexLock(&m_mutex);
1846  for (int Slot = 0; Slot < m_numSlots; Slot++) {
1847  auto *mmi = dynamic_cast<cCiMMI *>(GetSessionByResourceId(RI_MMI, Slot));
1848  if (mmi)
1849  return mmi->Menu();
1850  }
1851  return nullptr;
1852 }
1853 
1855 {
1856  cMutexLock MutexLock(&m_mutex);
1857  for (int Slot = 0; Slot < m_numSlots; Slot++) {
1858  auto *mmi = dynamic_cast<cCiMMI *>(GetSessionByResourceId(RI_MMI, Slot));
1859  if (mmi)
1860  return mmi->Enquiry();
1861  }
1862  return nullptr;
1863 }
1864 
1866  {
1867  static dvbca_vector empty {};
1868  cMutexLock MutexLock(&m_mutex);
1870  return cas ? cas->GetCaSystemIds() : empty;
1871 }
1872 
1873 bool cLlCiHandler::SetCaPmt(cCiCaPmt &CaPmt, int Slot)
1874 {
1875  cMutexLock MutexLock(&m_mutex);
1877  return cas && cas->SendPMT(CaPmt);
1878 }
1879 
1880 void cLlCiHandler::SetTimeOffset(double offset_in_seconds)
1881 {
1882  cMutexLock MutexLock(&m_mutex);
1883  cCiDateTime *dt = nullptr;
1884 
1885  for (uint i = 0; i < (uint) NumSlots(); i++)
1886  {
1887  dt = dynamic_cast<cCiDateTime*>(GetSessionByResourceId(RI_DATE_TIME, i));
1888  if (dt)
1889  dt->SetTimeOffset(offset_in_seconds);
1890  }
1891 }
1892 
1893 bool cLlCiHandler::Reset(int Slot)
1894 {
1895  cMutexLock MutexLock(&m_mutex);
1896  CloseAllSessions(Slot);
1897  return m_tpl->ResetSlot(Slot);
1898 }
1899 
1901 {
1902  return sConnected;
1903 }
1904 
1905 // -- cHlCiHandler -------------------------------------------------------------
1906 
1907 cHlCiHandler::cHlCiHandler(int Fd, int NumSlots)
1908 {
1909  m_numSlots = NumSlots;
1910  m_fdCa = Fd;
1911  esyslog("New High level CI handler");
1912 }
1913 
1915 {
1916  cMutexLock MutexLock(&m_mutex);
1917  close(m_fdCa);
1918 }
1919 
1920 int cHlCiHandler::CommHL(unsigned tag, unsigned function, struct ca_msg *msg) const
1921 {
1922  if (tag) {
1923  msg->msg[2] = tag & 0xff;
1924  msg->msg[1] = (tag & 0xff00) >> 8;
1925  msg->msg[0] = (tag & 0xff0000) >> 16;
1926  esyslog("Sending message=[%02x %02x %02x ]",
1927  msg->msg[0], msg->msg[1], msg->msg[2]);
1928  }
1929 
1930  return ioctl(m_fdCa, function, msg);
1931 }
1932 
1933 int cHlCiHandler::GetData(unsigned tag, struct ca_msg *msg)
1934 {
1935  return CommHL(tag, CA_GET_MSG, msg);
1936 }
1937 
1938 int cHlCiHandler::SendData(unsigned tag, struct ca_msg *msg)
1939 {
1940  return CommHL(tag, CA_SEND_MSG, msg);
1941 }
1942 
1944 {
1945  cMutexLock MutexLock(&m_mutex);
1946 
1947  struct ca_msg msg {};
1948  switch(m_state) {
1949  case 0:
1950  // Get CA_system_ids
1951  /* Enquire */
1952  if ((SendData(AOT_CA_INFO_ENQ, &msg)) < 0) {
1953  esyslog("HLCI communication failed");
1954  } else {
1955  dbgprotocol("==> Ca Info Enquiry");
1956  /* Receive */
1957  if ((GetData(AOT_CA_INFO, &msg)) < 0) {
1958  esyslog("HLCI communication failed");
1959  } else {
1960  QString message("Debug: ");
1961  for(int i = 0; i < 20; i++) {
1962  message += QString("%1 ").arg(msg.msg[i]);
1963  }
1964  LOG(VB_GENERAL, LOG_DEBUG, message);
1965  dbgprotocol("<== Ca Info");
1966  int l = msg.msg[3];
1967  const uint8_t *d = &msg.msg[4];
1968  while (l > 1) {
1969  unsigned short id = ((unsigned short)(*d) << 8) | *(d + 1);
1970  dbgprotocol(" %04X", id);
1971  d += 2;
1972  l -= 2;
1973 
1974  // Insert before the last element.
1975  m_caSystemIds.emplace_back(id);
1976  }
1977  dbgprotocol("\n");
1978  }
1979  m_state = 1;
1980  break;
1981  }
1982  }
1983 
1984  bool result = true;
1985 
1986  return result;
1987 }
1988 
1989 bool cHlCiHandler::EnterMenu(int /*Slot*/)
1990 {
1991  return false;
1992 }
1993 
1995 {
1996  return nullptr;
1997 }
1998 
2000 {
2001  return nullptr;
2002 }
2003 
2005 {
2006  return m_caSystemIds;
2007 }
2008 
2009 bool cHlCiHandler::SetCaPmt(cCiCaPmt &CaPmt, int /*Slot*/)
2010 {
2011  cMutexLock MutexLock(&m_mutex);
2012  struct ca_msg msg {};
2013 
2014  esyslog("Setting CA PMT.");
2015  m_state = 2;
2016 
2017  msg.msg[3] = CaPmt.m_length;
2018 
2019  if (CaPmt.m_length > (256 - 4))
2020  {
2021  esyslog("CA message too long");
2022  return false;
2023  }
2024 
2025  memcpy(&msg.msg[4], CaPmt.m_capmt, CaPmt.m_length);
2026 
2027  if ((SendData(AOT_CA_PMT, &msg)) < 0) {
2028  esyslog("HLCI communication failed");
2029  return false;
2030  }
2031 
2032  return true;
2033 }
2034 
2035 bool cHlCiHandler::Reset(int /*Slot*/) const
2036 {
2037  if ((ioctl(m_fdCa, CA_RESET)) < 0) {
2038  esyslog("ioctl CA_RESET failed.");
2039  return false;
2040  }
2041  return true;
2042 }
2043 
2045 {
2046  return m_state == 1;
2047 }
cCiDateTime::m_lastTime
time_t m_lastTime
Definition: dvbci.cpp:1100
cCiConditionalAccessSupport::m_state
int m_state
Definition: dvbci.cpp:1026
cCiConditionalAccessSupport
Definition: dvbci.cpp:1024
cCiApplicationInformation::~cCiApplicationInformation
~cCiApplicationInformation() override
Definition: dvbci.cpp:971
cCiApplicationInformation::GetManufacturerCode
uint16_t GetManufacturerCode() const
Definition: dvbci.cpp:956
cLlCiHandler::SetTimeOffset
void SetTimeOffset(double offset_in_seconds) override
Definition: dvbci.cpp:1880
dvbci.h
AOT_DISPLAY_CONTROL
@ AOT_DISPLAY_CONTROL
Definition: dvbci.cpp:745
cTPDU::cTPDU
cTPDU(void)=default
cLlCiHandler::connected
static bool connected()
Definition: dvbci.cpp:1900
cCiTransportConnection::RecvTPDU
int RecvTPDU(void)
Definition: dvbci.cpp:456
SS_OK
@ SS_OK
Definition: dvbci.cpp:709
RI_CONDITIONAL_ACCESS_SUPPORT
@ RI_CONDITIONAL_ACCESS_SUPPORT
Definition: dvbci.cpp:718
cCiTransportConnection::DataAvailable
bool DataAvailable(void) const
Definition: dvbci.cpp:412
AI_ANSWER
@ AI_ANSWER
Definition: dvbci.cpp:1241
cCiCaPmt::AddCaDescriptor
void AddCaDescriptor(int ca_system_id, int ca_pid, int data_len, const uint8_t *data)
Definition: dvbci.cpp:1545
T_DELETE_TC
@ T_DELETE_TC
Definition: dvbci.cpp:255
DATA_INDICATOR
static constexpr uint8_t DATA_INDICATOR
Definition: dvbci.cpp:248
tAnswer::m_text
char m_text[256]
Definition: dvbci.cpp:1414
AOT_CONNECTION_DESCRIPTOR
@ AOT_CONNECTION_DESCRIPTOR
Definition: dvbci.cpp:769
AOT_SCENE_END_MARK
@ AOT_SCENE_END_MARK
Definition: dvbci.cpp:761
cLlCiHandler::GetSessionBySessionId
cCiSession * GetSessionBySessionId(int SessionId)
Definition: dvbci.cpp:1652
cCiTransportConnection::~cCiTransportConnection
~cCiTransportConnection()
Definition: dvbci.cpp:430
cCiTransportConnection::m_lastResponse
int m_lastResponse
Definition: dvbci.cpp:403
cTPDU
Definition: dvbci.cpp:264
cLlCiHandler::CloseAllSessions
int CloseAllSessions(int Slot)
Definition: dvbci.cpp:1736
cCiSession::GetTag
static int GetTag(int &Length, const uint8_t **Data)
Definition: dvbci.cpp:805
AOT_DISPLAY_MESSAGE
@ AOT_DISPLAY_MESSAGE
Definition: dvbci.cpp:760
cCiConditionalAccessSupport::m_needCaPmt
bool m_needCaPmt
Definition: dvbci.cpp:1028
dvbca_vector
std::vector< uint16_t > dvbca_vector
Definition: dvbci.h:44
stDELETION
@ stDELETION
Definition: dvbci.cpp:392
AOT_CA_PMT_REPLY
@ AOT_CA_PMT_REPLY
Definition: dvbci.cpp:737
stIDLE
@ stIDLE
Definition: dvbci.cpp:392
cCiApplicationInformation::cCiApplicationInformation
cCiApplicationInformation(int SessionId, cCiTransportConnection *Tc)
Definition: dvbci.cpp:959
AOT_TEXT_MORE
@ AOT_TEXT_MORE
Definition: dvbci.cpp:748
cCiTransportConnection::m_slot
uint8_t m_slot
Definition: dvbci.cpp:398
CPCI_OK_DESCRAMBLING
@ CPCI_OK_DESCRAMBLING
Definition: dvbci.cpp:1491
cCiConditionalAccessSupport::m_caSystemIds
dvbca_vector m_caSystemIds
Definition: dvbci.cpp:1027
AOT_APPLICATION_INFO
@ AOT_APPLICATION_INFO
Definition: dvbci.cpp:732
AOT_APPLICATION_INFO_ENQ
@ AOT_APPLICATION_INFO_ENQ
Definition: dvbci.cpp:731
cHlCiHandler::cHlCiHandler
cHlCiHandler(int Fd, int NumSlots)
Definition: dvbci.cpp:1907
cCiMMI
Definition: dvbci.cpp:1244
discid.disc.read
def read(device=None, features=[])
Definition: disc.py:35
cMutex::m_mutex
pthread_mutex_t m_mutex
Definition: dvbci.h:49
cHlCiHandler::SetCaPmt
bool SetCaPmt(cCiCaPmt &CaPmt)
RI_DATE_TIME
@ RI_DATE_TIME
Definition: dvbci.cpp:720
AOT_CA_INFO
@ AOT_CA_INFO
Definition: dvbci.cpp:735
GetString
static char * GetString(int &Length, const uint8_t **Data)
Definition: dvbci.cpp:178
ST_CLOSE_SESSION_REQUEST
@ ST_CLOSE_SESSION_REQUEST
Definition: dvbci.cpp:702
cCiTransportLayer::m_numSlots
int m_numSlots
Definition: dvbci.cpp:599
AOT_SUBTITLE_DOWNLOAD_MORE
@ AOT_SUBTITLE_DOWNLOAD_MORE
Definition: dvbci.cpp:765
AOT_SUBTITLE_SEGMENT_MORE
@ AOT_SUBTITLE_SEGMENT_MORE
Definition: dvbci.cpp:759
cLlCiHandler::NumSlots
int NumSlots(void) override
Definition: dvbci.h:184
cCiTransportConnection::SendData
int SendData(int Length, const uint8_t *Data)
Definition: dvbci.cpp:514
cHlCiHandler::GetData
int GetData(unsigned tag, struct ca_msg *msg)
Definition: dvbci.cpp:1933
ST_OPEN_SESSION_REQUEST
@ ST_OPEN_SESSION_REQUEST
Definition: dvbci.cpp:698
T_DATA_LAST
@ T_DATA_LAST
Definition: dvbci.cpp:260
AOT_ENTER_MENU
@ AOT_ENTER_MENU
Definition: dvbci.cpp:733
cCiMenu::cCiMenu
cCiMenu(cCiMMI *MMI, bool Selectable)
Definition: dvbci.cpp:1433
mythburn.write
def write(text, progress=True)
Definition: mythburn.py:308
cCiCaPmt::m_length
int m_length
Definition: dvbci.h:127
T_DATA_MORE
@ T_DATA_MORE
Definition: dvbci.cpp:261
cCiEnquiry::Cancel
bool Cancel(void)
Definition: dvbci.cpp:1481
cTPDU::Write
int Write(int fd)
Definition: dvbci.cpp:327
cCiTransportConnection::Init
void Init(int Fd, uint8_t Slot, uint8_t Tcid)
Definition: dvbci.cpp:435
LOG_ERROR_STR
#define LOG_ERROR_STR(s)
Definition: dvbci.cpp:57
stACTIVE
@ stACTIVE
Definition: dvbci.cpp:392
DRI_MMI_MODE_ACK
@ DRI_MMI_MODE_ACK
Definition: dvbci.cpp:1223
CPCI_QUERY
@ CPCI_QUERY
Definition: dvbci.cpp:1493
cTPDU::m_data
std::array< uint8_t, MAX_TPDU_SIZE > m_data
Definition: dvbci.cpp:267
AOT_CA_PMT
@ AOT_CA_PMT
Definition: dvbci.cpp:736
T_RCV
@ T_RCV
Definition: dvbci.cpp:252
AOT_MENU_LAST
@ AOT_MENU_LAST
Definition: dvbci.cpp:753
AOT_COMMS_RCV_MORE
@ AOT_COMMS_RCV_MORE
Definition: dvbci.cpp:774
cLlCiHandler::m_tc
cCiTransportConnection * m_tc
Definition: dvbci.h:170
CLOSE_MMI_IMMEDIATE
@ CLOSE_MMI_IMMEDIATE
Definition: dvbci.cpp:1198
AOT_DISPLAY_REPLY
@ AOT_DISPLAY_REPLY
Definition: dvbci.cpp:746
cLlCiHandler::GetEnquiry
cCiEnquiry * GetEnquiry(void) override
Definition: dvbci.cpp:1854
cCiCaPmt
Definition: dvbci.h:123
AOT_DATE_TIME_ENQ
@ AOT_DATE_TIME_ENQ
Definition: dvbci.cpp:742
TIMEOUT
static constexpr int TIMEOUT
Definition: dvbci.cpp:70
cHlCiHandler::SendData
int SendData(unsigned tag, struct ca_msg *msg)
Definition: dvbci.cpp:1938
LOG
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
Definition: mythlogging.h:39
cLlCiHandler::Process
bool Process(void) override
Definition: dvbci.cpp:1748
cMutexLock::~cMutexLock
~cMutexLock()
Definition: dvbci.cpp:224
AOT_REPLACE
@ AOT_REPLACE
Definition: dvbci.cpp:739
ST_OPEN_SESSION_RESPONSE
@ ST_OPEN_SESSION_RESPONSE
Definition: dvbci.cpp:699
sDebugProtocol
static bool sDebugProtocol
Definition: dvbci.cpp:63
AOT_DOWNLOAD_REPLY
@ AOT_DOWNLOAD_REPLY
Definition: dvbci.cpp:767
cCiMenu::m_mmi
cCiMMI * m_mmi
Definition: dvbci.h:76
SESSION_TAGS
SESSION_TAGS
Definition: dvbci.cpp:696
DRI_UNKNOWN_CHARACTER_TABLE
@ DRI_UNKNOWN_CHARACTER_TABLE
Definition: dvbci.cpp:1230
cCiTransportConnection::m_lastPoll
std::chrono::milliseconds m_lastPoll
Definition: dvbci.cpp:402
DCC_OVERLAY_GRAPHICS_CHARACTERISTICS
@ DCC_OVERLAY_GRAPHICS_CHARACTERISTICS
Definition: dvbci.cpp:1208
AOT_COMMS_SEND_MORE
@ AOT_COMMS_SEND_MORE
Definition: dvbci.cpp:772
cCiTransportLayer::m_tc
std::array< cCiTransportConnection, MAX_CI_CONNECT > m_tc
Definition: dvbci.cpp:600
AOT_ANSW
@ AOT_ANSW
Definition: dvbci.cpp:752
cCiEnquiry::Reply
bool Reply(const char *s)
Definition: dvbci.cpp:1476
MM_LOW_LEVEL_OVERLAY_GRAPHICS
@ MM_LOW_LEVEL_OVERLAY_GRAPHICS
Definition: dvbci.cpp:1216
cMutexLock
Definition: dvbci.h:59
cCiTransportLayer::Process
cCiTransportConnection * Process(int Slot)
Definition: dvbci.cpp:653
cHlCiHandler::~cHlCiHandler
~cHlCiHandler() override
Definition: dvbci.cpp:1914
cCiMMI::cCiMMI
cCiMMI(int SessionId, cCiTransportConnection *Tc)
Definition: dvbci.cpp:1260
cCiApplicationInformation::m_applicationManufacturer
uint16_t m_applicationManufacturer
Definition: dvbci.cpp:946
cLlCiHandler::m_mutex
cMutex m_mutex
Definition: dvbci.h:162
DCC_INPUT_CHARACTER_TABLE_LIST
@ DCC_INPUT_CHARACTER_TABLE_LIST
Definition: dvbci.cpp:1207
cCiTransportConnection::m_tcid
uint8_t m_tcid
Definition: dvbci.cpp:399
cCiDateTime::m_timeOffset
int m_timeOffset
Definition: dvbci.cpp:1101
cCiCaPmt::m_capmt
uint8_t m_capmt[2048]
XXX is there a specified maximum?
Definition: dvbci.h:129
EF_BLIND
static constexpr uint8_t EF_BLIND
Definition: dvbci.cpp:1235
cCiResourceManager::Process
bool Process(int Length=0, const uint8_t *Data=nullptr) override
Definition: dvbci.cpp:890
RI_RESOURCE_MANAGER
@ RI_RESOURCE_MANAGER
Definition: dvbci.cpp:716
cHlCiHandler::Process
bool Process(void) override
Definition: dvbci.cpp:1943
close
#define close
Definition: compat.h:43
AOT_DATE_TIME
@ AOT_DATE_TIME
Definition: dvbci.cpp:743
cCiMenu::Selectable
bool Selectable(void) const
Definition: dvbci.h:92
cLlCiHandler::m_numSlots
int m_numSlots
Definition: dvbci.h:164
cLlCiHandler::~cLlCiHandler
~cLlCiHandler() override
Definition: dvbci.cpp:1593
AOT_CLEAR_REPLACE
@ AOT_CLEAR_REPLACE
Definition: dvbci.cpp:740
DRI_LIST_GRAPHIC_OVERLAY_CHARACTERISTICS
@ DRI_LIST_GRAPHIC_OVERLAY_CHARACTERISTICS
Definition: dvbci.cpp:1226
DRI_LIST_INPUT_CHARACTER_TABLES
@ DRI_LIST_INPUT_CHARACTER_TABLES
Definition: dvbci.cpp:1225
AOT_SCENE_DONE
@ AOT_SCENE_DONE
Definition: dvbci.cpp:762
DISPLAY_REPLY_IDS
DISPLAY_REPLY_IDS
Definition: dvbci.cpp:1222
DISPLAY_CONTROL
DISPLAY_CONTROL
Definition: dvbci.cpp:1204
AOT_CA_INFO_ENQ
@ AOT_CA_INFO_ENQ
Definition: dvbci.cpp:734
cCiMenu::m_subTitleText
char * m_subTitleText
Definition: dvbci.h:79
AOT_KEYPAD_CONTROL
@ AOT_KEYPAD_CONTROL
Definition: dvbci.cpp:749
cLlCiHandler::m_sessions
cCiSession * m_sessions[MAX_CI_SESSION]
Definition: dvbci.h:168
T_DTC_REPLY
@ T_DTC_REPLY
Definition: dvbci.cpp:256
cHlCiHandler::m_state
int m_state
Definition: dvbci.h:208
T_CTC_REPLY
@ T_CTC_REPLY
Definition: dvbci.cpp:254
cMutex
Definition: dvbci.h:46
cHlCiHandler::EnterMenu
bool EnterMenu(int Slot) override
Definition: dvbci.cpp:1989
cCiApplicationInformation::m_menuString
char * m_menuString
Definition: dvbci.cpp:948
cMutex::m_locked
int m_locked
Definition: dvbci.h:51
cCiTransportConnection
Definition: dvbci.cpp:394
AOT_COMMS_CMD
@ AOT_COMMS_CMD
Definition: dvbci.cpp:768
cTPDU::Dump
void Dump(bool Outgoing)
Definition: dvbci.cpp:348
AOT_PROFILE_ENQ
@ AOT_PROFILE_ENQ
Definition: dvbci.cpp:728
safe_read
static ssize_t safe_read(int filedes, void *buffer, size_t size)
Definition: dvbci.cpp:83
cCiTransportLayer::ModuleReady
bool ModuleReady(int Slot) const
Definition: dvbci.cpp:643
AOT_FLUSH_DOWNLOAD
@ AOT_FLUSH_DOWNLOAD
Definition: dvbci.cpp:766
mythlogging.h
SetLength
static uint8_t * SetLength(uint8_t *Data, int Length)
Definition: dvbci.cpp:117
cCiSession::~cCiSession
virtual ~cCiSession()=default
cMutexLock::m_locked
bool m_locked
Definition: dvbci.h:62
cCiMMI::SendAnswer
bool SendAnswer(const char *Text)
Definition: dvbci.cpp:1417
T_NEW_TC
@ T_NEW_TC
Definition: dvbci.cpp:258
AOT_CLOSE_MMI
@ AOT_CLOSE_MMI
Definition: dvbci.cpp:744
ST_CREATE_SESSION_RESPONSE
@ ST_CREATE_SESSION_RESPONSE
Definition: dvbci.cpp:701
cCiEnquiry::m_blind
bool m_blind
Definition: dvbci.h:102
cCiHandler::NumSlots
virtual int NumSlots(void)=0
MM_LOW_LEVEL_FULL_SCREEN_GRAPHICS
@ MM_LOW_LEVEL_FULL_SCREEN_GRAPHICS
Definition: dvbci.cpp:1217
MAX_TPDU_DATA
static constexpr int MAX_TPDU_DATA
Definition: dvbci.cpp:246
cLlCiHandler::SetCaPmt
bool SetCaPmt(cCiCaPmt &CaPmt)
stCREATION
@ stCREATION
Definition: dvbci.cpp:392
CLOSE_MMI
CLOSE_MMI
Definition: dvbci.cpp:1197
hardwareprofile.config.p
p
Definition: config.py:33
hardwareprofile.i18n.t
t
Definition: i18n.py:36
cCiSession::SessionId
int SessionId(void) const
Definition: dvbci.cpp:792
cTPDU::Tcid
uint8_t Tcid(void)
Definition: dvbci.cpp:273
cCiEnquiry::~cCiEnquiry
~cCiEnquiry()
Definition: dvbci.cpp:1471
AOT_LIST_LAST
@ AOT_LIST_LAST
Definition: dvbci.cpp:756
cCiResourceManager
Definition: dvbci.cpp:875
SIZE_INDICATOR
static constexpr int SIZE_INDICATOR
Definition: dvbci.cpp:81
cLlCiHandler::GetCaSystemIds
dvbca_vector GetCaSystemIds(int Slot) override
Definition: dvbci.cpp:1865
DCC_DISPLAY_CHARACTER_TABLE_LIST
@ DCC_DISPLAY_CHARACTER_TABLE_LIST
Definition: dvbci.cpp:1206
CPCI_OK_MMI
@ CPCI_OK_MMI
Definition: dvbci.cpp:1492
cLlCiHandler::m_fdCa
int m_fdCa
Definition: dvbci.h:163
AOT_SUBTITLE_DOWNLOAD_LAST
@ AOT_SUBTITLE_DOWNLOAD_LAST
Definition: dvbci.cpp:764
cCiSession::GetData
static const uint8_t * GetData(const uint8_t *Data, int &Length)
Definition: dvbci.cpp:824
AOT_MENU_MORE
@ AOT_MENU_MORE
Definition: dvbci.cpp:754
cCiMenu::Select
bool Select(int Index)
Definition: dvbci.cpp:1457
MAX_CI_SESSION
#define MAX_CI_SESSION
Definition: dvbci.h:137
ST_CLOSE_SESSION_RESPONSE
@ ST_CLOSE_SESSION_RESPONSE
Definition: dvbci.cpp:703
AOT_COMMS_REPLY
@ AOT_COMMS_REPLY
Definition: dvbci.cpp:770
cHlCiHandler
Definition: dvbci.h:202
State
State
Definition: zmserver.h:68
AOT_TEXT_LAST
@ AOT_TEXT_LAST
Definition: dvbci.cpp:747
cCiMenu::m_bottomText
char * m_bottomText
Definition: dvbci.h:80
cCiMenu::m_titleText
char * m_titleText
Definition: dvbci.h:78
tAnswer::m_id
uint8_t m_id
Definition: dvbci.cpp:1414
cCiTransportConnection::SendData
int SendData(std::vector< uint8_t > &Data)
Definition: dvbci.cpp:418
DRI_UNKNOWN_DISPLAY_CONTROL_CMD
@ DRI_UNKNOWN_DISPLAY_CONTROL_CMD
Definition: dvbci.cpp:1228
cCiTransportConnection::Poll
int Poll(void)
Definition: dvbci.cpp:573
cLlCiHandler::Send
bool Send(uint8_t Tag, int SessionId, int ResourceId=0, int Status=-1)
Definition: dvbci.cpp:1635
cMutex::Unlock
void Unlock(void)
Definition: dvbci.cpp:211
cMutexLock::m_mutex
cMutex * m_mutex
Definition: dvbci.h:61
cCiMMI::m_menu
cCiMenu * m_menu
Definition: dvbci.cpp:1247
DCC_SET_MMI_MODE
@ DCC_SET_MMI_MODE
Definition: dvbci.cpp:1205
T_REQUEST_TC
@ T_REQUEST_TC
Definition: dvbci.cpp:257
cLlCiHandler::m_hasUserIO
bool m_hasUserIO
Definition: dvbci.h:166
cCiTransportConnection::m_dataAvailable
bool m_dataAvailable
Definition: dvbci.cpp:404
T_VALUES
T_VALUES
Definition: dvbci.cpp:250
OBJECT_TAG
OBJECT_TAG
Definition: dvbci.cpp:726
cCiConditionalAccessSupport::GetCaSystemIds
dvbca_vector GetCaSystemIds(void)
Definition: dvbci.cpp:1032
AOT_LIST_MORE
@ AOT_LIST_MORE
Definition: dvbci.cpp:757
cLlCiHandler::CloseSession
bool CloseSession(int SessionId)
Definition: dvbci.cpp:1720
cLlCiHandler
Definition: dvbci.h:159
cMutexLock::Lock
bool Lock(cMutex *Mutex)
Definition: dvbci.cpp:230
cCiDateTime::SetTimeOffset
void SetTimeOffset(double offset)
Definition: dvbci.cpp:1115
cMutex::Lock
void Lock(void)
Definition: dvbci.cpp:202
cTPDU::Status
uint8_t Status(void)
Definition: dvbci.cpp:381
CPCI_IDS
CPCI_IDS
Definition: dvbci.cpp:1490
cLlCiHandler::CreateSession
cCiSession * CreateSession(int ResourceId)
Definition: dvbci.cpp:1670
AOT_MENU_ANSW
@ AOT_MENU_ANSW
Definition: dvbci.cpp:755
cCiApplicationInformation::GetApplicationManufacturer
uint16_t GetApplicationManufacturer() const
Definition: dvbci.cpp:955
T_SB
@ T_SB
Definition: dvbci.cpp:251
cCiTransportLayer
Definition: dvbci.cpp:596
cCiSession::cCiSession
cCiSession(int SessionId, int ResourceId, cCiTransportConnection *Tc)
Definition: dvbci.cpp:798
cCiTransportConnection::Data
const uint8_t * Data(int &Length)
Definition: dvbci.cpp:538
cCiMenu::~cCiMenu
~cCiMenu()
Definition: dvbci.cpp:1439
cCiApplicationInformation::GetApplicationString
char * GetApplicationString()
Definition: dvbci.cpp:954
IDENTIFIERS
IDENTIFIERS
Definition: dvbci.cpp:715
MAX_CI_CONNECT
static constexpr size_t MAX_CI_CONNECT
Definition: dvbci.cpp:594
cHlCiHandler::m_caSystemIds
dvbca_vector m_caSystemIds
Definition: dvbci.h:210
RI_HOST_CONTROL
@ RI_HOST_CONTROL
Definition: dvbci.cpp:719
cCiSession::Process
virtual bool Process(int Length=0, const uint8_t *Data=nullptr)
Definition: dvbci.cpp:867
uint
unsigned int uint
Definition: compat.h:81
cTPDU::m_size
ssize_t m_size
Definition: dvbci.cpp:266
cCiResourceManager::cCiResourceManager
cCiResourceManager(int SessionId, cCiTransportConnection *Tc)
Definition: dvbci.cpp:883
cCiSession::Tc
const cCiTransportConnection * Tc(void)
Definition: dvbci.cpp:791
cCiMenu::m_entries
char * m_entries[MAX_CIMENU_ENTRIES]
Definition: dvbci.h:81
CLOSE_MMI_DELAY
@ CLOSE_MMI_DELAY
Definition: dvbci.cpp:1199
cCiApplicationInformation::m_manufacturerCode
uint16_t m_manufacturerCode
Definition: dvbci.cpp:947
SS_NOT_ALLOCATED
@ SS_NOT_ALLOCATED
Definition: dvbci.cpp:710
cTPDU::Tag
uint8_t Tag(void)
Definition: dvbci.cpp:274
DEC2BCD
static constexpr uint8_t DEC2BCD(uint8_t d)
Definition: dvbci.cpp:1121
cHlCiHandler::Reset
bool Reset(int Slot) const
Definition: dvbci.cpp:2035
DRI_LIST_DISPLAY_CHARACTER_TABLES
@ DRI_LIST_DISPLAY_CHARACTER_TABLES
Definition: dvbci.cpp:1224
cCiConditionalAccessSupport::SendPMT
bool SendPMT(const cCiCaPmt &CaPmt)
Definition: dvbci.cpp:1085
cHlCiHandler::CommHL
int CommHL(unsigned tag, unsigned function, struct ca_msg *msg) const
Definition: dvbci.cpp:1920
cHlCiHandler::NumSlots
int NumSlots(void) override
Definition: dvbci.h:217
AOT_PROFILE
@ AOT_PROFILE
Definition: dvbci.cpp:729
cCiTransportLayer::ResetSlot
bool ResetSlot(int Slot) const
Definition: dvbci.cpp:631
WRKRND_TIME_BEFORE_ENTER_MENU
static constexpr time_t WRKRND_TIME_BEFORE_ENTER_MENU
Definition: dvbci.cpp:77
MAX_TPDU_SIZE
static constexpr size_t MAX_TPDU_SIZE
Definition: dvbci.cpp:245
cCiConditionalAccessSupport::Process
bool Process(int Length=0, const uint8_t *Data=nullptr) override
Definition: dvbci.cpp:1044
cCiMMI::HasUserIO
bool HasUserIO(void) override
Definition: dvbci.cpp:1253
CPCI_NOT_SELECTED
@ CPCI_NOT_SELECTED
Definition: dvbci.cpp:1494
cCiApplicationInformation::Process
bool Process(int Length=0, const uint8_t *Data=nullptr) override
Definition: dvbci.cpp:976
dsyslog
#define dsyslog(a...)
Definition: dvbci.cpp:54
cCiApplicationInformation::EnterMenu
bool EnterMenu(void)
Definition: dvbci.cpp:1012
cCiMenu::m_selectable
bool m_selectable
Definition: dvbci.h:77
AI_CANCEL
@ AI_CANCEL
Definition: dvbci.cpp:1240
SESSION_STATUS
SESSION_STATUS
Definition: dvbci.cpp:708
T_CREATE_TC
@ T_CREATE_TC
Definition: dvbci.cpp:253
cHlCiHandler::m_fdCa
int m_fdCa
Definition: dvbci.h:206
cHlCiHandler::m_numSlots
int m_numSlots
Definition: dvbci.h:207
esyslog
#define esyslog(a...)
Definition: dvbci.cpp:52
T_TC_ERROR
@ T_TC_ERROR
Definition: dvbci.cpp:259
cTPDU::Slot
uint8_t Slot(void)
Definition: dvbci.cpp:272
cCiSession::SendData
int SendData(int Tag, std::vector< uint8_t > &Data)
Definition: dvbci.cpp:786
RI_APPLICATION_INFORMATION
@ RI_APPLICATION_INFORMATION
Definition: dvbci.cpp:717
sConnected
static bool sConnected
Definition: dvbci.cpp:64
cCiMMI::SendMenuAnswer
bool SendMenuAnswer(uint8_t Selection)
Definition: dvbci.cpp:1404
cCiApplicationInformation
Definition: dvbci.cpp:941
cCiSession
Definition: dvbci.cpp:777
cLlCiHandler::m_tpl
cCiTransportLayer * m_tpl
Definition: dvbci.h:169
MM_HIGH_LEVEL
@ MM_HIGH_LEVEL
Definition: dvbci.cpp:1215
cCiTransportConnection::m_state
eState m_state
Definition: dvbci.cpp:400
cCiMMI::~cCiMMI
~cCiMMI() override
Definition: dvbci.cpp:1268
cHlCiHandler::GetCaSystemIds
dvbca_vector GetCaSystemIds(int Slot) override
Definition: dvbci.cpp:2004
cCiTransportConnection::Slot
int Slot(void) const
Definition: dvbci.cpp:416
DRI_LIST_FULL_SCREEN_GRAPHIC_CHARACTERISTICS
@ DRI_LIST_FULL_SCREEN_GRAPHIC_CHARACTERISTICS
Definition: dvbci.cpp:1227
cCiDateTime::Process
bool Process(int Length=0, const uint8_t *Data=nullptr) override
Definition: dvbci.cpp:1166
cMutex::m_lockingPid
pid_t m_lockingPid
Definition: dvbci.h:50
MMI_MODES
MMI_MODES
Definition: dvbci.cpp:1214
DRI_UNKNOWN_MMI_MODE
@ DRI_UNKNOWN_MMI_MODE
Definition: dvbci.cpp:1229
cCiMMI::m_enquiry
cCiEnquiry * m_enquiry
Definition: dvbci.cpp:1248
dbgprotocol
#define dbgprotocol(a...)
Definition: dvbci.cpp:67
eState
eState
Definition: dvbci.cpp:392
cCiEnquiry::m_mmi
cCiMMI * m_mmi
Definition: dvbci.h:100
cCiTransportLayer::NewConnection
cCiTransportConnection * NewConnection(int Slot)
Definition: dvbci.cpp:617
cCiMenu::MAX_CIMENU_ENTRIES
@ MAX_CIMENU_ENTRIES
Definition: dvbci.h:75
cCiTransportConnection::cCiTransportConnection
cCiTransportConnection(void)
Definition: dvbci.cpp:425
cTPDU::GetData
const uint8_t * GetData(const uint8_t *Data, int &Length) const
Definition: dvbci.cpp:369
AOT_PROFILE_CHANGE
@ AOT_PROFILE_CHANGE
Definition: dvbci.cpp:730
cCiDateTime
Definition: dvbci.cpp:1097
AOT_ASK_RELEASE
@ AOT_ASK_RELEASE
Definition: dvbci.cpp:741
cCiTransportConnection::LastResponse
int LastResponse(void) const
Definition: dvbci.cpp:411
cCiTransportLayer::m_fd
int m_fd
Definition: dvbci.cpp:598
cLlCiHandler::cLlCiHandler
cLlCiHandler(int Fd, int NumSlots)
Definition: dvbci.cpp:1586
cCiTransportLayer::cCiTransportLayer
cCiTransportLayer(int Fd, int NumSlots)
Definition: dvbci.cpp:609
POLL_INTERVAL
static constexpr std::chrono::milliseconds POLL_INTERVAL
Definition: dvbci.cpp:571
cCiMMI::GetText
char * GetText(int &Length, const uint8_t **Data)
Definition: dvbci.cpp:1274
cTPDU::Data
const uint8_t * Data(int &Length)
Definition: dvbci.cpp:275
cHlCiHandler::NeedCaPmt
bool NeedCaPmt(void) override
Definition: dvbci.cpp:2044
OK
static constexpr int OK
Definition: dvbci.cpp:69
BYTE1
static constexpr uint8_t BYTE1(uint16_t a)
Definition: dvbci.cpp:1125
cCiSession::m_tc
cCiTransportConnection * m_tc
Definition: dvbci.cpp:781
cCiEnquiry::m_text
char * m_text
Definition: dvbci.h:101
cLlCiHandler::Reset
bool Reset(int Slot)
Definition: dvbci.cpp:1893
cLlCiHandler::m_needCaPmt
bool m_needCaPmt
Definition: dvbci.h:167
cLlCiHandler::EnterMenu
bool EnterMenu(int Slot) override
Definition: dvbci.cpp:1836
cLlCiHandler::ResourceIdToInt
static int ResourceIdToInt(const uint8_t *Data)
Definition: dvbci.cpp:1630
sDumpTPDUDataTransfer
static bool sDumpTPDUDataTransfer
Definition: dvbci.cpp:62
CopyString
static char * CopyString(int Length, const uint8_t *Data)
Definition: dvbci.cpp:166
AOT_COMMS_RCV_LAST
@ AOT_COMMS_RCV_LAST
Definition: dvbci.cpp:773
cCiHandler::CreateCiHandler
static cCiHandler * CreateCiHandler(const char *FileName)
Definition: dvbci.cpp:1602
DCC_FULL_SCREEN_GRAPHICS_CHARACTERISTICS
@ DCC_FULL_SCREEN_GRAPHICS_CHARACTERISTICS
Definition: dvbci.cpp:1209
GetLength
static const uint8_t * GetLength(const uint8_t *Data, int &Length)
Definition: dvbci.cpp:95
uint16_t
unsigned short uint16_t
Definition: iso6937tables.h:3
cCiApplicationInformation::m_state
int m_state
Definition: dvbci.cpp:943
cCiMenu
Definition: dvbci.h:72
cCiSession::m_resourceId
int m_resourceId
Definition: dvbci.cpp:780
cTPDU::Read
int Read(int fd)
Definition: dvbci.cpp:336
tAnswer
Definition: dvbci.cpp:1414
cCiEnquiry
Definition: dvbci.h:97
cCiSession::HasUserIO
virtual bool HasUserIO(void)
Definition: dvbci.cpp:794
cCiDateTime::SendDateTime
bool SendDateTime(void)
Definition: dvbci.cpp:1128
AOT_SCENE_CONTROL
@ AOT_SCENE_CONTROL
Definition: dvbci.cpp:763
cCiSession::m_sessionId
int m_sessionId
Definition: dvbci.cpp:779
cHlCiHandler::m_mutex
cMutex m_mutex
Definition: dvbci.h:205
AOT_NONE
@ AOT_NONE
Definition: dvbci.cpp:727
cCiResourceManager::m_state
int m_state
Definition: dvbci.cpp:877
ST_SESSION_NUMBER
@ ST_SESSION_NUMBER
Definition: dvbci.cpp:697
d
static const iso6937table * d
Definition: iso6937tables.cpp:1025
cCiCaPmt::m_infoLengthPos
int m_infoLengthPos
Definition: dvbci.h:128
AOT_TUNE
@ AOT_TUNE
Definition: dvbci.cpp:738
cCiTransportConnection::State
eState State(void)
Definition: dvbci.cpp:410
MAX_CONNECT_RETRIES
static constexpr int8_t MAX_CONNECT_RETRIES
Definition: dvbci.cpp:543
cCiTransportConnection::CreateConnection
int CreateConnection(void)
Definition: dvbci.cpp:545
cCiApplicationInformation::m_applicationType
uint8_t m_applicationType
Definition: dvbci.cpp:945
cLlCiHandler::GetSessionByResourceId
cCiSession * GetSessionByResourceId(int ResourceId, int Slot)
Definition: dvbci.cpp:1661
cCiConditionalAccessSupport::cCiConditionalAccessSupport
cCiConditionalAccessSupport(int SessionId, cCiTransportConnection *Tc)
Definition: dvbci.cpp:1037
RI_MMI
@ RI_MMI
Definition: dvbci.cpp:721
cCiTransportConnection::m_fd
int m_fd
Definition: dvbci.cpp:397
cCiCaPmt::cCiCaPmt
cCiCaPmt(int ProgramNumber, uint8_t cplm=CPLM_ONLY)
Definition: dvbci.cpp:1497
cCiMMI::Menu
cCiMenu * Menu(void)
Definition: dvbci.cpp:1390
AOT_SUBTITLE_SEGMENT_LAST
@ AOT_SUBTITLE_SEGMENT_LAST
Definition: dvbci.cpp:758
cCiConditionalAccessSupport::NeedCaPmt
bool NeedCaPmt(void) const
Definition: dvbci.cpp:1034
ST_CREATE_SESSION
@ ST_CREATE_SESSION
Definition: dvbci.cpp:700
D
#define D(i, j)
cCiTransportConnection::m_tpdu
cTPDU * m_tpdu
Definition: dvbci.cpp:401
cLlCiHandler::GetMenu
cCiMenu * GetMenu(void) override
Definition: dvbci.cpp:1843
cLlCiHandler::m_newCaSupport
bool m_newCaSupport
Definition: dvbci.h:165
cCiTransportConnection::RecvData
int RecvData(void)
Definition: dvbci.cpp:531
cCiSession::ResourceId
int ResourceId(void) const
Definition: dvbci.cpp:793
AOT_COMMS_SEND_LAST
@ AOT_COMMS_SEND_LAST
Definition: dvbci.cpp:771
cCiEnquiry::m_expectedLength
int m_expectedLength
Definition: dvbci.h:103
cCiDateTime::m_interval
int m_interval
Definition: dvbci.cpp:1099
cCiHandler
Definition: dvbci.h:143
cCiMenu::AddEntry
bool AddEntry(char *s)
Definition: dvbci.cpp:1448
BYTE0
static constexpr uint8_t BYTE0(uint16_t a)
Definition: dvbci.cpp:1123
cCiTransportConnection::SendTPDU
int SendTPDU(uint8_t Tag, int Length=0, const uint8_t *Data=nullptr) const
Definition: dvbci.cpp:448
cCiApplicationInformation::m_creationTime
time_t m_creationTime
Definition: dvbci.cpp:944
AOT_ENQ
@ AOT_ENQ
Definition: dvbci.cpp:751
cCiMMI::Process
bool Process(int Length=0, const uint8_t *Data=nullptr) override
Definition: dvbci.cpp:1293
isyslog
#define isyslog(a...)
Definition: dvbci.cpp:53
cCiSession::SendData
int SendData(int Tag, int Length=0, const uint8_t *Data=nullptr)
Definition: dvbci.cpp:830
find
static pid_list_t::iterator find(const PIDInfoMap &map, pid_list_t &list, pid_list_t::iterator begin, pid_list_t::iterator end, bool find_open)
Definition: dvbstreamhandler.cpp:363
CAM_READ_TIMEOUT
static constexpr int CAM_READ_TIMEOUT
Definition: dvbci.cpp:454
cCiMenu::m_numEntries
int m_numEntries
Definition: dvbci.h:82
AOT_KEYPRESS
@ AOT_KEYPRESS
Definition: dvbci.cpp:750
cLlCiHandler::OpenSession
bool OpenSession(int Length, const uint8_t *Data)
Definition: dvbci.cpp:1690
cCiMenu::Cancel
bool Cancel(void)
Definition: dvbci.cpp:1464
cCiMMI::Enquiry
cCiEnquiry * Enquiry(void)
Definition: dvbci.cpp:1397
cHlCiHandler::GetMenu
cCiMenu * GetMenu(void) override
Definition: dvbci.cpp:1994
cHlCiHandler::GetEnquiry
cCiEnquiry * GetEnquiry(void) override
Definition: dvbci.cpp:1999
ERROR
static constexpr int ERROR
Definition: dvbci.cpp:71
ANSWER_IDS
ANSWER_IDS
Definition: dvbci.cpp:1239
cCiCaPmt::AddElementaryStream
void AddElementaryStream(int type, int pid)
Definition: dvbci.cpp:1510
cCiDateTime::cCiDateTime
cCiDateTime(int SessionId, cCiTransportConnection *Tc)
Definition: dvbci.cpp:1109