The FreeRADIUS server $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Loading...
Searching...
No Matches
Macros | Functions | Variables
dns_tests.c File Reference

Tests for DNS label encoding / decoding. More...

#include "acutest.h"
#include "acutest_helpers.h"
#include <freeradius-devel/util/value.h>
#include <freeradius-devel/util/dns.h>
+ Include dependency graph for dns_tests.c:

Go to the source code of this file.

Macros

#define DNS_HDR_LEN   12
 

Functions

static ssize_t encode_label (uint8_t *buf, size_t buf_len, uint8_t *where, char const *str, bool compression, fr_dns_labels_t *lb)
 
static void labels_init (fr_dns_labels_t *lb, uint8_t const *packet, size_t packet_len, bool use_mark)
 
static void test_compress_62_byte_label (void)
 
static void test_compress_63_byte_label (void)
 
static void test_compress_middle_62_byte_label (void)
 
static void test_compress_middle_63_byte_label (void)
 
static void test_compress_two_names (void)
 
static void test_decode_compressed_pointer (void)
 
static void test_decode_forward_pointer_rejected (void)
 
static void test_decode_invalid_high_bits (void)
 
static void test_decode_label_invalid_chars (void)
 
static void test_decode_label_overflow (void)
 
static void test_decode_multi_label (void)
 
static void test_decode_null_inputs (void)
 
static void test_decode_pointer_to_pointer_rejected (void)
 
static void test_decode_root_label (void)
 
static void test_decode_self_pointer_rejected (void)
 
static void test_decode_simple_label (void)
 
static void test_decode_to_value_box_label_outside_buf (void)
 
static void test_decode_to_value_box_zero_len (void)
 
static void test_decode_total_length_exceeds_255 (void)
 
static void test_encode_buffer_too_small (void)
 
static void test_encode_double_dot (void)
 
static void test_encode_empty_string (void)
 
static void test_encode_hyphen_and_digits (void)
 
static void test_encode_invalid_chars (void)
 
static void test_encode_label_too_long (void)
 
static void test_encode_leading_dot (void)
 
static void test_encode_max_label_length (void)
 
static void test_encode_multi_label (void)
 
static void test_encode_non_string_type (void)
 
static void test_encode_null_inputs (void)
 
static void test_encode_root_dot (void)
 
static void test_encode_simple_label (void)
 
static void test_encode_trailing_dot (void)
 
static void test_encode_underscore_prefix (void)
 
static void test_encode_where_outside_buf (void)
 
static void test_labels_block_tracking (void)
 
static void test_pointer_invalid_with_mark_tracking (void)
 
static void test_pointer_to_zero_label_rejected (void)
 
static void test_pointer_valid_no_tracking (void)
 
static void test_roundtrip_case_preservation (void)
 
static void test_roundtrip_compressed (void)
 
static void test_roundtrip_root (void)
 
static void test_roundtrip_simple (void)
 
static void test_roundtrip_trailing_dot (void)
 
static void test_roundtrip_underscore (void)
 
static void test_verify_empty (void)
 
static void test_verify_simple (void)
 

Variables

static fr_dns_block_t test_blocks [256]
 
 TEST_LIST
 
static uint8_t test_marker [65536]
 

Detailed Description

Tests for DNS label encoding / decoding.

Definition in file dns_tests.c.

Macro Definition Documentation

◆ DNS_HDR_LEN

#define DNS_HDR_LEN   12

Definition at line 29 of file dns_tests.c.

Function Documentation

◆ encode_label()

static ssize_t encode_label ( uint8_t buf,
size_t  buf_len,
uint8_t where,
char const *  str,
bool  compression,
fr_dns_labels_t lb 
)
static

Definition at line 60 of file dns_tests.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ labels_init()

static void labels_init ( fr_dns_labels_t lb,
uint8_t const *  packet,
size_t  packet_len,
bool  use_mark 
)
static

Definition at line 37 of file dns_tests.c.

+ Here is the caller graph for this function:

◆ test_compress_62_byte_label()

static void test_compress_62_byte_label ( void  )
static

Definition at line 825 of file dns_tests.c.

+ Here is the call graph for this function:

◆ test_compress_63_byte_label()

static void test_compress_63_byte_label ( void  )
static

Definition at line 869 of file dns_tests.c.

+ Here is the call graph for this function:

◆ test_compress_middle_62_byte_label()

static void test_compress_middle_62_byte_label ( void  )
static

Definition at line 919 of file dns_tests.c.

+ Here is the call graph for this function:

◆ test_compress_middle_63_byte_label()

static void test_compress_middle_63_byte_label ( void  )
static

Definition at line 947 of file dns_tests.c.

+ Here is the call graph for this function:

◆ test_compress_two_names()

static void test_compress_two_names ( void  )
static

Definition at line 621 of file dns_tests.c.

+ Here is the call graph for this function:

◆ test_decode_compressed_pointer()

static void test_decode_compressed_pointer ( void  )
static

Definition at line 314 of file dns_tests.c.

+ Here is the call graph for this function:

◆ test_decode_forward_pointer_rejected()

static void test_decode_forward_pointer_rejected ( void  )
static

Definition at line 336 of file dns_tests.c.

+ Here is the call graph for this function:

◆ test_decode_invalid_high_bits()

static void test_decode_invalid_high_bits ( void  )
static

Definition at line 384 of file dns_tests.c.

+ Here is the call graph for this function:

◆ test_decode_label_invalid_chars()

static void test_decode_label_invalid_chars ( void  )
static

Definition at line 440 of file dns_tests.c.

+ Here is the call graph for this function:

◆ test_decode_label_overflow()

static void test_decode_label_overflow ( void  )
static

Definition at line 399 of file dns_tests.c.

+ Here is the call graph for this function:

◆ test_decode_multi_label()

static void test_decode_multi_label ( void  )
static

Definition at line 280 of file dns_tests.c.

+ Here is the call graph for this function:

◆ test_decode_null_inputs()

static void test_decode_null_inputs ( void  )
static

Definition at line 415 of file dns_tests.c.

+ Here is the call graph for this function:

◆ test_decode_pointer_to_pointer_rejected()

static void test_decode_pointer_to_pointer_rejected ( void  )
static

Definition at line 367 of file dns_tests.c.

+ Here is the call graph for this function:

◆ test_decode_root_label()

static void test_decode_root_label ( void  )
static

Definition at line 299 of file dns_tests.c.

+ Here is the call graph for this function:

◆ test_decode_self_pointer_rejected()

static void test_decode_self_pointer_rejected ( void  )
static

Definition at line 352 of file dns_tests.c.

+ Here is the call graph for this function:

◆ test_decode_simple_label()

static void test_decode_simple_label ( void  )
static

Definition at line 262 of file dns_tests.c.

+ Here is the call graph for this function:

◆ test_decode_to_value_box_label_outside_buf()

static void test_decode_to_value_box_label_outside_buf ( void  )
static

Definition at line 659 of file dns_tests.c.

+ Here is the call graph for this function:

◆ test_decode_to_value_box_zero_len()

static void test_decode_to_value_box_zero_len ( void  )
static

Definition at line 649 of file dns_tests.c.

+ Here is the call graph for this function:

◆ test_decode_total_length_exceeds_255()

static void test_decode_total_length_exceeds_255 ( void  )
static

Definition at line 455 of file dns_tests.c.

+ Here is the call graph for this function:

◆ test_encode_buffer_too_small()

static void test_encode_buffer_too_small ( void  )
static

Definition at line 234 of file dns_tests.c.

+ Here is the call graph for this function:

◆ test_encode_double_dot()

static void test_encode_double_dot ( void  )
static

Definition at line 203 of file dns_tests.c.

+ Here is the call graph for this function:

◆ test_encode_empty_string()

static void test_encode_empty_string ( void  )
static

Definition at line 71 of file dns_tests.c.

+ Here is the call graph for this function:

◆ test_encode_hyphen_and_digits()

static void test_encode_hyphen_and_digits ( void  )
static

Definition at line 761 of file dns_tests.c.

+ Here is the call graph for this function:

◆ test_encode_invalid_chars()

static void test_encode_invalid_chars ( void  )
static

Definition at line 185 of file dns_tests.c.

+ Here is the call graph for this function:

◆ test_encode_label_too_long()

static void test_encode_label_too_long ( void  )
static

Definition at line 221 of file dns_tests.c.

+ Here is the call graph for this function:

◆ test_encode_leading_dot()

static void test_encode_leading_dot ( void  )
static

Definition at line 212 of file dns_tests.c.

+ Here is the call graph for this function:

◆ test_encode_max_label_length()

static void test_encode_max_label_length ( void  )
static

Definition at line 748 of file dns_tests.c.

+ Here is the call graph for this function:

◆ test_encode_multi_label()

static void test_encode_multi_label ( void  )
static

Definition at line 107 of file dns_tests.c.

+ Here is the call graph for this function:

◆ test_encode_non_string_type()

static void test_encode_non_string_type ( void  )
static

Definition at line 174 of file dns_tests.c.

+ Here is the call graph for this function:

◆ test_encode_null_inputs()

static void test_encode_null_inputs ( void  )
static

Definition at line 156 of file dns_tests.c.

+ Here is the call graph for this function:

◆ test_encode_root_dot()

static void test_encode_root_dot ( void  )
static

Definition at line 82 of file dns_tests.c.

+ Here is the call graph for this function:

◆ test_encode_simple_label()

static void test_encode_simple_label ( void  )
static

Definition at line 93 of file dns_tests.c.

+ Here is the call graph for this function:

◆ test_encode_trailing_dot()

static void test_encode_trailing_dot ( void  )
static

Definition at line 125 of file dns_tests.c.

+ Here is the call graph for this function:

◆ test_encode_underscore_prefix()

static void test_encode_underscore_prefix ( void  )
static

Definition at line 140 of file dns_tests.c.

+ Here is the call graph for this function:

◆ test_encode_where_outside_buf()

static void test_encode_where_outside_buf ( void  )
static

Definition at line 247 of file dns_tests.c.

+ Here is the call graph for this function:

◆ test_labels_block_tracking()

static void test_labels_block_tracking ( void  )
static

Definition at line 674 of file dns_tests.c.

+ Here is the call graph for this function:

◆ test_pointer_invalid_with_mark_tracking()

static void test_pointer_invalid_with_mark_tracking ( void  )
static

Definition at line 707 of file dns_tests.c.

+ Here is the call graph for this function:

◆ test_pointer_to_zero_label_rejected()

static void test_pointer_to_zero_label_rejected ( void  )
static

Definition at line 728 of file dns_tests.c.

+ Here is the call graph for this function:

◆ test_pointer_valid_no_tracking()

static void test_pointer_valid_no_tracking ( void  )
static

Definition at line 690 of file dns_tests.c.

+ Here is the call graph for this function:

◆ test_roundtrip_case_preservation()

static void test_roundtrip_case_preservation ( void  )
static

Definition at line 597 of file dns_tests.c.

+ Here is the call graph for this function:

◆ test_roundtrip_compressed()

static void test_roundtrip_compressed ( void  )
static

Definition at line 775 of file dns_tests.c.

+ Here is the call graph for this function:

◆ test_roundtrip_root()

static void test_roundtrip_root ( void  )
static

Definition at line 556 of file dns_tests.c.

+ Here is the call graph for this function:

◆ test_roundtrip_simple()

static void test_roundtrip_simple ( void  )
static

Definition at line 511 of file dns_tests.c.

+ Here is the call graph for this function:

◆ test_roundtrip_trailing_dot()

static void test_roundtrip_trailing_dot ( void  )
static

Definition at line 535 of file dns_tests.c.

+ Here is the call graph for this function:

◆ test_roundtrip_underscore()

static void test_roundtrip_underscore ( void  )
static

Definition at line 577 of file dns_tests.c.

+ Here is the call graph for this function:

◆ test_verify_empty()

static void test_verify_empty ( void  )
static

Definition at line 495 of file dns_tests.c.

+ Here is the call graph for this function:

◆ test_verify_simple()

static void test_verify_simple ( void  )
static

Definition at line 482 of file dns_tests.c.

+ Here is the call graph for this function:

Variable Documentation

◆ test_blocks

fr_dns_block_t test_blocks[256]
static

Definition at line 34 of file dns_tests.c.

◆ TEST_LIST

TEST_LIST

Definition at line 993 of file dns_tests.c.

◆ test_marker

uint8_t test_marker[65536]
static

Definition at line 35 of file dns_tests.c.