summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYouness Alaoui <youness.alaoui@collabora.co.uk>2009-03-05 15:22:33 -0500
committerYouness Alaoui <youness.alaoui@collabora.co.uk>2009-03-05 15:22:33 -0500
commit994f4ae9c2859c47d948faa3270c9c2801565555 (patch)
tree0a215dd47fa7d0261248988ec4d7c1e88445aafc
parent494d8a0be807c64e3e13d7020ba14d3d5c5684bc (diff)
downloadlibnice-994f4ae9c2859c47d948faa3270c9c2801565555.tar.gz
Move functions and prototypes from one file to another to avoid having to install non public headers
-rw-r--r--stun/constants.h1
-rw-r--r--stun/stun5389.h10
-rw-r--r--stun/stunmessage.c50
-rw-r--r--stun/stunmessage.h35
-rw-r--r--stun/utils.c78
-rw-r--r--stun/utils.h43
6 files changed, 86 insertions, 131 deletions
diff --git a/stun/constants.h b/stun/constants.h
index 8b57f61..13ffa05 100644
--- a/stun/constants.h
+++ b/stun/constants.h
@@ -63,7 +63,6 @@
#define STUN_MAX_MESSAGE_SIZE_IPV4 576
#define STUN_MAX_MESSAGE_SIZE_IPV6 1280
/* #define STUN_MAX_MESSAGE_SIZE STUN_MAX_MESSAGE_SIZE_IPV4 */
-#define STUN_MAX_MESSAGE_SIZE 65552
#define STUN_ID_LEN 16
diff --git a/stun/stun5389.h b/stun/stun5389.h
index 5d7b5f2..3387304 100644
--- a/stun/stun5389.h
+++ b/stun/stun5389.h
@@ -60,16 +60,6 @@
uint32_t stun_fingerprint (const uint8_t *msg, size_t len,
bool wlm2009_stupid_crc32_typo);
-/**
- * stun_message_has_cookie:
- * @msg: The #StunMessage
- *
- * Checks if the STUN message has a RFC5389 compatible cookie
- *
- * Returns: %TRUE if the cookie is present, %FALSE otherwise
- */
-bool stun_message_has_cookie (const StunMessage *msg);
-
StunMessageReturn stun_message_append_software (StunMessage *msg);
diff --git a/stun/stunmessage.c b/stun/stunmessage.c
index df277d5..d97ae2d 100644
--- a/stun/stunmessage.c
+++ b/stun/stunmessage.c
@@ -604,3 +604,53 @@ bool stun_message_has_attribute (const StunMessage *msg, StunAttribute type)
uint16_t dummy;
return stun_message_find (msg, type, &dummy) != NULL;
}
+
+
+bool stun_optional (uint16_t t)
+{
+ return (t >> 15) == 1;
+}
+
+const char *stun_strerror (StunError code)
+{
+ static const struct
+ {
+ StunError code;
+ char phrase[32];
+ } tab[] =
+ {
+ { STUN_ERROR_TRY_ALTERNATE, "Try alternate server" },
+ { STUN_ERROR_BAD_REQUEST, "Bad request" },
+ { STUN_ERROR_UNAUTHORIZED, "Unauthorized" },
+ { STUN_ERROR_UNKNOWN_ATTRIBUTE, "Unknown Attribute" },
+ { STUN_ERROR_ALLOCATION_MISMATCH, "Allocation Mismatch" },
+ { STUN_ERROR_STALE_NONCE, "Stale Nonce" },
+ { STUN_ERROR_ACT_DST_ALREADY, "Active Destination Already Set" },
+ { STUN_ERROR_UNSUPPORTED_FAMILY, "Address Family not Supported" },
+ { STUN_ERROR_UNSUPPORTED_TRANSPORT, "Unsupported Transport Protocol" },
+ { STUN_ERROR_INVALID_IP, "Invalid IP Address" },
+ { STUN_ERROR_INVALID_PORT, "Invalid Port" },
+ { STUN_ERROR_OP_TCP_ONLY, "Operation for TCP Only" },
+ { STUN_ERROR_CONN_ALREADY, "Connection Already Exists" },
+ { STUN_ERROR_ALLOCATION_QUOTA_REACHED, "Allocation Quota Reached" },
+ { STUN_ERROR_ROLE_CONFLICT, "Role conflict" },
+ { STUN_ERROR_SERVER_ERROR, "Server Error" },
+ { STUN_ERROR_SERVER_CAPACITY, "Insufficient Capacity" },
+ { STUN_ERROR_INSUFFICIENT_CAPACITY, "Insufficient Capacity" },
+ };
+ const char *str = "Unknown error";
+ size_t i;
+
+ for (i = 0; i < (sizeof (tab) / sizeof (tab[0])); i++)
+ {
+ if (tab[i].code == code)
+ {
+ str = tab[i].phrase;
+ break;
+ }
+ }
+
+ /* Maximum allowed error message length */
+ // assert (strlen (str) < 128);
+ return str;
+}
diff --git a/stun/stunmessage.h b/stun/stunmessage.h
index 0f3a855..56ff222 100644
--- a/stun/stunmessage.h
+++ b/stun/stunmessage.h
@@ -864,4 +864,39 @@ StunMethod stun_message_get_method (const StunMessage *msg);
*/
bool stun_message_has_attribute (const StunMessage *msg, StunAttribute type);
+
+/* Defined in stun5389.c */
+/**
+ * stun_message_has_cookie:
+ * @msg: The #StunMessage
+ *
+ * Checks if the STUN message has a RFC5389 compatible cookie
+ *
+ * Returns: %TRUE if the cookie is present, %FALSE otherwise
+ */
+bool stun_message_has_cookie (const StunMessage *msg);
+
+
+/**
+ * stun_optional:
+ * @t: An attribute type
+ *
+ * Helper function that checks whether a STUN attribute is a mandatory
+ * or an optional attribute
+ *
+ * Returns: %TRUE if the attribute is an optional one
+ */
+bool stun_optional (uint16_t t);
+
+/**
+ * stun_strerror:
+ * @code: host-byte order error code
+ *
+ * Transforms a STUN error-code into a human readable string
+ *
+ * Returns: A static pointer to a NULL-terminated error message string.
+ */
+const char *stun_strerror (StunError code);
+
+
#endif /* _STUN_MESSAGE_H */
diff --git a/stun/utils.c b/stun/utils.c
index 42b7f60..5029b38 100644
--- a/stun/utils.c
+++ b/stun/utils.c
@@ -44,12 +44,6 @@
#include "utils.h"
-
-bool stun_optional (uint16_t t)
-{
- return (t >> 15) == 1;
-}
-
size_t stun_padding (size_t l)
{
return (4 - (l & 3)) & 3;
@@ -88,49 +82,6 @@ void stun_set_type (uint8_t *h, StunClass c, StunMethod m)
/* assert (stun_get_method (h) == m); */
}
-const char *stun_strerror (StunError code)
-{
- static const struct
- {
- StunError code;
- char phrase[32];
- } tab[] =
- {
- { STUN_ERROR_TRY_ALTERNATE, "Try alternate server" },
- { STUN_ERROR_BAD_REQUEST, "Bad request" },
- { STUN_ERROR_UNAUTHORIZED, "Unauthorized" },
- { STUN_ERROR_UNKNOWN_ATTRIBUTE, "Unknown Attribute" },
- { STUN_ERROR_ALLOCATION_MISMATCH, "Allocation Mismatch" },
- { STUN_ERROR_STALE_NONCE, "Stale Nonce" },
- { STUN_ERROR_ACT_DST_ALREADY, "Active Destination Already Set" },
- { STUN_ERROR_UNSUPPORTED_FAMILY, "Address Family not Supported" },
- { STUN_ERROR_UNSUPPORTED_TRANSPORT, "Unsupported Transport Protocol" },
- { STUN_ERROR_INVALID_IP, "Invalid IP Address" },
- { STUN_ERROR_INVALID_PORT, "Invalid Port" },
- { STUN_ERROR_OP_TCP_ONLY, "Operation for TCP Only" },
- { STUN_ERROR_CONN_ALREADY, "Connection Already Exists" },
- { STUN_ERROR_ALLOCATION_QUOTA_REACHED, "Allocation Quota Reached" },
- { STUN_ERROR_ROLE_CONFLICT, "Role conflict" },
- { STUN_ERROR_SERVER_ERROR, "Server Error" },
- { STUN_ERROR_SERVER_CAPACITY, "Insufficient Capacity" },
- { STUN_ERROR_INSUFFICIENT_CAPACITY, "Insufficient Capacity" },
- };
- const char *str = "Unknown error";
- size_t i;
-
- for (i = 0; i < (sizeof (tab) / sizeof (tab[0])); i++)
- {
- if (tab[i].code == code)
- {
- str = tab[i].phrase;
- break;
- }
- }
-
- /* Maximum allowed error message length */
- // assert (strlen (str) < 128);
- return str;
-}
StunMessageReturn stun_xor_address (const StunMessage *msg,
struct sockaddr *addr, socklen_t addrlen,
@@ -165,32 +116,3 @@ StunMessageReturn stun_xor_address (const StunMessage *msg,
}
return STUN_MESSAGE_RETURN_UNSUPPORTED_ADDRESS;
}
-
-static int debug_enabled = 1;
-
-void stun_debug_enable (void) {
- debug_enabled = 1;
-}
-void stun_debug_disable (void) {
- debug_enabled = 0;
-}
-
-void stun_debug (const char *fmt, ...)
-{
- va_list ap;
- if (debug_enabled) {
- va_start (ap, fmt);
- vfprintf (stderr, fmt, ap);
- va_end (ap);
- }
-}
-
-void stun_debug_bytes (const void *data, size_t len)
-{
- size_t i;
-
- stun_debug ("0x");
- for (i = 0; i < len; i++)
- stun_debug ("%02x", ((const unsigned char *)data)[i]);
-}
-
diff --git a/stun/utils.h b/stun/utils.h
index 6b526d7..296bddf 100644
--- a/stun/utils.h
+++ b/stun/utils.h
@@ -55,21 +55,8 @@
extern "C" {
# endif
-
-/**
- * stun_optional:
- * @t: An attribute type
- *
- * Helper function that checks whether a STUN attribute is a mandatory
- * or an optional attribute
- *
- * Returns: %TRUE if the attribute is an optional one
- */
-bool stun_optional (uint16_t t);
-
size_t stun_padding (size_t l);
-
size_t stun_align (size_t l);
uint16_t stun_getw (const uint8_t *ptr);
@@ -82,37 +69,9 @@ StunMessageReturn stun_xor_address (const StunMessage *msg,
struct sockaddr *addr, socklen_t addrlen,
uint32_t magic_cookie);
-/**
- * stun_strerror:
- * @code: host-byte order error code
- *
- * Transforms a STUN error-code into a human readable string
- *
- * Returns: A static pointer to a NULL-terminated error message string.
- */
-const char *stun_strerror (StunError code);
-
-/**
- * stun_debug_enable:
- *
- * Enable debug messages to stderr
- */
-void stun_debug_enable (void);
-
-/**
- * stun_debug_disable:
- *
- * Disable debug messages to stderr
- */
-void stun_debug_disable (void);
-
-
-void stun_debug (const char *fmt, ...);
-void stun_debug_bytes (const void *data, size_t len);
-
# ifdef __cplusplus
}
# endif
-#endif /* !STUN_UTILS_H */
+#endif /* STUN_UTILS_H */