Review Board 1.7.16


DNS: Add NAPTR support and tests

Review Request #4542 - Created March 27, 2015 and submitted

Mark Michelson
/team/group/dns/
Reviewers
asterisk-dev
Asterisk
This adds NAPTR support for DNS in Asterisk.

The main parts of this are the functions for allocating a DNS NAPTR record when a resolver wishes to add a NAPTR record, the sorting algorithm for sorting DNS NAPTR records, and the tests that use a mock DNS resolver.

NOTE: There is likely to be some overlap here in this review and Josh's SRV review (/r/4528). Our stance on this is that we will factor out the duplicated code once both SRV and NAPTR have been merged into the main DNS branch. The factoring out of common functions will be placed in its own review.
All previous DNS tests continue to pass, and all new tests added in this review pass as well.

Changes between revision 1 and 2

1 2 3
1 2 3

  1. /team/group/dns/tests/test_dns_naptr.c: Loading...
/team/group/dns/tests/test_dns_naptr.c
Diff Revision 1 Diff Revision 2
[20] 386 lines
[+20] [+] AST_TEST_DEFINE(naptr_resolve_nominal)
387
		{ 300,   6, {1, "3"}, {4, "BLAH"}, {0, ""}, "goose.down" },
387
		{ 300,   6, {1, "3"}, {4, "BLAH"}, {0, ""}, "goose.down" },
388
		{ 100,   2, {2, "32"}, {4, "BLAH"}, {0, ""}, "goose.down" },
388
		{ 100,   2, {2, "32"}, {4, "BLAH"}, {0, ""}, "goose.down" },
389
		{ 400, 100, {3, "A32"}, {4, "BLAH"}, {0, ""}, "goose.down" },
389
		{ 400, 100, {3, "A32"}, {4, "BLAH"}, {0, ""}, "goose.down" },
390
		/* Records with valid but unusual services */
390
		/* Records with valid but unusual services */
391
		{ 100, 700, {0, ""}, {0, ""}, {0, ""}, "goose.down" },
391
		{ 100, 700, {0, ""}, {0, ""}, {0, ""}, "goose.down" },
392
		//{ 500, 100, {1, "A"}, {42, "A+B12+C+D+EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE"}, {0, ""}, "goose.down" },
392
		{ 500, 102, {1, "A"}, {42, "A+B12+C+D+EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE"}, {0, ""}, "goose.down" },
393
		{ 500, 100, {1, "A"}, {14, "A+B12+C+D+EEEE"}, {0, ""}, "goose.down" },
393
		{ 500, 100, {1, "A"}, {14, "A+B12+C+D+EEEE"}, {0, ""}, "goose.down" },
394
		/* Records with valid regexes (regexes are always unusual) */
394
		/* Records with valid regexes (regexes are always unusual) */
395
		{ 500, 101, {1, "A"}, {4, "BLAH"}, {15, "!.*!horse.mane!"}, "" },
395
		{ 500, 101, {1, "A"}, {4, "BLAH"}, {15, "!.*!horse.mane!"}, "" },
396
		{ 500,  99, {1, "A"}, {4, "BLAH"}, {15, "0.*0horse.mane0"}, "" },
396
		{ 500,  99, {1, "A"}, {4, "BLAH"}, {15, "0.*0horse.mane0"}, "" },
397
		{  10, 100, {1, "A"}, {4, "BLAH"}, {11, "!.*!\\!\\!\\!!"}, "" },
397
		{  10, 100, {1, "A"}, {4, "BLAH"}, {11, "!.*!\\!\\!\\!!"}, "" },
398
		{ 700, 999, {1, "A"}, {4, "BLAH"}, {30, "!(.)(.)(.)(.)!\\1.m.\\2.n\\3.o\\4!"}, "" },
398
		{ 700, 999, {1, "A"}, {4, "BLAH"}, {30, "!(.)(.)(.)(.)!\\1.m.\\2.n\\3.o\\4!"}, "" },
399
	};
399
	};
400

    
   
400

   
401
	int naptr_record_order[] = { 9, 3, 5, 0, 2, 1, 4, 8, 6, 7, 10};
401
	int naptr_record_order[] = { 10, 3, 5, 0, 2, 1, 4, 9, 7, 8, 6, 11};
402
	enum ast_test_result_state res = AST_TEST_PASS;
402
	enum ast_test_result_state res = AST_TEST_PASS;
403
	int i;
403
	int i;
404

    
   
404

   
405
	switch (cmd) {
405
	switch (cmd) {
406
	case TEST_INIT:
406
	case TEST_INIT:
[+20] [20] 303 lines
  1. /team/group/dns/tests/test_dns_naptr.c: Loading...

https://reviewboard.asterisk.org/ runs on a server provided by Digium, Inc. and uses bandwidth donated to the open source Asterisk community by API Digital Communications in Huntsville, AL USA.
Please report problems with this site to asteriskteam@digium.com.