모든 몸으로, 나는 dns txt 레코드를 읽을 프로그램을 만들었지 만, 그 이유를 누가 말할 수 있는가? 다음 내 소스 코드c query txt record
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)) < 0)
{
/*Query DNS Server*/
return HOSTNOTFIND;
}
else
{
if (ns_initparse(responseByte,responseLength,&query_parse_msg) < 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 < ns_msg_count(query_parse_msg,ns_s_an);i++)
{
/*Count the toolly response*/
if (ns_parserr(&query_parse_msg,ns_s_an,i,&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);
}
}
}
출력 : Fv=spf1 redirect=_spf.google.com
하지만 u_char const *rdata = (u_char*)(ns_rr_rdata(query_parse_rr) +1)
출력으로 변경하면 원래의 TXT 레코드 내 문제가 u_char const *rdata = (u_char*)(ns_rr_rdata(query_parse_rr))
입니다 v=spf1 redirect=_spf.google.com
해야한다 변경됩니다 : v=spf1 redirect=_spf.google.com
또한 MX 레코드를 쿼리하는 방법을 참조했습니다. +2가있는 것으로 나타났습니다. 아무 것도 말해 줄 수 있습니까?
이 제대로입니다, 하지만 RFC 1034에 3.3.14 및 3.3.9를 찾을 수 없습니다. 내 링크가 구식 일 수 있습니까 ?? http://www.ietf.org/rfc/rfc1034.txt – user1550863
@ user1550863 __sorry__, 1035입니다. – Sandman4