Changeset 1239
- Timestamp:
- May 1, 2007 12:25:01 PM (18 years ago)
- Location:
- pjproject/trunk
- Files:
-
- 3 added
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjlib-util/src/pjlib-util/dns.c
r1031 r1239 67 67 68 68 /* Initialize header */ 69 hdr = packet;69 hdr = (pj_dns_hdr*) packet; 70 70 pj_bzero(hdr, sizeof(struct pj_dns_hdr)); 71 71 hdr->id = pj_htons(id); … … 111 111 * it may contain pointers when name compression is applied) 112 112 */ 113 static pj_status_t get_name_len(int rec_counter, const char*pkt,114 const char *start, const char *max,113 static pj_status_t get_name_len(int rec_counter, const pj_uint8_t *pkt, 114 const pj_uint8_t *start, const pj_uint8_t *max, 115 115 int *parsed_len, int *name_len) 116 116 { 117 const char*p;117 const pj_uint8_t *p; 118 118 pj_status_t status; 119 119 … … 181 181 * it may contain pointers when compression is applied). 182 182 */ 183 static pj_status_t get_name(int rec_counter, const char*pkt,184 const char *start, const char*max,183 static pj_status_t get_name(int rec_counter, const pj_uint8_t *pkt, 184 const pj_uint8_t *start, const pj_uint8_t *max, 185 185 pj_str_t *name) 186 186 { 187 const char*p;187 const pj_uint8_t *p; 188 188 pj_status_t status; 189 189 … … 242 242 /* Skip query records. */ 243 243 static pj_status_t parse_query(pj_dns_parsed_query *q, pj_pool_t *pool, 244 const char *pkt, const char *start,245 const char*max, int *parsed_len)246 { 247 const char*p = start;244 const pj_uint8_t *pkt, const pj_uint8_t *start, 245 const pj_uint8_t *max, int *parsed_len) 246 { 247 const pj_uint8_t *p = start; 248 248 int name_len, name_part_len; 249 249 pj_status_t status; … … 255 255 256 256 /* Allocate memory for the name */ 257 q->name.ptr = pj_pool_alloc(pool, name_len+4);257 q->name.ptr = (char*) pj_pool_alloc(pool, name_len+4); 258 258 q->name.slen = 0; 259 259 … … 283 283 /* Parse RR records */ 284 284 static pj_status_t parse_rr(pj_dns_parsed_rr *rr, pj_pool_t *pool, 285 const char*pkt,286 const char *start, const char *max,285 const pj_uint8_t *pkt, 286 const pj_uint8_t *start, const pj_uint8_t *max, 287 287 int *parsed_len) 288 288 { 289 const char*p = start;289 const pj_uint8_t *p = start; 290 290 int name_len, name_part_len; 291 291 pj_status_t status; … … 297 297 298 298 /* Allocate memory for the name */ 299 rr->name.ptr = pj_pool_alloc(pool, name_len+4);299 rr->name.ptr = (char*) pj_pool_alloc(pool, name_len+4); 300 300 rr->name.slen = 0; 301 301 … … 355 355 356 356 /* Allocate memory for the name */ 357 rr->rdata.cname.name.ptr = pj_pool_alloc(pool, name_len);357 rr->rdata.cname.name.ptr = (char*) pj_pool_alloc(pool, name_len); 358 358 rr->rdata.cname.name.slen = 0; 359 359 … … 388 388 389 389 /* Allocate memory for the name */ 390 rr->rdata.srv.target.ptr = pj_pool_alloc(pool, name_len);390 rr->rdata.srv.target.ptr = (char*) pj_pool_alloc(pool, name_len); 391 391 rr->rdata.srv.target.slen = 0; 392 392 … … 419 419 { 420 420 pj_dns_parsed_packet *res; 421 c har*start, *end;421 const pj_uint8_t *start, *end; 422 422 pj_status_t status; 423 423 unsigned i; … … 431 431 432 432 /* Create the structure */ 433 res = pj_pool_zalloc(pool, sizeof(pj_dns_parsed_packet));433 res = PJ_POOL_ZALLOC_T(pool, pj_dns_parsed_packet); 434 434 435 435 /* Copy the DNS header, and convert endianness to host byte order */ … … 443 443 444 444 /* Mark start and end of payload */ 445 start = ((c har*)packet) + sizeof(pj_dns_hdr);446 end = ((c har*)packet) + size;445 start = ((const pj_uint8_t*)packet) + sizeof(pj_dns_hdr); 446 end = ((const pj_uint8_t*)packet) + size; 447 447 448 448 /* Parse query records (if any). 449 449 */ 450 450 if (res->hdr.qdcount) { 451 res->q = pj_pool_zalloc(pool, res->hdr.qdcount * 451 res->q = (pj_dns_parsed_query*) 452 pj_pool_zalloc(pool, res->hdr.qdcount * 452 453 sizeof(pj_dns_parsed_query)); 453 454 for (i=0; i<res->hdr.qdcount; ++i) { 454 455 int parsed_len = 0; 455 456 456 status = parse_query(&res->q[i], pool, packet, start, end,457 457 status = parse_query(&res->q[i], pool, (const pj_uint8_t*)packet, 458 start, end, &parsed_len); 458 459 if (status != PJ_SUCCESS) 459 460 return status; … … 465 466 /* Parse answer, if any */ 466 467 if (res->hdr.anscount) { 467 res->ans = pj_pool_zalloc(pool, res->hdr.anscount * 468 res->ans = (pj_dns_parsed_rr*) 469 pj_pool_zalloc(pool, res->hdr.anscount * 468 470 sizeof(pj_dns_parsed_rr)); 469 471 … … 471 473 int parsed_len; 472 474 473 status = parse_rr(&res->ans[i], pool, packet, start, end,474 475 status = parse_rr(&res->ans[i], pool, (const pj_uint8_t*)packet, 476 start, end, &parsed_len); 475 477 if (status != PJ_SUCCESS) 476 478 return status; … … 482 484 /* Parse authoritative NS records, if any */ 483 485 if (res->hdr.nscount) { 484 res->ns = pj_pool_zalloc(pool, res->hdr.nscount * 486 res->ns = (pj_dns_parsed_rr*) 487 pj_pool_zalloc(pool, res->hdr.nscount * 485 488 sizeof(pj_dns_parsed_rr)); 486 489 … … 488 491 int parsed_len; 489 492 490 status = parse_rr(&res->ns[i], pool, packet, start, end,491 493 status = parse_rr(&res->ns[i], pool, (const pj_uint8_t*)packet, 494 start, end, &parsed_len); 492 495 if (status != PJ_SUCCESS) 493 496 return status; … … 499 502 /* Parse additional RR answer, if any */ 500 503 if (res->hdr.arcount) { 501 res->arr = pj_pool_zalloc(pool, res->hdr.arcount * 504 res->arr = (pj_dns_parsed_rr*) 505 pj_pool_zalloc(pool, res->hdr.arcount * 502 506 sizeof(pj_dns_parsed_rr)); 503 507 … … 505 509 int parsed_len; 506 510 507 status = parse_rr(&res->arr[i], pool, packet, start, end,508 511 status = parse_rr(&res->arr[i], pool, (const pj_uint8_t*)packet, 512 start, end, &parsed_len); 509 513 if (status != PJ_SUCCESS) 510 514 return status; … … 614 618 615 619 /* Create packet and copy header */ 616 *p_dst = dst = pj_pool_zalloc(pool, sizeof(pj_dns_parsed_packet));620 *p_dst = dst = PJ_POOL_ZALLOC_T(pool, pj_dns_parsed_packet); 617 621 pj_memcpy(&dst->hdr, &p->hdr, sizeof(p->hdr)); 618 622 … … 629 633 /* Copy query section */ 630 634 if (p->hdr.qdcount && (options & PJ_DNS_NO_QD)==0) { 631 dst->q = pj_pool_alloc(pool, p->hdr.qdcount * 635 dst->q = (pj_dns_parsed_query*) 636 pj_pool_alloc(pool, p->hdr.qdcount * 632 637 sizeof(pj_dns_parsed_query)); 633 638 for (i=0; i<p->hdr.qdcount; ++i) { … … 640 645 /* Copy answer section */ 641 646 if (p->hdr.anscount && (options & PJ_DNS_NO_ANS)==0) { 642 dst->ans = pj_pool_alloc(pool, p->hdr.anscount * 647 dst->ans = (pj_dns_parsed_rr*) 648 pj_pool_alloc(pool, p->hdr.anscount * 643 649 sizeof(pj_dns_parsed_rr)); 644 650 for (i=0; i<p->hdr.anscount; ++i) { … … 651 657 /* Copy NS section */ 652 658 if (p->hdr.nscount && (options & PJ_DNS_NO_NS)==0) { 653 dst->ns = pj_pool_alloc(pool, p->hdr.nscount * 659 dst->ns = (pj_dns_parsed_rr*) 660 pj_pool_alloc(pool, p->hdr.nscount * 654 661 sizeof(pj_dns_parsed_rr)); 655 662 for (i=0; i<p->hdr.nscount; ++i) { … … 662 669 /* Copy additional info section */ 663 670 if (p->hdr.arcount && (options & PJ_DNS_NO_AR)==0) { 664 dst->arr = pj_pool_alloc(pool, p->hdr.arcount * 671 dst->arr = (pj_dns_parsed_rr*) 672 pj_pool_alloc(pool, p->hdr.arcount * 665 673 sizeof(pj_dns_parsed_rr)); 666 674 for (i=0; i<p->hdr.arcount; ++i) { -
pjproject/trunk/pjlib-util/src/pjlib-util/resolver.c
r1031 r1239 244 244 245 245 /* Create pool and name */ 246 resv = pj_pool_zalloc(pool, sizeof(struct pj_dns_resolver));246 resv = PJ_POOL_ZALLOC_T(pool, struct pj_dns_resolver); 247 247 resv->pool = pool; 248 248 resv->udp_sock = PJ_INVALID_SOCKET; … … 338 338 it = pj_hash_first(resolver->hquerybyid, &it_buf); 339 339 while (it) { 340 pj_dns_async_query *q = pj_hash_this(resolver->hquerybyid, it); 340 pj_dns_async_query *q = (pj_dns_async_query *) 341 pj_hash_this(resolver->hquerybyid, it); 341 342 pj_dns_async_query *cq; 342 343 if (q->cb) … … 498 499 pj_bzero(q, sizeof(*q)); 499 500 } else { 500 q = pj_pool_zalloc(resolver->pool, sizeof(*q));501 q = PJ_POOL_ZALLOC_T(resolver->pool, pj_dns_async_query); 501 502 } 502 503 … … 658 659 */ 659 660 hval = 0; 660 cache = pj_hash_get(resolver->hrescache, &key, sizeof(key), &hval); 661 cache = (struct cached_res *) pj_hash_get(resolver->hrescache, &key, 662 sizeof(key), &hval); 661 663 if (cache) { 662 664 /* We've found a cached entry. */ … … 703 705 704 706 /* Next, check if we have pending query on the same resource */ 705 q = pj_hash_get(resolver->hquerybyres, &key, sizeof(key), NULL); 707 q = (pj_dns_async_query *) pj_hash_get(resolver->hquerybyres, &key, 708 sizeof(key), NULL); 706 709 if (q) { 707 710 /* Yes, there's another pending query to the same key. … … 942 945 /* If status is unsuccessful, clear the same entry from the cache */ 943 946 if (status != PJ_SUCCESS) { 944 cache = pj_hash_get(resolver->hrescache, key, sizeof(*key), &hval); 947 cache = (struct cached_res *) pj_hash_get(resolver->hrescache, key, 948 sizeof(*key), &hval); 945 949 if (cache) 946 950 pj_list_push_back(&resolver->res_free_nodes, cache); … … 977 981 /* If TTL is zero, clear the same entry in the hash table */ 978 982 if (ttl == 0) { 979 cache = pj_hash_get(resolver->hrescache, key, sizeof(*key), &hval); 983 cache = (struct cached_res *) pj_hash_get(resolver->hrescache, key, 984 sizeof(*key), &hval); 980 985 if (cache) 981 986 pj_list_push_back(&resolver->res_free_nodes, cache); … … 985 990 986 991 /* Get a cache response entry */ 987 cache = pj_hash_get(resolver->hrescache, key, sizeof(*key), &hval); 992 cache = (struct cached_res *) pj_hash_get(resolver->hrescache, key, 993 sizeof(*key), &hval); 988 994 if (cache == NULL) { 989 995 if (!pj_list_empty(&resolver->res_free_nodes)) { … … 991 997 pj_list_erase(cache); 992 998 } else { 993 cache = pj_pool_zalloc(resolver->pool, sizeof(*cache));999 cache = PJ_POOL_ZALLOC_T(resolver->pool, struct cached_res); 994 1000 } 995 1001 } … … 1041 1047 PJ_UNUSED_ARG(timer_heap); 1042 1048 1043 q = entry->user_data;1049 q = (pj_dns_async_query *) entry->user_data; 1044 1050 resolver = q->resolver; 1045 1051 … … 1125 1131 1126 1132 1127 resolver = pj_ioqueue_get_user_data(key);1133 resolver = (pj_dns_resolver *) pj_ioqueue_get_user_data(key); 1128 1134 pj_mutex_lock(resolver->mutex); 1129 1135 … … 1188 1194 1189 1195 /* Find the query based on the transaction ID */ 1190 q = pj_hash_get(resolver->hquerybyid, &dns_pkt->hdr.id, 1196 q = (pj_dns_async_query*) 1197 pj_hash_get(resolver->hquerybyid, &dns_pkt->hdr.id, 1191 1198 sizeof(dns_pkt->hdr.id), NULL); 1192 1199 if (!q) { … … 1372 1379 it = pj_hash_first(resolver->hrescache, &itbuf); 1373 1380 while (it) { 1374 struct cached_res *cache = pj_hash_this(resolver->hrescache, it); 1381 struct cached_res *cache; 1382 cache = (struct cached_res*)pj_hash_this(resolver->hrescache, it); 1375 1383 PJ_LOG(3,(resolver->name.ptr, 1376 1384 " Type %s: %s", … … 1390 1398 while (it) { 1391 1399 struct pj_dns_async_query *q; 1392 q = pj_hash_this(resolver->hquerybyid, it);1400 q = (pj_dns_async_query*) pj_hash_this(resolver->hquerybyid, it); 1393 1401 PJ_LOG(3,(resolver->name.ptr, 1394 1402 " Type %s: %s", -
pjproject/trunk/pjlib-util/src/pjlib-util/srv_resolver.c
r1113 r1239 382 382 pj_dns_parsed_packet *pkt) 383 383 { 384 pj_dns_srv_resolver_job *query_job = user_data;384 pj_dns_srv_resolver_job *query_job = (pj_dns_srv_resolver_job*) user_data; 385 385 unsigned i; 386 386 -
pjproject/trunk/pjlib-util/src/pjlib-util/string.c
r974 r1239 32 32 return *src_str; 33 33 34 dst = dst_str.ptr = pj_pool_alloc(pool, src_str->slen);34 dst = dst_str.ptr = (char*) pj_pool_alloc(pool, src_str->slen); 35 35 36 36 while (src != end) { -
pjproject/trunk/pjlib-util/src/pjlib-util/stun_simple.c
r992 r1239 36 36 37 37 38 hdr = pj_pool_calloc(pool, 1, sizeof(pjstun_msg_hdr));38 hdr = PJ_POOL_ZALLOC_T(pool, pjstun_msg_hdr); 39 39 if (!hdr) 40 40 return PJ_ENOMEM; -
pjproject/trunk/pjlib-util/src/pjlib-util/stun_simple_client.c
r992 r1239 42 42 int i, j, send_cnt = 0; 43 43 pj_pool_t *pool; 44 struct {44 struct query_rec { 45 45 struct { 46 46 pj_uint32_t mapped_addr; … … 62 62 63 63 /* Allocate client records */ 64 rec = pj_pool_calloc(pool, sock_cnt, sizeof(*rec));64 rec = (struct query_rec*) pj_pool_calloc(pool, sock_cnt, sizeof(*rec)); 65 65 if (!rec) { 66 66 status = PJ_ENOMEM; … … 98 98 for (i=0; i<sock_cnt && status==PJ_SUCCESS; ++i) { 99 99 for (j=0; j<2 && status==PJ_SUCCESS; ++j) { 100 pjstun_msg_hdr *msg_hdr = out_msg;100 pjstun_msg_hdr *msg_hdr = (pjstun_msg_hdr*) out_msg; 101 101 pj_ssize_t sent_len; 102 102 … … 195 195 } 196 196 197 attr = (void*)pjstun_msg_find_attr(&msg, PJSTUN_ATTR_MAPPED_ADDR); 197 attr = (pjstun_mapped_addr_attr*) 198 pjstun_msg_find_attr(&msg, PJSTUN_ATTR_MAPPED_ADDR); 198 199 if (!attr) { 199 200 status = PJLIB_UTIL_ESTUNNOMAP; -
pjproject/trunk/pjlib-util/src/pjlib-util/xml.c
r1145 r1239 38 38 pj_xml_node *node; 39 39 40 node = pj_pool_zalloc(pool, sizeof(pj_xml_node));40 node = PJ_POOL_ZALLOC_T(pool, pj_xml_node); 41 41 pj_list_init( &node->attr_head ); 42 42 pj_list_init( &node->node_head ); … … 47 47 static pj_xml_attr *alloc_attr( pj_pool_t *pool ) 48 48 { 49 return pj_pool_zalloc(pool, sizeof(pj_xml_attr));49 return PJ_POOL_ZALLOC_T(pool, pj_xml_attr); 50 50 } 51 51 … … 394 394 pj_bool_t (*match)(pj_xml_node *, const void*)) 395 395 { 396 pj_xml_node *head = ( void*)&parent->node_head, *node = head->next;396 pj_xml_node *head = (pj_xml_node*) &parent->node_head, *node = head->next; 397 397 398 398 while (node != (void*)head) { -
pjproject/trunk/pjnath/src/pjnath/ice_session.c
r1216 r1239 297 297 298 298 if (local_ufrag == NULL) { 299 ice->rx_ufrag.ptr = pj_pool_alloc(ice->pool, 16);299 ice->rx_ufrag.ptr = (char*) pj_pool_alloc(ice->pool, 16); 300 300 pj_create_random_string(ice->rx_ufrag.ptr, 16); 301 301 ice->rx_ufrag.slen = 16; … … 305 305 306 306 if (local_passwd == NULL) { 307 ice->rx_pass.ptr = pj_pool_alloc(ice->pool, 16);307 ice->rx_pass.ptr = (char*) pj_pool_alloc(ice->pool, 16); 308 308 pj_create_random_string(ice->rx_pass.ptr, 16); 309 309 ice->rx_pass.slen = 16; … … 397 397 { 398 398 PJ_ASSERT_RETURN(ice && prefs, PJ_EINVAL); 399 ice->prefs = pj_pool_calloc(ice->pool, PJ_ARRAY_SIZE(prefs),400 sizeof(pj_uint8_t));399 ice->prefs = (pj_uint8_t*) pj_pool_calloc(ice->pool, PJ_ARRAY_SIZE(prefs), 400 sizeof(pj_uint8_t)); 401 401 pj_memcpy(ice->prefs, prefs, sizeof(prefs)); 402 402 return PJ_SUCCESS; … … 1709 1709 * Request was sent from. 1710 1710 */ 1711 if (sockaddr_cmp(&check->rcand->addr, src_addr) != 0) {1711 if (sockaddr_cmp(&check->rcand->addr, (const pj_sockaddr*)src_addr) != 0) { 1712 1712 status = PJNATH_EICEINSRCADDR; 1713 1713 LOG4((ice->obj_name, … … 2064 2064 2065 2065 /* Foundation is random, unique from other foundation */ 2066 rcand->foundation.ptr = pj_pool_alloc(ice->pool, 36);2066 rcand->foundation.ptr = (char*) pj_pool_alloc(ice->pool, 36); 2067 2067 rcand->foundation.slen = pj_ansi_snprintf(rcand->foundation.ptr, 36, 2068 2068 "f%p", … … 2303 2303 } 2304 2304 2305 stun_status = pj_stun_msg_check(pkt, pkt_size, PJ_STUN_IS_DATAGRAM); 2305 stun_status = pj_stun_msg_check((const pj_uint8_t*)pkt, pkt_size, 2306 PJ_STUN_IS_DATAGRAM); 2306 2307 if (stun_status == PJ_SUCCESS) { 2307 2308 status = pj_stun_session_on_rx_pkt(comp->stun_sess, pkt, pkt_size, -
pjproject/trunk/pjnath/src/pjnath/stun_msg.c
r1150 r1239 1495 1495 if (data && length) { 1496 1496 attr->length = length; 1497 attr->data = pj_pool_alloc(pool, length);1497 attr->data = (pj_uint8_t*) pj_pool_alloc(pool, length); 1498 1498 pj_memcpy(attr->data, data, length); 1499 1499 } … … 1537 1537 /* Copy the data to the attribute */ 1538 1538 attr->length = attr->hdr.length; 1539 attr->data = pj_pool_alloc(pool, attr->length);1539 attr->data = (pj_uint8_t*) pj_pool_alloc(pool, attr->length); 1540 1540 pj_memcpy(attr->data, buf+ATTR_HDR_LEN, attr->length); 1541 1541 -
pjproject/trunk/pjnath/src/pjnath/stun_session.c
r1154 r1239 381 381 sess->use_fingerprint = fingerprint; 382 382 383 sess->srv_name.ptr = pj_pool_alloc(pool, 32);383 sess->srv_name.ptr = (char*) pj_pool_alloc(pool, 32); 384 384 sess->srv_name.slen = pj_ansi_snprintf(sess->srv_name.ptr, 32, 385 385 "pj_stun-%s", PJ_VERSION); … … 454 454 if (cred) { 455 455 if (!sess->cred) 456 sess->cred = pj_pool_alloc(sess->pool, sizeof(pj_stun_auth_cred));456 sess->cred = PJ_POOL_ALLOC_T(sess->pool, pj_stun_auth_cred); 457 457 pj_stun_auth_cred_dup(sess->pool, sess->cred, cred); 458 458 } else { … … 599 599 600 600 /* Encode message */ 601 status = pj_stun_msg_encode(tdata->msg, tdata->pkt, tdata->max_len, 602 0, get_passwd(sess, tdata->pool, tdata->msg), 601 status = pj_stun_msg_encode(tdata->msg, (pj_uint8_t*)tdata->pkt, 602 tdata->max_len, 0, 603 get_passwd(sess, tdata->pool, tdata->msg), 603 604 &tdata->pkt_size); 604 605 if (status != PJ_SUCCESS) { … … 753 754 /* Alloc packet buffer */ 754 755 out_max_len = PJ_STUN_MAX_PKT_LEN; 755 out_pkt = pj_pool_alloc(pool, out_max_len);756 out_pkt = (pj_uint8_t*) pj_pool_alloc(pool, out_max_len); 756 757 757 758 /* Encode */ … … 959 960 } 960 961 961 dump = pj_pool_alloc(tmp_pool, PJ_STUN_MAX_PKT_LEN);962 dump = (char*) pj_pool_alloc(tmp_pool, PJ_STUN_MAX_PKT_LEN); 962 963 963 964 PJ_LOG(5,(SNAME(sess), … … 981 982 */ 982 983 if ((options & PJ_STUN_NO_AUTHENTICATE) == 0) { 983 status = authenticate_msg(sess, packet, pkt_size, msg, tmp_pool,984 src_addr, src_addr_len);984 status = authenticate_msg(sess, (const pj_uint8_t*) packet, pkt_size, 985 msg, tmp_pool, src_addr, src_addr_len); 985 986 if (status != PJ_SUCCESS) { 986 987 goto on_return; … … 996 997 } else if (PJ_STUN_IS_REQUEST(msg->hdr.type)) { 997 998 998 status = on_incoming_request(sess, tmp_pool, packet, pkt_size, msg, 999 src_addr, src_addr_len); 999 status = on_incoming_request(sess, tmp_pool, 1000 (const pj_uint8_t*) packet, pkt_size, 1001 msg, src_addr, src_addr_len); 1000 1002 1001 1003 } else if (PJ_STUN_IS_INDICATION(msg->hdr.type)) { 1002 1004 1003 status = on_incoming_indication(sess, tmp_pool, packet, pkt_size, 1005 status = on_incoming_indication(sess, tmp_pool, 1006 (const pj_uint8_t*) packet, pkt_size, 1004 1007 msg, src_addr, src_addr_len); 1005 1008
Note: See TracChangeset
for help on using the changeset viewer.