source: trunk/reader-common.h

Last change on this file was 11478, checked in by Gorgone Impertinence, 23 months ago

big cleanup pack 4

  • Property svn:eol-style set to LF
File size: 2.7 KB
Line 
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
13int32_t reader_cmd2icc(struct s_reader *reader, const uint8_t *buf, const int32_t l, uint8_t *response, uint16_t *response_length);
14int32_t card_write(struct s_reader *reader, const uint8_t *, const uint8_t *, uint8_t *, 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 uint8_t 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_atr2 \
28 uint8_t atr2[ATR_MAX_SIZE]; \
29 uint32_t atr_size2; \
30 memset(atr2, 0, sizeof(atr2)); \
31 ATR_GetRaw(newatr, atr2, &atr_size2);
32
33#define get_hist \
34 uint8_t hist[ATR_MAX_HISTORICAL]; \
35 uint32_t hist_size = 0; \
36 ATR_GetHistoricalBytes(newatr, hist, &hist_size);
37
38#define def_resp \
39 uint8_t cta_res[CTA_RES_LEN]; \
40 memset(cta_res, 0, CTA_RES_LEN); \
41 uint16_t cta_lr;
42
43#ifdef WITH_CARDREADER
44void cardreader_init_locks(void);
45bool cardreader_init(struct s_reader *reader);
46void cardreader_close(struct s_reader *reader);
47void cardreader_do_reset(struct s_reader *reader);
48void cardreader_reset(struct s_client *cl);
49int32_t cardreader_do_checkhealth(struct s_reader *reader);
50void cardreader_checkhealth(struct s_client *cl, struct s_reader *rdr);
51int32_t cardreader_do_emm(struct s_reader *reader, EMM_PACKET *ep);
52void cardreader_process_ecm(struct s_reader *reader, struct s_client *cl, ECM_REQUEST *er);
53void cardreader_get_card_info(struct s_reader *reader);
54void cardreader_poll_status(struct s_reader *reader);
55int32_t check_sct_len(const uint8_t *data, int32_t off);
56#else
57static inline void cardreader_init_locks(void) { }
58static inline bool cardreader_init(struct s_reader *UNUSED(reader))
59{
60 return true;
61}
62static inline void cardreader_close(struct s_reader *UNUSED(reader)) { }
63static inline void cardreader_do_reset(struct s_reader *UNUSED(reader))
64{
65 return;
66}
67static inline void cardreader_reset(struct s_client *UNUSED(cl)) { }
68static inline int32_t cardreader_do_checkhealth(struct s_reader *UNUSED(reader))
69{
70 return false;
71}
72static inline void cardreader_checkhealth(struct s_client *UNUSED(cl), struct s_reader *UNUSED(rdr)) { }
73static inline int32_t cardreader_do_emm(struct s_reader *UNUSED(reader), EMM_PACKET *UNUSED(ep))
74{
75 return 0;
76}
77static inline void cardreader_process_ecm(struct s_reader *UNUSED(reader), struct s_client *UNUSED(cl), ECM_REQUEST *UNUSED(er)) { }
78static inline void cardreader_get_card_info(struct s_reader *UNUSED(reader)) { }
79static inline void cardreader_poll_status(struct s_reader *UNUSED(reader)) { }
80#endif
81
82#endif
Note: See TracBrowser for help on using the repository browser.