qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Alon Levy <alevy@redhat.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH 07/20] introduce libcacard/vscard_common.h
Date: Wed,  2 Feb 2011 22:28:07 +0200	[thread overview]
Message-ID: <1296678500-19497-8-git-send-email-alevy@redhat.com> (raw)
In-Reply-To: <1296678500-19497-1-git-send-email-alevy@redhat.com>

Signed-off-by: Alon Levy <alevy@redhat.com>
---
 libcacard/vscard_common.h |  130 +++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 130 insertions(+), 0 deletions(-)
 create mode 100644 libcacard/vscard_common.h

diff --git a/libcacard/vscard_common.h b/libcacard/vscard_common.h
new file mode 100644
index 0000000..9ff1295
--- /dev/null
+++ b/libcacard/vscard_common.h
@@ -0,0 +1,130 @@
+/* Virtual Smart Card protocol definition
+ *
+ * This protocol is between a host implementing a group of virtual smart card
+ * reader, and a client implementing a virtual smart card, or passthrough to
+ * a real card.
+ *
+ * The current implementation passes the raw APDU's from 7816 and additionally
+ * contains messages to setup and teardown readers, handle insertion and
+ * removal of cards, negotiate the protocol and provide for error responses.
+ *
+ * Copyright (c) 2010 Red Hat.
+ *
+ * This code is licensed under the LGPL.
+ */
+
+#ifndef _VSCARD_COMMON_H
+#define _VSCARD_COMMON_H
+
+#include <stdint.h>
+
+#define VERSION_MAJOR_BITS 11
+#define VERSION_MIDDLE_BITS 11
+#define VERSION_MINOR_BITS 10
+
+#define MAKE_VERSION(major, middle, minor) \
+     (  (major  << (VERSION_MINOR_BITS + VERSION_MIDDLE_BITS)) \
+      | (middle <<  VERSION_MINOR_BITS) \
+      | (minor)  )
+
+/** IMPORTANT NOTE on VERSION
+ *
+ * The version below MUST be changed whenever a change in this file is made.
+ *
+ * The last digit, the minor, is for bug fix changes only.
+ *
+ * The middle digit is for backward / forward compatible changes, updates
+ * to the existing messages, addition of fields.
+ *
+ * The major digit is for a breaking change of protocol, presumably
+ * something that cannot be accomodated with the existing protocol.
+ */
+
+#define VSCARD_VERSION MAKE_VERSION(0,0,1)
+
+typedef enum {
+    VSC_Init,
+    VSC_Error,
+    VSC_ReaderAdd,
+    VSC_ReaderAddResponse,
+    VSC_ReaderRemove,
+    VSC_ATR,
+    VSC_CardRemove,
+    VSC_APDU,
+    VSC_Reconnect
+} VSCMsgType;
+
+typedef enum {
+    VSC_GENERAL_ERROR=1,
+    VSC_CANNOT_ADD_MORE_READERS,
+} VSCErrorCode;
+
+typedef uint32_t reader_id_t;
+#define VSCARD_UNDEFINED_READER_ID 0xffffffff
+#define VSCARD_MINIMAL_READER_ID    0
+
+typedef struct VSCMsgHeader {
+    VSCMsgType type;
+    reader_id_t   reader_id;
+    uint32_t   length;
+    uint8_t    data[0];
+} VSCMsgHeader;
+
+/* VSCMsgInit               Client <-> Host
+ * Host replies with allocated reader id in ReaderAddResponse
+ * */
+typedef struct VSCMsgInit {
+    uint32_t   version;
+} VSCMsgInit;
+
+/* VSCMsgError              Client <-> Host
+ * */
+typedef struct VSCMsgError {
+    uint32_t   code;
+} VSCMsgError;
+
+/* VSCMsgReaderAdd          Client -> Host
+ * Host replies with allocated reader id in ReaderAddResponse
+ * name - name of the reader on client side.
+ * */
+typedef struct VSCMsgReaderAdd {
+    uint8_t    name[0];
+} VSCMsgReaderAdd;
+
+/* VSCMsgReaderAddResponse  Host -> Client
+ * Reply to ReaderAdd
+ * */
+typedef struct VSCMsgReaderAddResponse {
+} VSCMsgReaderAddResponse;
+
+/* VSCMsgReaderRemove       Client -> Host
+ * */
+typedef struct VSCMsgReaderRemove {
+} VSCMsgReaderRemove;
+
+/* VSCMsgATR                Client -> Host
+ * Answer to reset. Sent for card insertion or card reset.
+ * */
+typedef struct VSCMsgATR {
+    uint8_t     atr[0];
+} VSCMsgATR;
+
+/* VSCMsgCardRemove         Client -> Host
+ * */
+typedef struct VSCMsgCardRemove {
+} VSCMsgCardRemove;
+
+/* VSCMsgAPDU               Client <-> Host
+ * */
+typedef struct VSCMsgAPDU {
+    uint8_t    data[0];
+} VSCMsgAPDU;
+
+/* VSCMsgReconnect          Host -> Client
+ * */
+typedef struct VSCMsgReconnect {
+    uint32_t   ip;
+    uint16_t   port;
+} VSCMsgReconnect;
+
+#endif
-- 
1.7.4

  parent reply	other threads:[~2011-02-02 20:28 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-02 20:28 [Qemu-devel] [PATCH 00/20] usb-ccid (v16) Alon Levy
2011-02-02 20:28 ` [Qemu-devel] [PATCH 01/20] qdev: add print_options callback Alon Levy
2011-02-03 16:39   ` Anthony Liguori
2011-02-03 20:54     ` Alon Levy
2011-02-02 20:28 ` [Qemu-devel] [PATCH 02/20] qdev: add data pointer to Property Alon Levy
2011-02-02 20:28 ` [Qemu-devel] [PATCH 03/20] qdev-properties: add PROP_TYPE_ENUM Alon Levy
2011-02-03 16:44   ` Anthony Liguori
2011-02-03 20:59     ` Alon Levy
2011-02-02 20:28 ` [Qemu-devel] [PATCH 04/20] qdev-properties: parse_enum: don't cast a void* Alon Levy
2011-02-02 20:28 ` [Qemu-devel] [PATCH 05/20] usb-ccid: add CCID bus Alon Levy
2011-02-03 16:46   ` Anthony Liguori
2011-02-03 18:53     ` Alon Levy
2011-02-03 19:29       ` Alon Levy
2011-02-02 20:28 ` [Qemu-devel] [PATCH 06/20] usb-ccid: review fixes (v15-v16) Alon Levy
2011-02-03 16:48   ` Anthony Liguori
2011-02-03 18:53     ` Alon Levy
2011-02-02 20:28 ` Alon Levy [this message]
2011-02-02 20:28 ` [Qemu-devel] [PATCH 08/20] libcacard/vscard_common.h update (v15->v16) Alon Levy
2011-02-02 20:28 ` [Qemu-devel] [PATCH 09/20] ccid: add passthru card device Alon Levy
2011-02-02 20:28 ` [Qemu-devel] [PATCH 10/20] ccid-card-passthru: review fixes (v15->v16) Alon Levy
2011-02-02 20:28 ` [Qemu-devel] [PATCH 11/20] libcacard: initial commit after coding style fixes Alon Levy
2011-02-02 20:28 ` [Qemu-devel] [PATCH 12/20] libcacard: fixes from review (v15->v16) Alon Levy
2011-02-02 20:28 ` [Qemu-devel] [PATCH 13/20] ccid: add ccid-card-emulated device (v2) Alon Levy
2011-02-02 20:28 ` [Qemu-devel] [PATCH 14/20] ccid-card-emulated: use PROP_TYPE_ENUM for backend Alon Levy
2011-02-02 20:28 ` [Qemu-devel] [PATCH 15/20] ccid-card-emulated: review fixes (v15->v16) Alon Levy
2011-02-02 20:28 ` [Qemu-devel] [PATCH 16/20] ccid: add docs Alon Levy
2011-02-02 20:28 ` [Qemu-devel] [PATCH 17/20] ccid: configure: add --enable/disable and nss only disable Alon Levy
2011-02-02 20:28 ` [Qemu-devel] [PATCH 18/20] ccid: add qdev description strings Alon Levy
2011-02-02 20:28 ` [Qemu-devel] [PATCH 19/20] smartcard, configure: add --enable-smartcard-nss, report only nss Alon Levy
2011-02-02 20:28 ` [Qemu-devel] [PATCH 20/20] smartcard,configure: " Alon Levy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1296678500-19497-8-git-send-email-alevy@redhat.com \
    --to=alevy@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).