MsgItem *smartcard_char_device_on_message_from_device(SmartCardDeviceState *state, VSCMsgHeader *vheader) { 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 NULL; default: break; } /* We pass any VSC_Error right now - might need to ignore some? */ if (state->reader_id == VSCARD_UNDEFINED_READER_ID && vheader->type != VSC_Init) { spice_printerr("error: reader_id not assigned for message of type %d", vheader->type); } if (state->scc) { 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; return smartcard_get_vsc_msg_item(&state->scc->base, sent_header); } return NULL; }
void smartcard_char_device_on_message_from_device( SmartCardDeviceState *state, VSCMsgHeader *vheader) { VSCMsgHeader *sent_header; switch (vheader->type) { 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; } ASSERT(state->reader_id != VSCARD_UNDEFINED_READER_ID); ASSERT(g_smartcard_channel != NULL); sent_header = spice_memdup(vheader, sizeof(*vheader) + vheader->length); sent_header->reader_id = state->reader_id; smartcard_on_message_from_device(g_smartcard_channel, sent_header); }
SpiceOpenSSLVerify* spice_openssl_verify_new(SSL *ssl, SPICE_SSL_VERIFY_OP verifyop, const char *hostname, const char *pubkey, size_t pubkey_size, const char *subject) { SpiceOpenSSLVerify *v; if (!verifyop) return NULL; v = spice_new0(SpiceOpenSSLVerify, 1); v->ssl = ssl; v->verifyop = verifyop; v->hostname = spice_strdup(hostname); v->pubkey = (char*)spice_memdup(pubkey, pubkey_size); v->pubkey_size = pubkey_size; v->subject = spice_strdup(subject); v->all_preverify_ok = 1; SSL_set_app_data(ssl, v); SSL_set_verify(ssl, SSL_VERIFY_PEER, openssl_verify); return v; }