MCPcopy Create free account
hub / github.com/OpenSIPS/opensips / deserialize_dns_rdata

Function deserialize_dns_rdata

modules/dns_cache/dns_cache.c:483–659  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

481static unsigned char *dec_rdata_buf=NULL;
482static int dec_rdata_buf_len=0;
483static struct rdata* deserialize_dns_rdata(char *buff,int buf_len,int do_decoding)
484{
485 unsigned char *p;
486 int max_len=0,actual_len=0,entry_len=0;
487 struct rdata *head,*it,**last;
488 struct naptr_rdata *naptr_rd;
489 struct srv_rdata *srv_rd;
490 struct txt_rdata *txt_rd;
491 struct ebl_rdata *ebl_rd;
492
493 head=it=NULL;
494 last=&head;
495
496 if (do_decoding) {
497 max_len = calc_max_base64_decode_len(buf_len);
498 } else {
499 max_len = buf_len;
500 }
501
502 if (dec_rdata_buf == NULL || max_len > dec_rdata_buf_len) {
503 /* realloc buff if not enough space */
504 dec_rdata_buf = pkg_realloc(dec_rdata_buf,max_len);
505 if (dec_rdata_buf == NULL) {
506 LM_ERR("No more pkg\n");
507 return NULL;
508 }
509 dec_rdata_buf_len = max_len;
510 }
511
512 if (do_decoding) {
513 /* decode base64 buf */
514 actual_len = base64decode(dec_rdata_buf,(unsigned char *)buff,buf_len);
515 p = dec_rdata_buf;
516 } else {
517 memcpy(dec_rdata_buf,buff,buf_len);
518 actual_len = buf_len;
519 p = dec_rdata_buf;
520 }
521
522 while ( p < dec_rdata_buf+actual_len) {
523 it = pkg_malloc(sizeof(struct rdata));
524 if (it == 0) {
525 LM_ERR("no more pkg mem\n");
526 goto it_alloc_error;
527 }
528
529 /* copy type, class & ttl */
530 memcpy(it,p,rdata_struct_len);
531 p+=rdata_struct_len;
532 it->next=0;
533 it->rdata=0;
534
535 switch (it->type) {
536 case T_A:
537 it->rdata = pkg_malloc(sizeof(struct a_rdata));
538 if (it->rdata == 0) {
539 LM_ERR("no more pkg\n");
540 goto rdata_alloc_error;

Callers 1

get_dnscache_valueFunction · 0.85

Calls 2

base64decodeFunction · 0.85
free_rdata_listFunction · 0.85

Tested by

no test coverage detected