Commit cb194547 authored by Kai Vehmanen's avatar Kai Vehmanen

Adds a workaround for a bug in stund-0.94 and older...

Adds a workaround for a bug in stund-0.94 and older (http://sourceforge.net/projects/stun/). Added new STUN attributes defined in recent STUN and TURN IETF drafts.

darcs-hash:20060726112455-7659e-345688ba16b5ef33529a39b01a656720ea3ef9a4.gz
parent 6bb7423e
2006-07-11 Kai Vehmanen <kai.vehmanen@nokia.com>
* sofia-sip/stun_common.h: New defines for STUN attributes defined
in RFC3489bis. Some old defines have been deprecated, but are still
supported in the API.
2006-05-22 Kai Vehmanen <kai.vehmanen@nokia.com>
* Makefile.am: Install the stunc tool.
......
......@@ -75,9 +75,26 @@ SOFIA_BEGIN_DECLS
#define ERROR_CODE 0x0009
#define UNKNOWN_ATTRIBUTES 0x000a
#define REFLECTED_FROM 0x000b
#define LARGEST_ATTRIBUTE 0x000b /**< largest attribute in
the current spec */
#define OPTIONAL_ATTRIBUTE 0x7fff
#define STUN_A_REALM 0x0014 /* XXX: check value in 3489bis-05+ */
#define STUN_A_NONCE 0x0015 /* XXX: check value in 3489bis-05+ */
#define STUN_A_XOR_MAPPED_ADDRESS 0x0020
#define STUN_A_FINGERPRINT 0x0023
#define STUN_A_SERVER 0x8022
#define STUN_A_ALTERNATE_SERVER 0x8023
#define STUN_A_REFRESH_INTERVAL 0x8024
/* Defines for mandatory and optional attributes */
#define STUN_A_LAST_MANDATORY 0x0023 /**< largest attribute in the current
spec (see above for exceptions
for buggy servers) */
#define STUN_A_OPTIONAL 0x7fff
/* Compability attribute types */
#define STUN_A_ALTERNATE_SERVER_DEP 0x000e /**< historic from early fc3489bis drafts */
#define STUN_A_BUGGYSERVER_XORONLY 0x0021 /**< workaround for stund-0.94 and older */
#define STUN_A_BUGGYSERVER_SERVER 0x0022 /**< workaround for stund-0.94 and older */
#define LARGEST_ATTRIBUTE STUN_A_LAST_MANDATORY /**< deprecated API */
#define OPTIONAL_ATTRIBUTE STUN_A_OPTIONAL /**< deprecated API */
/* Stun response codes */
#define STUN_400_BAD_REQUEST 400
......
......@@ -39,8 +39,8 @@
#ifdef USE_TURN
#include "../turn/turn_common.h"
#undef LARGEST_ATTRIBUTE
#define LARGEST_ATTRIBUTE TURN_LARGEST_ATTRIBUTE
#undef STUN_A_LAST_MANDATORY
#define STUN_A_LAST_MANDATORY TURN_LARGEST_ATTRIBUTE
#endif
#include "stun_internal.h"
......@@ -123,7 +123,7 @@ int stun_parse_attribute(stun_msg_t *msg, unsigned char *p)
SU_DEBUG_5(("%s: received attribute: Type %02X, Length %d - %s\n",
__func__, attr_type, len, stun_attr_phrase(attr_type)));
if (attr_type > LARGEST_ATTRIBUTE && attr_type < OPTIONAL_ATTRIBUTE) {
if (attr_type > STUN_A_LAST_MANDATORY && attr_type < STUN_A_OPTIONAL) {
return -1;
}
......@@ -166,6 +166,8 @@ int stun_parse_attribute(stun_msg_t *msg, unsigned char *p)
break;
case USERNAME:
case PASSWORD:
case STUN_A_REALM:
case STUN_A_NONCE:
#ifdef USE_TURN
case TURN_DATA:
case TURN_NONCE:
......@@ -794,6 +796,12 @@ const char *stun_attr_phrase(uint16_t type)
case ERROR_CODE: return "ERROR-CODE";
case UNKNOWN_ATTRIBUTES: return "UNKNOWN-ATTRIBUTES";
case REFLECTED_FROM: return "REFLECTED-FROM";
case STUN_A_ALTERNATE_SERVER:
case STUN_A_ALTERNATE_SERVER_DEP:
return "ALTERNATE-SERVER";
case STUN_A_REALM: return "REALM";
case STUN_A_NONCE: return "NONCE";
case STUN_A_XOR_MAPPED_ADDRESS: return "XOR-MAPPED-ADDRESS";
#ifdef USE_TURN
case TURN_REALM: return "REALM";
case TURN_LIFETIME: return "LIFETIME";
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment