diff options
author | Youness Alaoui <youness.alaoui@collabora.co.uk> | 2009-03-05 15:22:33 -0500 |
---|---|---|
committer | Youness Alaoui <youness.alaoui@collabora.co.uk> | 2009-03-05 15:22:33 -0500 |
commit | 994f4ae9c2859c47d948faa3270c9c2801565555 (patch) | |
tree | 0a215dd47fa7d0261248988ec4d7c1e88445aafc /stun/utils.c | |
parent | 494d8a0be807c64e3e13d7020ba14d3d5c5684bc (diff) | |
download | libnice-994f4ae9c2859c47d948faa3270c9c2801565555.tar.gz |
Move functions and prototypes from one file to another to avoid having to install non public headers
Diffstat (limited to 'stun/utils.c')
-rw-r--r-- | stun/utils.c | 78 |
1 files changed, 0 insertions, 78 deletions
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]); -} - |