1: 2: 3: /********************* 4: * * 5: * PROJECT INCLUDES * 6: * * 7: *********************/ 8: 9: 10: #include "format.h" 11: #include "rdata_a.h" 12: 13: 14: using WWWI::IPDump; 15: 16: 17: /***************** 18: * * 19: * METHOD CLONE * 20: * * 21: *****************/ 22: 23: 24: RDataPtr RDataA::Clone() const { 25: RDataA *rdpOut = new RDataA; 26: rdpOut->m_ip = m_ip; 27: return (RDataPtr)rdpOut; 28: } 29: 30: 31: /******************* 32: * * 33: * METHOD COMPARE * 34: * * 35: *******************/ 36: 37: 38: bool RDataA::Compare(const RData &ci_rdr) const { 39: return (ci_rdr.As<RDataA>()->GetRDAddress()==m_ip); 40: } 41: 42: 43: /**************** 44: * * 45: * METHOD DUMP * 46: * * 47: ****************/ 48: 49: 50: void RDataA::Dump(ostream &io_smr) const { 51: IPDump(io_smr,m_ip); 52: } 53: 54: 55: /************************ 56: * * 57: * METHOD GETRDADDRESS * 58: * * 59: ************************/ 60: 61: 62: IPAddress RDataA::GetRDAddress() const { return m_ip; } 63: 64: 65: /******************* 66: * * 67: * METHOD ISMATCH * 68: * * 69: *******************/ 70: 71: 72: bool RDataA::IsMatch(RRType i_ty, RRClass i_cl) { 73: if (i_cl!=CL_IN) return false; 74: if (i_ty==TY_A) return true; 75: return false; 76: } 77: 78: 79: /********************* 80: * * 81: * METHOD READRDATA * 82: * * 83: *********************/ 84: 85: 86: void RDataA::ReadRData(BufferConstPtr ci_dpp) { 87: unsigned short us; 88: 89: ci_dpp->ReadNBO(us); 90: if (us!=sizeof(IPAddress)) 91: throw BadParseEx(FOUT("length of A was not ",sizeof(IPAddress))); 92: ci_dpp->Read(m_ip); 93: } 94: 95: 96: /******************** 97: * * 98: * METHOD SETRDATA * 99: * * 100: ********************/ 101: 102: 103: void RDataA::SetRData(const char *ci_strRData) { 104: m_ip = inet_addr(ci_strRData); 105: if (m_ip==(IPAddress)-1) 106: throw BadParseEx(FOUT("RDataA::SetRData: not an IP address: ",ci_strRData)); 107: } 108: 109: 110: /********************** 111: * * 112: * METHOD WRITERDATA * 113: * * 114: **********************/ 115: 116: 117: void RDataA::WriteRData(BufferPtr io_dpp) const { 118: unsigned short us; 119: 120: us = sizeof(IPAddress); 121: io_dpp->WriteNBO(us); 122: io_dpp->Write(m_ip); 123: } 124: 125: 126: /********************** 127: * * 128: * RDATAA DESTRUCTOR * 129: * * 130: **********************/ 131: 132: 133: RDataA::~RDataA() { m_ip = 0; } 134: 135: 136: