return ret;
}
+string PacketReader::getUnquotedText(bool lenField)
+{
+ int16_t stop_at;
+ if(lenField)
+ stop_at = (uint8_t)d_content.at(d_pos) + d_pos + 1;
+ else
+ stop_at = d_recordlen;
+
+ if(stop_at == d_pos)
+ return "";
+
+ d_pos++;
+ string ret(&d_content.at(d_pos), &d_content.at(stop_at));
+ d_pos = stop_at;
+ return ret;
+}
void PacketReader::xfrBlob(string& blob)
try
text=getText(multi, lenField);
}
+ void xfrUnquotedText(string &text, bool lenField){
+ text=getUnquotedText(lenField);
+ }
+
void xfrBlob(string& blob);
void xfrBlobNoSpaces(string& blob, int len);
void xfrBlob(string& blob, int length);
DNSName getName();
string getText(bool multi, bool lenField);
+ string getUnquotedText(bool lenField);
uint16_t d_pos;
}
}
+void DNSPacketWriter::xfrUnquotedText(const string& text, bool lenField)
+{
+ if(text.empty()) {
+ d_record.push_back(0);
+ return;
+ }
+ if(lenField)
+ d_record.push_back(text.length());
+ d_record.insert(d_record.end(), text.c_str(), text.c_str() + text.length());
+}
+
/* FIXME400: check that this beats a map */
DNSPacketWriter::lmap_t::iterator find(DNSPacketWriter::lmap_t& nmap, const DNSName& name)
{
void xfrName(const DNSName& label, bool compress=false, bool noDot=false);
void xfrText(const string& text, bool multi=false, bool lenField=true);
+ void xfrUnquotedText(const string& text, bool lenField);
void xfrBlob(const string& blob, int len=-1);
void xfrBlobNoSpaces(const string& blob, int len=-1);
void xfrHexBlob(const string& blob, bool keepReading=false);
}
}
+void RecordTextReader::xfrUnquotedText(string& val, bool lenField)
+{
+ val.clear();
+ val.reserve(d_end - d_pos);
+
+ if(!val.empty())
+ val.append(1, ' ');
+
+ skipSpaces();
+ val.append(1, d_string[d_pos]);
+ while(++d_pos < d_end && d_string[d_pos] != ' '){
+ val.append(1, d_string[d_pos]);
+ }
+}
+
void RecordTextReader::xfrType(uint16_t& val)
{
skipSpaces();
d_string.append(val);
}
+void RecordTextWriter::xfrUnquotedText(const string& val, bool lenField)
+{
+ if(!d_string.empty())
+ d_string.append(1,' ');
+ d_string.append(val);
+}
#ifdef TESTING
void xfrName(DNSName& val, bool compress=false, bool noDot=false);
void xfrText(string& val, bool multi=false, bool lenField=true);
+ void xfrUnquotedText(string& val, bool lenField=true);
void xfrHexBlob(string& val, bool keepReading=false);
void xfrBase32HexBlob(string& val);
void xfrType(const uint16_t& val);
void xfrName(const DNSName& val, bool compress=false, bool noDot=false);
void xfrText(const string& val, bool multi=false, bool lenField=true);
+ void xfrUnquotedText(const string& val, bool lenField=true);
void xfrBlobNoSpaces(const string& val, int len=-1);
void xfrBlob(const string& val, int len=-1);
void xfrHexBlob(const string& val, bool keepReading=false);