dummy callback added to interface manager
[strongswan.git] / src / charon / control / interface_manager.c
index 4cc0581..917470d 100644 (file)
@@ -239,6 +239,15 @@ static bool unroute_listener(interface_bus_listener_t *this, signal_t signal,
 }
 
 /**
+ * dummy callback
+ */
+static bool dummy_callback(void *param, signal_t signal, level_t level,
+                                        ike_sa_t *ike_sa, char *format, va_list args)
+{
+       return TRUE;
+}
+
+/**
  * remove a previously registered listener from the bus
  */
 static void remove_listener(interface_bus_listener_t *listener)
@@ -270,17 +279,14 @@ static status_t initiate(private_interface_manager_t *this,
        peer_cfg->destroy(peer_cfg);
 
        listener.listener.signal = (void*)initiate_listener;
-       listener.callback = callback;
+       listener.callback = callback ? callback : (interface_manager_cb_t)dummy_callback;
        listener.ike_sa = ike_sa;
        listener.param = param;
        listener.cancelled = FALSE;
 
        /* we listen passively to catch the signals we are raising in 
-        * ike_sa->delete(). */
-       if (callback)
-       {
-               charon->bus->add_listener(charon->bus, &listener.listener);
-       }
+        * ike_sa->initiate(). */
+       charon->bus->add_listener(charon->bus, &listener.listener);
        charon->bus->set_listen_state(charon->bus, TRUE);
        if (ike_sa->initiate(ike_sa, child_cfg) != SUCCESS)
        {
@@ -344,7 +350,7 @@ static status_t terminate_ike(interface_manager_t *this, u_int32_t unique_id,
                                                          interface_manager_cb_t callback, void *param)
 {
        ike_sa_t *ike_sa;
-       status_t status = FAILED;;
+       status_t status = FAILED;
        interface_bus_listener_t listener;
        
        ike_sa = charon->ike_sa_manager->checkout_by_id(charon->ike_sa_manager,
@@ -357,14 +363,12 @@ static status_t terminate_ike(interface_manager_t *this, u_int32_t unique_id,
        /* we listen passively to catch the signals we are raising in 
         * ike_sa->delete(). */
        listener.listener.signal = (void*)terminate_ike_listener;
-       listener.callback = callback;
+       listener.callback = callback ? callback : (interface_manager_cb_t)dummy_callback;
        listener.ike_sa = ike_sa;
        listener.param = param;
        listener.cancelled = FALSE;
-       if (callback)
-       {
-               charon->bus->add_listener(charon->bus, &listener.listener);
-       }
+       
+       charon->bus->add_listener(charon->bus, &listener.listener);
        charon->bus->set_listen_state(charon->bus, TRUE);
        status = ike_sa->delete(ike_sa);
        if (status == DESTROY_ME)
@@ -458,16 +462,13 @@ static status_t terminate_child(interface_manager_t *this, u_int32_t reqid,
        }
        
        listener.listener.signal = (void*)terminate_child_listener;
-       listener.callback = callback;
+       listener.callback = callback ? callback : (interface_manager_cb_t)dummy_callback;
        listener.ike_sa = ike_sa;
        listener.param = param;
        listener.cancelled = FALSE;
                
        /* we listen passively to catch the signals we are raising */
-       if (callback)
-       {
-               charon->bus->add_listener(charon->bus, &listener.listener);
-       }
+       charon->bus->add_listener(charon->bus, &listener.listener);
        charon->bus->set_listen_state(charon->bus, TRUE);
        status = ike_sa->delete_child_sa(ike_sa, child_sa->get_protocol(child_sa),
                                                                         child_sa->get_spi(child_sa, TRUE));
@@ -548,17 +549,14 @@ static status_t route(interface_manager_t *this,
        }
                
        /* we listen passively only, as routing is done by one thread only */
-       if (callback)
-       {
-               interface_bus_listener_t listener;
+       interface_bus_listener_t listener;
        
-               listener.listener.signal = (void*)route_listener;
-               listener.callback = callback;
-               listener.ike_sa = ike_sa;
-               listener.param = param;
-               listener.cancelled = FALSE;
-               charon->bus->add_listener(charon->bus, &listener.listener);
-       }
+       listener.listener.signal = (void*)route_listener;
+       listener.callback = callback ? callback : (interface_manager_cb_t)dummy_callback;
+       listener.ike_sa = ike_sa;
+       listener.param = param;
+       listener.cancelled = FALSE;
+       charon->bus->add_listener(charon->bus, &listener.listener);
        
        if (ike_sa->route(ike_sa, child_cfg) != SUCCESS)
        {
@@ -585,17 +583,15 @@ static status_t unroute(interface_manager_t *this, u_int32_t reqid,
        }
        
        /* we listen passively only, as routing is done by one thread only */
-       if (callback)
-       {
-               interface_bus_listener_t listener;
+       interface_bus_listener_t listener;
+       
+       listener.listener.signal = (void*)unroute_listener;
+       listener.callback = callback ? callback : (interface_manager_cb_t)dummy_callback;
+       listener.ike_sa = ike_sa;
+       listener.param = param;
+       listener.cancelled = FALSE;
+       charon->bus->add_listener(charon->bus, &listener.listener);
        
-               listener.listener.signal = (void*)unroute_listener;
-               listener.callback = callback;
-               listener.ike_sa = ike_sa;
-               listener.param = param;
-               listener.cancelled = FALSE;
-               charon->bus->add_listener(charon->bus, &listener.listener);
-       }
        status = ike_sa->unroute(ike_sa, reqid);
        if (status == DESTROY_ME)
        {