[Spice-commits] 10 commits - client/smartcard_channel.cpp client/smartcard_channel.h configure.ac server/smartcard.c
Alon Levy
alon at kemper.freedesktop.org
Thu Feb 10 00:11:09 PST 2011
client/smartcard_channel.cpp | 99 +++++++++++++++++++++++++++++++++----------
client/smartcard_channel.h | 21 ++++++---
configure.ac | 2
server/smartcard.c | 92 +++++++++++++++------------------------
4 files changed, 128 insertions(+), 86 deletions(-)
New commits:
commit 3700eefcec98a4938ad43eb0eb17374ec025884f
Author: Alon Levy <alevy at redhat.com>
Date: Wed Feb 9 15:18:01 2011 +0200
update required minimal libcacard to 0.1.2
diff --git a/configure.ac b/configure.ac
index 9159b4a..00f19d2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -190,7 +190,7 @@ if test "x$have_tunnel" = "xyes"; then
fi
if test "x$have_smartcard" = "xyes"; then
- PKG_CHECK_MODULES(CAC_CARD, libcacard >= 0.1.0)
+ PKG_CHECK_MODULES(CAC_CARD, libcacard >= 0.1.2)
SMARTCARD_LIBS="$CAC_CARD_LIBS"
SMARTCARD_CFLAGS="$CAC_CARD_CFLAGS"
AC_SUBST(SMARTCARD_LIBS)
commit 85ce53b6beaeec63023ce81cdf4a1c0c47f3b8bf
Author: Alon Levy <alevy at redhat.com>
Date: Thu Feb 3 17:51:29 2011 +0200
client/smartcard: libcacard dropped ReaderAddResponse
uses VSC_Error with code==VSC_SUCCESS instead. This means that the VSC_Error
message is overloaded. Instead of the other option of adding a message id,
since the connection is TCP so no messages may be dropped or reordered, by
having each message followed by a response there is no ambiguity. Still
this commit adds a queue for messages that we only have one of which outstanding
at a time, i.e. send, wait for response, send the next, etc. This further
simplifies the logic, while not adding much overhead since only when spicec
starts up it has a situation where it needs to send two events (ReaderAdd
and ATR for Card Insert).
diff --git a/client/smartcard_channel.cpp b/client/smartcard_channel.cpp
index c57ecd5..98f24a8 100644
--- a/client/smartcard_channel.cpp
+++ b/client/smartcard_channel.cpp
@@ -45,6 +45,7 @@ public:
SmartCardChannel::SmartCardChannel(RedClient& client, uint32_t id)
: RedChannel(client, SPICE_CHANNEL_SMARTCARD, id, new SmartCardHandler(*this))
+ , _next_sync_vevent(VEVENT_LAST)
{
SmartCardHandler* handler = static_cast<SmartCardHandler*>(get_message_handler());
@@ -84,6 +85,7 @@ void SmartCardChannel::add_unallocated_reader(VReader* vreader, const char* name
data->reader_id = VSCARD_UNDEFINED_READER_ID;
data->name = spice_strdup(name);
_unallocated_readers_by_vreader.insert(std::pair<VReader*, ReaderData*>(vreader, data));
+ LOG_INFO("adding unallocated reader %p", data);
}
/** called upon the VSC_ReaderAddResponse
@@ -96,6 +98,7 @@ ReaderData* SmartCardChannel::add_reader(uint32_t reader_id)
assert(unallocated > 0);
data = _unallocated_readers_by_vreader.begin()->second;
data->reader_id = reader_id;
+ LOG_INFO("adding %p->%d", data, reader_id);
_readers_by_vreader.insert(
std::pair<VReader*, ReaderData*>(data->vreader, data));
assert(_readers_by_vreader.count(data->vreader) == 1);
@@ -179,6 +182,65 @@ void SmartCardChannel::remove_reader(ReaderData* data)
delete data;
}
+/* Sync events need to be sent one by one, waiting for VSC_Error
+ * messages from the server in between. */
+void SmartCardChannel::push_sync_event(VEventType type, Event *event)
+{
+ event->ref();
+ _sync_events.push_back(SmartCardEvent(type, event));
+ if (_next_sync_vevent != VEVENT_LAST) {
+ return;
+ }
+ send_next_sync_event();
+}
+
+void SmartCardChannel::send_next_sync_event()
+{
+ if (_sync_events.empty()) {
+ _next_sync_vevent = VEVENT_LAST;
+ return;
+ }
+ SmartCardEvent sync_event = _sync_events.front();
+ _sync_events.pop_front();
+ get_client().push_event(sync_event.second);
+ sync_event.second->unref();
+ _next_sync_vevent = sync_event.first;
+}
+
+void SmartCardChannel::handle_reader_add_response(VSCMsgHeader *vheader,
+ VSCMsgError *error)
+{
+ ReaderData* data;
+
+ if (error->code == VSC_SUCCESS) {
+ data = add_reader(vheader->reader_id);
+ if (data->card_insert_pending) {
+ data->card_insert_pending = false;
+ send_atr(data->vreader);
+ }
+ } else {
+ LOG_WARN("VSC Error: reader %d, code %d",
+ vheader->reader_id, error->code);
+ }
+}
+
+void SmartCardChannel::handle_error_message(VSCMsgHeader *vheader,
+ VSCMsgError *error)
+{
+ switch (_next_sync_vevent) {
+ case VEVENT_READER_INSERT:
+ handle_reader_add_response(vheader, error);
+ break;
+ case VEVENT_CARD_INSERT:
+ case VEVENT_CARD_REMOVE:
+ case VEVENT_READER_REMOVE:
+ break;
+ default:
+ LOG_WARN("Unexpected Error message: %d", error->code);
+ }
+ send_next_sync_event();
+}
+
void SmartCardChannel::cac_card_events_thread_main()
{
VEvent *vevent = NULL;
@@ -194,28 +256,28 @@ void SmartCardChannel::cac_card_events_thread_main()
LOG_INFO("VEVENT_READER_INSERT");
{
AutoRef<ReaderAddEvent> event(new ReaderAddEvent(this, vevent));
- get_client().push_event(*event);
+ push_sync_event(vevent->type, *event);
}
break;
case VEVENT_READER_REMOVE:
LOG_INFO("VEVENT_READER_REMOVE");
{
AutoRef<ReaderRemoveEvent> event(new ReaderRemoveEvent(this, vevent));
- get_client().push_event(*event);
+ push_sync_event(vevent->type, *event);
}
break;
case VEVENT_CARD_INSERT:
LOG_INFO("VEVENT_CARD_INSERT");
{
AutoRef<CardInsertEvent> event(new CardInsertEvent(this, vevent));
- get_client().push_event(*event);
+ push_sync_event(vevent->type, *event);
}
break;
case VEVENT_CARD_REMOVE:
LOG_INFO("VEVENT_CARD_REMOVE");
{
AutoRef<CardRemoveEvent> event(new CardRemoveEvent(this, vevent));
- get_client().push_event(*event);
+ push_sync_event(vevent->type, *event);
}
break;
case VEVENT_LAST:
@@ -390,25 +452,14 @@ void VSCMessageEvent::response(AbstractProcessLoop& loop)
uint8_t pbRecvBuffer[APDUBufSize+sizeof(uint32_t)];
VReaderStatus reader_status;
uint32_t rv;
- ReaderData* data;
switch (_vheader->type) {
- case (VSC_ReaderAddResponse):
- data = _smartcard_channel->add_reader(_vheader->reader_id);
- if (data->card_insert_pending) {
- data->card_insert_pending = false;
- _smartcard_channel->send_atr(data->vreader);
- }
- return;
- break;
case VSC_APDU:
break;
case VSC_Error:
- {
- VSCMsgError *error = (VSCMsgError*)_vheader->data;
- LOG_WARN("VSC Error: reader %d, code %d",
- _vheader->reader_id, error->code);
- }
+ _smartcard_channel->handle_error_message(
+ _vheader,
+ (VSCMsgError*)_vheader->data);
return;
case VSC_Init:
break;
diff --git a/client/smartcard_channel.h b/client/smartcard_channel.h
index 1d512a6..752713b 100644
--- a/client/smartcard_channel.h
+++ b/client/smartcard_channel.h
@@ -86,6 +86,8 @@ public:
virtual void response(AbstractProcessLoop& events_loop);
};
+typedef std::pair<VEventType, Event*> SmartCardEvent;
+
class SmartCardChannel : public RedChannel {
public:
@@ -114,6 +116,13 @@ private:
typedef std::map<VReader*, ReaderData*> readers_by_vreader_t;
readers_by_vreader_t _readers_by_vreader;
readers_by_vreader_t _unallocated_readers_by_vreader;
+ VEventType _next_sync_vevent;
+ std::list<SmartCardEvent> _sync_events;
+
+ void push_sync_event(VEventType type, Event *event);
+ void send_next_sync_event();
+ void handle_reader_add_response(VSCMsgHeader *vheader, VSCMsgError *error);
+ void handle_error_message(VSCMsgHeader *vheader, VSCMsgError *error);
ReaderData* reader_data_from_vreader(VReader* vreader);
ReaderData* reader_data_from_reader_id(uint32_t reader_id);
commit 51da06793c33ff30b45154ccfc6e28d6d0d35db6
Author: Alon Levy <alevy at redhat.com>
Date: Wed Feb 9 12:09:43 2011 +0200
server/smartcard: don't push our own error on reader add
The device already sends one. There are actually two connections going
on:
server to client - this is the smartcard channel, it reuses the VSC protocol.
server to device - this is an internal connection using VSC too.
We generally just passthrough all messages from the client to the device,
and from the device to the client. We only rewrite the reader_id because
the device knows about a single id (it is actually a card id), and we
may manage more then one in the future.
Bottom line is that there was an extra VSC_Error message reaching the client.
diff --git a/server/smartcard.c b/server/smartcard.c
index 9fbeead..a93e59d 100644
--- a/server/smartcard.c
+++ b/server/smartcard.c
@@ -393,12 +393,12 @@ static void smartcard_add_reader(SmartCardChannel *smartcard_channel, uint8_t *n
// TODO - save name somewhere
SpiceCharDeviceInstance *char_device =
smartcard_readers_get_unattached();
- SmartCardDeviceState *state;
if (char_device != NULL) {
- state = SPICE_CONTAINEROF(char_device->st, SmartCardDeviceState, base);
smartcard_char_device_attach(char_device, smartcard_channel);
- smartcard_push_error(smartcard_channel, state->reader_id, VSC_SUCCESS);
+ // The device sends a VSC_Error message, we will let it through, no
+ // need to send our own. We already set the correct reader_id, from
+ // our SmartCardDeviceState.
} else {
smartcard_push_error(smartcard_channel, VSCARD_UNDEFINED_READER_ID,
VSC_CANNOT_ADD_MORE_READERS);
commit 91bf99a1e98623905485089ff0b7886e30c369a4
Author: Alon Levy <alevy at redhat.com>
Date: Thu Feb 3 20:50:22 2011 +0200
client/smartcard: ignore VSC_Init
diff --git a/client/smartcard_channel.cpp b/client/smartcard_channel.cpp
index e7f3870..c57ecd5 100644
--- a/client/smartcard_channel.cpp
+++ b/client/smartcard_channel.cpp
@@ -410,6 +410,8 @@ void VSCMessageEvent::response(AbstractProcessLoop& loop)
_vheader->reader_id, error->code);
}
return;
+ case VSC_Init:
+ break;
default:
LOG_WARN("unhandled VSC %d of length %d, reader %d",
_vheader->type, _vheader->length, _vheader->reader_id);
commit c7c6f9aed00b23bf97cb207ab88375dfc2027452
Author: Alon Levy <alevy at redhat.com>
Date: Thu Feb 3 20:55:03 2011 +0200
server/smartcard: ignore VSC_Init from client
diff --git a/server/smartcard.c b/server/smartcard.c
index bd2cb25..9fbeead 100644
--- a/server/smartcard.c
+++ b/server/smartcard.c
@@ -443,6 +443,9 @@ static int smartcard_channel_handle_message(RedChannel *channel, SpiceDataHeader
return TRUE;
break;
case VSC_Init:
+ // ignore - we should never get this anyway
+ return TRUE;
+ break;
case VSC_Error:
case VSC_ATR:
case VSC_CardRemove:
commit 612f9744dff8a66964dbac6bae96bbb09c0e51a3
Author: Alon Levy <alevy at redhat.com>
Date: Thu Feb 3 20:54:48 2011 +0200
server/smartcard: print instead of assert on bad reader_id in smartcard_char_device_on_message_from_device
diff --git a/server/smartcard.c b/server/smartcard.c
index da67885..bd2cb25 100644
--- a/server/smartcard.c
+++ b/server/smartcard.c
@@ -114,7 +114,9 @@ void smartcard_char_device_on_message_from_device(
break;
}
/* We pass any VSC_Error right now - might need to ignore some? */
- ASSERT(state->reader_id != VSCARD_UNDEFINED_READER_ID);
+ if (state->reader_id == VSCARD_UNDEFINED_READER_ID && vheader->type != VSC_Init) {
+ red_printf("error: reader_id not assigned for message of type %d", vheader->type);
+ }
ASSERT(g_smartcard_channel != NULL);
sent_header = spice_memdup(vheader, sizeof(*vheader) + vheader->length);
/* We patch the reader_id, since the device only knows about itself, and
commit fe83d01162b3d78192144cdcbf0e21baa0e1e9be
Author: Alon Levy <alevy at redhat.com>
Date: Thu Feb 3 20:51:01 2011 +0200
server/smartcard: libcacard uses network byte order, so we must too
diff --git a/server/smartcard.c b/server/smartcard.c
index 4dddd94..da67885 100644
--- a/server/smartcard.c
+++ b/server/smartcard.c
@@ -1,3 +1,5 @@
+#include <arpa/inet.h>
+
#include "server/char_device.h"
#include "server/red_channel.h"
#include "server/smartcard.h"
@@ -67,6 +69,7 @@ void smartcard_char_device_wakeup(SpiceCharDeviceInstance *sin)
VSCMsgHeader *vheader = (VSCMsgHeader*)state->buf;
int n;
int remaining;
+ int actual_length;
while ((n = sif->read(sin, state->buf_pos, state->buf_size - state->buf_used)) > 0) {
state->buf_pos += n;
@@ -74,16 +77,17 @@ void smartcard_char_device_wakeup(SpiceCharDeviceInstance *sin)
if (state->buf_used < sizeof(VSCMsgHeader)) {
continue;
}
- if (vheader->length > state->buf_size) {
- state->buf_size = MAX(state->buf_size*2, vheader->length + sizeof(VSCMsgHeader));
+ actual_length = ntohl(vheader->length);
+ if (actual_length > state->buf_size) {
+ state->buf_size = MAX(state->buf_size*2, actual_length + sizeof(VSCMsgHeader));
state->buf = spice_realloc(state->buf, state->buf_size);
ASSERT(state->buf != NULL);
}
- if (state->buf_used - sizeof(VSCMsgHeader) < vheader->length) {
+ if (state->buf_used - sizeof(VSCMsgHeader) < actual_length) {
continue;
}
smartcard_char_device_on_message_from_device(state, vheader);
- remaining = state->buf_used - sizeof(VSCMsgHeader) > vheader->length;
+ remaining = state->buf_used - sizeof(VSCMsgHeader) > actual_length;
if (remaining > 0) {
memcpy(state->buf, state->buf_pos, remaining);
}
@@ -98,6 +102,10 @@ void smartcard_char_device_on_message_from_device(
{
VSCMsgHeader *sent_header;
+ vheader->type = ntohl(vheader->type);
+ vheader->length = ntohl(vheader->length);
+ vheader->reader_id = ntohl(vheader->reader_id);
+
switch (vheader->type) {
case VSC_Init:
return;
@@ -401,15 +409,20 @@ static void smartcard_channel_write_to_reader(
SpiceCharDeviceInstance *sin;
SpiceCharDeviceInterface *sif;
uint32_t n;
+ uint32_t actual_length = vheader->length;
ASSERT(vheader->reader_id >= 0 &&
vheader->reader_id <= g_smartcard_readers.num);
sin = g_smartcard_readers.sin[vheader->reader_id];
sif = SPICE_CONTAINEROF(sin->base.sif, SpiceCharDeviceInterface, base);
+ /* protocol requires messages to be in network endianess */
+ vheader->type = htonl(vheader->type);
+ vheader->length = htonl(vheader->length);
+ vheader->reader_id = htonl(vheader->reader_id);
n = sif->write(sin, (uint8_t*)vheader,
- vheader->length + sizeof(VSCMsgHeader));
+ actual_length + sizeof(VSCMsgHeader));
// TODO - add ring
- ASSERT(n == vheader->length + sizeof(VSCMsgHeader));
+ ASSERT(n == actual_length + sizeof(VSCMsgHeader));
}
static int smartcard_channel_handle_message(RedChannel *channel, SpiceDataHeader *header, uint8_t *msg)
commit aed4c72a49feab938fda806e0080b1294ed84487
Author: Alon Levy <alevy at redhat.com>
Date: Thu Feb 3 17:45:46 2011 +0200
client/smartcard: s/reader_id_t/uint32_t/ (libcacard changed)
diff --git a/client/smartcard_channel.cpp b/client/smartcard_channel.cpp
index 994671f..e7f3870 100644
--- a/client/smartcard_channel.cpp
+++ b/client/smartcard_channel.cpp
@@ -66,7 +66,7 @@ ReaderData* SmartCardChannel::reader_data_from_vreader(VReader* vreader)
return _unallocated_readers_by_vreader.find(vreader)->second;
}
-ReaderData* SmartCardChannel::reader_data_from_reader_id(reader_id_t reader_id)
+ReaderData* SmartCardChannel::reader_data_from_reader_id(uint32_t reader_id)
{
if (_readers_by_id.count(reader_id) > 0) {
return _readers_by_id.find(reader_id)->second;
@@ -88,7 +88,7 @@ void SmartCardChannel::add_unallocated_reader(VReader* vreader, const char* name
/** called upon the VSC_ReaderAddResponse
*/
-ReaderData* SmartCardChannel::add_reader(reader_id_t reader_id)
+ReaderData* SmartCardChannel::add_reader(uint32_t reader_id)
{
ReaderData* data;
size_t unallocated = _unallocated_readers_by_vreader.size();
@@ -99,7 +99,7 @@ ReaderData* SmartCardChannel::add_reader(reader_id_t reader_id)
_readers_by_vreader.insert(
std::pair<VReader*, ReaderData*>(data->vreader, data));
assert(_readers_by_vreader.count(data->vreader) == 1);
- _readers_by_id.insert(std::pair<reader_id_t, ReaderData*>(reader_id, data));
+ _readers_by_id.insert(std::pair<uint32_t, ReaderData*>(reader_id, data));
assert(_readers_by_id.count(reader_id) == 1);
_unallocated_readers_by_vreader.erase(_unallocated_readers_by_vreader.begin());
assert(_unallocated_readers_by_vreader.size() == unallocated - 1);
@@ -328,7 +328,7 @@ void SmartCardChannel::on_disconnect()
}
-void SmartCardChannel::send_reader_removed(reader_id_t reader_id)
+void SmartCardChannel::send_reader_removed(uint32_t reader_id)
{
send_message(reader_id, VSC_ReaderRemove, NULL, 0);
}
@@ -343,7 +343,7 @@ void SmartCardChannel::send_atr(VReader* vreader)
{
unsigned char atr[ MAX_ATR_LEN];
int atr_len = MAX_ATR_LEN;
- reader_id_t reader_id = reader_data_from_vreader(vreader)->reader_id;
+ uint32_t reader_id = reader_data_from_vreader(vreader)->reader_id;
assert(reader_id != VSCARD_UNDEFINED_READER_ID);
vreader_power_on(vreader, atr, &atr_len);
diff --git a/client/smartcard_channel.h b/client/smartcard_channel.h
index 60c6db5..1d512a6 100644
--- a/client/smartcard_channel.h
+++ b/client/smartcard_channel.h
@@ -29,7 +29,7 @@ struct ReaderData {
card_insert_pending(false)
{}
VReader *vreader;
- reader_id_t reader_id;
+ uint32_t reader_id;
char* name;
bool card_insert_pending;
};
@@ -102,26 +102,26 @@ protected:
private:
static void* cac_card_events_thread_entry(void* data);
void cac_card_events_thread_main();
- void send_message(reader_id_t reader_id, VSCMsgType type, uint8_t* data, uint32_t len);
+ void send_message(uint32_t reader_id, VSCMsgType type, uint8_t* data, uint32_t len);
Thread* _event_thread;
Application* _app;
VReaderList *_reader_list;
- typedef std::map<reader_id_t, ReaderData*> readers_by_id_t;
+ typedef std::map<uint32_t, ReaderData*> readers_by_id_t;
readers_by_id_t _readers_by_id;
typedef std::map<VReader*, ReaderData*> readers_by_vreader_t;
readers_by_vreader_t _readers_by_vreader;
readers_by_vreader_t _unallocated_readers_by_vreader;
ReaderData* reader_data_from_vreader(VReader* vreader);
- ReaderData* reader_data_from_reader_id(reader_id_t reader_id);
+ ReaderData* reader_data_from_reader_id(uint32_t reader_id);
void add_unallocated_reader(VReader* vreader, const char* name);
- ReaderData* add_reader(reader_id_t reader_id);
+ ReaderData* add_reader(uint32_t reader_id);
void remove_reader(ReaderData* data);
void send_reader_added(const char* reader_name);
- void send_reader_removed(reader_id_t reader_id);
+ void send_reader_removed(uint32_t reader_id);
void send_atr(VReader* vreader);
friend class ReaderAddEvent;
commit 9d75e4322664e91dfbff1b695a4e792956635c12
Author: Alon Levy <alevy at redhat.com>
Date: Thu Feb 3 17:43:12 2011 +0200
server/smartcard: libcacard removed ReaderAddResponse
diff --git a/server/smartcard.c b/server/smartcard.c
index caba141..4dddd94 100644
--- a/server/smartcard.c
+++ b/server/smartcard.c
@@ -17,7 +17,6 @@ typedef struct SmartCardDeviceState {
enum {
PIPE_ITEM_TYPE_ERROR=1,
- PIPE_ITEM_TYPE_READER_ADD_RESPONSE,
PIPE_ITEM_TYPE_MSG,
};
@@ -27,11 +26,6 @@ typedef struct ErrorItem {
uint32_t error;
} ErrorItem;
-typedef struct ReaderAddResponseItem {
- PipeItem base;
- uint32_t reader_id;
-} ReaderAddResponseItem;
-
typedef struct MsgItem {
PipeItem base;
VSCMsgHeader* vheader;
@@ -108,21 +102,15 @@ void smartcard_char_device_on_message_from_device(
case VSC_Init:
return;
break;
- case VSC_ReaderAddResponse:
- /* The device sends this for vscclient, we send one ourselves,
- * a second would be an error. */
- return;
- break;
- case VSC_Reconnect:
- /* Ignore VSC_Reconnect messages, spice channel reconnection does the same. */
- return;
- break;
default:
break;
}
+ /* We pass any VSC_Error right now - might need to ignore some? */
ASSERT(state->reader_id != VSCARD_UNDEFINED_READER_ID);
ASSERT(g_smartcard_channel != NULL);
sent_header = spice_memdup(vheader, sizeof(*vheader) + vheader->length);
+ /* We patch the reader_id, since the device only knows about itself, and
+ * we know about the sum of readers. */
sent_header->reader_id = state->reader_id;
smartcard_on_message_from_device(g_smartcard_channel, sent_header);
}
@@ -299,16 +287,6 @@ static void smartcard_channel_send_error(
VSC_Error, (uint8_t*)&error, sizeof(error));
}
-static void smartcard_channel_send_reader_add_response(
- SmartCardChannel *smartcard_channel, PipeItem *item)
-{
- ReaderAddResponseItem* rar_item = (ReaderAddResponseItem*)item;
- VSCMsgReaderAddResponse rar;
-
- smartcard_channel_send_message(&smartcard_channel->base, item, rar_item->reader_id,
- VSC_ReaderAddResponse, (uint8_t*)&rar, sizeof(rar));
-}
-
static void smartcard_channel_send_msg(
SmartCardChannel *smartcard_channel, PipeItem *item)
{
@@ -326,9 +304,6 @@ static void smartcard_channel_send_item(RedChannel *channel, PipeItem *item)
case PIPE_ITEM_TYPE_ERROR:
smartcard_channel_send_error(smartcard_channel, item);
break;
- case PIPE_ITEM_TYPE_READER_ADD_RESPONSE:
- smartcard_channel_send_reader_add_response(smartcard_channel, item);
- break;
case PIPE_ITEM_TYPE_MSG:
smartcard_channel_send_msg(smartcard_channel, item);
}
@@ -368,15 +343,6 @@ static void smartcard_push_error(SmartCardChannel* channel, uint32_t reader_id,
smartcard_channel_pipe_add_push(channel, &error_item->base);
}
-static void smartcard_push_reader_add_response(SmartCardChannel *channel, uint32_t reader_id)
-{
- ReaderAddResponseItem *rar_item = spice_new0(ReaderAddResponseItem, 1);
-
- rar_item->base.type = PIPE_ITEM_TYPE_READER_ADD_RESPONSE;
- rar_item->reader_id = reader_id;
- smartcard_channel_pipe_add_push(channel, &rar_item->base);
-}
-
static void smartcard_push_vscmsg(SmartCardChannel *channel, VSCMsgHeader *vheader)
{
MsgItem *msg_item = spice_new0(MsgItem, 1);
@@ -422,7 +388,7 @@ static void smartcard_add_reader(SmartCardChannel *smartcard_channel, uint8_t *n
if (char_device != NULL) {
state = SPICE_CONTAINEROF(char_device->st, SmartCardDeviceState, base);
smartcard_char_device_attach(char_device, smartcard_channel);
- smartcard_push_reader_add_response(smartcard_channel, state->reader_id);
+ smartcard_push_error(smartcard_channel, state->reader_id, VSC_SUCCESS);
} else {
smartcard_push_error(smartcard_channel, VSCARD_UNDEFINED_READER_ID,
VSC_CANNOT_ADD_MORE_READERS);
@@ -461,10 +427,6 @@ static int smartcard_channel_handle_message(RedChannel *channel, SpiceDataHeader
smartcard_remove_reader(smartcard_channel, vheader->reader_id);
return TRUE;
break;
- case VSC_ReaderAddResponse:
- /* We shouldn't get this - we only send it */
- return TRUE;
- break;
case VSC_Init:
case VSC_Error:
case VSC_ATR:
commit 4e48f65dc4e7778c07a51e58e57d4d84063a3b26
Author: Alon Levy <alevy at redhat.com>
Date: Thu Feb 3 17:33:37 2011 +0200
server/smartcard: s/reader_id_t/uint32_t/ (libcacard changed)
diff --git a/server/smartcard.c b/server/smartcard.c
index b22d7c4..caba141 100644
--- a/server/smartcard.c
+++ b/server/smartcard.c
@@ -7,7 +7,7 @@
typedef struct SmartCardDeviceState {
SpiceCharDeviceState base;
- reader_id_t reader_id;
+ uint32_t reader_id;
uint32_t attached;
uint8_t *buf;
uint32_t buf_size;
@@ -23,7 +23,7 @@ enum {
typedef struct ErrorItem {
PipeItem base;
- reader_id_t reader_id;
+ uint32_t reader_id;
uint32_t error;
} ErrorItem;
@@ -49,7 +49,7 @@ static struct Readers {
} g_smartcard_readers = {0, {NULL}};
static SpiceCharDeviceInstance* smartcard_readers_get_unattached();
-static SpiceCharDeviceInstance* smartcard_readers_get(reader_id_t reader_id);
+static SpiceCharDeviceInstance* smartcard_readers_get(uint32_t reader_id);
static int smartcard_char_device_add_to_readers(SpiceCharDeviceInstance *sin);
static void smartcard_char_device_attach(
SpiceCharDeviceInstance *char_device, SmartCardChannel *smartcard_channel);
@@ -150,7 +150,7 @@ static int smartcard_char_device_add_to_readers(SpiceCharDeviceInstance *char_de
return 0;
}
-static SpiceCharDeviceInstance *smartcard_readers_get(reader_id_t reader_id)
+static SpiceCharDeviceInstance *smartcard_readers_get(uint32_t reader_id)
{
ASSERT(reader_id < g_smartcard_readers.num);
return g_smartcard_readers.sin[reader_id];
@@ -358,7 +358,7 @@ static void smartcard_channel_pipe_add_push(SmartCardChannel *channel, PipeItem
red_channel_pipe_add_push(&channel->base, item);
}
-static void smartcard_push_error(SmartCardChannel* channel, reader_id_t reader_id, VSCErrorCode error)
+static void smartcard_push_error(SmartCardChannel* channel, uint32_t reader_id, VSCErrorCode error)
{
ErrorItem *error_item = spice_new0(ErrorItem, 1);
@@ -392,7 +392,7 @@ void smartcard_on_message_from_device(SmartCardChannel *smartcard_channel,
smartcard_push_vscmsg(smartcard_channel, vheader);
}
-static void smartcard_remove_reader(SmartCardChannel *smartcard_channel, reader_id_t reader_id)
+static void smartcard_remove_reader(SmartCardChannel *smartcard_channel, uint32_t reader_id)
{
SpiceCharDeviceInstance *char_device = smartcard_readers_get(reader_id);
SmartCardDeviceState *state;
More information about the Spice-commits
mailing list