1 #include "newpacket.hpp"
5 bool brief_mode
= false;
7 void handle_packet(packet
* p
)
9 std::cout
<< "Packet: channel " << p
->rp_channel
<< "<perm#" << p
->rp_channel_perm
<< ">[";
10 for(size_t i
= 0; i
< p
->rp_channel_name
.length(); i
++) {
11 unsigned char ch
= p
->rp_channel_name
[i
];
12 if(ch
< 32 || ch
> 126)
13 std::cout
<< "\\x" << std::setfill('0') << std::setw(2) << std::hex
<< (uint16_t)ch
;
14 else if(ch
== '[' || ch
== ']' || ch
== '\\')
15 std::cout
<< "\\" << ch
;
19 std::cout
<< "] at " << std::dec
<< p
->rp_timestamp
<< ", type " << p
->rp_major
<< "("
20 << (uint16_t)p
->rp_minor
<< ") " << "payload " << p
->rp_payload
.size() << ":" << std::endl
;
21 for(size_t i
= 0; !brief_mode
&& i
< p
->rp_payload
.size(); i
+= 16) {
22 size_t j
= p
->rp_payload
.size() - i
;
26 for(size_t k
= 0; k
< j
; k
++)
27 std::cout
<< std::setfill('0') << std::setw(2) << std::hex
28 << (uint16_t)p
->rp_payload
[i
+ k
] << " ";
29 std::cout
<< std::endl
;
34 int real_main(int argc
, char** argv
)
38 std::cerr
<< "syntax: " << argv
[0] << " <file>" << std::endl
;
41 if(getenv("BRIEF_PACKETDUMP"))
43 read_channel
rc(argv
[1]);
44 while((p
= rc
.read()))