rdata_test.c revision 0c27b3fe77ac1d5094ba3521e8142d9e7973133f
/*
* Copyright (C) 2012, 2013, 2015, 2016 Internet Systems Consortium, Inc. ("ISC")
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
/* $Id$ */
/*! \file */
#include <config.h>
#include <atf-c.h>
#include <unistd.h>
#include <dns/callbacks.h>
#include "dnstest.h"
/*
* Individual unit tests
*/
/* Successful load test */
"be rejected");
}
unsigned char hipwire[DNS_RDATA_MAXLENGTH] = {
0x01, 0x00, 0x00, 0x01, 0x00, 0x00,
0x04, 0x41, 0x42, 0x43, 0x44, 0x00 };
size_t i;
/*
* Fill the rest of input buffer with compression pointers.
*/
hipwire[i] = 0xc0;
}
isc_buffer_setactive(&source, i);
0, &target);
}
"check EDNS client subnet option parsing");
}
struct {
unsigned char data[64];
} test_data[] = {
{
/* option code with no content */
},
{
/* Option code family 0, source 0, scope 0 */
{
0x00, 0x08, 0x00, 0x04,
0x00, 0x00, 0x00, 0x00
},
8, ISC_TRUE
},
{
/* Option code family 1 (ipv4), source 0, scope 0 */
{
0x00, 0x08, 0x00, 0x04,
0x00, 0x01, 0x00, 0x00
},
8, ISC_FALSE
},
{
/* Option code family 2 (ipv6) , source 0, scope 0 */
{
0x00, 0x08, 0x00, 0x04,
0x00, 0x02, 0x00, 0x00
},
8, ISC_FALSE
},
{
/* extra octet */
{
0x00, 0x08, 0x00, 0x05,
0x00, 0x00, 0x00, 0x00,
0x00
},
9, ISC_FALSE
},
{
/* source too long for IPv4 */
{
0x00, 0x08, 0x00, 8,
0x00, 0x01, 33, 0x00,
0x00, 0x00, 0x00, 0x00
},
12, ISC_FALSE
},
{
/* source too long for IPv6 */
{
0x00, 0x08, 0x00, 20,
0x00, 0x02, 129, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
},
24, ISC_FALSE
},
{
/* scope too long for IPv4 */
{
0x00, 0x08, 0x00, 8,
0x00, 0x01, 0x00, 33,
0x00, 0x00, 0x00, 0x00
},
12, ISC_FALSE
},
{
/* scope too long for IPv6 */
{
0x00, 0x08, 0x00, 20,
0x00, 0x02, 0x00, 129,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
},
24, ISC_FALSE
},
{
/* length too short for source generic */
{
0x00, 0x08, 0x00, 5,
0x00, 0x00, 17, 0x00,
0x00, 0x00,
},
19, ISC_FALSE
},
{
/* length too short for source ipv4 */
{
0x00, 0x08, 0x00, 7,
0x00, 0x01, 32, 0x00,
0x00, 0x00, 0x00, 0x00
},
11, ISC_FALSE
},
{
/* length too short for source ipv6 */
{
0x00, 0x08, 0x00, 19,
0x00, 0x02, 128, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
},
23, ISC_FALSE
},
{
/* sentinal */
{ 0x00 }, 0, ISC_FALSE
}
};
size_t i;
else
}
}
}
struct {
unsigned char data[64];
} test_data[] = {
{
/* too short */
},
{
/* minimal TCP */
},
{
/* minimal UDP */
},
{
/* minimal other */
},
{
/* sentinal */
{ 0x00 }, 0, ISC_FALSE
}
};
unsigned char buf1[1024];
unsigned char buf2[1024];
size_t i;
else
if (result != ISC_R_SUCCESS)
continue;
&target2);
}
}
}
struct {
unsigned char data[64];
} test_data[] = {
{
/* "" */
},
{
/* "\001" */
},
{
/* "\001" "" */
},
{
/* "\000" "\001" */
},
{
/* sentinal */
{ 0x00 }, 0, ISC_FALSE
}
};
unsigned char buf1[1024];
unsigned char buf2[1024];
size_t i;
else
if (result != ISC_R_SUCCESS)
continue;
&target2);
}
}
static void
}
static void
}
}
struct {
const char *data;
} text_data[] = {
{ "", ISC_FALSE },
{ ".", ISC_FALSE },
{ ". RRSIG", ISC_TRUE },
};
struct {
unsigned char data[64];
} wire_data[] = {
{ { 0x00 }, 0, ISC_FALSE },
};
size_t i;
&callbacks);
else
}
else
if (result != ISC_R_SUCCESS)
continue;
}
}
}
struct {
const char *data;
} text_data[] = {
{ "", ISC_FALSE },
{ "0", ISC_FALSE },
{ "0 0", ISC_TRUE },
{ "0 0 A", ISC_TRUE },
{ "0 0 NS", ISC_TRUE },
{ "0 0 AAAA", ISC_TRUE },
{ "0 0 A AAAA", ISC_TRUE },
{ "0 0 A NS AAAA", ISC_TRUE },
{ "0 0 A NS AAAA BOGUS", ISC_FALSE },
};
struct {
unsigned char data[64];
} wire_data[] = {
/* short */
{ { 0x00 }, 0, ISC_FALSE },
/* short */
/* short */
/* short */
/* short */
/* short */
/* serial + flags only */
/* bad type map */
/* bad type map */
{ { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
8, ISC_FALSE },
/* good type map */
{ { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02 },
9, ISC_TRUE }
};
unsigned char buf1[1024];
unsigned char buf2[1024];
size_t i;
&callbacks);
else
}
else
if (result != ISC_R_SUCCESS)
continue;
}
}
/*
* Main
*/
ATF_TP_ADD_TCS(tp) {
return (atf_no_error());
}