summaryrefslogtreecommitdiff
path: root/src/libknot/packet/response.c
diff options
context:
space:
mode:
authorOndřej Surý <ondrej@sury.org>2012-01-21 15:43:16 +0100
committerOndřej Surý <ondrej@sury.org>2012-01-21 15:43:16 +0100
commitf855fa7608da509ea1539f861ab7eb54305443c4 (patch)
treeebfbcb7b5fcfa4ac0c860e5dbb2c301bf2287c7a /src/libknot/packet/response.c
parent008d2859f102613c5a1d064c97e5dc7ea753faa2 (diff)
downloadknot-f855fa7608da509ea1539f861ab7eb54305443c4.tar.gz
Imported Upstream version 0.9.1upstream/0.9.1
Diffstat (limited to 'src/libknot/packet/response.c')
-rw-r--r--src/libknot/packet/response.c33
1 files changed, 27 insertions, 6 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;
}