Changeset 1877 for pjproject/trunk/pjnath/src/pjnath/stun_session.c
- Timestamp:
- Mar 19, 2008 11:00:30 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjnath/src/pjnath/stun_session.c
r1869 r1877 18 18 */ 19 19 #include <pjnath/stun_session.h> 20 #include <pjnath/errno.h> 20 21 #include <pjlib.h> 21 22 … … 30 31 31 32 pj_bool_t use_fingerprint; 32 pj_stun_auth_cred *cred; 33 34 char dump_buf[1000]; 35 36 pj_stun_auth_type auth_type; 37 pj_stun_auth_cred cred; 38 int auth_retry; 39 pj_str_t next_nonce; 40 33 41 pj_str_t srv_name; 34 42 … … 126 134 } 127 135 128 static pj_status_t create_request_tdata(pj_stun_session *sess,129 unsigned msg_type,130 pj_uint32_t magic,131 const pj_uint8_t tsx_id[12],132 pj_stun_tx_data **p_tdata)133 {134 pj_status_t status;135 pj_stun_tx_data *tdata;136 137 status = create_tdata(sess, &tdata);138 if (status != PJ_SUCCESS)139 return status;140 141 /* Create STUN message */142 status = pj_stun_msg_create(tdata->pool, msg_type, magic,143 tsx_id, &tdata->msg);144 if (status != PJ_SUCCESS) {145 pj_pool_release(tdata->pool);146 return status;147 }148 149 /* copy the request's transaction ID as the transaction key. */150 pj_assert(sizeof(tdata->msg_key)==sizeof(tdata->msg->hdr.tsx_id));151 tdata->msg_magic = tdata->msg->hdr.magic;152 pj_memcpy(tdata->msg_key, tdata->msg->hdr.tsx_id,153 sizeof(tdata->msg->hdr.tsx_id));154 155 *p_tdata = tdata;156 157 return PJ_SUCCESS;158 }159 160 161 136 static void stun_tsx_on_destroy(pj_stun_client_tsx *tsx) 162 137 { … … 216 191 } 217 192 218 static pj_status_t get_key(pj_stun_session *sess, pj_pool_t *pool,219 const pj_stun_msg *msg, pj_str_t *auth_key)220 {221 if (sess->cred == NULL) {222 auth_key->slen = 0;223 return PJ_SUCCESS;224 } else if (sess->cred->type == PJ_STUN_AUTH_CRED_STATIC) {225 pj_stun_create_key(pool, auth_key,226 &sess->cred->data.static_cred.realm,227 &sess->cred->data.static_cred.username,228 &sess->cred->data.static_cred.data);229 return PJ_SUCCESS;230 } else if (sess->cred->type == PJ_STUN_AUTH_CRED_DYNAMIC) {231 pj_str_t realm, username, nonce;232 pj_str_t *password;233 void *user_data = sess->cred->data.dyn_cred.user_data;234 int data_type = 0;235 pj_status_t status;236 237 realm.slen = username.slen = nonce.slen = 0;238 password = PJ_POOL_ZALLOC_T(pool, pj_str_t);239 status = (*sess->cred->data.dyn_cred.get_cred)(msg, user_data, pool,240 &realm, &username,241 &nonce, &data_type,242 password);243 if (status != PJ_SUCCESS)244 return status;245 246 pj_stun_create_key(pool, auth_key,247 &realm, &username, password);248 249 return PJ_SUCCESS;250 251 } else {252 pj_assert(!"Unknown credential type");253 return PJ_EBUG;254 }255 }256 257 193 static pj_status_t apply_msg_options(pj_stun_session *sess, 258 194 pj_pool_t *pool, 195 const pj_stun_req_cred_info *auth_info, 259 196 pj_stun_msg *msg) 260 197 { 261 198 pj_status_t status = 0; 262 pj_bool_t need_auth; 263 pj_str_t realm, username, nonce, password; 264 int data_type = 0; 265 266 realm.slen = username.slen = nonce.slen = password.slen = 0; 199 pj_str_t realm, username, nonce, auth_key; 267 200 268 201 /* The server SHOULD include a SERVER attribute in all responses */ … … 272 205 } 273 206 274 need_auth = pj_stun_auth_valid_for_msg(msg); 275 276 if (sess->cred && sess->cred->type == PJ_STUN_AUTH_CRED_STATIC && 277 need_auth) 278 { 279 realm = sess->cred->data.static_cred.realm; 280 username = sess->cred->data.static_cred.username; 281 data_type = sess->cred->data.static_cred.data_type; 282 password = sess->cred->data.static_cred.data; 283 nonce = sess->cred->data.static_cred.nonce; 284 285 } else if (sess->cred && sess->cred->type == PJ_STUN_AUTH_CRED_DYNAMIC && 286 need_auth) 287 { 288 void *user_data = sess->cred->data.dyn_cred.user_data; 289 290 status = (*sess->cred->data.dyn_cred.get_cred)(msg, user_data, pool, 291 &realm, &username, 292 &nonce, &data_type, 293 &password); 294 if (status != PJ_SUCCESS) 295 return status; 296 } 297 298 299 /* Create and add USERNAME attribute for */ 207 if (pj_stun_auth_valid_for_msg(msg) && auth_info) { 208 realm = auth_info->realm; 209 username = auth_info->username; 210 nonce = auth_info->nonce; 211 auth_key = auth_info->auth_key; 212 } else { 213 realm.slen = username.slen = nonce.slen = auth_key.slen = 0; 214 } 215 216 /* Create and add USERNAME attribute if needed */ 300 217 if (username.slen && PJ_STUN_IS_REQUEST(msg->hdr.type)) { 301 218 status = pj_stun_msg_add_string_attr(pool, msg, … … 324 241 325 242 /* Add MESSAGE-INTEGRITY attribute */ 326 if (username.slen && need_auth) {243 if (username.slen && auth_key.slen) { 327 244 status = pj_stun_msg_add_msgint_attr(pool, msg); 328 245 PJ_ASSERT_RETURN(status==PJ_SUCCESS, status); … … 340 257 } 341 258 259 static pj_status_t handle_auth_challenge(pj_stun_session *sess, 260 const pj_stun_tx_data *request, 261 const pj_stun_msg *response, 262 const pj_sockaddr_t *src_addr, 263 unsigned src_addr_len, 264 pj_bool_t *notify_user) 265 { 266 const pj_stun_errcode_attr *ea; 267 268 *notify_user = PJ_TRUE; 269 270 if (sess->auth_type != PJ_STUN_AUTH_LONG_TERM) 271 return PJ_SUCCESS; 272 273 if (!PJ_STUN_IS_ERROR_RESPONSE(response->hdr.type)) 274 return PJ_SUCCESS; 275 276 ea = (const pj_stun_errcode_attr*) 277 pj_stun_msg_find_attr(response, PJ_STUN_ATTR_ERROR_CODE, 0); 278 if (!ea) { 279 PJ_LOG(4,(SNAME(sess), "Invalid error response: no ERROR-CODE" 280 " attribute")); 281 *notify_user = PJ_FALSE; 282 return PJNATH_EINSTUNMSG; 283 } 284 285 if (ea->err_code == PJ_STUN_SC_UNAUTHORIZED || 286 ea->err_code == PJ_STUN_SC_STALE_NONCE) 287 { 288 const pj_stun_nonce_attr *anonce; 289 pj_stun_tx_data *tdata; 290 unsigned i; 291 pj_status_t status; 292 293 anonce = (const pj_stun_nonce_attr*) 294 pj_stun_msg_find_attr(response, PJ_STUN_ATTR_NONCE, 0); 295 if (!anonce) { 296 PJ_LOG(4,(SNAME(sess), "Invalid response: missing NONCE")); 297 *notify_user = PJ_FALSE; 298 return PJNATH_EINSTUNMSG; 299 } 300 301 /* Bail out if we've supplied the correct nonce */ 302 if (pj_strcmp(&anonce->value, &sess->next_nonce)==0) { 303 return PJ_SUCCESS; 304 } 305 306 /* Bail out if we've tried too many */ 307 if (++sess->auth_retry > 3) { 308 PJ_LOG(4,(SNAME(sess), "Error: authentication failed (too " 309 "many retries)")); 310 return PJ_STATUS_FROM_STUN_CODE(401); 311 } 312 313 /* Save next_nonce */ 314 pj_strdup(sess->pool, &sess->next_nonce, &anonce->value); 315 316 /* Create new request */ 317 status = pj_stun_session_create_req(sess, request->msg->hdr.type, 318 request->msg->hdr.magic, 319 NULL, &tdata); 320 if (status != PJ_SUCCESS) 321 return status; 322 323 /* Duplicate all the attributes in the old request, except 324 * USERNAME, REALM, M-I, and NONCE 325 */ 326 for (i=0; i<request->msg->attr_count; ++i) { 327 const pj_stun_attr_hdr *asrc = request->msg->attr[i]; 328 329 if (asrc->type == PJ_STUN_ATTR_USERNAME || 330 asrc->type == PJ_STUN_ATTR_REALM || 331 asrc->type == PJ_STUN_ATTR_MESSAGE_INTEGRITY || 332 asrc->type == PJ_STUN_ATTR_NONCE) 333 { 334 continue; 335 } 336 337 tdata->msg->attr[tdata->msg->attr_count++] = 338 pj_stun_attr_clone(tdata->pool, asrc); 339 } 340 341 /* Will retry the request with authentication, no need to 342 * notify user. 343 */ 344 *notify_user = PJ_FALSE; 345 346 PJ_LOG(4,(SNAME(sess), "Retrying request with new authentication")); 347 348 /* Retry the request */ 349 status = pj_stun_session_send_msg(sess, PJ_TRUE, src_addr, 350 src_addr_len, tdata); 351 352 } else { 353 sess->auth_retry = 0; 354 } 355 356 return PJ_SUCCESS; 357 } 342 358 343 359 static void stun_tsx_on_complete(pj_stun_client_tsx *tsx, … … 347 363 unsigned src_addr_len) 348 364 { 365 pj_stun_session *sess; 366 pj_bool_t notify_user = PJ_TRUE; 349 367 pj_stun_tx_data *tdata; 350 368 351 369 tdata = (pj_stun_tx_data*) pj_stun_client_tsx_get_data(tsx); 352 353 if (tdata->sess->cb.on_request_complete) { 354 (*tdata->sess->cb.on_request_complete)(tdata->sess, status, tdata, 355 response, 356 src_addr, src_addr_len); 370 sess = tdata->sess; 371 372 /* Handle authentication challenge */ 373 handle_auth_challenge(sess, tdata, response, src_addr, 374 src_addr_len, ¬ify_user); 375 376 if (notify_user && sess->cb.on_request_complete) { 377 (*sess->cb.on_request_complete)(sess, status, tdata, 378 response, 379 src_addr, src_addr_len); 357 380 } 358 381 } … … 489 512 } 490 513 491 PJ_DEF(void) pj_stun_session_set_credential(pj_stun_session *sess, 492 const pj_stun_auth_cred *cred) 493 { 494 PJ_ASSERT_ON_FAIL(sess, return); 514 PJ_DEF(pj_status_t) pj_stun_session_set_credential(pj_stun_session *sess, 515 pj_stun_auth_type auth_type, 516 const pj_stun_auth_cred *cred) 517 { 518 PJ_ASSERT_RETURN(sess, PJ_EINVAL); 519 520 sess->auth_type = auth_type; 495 521 if (cred) { 496 if (!sess->cred) 497 sess->cred = PJ_POOL_ALLOC_T(sess->pool, pj_stun_auth_cred); 498 pj_stun_auth_cred_dup(sess->pool, sess->cred, cred); 522 pj_stun_auth_cred_dup(sess->pool, &sess->cred, cred); 499 523 } else { 500 sess->cred = NULL; 501 } 502 } 503 524 sess->auth_type = PJ_STUN_AUTH_NONE; 525 pj_bzero(&sess->cred, sizeof(sess->cred)); 526 } 527 528 return PJ_SUCCESS; 529 } 530 531 532 static pj_status_t get_auth(pj_stun_session *sess, 533 pj_stun_tx_data *tdata) 534 { 535 if (sess->cred.type == PJ_STUN_AUTH_CRED_STATIC) { 536 tdata->auth_info.realm = sess->cred.data.static_cred.realm; 537 tdata->auth_info.username = sess->cred.data.static_cred.username; 538 tdata->auth_info.nonce = sess->cred.data.static_cred.nonce; 539 540 pj_stun_create_key(tdata->pool, &tdata->auth_info.auth_key, 541 &tdata->auth_info.realm, 542 &tdata->auth_info.username, 543 sess->cred.data.static_cred.data_type, 544 &sess->cred.data.static_cred.data); 545 546 } else if (sess->cred.type == PJ_STUN_AUTH_CRED_DYNAMIC) { 547 pj_str_t password; 548 void *user_data = sess->cred.data.dyn_cred.user_data; 549 pj_stun_passwd_type data_type = PJ_STUN_PASSWD_PLAIN; 550 pj_status_t rc; 551 552 rc = (*sess->cred.data.dyn_cred.get_cred)(tdata->msg, user_data, 553 tdata->pool, 554 &tdata->auth_info.realm, 555 &tdata->auth_info.username, 556 &tdata->auth_info.nonce, 557 &data_type, &password); 558 if (rc != PJ_SUCCESS) 559 return rc; 560 561 pj_stun_create_key(tdata->pool, &tdata->auth_info.auth_key, 562 &tdata->auth_info.realm, &tdata->auth_info.username, 563 data_type, &password); 564 565 } else { 566 pj_assert(!"Unknown credential type"); 567 return PJ_EBUG; 568 } 569 570 return PJ_SUCCESS; 571 } 504 572 505 573 PJ_DEF(pj_status_t) pj_stun_session_create_req(pj_stun_session *sess, … … 514 582 PJ_ASSERT_RETURN(sess && p_tdata, PJ_EINVAL); 515 583 516 status = create_ request_tdata(sess, method, magic, tsx_id, &tdata);584 status = create_tdata(sess, &tdata); 517 585 if (status != PJ_SUCCESS) 518 586 return status; 587 588 /* Create STUN message */ 589 status = pj_stun_msg_create(tdata->pool, method, magic, 590 tsx_id, &tdata->msg); 591 if (status != PJ_SUCCESS) { 592 pj_pool_release(tdata->pool); 593 return status; 594 } 595 596 /* copy the request's transaction ID as the transaction key. */ 597 pj_assert(sizeof(tdata->msg_key)==sizeof(tdata->msg->hdr.tsx_id)); 598 tdata->msg_magic = tdata->msg->hdr.magic; 599 pj_memcpy(tdata->msg_key, tdata->msg->hdr.tsx_id, 600 sizeof(tdata->msg->hdr.tsx_id)); 601 602 603 /* Get authentication information for the request */ 604 if (sess->auth_type == PJ_STUN_AUTH_NONE) { 605 /* No authentication */ 606 607 } else if (sess->auth_type == PJ_STUN_AUTH_SHORT_TERM) { 608 /* MUST put authentication in request */ 609 status = get_auth(sess, tdata); 610 if (status != PJ_SUCCESS) { 611 pj_pool_release(tdata->pool); 612 return status; 613 } 614 615 } else if (sess->auth_type == PJ_STUN_AUTH_LONG_TERM) { 616 /* Only put authentication information if we've received 617 * response from server. 618 */ 619 if (sess->next_nonce.slen != 0) { 620 status = get_auth(sess, tdata); 621 if (status != PJ_SUCCESS) { 622 pj_pool_release(tdata->pool); 623 return status; 624 } 625 tdata->auth_info.nonce = sess->next_nonce; 626 } 627 628 } else { 629 pj_assert(!"Invalid authentication type"); 630 pj_pool_release(tdata->pool); 631 return PJ_EBUG; 632 } 519 633 520 634 *p_tdata = tdata; … … 552 666 */ 553 667 PJ_DEF(pj_status_t) pj_stun_session_create_res( pj_stun_session *sess, 554 const pj_stun_ msg *req,668 const pj_stun_rx_data *rdata, 555 669 unsigned err_code, 556 670 const pj_str_t *err_msg, … … 565 679 566 680 /* Create STUN response message */ 567 status = pj_stun_msg_create_response(tdata->pool, r eq, err_code, err_msg,568 &tdata->msg);681 status = pj_stun_msg_create_response(tdata->pool, rdata->msg, 682 err_code, err_msg, &tdata->msg); 569 683 if (status != PJ_SUCCESS) { 570 684 pj_pool_release(tdata->pool); … … 573 687 574 688 /* copy the request's transaction ID as the transaction key. */ 575 pj_assert(sizeof(tdata->msg_key)==sizeof(req->hdr.tsx_id)); 576 tdata->msg_magic = req->hdr.magic; 577 pj_memcpy(tdata->msg_key, req->hdr.tsx_id, sizeof(req->hdr.tsx_id)); 689 pj_assert(sizeof(tdata->msg_key)==sizeof(rdata->msg->hdr.tsx_id)); 690 tdata->msg_magic = rdata->msg->hdr.magic; 691 pj_memcpy(tdata->msg_key, rdata->msg->hdr.tsx_id, 692 sizeof(rdata->msg->hdr.tsx_id)); 693 694 /* copy the credential found in the request */ 695 pj_stun_req_cred_info_dup(tdata->pool, &tdata->auth_info, &rdata->info); 578 696 579 697 *p_tdata = tdata; … … 587 705 unsigned pkt_size, const pj_sockaddr_t *addr) 588 706 { 589 const char *dst_name; 590 int dst_port; 591 const pj_sockaddr *dst = (const pj_sockaddr*)addr; 592 char buf[800]; 707 char dst_name[80]; 593 708 594 if (dst->addr.sa_family == pj_AF_INET()) { 595 dst_name = pj_inet_ntoa(dst->ipv4.sin_addr); 596 dst_port = pj_ntohs(dst->ipv4.sin_port); 597 } else if (dst->addr.sa_family == pj_AF_INET6()) { 598 dst_name = "IPv6"; 599 dst_port = pj_ntohs(dst->ipv6.sin6_port); 600 } else { 601 LOG_ERR_(sess, "Invalid address family", PJ_EINVAL); 602 return; 603 } 709 pj_sockaddr_print(addr, dst_name, sizeof(dst_name), 3); 604 710 605 711 PJ_LOG(5,(SNAME(sess), 606 "TX %d bytes STUN message to %s: %d:\n"712 "TX %d bytes STUN message to %s:\n" 607 713 "--- begin STUN message ---\n" 608 714 "%s" 609 715 "--- end of STUN message ---\n", 610 pkt_size, dst_name, dst_port, 611 pj_stun_msg_dump(msg, buf, sizeof(buf), NULL))); 716 pkt_size, dst_name, 717 pj_stun_msg_dump(msg, sess->dump_buf, sizeof(sess->dump_buf), 718 NULL))); 612 719 613 720 } … … 632 739 633 740 /* Apply options */ 634 status = apply_msg_options(sess, tdata->pool, tdata->msg); 741 status = apply_msg_options(sess, tdata->pool, &tdata->auth_info, 742 tdata->msg); 635 743 if (status != PJ_SUCCESS) { 636 744 pj_stun_msg_destroy_tdata(sess, tdata); … … 640 748 } 641 749 642 status = get_key(sess, tdata->pool, tdata->msg, &tdata->auth_key);643 if (status != PJ_SUCCESS) {644 pj_stun_msg_destroy_tdata(sess, tdata);645 pj_lock_release(sess->lock);646 LOG_ERR_(sess, "Error getting creadential's key", status);647 return status;648 }649 650 750 /* Encode message */ 651 751 status = pj_stun_msg_encode(tdata->msg, (pj_uint8_t*)tdata->pkt, 652 752 tdata->max_len, 0, 653 &tdata->auth_ key,753 &tdata->auth_info.auth_key, 654 754 &tdata->pkt_size); 655 755 if (status != PJ_SUCCESS) { … … 743 843 */ 744 844 PJ_DEF(pj_status_t) pj_stun_session_respond( pj_stun_session *sess, 745 const pj_stun_ msg *req,845 const pj_stun_rx_data *rdata, 746 846 unsigned code, 747 847 const char *errmsg, … … 754 854 pj_stun_tx_data *tdata; 755 855 756 status = pj_stun_session_create_res(sess, r eq, code,856 status = pj_stun_session_create_res(sess, rdata, code, 757 857 (errmsg?pj_cstr(&reason,errmsg):NULL), 758 858 &tdata); … … 814 914 static pj_status_t send_response(pj_stun_session *sess, 815 915 pj_pool_t *pool, pj_stun_msg *response, 816 const pj_st r_t *auth_key,916 const pj_stun_req_cred_info *auth_info, 817 917 pj_bool_t retransmission, 818 918 const pj_sockaddr_t *addr, unsigned addr_len) … … 824 924 /* Apply options */ 825 925 if (!retransmission) { 826 status = apply_msg_options(sess, pool, response);926 status = apply_msg_options(sess, pool, auth_info, response); 827 927 if (status != PJ_SUCCESS) 828 928 return status; … … 835 935 /* Encode */ 836 936 status = pj_stun_msg_encode(response, out_pkt, out_max_len, 0, 837 auth_key, &out_len);937 &auth_info->auth_key, &out_len); 838 938 if (status != PJ_SUCCESS) { 839 939 LOG_ERR_(sess, "Error encoding message", status); … … 854 954 const pj_uint8_t *pkt, 855 955 unsigned pkt_len, 856 const pj_stun_msg *msg,956 pj_stun_rx_data *rdata, 857 957 pj_pool_t *tmp_pool, 858 958 const pj_sockaddr_t *src_addr, … … 860 960 { 861 961 pj_stun_msg *response; 862 pj_str_t auth_key;863 962 pj_status_t status; 864 963 865 if (PJ_STUN_IS_ERROR_RESPONSE(msg->hdr.type) || sess->cred == NULL) 964 if (PJ_STUN_IS_ERROR_RESPONSE(rdata->msg->hdr.type) || 965 sess->auth_type == PJ_STUN_AUTH_NONE) 966 { 866 967 return PJ_SUCCESS; 867 868 status = pj_stun_authenticate_request(pkt, pkt_len, msg, sess->cred, 869 tmp_pool, &auth_key, &response); 968 } 969 970 status = pj_stun_authenticate_request(pkt, pkt_len, rdata->msg, 971 &sess->cred, tmp_pool, &rdata->info, 972 &response); 870 973 if (status != PJ_SUCCESS && response != NULL) { 871 974 PJ_LOG(5,(SNAME(sess), "Message authentication failed")); 872 send_response(sess, tmp_pool, response, & auth_key, PJ_FALSE,975 send_response(sess, tmp_pool, response, &rdata->info, PJ_FALSE, 873 976 src_addr, src_addr_len); 874 977 } … … 898 1001 } 899 1002 1003 if (sess->auth_type == PJ_STUN_AUTH_NONE) 1004 options |= PJ_STUN_NO_AUTHENTICATE; 1005 900 1006 /* Authenticate the message, unless PJ_STUN_NO_AUTHENTICATE 901 1007 * is specified in the option. 902 1008 */ 903 if ((options & PJ_STUN_NO_AUTHENTICATE) == 0 && tdata->auth_key.slen != 0 904 && pj_stun_auth_valid_for_msg(msg)) 1009 if ((options & PJ_STUN_NO_AUTHENTICATE) == 0 && 1010 tdata->auth_info.auth_key.slen != 0 && 1011 pj_stun_auth_valid_for_msg(msg)) 905 1012 { 906 1013 status = pj_stun_authenticate_response(pkt, pkt_len, msg, 907 &tdata->auth_ key);1014 &tdata->auth_info.auth_key); 908 1015 if (status != PJ_SUCCESS) { 909 1016 PJ_LOG(5,(SNAME(sess), … … 963 1070 "Request retransmission, sending cached response")); 964 1071 965 send_response(sess, tmp_pool, t->msg, &t->auth_ key, PJ_TRUE,1072 send_response(sess, tmp_pool, t->msg, &t->auth_info, PJ_TRUE, 966 1073 src_addr, src_addr_len); 967 1074 return PJ_SUCCESS; … … 977 1084 const pj_uint8_t *in_pkt, 978 1085 unsigned in_pkt_len, 979 constpj_stun_msg *msg,1086 pj_stun_msg *msg, 980 1087 const pj_sockaddr_t *src_addr, 981 1088 unsigned src_addr_len) 982 1089 { 1090 pj_stun_rx_data rdata; 983 1091 pj_status_t status; 1092 1093 /* Init rdata */ 1094 rdata.msg = msg; 1095 pj_bzero(&rdata.info, sizeof(rdata.info)); 1096 1097 if (sess->auth_type == PJ_STUN_AUTH_NONE) 1098 options |= PJ_STUN_NO_AUTHENTICATE; 984 1099 985 1100 /* Authenticate the message, unless PJ_STUN_NO_AUTHENTICATE … … 988 1103 if ((options & PJ_STUN_NO_AUTHENTICATE) == 0) { 989 1104 status = authenticate_req(sess, (const pj_uint8_t*) in_pkt, in_pkt_len, 990 msg, tmp_pool, src_addr, src_addr_len);1105 &rdata, tmp_pool, src_addr, src_addr_len); 991 1106 if (status != PJ_SUCCESS) { 992 1107 return status; … … 996 1111 /* Distribute to handler, or respond with Bad Request */ 997 1112 if (sess->cb.on_rx_request) { 998 status = (*sess->cb.on_rx_request)(sess, in_pkt, in_pkt_len, msg,1113 status = (*sess->cb.on_rx_request)(sess, in_pkt, in_pkt_len, &rdata, 999 1114 src_addr, src_addr_len); 1000 1115 } else { 1116 pj_str_t err_text; 1001 1117 pj_stun_msg *response; 1002 1118 1119 err_text = pj_str("Callback is not set to handle request"); 1003 1120 status = pj_stun_msg_create_response(tmp_pool, msg, 1004 PJ_STUN_SC_BAD_REQUEST, NULL,1005 & response);1121 PJ_STUN_SC_BAD_REQUEST, 1122 &err_text, &response); 1006 1123 if (status == PJ_SUCCESS && response) { 1007 1124 status = send_response(sess, tmp_pool, response,
Note: See TracChangeset
for help on using the changeset viewer.