summaryrefslogtreecommitdiff
path: root/omapip/connection.c
diff options
context:
space:
mode:
authorTed Lemon <source@isc.org>2001-05-02 06:52:03 +0000
committerTed Lemon <source@isc.org>2001-05-02 06:52:03 +0000
commitaaa98d8c5bc7e9b75569fac2d21e12a9152cc522 (patch)
tree5c32faed9dfb1d8434787d9e406889772a99fef6 /omapip/connection.c
parent96c823d5e8f516b191f1d40003b3f18f471f8ab2 (diff)
downloadisc-dhcp-aaa98d8c5bc7e9b75569fac2d21e12a9152cc522.tar.gz
Return connection failure status codes.
Diffstat (limited to 'omapip/connection.c')
-rw-r--r--omapip/connection.c31
1 files changed, 27 insertions, 4 deletions
diff --git a/omapip/connection.c b/omapip/connection.c
index b87e9867..df811b39 100644
--- a/omapip/connection.c
+++ b/omapip/connection.c
@@ -55,6 +55,7 @@ trace_type_t *trace_connect;
trace_type_t *trace_disconnect;
extern omapi_array_t *trace_listeners;
#endif
+static isc_result_t omapi_connection_connect_internal (omapi_object_t *);
OMAPI_OBJECT_ALLOC (omapi_connection,
omapi_connection_object_t, omapi_type_connection)
@@ -223,7 +224,8 @@ isc_result_t omapi_connect_list (omapi_object_t *c,
omapi_connection_reaper));
if (status != ISC_R_SUCCESS)
goto out;
- status = omapi_connection_connect ((omapi_object_t *)obj);
+ status = omapi_connection_connect_internal ((omapi_object_t *)
+ obj);
#if defined (TRACING)
}
omapi_connection_register (obj, MDL);
@@ -553,6 +555,16 @@ int omapi_connection_writefd (omapi_object_t *h)
isc_result_t omapi_connection_connect (omapi_object_t *h)
{
+ isc_result_t status;
+
+ status = omapi_connection_connect_internal (h);
+ if (status != ISC_R_SUCCESS)
+ omapi_signal (h, "status", status);
+ return ISC_R_SUCCESS;
+}
+
+static isc_result_t omapi_connection_connect_internal (omapi_object_t *h)
+{
int error;
omapi_connection_object_t *c;
SOCKLEN_T sl;
@@ -575,14 +587,25 @@ isc_result_t omapi_connection_connect (omapi_object_t *h)
if (c -> state == omapi_connection_connecting ||
c -> state == omapi_connection_unconnected) {
if (c -> cptr >= c -> connect_list -> count) {
+ switch (error) {
+ case ECONNREFUSED:
+ status = ISC_R_CONNREFUSED;
+ break;
+ case ENETUNREACH:
+ status = ISC_R_NETUNREACH;
+ break;
+ default:
+ status = uerr2isc (error);
+ break;
+ }
omapi_disconnect (h, 1);
- return ISC_R_SUCCESS;
+ return status;
}
if (c -> connect_list -> addresses [c -> cptr].addrtype !=
AF_INET) {
omapi_disconnect (h, 1);
- return ISC_R_SUCCESS;
+ return ISC_R_INVALIDARG;
}
memcpy (&c -> remote_addr.sin_addr,
@@ -613,7 +636,7 @@ isc_result_t omapi_connection_connect (omapi_object_t *h)
status = ISC_R_NETUNREACH;
break;
default:
- status = ISC_R_UNEXPECTED;
+ status = uerr2isc (error);
break;
}
return status;