source: trunk/reader-common.h

Last change on this file was 11478, checked in by Gorgone Impertinence, 2 years ago

big cleanup pack 4

  • Property svn:eol-style set to LF
File size: 2.7 KB
RevLine 
[7688]1#ifndef READER_COMMON_H_
2#define READER_COMMON_H_
3
[1389]4//Warning: OK = 0 and ERROR = 1 in csctapi !!!
5#define SKIPPED 2
[8256]6#define OK 1
7#define ERROR 0
8
[8951]9#include "csctapi/atr.h"
[7585]10#include "oscam-string.h"
[8264]11#include "oscam-reader.h"
[7585]12
[11478]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 *);
[7688]15
[1951]16#define write_cmd(cmd, data) \
[11478]17 { \
18 if (card_write(reader, cmd, data, cta_res, &cta_lr)) return ERROR; \
19 }
[1951]20
[1389]21#define get_atr \
[11478]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);
[1389]26
[10037]27#define get_atr2 \
[11478]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);
[10037]32
[1389]33#define get_hist \
[11478]34 uint8_t hist[ATR_MAX_HISTORICAL]; \
35 uint32_t hist_size = 0; \
36 ATR_GetHistoricalBytes(newatr, hist, &hist_size);
[1389]37
[1951]38#define def_resp \
[11478]39 uint8_t cta_res[CTA_RES_LEN]; \
40 memset(cta_res, 0, CTA_RES_LEN); \
41 uint16_t cta_lr;
[7688]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);
[7692]49int32_t cardreader_do_checkhealth(struct s_reader *reader);
[7688]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);
[10376]54void cardreader_poll_status(struct s_reader *reader);
[11478]55int32_t check_sct_len(const uint8_t *data, int32_t off);
[7688]56#else
57static inline void cardreader_init_locks(void) { }
[8951]58static inline bool cardreader_init(struct s_reader *UNUSED(reader))
59{
[8960]60 return true;
[8951]61}
[7688]62static inline void cardreader_close(struct s_reader *UNUSED(reader)) { }
[8951]63static inline void cardreader_do_reset(struct s_reader *UNUSED(reader))
64{
[8960]65 return;
[8951]66}
[7688]67static inline void cardreader_reset(struct s_client *UNUSED(cl)) { }
[8951]68static inline int32_t cardreader_do_checkhealth(struct s_reader *UNUSED(reader))
69{
[8960]70 return false;
[8951]71}
[7688]72static inline void cardreader_checkhealth(struct s_client *UNUSED(cl), struct s_reader *UNUSED(rdr)) { }
[8951]73static inline int32_t cardreader_do_emm(struct s_reader *UNUSED(reader), EMM_PACKET *UNUSED(ep))
74{
[8960]75 return 0;
[8951]76}
[7688]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)) { }
[10376]79static inline void cardreader_poll_status(struct s_reader *UNUSED(reader)) { }
[7688]80#endif
81
82#endif
Note: See TracBrowser for help on using the repository browser.