diff options
-rw-r--r-- | gresolv/gresolv.c | 29 | ||||
-rw-r--r-- | gresolv/gresolv.h | 10 |
2 files changed, 32 insertions, 7 deletions
diff --git a/gresolv/gresolv.c b/gresolv/gresolv.c index 66b2641b..bab18104 100644 --- a/gresolv/gresolv.c +++ b/gresolv/gresolv.c @@ -102,7 +102,7 @@ static gboolean query_timeout(gpointer user_data) query->timeout = 0; if (query->result_func != NULL) - query->result_func(G_RESOLV_STATUS_ERROR, + query->result_func(G_RESOLV_RESULT_STATUS_NO_RESPONSE, NULL, query->result_data); destroy_query(query); @@ -210,10 +210,29 @@ static void parse_response(struct resolv_nameserver *nameserver, debug(resolv, "msg id: 0x%04x rcode: %d count: %d", ns_msg_id(msg), rcode, count); - if (rcode == 0) - status = G_RESOLV_STATUS_SUCCESS; - else - status = G_RESOLV_STATUS_ERROR; + switch (rcode) { + case 0: + status = G_RESOLV_RESULT_STATUS_SUCCESS; + break; + case 1: + status = G_RESOLV_RESULT_STATUS_FORMAT_ERROR; + break; + case 2: + status = G_RESOLV_RESULT_STATUS_SERVER_FAILURE; + break; + case 3: + status = G_RESOLV_RESULT_STATUS_NAME_ERROR; + break; + case 4: + status = G_RESOLV_RESULT_STATUS_NOT_IMPLEMENTED; + break; + case 5: + status = G_RESOLV_RESULT_STATUS_REFUSED; + break; + default: + status = G_RESOLV_RESULT_STATUS_ERROR; + break; + } results = g_try_new(char *, count + 1); if (results == NULL) diff --git a/gresolv/gresolv.h b/gresolv/gresolv.h index 1f678de0..5a98e8c2 100644 --- a/gresolv/gresolv.h +++ b/gresolv/gresolv.h @@ -35,8 +35,14 @@ struct _GResolv; typedef struct _GResolv GResolv; typedef enum { - G_RESOLV_STATUS_SUCCESS, - G_RESOLV_STATUS_ERROR, + G_RESOLV_RESULT_STATUS_SUCCESS, + G_RESOLV_RESULT_STATUS_ERROR, + G_RESOLV_RESULT_STATUS_NO_RESPONSE, + G_RESOLV_RESULT_STATUS_FORMAT_ERROR, + G_RESOLV_RESULT_STATUS_SERVER_FAILURE, + G_RESOLV_RESULT_STATUS_NAME_ERROR, + G_RESOLV_RESULT_STATUS_NOT_IMPLEMENTED, + G_RESOLV_RESULT_STATUS_REFUSED, } GResolvResultStatus; typedef void (*GResolvResultFunc)(GResolvResultStatus status, |