Loading...
Searching...
No Matches
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; \
}

Referenced by pcsc_card_close(), pcsc_card_open(), pcsc_card_reset(), pcsc_get_atr(), pcsc_reader_open(), and pcsc_transceive().

## Function Documentation

## pcsc_card_close()

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()

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

static

References osim_card_hdl::apps, osim_chan_hdl::card, osim_reader_hdl::card, osim_card_hdl::channels, pcsc_reader_state::dwActiveProtocol, pcsc_reader_state::hCard, pcsc_reader_state::hContext, osim_chan_hdl::list, 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()

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()

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()

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()

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

static

References pcsc_reader_state::hCard, msgb_apdu_le, PCSC_ERROR, pcsc_reader_state::pioRecvPci, pcsc_reader_state::pioSendPci, and osim_reader_hdl::priv.

## 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().