From: Marcel Holtmann Date: Wed, 28 Jul 2010 18:50:16 +0000 (-0700) Subject: Add proper status support for lookups via resolver library X-Git-Tag: 0.56~82 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f3e66867ca3d87cc3f6610b9bab2bbf3a1ad5138;p=platform%2Fupstream%2Fconnman.git Add proper status support for lookups via resolver library --- diff --git a/gresolv/gresolv.c b/gresolv/gresolv.c index 66b2641..bab1810 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 1f678de..5a98e8c 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,