diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2010-07-28 11:50:16 -0700 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2010-07-28 11:50:16 -0700 |
commit | f3e66867ca3d87cc3f6610b9bab2bbf3a1ad5138 (patch) | |
tree | 850ade2509960962556e6e514d8cb29c3c59ca10 /gresolv | |
parent | 202d34eddb948e2c4f1dc9a0c7d9417a38ced2db (diff) | |
download | connman-f3e66867ca3d87cc3f6610b9bab2bbf3a1ad5138.tar.gz connman-f3e66867ca3d87cc3f6610b9bab2bbf3a1ad5138.tar.bz2 connman-f3e66867ca3d87cc3f6610b9bab2bbf3a1ad5138.zip |
Add proper status support for lookups via resolver library
Diffstat (limited to 'gresolv')
-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, |