Changeset 3232
- Timestamp:
- Jul 1, 2010 10:25:47 AM (14 years ago)
- Location:
- pjproject/branches/projects/cli
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/branches/projects/cli/pjlib-util/src/pjlib-util/cli_telnet.c
r3231 r3232 441 441 pj_sock_t sock = PJ_INVALID_SOCKET; 442 442 pj_activesock_cb asock_cb; 443 pj_sockaddr addr;443 pj_sockaddr_in addr; 444 444 pj_status_t sstatus; 445 445 … … 472 472 goto on_exit; 473 473 fe->own_ioqueue = PJ_TRUE; 474 474 } 475 476 sstatus = pj_mutex_create_recursive(pool, "mutex_telnet_fe", &fe->mutex); 477 if (sstatus != PJ_SUCCESS) 478 goto on_exit; 479 480 /* Start telnet daemon */ 481 sstatus = pj_sock_socket(pj_AF_INET(), pj_SOCK_STREAM(), 0, 482 &sock); 483 if (sstatus != PJ_SUCCESS) 484 goto on_exit; 485 486 pj_sockaddr_in_init(&addr, NULL, fe->cfg.port); 487 488 sstatus = pj_sock_bind(sock, &addr, sizeof(addr)); 489 if (sstatus == PJ_SUCCESS) { 490 pj_sockaddr_in addr; 491 int addr_len = sizeof(addr); 492 493 sstatus = pj_sock_getsockname(sock, &addr, &addr_len); 494 if (sstatus != PJ_SUCCESS) 495 goto on_exit; 496 fe->cfg.port = pj_sockaddr_in_get_port(&addr); 497 PJ_LOG(3, (THIS_FILE, "CLI telnet daemon listening at port %d", 498 fe->cfg.port)); 499 } else { 500 PJ_LOG(3, (THIS_FILE, "Failed binding the socket")); 501 goto on_exit; 502 } 503 504 sstatus = pj_sock_listen(sock, 4); 505 if (sstatus != PJ_SUCCESS) 506 goto on_exit; 507 508 pj_bzero(&asock_cb, sizeof(asock_cb)); 509 asock_cb.on_accept_complete = &telnet_fe_on_accept; 510 sstatus = pj_activesock_create(pool, sock, pj_SOCK_STREAM(), 511 NULL, fe->cfg.ioqueue, 512 &asock_cb, fe, &fe->asock); 513 if (sstatus != PJ_SUCCESS) 514 goto on_exit; 515 516 sstatus = pj_activesock_start_accept(fe->asock, pool); 517 if (sstatus != PJ_SUCCESS) 518 goto on_exit; 519 520 if (fe->own_ioqueue) { 475 521 /* Create our own worker thread */ 476 522 sstatus = pj_thread_create(pool, "worker_telnet_fe", … … 481 527 } 482 528 483 sstatus = pj_mutex_create_recursive(pool, "mutex_telnet_fe", &fe->mutex);484 if (sstatus != PJ_SUCCESS)485 goto on_exit;486 487 /* Start telnet daemon */488 sstatus = pj_sock_socket(pj_AF_INET(), pj_SOCK_STREAM(), 0,489 &sock);490 if (sstatus != PJ_SUCCESS)491 goto on_exit;492 493 pj_sockaddr_init(pj_AF_INET(), &addr, NULL, fe->cfg.port);494 495 sstatus = pj_sock_bind(sock, &addr, sizeof(addr));496 if (sstatus != PJ_SUCCESS)497 goto on_exit;498 499 sstatus = pj_sock_listen(sock, 4);500 if (sstatus != PJ_SUCCESS)501 goto on_exit;502 503 pj_bzero(&asock_cb, sizeof(asock_cb));504 asock_cb.on_accept_complete = &telnet_fe_on_accept;505 sstatus = pj_activesock_create(pool, sock, pj_SOCK_STREAM(),506 NULL, fe->cfg.ioqueue,507 &asock_cb, fe, &fe->asock);508 if (sstatus != PJ_SUCCESS)509 goto on_exit;510 511 sstatus = pj_activesock_start_accept(fe->asock, pool);512 if (sstatus != PJ_SUCCESS)513 goto on_exit;514 515 529 pj_cli_register_front_end(cli, &fe->base); 516 530 -
pjproject/branches/projects/cli/pjsip-apps/src/samples/clidemo.c
r3231 r3232 30 30 #define THIS_FILE "clidemo.c" 31 31 32 /* Set this to 1 if you want to let the system assign a port 33 * for the CLI telnet daemon. 34 * Default: 1 35 */ 36 #define USE_RANDOM_PORT 1 37 32 38 struct cmd_xml_t { 33 39 char * xml; … … 128 134 pjlib_util_init(); 129 135 130 pj_log_set_log_func(&log_writer);131 132 136 /* 133 137 * Create CLI app. … … 158 162 pj_cli_telnet_cfg_default(&tcfg); 159 163 // tcfg.passwd = pj_str("pjsip"); 164 #if USE_RANDOM_PORT 165 tcfg.port = 0; 166 #endif 160 167 status = pj_cli_telnet_create(cli, &tcfg, NULL); 161 168 if (status != PJ_SUCCESS) … … 196 203 if (status != PJ_SUCCESS) 197 204 return status; 205 206 pj_log_set_log_func(&log_writer); 198 207 199 208 /*
Note: See TracChangeset
for help on using the changeset viewer.