1: 
   2: 
   3: /**********************
   4: *                     *
   5: *  COMPILER INCLUDES  *
   6: *                     *
   7: **********************/
   8: 
   9: 
  10: #include <cassert> 
  11: 
  12: 
  13: /*********************
  14: *                    *
  15: *  PROJECT INCLUDES  *
  16: *                    *
  17: *********************/
  18: 
  19: 
  20: #include "dnsutil.h" 
  21: #include "response.h" 
  22: 
  23: 
  24: /*************************
  25: *                        *
  26: *  RESPONSE CONSTRUCTOR  *
  27: *                        *
  28: *************************/
  29: 
  30: 
  31: Response::Response(bool i_bAA, bool i_bTC, RCode i_cd, RRListPtr &i_rlprAN, RRListPtr &i_rlprNS, RRListPtr &i_rlprAR) {
  32:   m_bAA = i_bAA;
  33:   m_bTC = i_bTC;
  34:   m_cd = i_cd;
  35:   m_rlpAN = i_rlprAN;
  36:   m_rlpNS = i_rlprNS;
  37:   m_rlpAR = i_rlprAR; 
  38:   i_rlprAN = NULL;
  39:   i_rlprNS = NULL;
  40:   i_rlprAR = NULL;
  41: }
  42: 
  43: 
  44: Response::Response(RCode i_cd) {
  45:   m_bAA = true;
  46:   m_bTC = false;
  47:   m_cd = i_cd;
  48:   m_rlpAN = NULL;
  49:   m_rlpNS = NULL;
  50:   m_rlpAR = NULL;
  51: }
  52: 
  53: 
  54: /************************
  55: *                       *
  56: *  RESPONSE DESTRUCTOR  *
  57: *                       *
  58: ************************/
  59: 
  60: 
  61: Response::~Response() {
  62:   SoftDelete(m_rlpAN);
  63:   SoftDelete(m_rlpNS);
  64:   SoftDelete(m_rlpAR);
  65: }
  66: 
  67: 
  68: /****************
  69: *               *
  70: *  OPERATOR <<  *
  71: *               *
  72: ****************/
  73: 
  74: 
  75: ostream& operator<<(ostream& io_smr, const Response &i_rsr) {
  76:   if (&i_rsr==NULL) {
  77:     io_smr << "[NULL RESPONSE]" << endl;
  78:     return io_smr;
  79:   }
  80:   if (i_rsr.GetAA()==true) io_smr << "AA ";
  81:   if (i_rsr.GetTC()==true) io_smr << "TC ";
  82:   io_smr << GetRCodeName(i_rsr.GetRCode()) << " ";
  83:   io_smr << endl << "AN Records:" << endl;
  84:   io_smr << *i_rsr.GetANList();
  85:   io_smr << "NS Records:" << endl;
  86:   io_smr << *i_rsr.GetNSList();
  87:   io_smr << "AR Records:" << endl;
  88:   io_smr << *i_rsr.GetARList();
  89:   io_smr << endl;
  90:   return io_smr;
  91: }
  92: 
  93: 
  94: ostream& operator<<(ostream& io_smr, ResponseConstPtr i_rsp) {
  95:   io_smr << *i_rsp;
  96:   return io_smr;
  97: }
  98: 
  99: 
 100: