[hipl-commit] [tiny] Rev 3672: Added (un)registration of maintenance function to HEARTBEAT module.

  • From: Tim Just <tim.just@xxxxxxxxxxxxxx>
  • To: hipl-commit@xxxxxxxxxxxxx
  • Date: Sat, 13 Mar 2010 13:01:17 +0200

Committer: Tim Just <tim.just@xxxxxxxxxxxxxx>
Date: Sat Mar 13 11:59:53 2010 +0100
Revision: 3672
Revision-id: tim.just@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Branch nick: tiny

Log:
  Added (un)registration of maintenance function to HEARTBEAT module.
  
  The HEARTBEAT module unregisters the NAT keep-alive and registers the
  HEARTBEAT maintenance function.
  
  Added hip_unregister_maintenance function used for unregistration.

Modified:
  M  hipd/modularization.c
  M  hipd/modularization.h
  M  hipd/nat.c
  M  modules/heartbeat/hipd/heartbeat.c

=== modified file 'hipd/modularization.c'
--- hipd/modularization.c       2010-03-11 14:08:33 +0000
+++ hipd/modularization.c       2010-03-13 10:59:53 +0000
@@ -217,6 +217,22 @@
 }
 
 /**
+ * hip_unregister_maint_function
+ *
+ * Remove a maintenance function from the list.
+ *
+ * @param *maint_function Pointer to the function which should be unregistered.
+ *
+ * @return Success =  0
+ *         Error   = -1
+ */
+int hip_unregister_maint_function(int (*maint_function)(void))
+{
+    return lmod_unregister_function(hip_maintenance_functions,
+                                    maint_function);
+}
+
+/**
  * hip_run_maint_functions
  *
  * Run all maintenance functions.

=== modified file 'hipd/modularization.h'
--- hipd/modularization.h       2010-03-11 14:08:33 +0000
+++ hipd/modularization.h       2010-03-13 10:59:53 +0000
@@ -30,6 +30,8 @@
 int hip_register_maint_function(int (*maint_function)(void),
                                 const uint16_t priority);
 
+int hip_unregister_maint_function(int (*maint_function)(void));
+
 int hip_run_maint_functions(void);
 
 void hip_uninit_maint_functions(void);

=== modified file 'hipd/nat.c'
--- hipd/nat.c  2010-03-13 10:30:42 +0000
+++ hipd/nat.c  2010-03-13 10:59:53 +0000
@@ -94,7 +94,7 @@
  *
  * @return zero on success, or negative error value on error.
  */
-int hip_nat_refresh_port()
+int hip_nat_refresh_port(void)
 {
     int err = 0;
 

=== modified file 'modules/heartbeat/hipd/heartbeat.c'
--- modules/heartbeat/hipd/heartbeat.c  2010-03-12 15:45:15 +0000
+++ modules/heartbeat/hipd/heartbeat.c  2010-03-13 10:59:53 +0000
@@ -324,11 +324,21 @@
 
     HIP_IFEL(lmod_register_module("heartbeat"),
              -1,
-             "Error on registering HEATBEAT module.\n");
-
-    hip_register_socket(hip_icmp_sock, &hip_heartbeat_handle_icmp_sock, 30000);
-
-    hip_register_maint_function(&hip_heartbeat_maintenance, 10000);
+             "Error on registration of HEARTBEAT module.\n");
+
+    HIP_IFEL(hip_register_socket(hip_icmp_sock,
+                                 &hip_heartbeat_handle_icmp_sock,
+                                 30000),
+             -1,
+             "Error on registration of hip_icmp_sock for HEARTBEAT module.\n");
+
+    if (hip_unregister_maint_function(&hip_nat_refresh_port)) {
+        HIP_DEBUG("Unregister 'hip_nat_refresh_port() failed.\n");
+    }
+
+    HIP_IFEL(hip_register_maint_function(&hip_heartbeat_maintenance, 10000),
+             -1,
+             "Error on registration of hip_heartbeat_maintenance().\n");
 
 out_err:
     return err;

Other related posts:

  • » [hipl-commit] [tiny] Rev 3672: Added (un)registration of maintenance function to HEARTBEAT module. - Tim Just