Note that there are some explanatory texts on larger screens.

plurals
  1. POc query txt record
    text
    copied!<p>Every body, I have write program to read the dns txt record, but it has some issue, who can tell my why? Following is my source code</p> <pre><code>char blockItem[512]; bzero(blockItem,512); /*Temp Save the txt record value*/ int responseLength; /*The Length of response*/ int i; /*For Loop Controller*/ ns_msg query_parse_msg; /*List of response message * For txt record , It sould only one response! * */ ns_rr query_parse_rr; /*One response message*/ u_char responseByte[512]; /*Variable that for storage query answer.*/ bzero(responseByte,512); /*Clear variable*/ if ((responseLength = res_query(host,C_IN,T_TXT,responseByte,512)) &lt; 0) { /*Query DNS Server*/ return HOSTNOTFIND; } else { if (ns_initparse(responseByte,responseLength,&amp;query_parse_msg) &lt; 0) { /*Pass the answer to ns_msg(May be it mean cut the dns header)*/ printf("%s\n","Cannot Read response Message"); return NOTSUCCESSFUL; } else { for (i =0;i &lt; ns_msg_count(query_parse_msg,ns_s_an);i++) { /*Count the toolly response*/ if (ns_parserr(&amp;query_parse_msg,ns_s_an,i,&amp;query_parse_rr)) { /*Pass the msg list to rr.*/ printf("%s\n","Parse failed!"); return NOTSUCCESSFUL; } else { u_char const *rdata = (u_char*)(ns_rr_rdata(query_parse_rr) ); char *blockItem; blockItem=(char*)rdata; blockItem[strlen((char*)rdata)-2] = '\0'; /*Pass the ns_rr to char data type.*/ printf("Normal:%s\n",(u_char *)blockItem); } } } </code></pre> <p>OutPut: <code>Fv=spf1 redirect=_spf.google.com</code></p> <p>But original txt record should be <code>v=spf1 redirect=_spf.google.com</code></p> <p>My issue is <code>u_char const *rdata = (u_char*)(ns_rr_rdata(query_parse_rr) )</code></p> <p>If i change it to <code>u_char const *rdata = (u_char*)(ns_rr_rdata(query_parse_rr) +1)</code></p> <p>Output will change to: <code>v=spf1 redirect=_spf.google.com</code></p> <p>Also , I has refer how to query MX record, i found that has +2, Anything can tell me why??</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload