git-svn-id: svn+ssh://svn.dolda2000.com/srv/svn/repos/src/doldaconnect@886
959494ce-11ee-0310-bf91-
de5d638817bd
+/*
+ * It kind of sucks that libresolv doesn't have any DNS parsing
+ * routines. We'll have to do it manually.
+ */
static char *readname(unsigned char *msg, unsigned char *eom, unsigned char **p)
{
char *name, *tname;
static char *readname(unsigned char *msg, unsigned char *eom, unsigned char **p)
{
char *name, *tname;
return(-1);
}
eom = buf + ret;
return(-1);
}
eom = buf + ret;
+ /*
+ * Assume transaction ID is correct.
+ *
+ * Flags check: FA0F masks in request/response flag, opcode,
+ * truncated flag and status code, and ignores authoritativeness,
+ * recursion flags and DNSSEC and reserved bits.
+ */
flags = (buf[2] << 8) + buf[3];
if((flags & 0xfa0f) != 0x8000)
{
free(name2);
return(-1);
}
flags = (buf[2] << 8) + buf[3];
if((flags & 0xfa0f) != 0x8000)
{
free(name2);
return(-1);
}
+ /* Skip the query entries */
num = (buf[4] << 8) + buf[5];
p = buf + 12;
for(i = 0; i < num; i++)
num = (buf[4] << 8) + buf[5];
p = buf + 12;
for(i = 0; i < num; i++)
free(name2);
return(-1);
}
free(name2);
return(-1);
}
+ p += 4; /* Type and class */
num = (buf[6] << 8) + buf[7];
for(i = 0; i < num; i++)
{
num = (buf[6] << 8) + buf[7];
for(i = 0; i < num; i++)
{
type += *(p++);
class = *(p++) << 8;
class += *(p++);
type += *(p++);
class = *(p++) << 8;
class += *(p++);
len = *(p++) << 8;
len += *(p++);
if((class == C_IN) && (type == T_SRV) && !strcmp(rrname, name2))
len = *(p++) << 8;
len += *(p++);
if((class == C_IN) && (type == T_SRV) && !strcmp(rrname, name2))