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(int Length, const uint8_t *Data)
868 {
869  (void)Length;
870  (void)Data;
871  return true;
872 }
873 
874 // -- cCiResourceManager -----------------------------------------------------
875 
877 private:
878  int m_state;
879 public:
881  bool Process(int Length = 0, const uint8_t *Data = nullptr) override; // cCiSession
882  };
883 
885 :cCiSession(SessionId, RI_RESOURCE_MANAGER, Tc)
886 {
887  dbgprotocol("New Resource Manager (session id %d)\n", SessionId);
888  m_state = 0;
889 }
890 
891 bool cCiResourceManager::Process(int Length, const uint8_t *Data)
892 {
893  if (Data) {
894  int Tag = GetTag(Length, &Data);
895  switch (Tag) {
896  case AOT_PROFILE_ENQ: {
897  dbgprotocol("%d: <== Profile Enquiry\n", SessionId());
898  const std::array<const uint32_t,5> resources
899  {
900  htonl(RI_RESOURCE_MANAGER),
903  htonl(RI_DATE_TIME),
904  htonl(RI_MMI)
905  };
906  dbgprotocol("%d: ==> Profile\n", SessionId());
907  SendData(AOT_PROFILE, resources.size() * sizeof(uint32_t),
908  reinterpret_cast<const uint8_t*>(resources.data()));
909  m_state = 3;
910  }
911  break;
912  case AOT_PROFILE: {
913  dbgprotocol("%d: <== Profile\n", SessionId());
914  if (m_state == 1) {
915  int l = 0;
916  const uint8_t *d = GetData(Data, l);
917  if (l > 0 && d)
918  esyslog("CI resource manager: unexpected data");
919  dbgprotocol("%d: ==> Profile Change\n", SessionId());
921  m_state = 2;
922  }
923  else {
924  esyslog("ERROR: CI resource manager: unexpected tag %06X in state %d", Tag, m_state);
925  }
926  }
927  break;
928  default: esyslog("ERROR: CI resource manager: unknown tag %06X", Tag);
929  return false;
930  }
931  }
932  else if (m_state == 0) {
933  dbgprotocol("%d: ==> Profile Enq\n", SessionId());
935  m_state = 1;
936  }
937  return true;
938 }
939 
940 // --- cCiApplicationInformation ---------------------------------------------
941 
943 private:
944  int m_state;
950 public:
952  ~cCiApplicationInformation() override;
953  bool Process(int Length = 0, const uint8_t *Data = nullptr) override; // cCiSession
954  bool EnterMenu(void);
955  char *GetApplicationString() { return strdup(m_menuString); };
958  };
959 
961 :cCiSession(SessionId, RI_APPLICATION_INFORMATION, Tc)
962 {
963  dbgprotocol("New Application Information (session id %d)\n", SessionId);
964  m_state = 0;
965  m_creationTime = time(nullptr);
966  m_applicationType = 0;
968  m_manufacturerCode = 0;
969  m_menuString = nullptr;
970 }
971 
973 {
974  free(m_menuString);
975 }
976 
977 bool cCiApplicationInformation::Process(int Length, const uint8_t *Data)
978 {
979  if (Data) {
980  int Tag = GetTag(Length, &Data);
981  switch (Tag) {
982  case AOT_APPLICATION_INFO: {
983  dbgprotocol("%d: <== Application Info\n", SessionId());
984  int l = 0;
985  const uint8_t *d = GetData(Data, l);
986  if ((l -= 1) < 0) break;
987  m_applicationType = *d++;
988  if ((l -= 2) < 0) break;
989  m_applicationManufacturer = ntohs(*(uint16_t *)d);
990  d += 2;
991  if ((l -= 2) < 0) break;
992  m_manufacturerCode = ntohs(*(uint16_t *)d);
993  d += 2;
994  free(m_menuString);
995  m_menuString = GetString(l, &d);
996  isyslog("CAM: %s, %02X, %04X, %04X", m_menuString, m_applicationType,
998  }
999  m_state = 2;
1000  break;
1001  default: esyslog("ERROR: CI application information: unknown tag %06X", Tag);
1002  return false;
1003  }
1004  }
1005  else if (m_state == 0) {
1006  dbgprotocol("%d: ==> Application Info Enq\n", SessionId());
1008  m_state = 1;
1009  }
1010  return true;
1011 }
1012 
1014 {
1015  if (m_state == 2 && time(nullptr) - m_creationTime > WRKRND_TIME_BEFORE_ENTER_MENU) {
1016  dbgprotocol("%d: ==> Enter Menu\n", SessionId());
1018  return true;//XXX
1019  }
1020  return false;
1021 }
1022 
1023 // --- cCiConditionalAccessSupport -------------------------------------------
1024 
1026 private:
1027  int m_state {0};
1029  bool m_needCaPmt {false};
1030 public:
1032  bool Process(int Length = 0, const uint8_t *Data = nullptr) override; // cCiSession
1034  bool SendPMT(const cCiCaPmt &CaPmt);
1035  bool NeedCaPmt(void) const { return m_needCaPmt; }
1036  };
1037 
1039  int SessionId, cCiTransportConnection *Tc) :
1041 {
1042  dbgprotocol("New Conditional Access Support (session id %d)\n", SessionId);
1043 }
1044 
1045 bool cCiConditionalAccessSupport::Process(int Length, const uint8_t *Data)
1046 {
1047  if (Data) {
1048  int Tag = GetTag(Length, &Data);
1049  switch (Tag) {
1050  case AOT_CA_INFO: {
1051  dbgprotocol("%d: <== Ca Info", SessionId());
1052  int l = 0;
1053  const uint8_t *d = GetData(Data, l);
1054  while (l > 1) {
1055  unsigned short id = ((unsigned short)(*d) << 8) | *(d + 1);
1056  dbgprotocol(" %04X", id);
1057  d += 2;
1058  l -= 2;
1059 
1060  // Make sure the id is not already present
1061  if (std::find(m_caSystemIds.cbegin(), m_caSystemIds.cend(), id)
1062  != m_caSystemIds.end())
1063  continue;
1064 
1065  // Insert before the last element.
1066  m_caSystemIds.emplace_back(id);
1067  }
1068 
1069  dbgprotocol("\n");
1070  }
1071  m_state = 2;
1072  m_needCaPmt = true;
1073  break;
1074  default: esyslog("ERROR: CI conditional access support: unknown tag %06X", Tag);
1075  return false;
1076  }
1077  }
1078  else if (m_state == 0) {
1079  dbgprotocol("%d: ==> Ca Info Enq\n", SessionId());
1081  m_state = 1;
1082  }
1083  return true;
1084 }
1085 
1087 {
1088  if (m_state == 2) {
1089  SendData(AOT_CA_PMT, CaPmt.m_length, CaPmt.m_capmt);
1090  m_needCaPmt = false;
1091  return true;
1092  }
1093  return false;
1094 }
1095 
1096 // --- cCiDateTime -----------------------------------------------------------
1097 
1098 class cCiDateTime : public cCiSession {
1099 private:
1100  int m_interval { 0 };
1101  time_t m_lastTime { 0 };
1102  int m_timeOffset { 0 };
1103  bool SendDateTime(void);
1104 public:
1106  bool Process(int Length = 0, const uint8_t *Data = nullptr) override; // cCiSession
1107  void SetTimeOffset(double offset);
1108  };
1109 
1111 :cCiSession(SessionId, RI_DATE_TIME, Tc)
1112 {
1113  dbgprotocol("New Date Time (session id %d)\n", SessionId);
1114 }
1115 
1116 void cCiDateTime::SetTimeOffset(double offset)
1117 {
1118  m_timeOffset = (int) offset;
1119  dbgprotocol("New Time Offset: %i secs\n", m_timeOffset);
1120 }
1121 
1122 static constexpr uint8_t DEC2BCD(uint8_t d)
1123  { return ((d / 10) << 4) + (d % 10); }
1124 static constexpr uint8_t BYTE0(uint16_t a)
1125  { return static_cast<uint8_t>(a & 0xFF); }
1126 static constexpr uint8_t BYTE1(uint16_t a)
1127  { return static_cast<uint8_t>((a >> 8) & 0xFF); }
1128 
1130 {
1131  time_t t = time(nullptr);
1132  struct tm tm_gmt {};
1133  struct tm tm_loc {};
1134 
1135  // Avoid using signed time_t types
1136  if (m_timeOffset < 0)
1137  t -= (time_t)(-m_timeOffset);
1138  else
1139  t += (time_t)(m_timeOffset);
1140 
1141  if (gmtime_r(&t, &tm_gmt) && localtime_r(&t, &tm_loc)) {
1142  int Y = tm_gmt.tm_year;
1143  int M = tm_gmt.tm_mon + 1;
1144  int D = tm_gmt.tm_mday;
1145  int L = (M == 1 || M == 2) ? 1 : 0;
1146  int MJD = 14956 + D + int((Y - L) * 365.25) + int((M + 1 + L * 12) * 30.6001);
1147  uint16_t mjd = htons(MJD);
1148  int16_t local_offset = htons(tm_loc.tm_gmtoff / 60);
1149  std::vector<uint8_t> T {
1150  BYTE0(mjd),
1151  BYTE1(mjd),
1152  DEC2BCD(tm_gmt.tm_hour),
1153  DEC2BCD(tm_gmt.tm_min),
1154  DEC2BCD(tm_gmt.tm_sec),
1155  BYTE0(local_offset),
1156  BYTE1(local_offset)
1157  };
1158 
1159  dbgprotocol("%d: ==> Date Time\n", SessionId());
1160  SendData(AOT_DATE_TIME, T);
1161  //XXX return value of all SendData() calls???
1162  return true;
1163  }
1164  return false;
1165 }
1166 
1167 bool cCiDateTime::Process(int Length, const uint8_t *Data)
1168 {
1169  if (Data) {
1170  int Tag = GetTag(Length, &Data);
1171  switch (Tag) {
1172  case AOT_DATE_TIME_ENQ: {
1173  m_interval = 0;
1174  int l = 0;
1175  const uint8_t *d = GetData(Data, l);
1176  if (l > 0)
1177  m_interval = *d;
1178  dbgprotocol("%d: <== Date Time Enq, interval = %d\n", SessionId(), m_interval);
1179  m_lastTime = time(nullptr);
1180  return SendDateTime();
1181  }
1182  break;
1183  default: esyslog("ERROR: CI date time: unknown tag %06X", Tag);
1184  return false;
1185  }
1186  }
1187  else if (m_interval && time(nullptr) - m_lastTime > m_interval) {
1188  m_lastTime = time(nullptr);
1189  return SendDateTime();
1190  }
1191  return true;
1192 }
1193 
1194 // --- cCiMMI ----------------------------------------------------------------
1195 
1196 // Close MMI Commands:
1197 
1201 };
1202 
1203 // Display Control Commands:
1204 
1211 };
1212 
1213 // MMI Modes:
1214 
1219 };
1220 
1221 // Display Reply IDs:
1222 
1232 };
1233 
1234 // Enquiry Flags:
1235 
1236 static constexpr uint8_t EF_BLIND { 0x01 };
1237 
1238 // Answer IDs:
1239 
1241  AI_CANCEL = 0x00,
1242  AI_ANSWER = 0x01,
1243 };
1244 
1245 class cCiMMI : public cCiSession {
1246 private:
1247  char *GetText(int &Length, const uint8_t **Data);
1250 public:
1252  ~cCiMMI() override;
1253  bool Process(int Length = 0, const uint8_t *Data = nullptr) override; // cCiSession
1254  bool HasUserIO(void) override { return m_menu || m_enquiry; } // cCiSession
1255  cCiMenu *Menu(void);
1256  cCiEnquiry *Enquiry(void);
1257  bool SendMenuAnswer(uint8_t Selection);
1258  bool SendAnswer(const char *Text);
1259  };
1260 
1262 :cCiSession(SessionId, RI_MMI, Tc)
1263 {
1264  dbgprotocol("New MMI (session id %d)\n", SessionId);
1265  m_menu = nullptr;
1266  m_enquiry = nullptr;
1267 }
1268 
1270 {
1271  delete m_menu;
1272  delete m_enquiry;
1273 }
1274 
1275 char *cCiMMI::GetText(int &Length, const uint8_t **Data)
1283 {
1284  int Tag = GetTag(Length, Data);
1285  if (Tag == AOT_TEXT_LAST) {
1286  char *s = GetString(Length, Data);
1287  dbgprotocol("%d: <== Text Last '%s'\n", SessionId(), s);
1288  return s;
1289  }
1290  esyslog("CI MMI: unexpected text tag: %06X", Tag);
1291  return nullptr;
1292 }
1293 
1294 bool cCiMMI::Process(int Length, const uint8_t *Data)
1295 {
1296  if (Data) {
1297  int Tag = GetTag(Length, &Data);
1298  switch (Tag) {
1299  case AOT_DISPLAY_CONTROL: {
1300  dbgprotocol("%d: <== Display Control\n", SessionId());
1301  int l = 0;
1302  const uint8_t *d = GetData(Data, l);
1303  if (l > 0) {
1304  switch (*d) {
1305  case DCC_SET_MMI_MODE:
1306  if (l == 2 && *++d == MM_HIGH_LEVEL) {
1307  struct tDisplayReply { uint8_t m_id; uint8_t m_mode; };
1308  tDisplayReply dr {};
1309  dr.m_id = DRI_MMI_MODE_ACK;
1310  dr.m_mode = MM_HIGH_LEVEL;
1311  dbgprotocol("%d: ==> Display Reply\n", SessionId());
1312  SendData(AOT_DISPLAY_REPLY, 2, (uint8_t *)&dr);
1313  }
1314  break;
1315  default: esyslog("CI MMI: unsupported display control command %02X", *d);
1316  return false;
1317  }
1318  }
1319  }
1320  break;
1321  case AOT_LIST_LAST:
1322  case AOT_MENU_LAST: {
1323  dbgprotocol("%d: <== Menu Last\n", SessionId());
1324  delete m_menu;
1325  m_menu = new cCiMenu(this, Tag == AOT_MENU_LAST);
1326  int l = 0;
1327  const uint8_t *d = GetData(Data, l);
1328  if (l > 0) {
1329  // since the specification allows choiceNb to be undefined it is useless, so let's just skip it:
1330  d++;
1331  l--;
1332  if (l > 0) m_menu->m_titleText = GetText(l, &d);
1333  if (l > 0) m_menu->m_subTitleText = GetText(l, &d);
1334  if (l > 0) m_menu->m_bottomText = GetText(l, &d);
1335  while (l > 0) {
1336  char *s = GetText(l, &d);
1337  if (s) {
1338  if (!m_menu->AddEntry(s))
1339  free(s);
1340  }
1341  else
1342  break;
1343  }
1344  }
1345  }
1346  break;
1347  case AOT_ENQ: {
1348  dbgprotocol("%d: <== Enq\n", SessionId());
1349  delete m_enquiry;
1350  m_enquiry = new cCiEnquiry(this);
1351  int l = 0;
1352  const uint8_t *d = GetData(Data, l);
1353  if (l > 0) {
1354  uint8_t blind = *d++;
1355  //XXX GetByte()???
1356  l--;
1357  m_enquiry->m_blind = ((blind & EF_BLIND) != 0);
1359  l--;
1360  // I really wonder why there is no text length field here...
1361  m_enquiry->m_text = CopyString(l, d);
1362  }
1363  }
1364  break;
1365  case AOT_CLOSE_MMI: {
1366  int l = 0;
1367  const uint8_t *d = GetData(Data, l);
1368 
1369  if(l > 0){
1370  switch(*d){
1371  case CLOSE_MMI_IMMEDIATE:
1372  dbgprotocol("%d <== Menu Close: immediate\n", SessionId());
1373  break;
1374  case CLOSE_MMI_DELAY:
1375  dbgprotocol("%d <== Menu Close: delay\n", SessionId());
1376  break;
1377  default: esyslog("ERROR: CI MMI: unknown close_mmi_cmd_id %02X", *d);
1378  return false;
1379  }
1380  }
1381 
1382  break;
1383  }
1384  default: esyslog("ERROR: CI MMI: unknown tag %06X", Tag);
1385  return false;
1386  }
1387  }
1388  return true;
1389 }
1390 
1392 {
1393  cCiMenu *m = m_menu;
1394  m_menu = nullptr;
1395  return m;
1396 }
1397 
1399 {
1400  cCiEnquiry *e = m_enquiry;
1401  m_enquiry = nullptr;
1402  return e;
1403 }
1404 
1405 bool cCiMMI::SendMenuAnswer(uint8_t Selection)
1406 {
1407  dbgprotocol("%d: ==> Menu Answ\n", SessionId());
1408  SendData(AOT_MENU_ANSW, 1, &Selection);
1409  //XXX return value of all SendData() calls???
1410  return true;
1411 }
1412 
1413 // Define protocol structure
1414 extern "C" {
1415  struct tAnswer { uint8_t m_id; char m_text[256]; };
1416 }
1417 
1418 bool cCiMMI::SendAnswer(const char *Text)
1419 {
1420  dbgprotocol("%d: ==> Answ\n", SessionId());
1421  tAnswer answer {};
1422  answer.m_id = Text ? AI_ANSWER : AI_CANCEL;
1423  if (Text) {
1424  strncpy(answer.m_text, Text, sizeof(answer.m_text) - 1);
1425  answer.m_text[255] = '\0';
1426  }
1427  SendData(AOT_ANSW, Text ? strlen(Text) + 1 : 1, (uint8_t *)&answer);
1428  //XXX return value of all SendData() calls???
1429  return true;
1430 }
1431 
1432 // --- cCiMenu ---------------------------------------------------------------
1433 
1434 cCiMenu::cCiMenu(cCiMMI *MMI, bool Selectable)
1435 {
1436  m_mmi = MMI;
1438 }
1439 
1441 {
1442  free(m_titleText);
1443  free(m_subTitleText);
1444  free(m_bottomText);
1445  for (int i = 0; i < m_numEntries; i++)
1446  free(m_entries[i]);
1447 }
1448 
1449 bool cCiMenu::AddEntry(char *s)
1450 {
1452  m_entries[m_numEntries++] = s;
1453  return true;
1454  }
1455  return false;
1456 }
1457 
1458 bool cCiMenu::Select(int Index)
1459 {
1460  if (m_mmi && -1 <= Index && Index < m_numEntries)
1461  return m_mmi->SendMenuAnswer(Index + 1);
1462  return false;
1463 }
1464 
1466 {
1467  return Select(-1);
1468 }
1469 
1470 // --- cCiEnquiry ------------------------------------------------------------
1471 
1473 {
1474  free(m_text);
1475 }
1476 
1477 bool cCiEnquiry::Reply(const char *s)
1478 {
1479  return m_mmi ? m_mmi->SendAnswer(s) : false;
1480 }
1481 
1483 {
1484  return Reply(nullptr);
1485 }
1486 
1487 // --- cCiCaPmt --------------------------------------------------------------
1488 
1489 // Ca Pmt Cmd Ids:
1490 
1491 enum CPCI_IDS {
1493  CPCI_OK_MMI = 0x02,
1494  CPCI_QUERY = 0x03,
1496 };
1497 
1498 cCiCaPmt::cCiCaPmt(int ProgramNumber, uint8_t cplm)
1499 {
1500  m_capmt[m_length++] = cplm; // ca_pmt_list_management
1501  m_capmt[m_length++] = (ProgramNumber >> 8) & 0xFF;
1502  m_capmt[m_length++] = ProgramNumber & 0xFF;
1503  m_capmt[m_length++] = 0x01; // version_number, current_next_indicator - apparently vn doesn't matter, but cni must be 1
1504 
1505  // program_info_length
1507  m_capmt[m_length++] = 0x00;
1508  m_capmt[m_length++] = 0x00;
1509 }
1510 
1512 {
1513  if (m_length + 5 > int(sizeof(m_capmt)))
1514  {
1515  esyslog("ERROR: buffer overflow in CA_PMT");
1516  return;
1517  }
1518 
1519  m_capmt[m_length++] = type & 0xFF;
1520  m_capmt[m_length++] = (pid >> 8) & 0xFF;
1521  m_capmt[m_length++] = pid & 0xFF;
1522 
1523  // ES_info_length
1525  m_capmt[m_length++] = 0x00;
1526  m_capmt[m_length++] = 0x00;
1527 }
1528 
1546 void cCiCaPmt::AddCaDescriptor(int ca_system_id, int ca_pid, int data_len,
1547  const uint8_t *data)
1548 {
1549  if (!m_infoLengthPos)
1550  {
1551  esyslog("ERROR: adding CA descriptor without program/stream!");
1552  return;
1553  }
1554 
1555  if (m_length + data_len + 7 > int(sizeof(m_capmt)))
1556  {
1557  esyslog("ERROR: buffer overflow in CA_PMT");
1558  return;
1559  }
1560 
1561  // We are either at start of program descriptors or stream descriptors.
1562  if (m_infoLengthPos + 2 == m_length)
1563  m_capmt[m_length++] = CPCI_OK_DESCRAMBLING; // ca_pmt_cmd_id
1564 
1565  m_capmt[m_length++] = 0x09; // CA descriptor tag
1566  m_capmt[m_length++] = 4 + data_len; // descriptor length
1567 
1568  m_capmt[m_length++] = (ca_system_id >> 8) & 0xFF;
1569  m_capmt[m_length++] = ca_system_id & 0xFF;
1570  m_capmt[m_length++] = (ca_pid >> 8) & 0xFF;
1571  m_capmt[m_length++] = ca_pid & 0xFF;
1572 
1573  if (data_len > 0)
1574  {
1575  memcpy(&m_capmt[m_length], data, data_len);
1576  m_length += data_len;
1577  }
1578 
1579  // update program_info_length/ES_info_length
1580  int l = m_length - m_infoLengthPos - 2;
1581  m_capmt[m_infoLengthPos] = (l >> 8) & 0xFF;
1582  m_capmt[m_infoLengthPos + 1] = l & 0xFF;
1583 }
1584 
1585 // -- cLlCiHandler -------------------------------------------------------------
1586 
1587 cLlCiHandler::cLlCiHandler(int Fd, int NumSlots)
1588 {
1589  m_numSlots = NumSlots;
1590  m_tpl = new cCiTransportLayer(Fd, m_numSlots);
1591  m_fdCa = Fd;
1592 }
1593 
1595 {
1596  cMutexLock MutexLock(&m_mutex);
1597  for (auto & session : m_sessions)
1598  delete session;
1599  delete m_tpl;
1600  close(m_fdCa);
1601 }
1602 
1604 {
1605  int fd_ca = open(FileName, O_RDWR);
1606  if (fd_ca >= 0)
1607  {
1608  ca_caps_t Caps;
1609  if (ioctl(fd_ca, CA_GET_CAP, &Caps) == 0)
1610  {
1611  int NumSlots = Caps.slot_num;
1612  if (NumSlots > 0)
1613  {
1614  if (Caps.slot_type & CA_CI_LINK)
1615  return new cLlCiHandler(fd_ca, NumSlots);
1616  if (Caps.slot_type & CA_CI)
1617  return new cHlCiHandler(fd_ca, NumSlots);
1618  isyslog("CAM doesn't support either high or low level CI,"
1619  " Caps.slot_type=%i", Caps.slot_type);
1620  }
1621  else
1622  esyslog("ERROR: no CAM slots found");
1623  }
1624  else
1625  LOG_ERROR_STR(FileName);
1626  close(fd_ca);
1627  }
1628  return nullptr;
1629 }
1630 
1631 int cLlCiHandler::ResourceIdToInt(const uint8_t *Data)
1632 {
1633  return (ntohl(*(int *)Data));
1634 }
1635 
1636 bool cLlCiHandler::Send(uint8_t Tag, int SessionId, int ResourceId, int Status)
1637 {
1638  std::vector<uint8_t> buffer {Tag, 0x00} ; // 0x00 will be replaced with length
1639  if (Status >= 0)
1640  buffer.push_back(Status);
1641  if (ResourceId) {
1642  buffer.push_back((ResourceId >> 24) & 0xFF);
1643  buffer.push_back((ResourceId >> 16) & 0xFF);
1644  buffer.push_back((ResourceId >> 8) & 0xFF);
1645  buffer.push_back( ResourceId & 0xFF);
1646  }
1647  buffer.push_back((SessionId >> 8) & 0xFF);
1648  buffer.push_back( SessionId & 0xFF);
1649  buffer[1] = buffer.size() - 2; // length
1650  return m_tc && m_tc->SendData(buffer) == OK;
1651 }
1652 
1654 {
1655  for (auto & session : m_sessions) {
1656  if (session && session->SessionId() == SessionId)
1657  return session;
1658  }
1659  return nullptr;
1660 }
1661 
1663 {
1664  for (auto & session : m_sessions) {
1665  if (session && session->Tc()->Slot() == Slot && session->ResourceId() == ResourceId)
1666  return session;
1667  }
1668  return nullptr;
1669 }
1670 
1672 {
1673  if (!GetSessionByResourceId(ResourceId, m_tc->Slot())) {
1674  for (int i = 0; i < MAX_CI_SESSION; i++) {
1675  if (!m_sessions[i]) {
1676  switch (ResourceId) {
1677  case RI_RESOURCE_MANAGER: return m_sessions[i] = new cCiResourceManager(i + 1, m_tc);
1680  return m_sessions[i] = new cCiConditionalAccessSupport(i + 1, m_tc);
1681  case RI_HOST_CONTROL: break; //XXX
1682  case RI_DATE_TIME: return m_sessions[i] = new cCiDateTime(i + 1, m_tc);
1683  case RI_MMI: return m_sessions[i] = new cCiMMI(i + 1, m_tc);
1684  }
1685  }
1686  }
1687  }
1688  return nullptr;
1689 }
1690 
1691 bool cLlCiHandler::OpenSession(int Length, const uint8_t *Data)
1692 {
1693  if (Length == 6 && *(Data + 1) == 0x04) {
1694  int ResourceId = ResourceIdToInt(Data + 2);
1695  dbgprotocol("OpenSession %08X\n", ResourceId);
1696  switch (ResourceId) {
1697  case RI_RESOURCE_MANAGER:
1700  case RI_HOST_CONTROL:
1701  case RI_DATE_TIME:
1702  case RI_MMI:
1703  {
1704  cCiSession *Session = CreateSession(ResourceId);
1705  if (Session)
1706  {
1708  Session->ResourceId(), SS_OK);
1709  return true;
1710  }
1711  esyslog("ERROR: can't create session for resource identifier: %08X",
1712  ResourceId);
1713  break;
1714  }
1715  default: esyslog("ERROR: unknown resource identifier: %08X", ResourceId);
1716  }
1717  }
1718  return false;
1719 }
1720 
1721 bool cLlCiHandler::CloseSession(int SessionId)
1722 {
1723  dbgprotocol("CloseSession %08X\n", SessionId);
1724  cCiSession *Session = GetSessionBySessionId(SessionId);
1725  if (Session && m_sessions[SessionId - 1] == Session) {
1726  delete Session;
1727  m_sessions[SessionId - 1] = nullptr;
1728  Send(ST_CLOSE_SESSION_RESPONSE, SessionId, 0, SS_OK);
1729  return true;
1730  }
1731 
1732  esyslog("ERROR: unknown session id: %d", SessionId);
1734  return false;
1735 }
1736 
1738 {
1739  int result = 0;
1740  for (auto & session : m_sessions) {
1741  if (session && session->Tc()->Slot() == Slot) {
1742  CloseSession(session->SessionId());
1743  result++;
1744  }
1745  }
1746  return result;
1747 }
1748 
1750 {
1751  bool result = true;
1752  cMutexLock MutexLock(&m_mutex);
1753 
1754  for (int Slot = 0; Slot < m_numSlots; Slot++)
1755  {
1756  m_tc = m_tpl->Process(Slot);
1757  if (m_tc)
1758  {
1759  int Length = 0;
1760  const uint8_t *Data = m_tc->Data(Length);
1761  if (Data && Length > 1)
1762  {
1763  switch (*Data)
1764  {
1765  case ST_SESSION_NUMBER:
1766  if (Length > 4)
1767  {
1768  int SessionId = ntohs(*(short *)&Data[2]);
1769  cCiSession *Session = GetSessionBySessionId(SessionId);
1770  if (Session)
1771  {
1772  Session->Process(Length - 4, Data + 4);
1773  if (Session->ResourceId() == RI_APPLICATION_INFORMATION)
1774  {
1775 #if 0
1776  esyslog("Test: %x",
1777  ((cCiApplicationInformation*)Session)->GetApplicationManufacturer());
1778 #endif
1779  }
1780  }
1781  else
1782  esyslog("ERROR: unknown session id: %d", SessionId);
1783  }
1784  break;
1785 
1787  OpenSession(Length, Data);
1788  break;
1789 
1791  if (Length == 4)
1792  CloseSession(ntohs(*(short *)&Data[2]));
1793  break;
1794 
1795  case ST_CREATE_SESSION_RESPONSE: //XXX fall through to default
1796  case ST_CLOSE_SESSION_RESPONSE: //XXX fall through to default
1797  default:
1798  esyslog("ERROR: unknown session tag: %02X", *Data);
1799  }
1800  }
1801  }
1802  else if (CloseAllSessions(Slot))
1803  {
1804  m_tpl->ResetSlot(Slot);
1805  result = false;
1806  }
1807  else if (m_tpl->ModuleReady(Slot))
1808  {
1809  dbgprotocol("Module ready in slot %d\n", Slot);
1810  m_tpl->NewConnection(Slot);
1811  }
1812  }
1813 
1814  bool UserIO = false;
1815  m_needCaPmt = false;
1816  for (auto & session : m_sessions)
1817  {
1818  if (session && session->Process())
1819  {
1820  UserIO |= session->HasUserIO();
1821  if (session->ResourceId() == RI_CONDITIONAL_ACCESS_SUPPORT)
1822  {
1823  auto *cas = dynamic_cast<cCiConditionalAccessSupport *>(session);
1824  if (cas == nullptr)
1825  continue;
1826  m_needCaPmt |= cas->NeedCaPmt();
1827  }
1828  }
1829  }
1830  m_hasUserIO = UserIO;
1831 
1832  if (m_newCaSupport)
1833  m_newCaSupport = result = false; // triggers new SetCaPmt at caller!
1834  return result;
1835 }
1836 
1838 {
1839  cMutexLock MutexLock(&m_mutex);
1841  return api ? api->EnterMenu() : false;
1842 }
1843 
1845 {
1846  cMutexLock MutexLock(&m_mutex);
1847  for (int Slot = 0; Slot < m_numSlots; Slot++) {
1848  auto *mmi = dynamic_cast<cCiMMI *>(GetSessionByResourceId(RI_MMI, Slot));
1849  if (mmi)
1850  return mmi->Menu();
1851  }
1852  return nullptr;
1853 }
1854 
1856 {
1857  cMutexLock MutexLock(&m_mutex);
1858  for (int Slot = 0; Slot < m_numSlots; Slot++) {
1859  auto *mmi = dynamic_cast<cCiMMI *>(GetSessionByResourceId(RI_MMI, Slot));
1860  if (mmi)
1861  return mmi->Enquiry();
1862  }
1863  return nullptr;
1864 }
1865 
1867  {
1868  static dvbca_vector empty {};
1869  cMutexLock MutexLock(&m_mutex);
1871  return cas ? cas->GetCaSystemIds() : empty;
1872 }
1873 
1874 bool cLlCiHandler::SetCaPmt(cCiCaPmt &CaPmt, int Slot)
1875 {
1876  cMutexLock MutexLock(&m_mutex);
1878  return cas && cas->SendPMT(CaPmt);
1879 }
1880 
1881 void cLlCiHandler::SetTimeOffset(double offset_in_seconds)
1882 {
1883  cMutexLock MutexLock(&m_mutex);
1884  cCiDateTime *dt = nullptr;
1885 
1886  for (uint i = 0; i < (uint) NumSlots(); i++)
1887  {
1888  dt = dynamic_cast<cCiDateTime*>(GetSessionByResourceId(RI_DATE_TIME, i));
1889  if (dt)
1890  dt->SetTimeOffset(offset_in_seconds);
1891  }
1892 }
1893 
1894 bool cLlCiHandler::Reset(int Slot)
1895 {
1896  cMutexLock MutexLock(&m_mutex);
1897  CloseAllSessions(Slot);
1898  return m_tpl->ResetSlot(Slot);
1899 }
1900 
1902 {
1903  return sConnected;
1904 }
1905 
1906 // -- cHlCiHandler -------------------------------------------------------------
1907 
1908 cHlCiHandler::cHlCiHandler(int Fd, int NumSlots)
1909 {
1910  m_numSlots = NumSlots;
1911  m_fdCa = Fd;
1912  esyslog("New High level CI handler");
1913 }
1914 
1916 {
1917  cMutexLock MutexLock(&m_mutex);
1918  close(m_fdCa);
1919 }
1920 
1921 int cHlCiHandler::CommHL(unsigned tag, unsigned function, struct ca_msg *msg) const
1922 {
1923  if (tag) {
1924  msg->msg[2] = tag & 0xff;
1925  msg->msg[1] = (tag & 0xff00) >> 8;
1926  msg->msg[0] = (tag & 0xff0000) >> 16;
1927  esyslog("Sending message=[%02x %02x %02x ]",
1928  msg->msg[0], msg->msg[1], msg->msg[2]);
1929  }
1930 
1931  return ioctl(m_fdCa, function, msg);
1932 }
1933 
1934 int cHlCiHandler::GetData(unsigned tag, struct ca_msg *msg)
1935 {
1936  return CommHL(tag, CA_GET_MSG, msg);
1937 }
1938 
1939 int cHlCiHandler::SendData(unsigned tag, struct ca_msg *msg)
1940 {
1941  return CommHL(tag, CA_SEND_MSG, msg);
1942 }
1943 
1945 {
1946  cMutexLock MutexLock(&m_mutex);
1947 
1948  struct ca_msg msg {};
1949  switch(m_state) {
1950  case 0:
1951  // Get CA_system_ids
1952  /* Enquire */
1953  if ((SendData(AOT_CA_INFO_ENQ, &msg)) < 0) {
1954  esyslog("HLCI communication failed");
1955  } else {
1956  dbgprotocol("==> Ca Info Enquiry");
1957  /* Receive */
1958  if ((GetData(AOT_CA_INFO, &msg)) < 0) {
1959  esyslog("HLCI communication failed");
1960  } else {
1961  QString message("Debug: ");
1962  for(int i = 0; i < 20; i++) {
1963  message += QString("%1 ").arg(msg.msg[i]);
1964  }
1965  LOG(VB_GENERAL, LOG_DEBUG, message);
1966  dbgprotocol("<== Ca Info");
1967  int l = msg.msg[3];
1968  const uint8_t *d = &msg.msg[4];
1969  while (l > 1) {
1970  unsigned short id = ((unsigned short)(*d) << 8) | *(d + 1);
1971  dbgprotocol(" %04X", id);
1972  d += 2;
1973  l -= 2;
1974 
1975  // Insert before the last element.
1976  m_caSystemIds.emplace_back(id);
1977  }
1978  dbgprotocol("\n");
1979  }
1980  m_state = 1;
1981  break;
1982  }
1983  }
1984 
1985  bool result = true;
1986 
1987  return result;
1988 }
1989 
1990 bool cHlCiHandler::EnterMenu(int /*Slot*/)
1991 {
1992  return false;
1993 }
1994 
1996 {
1997  return nullptr;
1998 }
1999 
2001 {
2002  return nullptr;
2003 }
2004 
2006 {
2007  return m_caSystemIds;
2008 }
2009 
2010 bool cHlCiHandler::SetCaPmt(cCiCaPmt &CaPmt, int /*Slot*/)
2011 {
2012  cMutexLock MutexLock(&m_mutex);
2013  struct ca_msg msg {};
2014 
2015  esyslog("Setting CA PMT.");
2016  m_state = 2;
2017 
2018  msg.msg[3] = CaPmt.m_length;
2019 
2020  if (CaPmt.m_length > (256 - 4))
2021  {
2022  esyslog("CA message too long");
2023  return false;
2024  }
2025 
2026  memcpy(&msg.msg[4], CaPmt.m_capmt, CaPmt.m_length);
2027 
2028  if ((SendData(AOT_CA_PMT, &msg)) < 0) {
2029  esyslog("HLCI communication failed");
2030  return false;
2031  }
2032 
2033  return true;
2034 }
2035 
2036 bool cHlCiHandler::Reset(int /*Slot*/) const
2037 {
2038  if ((ioctl(m_fdCa, CA_RESET)) < 0) {
2039  esyslog("ioctl CA_RESET failed.");
2040  return false;
2041  }
2042  return true;
2043 }
2044 
2046 {
2047  return m_state == 1;
2048 }
cCiDateTime::m_lastTime
time_t m_lastTime
Definition: dvbci.cpp:1101
cCiConditionalAccessSupport::m_state
int m_state
Definition: dvbci.cpp:1027
cCiConditionalAccessSupport
Definition: dvbci.cpp:1025
cCiApplicationInformation::~cCiApplicationInformation
~cCiApplicationInformation() override
Definition: dvbci.cpp:972
cCiApplicationInformation::GetManufacturerCode
uint16_t GetManufacturerCode() const
Definition: dvbci.cpp:957
cLlCiHandler::SetTimeOffset
void SetTimeOffset(double offset_in_seconds) override
Definition: dvbci.cpp:1881
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:1901
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:1242
cCiCaPmt::AddCaDescriptor
void AddCaDescriptor(int ca_system_id, int ca_pid, int data_len, const uint8_t *data)
Definition: dvbci.cpp:1546
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:1415
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:1653
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:1737
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:1029
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:960
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:1492
cCiConditionalAccessSupport::m_caSystemIds
dvbca_vector m_caSystemIds
Definition: dvbci.cpp:1028
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:1908
cCiMMI
Definition: dvbci.cpp:1245
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:1934
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:1434
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:1482
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:1224
CPCI_QUERY
@ CPCI_QUERY
Definition: dvbci.cpp:1494
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:1199
AOT_DISPLAY_REPLY
@ AOT_DISPLAY_REPLY
Definition: dvbci.cpp:746
cLlCiHandler::GetEnquiry
cCiEnquiry * GetEnquiry(void) override
Definition: dvbci.cpp:1855
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:1939
LOG
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
Definition: mythlogging.h:39
cLlCiHandler::Process
bool Process(void) override
Definition: dvbci.cpp:1749
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:1231
cCiTransportConnection::m_lastPoll
std::chrono::milliseconds m_lastPoll
Definition: dvbci.cpp:402
DCC_OVERLAY_GRAPHICS_CHARACTERISTICS
@ DCC_OVERLAY_GRAPHICS_CHARACTERISTICS
Definition: dvbci.cpp:1209
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:1477
MM_LOW_LEVEL_OVERLAY_GRAPHICS
@ MM_LOW_LEVEL_OVERLAY_GRAPHICS
Definition: dvbci.cpp:1217
cMutexLock
Definition: dvbci.h:59
cCiTransportLayer::Process
cCiTransportConnection * Process(int Slot)
Definition: dvbci.cpp:653
cHlCiHandler::~cHlCiHandler
~cHlCiHandler() override
Definition: dvbci.cpp:1915
cCiMMI::cCiMMI
cCiMMI(int SessionId, cCiTransportConnection *Tc)
Definition: dvbci.cpp:1261
cCiApplicationInformation::m_applicationManufacturer
uint16_t m_applicationManufacturer
Definition: dvbci.cpp:947
cLlCiHandler::m_mutex
cMutex m_mutex
Definition: dvbci.h:162
DCC_INPUT_CHARACTER_TABLE_LIST
@ DCC_INPUT_CHARACTER_TABLE_LIST
Definition: dvbci.cpp:1208
cCiTransportConnection::m_tcid
uint8_t m_tcid
Definition: dvbci.cpp:399
cCiDateTime::m_timeOffset
int m_timeOffset
Definition: dvbci.cpp:1102
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:1236
cCiResourceManager::Process
bool Process(int Length=0, const uint8_t *Data=nullptr) override
Definition: dvbci.cpp:891
RI_RESOURCE_MANAGER
@ RI_RESOURCE_MANAGER
Definition: dvbci.cpp:716
cHlCiHandler::Process
bool Process(void) override
Definition: dvbci.cpp:1944
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:1594
AOT_CLEAR_REPLACE
@ AOT_CLEAR_REPLACE
Definition: dvbci.cpp:740
DRI_LIST_GRAPHIC_OVERLAY_CHARACTERISTICS
@ DRI_LIST_GRAPHIC_OVERLAY_CHARACTERISTICS
Definition: dvbci.cpp:1227
DRI_LIST_INPUT_CHARACTER_TABLES
@ DRI_LIST_INPUT_CHARACTER_TABLES
Definition: dvbci.cpp:1226
AOT_SCENE_DONE
@ AOT_SCENE_DONE
Definition: dvbci.cpp:762
DISPLAY_REPLY_IDS
DISPLAY_REPLY_IDS
Definition: dvbci.cpp:1223
DISPLAY_CONTROL
DISPLAY_CONTROL
Definition: dvbci.cpp:1205
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:1990
cCiApplicationInformation::m_menuString
char * m_menuString
Definition: dvbci.cpp:949
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:1418
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:1218
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:1198
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:1472
AOT_LIST_LAST
@ AOT_LIST_LAST
Definition: dvbci.cpp:756
cCiResourceManager
Definition: dvbci.cpp:876
SIZE_INDICATOR
static constexpr int SIZE_INDICATOR
Definition: dvbci.cpp:81
cLlCiHandler::GetCaSystemIds
dvbca_vector GetCaSystemIds(int Slot) override
Definition: dvbci.cpp:1866
DCC_DISPLAY_CHARACTER_TABLE_LIST
@ DCC_DISPLAY_CHARACTER_TABLE_LIST
Definition: dvbci.cpp:1207
CPCI_OK_MMI
@ CPCI_OK_MMI
Definition: dvbci.cpp:1493
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:1458
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:1415
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:1229
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:1636
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:1248
DCC_SET_MMI_MODE
@ DCC_SET_MMI_MODE
Definition: dvbci.cpp:1206
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:1033
AOT_LIST_MORE
@ AOT_LIST_MORE
Definition: dvbci.cpp:757
cLlCiHandler::CloseSession
bool CloseSession(int SessionId)
Definition: dvbci.cpp:1721
cLlCiHandler
Definition: dvbci.h:159
cMutexLock::Lock
bool Lock(cMutex *Mutex)
Definition: dvbci.cpp:230
cCiDateTime::SetTimeOffset
void SetTimeOffset(double offset)
Definition: dvbci.cpp:1116
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:1491
cLlCiHandler::CreateSession
cCiSession * CreateSession(int ResourceId)
Definition: dvbci.cpp:1671
AOT_MENU_ANSW
@ AOT_MENU_ANSW
Definition: dvbci.cpp:755
cCiApplicationInformation::GetApplicationManufacturer
uint16_t GetApplicationManufacturer() const
Definition: dvbci.cpp:956
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:1440
cCiApplicationInformation::GetApplicationString
char * GetApplicationString()
Definition: dvbci.cpp:955
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:79
cTPDU::m_size
ssize_t m_size
Definition: dvbci.cpp:266
cCiResourceManager::cCiResourceManager
cCiResourceManager(int SessionId, cCiTransportConnection *Tc)
Definition: dvbci.cpp:884
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:1200
cCiApplicationInformation::m_manufacturerCode
uint16_t m_manufacturerCode
Definition: dvbci.cpp:948
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:1122
cHlCiHandler::Reset
bool Reset(int Slot) const
Definition: dvbci.cpp:2036
DRI_LIST_DISPLAY_CHARACTER_TABLES
@ DRI_LIST_DISPLAY_CHARACTER_TABLES
Definition: dvbci.cpp:1225
cCiConditionalAccessSupport::SendPMT
bool SendPMT(const cCiCaPmt &CaPmt)
Definition: dvbci.cpp:1086
cHlCiHandler::CommHL
int CommHL(unsigned tag, unsigned function, struct ca_msg *msg) const
Definition: dvbci.cpp:1921
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:1045
cCiMMI::HasUserIO
bool HasUserIO(void) override
Definition: dvbci.cpp:1254
CPCI_NOT_SELECTED
@ CPCI_NOT_SELECTED
Definition: dvbci.cpp:1495
cCiApplicationInformation::Process
bool Process(int Length=0, const uint8_t *Data=nullptr) override
Definition: dvbci.cpp:977
dsyslog
#define dsyslog(a...)
Definition: dvbci.cpp:54
cCiApplicationInformation::EnterMenu
bool EnterMenu(void)
Definition: dvbci.cpp:1013
cCiMenu::m_selectable
bool m_selectable
Definition: dvbci.h:77
AI_CANCEL
@ AI_CANCEL
Definition: dvbci.cpp:1241
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:1405
cCiApplicationInformation
Definition: dvbci.cpp:942
cCiSession
Definition: dvbci.cpp:777
cLlCiHandler::m_tpl
cCiTransportLayer * m_tpl
Definition: dvbci.h:169
MM_HIGH_LEVEL
@ MM_HIGH_LEVEL
Definition: dvbci.cpp:1216
cCiTransportConnection::m_state
eState m_state
Definition: dvbci.cpp:400
cCiMMI::~cCiMMI
~cCiMMI() override
Definition: dvbci.cpp:1269
cHlCiHandler::GetCaSystemIds
dvbca_vector GetCaSystemIds(int Slot) override
Definition: dvbci.cpp:2005
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:1228
cCiDateTime::Process
bool Process(int Length=0, const uint8_t *Data=nullptr) override
Definition: dvbci.cpp:1167
cMutex::m_lockingPid
pid_t m_lockingPid
Definition: dvbci.h:50
MMI_MODES
MMI_MODES
Definition: dvbci.cpp:1215
DRI_UNKNOWN_MMI_MODE
@ DRI_UNKNOWN_MMI_MODE
Definition: dvbci.cpp:1230
cCiMMI::m_enquiry
cCiEnquiry * m_enquiry
Definition: dvbci.cpp:1249
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:1098
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:1587
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:1275
cTPDU::Data
const uint8_t * Data(int &Length)
Definition: dvbci.cpp:275
cHlCiHandler::NeedCaPmt
bool NeedCaPmt(void) override
Definition: dvbci.cpp:2045
OK
static constexpr int OK
Definition: dvbci.cpp:69
BYTE1
static constexpr uint8_t BYTE1(uint16_t a)
Definition: dvbci.cpp:1126
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:1894
cLlCiHandler::m_needCaPmt
bool m_needCaPmt
Definition: dvbci.h:167
cLlCiHandler::EnterMenu
bool EnterMenu(int Slot) override
Definition: dvbci.cpp:1837
cLlCiHandler::ResourceIdToInt
static int ResourceIdToInt(const uint8_t *Data)
Definition: dvbci.cpp:1631
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:1603
DCC_FULL_SCREEN_GRAPHICS_CHARACTERISTICS
@ DCC_FULL_SCREEN_GRAPHICS_CHARACTERISTICS
Definition: dvbci.cpp:1210
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:944
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:1415
cCiEnquiry
Definition: dvbci.h:97
cCiSession::HasUserIO
virtual bool HasUserIO(void)
Definition: dvbci.cpp:794
cCiDateTime::SendDateTime
bool SendDateTime(void)
Definition: dvbci.cpp:1129
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:878
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:946
cLlCiHandler::GetSessionByResourceId
cCiSession * GetSessionByResourceId(int ResourceId, int Slot)
Definition: dvbci.cpp:1662
cCiConditionalAccessSupport::cCiConditionalAccessSupport
cCiConditionalAccessSupport(int SessionId, cCiTransportConnection *Tc)
Definition: dvbci.cpp:1038
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:1498
cCiMMI::Menu
cCiMenu * Menu(void)
Definition: dvbci.cpp:1391
AOT_SUBTITLE_SEGMENT_LAST
@ AOT_SUBTITLE_SEGMENT_LAST
Definition: dvbci.cpp:758
cCiConditionalAccessSupport::NeedCaPmt
bool NeedCaPmt(void) const
Definition: dvbci.cpp:1035
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:1844
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:1100
cCiHandler
Definition: dvbci.h:143
cCiMenu::AddEntry
bool AddEntry(char *s)
Definition: dvbci.cpp:1449
BYTE0
static constexpr uint8_t BYTE0(uint16_t a)
Definition: dvbci.cpp:1124
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:945
AOT_ENQ
@ AOT_ENQ
Definition: dvbci.cpp:751
cCiMMI::Process
bool Process(int Length=0, const uint8_t *Data=nullptr) override
Definition: dvbci.cpp:1294
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:1691
cCiMenu::Cancel
bool Cancel(void)
Definition: dvbci.cpp:1465
cCiMMI::Enquiry
cCiEnquiry * Enquiry(void)
Definition: dvbci.cpp:1398
cHlCiHandler::GetMenu
cCiMenu * GetMenu(void) override
Definition: dvbci.cpp:1995
cHlCiHandler::GetEnquiry
cCiEnquiry * GetEnquiry(void) override
Definition: dvbci.cpp:2000
ERROR
static constexpr int ERROR
Definition: dvbci.cpp:71
ANSWER_IDS
ANSWER_IDS
Definition: dvbci.cpp:1240
cCiCaPmt::AddElementaryStream
void AddElementaryStream(int type, int pid)
Definition: dvbci.cpp:1511
cCiDateTime::cCiDateTime
cCiDateTime(int SessionId, cCiTransportConnection *Tc)
Definition: dvbci.cpp:1110