comparison src/dnsbl.cpp @ 386:e27e22f6a49a

start parsing spf txt records
author Carl Byington <carl@five-ten-sg.com>
date Mon, 06 Mar 2017 15:03:38 -0800
parents be7355b47051
children 616e46e9b8f0
comparison
equal deleted inserted replaced
385:be7355b47051 386:e27e22f6a49a
149 // packed structure to allow a single socket write to dump the 149 // packed structure to allow a single socket write to dump the
150 // length and the following answer. The packing attribute is gcc specific. 150 // length and the following answer. The packing attribute is gcc specific.
151 struct glommer { 151 struct glommer {
152 size_t length; 152 size_t length;
153 #ifdef NS_PACKETSZ 153 #ifdef NS_PACKETSZ
154 u_char answer[NS_PACKETSZ*4]; // with a resolver, we return resolver answers 154 u_char answer[NS_PACKETSZ*8]; // with a resolver, we return resolver answers
155 #else 155 #else
156 uint32_t answer; // without a resolver, we return a single ipv4 address in network byte order, 0 == no answer 156 uint32_t answer; // without a resolver, we return a single ipv4 address in network byte order, 0 == no answer
157 #endif 157 #endif
158 } __attribute__ ((packed)); 158 } __attribute__ ((packed));
159 159
885 } 885 }
886 question[rs-1] = '\0'; // ensure null termination 886 question[rs-1] = '\0'; // ensure null termination
887 887
888 // find the answer 888 // find the answer
889 #ifdef NS_PACKETSZ 889 #ifdef NS_PACKETSZ
890 int res_result = res_search(question+1, ns_c_in, int8_t(question[0]), glom.answer, sizeof(glom.answer));
890 //#ifdef RESOLVER_DEBUG 891 //#ifdef RESOLVER_DEBUG
891 char text[1000]; 892 char text[1000];
892 snprintf(text, sizeof(text), "process_resolver_requests() has a question %s qtype %d", question+1, int8_t(question[0])); 893 snprintf(text, sizeof(text), "process_resolver_requests() has a question %s qtype %d buf len %d result %d", question+1, int8_t(question[0]), sizeof(glom.answer), res_result);
893 my_syslog(text); 894 my_syslog(text);
894 //#endif 895 //#endif
895 int res_result = res_search(question+1, ns_c_in, int8_t(question[0]), glom.answer, sizeof(glom.answer));
896 if (res_result < 0) glom.length = 0; // represent all errors as zero length answers 896 if (res_result < 0) glom.length = 0; // represent all errors as zero length answers
897 else glom.length = (size_t)res_result; 897 else glom.length = (size_t)res_result;
898 #else 898 #else
899 glom.length = sizeof(glom.answer); 899 glom.length = sizeof(glom.answer);
900 glom.answer = 0; 900 glom.answer = 0;