libosmosim 1.13.1.1-afb4 Osmocom SIM library

Data Structures | Macros | Functions | Variables
reader_pcsc.c File Reference

PC/SC Card reader backend for libosmosim. More...

`#include <string.h>`
`#include <stdint.h>`
`#include <stdio.h>`
`#include <errno.h>`
`#include <osmocom/core/talloc.h>`
`#include <osmocom/sim/sim.h>`
`#include <wintypes.h>`
`#include <winscard.h>`
`#include "sim_int.h"`

## Data Structures
struct | pcsc_reader_state

## Macros
#define | PCSC_ERROR(rv, text)

## Functions
static int | pcsc_get_atr (struct osim_card_hdl *card)
static struct osim_reader_hdl * | pcsc_reader_open (int num, const char *id, void *ctx)
static struct osim_card_hdl * | pcsc_card_open (struct osim_reader_hdl *rh, enum osim_proto proto)
static int | pcsc_card_reset (struct osim_card_hdl *card, bool cold_reset)
static int | pcsc_card_close (struct osim_card_hdl *card)
static int | pcsc_transceive (struct osim_reader_hdl *rh, struct msgb *msg)

## Variables
const struct osim_reader_ops | pcsc_reader_ops

## Detailed Description

PC/SC Card reader backend for libosmosim.

## Macro Definition Documentation

## ◆ PCSC_ERROR

#define PCSC_ERROR | ( |  | rv,
|  |  | text
| ) |  |

Value:
if (rv != SCARD_S_SUCCESS) { \
fprintf(stderr, text ": %s (0x%lX)\n", pcsc_stringify_error(rv), rv); \
goto end; \
}

## Function Documentation

## ◆ pcsc_card_close()

static int pcsc_card_close | ( | struct osim_card_hdl * | card | ) |
| static

References pcsc_reader_state::hCard, PCSC_ERROR, osim_reader_hdl::priv, and osim_card_hdl::reader.

## ◆ pcsc_card_open()

static struct osim_card_hdl * pcsc_card_open | ( | struct osim_reader_hdl * | rh,
|  | enum osim_proto | proto
| ) |  |
| static

References osim_card_hdl::apps, osim_reader_hdl::card, osim_chan_hdl::card, osim_card_hdl::channels, pcsc_reader_state::dwActiveProtocol, pcsc_reader_state::hCard, pcsc_reader_state::hContext, INIT_LLIST_HEAD, osim_chan_hdl::list, llist_add(), pcsc_reader_state::name, OSIM_PROTO_T0, PCSC_ERROR, pcsc_get_atr(), pcsc_reader_state::pioSendPci, osim_reader_hdl::priv, and osim_card_hdl::reader.

## ◆ pcsc_card_reset()

static int pcsc_card_reset | ( | struct osim_card_hdl * | card,
|  | bool | cold_reset
| ) |  |
| static

References pcsc_reader_state::dwActiveProtocol, pcsc_reader_state::hCard, PCSC_ERROR, osim_reader_hdl::priv, and osim_card_hdl::reader.

## ◆ pcsc_get_atr()

static int pcsc_get_atr | ( | struct osim_card_hdl * | card | ) |
| static

References osim_card_hdl::atr, osim_card_hdl::atr_len, osim_reader_hdl::card, pcsc_reader_state::hCard, PCSC_ERROR, osim_reader_hdl::priv, and osim_card_hdl::reader.

Referenced by pcsc_card_open().

## ◆ pcsc_reader_open()

static struct osim_reader_hdl * pcsc_reader_open | ( | int | num,
|  | const char * | id,
|  | void * | ctx
| ) |  |
| static

References pcsc_reader_state::dwActiveProtocol, pcsc_reader_state::hContext, pcsc_reader_state::name, PCSC_ERROR, and osim_reader_hdl::priv.

## ◆ pcsc_transceive()

static int pcsc_transceive | ( | struct osim_reader_hdl * | rh,
|  | struct msgb * | msg
| ) |  |
| static

References msgb::data, pcsc_reader_state::hCard, msgb_apdu_le, msgb_length(), msgb_put(), msgb_tailroom(), PCSC_ERROR, pcsc_reader_state::pioRecvPci, pcsc_reader_state::pioSendPci, osim_reader_hdl::priv, and msgb::tail.

## Variable Documentation

## ◆ pcsc_reader_ops

const struct osim_reader_ops pcsc_reader_ops

Initial value:
= {
.name = "PC/SC",
.reader_open = pcsc_reader_open,
.card_open = pcsc_card_open,
.card_reset = pcsc_card_reset,
.card_close = pcsc_card_close,
.transceive = pcsc_transceive,
}
pcsc_card_reset
static int pcsc_card_reset(struct osim_card_hdl *card, bool cold_reset)
Definition: reader_pcsc.c:155
pcsc_transceive
static int pcsc_transceive(struct osim_reader_hdl *rh, struct msgb *msg)
Definition: reader_pcsc.c:184
pcsc_reader_open
static struct osim_reader_hdl * pcsc_reader_open(int num, const char *id, void *ctx)
Definition: reader_pcsc.c:73
pcsc_card_open
static struct osim_card_hdl * pcsc_card_open(struct osim_reader_hdl *rh, enum osim_proto proto)
Definition: reader_pcsc.c:119
pcsc_card_close
static int pcsc_card_close(struct osim_card_hdl *card)
Definition: reader_pcsc.c:170

Referenced by osim_reader_open().