Bug 1338384: added STUN bandwidth attribute. r?bwc
MozReview-Commit-ID: DiW32Zdmen8
--- a/media/mtransport/third_party/nICEr/src/stun/stun.h
+++ b/media/mtransport/third_party/nICEr/src/stun/stun.h
@@ -109,16 +109,18 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE
#define NR_STUN_ATTR_USE_CANDIDATE 0x0025
#define NR_STUN_ATTR_ICE_CONTROLLED 0x8029
#define NR_STUN_ATTR_ICE_CONTROLLING 0x802A
#endif /* USE_ICE */
#ifdef USE_TURN
/* TURN attributes */
#define NR_STUN_ATTR_LIFETIME 0x000d
+/* from an expired draft defined as optional, but in the required range */
+#define NR_STUN_ATTR_BANDWIDTH 0x0010
#define NR_STUN_ATTR_XOR_PEER_ADDRESS 0x0012
#define NR_STUN_ATTR_DATA 0x0013
#define NR_STUN_ATTR_XOR_RELAY_ADDRESS 0x0016
#define NR_STUN_ATTR_REQUESTED_TRANSPORT 0x0019
#define NR_STUN_ATTR_REQUESTED_TRANSPORT_UDP 17
#endif /* USE_TURN */
--- a/media/mtransport/third_party/nICEr/src/stun/stun_codec.c
+++ b/media/mtransport/third_party/nICEr/src/stun/stun_codec.c
@@ -1191,16 +1191,17 @@ static nr_stun_attr_info attrs[] = {
#endif
#ifdef USE_TURN
NR_ADD_STUN_ATTRIBUTE(NR_STUN_ATTR_DATA, "DATA", nr_stun_attr_codec_data, 0)
NR_ADD_STUN_ATTRIBUTE(NR_STUN_ATTR_LIFETIME, "LIFETIME", nr_stun_attr_codec_UINT4, 0)
NR_ADD_STUN_ATTRIBUTE(NR_STUN_ATTR_XOR_RELAY_ADDRESS, "XOR-RELAY-ADDRESS", nr_stun_attr_codec_xor_mapped_address, 0)
NR_ADD_STUN_ATTRIBUTE(NR_STUN_ATTR_XOR_PEER_ADDRESS, "XOR-PEER-ADDRESS", nr_stun_attr_codec_xor_peer_address, 0)
NR_ADD_STUN_ATTRIBUTE(NR_STUN_ATTR_REQUESTED_TRANSPORT, "REQUESTED-TRANSPORT", nr_stun_attr_codec_UCHAR, 0)
+ NR_ADD_STUN_ATTRIBUTE(NR_STUN_ATTR_BANDWIDTH, "BANDWIDTH", nr_stun_attr_codec_UINT4, 0)
#endif /* USE_TURN */
/* for backwards compatibilty */
NR_ADD_STUN_ATTRIBUTE(NR_STUN_ATTR_OLD_XOR_MAPPED_ADDRESS, "Old XOR-MAPPED-ADDRESS", nr_stun_attr_codec_old_xor_mapped_address, 0)
#ifdef USE_RFC_3489_BACKWARDS_COMPATIBLE
NR_ADD_STUN_ATTRIBUTE_IGNORE(NR_STUN_ATTR_OLD_RESPONSE_ADDRESS, "RESPONSE-ADDRESS")
NR_ADD_STUN_ATTRIBUTE_IGNORE(NR_STUN_ATTR_OLD_SOURCE_ADDRESS, "SOURCE-ADDRESS")
NR_ADD_STUN_ATTRIBUTE_IGNORE(NR_STUN_ATTR_OLD_CHANGED_ADDRESS, "CHANGED-ADDRESS")
--- a/media/mtransport/third_party/nICEr/src/stun/stun_proc.c
+++ b/media/mtransport/third_party/nICEr/src/stun/stun_proc.c
@@ -147,16 +147,17 @@ nr_stun_process_request(nr_stun_message
int _status;
#ifdef USE_STUN_PEDANTIC
int r;
nr_stun_attr_unknown_attributes unknown_attributes = { { 0 } };
nr_stun_message_attribute *attr;
if (req->comprehension_required_unknown_attributes > 0) {
nr_stun_form_error_response(req, res, 420, "Unknown Attributes");
+ r_log(NR_LOG_STUN, LOG_WARNING, "Request contains comprehension required but unknown attributes");
TAILQ_FOREACH(attr, &req->attributes, entry) {
if (attr->name == 0) {
/* unrecognized attribute */
/* should never happen, but truncate if it ever were to occur */
if (unknown_attributes.num_attributes > NR_STUN_MAX_UNKNOWN_ATTRIBUTES)
break;
@@ -183,18 +184,20 @@ nr_stun_process_request(nr_stun_message
/* draft-ietf-behave-rfc3489bis-10.txt S 7.3.2 */
int
nr_stun_process_indication(nr_stun_message *ind)
{
int _status;
#ifdef USE_STUN_PEDANTIC
- if (ind->comprehension_required_unknown_attributes > 0)
+ if (ind->comprehension_required_unknown_attributes > 0) {
+ r_log(NR_LOG_STUN, LOG_WARNING, "Indication contains comprehension required but unknown attributes");
ABORT(R_REJECTED);
+ }
#endif /* USE_STUN_PEDANTIC */
_status=0;
#ifdef USE_STUN_PEDANTIC
abort:
#endif /* USE_STUN_PEDANTIC */
return _status;
}
@@ -206,18 +209,20 @@ nr_stun_process_indication(nr_stun_messa
Mozilla bug: 888274.
*/
int
nr_stun_process_success_response(nr_stun_message *res)
{
int _status;
#ifdef USE_STUN_PEDANTIC
- if (res->comprehension_required_unknown_attributes > 0)
+ if (res->comprehension_required_unknown_attributes > 0) {
+ r_log(NR_LOG_STUN, LOG_WARNING, "Response contains comprehension required but unknown attributes");
ABORT(R_REJECTED);
+ }
#endif /* USE_STUN_PEDANTIC */
if (NR_STUN_GET_TYPE_METHOD(res->header.type) == NR_METHOD_BINDING) {
if (! nr_stun_message_has_attribute(res, NR_STUN_ATTR_XOR_MAPPED_ADDRESS, 0) &&
! nr_stun_message_has_attribute(res, NR_STUN_ATTR_MAPPED_ADDRESS, 0)) {
r_log(NR_LOG_STUN, LOG_WARNING, "Missing XOR-MAPPED-ADDRESS and MAPPED_ADDRESS");
ABORT(R_REJECTED);
}
@@ -231,16 +236,17 @@ nr_stun_process_success_response(nr_stun
/* draft-ietf-behave-rfc3489bis-10.txt S 7.3.4 */
int
nr_stun_process_error_response(nr_stun_message *res, UINT2 *error_code)
{
int _status;
nr_stun_message_attribute *attr;
if (res->comprehension_required_unknown_attributes > 0) {
+ r_log(NR_LOG_STUN, LOG_WARNING, "Error response contains comprehension required but unknown attributes");
ABORT(R_REJECTED);
}
if (! nr_stun_message_has_attribute(res, NR_STUN_ATTR_ERROR_CODE, &attr)) {
r_log(NR_LOG_STUN, LOG_WARNING, "Missing ERROR-CODE");
ABORT(R_REJECTED);
}