Origin commit data
------------------
Branch: master
Commit: 0bbcfaf171
Author: max_10 <max_10@gmx.de>
Date: 2015-11-10 (Tue, 10 Nov 2015)


------------------
No further description and justification available within origin commit message!

------------------
This commit was generated by Migit
This commit is contained in:
max_10
2015-11-10 00:00:04 +01:00
parent f702f386e4
commit 68227f5297
7 changed files with 270 additions and 96 deletions

View File

@@ -5,12 +5,17 @@ AM_CPPFLAGS = \
-I$(top_srcdir)/include
AM_CXXFLAGS = -fno-rtti -fno-exceptions -fno-strict-aliasing
AM_LDFLAGS = -lpthread
AM_LDFLAGS = -lpthread -lcrypto -lssl
libdvbci_la_SOURCES = \
dvbci_session.cpp \
dvbci_mmi.cpp \
dvbci_camgr.cpp \
misc.cpp \
descrambler.cpp \
dh_rsa_misc.cpp \
aes_xcbc_mac.cpp \
dvbci_ccmgr.cpp \
dvbci_appmgr.cpp \
dvbci_datetimemgr.cpp \
dvbci_resmgr.cpp

View File

@@ -1,8 +1,13 @@
/* DVB CI DateTime Manager */
#include <stdio.h>
#include <inttypes.h>
#include <arpa/inet.h>
#include <time.h>
#include "dvbci_datetimemgr.h"
static const char * FILENAME = "[dvbci_datetimemgr]";
eDVBCIDateTimeSession::eDVBCIDateTimeSession(tSlot *tslot)
{
slot = tslot;
@@ -46,8 +51,30 @@ int eDVBCIDateTimeSession::doAction()
return 0;
case stateSendDateTime:
{
struct tm tm_gmt;
struct tm tm_loc;
unsigned char tag[3] = {0x9f, 0x84, 0x41}; // date_time_response
unsigned char msg[7] = {0, 0, 0, 0, 0, 0, 0};
printf("%s -> %s\n", FILENAME, __FUNCTION__);
time_t t = time(NULL);
if ( gmtime_r(&t, &tm_gmt) && localtime_r(&t, &tm_loc) )
{
int Y = tm_gmt.tm_year;
int M = tm_gmt.tm_mon + 1;
int D = tm_gmt.tm_mday;
int L = (M == 1 || M == 2) ? 1 : 0;
int MJD = 14956 + D + (int)((Y - L) * 365.25) + (int)((M + 1 + L * 12) * 30.6001);
#define DEC2BCD(d) (((d / 10) << 4) + (d % 10))
msg[0] = htons(MJD) >> 8;
msg[1] = htons(MJD) & 0xff;
msg[2] = DEC2BCD(tm_gmt.tm_hour);
msg[3] = DEC2BCD(tm_gmt.tm_min);
msg[4] = DEC2BCD(tm_gmt.tm_sec);
msg[5] = htons(tm_loc.tm_gmtoff / 60) >> 8;
msg[6] = htons(tm_loc.tm_gmtoff / 60) & 0xff;
}
sendAPDU(tag, msg, 7);
return 0;
}

View File

@@ -11,7 +11,7 @@ static const char * FILENAME = "[dvbci_mmi]";
eDVBCIMMISession::eDVBCIMMISession(tSlot *tslot)
{
printf("%s:%s\n", FILENAME, __func__);
printf("%s -> %s\n", FILENAME, __func__);
slot = tslot;
slot->hasMMIManager = true;
slot->mmiSession = this;

View File

@@ -6,7 +6,7 @@ static const char * FILENAME = "[dvbci_resmgr]";
int eDVBCIResourceManagerSession::receivedAPDU(const unsigned char *tag, const void *data, int len)
{
printf("SESSION(%d) %02x %02x %02x (len = %d): \n", session_nb, tag[0], tag[1], tag[2], len);
printf("SESSION(%d)RES %02x %02x %02x (len = %d): \n", session_nb, tag[0], tag[1], tag[2], len);
for (int i = 0; i < len; i++)
printf("%02x ", ((const unsigned char*)data)[i]);
printf("\n");
@@ -15,7 +15,7 @@ int eDVBCIResourceManagerSession::receivedAPDU(const unsigned char *tag, const v
switch (tag[2])
{
case 0x10: // profile enquiry
printf("cam fragt was ich kann.");
printf("cam fragt was ich kann.\n");
state = stateProfileEnquiry;
return 1;
break;
@@ -72,10 +72,12 @@ int eDVBCIResourceManagerSession::doAction()
{
{0x00, 0x01, 0x00, 0x41},
{0x00, 0x02, 0x00, 0x41},
{0x00, 0x02, 0x00, 0x43},
{0x00, 0x03, 0x00, 0x41},
// {0x00, 0x20, 0x00, 0x41}, // host control
{0x00, 0x40, 0x00, 0x41},
{0x00, 0x24, 0x00, 0x41}
{0x00, 0x24, 0x00, 0x41},
{0x00, 0x8c, 0x10, 0x01} // content control
// {0x00, 0x10, 0x00, 0x41} // auth.
};
sendAPDU(tag, data, sizeof(data));

View File

@@ -9,6 +9,7 @@
#include "dvbci_camgr.h"
#include "dvbci_datetimemgr.h"
#include "dvbci_mmi.h"
#include "dvbci_ccmgr.h"
static const char * FILENAME = "[dvbci_session]";
@@ -156,6 +157,7 @@ eDVBCISession* eDVBCISession::createSession(tSlot *slot, const unsigned char *re
printf("RESOURCE MANAGER\n");
break;
case 0x00020041:
case 0x00020043:
sessions[session_nb - 1] = new eDVBCIApplicationManagerSession(slot);
printf("APPLICATION MANAGER\n");
break;
@@ -171,6 +173,10 @@ eDVBCISession* eDVBCISession::createSession(tSlot *slot, const unsigned char *re
sessions[session_nb - 1] = new eDVBCIMMISession(slot);
printf("MMI - create session\n");
break;
case 0x008c1001:
sessions[session_nb - 1] = new eDVBCIContentControlManagerSession(slot);
printf("CC MANAGER\n");
break;
case 0x00100041:
// session=new eDVBCIAuthSession;
printf("AuthSession\n");
@@ -236,12 +242,12 @@ int eDVBCISession::pollAll()
void eDVBCISession::receiveData(tSlot *slot, const unsigned char *ptr, size_t len)
{
printf("slot: %p\n", slot);
printf("%s -> %s\n",FILENAME, __FUNCTION__);
#if 0
for(unsigned int i = 0; i < len; i++)
printf("%02x ", ptr[i]);
printf("\n");
#endif
if ((ptr[0] == 0x90 || ptr[0] == 0x95) && (ptr[3] == 0 ))
{
printf("****Mist: %02x %02x %02x %02x\n", ptr[0], ptr[1], ptr[2], ptr[3]);
@@ -272,7 +278,7 @@ void eDVBCISession::receiveData(tSlot *slot, const unsigned char *ptr, size_t le
else
{
unsigned session_nb;
printf("hlen = %d, %d, %d\n", hlen, pkt[hlen - 2], pkt[hlen - 1]);
//printf("hlen = %d, %d, %d\n", hlen, pkt[hlen - 2], pkt[hlen - 1]);
session_nb = pkt[hlen - 2] << 8;
session_nb |= pkt[hlen - 1] & 0xFF;
@@ -312,7 +318,7 @@ void eDVBCISession::receiveData(tSlot *slot, const unsigned char *ptr, size_t le
if (session)
{
printf("len %d\n", len);
//printf("len %d\n", len);
while (len > 0)
{
int alen;
@@ -323,7 +329,7 @@ void eDVBCISession::receiveData(tSlot *slot, const unsigned char *ptr, size_t le
pkt += hlen;
len -= hlen;
printf("len = %d, hlen = %d, alen = %d\n", len, hlen, alen);
//printf("len = %d, hlen = %d, alen = %d\n", len, hlen, alen);
if (((len - alen) > 0) && ((len - alen) < 3))
{