diff options
author | Benny Prijono <bennylp@teluu.com> | 2009-10-07 08:38:02 +0000 |
---|---|---|
committer | Benny Prijono <bennylp@teluu.com> | 2009-10-07 08:38:02 +0000 |
commit | dd24667ae19923f1d5ca50628dd164be96a08d61 (patch) | |
tree | c867e722739e1bbac92a2284f2e3fc86637737e4 /pjnath/src/pjnath/stun_msg.c | |
parent | 1523d8e3556c4c82d76914337892ab140d4e5045 (diff) |
More ticket #960: STUN compatibility problem with RFC 3489 servers (in encoding SERVER-NAME or SOFTWARE attribute)
- rollback the previous fix in r2916 since it is broken. It fails various authentication scenarios due to alignment of USERNAME attribute
- this fix only applies old alignment rule to SERVERNAME attribute or when STUN magic is not used in the message
- also disabled test vectors from draft-denis-behave-rfc3489bis-test-vectors-02, it fails with this fix
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@2928 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjnath/src/pjnath/stun_msg.c')
-rw-r--r-- | pjnath/src/pjnath/stun_msg.c | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/pjnath/src/pjnath/stun_msg.c b/pjnath/src/pjnath/stun_msg.c index fb9f1cb9..e9c86212 100644 --- a/pjnath/src/pjnath/stun_msg.c +++ b/pjnath/src/pjnath/stun_msg.c @@ -1235,10 +1235,22 @@ static pj_status_t encode_string_attr(const void *a, pj_uint8_t *buf, PUTVAL16H(buf, 0, ca->hdr.type); - /* Set the length to be 4-bytes aligned so that we can - * communicate with RFC 3489 endpoints + /* Special treatment for SOFTWARE attribute: + * This attribute had caused interop problem when talking to + * legacy RFC 3489 STUN servers, due to different "length" + * rules with RFC 5389. */ - PUTVAL16H(buf, 2, (pj_uint16_t)((ca->value.slen + 3) & (~3))); + if (msghdr->magic != PJ_STUN_MAGIC || + ca->hdr.type == PJ_STUN_ATTR_SOFTWARE) + { + /* Set the length to be 4-bytes aligned so that we can + * communicate with RFC 3489 endpoints + */ + PUTVAL16H(buf, 2, (pj_uint16_t)((ca->value.slen + 3) & (~3))); + } else { + /* Use RFC 5389 rule */ + PUTVAL16H(buf, 2, (pj_uint16_t)ca->value.slen); + } /* Copy the string */ pj_memcpy(buf+ATTR_HDR_LEN, ca->value.ptr, ca->value.slen); |