1 #ifndef _RESOLVPROTO_H_
2 #define _RESOLVPROTO_H_
10 /// Petición de un nameserver
11 /// +------------+------------+------------+
12 /// | QUERY_TYPE | SIZE | NAME |
13 /// +------------+------------+------------+
14 /// /-- 1 byte --/- 2 bytes --/- variable -/
15 struct ResolvProtoRequest
21 QT_DIRECT, ///> Búsqueda directa (inter nameservers)
22 QT_RECURSIVE ///> Búsqueda recursiva (para resolvers)
30 ResolvProtoRequest(int fd);
31 ResolvProtoRequest(std::string name, uint8_t query_type = QT_RECURSIVE);
34 void send(int sockfd) const throw (std::runtime_error);
37 void recv(int sockfd) throw (std::runtime_error);
41 /// Impresión de request
42 std::ostream& operator<< (std::ostream& os, const ResolvProtoRequest& rpr);
45 /// Respuesta de un nameserver
46 /// +-----------+-----------+-----------+-----------+-----------+-----------+
47 /// | RET | TTL | COUNT | IP 1 | ... | IP N |
48 /// +-----------+-----------+-----------+-----------+-----------+-----------+
49 /// /-- 1 byte -/- 4 bytes -/-- 1 byte -/- 4 bytes -/- 4 bytes -/- 4 bytes -/
50 struct ResolvProtoResponse
53 /// Resultado de la respuesta
56 R_A, ///> OK, se devolvió un registro A
57 R_NS, ///> OK, se devolvió un registro NS (sólo en directo)
58 R_NOTFOUND, ///> No se encontró
59 R_TIMEOUT ///> Tardó demasiado la consulta
63 /// TTL (sólo útil para búsquedas (inter nameserver)
67 typedef std::vector< IPAddr > ipvec_t;
71 ResolvProtoResponse();
72 ResolvProtoResponse(int fd);
73 ResolvProtoResponse(ret_t ret, uint32_t ttl = 0,
74 const ipvec_t& ips = ipvec_t());
77 void send(int sockfd) const throw (std::runtime_error);
80 void recv(int sockfd) throw (std::runtime_error);
84 /// Impresión de response
85 std::ostream& operator<< (std::ostream& os, const ResolvProtoResponse& rpr);
87 #endif // _RESOLVPROTO_H_
89 // vim: set et sw=4 sts=4 :