}
// exceptions thrown here do not result in logging in the main pdns auth server - just so you know!
-string PacketReader::getText(bool multi)
+string PacketReader::getText(bool multi, bool lenField)
{
string ret;
ret.reserve(40);
if(!ret.empty()) {
ret.append(1,' ');
}
- unsigned char labellen=d_content.at(d_pos++);
+ uint16_t labellen;
+ if(lenField)
+ labellen=d_content.at(d_pos++);
+ else
+ labellen=d_recordlen - (d_pos - d_startrecordpos);
ret.append(1,'"');
if(labellen) { // no need to do anything for an empty string
name=getName();
}
- void xfrText(string &text, bool multi=false)
+ void xfrText(string &text, bool multi=false, bool lenField=true)
{
- text=getText(multi);
+ text=getText(multi, lenField);
}
void xfrBlob(string& blob);
void copyRecord(unsigned char* dest, uint16_t len);
DNSName getName();
- string getText(bool multi);
+ string getText(bool multi, bool lenField);
uint16_t d_pos;
/* input:
+ if lenField is true
"" -> 0
"blah" -> 4blah
"blah" "blah" -> output 4blah4blah
"verylongstringlongerthan256....characters" \xffverylongstring\x23characters (autosplit)
"blah\"blah" -> 9blah"blah
"blah\97" -> 5blahb
+
+ if lenField is false
+ "blah" -> blah
+ "blah\"blah" -> blah"blah
*/
-void DNSPacketWriter::xfrText(const string& text, bool)
+void DNSPacketWriter::xfrText(const string& text, bool, bool lenField)
{
if(text.empty()) {
d_record.push_back(0);
}
vector<string> segments = segmentDNSText(text);
for(const string& str : segments) {
- d_record.push_back(str.length());
+ if(lenField)
+ d_record.push_back(str.length());
d_record.insert(d_record.end(), str.c_str(), str.c_str() + str.length());
}
}
void xfr8BitInt(uint8_t val);
void xfrName(const DNSName& label, bool compress=false, bool noDot=false);
- void xfrText(const string& text, bool multi=false);
+ void xfrText(const string& text, bool multi=false, bool lenField=true);
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::xfrText(string& val, bool multi)
+void RecordTextReader::xfrText(string& val, bool multi, bool lenField)
{
val.clear();
val.reserve(d_end - d_pos);
}
}
-void RecordTextWriter::xfrText(const string& val, bool multi)
+void RecordTextWriter::xfrText(const string& val, bool multi, bool lenField)
{
if(!d_string.empty())
d_string.append(1,' ');
void xfrTime(uint32_t& val);
void xfrName(DNSName& val, bool compress=false, bool noDot=false);
- void xfrText(string& val, bool multi=false);
+ void xfrText(string& val, bool multi=false, 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);
+ void xfrText(const string& val, bool multi=false, 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);