- template<>
- template<>
- void testobject::test<1>()
- {
- set_test_name("Check structure consistency");
-
- RAW_PACKET rp;
- rp.header.ipHeader.ip_v = 4;
- rp.header.ipHeader.ip_hl = 5;
- rp.header.ipHeader.ip_tos = 0;
- rp.header.ipHeader.ip_len = htons(40); // 20 of header + 20 of data
- rp.header.ipHeader.ip_p = 6;
- rp.header.ipHeader.ip_src.s_addr = inet_addr("192.168.0.1");
- rp.header.ipHeader.ip_dst.s_addr = inet_addr("192.168.0.101");
- rp.header.sPort = htons(80);
- rp.header.dPort = htons(38546);
-
- ensure_equals("IP header size (explicitly)", sizeof(rp.header.ipHeader), 20);
- ensure_equals("IP version", rp.GetIPVersion(), 4);
- ensure_equals("IP header size (with options)", rp.GetHeaderLen(), 20);
- ensure_equals("Underlying protocol version", rp.GetProto(), 6);
- ensure_equals("Packet length", rp.GetLen(), 40);
- ensure_equals("Source IP address", rp.GetSrcIP(), inet_addr("192.168.0.1"));
- ensure_equals("Destination IP address", rp.GetDstIP(), inet_addr("192.168.0.101"));
- ensure_equals("Source port number", rp.GetSrcPort(), 80);
- ensure_equals("Destination port number", rp.GetDstPort(), 38546);
+std::ostream & operator<<(std::ostream& stream, const STG::RawPacket& p)
+{
+ stream.setf(std::ios::hex);
+ for (size_t i = 0; i < sizeof(p.rawPacket.data); ++i) {
+ stream << static_cast<unsigned>(p.rawPacket.data[i]);