Changeset 1882 for pjproject/trunk/pjnath/src/pjturn-client/client_main.c
- Timestamp:
- Mar 20, 2008 7:21:27 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjnath/src/pjturn-client/client_main.c
r1879 r1882 67 67 68 68 static int worker_thread(void *unused); 69 static pj_status_t parse_addr(const char *input, pj_sockaddr_in *addr);70 69 static void turn_on_rx_data(pj_turn_udp *udp_rel, 71 70 const pj_uint8_t *pkt, … … 319 318 g.udp_rel = NULL; 320 319 } 321 }322 323 static pj_status_t parse_addr(const char *input,324 pj_sockaddr_in *addr)325 {326 const char *pos;327 pj_str_t ip;328 pj_uint16_t port;329 pj_sockaddr tmp_addr;330 331 pos = pj_ansi_strchr(input, ':');332 if (pos==NULL) {333 puts("Invalid format");334 return -1;335 }336 337 ip.ptr = (char*)input;338 ip.slen = pos - input;339 port = (pj_uint16_t)atoi(pos+1);340 341 if (port==0) {342 puts("Invalid port");343 return -1;344 }345 346 if (pj_sockaddr_in_init(&tmp_addr.ipv4, &ip, port)!=PJ_SUCCESS) {347 puts("Invalid address");348 return -1;349 }350 351 pj_memcpy(addr, &tmp_addr, sizeof(pj_sockaddr_in));352 353 return PJ_SUCCESS;354 320 } 355 321 … … 424 390 425 391 strcpy(input, "Hello from client"); 426 status = pj_turn_udp_sendto(g.udp_rel, input, strlen(input)+1, 392 status = pj_turn_udp_sendto(g.udp_rel, (const pj_uint8_t*)input, 393 strlen(input)+1, 427 394 &peer->addr, 428 395 pj_sockaddr_get_len(&peer->addr)); … … 454 421 case '0': 455 422 case '1': 423 if (g.udp_rel == NULL) { 424 puts("No relay"); 425 break; 426 } 456 427 peer = &g.peer[input[0]-'0']; 457 428 sprintf(input, "Hello from peer%d", input[0]-'0'); … … 523 494 if (pj_optind == argc) { 524 495 puts("Error: TARGET is needed"); 496 usage(); 525 497 return 1; 526 498 }
Note: See TracChangeset
for help on using the changeset viewer.