]> git.llucax.com Git - z.facultad/75.74/practicos.git/blobdiff - practicas/pipi/src/resolvproto.cpp
Se emprolija un poco la info de debug.
[z.facultad/75.74/practicos.git] / practicas / pipi / src / resolvproto.cpp
index 55e960c570375c925ed82e92852eebcc1209a6ca..3b39419a885995e41f1111604fc5405e22692f8c 100644 (file)
@@ -4,17 +4,17 @@
 #include <iterator>
 
 /// Constructor
-ResolvProtoRequest::ResolvProtoRequest(std::string name, uint8_t query_type):
+ResolvProtoRequest::ResolvProtoRequest(std::string name, rp_pkt_type_t query_type):
     query_type(query_type), name(name)
 {}
 
 /// Constructor a partir de un buffer
 ResolvProtoRequest::ResolvProtoRequest(std::string buf)
 {
-    memcpy(&query_type, buf.c_str(), sizeof(uint8_t));
+    memcpy(&query_type, buf.data(), sizeof(uint8_t));
     uint16_t size;
-    memcpy(&size, buf.c_str() + sizeof(uint8_t), sizeof(uint16_t));
-    name.assign(buf.c_str() + sizeof(uint8_t) + sizeof(uint16_t), size);
+    memcpy(&size, buf.data() + sizeof(uint8_t), sizeof(uint16_t));
+    name.assign(buf.data() + sizeof(uint8_t) + sizeof(uint16_t), size);
 }
 
 /// Convierte a un buffer
@@ -40,30 +40,30 @@ std::ostream& operator<< (std::ostream& os, const ResolvProtoRequest& rpr)
 }
 
 /// Constructor
-ResolvProtoResponse::ResolvProtoResponse(): ret(R_NOTFOUND), ttl(0)
+ResolvProtoResponse::ResolvProtoResponse(): ret(RP_RES_NOTFOUND), ttl(0)
 {
 }
 
 /// Constructor
 ResolvProtoResponse::ResolvProtoResponse(std::string buf)
 {
-    memcpy(&ret, buf.c_str(), sizeof(uint8_t));
-    memcpy(&ttl, buf.c_str() + sizeof(uint8_t), sizeof(uint32_t));
+    memcpy(&ret, buf.data(), sizeof(uint8_t));
+    memcpy(&ttl, buf.data() + sizeof(uint8_t), sizeof(uint32_t));
     uint8_t count;
-    memcpy(&count, buf.c_str() + sizeof(uint8_t) + sizeof(uint32_t),
+    memcpy(&count, buf.data() + sizeof(uint8_t) + sizeof(uint32_t),
             sizeof(uint8_t));
     ips.reserve(count);
     for (uint8_t i = 0; i < count; ++i)
     {
         uint32_t ip;
-        memcpy(&ip, buf.c_str() + 2 * sizeof(uint8_t)
+        memcpy(&ip, buf.data() + 2 * sizeof(uint8_t)
                 + sizeof(uint32_t) * (i + 1), sizeof(uint32_t));
         ips.push_back(ip);
     }
 }
 
 /// Constructor
-ResolvProtoResponse::ResolvProtoResponse(ret_t ret, uint32_t ttl,
+ResolvProtoResponse::ResolvProtoResponse(rp_pkt_type_t ret, uint32_t ttl,
         const ipvec_t& ips):
     ret(ret), ttl(ttl), ips(ips)
 {}