Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ISC Open Source Projects
BIND
Commits
c7868e22
Commit
c7868e22
authored
May 24, 2000
by
Michael Sawyer
Browse files
Modify dns_message_totext, dns_message_sectiontotext,
dns_message_pseudosectiontotext to use bitfields instead of flags
parent
1d514700
Changes
4
Hide whitespace changes
Inline
Side-by-side
bin/tests/dispatch_tcp_test.c
View file @
c7868e22
...
...
@@ -60,8 +60,7 @@ printmsg(dns_message_t *msg, FILE *out) {
int
result
;
isc_buffer_init
(
&
textbuf
,
text
,
sizeof
text
);
result
=
dns_message_totext
(
msg
,
ISC_TRUE
,
ISC_TRUE
,
ISC_FALSE
,
&
textbuf
);
result
=
dns_message_totext
(
msg
,
0
,
&
textbuf
);
if
(
result
!=
ISC_R_SUCCESS
)
return
(
result
);
...
...
bin/tests/dispatch_test.c
View file @
c7868e22
...
...
@@ -67,8 +67,7 @@ printmsg(dns_message_t *msg, FILE *out) {
int
result
;
isc_buffer_init
(
&
textbuf
,
text
,
sizeof
text
);
result
=
dns_message_totext
(
msg
,
ISC_TRUE
,
ISC_TRUE
,
ISC_FALSE
,
&
textbuf
);
result
=
dns_message_totext
(
msg
,
0
,
&
textbuf
);
if
(
result
!=
ISC_R_SUCCESS
)
return
(
result
);
...
...
lib/dns/include/dns/message.h
View file @
c7868e22
...
...
@@ -122,6 +122,10 @@ typedef int dns_pseudosection_t;
#define DNS_PSEUDOSECTION_SIG0 2
#define DNS_PSEUDOSECTION_MAX 3
typedef
int
dns_messagetextflag_t
;
#define DNS_MESSAGETEXTFLAG_NOCOMMENTS 0x0001
#define DNS_MESSAGETEXTFLAG_NOHEADERS 0x0002
#define DNS_MESSAGETEXTFLAG_OMITDOT 0x0004
/*
* Dynamic update names for these sections.
...
...
@@ -275,26 +279,20 @@ dns_message_destroy(dns_message_t **msgp);
isc_result_t
dns_message_sectiontotext
(
dns_message_t
*
msg
,
dns_section_t
section
,
isc_boolean_t
comments
,
isc_boolean_t
omit_final_dot
,
dns_messagetextflag_t
flags
,
isc_buffer_t
*
target
);
isc_result_t
dns_message_pseudosectiontotext
(
dns_message_t
*
msg
,
dns_pseudosection_t
section
,
isc_boolean_t
comments
,
isc_boolean_t
omit_final_dot
,
dns_messagetextflag_t
flags
,
isc_buffer_t
*
target
);
/*
* Convert section 'section' or 'pseudosection' of message 'msg' to
* a cleartext representation
*
* Notes:
* If 'omit_final_dot' is true, then the final '.' in absolute names
* will not be emitted.
* If 'no_rdata_or_tt;' is true, omit rdata and ttl fields.
* If 'comments' is true, lines beginning with ";;" will be emitted
* indicating section name.
* See dns_message_totext for meanings of flags.
*
* Requires:
*
...
...
@@ -322,18 +320,18 @@ dns_message_pseudosectiontotext(dns_message_t *msg,
*/
isc_result_t
dns_message_totext
(
dns_message_t
*
msg
,
isc_boolean_t
comments
,
isc_boolean_t
headers
,
isc_boolean_t
omit_final_dot
,
dns_message_totext
(
dns_message_t
*
msg
,
dns_messagetextflag_t
flags
,
isc_buffer_t
*
target
);
/*
* Convert all sections of message 'msg' to a cleartext representation
*
* Notes:
* If 'omit_final_dot' is true, then the final '.' in absolute names
* will not be emitted.
* If 'no_rdata_or_tt;' is true, omit rdata and ttl fields.
* If 'comments' is true, lines beginning with ";;" will be emitted
* indicating section name.
* In flags, If DNS_MESSAGETEXTFLAG_OMITDOT is set, then the *
* final '.' in absolute names will not be emitted. If
* DNS_MESSAGETEXTFLAG_NOCOMMENTS is cleared, * lines * beginning
* with ";;" will be emitted indicating section name. If
* DNS_MESSAGETEXTFLAG_NOHEADERS is cleared, header lines will
* be emmitted.
*
* Requires:
*
...
...
@@ -355,8 +353,7 @@ dns_message_totext(dns_message_t *msg, isc_boolean_t comments,
* ISC_R_NOSPACE
* ISC_R_NOMORE
*
* Note: On error return, *target may be partially filled with data.
*/
* Note: On error return, *target may be partially filled with data. */
isc_result_t
dns_message_parse
(
dns_message_t
*
msg
,
isc_buffer_t
*
source
,
...
...
lib/dns/message.c
View file @
c7868e22
...
...
@@ -2418,22 +2418,20 @@ dns_message_checksig(dns_message_t *msg, dns_view_t *view) {
isc_result_t
dns_message_sectiontotext
(
dns_message_t
*
msg
,
dns_section_t
section
,
isc_boolean_t
comments
,
isc_boolean_t
omit_final_dot
,
dns_messagetextflag_t
flags
,
isc_buffer_t
*
target
)
{
dns_name_t
*
name
,
empty_name
;
dns_rdataset_t
*
rdataset
;
isc_result_t
result
;
isc_boolean_t
no_rdata
;
isc_boolean_t
omit_final_dot
;
REQUIRE
(
DNS_MESSAGE_VALID
(
msg
));
REQUIRE
(
target
!=
NULL
);
REQUIRE
(
VALID_SECTION
(
section
));
/*
* If the section is empty, that's still success, but we don't
* actually do anything.
*/
omit_final_dot
=
ISC_TF
((
flags
&
DNS_MESSAGETEXTFLAG_OMITDOT
)
!=
0
);
if
(
ISC_LIST_EMPTY
(
msg
->
sections
[
section
]))
return
ISC_R_SUCCESS
;
...
...
@@ -2442,7 +2440,7 @@ dns_message_sectiontotext(dns_message_t *msg, dns_section_t section,
else
no_rdata
=
ISC_FALSE
;
if
(
comments
)
{
if
(
(
flags
&
DNS_MESSAGETEXTFLAG_NOCOMMENTS
)
==
0
)
{
ADD_STRING
(
target
,
";; "
);
ADD_STRING
(
target
,
sectiontext
[
section
]);
ADD_STRING
(
target
,
" SECTION:
\n
"
);
...
...
@@ -2479,28 +2477,26 @@ dns_message_sectiontotext(dns_message_t *msg, dns_section_t section,
isc_result_t
dns_message_pseudosectiontotext
(
dns_message_t
*
msg
,
dns_pseudosection_t
section
,
isc_boolean_t
comments
,
isc_boolean_t
omit_final_dot
,
dns_messagetextflag_t
flags
,
isc_buffer_t
*
target
)
{
dns_rdataset_t
*
ps
=
NULL
;
dns_name_t
*
name
=
NULL
;
isc_result_t
result
;
char
buf
[
sizeof
(
"1234567890"
)];
isc_boolean_t
omit_final_dot
;
REQUIRE
(
DNS_MESSAGE_VALID
(
msg
));
REQUIRE
(
target
!=
NULL
);
REQUIRE
(
VALID_PSEUDOSECTION
(
section
));
/*
* If the section is empty, that's still success, but we don't
* actually do anything.
*/
omit_final_dot
=
ISC_TF
((
flags
&
DNS_MESSAGETEXTFLAG_OMITDOT
)
!=
0
);
switch
(
section
)
{
case
DNS_PSEUDOSECTION_OPT
:
ps
=
dns_message_getopt
(
msg
);
if
(
ps
==
NULL
)
return
(
ISC_R_SUCCESS
);
if
(
comments
)
if
(
(
flags
&
DNS_MESSAGETEXTFLAG_NOCOMMENTS
)
==
0
)
ADD_STRING
(
target
,
";; OPT PSEUDOSECTION:
\n
"
);
ADD_STRING
(
target
,
"; EDNS: version: "
);
sprintf
(
buf
,
"%4u"
,
...
...
@@ -2516,7 +2512,7 @@ dns_message_pseudosectiontotext(dns_message_t *msg,
ps
=
dns_message_gettsig
(
msg
,
&
name
);
if
(
ps
==
NULL
)
return
(
ISC_R_SUCCESS
);
if
(
comments
)
if
(
(
flags
&
DNS_MESSAGETEXTFLAG_NOCOMMENTS
)
==
0
)
ADD_STRING
(
target
,
";; TSIG PSEUDOSECTION:
\n
"
);
result
=
dns_rdataset_totext
(
ps
,
name
,
omit_final_dot
,
ISC_FALSE
,
target
);
...
...
@@ -2526,7 +2522,7 @@ dns_message_pseudosectiontotext(dns_message_t *msg,
ps
=
dns_message_getsig0
(
msg
,
&
name
);
if
(
ps
==
NULL
)
return
(
ISC_R_SUCCESS
);
if
(
comments
)
if
(
(
flags
&
DNS_MESSAGETEXTFLAG_NOCOMMENTS
)
==
0
)
ADD_STRING
(
target
,
";; SIG0 PSEUDOSECTION:
\n
"
);
result
=
dns_rdataset_totext
(
ps
,
name
,
omit_final_dot
,
ISC_FALSE
,
target
);
...
...
@@ -2537,8 +2533,7 @@ dns_message_pseudosectiontotext(dns_message_t *msg,
}
isc_result_t
dns_message_totext
(
dns_message_t
*
msg
,
isc_boolean_t
comments
,
isc_boolean_t
headers
,
isc_boolean_t
omit_final_dot
,
dns_message_totext
(
dns_message_t
*
msg
,
dns_messagetextflag_t
flags
,
isc_buffer_t
*
target
)
{
char
buf
[
sizeof
"1234567890"
];
isc_result_t
result
;
...
...
@@ -2546,7 +2541,7 @@ dns_message_totext(dns_message_t *msg, isc_boolean_t comments,
REQUIRE
(
DNS_MESSAGE_VALID
(
msg
));
REQUIRE
(
target
!=
NULL
);
if
(
headers
)
{
if
(
(
flags
&
DNS_MESSAGETEXTFLAG_NOHEADERS
)
==
0
)
{
ADD_STRING
(
target
,
";; ->>HEADER<<- opcode: "
);
ADD_STRING
(
target
,
opcodetext
[
msg
->
opcode
]);
ADD_STRING
(
target
,
", status: "
);
...
...
@@ -2585,47 +2580,36 @@ dns_message_totext(dns_message_t *msg, isc_boolean_t comments,
}
result
=
dns_message_pseudosectiontotext
(
msg
,
DNS_PSEUDOSECTION_OPT
,
comments
,
omit_final_dot
,
target
);
flags
,
target
);
if
(
result
!=
ISC_R_SUCCESS
)
return
(
result
);
result
=
dns_message_sectiontotext
(
msg
,
DNS_SECTION_QUESTION
,
comments
,
omit_final_dot
,
target
);
flags
,
target
);
if
(
result
!=
ISC_R_SUCCESS
)
return
(
result
);
result
=
dns_message_sectiontotext
(
msg
,
DNS_SECTION_ANSWER
,
comments
,
omit_final_dot
,
target
);
flags
,
target
);
if
(
result
!=
ISC_R_SUCCESS
)
return
(
result
);
result
=
dns_message_sectiontotext
(
msg
,
DNS_SECTION_AUTHORITY
,
comments
,
omit_final_dot
,
target
);
flags
,
target
);
if
(
result
!=
ISC_R_SUCCESS
)
return
(
result
);
result
=
dns_message_sectiontotext
(
msg
,
DNS_SECTION_ADDITIONAL
,
comments
,
omit_final_dot
,
target
);
flags
,
target
);
if
(
result
!=
ISC_R_SUCCESS
)
return
(
result
);
result
=
dns_message_pseudosectiontotext
(
msg
,
DNS_PSEUDOSECTION_TSIG
,
comments
,
omit_final_dot
,
target
);
flags
,
target
);
if
(
result
!=
ISC_R_SUCCESS
)
return
(
result
);
result
=
dns_message_pseudosectiontotext
(
msg
,
DNS_PSEUDOSECTION_SIG0
,
comments
,
omit_final_dot
,
target
);
flags
,
target
);
if
(
result
!=
ISC_R_SUCCESS
)
return
(
result
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment