Changeset 1654
- Timestamp:
- Jan 2, 2008 8:24:10 AM (17 years ago)
- Location:
- pjproject/trunk/pjnath
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjnath/include/pjnath/config.h
r1479 r1654 256 256 257 257 258 /** ICE session pool initial size. */ 259 #ifndef PJNATH_POOL_LEN_ICE_SESS 260 # define PJNATH_POOL_LEN_ICE_SESS 512 261 #endif 262 263 /** ICE session pool increment size */ 264 #ifndef PJNATH_POOL_INC_ICE_SESS 265 # define PJNATH_POOL_INC_ICE_SESS 512 266 #endif 267 268 /** ICE stream transport pool initial size. */ 269 #ifndef PJNATH_POOL_LEN_ICE_STRANS 270 # define PJNATH_POOL_LEN_ICE_STRANS 1000 271 #endif 272 273 /** ICE stream transport pool increment size */ 274 #ifndef PJNATH_POOL_INC_ICE_STRANS 275 # define PJNATH_POOL_INC_ICE_STRANS 512 276 #endif 277 278 /** NAT detect pool initial size */ 279 #ifndef PJNATH_POOL_LEN_NATCK 280 # define PJNATH_POOL_LEN_NATCK 512 281 #endif 282 283 /** NAT detect pool increment size */ 284 #ifndef PJNATH_POOL_INC_NATCK 285 # define PJNATH_POOL_INC_NATCK 512 286 #endif 287 288 /** STUN session pool initial size */ 289 #ifndef PJNATH_POOL_LEN_STUN_SESS 290 # define PJNATH_POOL_LEN_STUN_SESS 1000 291 #endif 292 293 /** STUN session pool increment size */ 294 #ifndef PJNATH_POOL_INC_STUN_SESS 295 # define PJNATH_POOL_INC_STUN_SESS 1000 296 #endif 297 298 /** STUN session transmit data pool initial size */ 299 #ifndef PJNATH_POOL_LEN_STUN_TDATA 300 # define PJNATH_POOL_LEN_STUN_TDATA 1000 301 #endif 302 303 /** STUN session transmit data pool increment size */ 304 #ifndef PJNATH_POOL_INC_STUN_TDATA 305 # define PJNATH_POOL_INC_STUN_TDATA 1000 306 #endif 307 308 258 309 /** 259 310 * @} -
pjproject/trunk/pjnath/include/pjnath/ice_session.h
r1487 r1654 26 26 #include <pjnath/types.h> 27 27 #include <pjnath/stun_session.h> 28 #include <pjnath/errno.h> 28 29 #include <pj/sock.h> 29 30 #include <pj/timer.h> … … 561 562 /* Valid list */ 562 563 pj_ice_sess_checklist valid_list; /**< Valid list. */ 564 565 /* Temporary buffer for misc stuffs to avoid using stack too much */ 566 union { 567 char txt[128]; 568 char errmsg[PJ_ERR_MSG_SIZE]; 569 } tmp; 563 570 }; 564 571 -
pjproject/trunk/pjnath/src/pjnath/ice_session.c
r1574 r1654 18 18 */ 19 19 #include <pjnath/ice_session.h> 20 #include <pjnath/errno.h>21 20 #include <pj/addr_resolv.h> 22 21 #include <pj/array.h> … … 262 261 name = "ice%p"; 263 262 264 pool = pj_pool_create(stun_cfg->pf, name, 4000, 4000, NULL); 263 pool = pj_pool_create(stun_cfg->pf, name, PJNATH_POOL_LEN_ICE_SESS, 264 PJNATH_POOL_INC_ICE_SESS, NULL); 265 265 ice = PJ_POOL_ZALLOC_T(pool, pj_ice_sess); 266 266 ice->pool = pool; … … 558 558 pj_ice_sess_cand *lcand; 559 559 pj_status_t status = PJ_SUCCESS; 560 char tmp[128];561 560 562 561 PJ_ASSERT_RETURN(ice && comp_id && … … 585 584 586 585 587 pj_ansi_strcpy( tmp, pj_inet_ntoa(lcand->addr.ipv4.sin_addr));586 pj_ansi_strcpy(ice->tmp.txt, pj_inet_ntoa(lcand->addr.ipv4.sin_addr)); 588 587 LOG4((ice->obj_name, 589 588 "Candidate %d added: comp_id=%d, type=%s, foundation=%.*s, " … … 594 593 (int)lcand->foundation.slen, 595 594 lcand->foundation.ptr, 596 tmp,595 ice->tmp.txt, 597 596 (int)pj_ntohs(lcand->addr.ipv4.sin_port), 598 597 pj_inet_ntoa(lcand->base_addr.ipv4.sin_addr), … … 734 733 const pj_ice_sess_cand *lcand = check->lcand; 735 734 const pj_ice_sess_cand *rcand = check->rcand; 736 char laddr[ CHECK_NAME_LEN];735 char laddr[PJ_INET6_ADDRSTRLEN]; 737 736 int len; 737 738 PJ_CHECK_STACK(); 738 739 739 740 pj_ansi_strcpy(laddr, pj_inet_ntoa(lcand->addr.ipv4.sin_addr)); … … 761 762 } 762 763 763 static void dump_checklist(const char *title, constpj_ice_sess *ice,764 static void dump_checklist(const char *title, pj_ice_sess *ice, 764 765 const pj_ice_sess_checklist *clist) 765 766 { 766 767 unsigned i; 767 char buffer[CHECK_NAME_LEN];768 768 769 769 LOG4((ice->obj_name, "%s", title)); … … 771 771 const pj_ice_sess_check *c = &clist->checks[i]; 772 772 LOG4((ice->obj_name, " %s (%s, state=%s)", 773 dump_check( buffer, sizeof(buffer), clist, c),773 dump_check(ice->tmp.txt, sizeof(ice->tmp.txt), clist, c), 774 774 (c->nominated ? "nominated" : "not nominated"), 775 775 check_state_name[c->state])); … … 785 785 pj_status_t err_code) 786 786 { 787 char buf[CHECK_NAME_LEN];788 789 787 pj_assert(check->state < PJ_ICE_SESS_CHECK_STATE_SUCCEEDED); 790 788 791 789 LOG5((ice->obj_name, "Check %s: state changed from %s to %s", 792 dump_check( buf, sizeof(buf), &ice->clist, check),790 dump_check(ice->tmp.txt, sizeof(ice->tmp.txt), &ice->clist, check), 793 791 check_state_name[check->state], 794 792 check_state_name[st])); … … 938 936 if (reason != NULL) { 939 937 /* Found duplicate, remove it */ 940 char buf[CHECK_NAME_LEN];941 942 938 LOG5((ice->obj_name, "Check %s pruned (%s)", 943 dump_check( buf, sizeof(buf), &ice->clist,944 939 dump_check(ice->tmp.txt, sizeof(ice->tmp.txt), 940 &ice->clist, &clist->checks[j]), 945 941 reason)); 946 942 … … 976 972 { 977 973 if (!ice->is_complete) { 978 char errmsg[PJ_ERR_MSG_SIZE];979 980 974 ice->is_complete = PJ_TRUE; 981 975 ice->ice_status = status; … … 983 977 /* Log message */ 984 978 LOG4((ice->obj_name, "ICE process complete, status=%s", 985 pj_strerror(status, errmsg, sizeof(errmsg)).ptr)); 979 pj_strerror(status, ice->tmp.errmsg, 980 sizeof(ice->tmp.errmsg)).ptr)); 986 981 987 982 dump_checklist("Valid list", ice, &ice->valid_list); … … 1057 1052 if (check->err_code==PJ_SUCCESS && check->nominated) { 1058 1053 pj_ice_sess_comp *comp; 1059 char buf[CHECK_NAME_LEN];1060 1054 1061 1055 LOG5((ice->obj_name, "Check %d is successful and nominated", … … 1075 1069 LOG5((ice->obj_name, 1076 1070 "Check %s to be failed because state is %s", 1077 dump_check(buf, sizeof(buf), &ice->clist, c), 1071 dump_check(ice->tmp.txt, sizeof(ice->tmp.txt), 1072 &ice->clist, c), 1078 1073 check_state_name[c->state])); 1079 1074 check_set_state(ice, c, PJ_ICE_SESS_CHECK_STATE_FAILED, … … 1088 1083 LOG5((ice->obj_name, 1089 1084 "Cancelling check %s (In Progress)", 1090 dump_check(buf, sizeof(buf), &ice->clist, c))); 1085 dump_check(ice->tmp.txt, sizeof(ice->tmp.txt), 1086 &ice->clist, c))); 1091 1087 pj_stun_session_cancel_req(comp->stun_sess, 1092 1088 c->tdata, PJ_FALSE, 0); … … 1369 1365 const pj_ice_sess_cand *rcand; 1370 1366 pj_uint32_t prio; 1371 char buffer[128];1372 1367 pj_status_t status; 1373 1368 … … 1379 1374 LOG5((ice->obj_name, 1380 1375 "Sending connectivity check for check %s", 1381 dump_check( buffer, sizeof(buffer), clist, check)));1376 dump_check(ice->tmp.txt, sizeof(ice->tmp.txt), clist, check))); 1382 1377 1383 1378 /* Create request */ … … 1554 1549 pj_ice_sess_checklist *clist; 1555 1550 const pj_ice_sess_cand *cand0; 1556 const pj_str_t *flist[PJ_ICE_MAX_CAND]; 1551 const pj_str_t *flist[PJ_ICE_MAX_CAND]; // XXX 1557 1552 pj_ice_rx_check *rcheck; 1558 1553 unsigned i, flist_cnt = 0; 1554 pj_time_val delay; 1555 pj_status_t status; 1559 1556 1560 1557 PJ_ASSERT_RETURN(ice, PJ_EINVAL); … … 1625 1622 1626 1623 /* Start periodic check */ 1627 return start_periodic_check(ice->stun_cfg.timer_heap, &clist->timer); 1624 /* We could start it immediately like below, but lets schedule timer 1625 * instead to reduce stack usage: 1626 * return start_periodic_check(ice->stun_cfg.timer_heap, &clist->timer); 1627 */ 1628 clist->timer.id = PJ_TRUE; 1629 delay.sec = delay.msec = 0; 1630 status = pj_timer_heap_schedule(ice->stun_cfg.timer_heap, 1631 &clist->timer, &delay); 1632 if (status != PJ_SUCCESS) { 1633 clist->timer.id = PJ_FALSE; 1634 } 1635 1636 return status; 1628 1637 } 1629 1638 … … 1662 1671 pj_ice_sess_checklist *clist; 1663 1672 pj_stun_xor_mapped_addr_attr *xaddr; 1664 char buffer[CHECK_NAME_LEN];1665 1673 unsigned i; 1666 1674 … … 1731 1739 LOG4((ice->obj_name, 1732 1740 "Check %s%s: connectivity check FAILED: %s", 1733 dump_check(buffer, sizeof(buffer), &ice->clist, check), 1741 dump_check(ice->tmp.txt, sizeof(ice->tmp.txt), 1742 &ice->clist, check), 1734 1743 (check->nominated ? " (nominated)" : " (not nominated)"), 1735 1744 errmsg)); … … 1754 1763 LOG4((ice->obj_name, 1755 1764 "Check %s%s: connectivity check FAILED: source address mismatch", 1756 dump_check(buffer, sizeof(buffer), &ice->clist, check), 1765 dump_check(ice->tmp.txt, sizeof(ice->tmp.txt), 1766 &ice->clist, check), 1757 1767 (check->nominated ? " (nominated)" : " (not nominated)"))); 1758 1768 check_set_state(ice, check, PJ_ICE_SESS_CHECK_STATE_FAILED, status); … … 1780 1790 LOG4((ice->obj_name, 1781 1791 "Check %s%s: connectivity check SUCCESS", 1782 dump_check(buffer, sizeof(buffer), &ice->clist, check), 1792 dump_check(ice->tmp.txt, sizeof(ice->tmp.txt), 1793 &ice->clist, check), 1783 1794 (check->nominated ? " (nominated)" : " (not nominated)"))); 1784 1795 … … 2358 2369 NULL, src_addr, src_addr_len); 2359 2370 if (status != PJ_SUCCESS) { 2360 char errmsg[PJ_ERR_MSG_SIZE]; 2361 pj_strerror(status, errmsg, sizeof(errmsg)); 2371 pj_strerror(status, ice->tmp.errmsg, sizeof(ice->tmp.errmsg)); 2362 2372 LOG4((ice->obj_name, "Error processing incoming message: %s", 2363 errmsg));2373 ice->tmp.errmsg)); 2364 2374 } 2365 2375 } else { -
pjproject/trunk/pjnath/src/pjnath/ice_strans.c
r1604 r1654 98 98 name = "icstr%p"; 99 99 100 pool = pj_pool_create(stun_cfg->pf, name, 1000, 512, NULL); 100 pool = pj_pool_create(stun_cfg->pf, name, PJNATH_POOL_LEN_ICE_STRANS, 101 PJNATH_POOL_INC_ICE_STRANS, NULL); 101 102 ice_st = PJ_POOL_ZALLOC_T(pool, pj_ice_strans); 102 103 ice_st->pool = pool; -
pjproject/trunk/pjnath/src/pjnath/nat_detect.c
r1546 r1654 221 221 * Init NAT detection session. 222 222 */ 223 pool = pj_pool_create(stun_cfg->pf, "natck%p", 512, 512, NULL); 223 pool = pj_pool_create(stun_cfg->pf, "natck%p", PJNATH_POOL_LEN_NATCK, 224 PJNATH_POOL_INC_NATCK, NULL); 224 225 if (!pool) 225 226 return PJ_ENOMEM; -
pjproject/trunk/pjnath/src/pjnath/stun_msg.c
r1479 r1654 708 708 pj_uint32_t val; 709 709 710 PJ_CHECK_STACK(); 711 710 712 /* Create the attribute */ 711 713 attr = PJ_POOL_ZALLOC_T(pool, pj_stun_sockaddr_attr); … … 772 774 return PJ_ETOOSMALL; 773 775 776 PJ_CHECK_STACK(); 777 774 778 /* Copy and convert headers to network byte order */ 775 779 PUTVAL16H(buf, 0, ca->hdr.type); … … 900 904 (const pj_stun_string_attr*)a; 901 905 906 PJ_CHECK_STACK(); 907 902 908 /* Calculated total attr_len (add padding if necessary) */ 903 909 *printed = (ca->value.slen + ATTR_HDR_LEN + 3) & (~3); … … 1081 1087 const pj_stun_uint_attr *ca = (const pj_stun_uint_attr*)a; 1082 1088 1089 PJ_CHECK_STACK(); 1090 1083 1091 if (len < 8) 1084 1092 return PJ_ETOOSMALL; … … 1164 1172 const pj_stun_uint64_attr *ca = (const pj_stun_uint64_attr*)a; 1165 1173 1174 PJ_CHECK_STACK(); 1175 1166 1176 if (len < 12) 1167 1177 return PJ_ETOOSMALL; … … 1243 1253 const pj_stun_msgint_attr *ca = (const pj_stun_msgint_attr*)a; 1244 1254 1255 PJ_CHECK_STACK(); 1256 1245 1257 if (len < 24) 1246 1258 return PJ_ETOOSMALL; … … 1347 1359 (const pj_stun_errcode_attr*)a; 1348 1360 1361 PJ_CHECK_STACK(); 1362 1349 1363 if (len < ATTR_HDR_LEN + 4 + (unsigned)ca->reason.slen) 1350 1364 return PJ_ETOOSMALL; … … 1462 1476 unsigned i; 1463 1477 1478 PJ_CHECK_STACK(); 1479 1464 1480 /* Check that buffer is enough */ 1465 1481 if (len < ATTR_HDR_LEN + (ca->attr_count << 1)) … … 1562 1578 const pj_stun_binary_attr *ca = (const pj_stun_binary_attr*)a; 1563 1579 1580 PJ_CHECK_STACK(); 1581 1564 1582 /* Calculated total attr_len (add padding if necessary) */ 1565 1583 *printed = (ca->length + ATTR_HDR_LEN + 3) & (~3); -
pjproject/trunk/pjnath/src/pjnath/stun_msg_dump.c
r1450 r1654 20 20 #include <pjnath/errno.h> 21 21 #include <pj/assert.h> 22 #include <pj/os.h> 22 23 #include <pj/string.h> 23 24 24 25 25 #if PJ_LOG_MAX_LEVEL > 0 … … 237 237 PJ_ASSERT_RETURN(msg && buffer && length, NULL); 238 238 239 PJ_CHECK_STACK(); 240 239 241 p = buffer; 240 242 end = buffer + length; -
pjproject/trunk/pjnath/src/pjnath/stun_session.c
r1544 r1654 46 46 #define LOG_ERR_(sess,title,rc) pjnath_perror(sess->pool->obj_name,title,rc) 47 47 48 #define TDATA_POOL_SIZE 102449 #define TDATA_POOL_INC 102448 #define TDATA_POOL_SIZE PJNATH_POOL_LEN_STUN_TDATA 49 #define TDATA_POOL_INC PJNATH_POOL_INC_STUN_TDATA 50 50 51 51 … … 384 384 385 385 if (name==NULL) 386 name = "sess%p"; 387 388 pool = pj_pool_create(cfg->pf, name, 4000, 4000, NULL); 386 name = "stuse%p"; 387 388 pool = pj_pool_create(cfg->pf, name, PJNATH_POOL_LEN_STUN_SESS, 389 PJNATH_POOL_INC_STUN_SESS, NULL); 389 390 PJ_ASSERT_RETURN(pool, PJ_ENOMEM); 390 391 … … 996 997 PJ_ASSERT_RETURN(sess && packet && pkt_size, PJ_EINVAL); 997 998 998 tmp_pool = pj_pool_create(sess->cfg->pf, "tmpstun", 1024, 1024, NULL); 999 tmp_pool = pj_pool_create(sess->cfg->pf, "tmpstun", 1000 PJNATH_POOL_LEN_STUN_TDATA, 1001 PJNATH_POOL_INC_STUN_TDATA, NULL); 999 1002 if (!tmp_pool) 1000 1003 return PJ_ENOMEM;
Note: See TracChangeset
for help on using the changeset viewer.