summaryrefslogtreecommitdiff
path: root/src/libknot/packet
diff options
context:
space:
mode:
Diffstat (limited to 'src/libknot/packet')
-rw-r--r--src/libknot/packet/response.c33
-rw-r--r--src/libknot/packet/response.h15
2 files changed, 36 insertions, 12 deletions
diff --git a/src/libknot/packet/response.c b/src/libknot/packet/response.c
index e6f89d0..ed16e2f 100644
--- a/src/libknot/packet/response.c
+++ b/src/libknot/packet/response.c
@@ -987,8 +987,9 @@ int knot_response_add_opt(knot_packet_t *resp,
/*----------------------------------------------------------------------------*/
int knot_response_add_rrset_answer(knot_packet_t *response,
- const knot_rrset_t *rrset, int tc,
- int check_duplicates, int compr_cs)
+ knot_rrset_t *rrset, int tc,
+ int check_duplicates, int compr_cs,
+ int rotate)
{
if (response == NULL || rrset == NULL) {
return KNOT_EBADARG;
@@ -1024,6 +1025,12 @@ int knot_response_add_rrset_answer(knot_packet_t *response,
if (rrs >= 0) {
response->header.ancount += rrs;
+
+ if (rotate) {
+ // do round-robin rotation of the RRSet
+ knot_rrset_rotate(rrset);
+ }
+
return KNOT_EOK;
}
@@ -1033,8 +1040,9 @@ int knot_response_add_rrset_answer(knot_packet_t *response,
/*----------------------------------------------------------------------------*/
int knot_response_add_rrset_authority(knot_packet_t *response,
- const knot_rrset_t *rrset, int tc,
- int check_duplicates, int compr_cs)
+ knot_rrset_t *rrset, int tc,
+ int check_duplicates, int compr_cs,
+ int rotate)
{
if (response == NULL || rrset == NULL) {
return KNOT_EBADARG;
@@ -1066,6 +1074,12 @@ int knot_response_add_rrset_authority(knot_packet_t *response,
if (rrs >= 0) {
response->header.nscount += rrs;
+
+ if (rotate) {
+ // do round-robin rotation of the RRSet
+ knot_rrset_rotate(rrset);
+ }
+
return KNOT_EOK;
}
@@ -1075,8 +1089,9 @@ int knot_response_add_rrset_authority(knot_packet_t *response,
/*----------------------------------------------------------------------------*/
int knot_response_add_rrset_additional(knot_packet_t *response,
- const knot_rrset_t *rrset, int tc,
- int check_duplicates, int compr_cs)
+ knot_rrset_t *rrset, int tc,
+ int check_duplicates, int compr_cs,
+ int rotate)
{
if (response == NULL || rrset == NULL) {
return KNOT_EBADARG;
@@ -1114,6 +1129,12 @@ int knot_response_add_rrset_additional(knot_packet_t *response,
if (rrs >= 0) {
response->header.arcount += rrs;
+
+ if (rotate) {
+ // do round-robin rotation of the RRSet
+ knot_rrset_rotate(rrset);
+ }
+
return KNOT_EOK;
}
diff --git a/src/libknot/packet/response.h b/src/libknot/packet/response.h
index 38bd9a8..d76c10c 100644
--- a/src/libknot/packet/response.h
+++ b/src/libknot/packet/response.h
@@ -115,8 +115,9 @@ int knot_response_add_opt(knot_packet_t *resp,
* \retval KNOT_ESPACE
*/
int knot_response_add_rrset_answer(knot_packet_t *response,
- const knot_rrset_t *rrset, int tc,
- int check_duplicates, int compr_cs);
+ knot_rrset_t *rrset, int tc,
+ int check_duplicates, int compr_cs,
+ int rotate);
/*!
* \brief Adds a RRSet to the Authority section of the response.
@@ -135,8 +136,9 @@ int knot_response_add_rrset_answer(knot_packet_t *response,
* \retval KNOT_ESPACE
*/
int knot_response_add_rrset_authority(knot_packet_t *response,
- const knot_rrset_t *rrset, int tc,
- int check_duplicates, int compr_cs);
+ knot_rrset_t *rrset, int tc,
+ int check_duplicates, int compr_cs,
+ int rotate);
/*!
* \brief Adds a RRSet to the Additional section of the response.
@@ -155,8 +157,9 @@ int knot_response_add_rrset_authority(knot_packet_t *response,
* \retval KNOT_ESPACE
*/
int knot_response_add_rrset_additional(knot_packet_t *response,
- const knot_rrset_t *rrset, int tc,
- int check_duplicates, int compr_cs);
+ knot_rrset_t *rrset, int tc,
+ int check_duplicates, int compr_cs,
+ int rotate);
/*!
* \brief Sets the RCODE of the response.