- Timestamp:
- Mar 14, 2008 5:56:11 PM (17 years ago)
- Location:
- pjproject/trunk/pjnath
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjnath/include/pjnath/stun_auth.h
r1374 r1869 278 278 * @param pool If response is to be created, then memory will 279 279 * be allocated from this pool. 280 * @param auth_key Optional pointer to receive authentication key to 281 * calculate MESSAGE-INTEGRITY of the response, if 282 * the response needs to be authenticated. 280 283 * @param p_response Optional pointer to receive the response message 281 284 * then the credential in the request fails to … … 292 295 pj_stun_auth_cred *cred, 293 296 pj_pool_t *pool, 297 pj_str_t *auth_key, 294 298 pj_stun_msg **p_response); 295 299 -
pjproject/trunk/pjnath/src/pjnath-test/stun.c
r1451 r1869 656 656 657 657 status = pj_stun_authenticate_request(buf, len, msg, 658 &cred, pool, NULL );658 &cred, pool, NULL, NULL); 659 659 if (status != PJ_SUCCESS) { 660 660 char errmsg[PJ_ERR_MSG_SIZE]; -
pjproject/trunk/pjnath/src/pjnath/stun_auth.c
r1479 r1869 122 122 pj_stun_auth_cred *cred, 123 123 pj_pool_t *pool, 124 pj_str_t *auth_key, 124 125 pj_stun_msg **p_response) 125 126 { … … 333 334 NULL, &realm, &nonce, p_response); 334 335 } 336 if (auth_key) { 337 pj_stun_create_key(pool, auth_key, &realm, 338 &auser->value, &password); 339 } 335 340 return PJ_STATUS_FROM_STUN_CODE(PJ_STUN_SC_STALE_NONCE); 336 341 } -
pjproject/trunk/pjnath/src/pjnath/stun_session.c
r1862 r1869 860 860 { 861 861 pj_stun_msg *response; 862 pj_str_t auth_key; 862 863 pj_status_t status; 863 864 … … 866 867 867 868 status = pj_stun_authenticate_request(pkt, pkt_len, msg, sess->cred, 868 tmp_pool, & response);869 tmp_pool, &auth_key, &response); 869 870 if (status != PJ_SUCCESS && response != NULL) { 870 871 PJ_LOG(5,(SNAME(sess), "Message authentication failed")); 871 send_response(sess, tmp_pool, response, NULL, PJ_FALSE,872 send_response(sess, tmp_pool, response, &auth_key, PJ_FALSE, 872 873 src_addr, src_addr_len); 873 874 } -
pjproject/trunk/pjnath/src/pjnath/turn_session.c
r1867 r1869 219 219 } 220 220 221 /* Attach ourself to STUN session */ 222 pj_stun_session_set_user_data(sess->stun, sess); 223 221 224 /* Replace mutex in STUN session with a NULL mutex, since access to 222 225 * STUN session is serialized. -
pjproject/trunk/pjnath/src/pjnath/turn_udp.c
r1867 r1869 20 20 #include <pj/assert.h> 21 21 #include <pj/errno.h> 22 #include <pj/log.h> 22 23 #include <pj/pool.h> 23 24 #include <pj/ioqueue.h> … … 113 114 } 114 115 116 /* Bind to any */ 117 pj_sockaddr_init(af, &udp_rel->src_addr, NULL, 0); 118 status = pj_sock_bind(udp_rel->sock, &udp_rel->src_addr, 119 pj_sockaddr_get_len(&udp_rel->src_addr)); 120 if (status != PJ_SUCCESS) { 121 pj_turn_udp_destroy(udp_rel); 122 return status; 123 } 124 115 125 /* Register to ioqeuue */ 116 126 pj_bzero(&ioq_cb, sizeof(ioq_cb)); … … 256 266 pj_ssize_t bytes_read) 257 267 { 268 enum { MAX_RETRY = 10 }; 258 269 pj_turn_udp *udp_rel; 270 int retry = 0; 259 271 pj_status_t status; 260 272 … … 271 283 bytes_read = sizeof(udp_rel->pkt); 272 284 udp_rel->src_addr_len = sizeof(udp_rel->src_addr); 273 274 285 status = pj_ioqueue_recvfrom(udp_rel->key, op_key, 275 286 udp_rel->pkt, &bytes_read, 0, … … 277 288 &udp_rel->src_addr_len); 278 289 279 if (status != PJ_EPENDING && status != PJ_SUCCESS) 290 if (status != PJ_EPENDING && status != PJ_SUCCESS) { 291 char errmsg[PJ_ERR_MSG_SIZE]; 292 293 pj_strerror(status, errmsg, sizeof(errmsg)); 294 PJ_LOG(4,(udp_rel->pool->obj_name, 295 "ioqueue recvfrom error: %s", errmsg)); 296 280 297 bytes_read = -status; 281 282 } while (status != PJ_EPENDING && status != PJ_ECANCELLED); 298 } 299 300 } while (status != PJ_EPENDING && status != PJ_ECANCELLED && 301 ++retry < MAX_RETRY); 283 302 284 303 } -
pjproject/trunk/pjnath/src/pjturn-client/client_main.c
r1867 r1869 133 133 len = sizeof(addr); 134 134 CHECK( pj_sock_getsockname(g.peer[i].sock, &addr, &len) ); 135 port = pj_sockaddr_get_port(& g.peer[i].addr);135 port = pj_sockaddr_get_port(&addr); 136 136 137 137 CHECK( pj_gethostip(pj_AF_INET(), &g.peer[i].addr) ); … … 358 358 pj_turn_udp_get_info(g.udp_rel, &info); 359 359 strcpy(client_state, pj_turn_state_name(info.state)); 360 pj_sockaddr_print(&info.relay_addr, relay_addr, sizeof(relay_addr), 3); 360 if (info.state >= PJ_TURN_STATE_READY) 361 pj_sockaddr_print(&info.relay_addr, relay_addr, sizeof(relay_addr), 3); 362 else 363 strcpy(relay_addr, "0.0.0.0:0"); 361 364 } else { 362 365 strcpy(client_state, "NULL"); … … 372 375 puts("| CLIENT | PEER-0 |"); 373 376 puts("| | |"); 374 printf("| State : % 12s | Address: %21s |\n",377 printf("| State : %-12s | Address: %-21s |\n", 375 378 client_state, peer0_addr); 376 printf("| Relay addr: % 21s | |\n",379 printf("| Relay addr: %-21s | |\n", 377 380 relay_addr); 378 381 puts("| | 0 Send data to relay address |"); … … 380 383 puts("| S[01] Send data to peer 0/1 | PEER-1 |"); 381 384 puts("| B[01] BindChannel to peer 0/1 | |"); 382 printf("| X Delete allocation | Address: % 21s |\n",385 printf("| X Delete allocation | Address: %-21s |\n", 383 386 peer1_addr); 384 387 puts("+-----------------------------------+ |"); -
pjproject/trunk/pjnath/src/pjturn-srv/auth.c
r1852 r1869 56 56 { 57 57 /* Nothing to do */ 58 } 59 60 61 PJ_DEF(pj_status_t) pj_turn_get_cred( const pj_stun_msg *msg, 62 void *user_data, 63 pj_pool_t *pool, 64 pj_str_t *realm, 65 pj_str_t *username, 66 pj_str_t *nonce, 67 int *data_type, 68 pj_str_t *data) 69 { 70 PJ_UNUSED_ARG(msg); 71 PJ_UNUSED_ARG(pool); 72 PJ_UNUSED_ARG(user_data); 73 74 *realm = pj_str(g_realm); 75 *username = pj_str(g_cred[0].username); 76 *nonce = pj_str(THE_NONCE); 77 *data_type = 0; 78 *data = pj_str(g_cred[0].passwd); 79 80 return PJ_SUCCESS; 58 81 } 59 82 -
pjproject/trunk/pjnath/src/pjturn-srv/auth.h
r1852 r1869 62 62 63 63 /** 64 * Get credential. 65 */ 66 PJ_DECL(pj_status_t) pj_turn_get_cred(const pj_stun_msg *msg, 67 void *user_data, 68 pj_pool_t *pool, 69 pj_str_t *realm, 70 pj_str_t *username, 71 pj_str_t *nonce, 72 int *data_type, 73 pj_str_t *data); 74 75 /** 64 76 * This function is called to get the password for the specified username. 65 77 * This function is also used to check whether the username is valid. -
pjproject/trunk/pjnath/src/pjturn-srv/main.c
r1854 r1869 18 18 */ 19 19 #include "turn.h" 20 #include "auth.h" 21 22 #define REALM "pjsip.org" 20 23 21 24 int err(const char *title, pj_status_t status) … … 39 42 return err("pj_init() error", status); 40 43 44 pjlib_util_init(); 45 pjnath_init(); 46 41 47 pj_caching_pool_init(&cp, NULL, 0); 48 49 pj_turn_auth_init(REALM); 42 50 43 51 status = pj_turn_srv_create(&cp.factory, &srv); … … 45 53 return err("Error creating server", status); 46 54 47 status = pj_turn_listener_create_udp(srv, pj_AF_INET(), NULL, 3478, 1, 0, &listener); 55 status = pj_turn_listener_create_udp(srv, pj_AF_INET(), NULL, 56 PJ_STUN_PORT, 1, 0, &listener); 48 57 if (status != PJ_SUCCESS) 49 58 return err("Error creating listener", status); -
pjproject/trunk/pjnath/src/pjturn-srv/server.c
r1852 r1869 148 148 srv->core.cred.data.dyn_cred.user_data = srv; 149 149 srv->core.cred.data.dyn_cred.get_auth = &pj_turn_get_auth; 150 srv->core.cred.data.dyn_cred.get_cred = &pj_turn_ srv_get_cred;150 srv->core.cred.data.dyn_cred.get_cred = &pj_turn_get_cred; 151 151 srv->core.cred.data.dyn_cred.get_password = &pj_turn_get_password; 152 152 srv->core.cred.data.dyn_cred.verify_nonce = &pj_turn_verify_nonce;
Note: See TracChangeset
for help on using the changeset viewer.