Skip to content
This repository has been archived by the owner on Apr 14, 2024. It is now read-only.

Commit

Permalink
this patch includes:
Browse files Browse the repository at this point in the history
A. make, cmake and config parameters. 
This means that we have 2 new options: 
WITH_EMU to enable/disable the (dummy) emu reader, and 
WITH_SOFTCAM to enable/disable linking of softcam.key inside the binary. 
The WITH_SOFTCAM option can be removed completely if you like. 
No code that reads keys is included.

B. All webif changes are included. 
This means that when building WITH_EMU enabled, 
there will be a stream relay page and 
an emu reader "config bit" in the reader settings. 
There will also be a softcam.key link 
to open the softcam.key file and see its content 
(similar to what is done in constant.cw file).

C. When building with disabled WITH_EMU, 
there will be no sign of emu reader anywhere.

git-svn-id: http://www.streamboard.tv/svn/oscam/trunk@11503 4b0bc96b-bc66-0410-9d44-ebda105a78c1
  • Loading branch information
gorgone.impertinence committed Feb 17, 2019
1 parent 07bb0d0 commit 0e0c23c
Show file tree
Hide file tree
Showing 27 changed files with 567 additions and 23 deletions.
38 changes: 38 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,22 @@ endif (HAVE_PCSC)
# Manage config.h based on command line parameters
# Manipulate config file based on given parameters and read unset parameters

execute_process (COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/config.sh --enabled WITH_EMU OUTPUT_VARIABLE CONFIG_WITH_EMU OUTPUT_STRIP_TRAILING_WHITESPACE)
if (CONFIG_WITH_EMU MATCHES "Y" AND NOT WITH_EMU EQUAL 1)
add_definitions ("-DWITH_EMU")
set (WITH_EMU "1")
message (STATUS " EMU is added by config compiling with EMU")
endif (CONFIG_WITH_EMU MATCHES "Y" AND NOT WITH_EMU EQUAL 1)

if (WITH_EMU)
execute_process (COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/config.sh --enabled WITH_SOFTCAM OUTPUT_VARIABLE CONFIG_WITH_SOFTCAM OUTPUT_STRIP_TRAILING_WHITESPACE)
if (CONFIG_WITH_SOFTCAM MATCHES "Y" AND NOT WITH_SOFTCAM EQUAL 1)
add_definitions ("-DWITH_SOFTCAM")
set (WITH_SOFTCAM "1")
message (STATUS " SOFTCAM is added by config linking SoftCam.Key")
endif (CONFIG_WITH_SOFTCAM MATCHES "Y" AND NOT WITH_SOFTCAM EQUAL 1)
endif (WITH_EMU)

execute_process (COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/config.sh --show-valid OUTPUT_VARIABLE config_vars_string OUTPUT_STRIP_TRAILING_WHITESPACE)
string(REGEX MATCHALL "[A-Z0-9_]+" config_vars ${config_vars_string})

Expand Down Expand Up @@ -737,6 +753,21 @@ endif( HAVE_LIBRT OR HAVE_LIBRT_STATIC)

#--------------------------------------------------------------------------------

if (NOT OSCamOperatingSystem MATCHES "Mac OS X")
if (NOT DEFINED ENV{ANDROID_NDK})
if (NOT DEFINED ENV{ANDROID_STANDALONE_TOOLCHAIN})
if (WITH_SOFTCAM)
if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/SoftCam.Key)
execute_process (COMMAND cp ${CMAKE_CURRENT_SOURCE_DIR}/SoftCam.Key ${CMAKE_CURRENT_BINARY_DIR}/SoftCam.Key)
else (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/SoftCam.Key)
execute_process (COMMAND touch ${CMAKE_CURRENT_BINARY_DIR}/SoftCam.Key)
endif (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/SoftCam.Key)
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--format=binary -Wl,SoftCam.Key -Wl,--format=default")
endif (WITH_SOFTCAM)
endif (NOT DEFINED ENV{ANDROID_STANDALONE_TOOLCHAIN})
endif (NOT DEFINED ENV{ANDROID_NDK})
endif (NOT OSCamOperatingSystem MATCHES "Mac OS X")

#----------------------- installation -----------------------------

file (GLOB config_files "${CMAKE_CURRENT_SOURCE_DIR}/Distribution/oscam.*")
Expand Down Expand Up @@ -825,4 +856,11 @@ endif(STATIC_LIBUSB EQUAL 1)
endif(STATICLIBUSB AND NOT LIBUSBDIR)
endif (HAVE_LIBUSB)

if (WITH_EMU)
message (STATUS " Compile with EMU support")
if (WITH_SOFTCAM)
message (STATUS " SoftCam.Key will be linked as well")
endif (WITH_SOFTCAM)
endif (WITH_EMU)

message (STATUS "")
14 changes: 14 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,20 @@ SRC-$(CONFIG_CS_CACHEEX) += module-cccam-cacheex.c
SRC-$(CONFIG_MODULE_CCCAM) += module-cccam.c
SRC-$(CONFIG_MODULE_CCCSHARE) += module-cccshare.c
SRC-$(CONFIG_MODULE_CONSTCW) += module-constcw.c
SRC-$(CONFIG_WITH_EMU) += module-emulator.c
ifeq "$(CONFIG_WITH_EMU)" "y"
ifeq "$(CONFIG_WITH_SOFTCAM)" "y"
UNAME := $(shell uname -s)
ifneq ($(UNAME),Darwin)
ifndef ANDROID_NDK
ifndef ANDROID_STANDALONE_TOOLCHAIN
TOUCH_SK := $(shell touch SoftCam.Key)
override LDFLAGS += -Wl,--format=binary -Wl,SoftCam.Key -Wl,--format=default
endif
endif
endif
endif
endif
SRC-$(CONFIG_CS_CACHEEX) += module-csp.c
SRC-$(CONFIG_CW_CYCLE_CHECK) += module-cw-cycle-check.c
SRC-$(CONFIG_WITH_AZBOX) += module-dvbapi-azbox.c
Expand Down
2 changes: 2 additions & 0 deletions config.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#ifndef CONFIG_H_
#define CONFIG_H_

#define WITH_EMU 1
#define WITH_SOFTCAM 1
#define WEBIF 1
#define WEBIF_LIVELOG 1
#define WEBIF_JQUERY 1
Expand Down
20 changes: 14 additions & 6 deletions config.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/sh

addons="WEBIF WEBIF_LIVELOG WEBIF_JQUERY TOUCH WITH_SSL HAVE_DVBAPI WITH_NEUTRINO READ_SDT_CHARSETS IRDETO_GUESSING CS_ANTICASC WITH_DEBUG MODULE_MONITOR WITH_LB CS_CACHEEX CW_CYCLE_CHECK LCDSUPPORT LEDSUPPORT CLOCKFIX IPV6SUPPORT"
addons="WEBIF WEBIF_LIVELOG WEBIF_JQUERY TOUCH WITH_SSL HAVE_DVBAPI WITH_NEUTRINO READ_SDT_CHARSETS IRDETO_GUESSING CS_ANTICASC WITH_DEBUG MODULE_MONITOR WITH_LB CS_CACHEEX CW_CYCLE_CHECK LCDSUPPORT LEDSUPPORT CLOCKFIX IPV6SUPPORT WITH_EMU WITH_SOFTCAM"
protocols="MODULE_CAMD33 MODULE_CAMD35 MODULE_CAMD35_TCP MODULE_NEWCAMD MODULE_CCCAM MODULE_CCCSHARE MODULE_GBOX MODULE_RADEGAST MODULE_SCAM MODULE_SERIAL MODULE_CONSTCW MODULE_PANDORA MODULE_GHTTP"
readers="READER_NAGRA READER_NAGRA_MERLIN READER_IRDETO READER_CONAX READER_CRYPTOWORKS READER_SECA READER_VIACCESS READER_VIDEOGUARD READER_DRE READER_TONGFANG READER_BULCRYPT READER_GRIFFIN READER_DGCRYPT"
card_readers="CARDREADER_PHOENIX CARDREADER_INTERNAL CARDREADER_SC8IN1 CARDREADER_MP35 CARDREADER_SMARGO CARDREADER_DB2COM CARDREADER_STAPI CARDREADER_STAPI5 CARDREADER_STINGER CARDREADER_DRECAS"
Expand All @@ -25,6 +25,8 @@ CONFIG_WITH_LB=y
# CONFIG_LEDSUPPORT=n
# CONFIG_CLOCKFIX=n
# CONFIG_IPV6SUPPORT=n
# CONFIG_WITH_EMU=n
# CONFIG_WITH_SOFTCAM=n
# CONFIG_MODULE_CAMD33=n
CONFIG_MODULE_CAMD35=y
CONFIG_MODULE_CAMD35_TCP=y
Expand Down Expand Up @@ -292,12 +294,16 @@ get_opts() {

update_deps() {
# Calculate dependencies
enabled_any $(get_opts readers) $(get_opts card_readers) && enable_opt WITH_CARDREADER >/dev/null
disabled_all $(get_opts readers) $(get_opts card_readers) && disable_opt WITH_CARDREADER >/dev/null
enabled_any $(get_opts readers) $(get_opts card_readers) WITH_EMU && enable_opt WITH_CARDREADER >/dev/null
disabled_all $(get_opts readers) $(get_opts card_readers) WITH_EMU && disable_opt WITH_CARDREADER >/dev/null
disabled WEBIF && disable_opt WEBIF_LIVELOG >/dev/null
disabled WEBIF && disable_opt WEBIF_JQUERY >/dev/null
enabled MODULE_CCCSHARE && enable_opt MODULE_CCCAM >/dev/null
enabled_any CARDREADER_DB2COM CARDREADER_MP35 CARDREADER_SC8IN1 CARDREADER_STINGER && enable_opt CARDREADER_PHOENIX >/dev/null
enabled WITH_EMU && enable_opt READER_VIACCESS >/dev/null
enabled WITH_EMU && enable_opt READER_DRE >/dev/null
enabled WITH_EMU && enable_opt MODULE_NEWCAMD >/dev/null
disabled WITH_EMU && disable_opt WITH_SOFTCAM >/dev/null
}

list_config() {
Expand Down Expand Up @@ -347,9 +353,9 @@ list_config() {
not_have_flag USE_LIBCRYPTO && echo "CONFIG_LIB_AES=y" || echo "# CONFIG_LIB_AES=n"
enabled MODULE_CCCAM && echo "CONFIG_LIB_RC6=y" || echo "# CONFIG_LIB_RC6=n"
not_have_flag USE_LIBCRYPTO && enabled MODULE_CCCAM && echo "CONFIG_LIB_SHA1=y" || echo "# CONFIG_LIB_SHA1=n"
enabled_any READER_DRE MODULE_SCAM READER_VIACCESS READER_NAGRA_MERLIN && echo "CONFIG_LIB_DES=y" || echo "# CONFIG_LIB_DES=n"
enabled_any MODULE_CCCAM READER_NAGRA READER_NAGRA_MERLIN READER_SECA && echo "CONFIG_LIB_IDEA=y" || echo "# CONFIG_LIB_IDEA=n"
not_have_flag USE_LIBCRYPTO && enabled_any READER_CONAX READER_CRYPTOWORKS READER_NAGRA READER_NAGRA_MERLIN && echo "CONFIG_LIB_BIGNUM=y" || echo "# CONFIG_LIB_BIGNUM=n"
enabled_any READER_DRE MODULE_SCAM READER_VIACCESS READER_NAGRA_MERLIN WITH_EMU && echo "CONFIG_LIB_DES=y" || echo "# CONFIG_LIB_DES=n"
enabled_any MODULE_CCCAM READER_NAGRA READER_NAGRA_MERLIN READER_SECA WITH_EMU && echo "CONFIG_LIB_IDEA=y" || echo "# CONFIG_LIB_IDEA=n"
not_have_flag USE_LIBCRYPTO && enabled_any READER_CONAX READER_CRYPTOWORKS READER_NAGRA READER_NAGRA_MERLIN WITH_EMU && echo "CONFIG_LIB_BIGNUM=y" || echo "# CONFIG_LIB_BIGNUM=n"
enabled READER_NAGRA_MERLIN && echo "CONFIG_LIB_MDC2=y" || echo "# CONFIG_LIB_MDC2=n"
enabled READER_NAGRA_MERLIN && echo "CONFIG_LIB_FAST_AES=y" || echo "# CONFIG_LIB_FAST_AES=n"
enabled READER_NAGRA_MERLIN && echo "CONFIG_LIB_SHA256=y" || echo "# CONFIG_LIB_SHA256=n"
Expand Down Expand Up @@ -465,6 +471,8 @@ menu_addons() {
LEDSUPPORT "LED support" $(check_test "LEDSUPPORT") \
CLOCKFIX "Clockfix (disable on old systems!)" $(check_test "CLOCKFIX") \
IPV6SUPPORT "IPv6 support (experimental)" $(check_test "IPV6SUPPORT") \
WITH_EMU "Emulator support" $(check_test "WITH_EMU") \
WITH_SOFTCAM "Built-in SoftCam.Key" $(check_test "WITH_SOFTCAM") \
2> ${tempfile}

opt=${?}
Expand Down
1 change: 1 addition & 0 deletions csctapi/cardreaders.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ extern const struct s_cardreader cardreader_smartreader;
extern const struct s_cardreader cardreader_stapi;
extern const struct s_cardreader cardreader_stinger;
extern const struct s_cardreader cardreader_drecas;
extern const struct s_cardreader cardreader_emu;

#endif
39 changes: 38 additions & 1 deletion globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -390,15 +390,19 @@
// Support for multiple CWs per channel and other encryption algos
//#define WITH_EXTENDED_CW 1

#if defined(READER_DRE) || defined(READER_DRECAS) || defined(READER_VIACCESS)
#if defined(READER_DRE) || defined(READER_DRECAS) || defined(READER_VIACCESS) || defined(WITH_EMU)
#define MAX_ECM_SIZE 1024
#define MAX_EMM_SIZE 1024
#else
#define MAX_ECM_SIZE 596
#define MAX_EMM_SIZE 512
#endif

#ifdef WITH_EMU
#define CS_EMMCACHESIZE 1024 // nr of EMMs that EMU reader will cache
#else
#define CS_EMMCACHESIZE 512 // nr of EMMs that each reader will cache
#endif
#define MSGLOGSIZE 64 // size of string buffer for a ecm to return messages

#define D_TRACE 0x0001 // Generate very detailed error/trace messages per routine
Expand Down Expand Up @@ -430,6 +434,7 @@
#define R_SMART 0x7 // Smartreader+
#define R_PCSC 0x8 // PCSC
#define R_DRECAS 0x9 // Reader DRECAS
#define R_EMU 0x17 // Reader EMU
/////// proxy readers after R_CS378X
#define R_CAMD35 0x20 // Reader cascading camd 3.5x
#define R_CAMD33 0x21 // Reader cascading camd 3.3x
Expand Down Expand Up @@ -858,6 +863,13 @@ typedef struct s_entitlement // contains entitlement Info
uint32_t class; // the class needed for some systems
time_t start; // startdate
time_t end; // enddate
#ifdef WITH_EMU
bool isKey;
bool isData;
char name[8];
uint8_t *key;
uint32_t keyLength;
#endif
} S_ENTITLEMENT;

struct s_client;
Expand Down Expand Up @@ -972,6 +984,7 @@ struct s_cardsystem
void (*post_process)(struct s_reader *);
int32_t (*get_emm_type)(struct emm_packet_t *, struct s_reader *);
int32_t (*get_emm_filter)(struct s_reader *, struct s_csystem_emm_filter **, uint32_t *);
int32_t (*get_emm_filter_adv)(struct s_reader *, struct s_csystem_emm_filter **, uint32_t *, uint16_t, uint32_t, uint16_t);
int32_t (*get_tunemm_filter)(struct s_reader *, struct s_csystem_emm_filter **, uint32_t *);
};

Expand Down Expand Up @@ -1767,6 +1780,14 @@ struct s_reader // contains device info, reader info and card info
#endif
#ifdef MODULE_GHTTP
uint8_t ghttp_use_ssl;
#endif
#ifdef WITH_EMU
FTAB emu_auproviders; // AU providers for Emu reader
int8_t emu_datecodedenabled; // date-coded keys for BISS
char *extee36; // path to "ee36.bin" - Set by the user via the webif
char *extee56; // path to "ee56.bin" - Set by the user via the webif
uint8_t dre36_force_group;
uint8_t dre56_force_group;
#endif
uint8_t cnxlastecm; // == 0 - last ecm has not been paired ecm, > 0 last ecm has been paired ecm
LLIST *emmstat; // emm stats
Expand Down Expand Up @@ -2267,6 +2288,18 @@ struct s_config
struct s_ip *scam_allowed;
#endif

#ifdef WITH_EMU
char *emu_stream_source_host;
int32_t emu_stream_source_port;
char *emu_stream_source_auth_user;
char *emu_stream_source_auth_password;
int32_t emu_stream_relay_port;
uint32_t emu_stream_ecm_delay;
int8_t emu_stream_relay_enabled;
int8_t emu_stream_emm_enabled;
CAIDTAB emu_stream_relay_ctab; // use the stream server for these caids
#endif

int32_t max_cache_time; // seconds ecms are stored in ecmcwcache
int32_t max_hitcache_time; // seconds hits are stored in cspec_hitcache (to detect dyn wait_time)

Expand Down Expand Up @@ -2438,4 +2471,8 @@ static inline bool caid_is_bulcrypt(uint16_t caid) { return caid == 0x5581 || ca
static inline bool caid_is_dre(uint16_t caid) { return caid == 0x4AE0 || caid == 0x4AE1 || caid == 0x2710;}
const char *get_cardsystem_desc_by_caid(uint16_t caid);

#ifdef WITH_EMU
FILTER *get_emu_prids_for_caid(struct s_reader *rdr, uint16_t caid);
#endif

#endif
70 changes: 67 additions & 3 deletions module-dvbapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -1697,7 +1697,14 @@ void dvbapi_start_emm_filter(int32_t demux_index)

if(match)
{
csystem = get_cardsystem_by_caid(caid);
if(rdr->typ == R_EMU)
{
csystem = rdr->csystem;
}
else
{
csystem = get_cardsystem_by_caid(caid);
}
if(csystem)
{
if(caid != ncaid)
Expand All @@ -1717,7 +1724,14 @@ void dvbapi_start_emm_filter(int32_t demux_index)
}
else if(csystem->get_emm_filter)
{
csystem->get_emm_filter(rdr, &dmx_filter, &filter_count);
if(rdr->typ == R_EMU)
{
csystem->get_emm_filter_adv(rdr, &dmx_filter, &filter_count, caid, provid, demux[demux_index].program_number);
}
else
{
csystem->get_emm_filter(rdr, &dmx_filter, &filter_count);
}
}
}
else
Expand Down Expand Up @@ -5141,6 +5155,7 @@ void dvbapi_process_input(int32_t demux_id, int32_t filter_num, uint8_t *buffer,
if(filtertype == TYPE_ECM)
{
uint32_t chid = 0x10000;
int8_t pvu_skip = 0;
ECM_REQUEST *er;
if(len != 0) // len = 0 receiver encountered an internal bufferoverflow!
{
Expand Down Expand Up @@ -5169,7 +5184,24 @@ void dvbapi_process_input(int32_t demux_id, int32_t filter_num, uint8_t *buffer,
return;
}

if(curpid->table == buffer[0] && !caid_is_irdeto(curpid->CAID)) // wait for odd / even ecm change (only not for irdeto!)
#ifdef WITH_EMU
if(caid_is_powervu(curpid->CAID)) // ecm counter for powervu
{
pvu_skip = 1;

if(sctlen - 11 > buffer[9])
{
if(buffer[11 + buffer[9]] > curpid->pvu_counter
|| (curpid->pvu_counter == 255 && buffer[11 + buffer[9]] == 0)
|| ((curpid->pvu_counter - buffer[11 + buffer[9]]) > 5))
{
curpid->pvu_counter = buffer[11 + buffer[9]];
pvu_skip = 0;
}
}
}
#endif
if((curpid->table == buffer[0] && !caid_is_irdeto(curpid->CAID)) || pvu_skip) // wait for odd / even ecm change (only not for irdeto!)
{
if(!(er = get_ecmtask()))
{
Expand Down Expand Up @@ -5498,6 +5530,35 @@ void dvbapi_process_input(int32_t demux_id, int32_t filter_num, uint8_t *buffer,
return;
}

#ifdef WITH_EMU
if(caid_is_director(demux[demux_id].demux_fd[filter_num].caid))
{
uint32_t i;
uint32_t emmhash;

if(sctlen < 4)
{
return;
}

for(i = 0; i + 2 < sctlen; i++)
{
if(buffer[i] == 0xF0 && (buffer[i + 2] == 0xE1 || buffer[i + 2] == 0xE4))
{
emmhash = (buffer[3] << 8) | buffer[sctlen - 2];
if(demux[demux_id].demux_fd[filter_num].cadata == emmhash)
{
return;
}

demux[demux_id].demux_fd[filter_num].cadata = emmhash;
dvbapi_process_emm(demux_id, filter_num, buffer, sctlen);
return;
}
}
return;
}
#endif
// fix to handle more than one irdeto emm packet
uint8_t *pbuf = buffer;
int32_t done = 0;
Expand Down Expand Up @@ -7151,6 +7212,9 @@ void dvbapi_send_dcw(struct s_client *client, ECM_REQUEST *er)

delayer(er, delay);

#ifdef WITH_EMU
if(!chk_ctab_ex(er->caid, &cfg.emu_stream_relay_ctab) || !cfg.emu_stream_relay_enabled)
#endif
switch(selected_api)
{
#if defined(WITH_STAPI) || defined(WITH_STAPI5)
Expand Down
6 changes: 6 additions & 0 deletions module-dvbapi.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,9 @@ struct s_ecmpids
int8_t useMultipleIndices;
uint32_t streams;
uint32_t cadata;
#ifdef WITH_EMU
int16_t pvu_counter;
#endif
};

typedef struct filter_s
Expand All @@ -163,6 +166,9 @@ typedef struct filter_s
uint32_t SlotHandle[10];
uint32_t BufferHandle[10];
#endif
#ifdef WITH_EMU
uint32_t cadata;
#endif
} FILTERTYPE;

struct s_emmpids
Expand Down
Loading

0 comments on commit 0e0c23c

Please sign in to comment.