]> git.llucax.com Git - z.facultad/75.74/practicos.git/commitdiff
Se normaliza toda la salida de debug para que vaya por std::cerr.
authorLeandro Lucarella <llucax@gmail.com>
Tue, 4 Jul 2006 15:02:25 +0000 (15:02 +0000)
committerLeandro Lucarella <llucax@gmail.com>
Tue, 4 Jul 2006 15:02:25 +0000 (15:02 +0000)
practicas/pipi/src/nameserver.cpp
practicas/pipi/src/resolver.cpp

index 959286a3ee6dde5a029828c55334f7d80158dd56..4fd894a51eaaedab6aaa2e1fec1f02e44f8268b9 100644 (file)
@@ -46,7 +46,7 @@ static std::istream& parsezone(std::istream& is, NameServer::Zone& z)
         throw std::runtime_error("Error al parsear");
     z.name = sname;
 #ifdef DEBUG_PARSER
         throw std::runtime_error("Error al parsear");
     z.name = sname;
 #ifdef DEBUG_PARSER
-    std::cerr << "NameServer::parsezone: IP = " << ip << "\n\n";
+    std::cout << "NameServer::parsezone: IP = " << ip << "\n\n";
 #endif
     z.parent = IPAddr(ip);
     // un record por linea, sin líneas vacías
 #endif
     z.parent = IPAddr(ip);
     // un record por linea, sin líneas vacías
@@ -60,13 +60,13 @@ static std::istream& parsezone(std::istream& is, NameServer::Zone& z)
             throw std::runtime_error("Error al parsear");
         typedef NameServer::Record Rec;
 #ifdef DEBUG_PARSER
             throw std::runtime_error("Error al parsear");
         typedef NameServer::Record Rec;
 #ifdef DEBUG_PARSER
-        std::cerr << "NameServer::parsezone: IP = " << ip << "\n\n";
+        std::cout << "NameServer::parsezone: IP = " << ip << "\n\n";
 #endif
         Rec r((type == "NS") ? Rec::NS : Rec::A, IPAddr(ip));
         z.records.insert(NameServer::Zone::records_t::value_type(key, r));
     }
 #ifdef DEBUG_PARSER
 #endif
         Rec r((type == "NS") ? Rec::NS : Rec::A, IPAddr(ip));
         z.records.insert(NameServer::Zone::records_t::value_type(key, r));
     }
 #ifdef DEBUG_PARSER
-    std::cerr << "NameServer::parsezone: " << z << "\n\n";
+    std::cout << "NameServer::parsezone: " << z << "\n\n";
 #endif
     return is;
 }
 #endif
     return is;
 }
@@ -106,7 +106,7 @@ NameServer::NameServer(std::istream& is, IPIn& ipin, IPOut& ipout,
         zones.push_back(z);
         z.clear();
 #ifdef DEBUG_PARSER
         zones.push_back(z);
         z.clear();
 #ifdef DEBUG_PARSER
-        std::cerr << "NameServer::NameServer: " << z << "\n\n";
+        std::cout << "NameServer::NameServer: " << z << "\n\n";
 #endif
     }
 
 #endif
     }
 
@@ -142,7 +142,7 @@ name_split(NameServer::Name n, NameServer::Name m)
         r.push_back(n[i++]);
     std::reverse(r.begin(), r.end());
 #ifdef DEBUG_NAME
         r.push_back(n[i++]);
     std::reverse(r.begin(), r.end());
 #ifdef DEBUG_NAME
-    std::cerr << "NameServer::name_split(" << n << ", " << m << ") -> "
+    std::cout << "NameServer::name_split(" << n << ", " << m << ") -> "
         << r << "\n";
 #endif
     return r;
         << r << "\n";
 #endif
     return r;
@@ -226,7 +226,7 @@ ResolvProtoResponse NameServer::resolv_direct(const Name& n)
     std::cout << "NameServer::resolv_direct()\n";
 #endif
 #ifdef DEBUG_RESOLV
     std::cout << "NameServer::resolv_direct()\n";
 #endif
 #ifdef DEBUG_RESOLV
-    std::cerr << "NameServer::resolv_direct -> tratando de resolver: "
+    std::cout << "NameServer::resolv_direct -> tratando de resolver: "
         << n << "\n";
 #endif
     search_zone zs(n);
         << n << "\n";
 #endif
     search_zone zs(n);
@@ -237,7 +237,7 @@ ResolvProtoResponse NameServer::resolv_direct(const Name& n)
     if (found)
     {
 #ifdef DEBUG_RESOLV
     if (found)
     {
 #ifdef DEBUG_RESOLV
-        std::cerr << "NameServer::resolv_direct -> found (local/hijo): "
+        std::cout << "NameServer::resolv_direct -> found (local/hijo): "
             << zs.resp << "\n";
 #endif
         return zs.resp;
             << zs.resp << "\n";
 #endif
         return zs.resp;
@@ -245,7 +245,7 @@ ResolvProtoResponse NameServer::resolv_direct(const Name& n)
     if (zs.local)
     {
 #ifdef DEBUG_RESOLV
     if (zs.local)
     {
 #ifdef DEBUG_RESOLV
-        std::cerr << "NameServer::resolv_direct -> NOT FOUND (es local pero "
+        std::cout << "NameServer::resolv_direct -> NOT FOUND (es local pero "
             "no existe)\n";
 #endif
         return ResolvProtoResponse(RP_RES_NOTFOUND);
             "no existe)\n";
 #endif
         return ResolvProtoResponse(RP_RES_NOTFOUND);
@@ -255,14 +255,14 @@ ResolvProtoResponse NameServer::resolv_direct(const Name& n)
     {
         const CacheRecord& cr = i->second;
 #ifdef DEBUG_RESOLV
     {
         const CacheRecord& cr = i->second;
 #ifdef DEBUG_RESOLV
-        std::cerr << "NameServer::resolv_direct -> found (en cache): "
+        std::cout << "NameServer::resolv_direct -> found (en cache): "
             << cr << "\n";
 #endif
         if (unsigned(time(NULL)) > cr.expire) // Expiró
         {
             cache.erase(i);
 #ifdef DEBUG_RESOLV
             << cr << "\n";
 #endif
         if (unsigned(time(NULL)) > cr.expire) // Expiró
         {
             cache.erase(i);
 #ifdef DEBUG_RESOLV
-            std::cerr << "                          -> pero no sirve, expiró "
+            std::cout << "                          -> pero no sirve, expiró "
                 "hace unos " << (time(NULL) - cr.expire) << " segundos\n";
 #endif
         }
                 "hace unos " << (time(NULL) - cr.expire) << " segundos\n";
 #endif
         }
@@ -277,13 +277,13 @@ ResolvProtoResponse NameServer::resolv_direct(const Name& n)
         for (zones_t::const_iterator i = zones.begin(); i != zones.end(); ++i)
         {
 #ifdef DEBUG_RESOLV
         for (zones_t::const_iterator i = zones.begin(); i != zones.end(); ++i)
         {
 #ifdef DEBUG_RESOLV
-            std::cerr << "NameServer::resolv_direct -> evaluando padre "
+            std::cout << "NameServer::resolv_direct -> evaluando padre "
                 << i->parent << "\n";
 #endif
             if (i->parent != IPAddr(0))
             {
 #ifdef DEBUG_RESOLV
                 << i->parent << "\n";
 #endif
             if (i->parent != IPAddr(0))
             {
 #ifdef DEBUG_RESOLV
-                std::cerr << "NameServer::resolv_direct -> found (al padre): "
+                std::cout << "NameServer::resolv_direct -> found (al padre): "
                     << i->parent << "\n";
 #endif
                 ResolvProtoResponse rpr(RP_RES_NS, i->ttl);
                     << i->parent << "\n";
 #endif
                 ResolvProtoResponse rpr(RP_RES_NS, i->ttl);
@@ -293,7 +293,7 @@ ResolvProtoResponse NameServer::resolv_direct(const Name& n)
         }
     }
 #ifdef DEBUG_RESOLV
         }
     }
 #ifdef DEBUG_RESOLV
-    std::cerr << "NameServer::resolv_direct -> NOT FOUND (no hay padre)\n";
+    std::cout << "NameServer::resolv_direct -> NOT FOUND (no hay padre)\n";
 #endif
     // No hay padre, no puedo hacer nada más
     return ResolvProtoResponse(RP_RES_NOTFOUND);
 #endif
     // No hay padre, no puedo hacer nada más
     return ResolvProtoResponse(RP_RES_NOTFOUND);
@@ -310,13 +310,13 @@ ResolvProtoResponse NameServer::resolv_recursive(const Name& n)
     {
         case RP_RES_NS:
 #ifdef DEBUG_RESOLV
     {
         case RP_RES_NS:
 #ifdef DEBUG_RESOLV
-            std::cerr << "NameServer::resolv_recursive -> redirect a "
+            std::cout << "NameServer::resolv_recursive -> redirect a "
                 << rpr << "\n";
 #endif
             return resolv_recursive_r(n, rpr); // Sigo "bajando"
         case RP_RES_A:
 #ifdef DEBUG_RESOLV
                 << rpr << "\n";
 #endif
             return resolv_recursive_r(n, rpr); // Sigo "bajando"
         case RP_RES_A:
 #ifdef DEBUG_RESOLV
-            std::cerr << "NameServer::resolv_recursive -> gotcha! "
+            std::cout << "NameServer::resolv_recursive -> gotcha! "
                 << rpr << "\n";
 #endif
             break;
                 << rpr << "\n";
 #endif
             break;
@@ -340,26 +340,26 @@ ResolvProtoResponse NameServer::resolv_recursive_r(const Name& n,
         {
             case RP_RES_NS:
 #ifdef DEBUG_RESOLV
         {
             case RP_RES_NS:
 #ifdef DEBUG_RESOLV
-                std::cerr << "NameServer::resolv_recursive_r -> redirect a "
+                std::cout << "NameServer::resolv_recursive_r -> redirect a "
                     << r << "\n";
 #endif
                 return resolv_recursive_r(n, r); // Sigo "bajando"
             case RP_RES_NOTFOUND:
 #ifdef DEBUG_RESOLV
                     << r << "\n";
 #endif
                 return resolv_recursive_r(n, r); // Sigo "bajando"
             case RP_RES_NOTFOUND:
 #ifdef DEBUG_RESOLV
-                std::cerr << "NameServer::resolv_recursive_r -> NOT FOUND en "
+                std::cout << "NameServer::resolv_recursive_r -> NOT FOUND en "
                     << *ip << ", sigo probando\n";
 #endif
                 break; // Sigo probando del mismo nivel
             case RP_RES_A:
 #ifdef DEBUG_RESOLV
                     << *ip << ", sigo probando\n";
 #endif
                 break; // Sigo probando del mismo nivel
             case RP_RES_A:
 #ifdef DEBUG_RESOLV
-                std::cerr << "NameServer::resolv_recursive_r -> gotcha! "
+                std::cout << "NameServer::resolv_recursive_r -> gotcha! "
                     << r << "\n";
 #endif
                 return r; // Gotcha!
         }
     }
 #ifdef DEBUG_RESOLV
                     << r << "\n";
 #endif
                 return r; // Gotcha!
         }
     }
 #ifdef DEBUG_RESOLV
-    std::cerr << "NameServer::resolv_recursive_r -> NOT FOUND, no hay más "
+    std::cout << "NameServer::resolv_recursive_r -> NOT FOUND, no hay más "
         "por hacer\n";
 #endif
     return r; // NOTFOUND
         "por hacer\n";
 #endif
     return r; // NOTFOUND
@@ -373,7 +373,7 @@ ResolvProtoResponse NameServer::query(const Name& n, const IPAddr& ip)
 #endif
     ResolvProtoRequest r(std::string(n), RP_REQ_DIRECT);
 #ifdef DEBUG_RESOLV
 #endif
     ResolvProtoRequest r(std::string(n), RP_REQ_DIRECT);
 #ifdef DEBUG_RESOLV
-    std::cerr << "NameServer::query -> pidiendo " << r << " a " << ip << "\n";
+    std::cout << "NameServer::query -> pidiendo " << r << " a " << ip << "\n";
 #endif
     // Envía a través de la cola de envío
     snd_que.transmit(std::string(r), ip);
 #endif
     // Envía a través de la cola de envío
     snd_que.transmit(std::string(r), ip);
@@ -381,7 +381,7 @@ ResolvProtoResponse NameServer::query(const Name& n, const IPAddr& ip)
     std::string buf = res_que.receive(mac);
     ResolvProtoResponse resp(buf);
 #ifdef DEBUG_RESOLV
     std::string buf = res_que.receive(mac);
     ResolvProtoResponse resp(buf);
 #ifdef DEBUG_RESOLV
-    std::cerr << "NameServer::query -> recibido " << resp << " de "
+    std::cout << "NameServer::query -> recibido " << resp << " de "
         << ip << "\n";
 #endif
     // Agrego a cache
         << ip << "\n";
 #endif
     // Agrego a cache
index 3eee09c601abb07a8b9eeb3b5965996da0b9b6a7..cf40b9fc3065e2511207a155b958ee00dfe69065 100644 (file)
@@ -73,7 +73,7 @@ ResolvProtoResponse Resolver::query(const std::string& name, const IPAddr& ip)
     std::string buf = res_que.receive(mac);
     ResolvProtoResponse resp(buf);
 #ifdef DEBUG_RESOLV
     std::string buf = res_que.receive(mac);
     ResolvProtoResponse resp(buf);
 #ifdef DEBUG_RESOLV
-    std::cerr << "query -> recibido " << resp << " de " << ip << "\n";
+    std::cout << "query -> recibido " << resp << " de " << ip << "\n";
 #endif
     return resp;
 }
 #endif
     return resp;
 }