Changeset 2041 for pjproject/trunk/pjnath/src/pjnath/stun_msg.c
- Timestamp:
- Jun 21, 2008 12:36:56 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjnath/src/pjnath/stun_msg.c
r1997 r2041 1657 1657 INIT_ATTR(attr, attr_type, length); 1658 1658 1659 attr->magic = PJ_STUN_MAGIC; 1660 1659 1661 if (data && length) { 1660 1662 attr->length = length; … … 2024 2026 if (adesc == NULL) { 2025 2027 /* Unrecognized attribute */ 2028 pj_stun_binary_attr *attr; 2026 2029 2027 2030 PJ_LOG(4,(THIS_FILE, "Unrecognized attribute type %d", … … 2047 2050 return PJ_STATUS_FROM_STUN_CODE(PJ_STUN_SC_UNKNOWN_ATTRIBUTE); 2048 2051 } 2052 2053 /* Make sure we have rooms for the new attribute */ 2054 if (msg->attr_count >= PJ_STUN_MAX_ATTR) { 2055 if (p_response) { 2056 pj_stun_msg_create_response(pool, msg, 2057 PJ_STUN_SC_SERVER_ERROR, 2058 NULL, p_response); 2059 } 2060 return PJNATH_ESTUNTOOMANYATTR; 2061 } 2062 2063 /* Create binary attribute to represent this */ 2064 status = pj_stun_binary_attr_create(pool, attr_type, pdu+4, 2065 GETVAL16H(pdu, 2), &attr); 2066 if (status != PJ_SUCCESS) { 2067 if (p_response) { 2068 pj_stun_msg_create_response(pool, msg, 2069 PJ_STUN_SC_SERVER_ERROR, 2070 NULL, p_response); 2071 } 2072 2073 PJ_LOG(4,(THIS_FILE, 2074 "Error parsing unknown STUN attribute type %d", 2075 attr_type)); 2076 2077 return status; 2078 } 2079 2080 /* Add the attribute */ 2081 msg->attr[msg->attr_count++] = &attr->hdr; 2049 2082 2050 2083 } else { … … 2125 2158 if (p_response) { 2126 2159 pj_stun_msg_create_response(pool, msg, 2127 PJ_STUN_SC_ BAD_REQUEST,2160 PJ_STUN_SC_SERVER_ERROR, 2128 2161 NULL, p_response); 2129 2162 } … … 2135 2168 } 2136 2169 2170 /* Next attribute */ 2137 2171 if (attr_val_len + 4 >= pdu_len) { 2138 2172 pdu += pdu_len; … … 2240 2274 2241 2275 adesc = find_attr_desc(attr_hdr->type); 2242 PJ_ASSERT_RETURN(adesc != NULL, PJ_EBUG); 2243 2244 status = adesc->encode_attr(attr_hdr, buf, buf_size, &printed); 2276 if (adesc) { 2277 status = adesc->encode_attr(attr_hdr, buf, buf_size, &printed); 2278 } else { 2279 /* This may be a generic attribute */ 2280 const pj_stun_binary_attr *bin_attr = (const pj_stun_binary_attr*) 2281 attr_hdr; 2282 PJ_ASSERT_RETURN(bin_attr->magic == PJ_STUN_MAGIC, PJ_EBUG); 2283 status = encode_binary_attr(bin_attr, buf, buf_size, &printed); 2284 } 2285 2245 2286 if (status != PJ_SUCCESS) 2246 2287 return status; … … 2415 2456 /* Get the attribute descriptor */ 2416 2457 adesc = find_attr_desc(attr->type); 2417 PJ_ASSERT_RETURN(adesc != NULL, NULL); 2418 2419 return (pj_stun_attr_hdr*) (*adesc->clone_attr)(pool, attr); 2420 } 2421 2422 2458 if (adesc) { 2459 return (pj_stun_attr_hdr*) (*adesc->clone_attr)(pool, attr); 2460 } else { 2461 /* Clone generic attribute */ 2462 const pj_stun_binary_attr *bin_attr = (const pj_stun_binary_attr*) 2463 attr; 2464 PJ_ASSERT_RETURN(bin_attr->magic == PJ_STUN_MAGIC, NULL); 2465 if (bin_attr->magic == PJ_STUN_MAGIC) { 2466 return (pj_stun_attr_hdr*) clone_binary_attr(pool, attr); 2467 } else { 2468 return NULL; 2469 } 2470 } 2471 } 2472 2473
Note: See TracChangeset
for help on using the changeset viewer.