[Spice-devel] [PATCH 2/3] Introduce red_link_info_test_capability()
Christophe Fergeau
cfergeau at redhat.com
Thu Mar 20 03:23:06 PDT 2014
This just hides a bit of pointer arithmetic away from reds_send_link_ack.
This helper will be used in the next commits.
---
server/reds.c | 21 ++++++++++++++++++---
1 file changed, 18 insertions(+), 3 deletions(-)
diff --git a/server/reds.c b/server/reds.c
index fb2a19b..79a685b 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -1325,6 +1325,22 @@ static void reds_channel_init_auth_caps(RedLinkInfo *link, RedChannel *channel)
red_channel_set_common_cap(channel, SPICE_COMMON_CAP_PROTOCOL_AUTH_SELECTION);
}
+
+static const uint32_t *red_link_info_get_caps(const RedLinkInfo *link)
+{
+ const uint8_t *caps_start = (const uint8_t *)link->link_mess;
+
+ return (const uint32_t *)(caps_start + link->link_mess->caps_offset);
+}
+
+static bool red_link_info_test_capability(const RedLinkInfo *link, uint32_t cap)
+{
+ const uint32_t *caps = red_link_info_get_caps(link);
+
+ return test_capability(caps, link->link_mess->num_common_caps, cap);
+}
+
+
static int reds_send_link_ack(RedLinkInfo *link)
{
SpiceLinkHeader header;
@@ -2038,7 +2054,6 @@ static void reds_handle_read_link_done(void *opaque)
RedLinkInfo *link = (RedLinkInfo *)opaque;
SpiceLinkMess *link_mess = link->link_mess;
uint32_t num_caps = link_mess->num_common_caps + link_mess->num_channel_caps;
- uint32_t *caps = (uint32_t *)((uint8_t *)link_mess + link_mess->caps_offset);
int auth_selection;
if (num_caps && (num_caps * sizeof(uint32_t) + link_mess->caps_offset >
@@ -2049,8 +2064,8 @@ static void reds_handle_read_link_done(void *opaque)
return;
}
- auth_selection = test_capability(caps, link_mess->num_common_caps,
- SPICE_COMMON_CAP_PROTOCOL_AUTH_SELECTION);
+ auth_selection = red_link_info_test_capability(link,
+ SPICE_COMMON_CAP_PROTOCOL_AUTH_SELECTION);
if (!reds_security_check(link)) {
if (reds_stream_is_ssl(link->stream)) {
--
1.8.5.3
More information about the Spice-devel
mailing list