Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Knot DNS
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
23
Issues
23
List
Boards
Labels
Milestones
Merge Requests
5
Merge Requests
5
Packages
Packages
Container Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Knot projects
Knot DNS
Commits
35a22580
Commit
35a22580
authored
Apr 12, 2013
by
Daniel Salzman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
consts: merge rcodes with tsig rcodes and reformat
Change-Id: I0a751268fb674e65ca5ccd141c037a9fab67f096
parent
8d64daa8
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
75 additions
and
65 deletions
+75
-65
src/knot/server/xfr-handler.c
src/knot/server/xfr-handler.c
+5
-5
src/knot/server/zones.c
src/knot/server/zones.c
+12
-12
src/libknot/consts.h
src/libknot/consts.h
+46
-42
src/libknot/nameserver/name-server.c
src/libknot/nameserver/name-server.c
+1
-1
src/libknot/tsig-op.c
src/libknot/tsig-op.c
+3
-3
src/libknot/tsig.c
src/libknot/tsig.c
+1
-1
src/utils/common/exec.c
src/utils/common/exec.c
+7
-1
No files found.
src/knot/server/xfr-handler.c
View file @
35a22580
...
...
@@ -838,7 +838,7 @@ static int xfr_check_tsig(knot_ns_xfr_t *xfr, knot_rcode_t *rcode, char **tag)
if
(
tsig_alg_digest_length
(
alg
)
==
0
)
{
*
rcode
=
KNOT_RCODE_NOTAUTH
;
xfr
->
tsig_key
=
NULL
;
xfr
->
tsig_rcode
=
KNOT_
TSIG_
RCODE_BADKEY
;
xfr
->
tsig_rcode
=
KNOT_RCODE_BADKEY
;
xfr
->
tsig_prev_time_signed
=
tsig_rdata_time_signed
(
tsig_rr
);
return
KNOT_TSIG_EBADKEY
;
...
...
@@ -858,7 +858,7 @@ static int xfr_check_tsig(knot_ns_xfr_t *xfr, knot_rcode_t *rcode, char **tag)
", treating as bad key
\n
"
);
*
rcode
=
KNOT_RCODE_NOTAUTH
;
ret
=
KNOT_TSIG_EBADKEY
;
xfr
->
tsig_rcode
=
KNOT_
TSIG_
RCODE_BADKEY
;
xfr
->
tsig_rcode
=
KNOT_RCODE_BADKEY
;
key
=
NULL
;
/* Invalidate, ret already set to BADKEY */
}
...
...
@@ -896,17 +896,17 @@ static int xfr_check_tsig(knot_ns_xfr_t *xfr, knot_rcode_t *rcode, char **tag)
*
rcode
=
KNOT_RCODE_NOERROR
;
break
;
case
KNOT_TSIG_EBADKEY
:
xfr
->
tsig_rcode
=
KNOT_
TSIG_
RCODE_BADKEY
;
xfr
->
tsig_rcode
=
KNOT_RCODE_BADKEY
;
xfr
->
tsig_key
=
NULL
;
*
rcode
=
KNOT_RCODE_NOTAUTH
;
break
;
case
KNOT_TSIG_EBADSIG
:
xfr
->
tsig_rcode
=
KNOT_
TSIG_
RCODE_BADSIG
;
xfr
->
tsig_rcode
=
KNOT_RCODE_BADSIG
;
xfr
->
tsig_key
=
NULL
;
*
rcode
=
KNOT_RCODE_NOTAUTH
;
break
;
case
KNOT_TSIG_EBADTIME
:
xfr
->
tsig_rcode
=
KNOT_
TSIG_
RCODE_BADTIME
;
xfr
->
tsig_rcode
=
KNOT_RCODE_BADTIME
;
// store the time signed from the query
assert
(
tsig_rr
!=
NULL
);
xfr
->
tsig_prev_time_signed
=
...
...
src/knot/server/zones.c
View file @
35a22580
...
...
@@ -1489,7 +1489,7 @@ static int zones_check_tsig_query(const knot_zone_t *zone,
// no key configured for zone, return BADKEY
dbg_zones_verb
(
"TSIG used, but not configured "
"for this zone, ret=BADKEY.
\n
"
);
*
tsig_rcode
=
KNOT_
TSIG_
RCODE_BADKEY
;
*
tsig_rcode
=
KNOT_RCODE_BADKEY
;
*
rcode
=
KNOT_RCODE_NOTAUTH
;
ret
=
KNOT_TSIG_EBADKEY
;
}
...
...
@@ -2121,7 +2121,7 @@ int zones_normal_query_answer(knot_nameserver_t *nameserver,
// treat as BADKEY error
/*! \todo Is this OK?? */
rcode
=
KNOT_RCODE_NOTAUTH
;
tsig_rcode
=
KNOT_
TSIG_
RCODE_BADKEY
;
tsig_rcode
=
KNOT_RCODE_BADKEY
;
ret
=
KNOT_TSIG_EBADKEY
;
}
else
{
dbg_zones_verb
(
"Checking TSIG in query.
\n
"
);
...
...
@@ -2231,7 +2231,7 @@ int zones_normal_query_answer(knot_nameserver_t *nameserver,
// then add the TSIG to the wire format
if
(
ret
==
KNOT_EOK
&&
tsig_rcode
!=
KNOT_
TSIG_
RCODE_BADTIME
)
{
tsig_rcode
!=
KNOT_RCODE_BADTIME
)
{
dbg_zones_verb
(
"Adding TSIG.
\n
"
);
ret
=
knot_tsig_add
(
resp_wire
,
&
answer_size
,
...
...
@@ -2242,7 +2242,7 @@ int zones_normal_query_answer(knot_nameserver_t *nameserver,
*
rsize
=
answer_size
;
}
else
if
(
tsig_rcode
==
KNOT_
TSIG_
RCODE_BADTIME
)
{
==
KNOT_RCODE_BADTIME
)
{
dbg_zones_verb
(
"Signing error resp.
\n
"
);
//*rsize = answer_size;
...
...
@@ -2332,11 +2332,11 @@ int zones_process_update(knot_nameserver_t *nameserver,
const
knot_zone_contents_t
*
contents
=
knot_zone_contents
(
zone
);
if
(
zone
&&
(
knot_zone_flags
(
zone
)
&
KNOT_ZONE_DISCARDED
))
{
rcode
=
KNOT_RCODE_SERVFAIL
;
/* It's ok, temporarily. */
tsig_rcode
=
KNOT_
TSIG_
RCODE_BADKEY
;
tsig_rcode
=
KNOT_RCODE_BADKEY
;
ret
=
KNOT_ENOZONE
;
}
else
if
(
!
zone
||
!
contents
)
{
/* Treat as BADKEY. */
rcode
=
KNOT_RCODE_NOTAUTH
;
tsig_rcode
=
KNOT_
TSIG_
RCODE_BADKEY
;
tsig_rcode
=
KNOT_RCODE_BADKEY
;
ret
=
KNOT_TSIG_EBADKEY
;
dbg_zones_verb
(
"No zone or empty, refusing UPDATE.
\n
"
);
}
...
...
@@ -2419,7 +2419,7 @@ int zones_process_update(knot_nameserver_t *nameserver,
}
/* Just add TSIG RR on most errors. */
if
(
tsig_rcode
!=
0
&&
tsig_rcode
!=
KNOT_
TSIG_
RCODE_BADTIME
)
{
if
(
tsig_rcode
!=
0
&&
tsig_rcode
!=
KNOT_RCODE_BADTIME
)
{
ret
=
knot_tsig_add
(
resp_wire
,
rsize
,
rsize_max
,
tsig_rcode
,
tsig_rr
);
dbg_zones_verb
(
"Adding TSIG = %s
\n
"
,
knot_strerror
(
ret
));
...
...
@@ -3307,7 +3307,7 @@ int zones_verify_tsig_query(const knot_packet_t *query,
* or some other error.
*/
*
rcode
=
KNOT_RCODE_NOTAUTH
;
*
tsig_rcode
=
KNOT_
TSIG_
RCODE_BADKEY
;
*
tsig_rcode
=
KNOT_RCODE_BADKEY
;
return
KNOT_TSIG_EBADKEY
;
}
...
...
@@ -3323,7 +3323,7 @@ int zones_verify_tsig_query(const knot_packet_t *query,
dbg_zones_verb
(
"Found claimed TSIG key for comparison
\n
"
);
}
else
{
*
rcode
=
KNOT_RCODE_NOTAUTH
;
*
tsig_rcode
=
KNOT_
TSIG_
RCODE_BADKEY
;
*
tsig_rcode
=
KNOT_RCODE_BADKEY
;
return
KNOT_TSIG_EBADKEY
;
}
...
...
@@ -3369,15 +3369,15 @@ int zones_verify_tsig_query(const knot_packet_t *query,
*
rcode
=
KNOT_RCODE_NOERROR
;
break
;
case
KNOT_TSIG_EBADKEY
:
*
tsig_rcode
=
KNOT_
TSIG_
RCODE_BADKEY
;
*
tsig_rcode
=
KNOT_RCODE_BADKEY
;
*
rcode
=
KNOT_RCODE_NOTAUTH
;
break
;
case
KNOT_TSIG_EBADSIG
:
*
tsig_rcode
=
KNOT_
TSIG_
RCODE_BADSIG
;
*
tsig_rcode
=
KNOT_RCODE_BADSIG
;
*
rcode
=
KNOT_RCODE_NOTAUTH
;
break
;
case
KNOT_TSIG_EBADTIME
:
*
tsig_rcode
=
KNOT_
TSIG_
RCODE_BADTIME
;
*
tsig_rcode
=
KNOT_RCODE_BADTIME
;
// store the time signed from the query
*
tsig_prev_time_signed
=
tsig_rdata_time_signed
(
tsig_rr
);
*
rcode
=
KNOT_RCODE_NOTAUTH
;
...
...
src/libknot/consts.h
View file @
35a22580
...
...
@@ -29,25 +29,60 @@
#include <stdint.h>
/*
*
OPCODEs
/*
!
*
\brief Basic limits for domain names (RFC 1035).
*/
typedef
enum
knot_opcode
{
KNOT_OPCODE_QUERY
=
0
,
/* a standard query (QUERY) */
KNOT_OPCODE_IQUERY
=
1
,
/* an inverse query (IQUERY) */
KNOT_OPCODE_STATUS
=
2
,
/* a server status request (STATUS) */
KNOT_OPCODE_NOTIFY
=
4
,
/* NOTIFY */
KNOT_OPCODE_UPDATE
=
5
,
/* Dynamic update */
KNOT_OPCODE_OFFSET
=
14
typedef
enum
{
KNOT_MAX_DNAME_LENGTH
=
255
,
/*!< 1-byte maximum. */
KNOT_MAX_DNAME_LABELS
=
127
/*!< 1-char labels. */
}
knot_const_t
;
/*!
* \brief DNS operation codes (OPCODEs).
*
* http://www.iana.org/assignments/dns-parameters/dns-parameters.xml
*/
typedef
enum
{
KNOT_OPCODE_QUERY
=
0
,
/*!< Standard query. */
KNOT_OPCODE_IQUERY
=
1
,
/*!< Inverse query. */
KNOT_OPCODE_STATUS
=
2
,
/*!< Server status request. */
KNOT_OPCODE_NOTIFY
=
4
,
/*!< Notify message. */
KNOT_OPCODE_UPDATE
=
5
/*!< Dynamic update. */
}
knot_opcode_t
;
/*!
* \brief Query types (internal use only).
* \brief DNS reply codes (RCODEs).
*
* http://www.iana.org/assignments/dns-parameters/dns-parameters.xml
*/
typedef
enum
{
KNOT_RCODE_NOERROR
=
0
,
/*!< No error. */
KNOT_RCODE_FORMERR
=
1
,
/*!< Format error. */
KNOT_RCODE_SERVFAIL
=
2
,
/*!< Server failure. */
KNOT_RCODE_NXDOMAIN
=
3
,
/*!< Non-existend domain. */
KNOT_RCODE_NOTIMPL
=
4
,
/*!< Not implemented. */
KNOT_RCODE_REFUSED
=
5
,
/*!< Refused. */
KNOT_RCODE_YXDOMAIN
=
6
,
/*!< Name should not exist. */
KNOT_RCODE_YXRRSET
=
7
,
/*!< RR set should not exist. */
KNOT_RCODE_NXRRSET
=
8
,
/*!< RR set does not exist. */
KNOT_RCODE_NOTAUTH
=
9
,
/*!< Server not authoritative. */
KNOT_RCODE_NOTZONE
=
10
,
/*!< Name is not inside zone. */
KNOT_RCODE_BADSIG
=
16
,
/*!< TSIG signature failed. */
KNOT_RCODE_BADKEY
=
17
,
/*!< Key is not supported. */
KNOT_RCODE_BADTIME
=
18
,
/*!< Signature out of time window. */
KNOT_RCODE_BADMODE
=
19
,
/*!< Bad TKEY mode. */
KNOT_RCODE_BADNAME
=
20
,
/*!< Duplicate key name. */
KNOT_RCODE_BADALG
=
21
,
/*!< Algorithm not supported. */
KNOT_RCODE_BADTRUNC
=
22
/*!< Bad truncation. */
}
knot_rcode_t
;
/*!
* \brief DNS query types (internal use only).
*
* This type encompasses the different query types distinguished by both the
* OPCODE and the QTYPE.
*/
typedef
enum
knot_packet_type
{
typedef
enum
{
KNOT_QUERY_INVALID
,
/*!< Invalid query. */
KNOT_QUERY_NORMAL
,
/*!< Normal query. */
KNOT_QUERY_AXFR
,
/*!< Request for AXFR transfer. */
...
...
@@ -61,37 +96,6 @@ typedef enum knot_packet_type {
KNOT_RESPONSE_UPDATE
/*!< Dynamic update response. */
}
knot_packet_type_t
;
/*
* RCODEs
*/
typedef
enum
knot_rcode
{
KNOT_RCODE_NOERROR
=
0
,
/* No error condition */
KNOT_RCODE_FORMERR
=
1
,
/* Format error */
KNOT_RCODE_SERVFAIL
=
2
,
/* Server failure */
KNOT_RCODE_NXDOMAIN
=
3
,
/* Name Error */
KNOT_RCODE_NOTIMPL
=
4
,
/* Not implemented */
KNOT_RCODE_REFUSED
=
5
,
/* Refused */
KNOT_RCODE_YXDOMAIN
=
6
,
/* name should not exist */
KNOT_RCODE_YXRRSET
=
7
,
/* rrset should not exist */
KNOT_RCODE_NXRRSET
=
8
,
/* rrset does not exist */
KNOT_RCODE_NOTAUTH
=
9
,
/* server not authoritative */
KNOT_RCODE_NOTZONE
=
10
,
/* name not inside zone */
}
knot_rcode_t
;
typedef
enum
knot_tsig_rcode
{
KNOT_TSIG_RCODE_BADSIG
=
16
,
KNOT_TSIG_RCODE_BADKEY
=
17
,
KNOT_TSIG_RCODE_BADTIME
=
18
}
knot_tsig_rcode_t
;
/*
* Other
*/
typedef
enum
knot_const
{
KNOT_MAX_DNAME_LENGTH
=
255
,
KNOT_MAX_DNAME_LABELS
=
127
// 1-char labels
}
knot_const_t
;
#endif
/* _KNOT_CONSTS_H_ */
/*! @} */
src/libknot/nameserver/name-server.c
View file @
35a22580
...
...
@@ -2491,7 +2491,7 @@ static int ns_xfr_send_and_clear(knot_ns_xfr_t *xfr, int add_tsig)
}
else
if
(
xfr
->
tsig_rcode
!=
0
)
{
dbg_ns_verb
(
"Adding TSIG without signing, TSIG RCODE: %d.
\n
"
,
xfr
->
tsig_rcode
);
assert
(
xfr
->
tsig_rcode
!=
KNOT_
TSIG_
RCODE_BADTIME
);
assert
(
xfr
->
tsig_rcode
!=
KNOT_RCODE_BADTIME
);
// add TSIG without signing
assert
(
xfr
->
query
!=
NULL
);
assert
(
knot_packet_additional_rrset_count
(
xfr
->
query
)
>
0
);
...
...
src/libknot/tsig-op.c
View file @
35a22580
...
...
@@ -470,13 +470,13 @@ int knot_tsig_sign(uint8_t *msg, size_t *msg_len,
/* Create rdata for TSIG RR. */
tsig_create_rdata
(
tmp_tsig
,
tsig_alg_digest_length
(
key
->
algorithm
),
(
tsig_rcode
==
KNOT_
TSIG_
RCODE_BADTIME
)
(
tsig_rcode
==
KNOT_RCODE_BADTIME
)
?
tsig_rcode
:
0
);
tsig_rdata_set_alg
(
tmp_tsig
,
key
->
algorithm
);
/* Distinguish BADTIME response. */
if
(
tsig_rcode
==
KNOT_
TSIG_
RCODE_BADTIME
)
{
if
(
tsig_rcode
==
KNOT_RCODE_BADTIME
)
{
/* Set client's time signed into the time signed field. */
tsig_rdata_set_time_signed
(
tmp_tsig
,
request_time_signed
);
...
...
@@ -863,7 +863,7 @@ int knot_tsig_add(uint8_t *msg, size_t *msg_len, size_t msg_max_len,
return
KNOT_ERROR
;
}
assert
(
tsig_rcode
!=
KNOT_
TSIG_
RCODE_BADTIME
);
assert
(
tsig_rcode
!=
KNOT_RCODE_BADTIME
);
tsig_create_rdata
(
tmp_tsig
,
0
,
tsig_rcode
);
/* No digest. */
tsig_rdata_set_alg_name
(
tmp_tsig
,
alg_name
);
...
...
src/libknot/tsig.c
View file @
35a22580
...
...
@@ -140,7 +140,7 @@ int tsig_create_rdata(knot_rrset_t *rr, uint16_t maclen, uint16_t tsig_err)
/* We already checked rr and know rdlen > 0, no need to check rets. */
size_t
rdlen
=
TSIG_FIXED_RDLEN
+
maclen
;
if
(
tsig_err
!=
KNOT_
TSIG_
RCODE_BADTIME
)
{
if
(
tsig_err
!=
KNOT_RCODE_BADTIME
)
{
rdlen
-=
TSIG_OTHER_MAXLEN
;
}
uint8_t
*
rd
=
knot_rrset_create_rdata
(
rr
,
rdlen
);
...
...
src/utils/common/exec.c
View file @
35a22580
...
...
@@ -33,7 +33,6 @@ knot_lookup_table_t opcodes[] = {
{
KNOT_OPCODE_STATUS
,
"STATUS"
},
{
KNOT_OPCODE_NOTIFY
,
"NOTIFY"
},
{
KNOT_OPCODE_UPDATE
,
"UPDATE"
},
{
KNOT_OPCODE_OFFSET
,
"OFFSET"
},
{
0
,
NULL
}
};
...
...
@@ -49,6 +48,13 @@ knot_lookup_table_t rcodes[] = {
{
KNOT_RCODE_NXRRSET
,
"NXRRSET"
},
{
KNOT_RCODE_NOTAUTH
,
"NOTAUTH"
},
{
KNOT_RCODE_NOTZONE
,
"NOTZONE"
},
{
KNOT_RCODE_BADSIG
,
"BADSIG"
},
{
KNOT_RCODE_BADKEY
,
"BADKEY"
},
{
KNOT_RCODE_BADTIME
,
"BADTIME"
},
{
KNOT_RCODE_BADMODE
,
"BADMODE"
},
{
KNOT_RCODE_BADNAME
,
"BADNAME"
},
{
KNOT_RCODE_BADALG
,
"BADALG"
},
{
KNOT_RCODE_BADTRUNC
,
"BADTRUNC"
},
{
0
,
NULL
}
};
...
...
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