summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYouness Alaoui <youness.alaoui@collabora.co.uk>2009-01-30 21:37:35 -0500
committerYouness Alaoui <youness.alaoui@collabora.co.uk>2009-01-30 21:37:35 -0500
commit70edccc39f668dd48eff2b7d44ee81a77de1a14f (patch)
tree9f7db89f550c520e5874a87b79cc0a96f1bf3da2
parentb11d5a078438932a2effd953873cf0c3c4b795c9 (diff)
downloadlibnice-70edccc39f668dd48eff2b7d44ee81a77de1a14f.tar.gz
Port stun_xor_address to use StunMessageReturn and removed stun_memcp and stun_strcmp which are unused and useless
-rw-r--r--stun/utils.c45
-rw-r--r--stun/utils.h5
2 files changed, 3 insertions, 47 deletions
diff --git a/stun/utils.c b/stun/utils.c
index 62a4c97..fde58b5 100644
--- a/stun/utils.c
+++ b/stun/utils.c
@@ -181,56 +181,17 @@ StunMessageReturn stun_xor_address (const StunMessage *msg,
unsigned short i;
if ((size_t) addrlen < sizeof (*ip6))
- return EINVAL;
+ return STUN_MESSAGE_RETURN_INVALID;
ip6->sin6_port ^= htons (magic_cookie >> 16);
for (i = 0; i < 16; i++)
ip6->sin6_addr.s6_addr[i] ^= msg->buffer[4 + i];
- return 0;
+ return STUN_MESSAGE_RETURN_SUCCESS;
}
}
- return EAFNOSUPPORT;
-}
-
-/**
- * Compares the length and content of an attribute.
- *
- * @param msg valid STUN message buffer
- * @param type STUN attribute type (host byte order)
- * @param data pointer to value to compare with
- * @param len byte length of the value
- * @return 0 in case of match, ENOENT if attribute was not found,
- * EINVAL if it did not match (different length, or same length but
- * different content)
- */
-int stun_memcmp (const StunMessage *msg, stun_attr_type_t type,
- const void *data, size_t len)
-{
- uint16_t alen;
- const void *ptr = stun_message_find (msg, type, &alen);
- if (ptr == NULL)
- return ENOENT;
-
- if ((len != alen) || memcmp (ptr, data, len))
- return EINVAL;
- return 0;
+ return STUN_MESSAGE_RETURN_UNSUPPORTED_ADDRESS;
}
-
-/**
- * Compares the content of an attribute with a string.
- * @param msg valid STUN message buffer
- * @param type STUN attribute type (host byte order)
- * @param str string to compare with
- * @return 0 in case of match, ENOENT if attribute was not found,
- * EINVAL if it did not match
- */
-int stun_strcmp (const StunMessage *msg, stun_attr_type_t type, const char *str)
-{
- return stun_memcmp (msg, type, str, strlen (str));
-}
-
-
void *stun_setw (uint8_t *ptr, uint16_t value)
{
*ptr++ = value >> 8;
diff --git a/stun/utils.h b/stun/utils.h
index 8e02719..a557eaf 100644
--- a/stun/utils.h
+++ b/stun/utils.h
@@ -75,11 +75,6 @@ StunMessageReturn stun_xor_address (const StunMessage *msg,
struct sockaddr *addr, socklen_t addrlen,
uint32_t magic_cookie);
-int stun_memcmp (const StunMessage *msg, stun_attr_type_t type,
- const void *data, size_t len);
-
-int stun_strcmp (const StunMessage *msg, stun_attr_type_t type, const char *str);
-
void *stun_setw (uint8_t *ptr, uint16_t value);
void stun_set_type (uint8_t *h, stun_class_t c, stun_method_t m);