Returns hostent or rdata struct, based on what callers needs */
| 766 | |
| 767 | /* Returns hostent or rdata struct, based on what callers needs */ |
| 768 | void* get_dnscache_value(char *name,int r_type,int name_len) |
| 769 | { |
| 770 | str value; |
| 771 | struct hostent *he; |
| 772 | struct rdata *head; |
| 773 | |
| 774 | if (cdbc == NULL) { |
| 775 | /* assume dns request before forking - cache is not ready yet */ |
| 776 | return NULL; |
| 777 | } |
| 778 | |
| 779 | if (get_dnscache_strvalue(name,r_type,name_len,&value) < 0) { |
| 780 | LM_DBG("failed to fetch from cache\n"); |
| 781 | return NULL; |
| 782 | } |
| 783 | |
| 784 | if (value.len == FAILURE_MARKER_LEN && value.s[0] == FAILURE_MARKER_CHAR) { |
| 785 | LM_DBG("blacklisted value %s for type %d\n",name,r_type); |
| 786 | pkg_free(value.s); |
| 787 | return (void *)-1; |
| 788 | } |
| 789 | |
| 790 | if (r_type == T_A || r_type == T_AAAA || r_type == T_PTR) { |
| 791 | he = deserialize_he_rdata(value.s,value.len, |
| 792 | CACHEDB_CAPABILITY(&cdbf,CACHEDB_CAP_BINARY_VALUE)?0:1); |
| 793 | if (he == NULL) { |
| 794 | LM_ERR("failed to deserialize he struct\n"); |
| 795 | pkg_free(value.s); |
| 796 | return NULL; |
| 797 | } |
| 798 | pkg_free(value.s); |
| 799 | return he; |
| 800 | } else { |
| 801 | head = deserialize_dns_rdata(value.s,value.len, |
| 802 | CACHEDB_CAPABILITY(&cdbf,CACHEDB_CAP_BINARY_VALUE)?0:1); |
| 803 | if (head == NULL) { |
| 804 | LM_ERR("failed to deserialize rdata struct\n"); |
| 805 | pkg_free(value.s); |
| 806 | return NULL; |
| 807 | } |
| 808 | pkg_free(value.s); |
| 809 | return head; |
| 810 | } |
| 811 | } |
| 812 | |
| 813 | /* Pushes internal structure ( hostent or rdata ) to a cache backend |
| 814 | * |
nothing calls this directly
no test coverage detected