|
|
|
@ -527,9 +527,86 @@ end:
|
|
|
|
|
return (result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** \test TXT records in answer */
|
|
|
|
|
static int DNSUDPParserTest04 (void) {
|
|
|
|
|
int result = 0;
|
|
|
|
|
uint8_t buf[] = {
|
|
|
|
|
0xc2,0x2f,0x81,0x80,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x0a,0x41,0x41,0x41,
|
|
|
|
|
0x41,0x41,0x4f,0x31,0x6b,0x51,0x41,0x05,0x3d,0x61,0x75,0x74,0x68,0x03,0x73,0x72,
|
|
|
|
|
0x76,0x06,0x74,0x75,0x6e,0x6e,0x65,0x6c,0x03,0x63,0x6f,0x6d,0x00,0x00,0x10,0x00,
|
|
|
|
|
0x01,
|
|
|
|
|
/* answer record start */
|
|
|
|
|
0xc0,0x0c,0x00,0x10,0x00,0x01,0x00,0x00,0x00,0x03,0x00,0x22,
|
|
|
|
|
/* txt record starts: */
|
|
|
|
|
0x20, /* <txt len 32 */ 0x41,0x68,0x76,0x4d,0x41,0x41,0x4f,0x31,0x6b,0x41,0x46,
|
|
|
|
|
0x45,0x35,0x54,0x45,0x39,0x51,0x54,0x6a,0x46,0x46,0x4e,0x30,0x39,0x52,0x4e,0x31,
|
|
|
|
|
0x6c,0x59,0x53,0x44,0x6b,0x00, /* <txt len 0 */ 0xc0,0x1d,0x00,0x02,0x00,0x01,
|
|
|
|
|
0x00,0x09,0x3a,0x80,0x00,0x09,0x06,0x69,0x6f,0x64,0x69,0x6e,0x65,0xc0,0x21,0xc0,
|
|
|
|
|
0x6b,0x00,0x01,0x00,0x01,0x00,0x09,0x3a,0x80,0x00,0x04,0x0a,0x1e,0x1c,0x5f
|
|
|
|
|
};
|
|
|
|
|
size_t buflen = sizeof(buf);
|
|
|
|
|
Flow *f = NULL;
|
|
|
|
|
|
|
|
|
|
f = UTHBuildFlow(AF_INET, "1.2.3.4", "1.2.3.5", 1024, 53);
|
|
|
|
|
if (f == NULL)
|
|
|
|
|
goto end;
|
|
|
|
|
f->proto = IPPROTO_UDP;
|
|
|
|
|
f->alproto = ALPROTO_DNS;
|
|
|
|
|
f->alstate = DNSStateAlloc();
|
|
|
|
|
|
|
|
|
|
int r = DNSUDPResponseParse(f, f->alstate, NULL, buf, buflen, NULL);
|
|
|
|
|
if (r != 1)
|
|
|
|
|
goto end;
|
|
|
|
|
|
|
|
|
|
result = 1;
|
|
|
|
|
end:
|
|
|
|
|
UTHFreeFlow(f);
|
|
|
|
|
return (result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** \test TXT records in answer, bad txtlen */
|
|
|
|
|
static int DNSUDPParserTest05 (void) {
|
|
|
|
|
int result = 0;
|
|
|
|
|
uint8_t buf[] = {
|
|
|
|
|
0xc2,0x2f,0x81,0x80,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x0a,0x41,0x41,0x41,
|
|
|
|
|
0x41,0x41,0x4f,0x31,0x6b,0x51,0x41,0x05,0x3d,0x61,0x75,0x74,0x68,0x03,0x73,0x72,
|
|
|
|
|
0x76,0x06,0x74,0x75,0x6e,0x6e,0x65,0x6c,0x03,0x63,0x6f,0x6d,0x00,0x00,0x10,0x00,
|
|
|
|
|
0x01,
|
|
|
|
|
/* answer record start */
|
|
|
|
|
0xc0,0x0c,0x00,0x10,0x00,0x01,0x00,0x00,0x00,0x03,0x00,0x22,
|
|
|
|
|
/* txt record starts: */
|
|
|
|
|
0x40, /* <txt len 64 */ 0x41,0x68,0x76,0x4d,0x41,0x41,0x4f,0x31,0x6b,0x41,0x46,
|
|
|
|
|
0x45,0x35,0x54,0x45,0x39,0x51,0x54,0x6a,0x46,0x46,0x4e,0x30,0x39,0x52,0x4e,0x31,
|
|
|
|
|
0x6c,0x59,0x53,0x44,0x6b,0x00, /* <txt len 0 */ 0xc0,0x1d,0x00,0x02,0x00,0x01,
|
|
|
|
|
0x00,0x09,0x3a,0x80,0x00,0x09,0x06,0x69,0x6f,0x64,0x69,0x6e,0x65,0xc0,0x21,0xc0,
|
|
|
|
|
0x6b,0x00,0x01,0x00,0x01,0x00,0x09,0x3a,0x80,0x00,0x04,0x0a,0x1e,0x1c,0x5f
|
|
|
|
|
};
|
|
|
|
|
size_t buflen = sizeof(buf);
|
|
|
|
|
Flow *f = NULL;
|
|
|
|
|
|
|
|
|
|
f = UTHBuildFlow(AF_INET, "1.2.3.4", "1.2.3.5", 1024, 53);
|
|
|
|
|
if (f == NULL)
|
|
|
|
|
goto end;
|
|
|
|
|
f->proto = IPPROTO_UDP;
|
|
|
|
|
f->alproto = ALPROTO_DNS;
|
|
|
|
|
f->alstate = DNSStateAlloc();
|
|
|
|
|
|
|
|
|
|
int r = DNSUDPResponseParse(f, f->alstate, NULL, buf, buflen, NULL);
|
|
|
|
|
if (r != -1)
|
|
|
|
|
goto end;
|
|
|
|
|
|
|
|
|
|
result = 1;
|
|
|
|
|
end:
|
|
|
|
|
UTHFreeFlow(f);
|
|
|
|
|
return (result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void DNSUDPParserRegisterTests(void) {
|
|
|
|
|
UtRegisterTest("DNSUDPParserTest01", DNSUDPParserTest01, 1);
|
|
|
|
|
UtRegisterTest("DNSUDPParserTest02", DNSUDPParserTest02, 1);
|
|
|
|
|
UtRegisterTest("DNSUDPParserTest03", DNSUDPParserTest03, 1);
|
|
|
|
|
UtRegisterTest("DNSUDPParserTest04", DNSUDPParserTest04, 1);
|
|
|
|
|
UtRegisterTest("DNSUDPParserTest05", DNSUDPParserTest05, 1);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|