-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathquery.cpp
More file actions
29 lines (25 loc) · 700 Bytes
/
query.cpp
File metadata and controls
29 lines (25 loc) · 700 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
//
// query.cpp
// TSDNSServer
//
// Created by zhaoxy on 14-5-11.
// Copyright (c) 2014年 tsinghua. All rights reserved.
//
#include "query.h"
#include <sstream>
using namespace dns;
void Query::decode(const char *buff, const int size) {
if (sizeof(MHeader) > size) return;
decode_header(buff);
decode_questions(buff);
}
//convert query to string
std::string Query::to_string() {
std::stringstream stream;
stream<<"Query:"<<std::endl;
for (std::vector<MQuestion>::iterator iter=m_questions.begin(); iter!=m_questions.end(); iter++) {
MQuestion question = *iter;
stream<<question.qName<<" "<<question.qType<<std::endl;
}
return stream.str();
}