- Timestamp:
- Jul 6, 2010 8:11:04 AM (14 years ago)
- Location:
- pjproject/trunk/pjlib-util
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjlib-util/include/pjlib-util/stun_simple.h
r2394 r3235 61 61 PJSTUN_ATTR_ERROR_CODE, 62 62 PJSTUN_ATTR_UNKNOWN_ATTRIBUTES, 63 PJSTUN_ATTR_REFLECTED_FORM 63 PJSTUN_ATTR_REFLECTED_FROM, 64 PJSTUN_ATTR_XOR_MAPPED_ADDR = 0x0020 64 65 } pjstun_attr_type; 65 66 -
pjproject/trunk/pjlib-util/src/pjlib-util/stun_simple.c
r2394 r3235 87 87 pjstun_attr_hdr **attr = &msg->attr[msg->attr_count]; 88 88 pj_uint32_t len; 89 pj_uint16_t attr_type; 89 90 90 91 *attr = (pjstun_attr_hdr*)p_attr; … … 98 99 } 99 100 100 if (pj_ntohs((*attr)->type) > PJSTUN_ATTR_REFLECTED_FORM) { 101 attr_type = pj_ntohs((*attr)->type); 102 if (attr_type > PJSTUN_ATTR_REFLECTED_FROM && 103 attr_type != PJSTUN_ATTR_XOR_MAPPED_ADDR) 104 { 101 105 PJ_LOG(5,(THIS_FILE, "Warning: unknown attr type %x in attr %d. " 102 106 "Attribute was ignored.", 103 pj_ntohs((*attr)->type), msg->attr_count));107 attr_type, msg->attr_count)); 104 108 } 105 109 -
pjproject/trunk/pjlib-util/src/pjlib-util/stun_simple_client.c
r2394 r3235 30 30 enum { MAX_REQUEST = 4 }; 31 31 static int stun_timer[] = {1000, 1000, 1000, 1000 }; 32 #define STUN_MAGIC 0x2112A442 32 33 33 34 #define THIS_FILE "stun_client.c" … … 224 225 pjstun_msg_find_attr(&msg, PJSTUN_ATTR_MAPPED_ADDR); 225 226 if (!attr) { 226 status = PJLIB_UTIL_ESTUNNOMAP; 227 continue; 227 attr = (pjstun_mapped_addr_attr*) 228 pjstun_msg_find_attr(&msg, PJSTUN_ATTR_XOR_MAPPED_ADDR); 229 if (!attr || attr->family != 1) { 230 status = PJLIB_UTIL_ESTUNNOMAP; 231 continue; 232 } 228 233 } 229 234 230 235 rec[sock_idx].srv[srv_idx].mapped_addr = attr->addr; 231 236 rec[sock_idx].srv[srv_idx].mapped_port = attr->port; 237 if (pj_ntohs(attr->hdr.type) == PJSTUN_ATTR_XOR_MAPPED_ADDR) { 238 rec[sock_idx].srv[srv_idx].mapped_addr ^= pj_htonl(STUN_MAGIC); 239 rec[sock_idx].srv[srv_idx].mapped_port ^= pj_htons(STUN_MAGIC >> 16); 240 } 232 241 } 233 242 }
Note: See TracChangeset
for help on using the changeset viewer.