summaryrefslogtreecommitdiffstats
path: root/src/c-ares/test/dns-dump.cc
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 18:45:59 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 18:45:59 +0000
commit19fcec84d8d7d21e796c7624e521b60d28ee21ed (patch)
tree42d26aa27d1e3f7c0b8bd3fd14e7d7082f5008dc /src/c-ares/test/dns-dump.cc
parentInitial commit. (diff)
downloadceph-19fcec84d8d7d21e796c7624e521b60d28ee21ed.tar.xz
ceph-19fcec84d8d7d21e796c7624e521b60d28ee21ed.zip
Adding upstream version 16.2.11+ds.upstream/16.2.11+dsupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/c-ares/test/dns-dump.cc')
-rw-r--r--src/c-ares/test/dns-dump.cc35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/c-ares/test/dns-dump.cc b/src/c-ares/test/dns-dump.cc
new file mode 100644
index 000000000..023de3697
--- /dev/null
+++ b/src/c-ares/test/dns-dump.cc
@@ -0,0 +1,35 @@
+#include <sys/types.h>
+#include <fcntl.h>
+#include <unistd.h>
+
+#include <iostream>
+#include <vector>
+
+#include "dns-proto.h"
+
+namespace ares {
+
+static void ShowFile(const char* filename) {
+ int fd = open(filename, O_RDONLY);
+ if (fd < 0) {
+ std::cerr << "Failed to open '" << filename << "'" << std::endl;
+ return;
+ }
+ std::vector<unsigned char> contents;
+ while (true) {
+ unsigned char buffer[1024];
+ int len = read(fd, buffer, sizeof(buffer));
+ if (len <= 0) break;
+ contents.insert(contents.end(), buffer, buffer + len);
+ }
+ std::cout << PacketToString(contents) << std::endl;
+}
+
+} // namespace ares
+
+int main(int argc, char* argv[]) {
+ for (int ii = 1; ii < argc; ++ii) {
+ ares::ShowFile(argv[ii]);
+ }
+}
+