Changeset 1101 for pjproject/trunk/pjnath/src/pjnath/stun_msg.c
- Timestamp:
- Mar 24, 2007 1:00:30 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjnath/src/pjnath/stun_msg.c
r1094 r1101 65 65 { PJ_STUN_SC_STALE_NONCE, "Stale Nonce"}, 66 66 { PJ_STUN_SC_TRANSITIONING, "Active Destination Already Set"}, 67 { PJ_STUN_SC_WRONG_USERNAME, "Wrong Username"},68 67 { PJ_STUN_SC_UNSUPP_TRANSPORT_PROTO, "Unsupported Transport Protocol"}, 69 68 { PJ_STUN_SC_INVALID_IP_ADDR, "Invalid IP Address"}, … … 514 513 PJ_DEF(pj_str_t) pj_stun_get_err_reason(int err_code) 515 514 { 515 #if 0 516 /* Find error using linear search */ 516 517 unsigned i; 517 518 … … 521 522 } 522 523 return pj_str(NULL); 524 #else 525 /* Find error message using binary search */ 526 int first = 0; 527 int n = PJ_ARRAY_SIZE(stun_err_msg_map); 528 529 while (n > 0) { 530 int half = n/2; 531 int mid = first + half; 532 533 if (stun_err_msg_map[mid].err_code < err_code) { 534 first = mid+1; 535 n -= (half+1); 536 } else if (stun_err_msg_map[mid].err_code > err_code) { 537 n = half; 538 } else { 539 first = mid; 540 break; 541 } 542 } 543 544 545 if (stun_err_msg_map[first].err_code == err_code) { 546 return pj_str((char*)stun_err_msg_map[first].err_msg); 547 } else { 548 return pj_str(NULL); 549 } 550 #endif 523 551 } 524 552 … … 1580 1608 1581 1609 if (pdu_len < sizeof(pj_stun_msg_hdr)) 1582 return PJNATH_E STUNINMSGLEN;1610 return PJNATH_EINSTUNMSGLEN; 1583 1611 1584 1612 /* First byte of STUN message is always 0x00 or 0x01. */ 1585 1613 if (*pdu != 0x00 && *pdu != 0x01) 1586 return PJNATH_E STUNINMSGTYPE;1614 return PJNATH_EINSTUNMSGTYPE; 1587 1615 1588 1616 /* Check the PDU length */ … … 1591 1619 ((options & PJ_STUN_IS_DATAGRAM) && msg_len + 20 != pdu_len)) 1592 1620 { 1593 return PJNATH_E STUNINMSGLEN;1621 return PJNATH_EINSTUNMSGLEN; 1594 1622 } 1595 1623 … … 1635 1663 1636 1664 PJ_ASSERT_RETURN(PJ_STUN_IS_REQUEST(msg_type), 1637 PJNATH_E STUNINMSGTYPE);1665 PJNATH_EINSTUNMSGTYPE); 1638 1666 1639 1667 /* Create response or error response */ … … 1774 1802 } 1775 1803 1776 return PJ NATH_ESTUNUNKNOWNATTR;1804 return PJ_STATUS_FROM_STUN_CODE(PJ_STUN_SC_UNKNOWN_ATTRIBUTE); 1777 1805 } 1778 1806 … … 2103 2131 /* Should not happen for message generated by us */ 2104 2132 pj_assert(PJ_FALSE); 2105 return PJ NATH_ESTUNNOUSERNAME;2133 return PJ_STATUS_FROM_STUN_CODE(PJ_STUN_SC_MISSING_USERNAME); 2106 2134 } 2107 2135
Note: See TracChangeset
for help on using the changeset viewer.