From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=58419 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q4EGR-0001ef-QY for qemu-devel@nongnu.org; Mon, 28 Mar 2011 11:21:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Q4EGQ-0007zB-Jl for qemu-devel@nongnu.org; Mon, 28 Mar 2011 11:21:55 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40151) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Q4EGQ-0007yy-AQ for qemu-devel@nongnu.org; Mon, 28 Mar 2011 11:21:54 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p2SFLqpt021472 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 28 Mar 2011 11:21:52 -0400 Date: Mon, 28 Mar 2011 17:21:47 +0200 From: Alon Levy Subject: Re: [Qemu-devel] [PATCH v23 08/11] libcacard: add passthru Message-ID: <20110328152146.GE2741@playa.redhat.com> References: <1300886393-2799-1-git-send-email-alevy@redhat.com> <1300886393-2799-9-git-send-email-alevy@redhat.com> <4D908CD5.5030301@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4D908CD5.5030301@redhat.com> List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Jes Sorensen Cc: qemu-devel@nongnu.org On Mon, Mar 28, 2011 at 03:27:49PM +0200, Jes Sorensen wrote: > On 03/23/11 14:19, Alon Levy wrote: > > diff --git a/libcacard/passthru.c b/libcacard/passthru.c > > new file mode 100644 > > index 0000000..d78e2db > > --- /dev/null > > +++ b/libcacard/passthru.c > > @@ -0,0 +1,609 @@ > > +/* > > + * implement the applets for the CAC card. > > + * > > + * This work is licensed under the terms of the GNU LGPL, version 2.1 or later. > > + * See the COPYING.LIB file in the top-level directory. > > + */ > > +#ifdef USE_PASSTHRU > > +#include > > +#include > > + > > +#include > > + > > +#include "qemu-thread.h" > > + > > +#include "vcard.h" > > +#include "vcard_emul.h" > > +#include "card_7816.h" > > +#include "vreader.h" > > +#include "vcard_emul.h" > > +#include "passthru.h" > > + > > +/* > > + * Passthru applet private data > > + */ > > +struct VCardAppletPrivateStruct { > > + char *reader_name; > > + /* pcsc-lite parameters */ > > + SCARDHANDLE hCard; > > + uint32_t hProtocol; > > + SCARD_IO_REQUEST *send_io; > > + unsigned char atr[MAX_ATR_SIZE]; > > + int atr_len; > > +}; > > + > > +static SCARDCONTEXT global_context; > > + > > +#define MAX_RESPONSE_LENGTH 261 /*65537 */ > > +/* > > + * handle all the APDU's that are common to all CAC applets > > + */ > > +static VCardStatus > > +passthru_process_apdu(VCard *card, VCardAPDU *apdu, VCardResponse **response) > > +{ > > + LONG rv; > > Where does this odd LONG type come from? I think Windows uses LONG so > having your own type would conflict with that, and of course we don't > really want Windows types directly in QEMU either, so I am curious? > This comes from pcsclite (which means I need to add the dependency to configure, I'll fix this). From there it comes via an include called wintypes.h. the PCSC API is actually a copy of a microsoft API, so it makes sense that it uses those types. On windows pcsclite won't be needed, since it has a native equivalent API, so there won't be a redefinition of LONG. So the real fix is that I need to add yet another dependency for qemu's configure, for pcsc-lite - but right now the whole libcacard/passthru.c is protected by an "#ifdef USE_PASSTHRU", which we don't define - so in effect this is currently dead code. I could even just remove this commit in its entirety atm, maybe best? Notice that has nothing to do with ccid-card-emulated or with ccid-card-passthru. I will need it later, but I need to add the pcsclite configure check anyway. So is this ok, I'll drop this patch? > Otherwise the code looks fine. > > Cheers, > Jes