]> git.ipfire.org Git - thirdparty/dhcp.git/commitdiff
Return connection failure status codes.
authorTed Lemon <source@isc.org>
Wed, 2 May 2001 06:52:03 +0000 (06:52 +0000)
committerTed Lemon <source@isc.org>
Wed, 2 May 2001 06:52:03 +0000 (06:52 +0000)
omapip/connection.c

index b87e98677b2f17b27f5ed487024b47a2ebc613dd..df811b39159a3ed8352450ae6055d84e83e7b864 100644 (file)
@@ -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);
@@ -552,6 +554,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;
@@ -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;