diff options
author | Alexander Larsson <alexl@redhat.com> | 2010-07-19 14:10:16 +0200 |
---|---|---|
committer | Alexander Larsson <alexl@redhat.com> | 2010-07-19 16:28:22 +0200 |
commit | 12b08f2c3e07cea617255bedfd97b2eedf0f180f (patch) | |
tree | 9a35ebbc31d6b61e94d3fbcd72feb70f0e9b9858 /client | |
parent | 2962bdaea056d7069303badc3d73ed9530fdbb15 (diff) | |
download | spice-12b08f2c3e07cea617255bedfd97b2eedf0f180f.tar.gz spice-12b08f2c3e07cea617255bedfd97b2eedf0f180f.tar.xz spice-12b08f2c3e07cea617255bedfd97b2eedf0f180f.zip |
codegen: Various cleanups
Remove all uses of @end in the marshaller, instead just using
the C struct array-at-end-of-struct. To make this work we also remove
all use of @end for switches (making them C unions).
We drop the zero member of the notify message so that we can avoid this
use of @end for a primitive in the marshaller (plus its useless to send
over the wire).
We change the offsets and stuff in the migration messages to real pointers.
Diffstat (limited to 'client')
-rw-r--r-- | client/red_channel.cpp | 22 | ||||
-rw-r--r-- | client/red_client.cpp | 10 | ||||
-rw-r--r-- | client/tunnel_channel.cpp | 19 |
3 files changed, 23 insertions, 28 deletions
diff --git a/client/red_channel.cpp b/client/red_channel.cpp index b475927b..54caccf7 100644 --- a/client/red_channel.cpp +++ b/client/red_channel.cpp @@ -729,19 +729,19 @@ void RedChannel::handle_disconnect(RedPeer::InMessage* message) void RedChannel::handle_notify(RedPeer::InMessage* message) { SpiceMsgNotify *notify = (SpiceMsgNotify *)message->data(); - const char *sevirity; + const char *severity; const char *visibility; - const char *message_str = ""; + char *message_str = (char *)""; const char *message_prefix = ""; - static const char* sevirity_strings[] = {"info", "warn", "error"}; + static const char* severity_strings[] = {"info", "warn", "error"}; static const char* visibility_strings[] = {"!", "!!", "!!!"}; if (notify->severity > SPICE_NOTIFY_SEVERITY_ERROR) { THROW("bad severity"); } - sevirity = sevirity_strings[notify->severity]; + severity = severity_strings[notify->severity]; if (notify->visibilty > SPICE_NOTIFY_VISIBILITY_HIGH) { THROW("bad visibility"); @@ -750,22 +750,24 @@ void RedChannel::handle_notify(RedPeer::InMessage* message) if (notify->message_len) { - if ((message->size() - sizeof(*notify) < notify->message_len + 1)) { + if ((message->size() - sizeof(*notify) < notify->message_len)) { THROW("access violation"); } - message_str = (char *)(notify + 1); - if (message_str[notify->message_len] != 0) { - THROW("invalid message"); - } + message_str = new char[notify->message_len + 1]; + memcpy(message_str, notify->message, notify->message_len); + message_str[notify->message_len] = 0; message_prefix = ": "; } LOG_INFO("remote channel %u:%u %s%s #%u%s%s", get_type(), get_id(), - sevirity, visibility, + severity, visibility, notify->what, message_prefix, message_str); + if (notify->message_len) { + delete [] message_str; + } } void RedChannel::handle_wait_for_channels(RedPeer::InMessage* message) diff --git a/client/red_client.cpp b/client/red_client.cpp index 3f4f8bf3..9a8078ea 100644 --- a/client/red_client.cpp +++ b/client/red_client.cpp @@ -223,13 +223,11 @@ void Migrate::start(const SpiceMsgMainMigrationBegin* migrate) _sport = old_migrate->sport ? old_migrate->sport : -1;; _auth_options = _client.get_host_auth_options(); } else { - _host.assign(((char*)migrate) + migrate->host_offset); + _host.assign((char *)migrate->host_data); _port = migrate->port ? migrate->port : -1; _sport = migrate->sport ? migrate->sport : -1; _auth_options.type_flags = RedPeer::HostAuthOptions::HOST_AUTH_OP_PUBKEY; - _auth_options.host_pubkey.assign(((uint8_t*)migrate)+ migrate->pub_key_offset, - ((uint8_t*)migrate)+ migrate->pub_key_offset + - migrate->pub_key_size); + _auth_options.host_pubkey.assign(migrate->pub_key_data, migrate->pub_key_data + migrate->pub_key_size); } _con_ciphers = _client.get_connection_ciphers(); @@ -1008,7 +1006,7 @@ void RedClient::handle_agent_tokens(RedPeer::InMessage* message) void RedClient::handle_migrate_switch_host(RedPeer::InMessage* message) { SpiceMsgMainMigrationSwitchHost* migrate = (SpiceMsgMainMigrationSwitchHost*)message->data(); - char* host = ((char*)migrate) + migrate->host_offset; + char* host = (char *)migrate->host_data; char* subject = NULL; if (host[migrate->host_size - 1] != '\0') { @@ -1016,7 +1014,7 @@ void RedClient::handle_migrate_switch_host(RedPeer::InMessage* message) } if (migrate->cert_subject_size) { - subject = ((char*)migrate)+ migrate->cert_subject_offset; + subject = (char *)migrate->cert_subject_data; if (subject[migrate->cert_subject_size - 1] != '\0') { THROW("cert subject is not a null-terminated string"); } diff --git a/client/tunnel_channel.cpp b/client/tunnel_channel.cpp index 7047d461..52587422 100644 --- a/client/tunnel_channel.cpp +++ b/client/tunnel_channel.cpp @@ -287,25 +287,20 @@ void TunnelChannel::send_service(TunnelService& service) } Message* service_msg = new Message(SPICE_MSGC_TUNNEL_SERVICE_ADD); - SpiceMsgcTunnelAddPrintService add; + SpiceMsgcTunnelAddGenericService add; SpiceMarshaller *name_out, *description_out; - add.base.id = service.id; - add.base.group = service.group; - add.base.type = service.type; - add.base.port = service.port; + add.id = service.id; + add.group = service.group; + add.type = service.type; + add.port = service.port; if (service.type == SPICE_TUNNEL_SERVICE_TYPE_IPP) { - add.ip.type = SPICE_TUNNEL_IP_TYPE_IPv4; + add.u.ip.type = SPICE_TUNNEL_IP_TYPE_IPv4; } - _marshallers->msgc_tunnel_service_add(service_msg->marshaller(), &add.base, + _marshallers->msgc_tunnel_service_add(service_msg->marshaller(), &add, &name_out, &description_out); - if (service.type == SPICE_TUNNEL_SERVICE_TYPE_IPP) { - spice_marshaller_add(service_msg->marshaller(), (uint8_t *)&(service.ip.s_addr), - sizeof(SpiceTunnelIPv4)); - } - spice_marshaller_add(name_out, (uint8_t *)service.name.c_str(), service.name.length() + 1); spice_marshaller_add(description_out, (uint8_t *)service.description.c_str(), service.description.length() + 1); |