Changeset 1879 for pjproject/trunk/pjnath/src/pjturn-client/client_main.c
- Timestamp:
- Mar 20, 2008 4:32:06 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjnath/src/pjturn-client/client_main.c
r1869 r1879 62 62 char *user_name; 63 63 char *password; 64 char *nonce;65 64 pj_bool_t use_fingerprint; 66 65 } o; … … 136 135 137 136 CHECK( pj_gethostip(pj_AF_INET(), &g.peer[i].addr) ); 138 pj_sockaddr_set_port(&g.peer[ 0].addr, port);137 pj_sockaddr_set_port(&g.peer[i].addr, port); 139 138 140 139 } … … 266 265 cred.data.static_cred.data_type = 0; 267 266 cred.data.static_cred.data = pj_str(o.password); 268 cred.data.static_cred.nonce = pj_str(o.nonce);267 //cred.data.static_cred.nonce = pj_str(o.nonce); 269 268 } else { 270 269 PJ_LOG(2,(THIS_FILE, "Warning: no credential is set")); … … 287 286 if (g.udp_rel) { 288 287 pj_turn_udp_destroy(g.udp_rel); 289 g.udp_rel = NULL;290 288 } 291 289 } … … 310 308 pj_turn_state_t new_state) 311 309 { 310 PJ_LOG(3,(THIS_FILE, "State %s --> %s", pj_turn_state_name(old_state), 311 pj_turn_state_name(new_state))); 312 312 313 if (new_state == PJ_TURN_STATE_READY) { 313 314 pj_turn_session_info info; 314 315 pj_turn_udp_get_info(udp_rel, &info); 315 316 pj_memcpy(&g.relay_addr, &info.relay_addr, sizeof(pj_sockaddr)); 317 } else if (new_state > PJ_TURN_STATE_READY && g.udp_rel) { 318 PJ_LOG(3,(THIS_FILE, "Relay shutting down..")); 319 g.udp_rel = NULL; 316 320 } 317 321 } … … 380 384 relay_addr); 381 385 puts("| | 0 Send data to relay address |"); 382 puts("| AAllocate relay +--------------------------------+ ");383 puts("| S[01]Send data to peer 0/1 | PEER-1 |");384 puts("| B[01]BindChannel to peer 0/1 | |");385 printf("| XDelete allocation | Address: %-21s |\n",386 puts("| a Allocate relay +--------------------------------+ "); 387 puts("| s,ss Send data to peer 0/1 | PEER-1 |"); 388 puts("| b,bb BindChannel to peer 0/1 | |"); 389 printf("| x Delete allocation | Address: %-21s |\n", 386 390 peer1_addr); 387 391 puts("+-----------------------------------+ |"); … … 406 410 407 411 switch (input[0]) { 408 case ' A':412 case 'a': 409 413 create_relay(); 410 414 break; 411 case ' S':415 case 's': 412 416 if (g.udp_rel == NULL) { 413 417 puts("Error: no relay"); 414 418 continue; 415 419 } 416 if (input[1] != '0' && input[1] != '1') {417 p uts("Usage: S0 or S1");418 continue;419 }420 peer = &g.peer[input[1]-'0']; 420 if (input[1]!='s') 421 peer = &g.peer[0]; 422 else 423 peer = &g.peer[1]; 424 421 425 strcpy(input, "Hello from client"); 422 426 status = pj_turn_udp_sendto(g.udp_rel, input, strlen(input)+1, … … 426 430 my_perror("turn_udp_sendto() failed", status); 427 431 break; 428 case ' B':432 case 'b': 429 433 if (g.udp_rel == NULL) { 430 434 puts("Error: no relay"); 431 435 continue; 432 436 } 433 if (input[1] != '0' && input[1] != '1') {434 p uts("Usage: B0 or B1");435 continue;436 }437 peer = &g.peer[input[1]-'0']; 437 if (input[1]!='b') 438 peer = &g.peer[0]; 439 else 440 peer = &g.peer[1]; 441 438 442 status = pj_turn_udp_bind_channel(g.udp_rel, &peer->addr, 439 443 pj_sockaddr_get_len(&peer->addr)); … … 441 445 my_perror("turn_udp_bind_channel() failed", status); 442 446 break; 443 case ' X':447 case 'x': 444 448 if (g.udp_rel == NULL) { 445 449 puts("Error: no relay"); … … 450 454 case '0': 451 455 case '1': 452 peer = &g.peer[input[ 1]-'0'];456 peer = &g.peer[input[0]-'0']; 453 457 sprintf(input, "Hello from peer%d", input[0]-'0'); 454 458 len = strlen(input)+1; … … 474 478 puts(" --username, -u Set username of the credential"); 475 479 puts(" --password, -p Set password of the credential"); 476 puts(" --nonce, -N Set NONCE");477 480 puts(" --fingerprint, -F Use fingerprint for outgoing requests"); 478 481 puts(" --help, -h"); … … 485 488 { "username", 1, 0, 'u'}, 486 489 { "password", 1, 0, 'p'}, 487 { "nonce", 1, 0, 'N'},488 490 { "fingerprint",0, 0, 'F'}, 489 491 { "data", 1, 0, 'D'}, … … 505 507 o.password = pj_optarg; 506 508 break; 507 case 'N':508 o.nonce = pj_optarg;509 break;510 509 case 'h': 511 510 usage(); … … 538 537 goto on_return; 539 538 540 if ((status=create_relay()) != 0)541 goto on_return;539 //if ((status=create_relay()) != 0) 540 // goto on_return; 542 541 543 542 console_main();
Note: See TracChangeset
for help on using the changeset viewer.