1 | #ifndef READER_COMMON_H_
|
---|
2 | #define READER_COMMON_H_
|
---|
3 |
|
---|
4 | //Warning: OK = 0 and ERROR = 1 in csctapi !!!
|
---|
5 | #define SKIPPED 2
|
---|
6 | #define OK 1
|
---|
7 | #define ERROR 0
|
---|
8 |
|
---|
9 | #include "csctapi/atr.h"
|
---|
10 | #include "oscam-string.h"
|
---|
11 | #include "oscam-reader.h"
|
---|
12 |
|
---|
13 | int32_t reader_cmd2icc(struct s_reader *reader, const uchar *buf, const int32_t l, uchar *response, uint16_t *response_length);
|
---|
14 | int32_t card_write(struct s_reader *reader, const uchar *, const uchar *, uchar *, uint16_t *);
|
---|
15 |
|
---|
16 | #define write_cmd(cmd, data) \
|
---|
17 | { \
|
---|
18 | if (card_write(reader, cmd, data, cta_res, &cta_lr)) return ERROR; \
|
---|
19 | }
|
---|
20 |
|
---|
21 | #define get_atr \
|
---|
22 | unsigned char atr[ATR_MAX_SIZE]; \
|
---|
23 | uint32_t atr_size; \
|
---|
24 | memset(atr, 0, sizeof(atr)); \
|
---|
25 | ATR_GetRaw(newatr, atr, &atr_size);
|
---|
26 |
|
---|
27 | #define get_hist \
|
---|
28 | unsigned char hist[ATR_MAX_HISTORICAL]; \
|
---|
29 | uint32_t hist_size = 0; \
|
---|
30 | ATR_GetHistoricalBytes(newatr, hist, &hist_size);
|
---|
31 |
|
---|
32 | #define def_resp \
|
---|
33 | unsigned char cta_res[CTA_RES_LEN]; \
|
---|
34 | memset(cta_res, 0, CTA_RES_LEN); \
|
---|
35 | uint16_t cta_lr;
|
---|
36 |
|
---|
37 | #ifdef WITH_CARDREADER
|
---|
38 | void cardreader_init_locks(void);
|
---|
39 | bool cardreader_init(struct s_reader *reader);
|
---|
40 | void cardreader_close(struct s_reader *reader);
|
---|
41 | void cardreader_do_reset(struct s_reader *reader);
|
---|
42 | void cardreader_reset(struct s_client *cl);
|
---|
43 | int32_t cardreader_do_checkhealth(struct s_reader *reader);
|
---|
44 | void cardreader_checkhealth(struct s_client *cl, struct s_reader *rdr);
|
---|
45 | int32_t cardreader_do_emm(struct s_reader *reader, EMM_PACKET *ep);
|
---|
46 | void cardreader_process_ecm(struct s_reader *reader, struct s_client *cl, ECM_REQUEST *er);
|
---|
47 | void cardreader_get_card_info(struct s_reader *reader);
|
---|
48 | int32_t check_sct_len(const unsigned char *data, int32_t off);
|
---|
49 | #else
|
---|
50 | static inline void cardreader_init_locks(void) { }
|
---|
51 | static inline bool cardreader_init(struct s_reader *UNUSED(reader)) { return true; }
|
---|
52 | static inline void cardreader_close(struct s_reader *UNUSED(reader)) { }
|
---|
53 | static inline void cardreader_do_reset(struct s_reader *UNUSED(reader)) { return; }
|
---|
54 | static inline void cardreader_reset(struct s_client *UNUSED(cl)) { }
|
---|
55 | static inline int32_t cardreader_do_checkhealth(struct s_reader *UNUSED(reader)) { return false; }
|
---|
56 | static inline void cardreader_checkhealth(struct s_client *UNUSED(cl), struct s_reader *UNUSED(rdr)) { }
|
---|
57 | static inline int32_t cardreader_do_emm(struct s_reader *UNUSED(reader), EMM_PACKET *UNUSED(ep)) { return 0; }
|
---|
58 | static inline void cardreader_process_ecm(struct s_reader *UNUSED(reader), struct s_client *UNUSED(cl), ECM_REQUEST *UNUSED(er)) { }
|
---|
59 | static inline void cardreader_get_card_info(struct s_reader *UNUSED(reader)) { }
|
---|
60 | #endif
|
---|
61 |
|
---|
62 | #endif
|
---|