[Olsr-cvs] olsrd-current/lib/dyn_gw/src olsrd_dyn_gw.c, 1.16, 1.17 olsrd_dyn_gw.h, 1.10, 1.11 olsrd_plugin.c, 1.11, 1.12 olsrd_plugin.h, 1.15, NONE

Bruno Randolf (spam-protected)
Sun May 29 14:47:43 CEST 2005


Update of /cvsroot/olsrd/olsrd-current/lib/dyn_gw/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25973/lib/dyn_gw/src

Modified Files:
	olsrd_dyn_gw.c olsrd_dyn_gw.h olsrd_plugin.c 
Removed Files:
	olsrd_plugin.h 
Log Message:
new plugin interface:
  - plugins can now directly access all olsrd data structures
  - a plugin only has to include "olsrd_plugin.h" and provide 3 interface functions:
      1. olsrd_plugin_interface_version()
      2. olsrd_plugin_register_param()
      3. olsrd_plugin_init()
    which are called in the above order
  - moved all plugins to the new interface


Index: olsrd_dyn_gw.c
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/lib/dyn_gw/src/olsrd_dyn_gw.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -d -r1.16 -r1.17
*** olsrd_dyn_gw.c	25 May 2005 16:33:24 -0000	1.16
--- olsrd_dyn_gw.c	29 May 2005 12:47:40 -0000	1.17
***************
*** 46,50 ****
--- 46,57 ----
   */
  
+ #include <arpa/inet.h>
+ 
+ #include "olsr_types.h"
  #include "olsrd_dyn_gw.h"
+ #include "scheduler.h"
+ #include "olsr.h"
+ #include "local_hna_set.h"
+ 
  #include <stdio.h>
  #include <string.h>
***************
*** 83,86 ****
--- 90,94 ----
  #endif
  
+ 
  /* set default interval, in case none is given in the config file */
  static int check_interval = 5;
***************
*** 99,103 ****
  struct hna_list {
    union olsr_ip_addr hna_net;
!   union hna_netmask hna_netmask;
    struct ping_list *ping_hosts;
    int hna_added;
--- 107,111 ----
  struct hna_list {
    union olsr_ip_addr hna_net;
!   union olsr_ip_addr hna_netmask;
    struct ping_list *ping_hosts;
    int hna_added;
***************
*** 109,113 ****
  	add_to_hna_list(struct hna_list *,
  				union olsr_ip_addr *hna_net,
! 				union hna_netmask *hna_netmask );
  
  struct hna_list *the_hna_list = NULL;
--- 117,121 ----
  	add_to_hna_list(struct hna_list *,
  				union olsr_ip_addr *hna_net,
! 				union olsr_ip_addr *hna_netmask );
  
  struct hna_list *the_hna_list = NULL;
***************
*** 117,121 ****
  
  static int
! check_gw(union olsr_ip_addr *, union hna_netmask *,struct ping_list *);
  
  static int
--- 125,129 ----
  
  static int
! check_gw(union olsr_ip_addr *, union olsr_ip_addr *,struct ping_list *);
  
  static int
***************
*** 129,133 ****
   */  
  int
! register_olsr_param(char *key, char *value)
  {
    /* foo_addr is only used for call to inet_aton */ 
--- 137,141 ----
   */  
  int
! olsrd_plugin_register_param(char *key, char *value)
  {
    /* foo_addr is only used for call to inet_aton */ 
***************
*** 136,140 ****
    int i;
    union olsr_ip_addr temp_net;
!   union hna_netmask temp_netmask;
    char s_netaddr[16];
    char s_mask[16];
--- 144,148 ----
    int i;
    union olsr_ip_addr temp_net;
!   union olsr_ip_addr temp_netmask;
    char s_netaddr[16];
    char s_mask[16];
***************
*** 189,193 ****
   */
  int
! olsr_plugin_init()
  {
    pthread_t ping_thread;
--- 197,201 ----
   */
  int
! olsrd_plugin_init()
  {
    pthread_t ping_thread;
***************
*** 215,246 ****
  
  
- 
- /*
-  * destructor - called at unload
-  */
- void
- olsr_plugin_exit()
- {
- 
- }
- 
- 
- 
- /* Mulitpurpose funtion */
- int
- plugin_io(int cmd, void *data, size_t size)
- {
- 
-   switch(cmd)
-     {
-     default:
-       return 0;
-     }
-   
-   return 1;
- }
- 
- 
- 
  /**
   * Scheduled event to update the hna table,
--- 223,226 ----
***************
*** 248,252 ****
   */
  void
! olsr_event_doing_hna()
  {
  	struct hna_list *li;
--- 228,232 ----
   */
  void
! olsr_event_doing_hna(void *foo)
  {
  	struct hna_list *li;
***************
*** 277,285 ****
  	}
  }
-   
- 
- 
- 
- 
  
  
--- 257,260 ----
***************
*** 309,313 ****
      /* the time to wait in "Interval" sec (see connfig), default=5sec */
      struct timespec sleeptime_spec  = {(time_t) check_interval, 0L };
!     
      li=the_hna_list;
      while(li){
--- 284,288 ----
      /* the time to wait in "Interval" sec (see connfig), default=5sec */
      struct timespec sleeptime_spec  = {(time_t) check_interval, 0L };
! 
      li=the_hna_list;
      while(li){
***************
*** 326,330 ****
  
  static int
! check_gw(union olsr_ip_addr *net, union hna_netmask *mask, struct ping_list *the_ping_list)
  {
      char buff[1024], iface[16];
--- 301,305 ----
  
  static int
! check_gw(union olsr_ip_addr *net, union olsr_ip_addr *mask, struct ping_list *the_ping_list)
  {
      char buff[1024], iface[16];
***************
*** 436,440 ****
  
  static struct hna_list *
! add_to_hna_list(struct hna_list * list_root, union olsr_ip_addr *hna_net, union hna_netmask *hna_netmask )
  {
    struct hna_list *new = (struct hna_list *) malloc(sizeof(struct hna_list));
--- 411,415 ----
  
  static struct hna_list *
! add_to_hna_list(struct hna_list * list_root, union olsr_ip_addr *hna_net, union olsr_ip_addr *hna_netmask )
  {
    struct hna_list *new = (struct hna_list *) malloc(sizeof(struct hna_list));

Index: olsrd_dyn_gw.h
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/lib/dyn_gw/src/olsrd_dyn_gw.h,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** olsrd_dyn_gw.h	19 Feb 2005 17:56:05 -0000	1.10
--- olsrd_dyn_gw.h	29 May 2005 12:47:40 -0000	1.11
***************
*** 58,62 ****
  /* Event function to register with the scheduler */
  void
! olsr_event_doing_hna(void);
  
  #endif
--- 58,62 ----
  /* Event function to register with the scheduler */
  void
! olsr_event_doing_hna(void *);
  
  #endif

--- olsrd_plugin.h DELETED ---

Index: olsrd_plugin.c
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/lib/dyn_gw/src/olsrd_plugin.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** olsrd_plugin.c	25 Feb 2005 22:43:21 -0000	1.11
--- olsrd_plugin.c	29 May 2005 12:47:40 -0000	1.12
***************
*** 42,64 ****
  
  #include "olsrd_plugin.h"
- #include "plugin_loader.h"
  #include <stdio.h>
  
  /**
   * "Private" declarations
   */
  
! void __attribute__ ((constructor)) 
  my_init(void);
  
- void __attribute__ ((destructor)) 
- my_fini(void);
- 
- int
- register_olsr_data(struct olsr_plugin_data *);
- 
- int
- fetch_olsrd_data(void);
- 
  
  /*
--- 42,61 ----
  
  #include "olsrd_plugin.h"
  #include <stdio.h>
  
+ #define PLUGIN_NAME    "OLSRD dynamic gateway plugin"
+ #define PLUGIN_VERSION "0.4"
+ #define PLUGIN_AUTHOR   "Various artists"
+ #define MOD_DESC PLUGIN_NAME " " PLUGIN_VERSION " by " PLUGIN_AUTHOR
+ #define PLUGIN_INTERFACE_VERSION 4
+ 
+ 
  /**
   * "Private" declarations
   */
  
! static void __attribute__ ((constructor)) 
  my_init(void);
  
  
  /*
***************
*** 68,72 ****
   */
  int 
! get_plugin_interface_version()
  {
    return PLUGIN_INTERFACE_VERSION;
--- 65,69 ----
   */
  int 
! olsrd_plugin_interface_version()
  {
    return PLUGIN_INTERFACE_VERSION;
***************
*** 85,200 ****
    return;
  }
- 
- /**
-  *Destructor
-  */
- void
- my_fini()
- {
- 
-   /* Calls the destruction function
-    * olsr_plugin_exit()
-    * This function should be present in your
-    * sourcefile and all data destruction
-    * should happen there - NOT HERE!
-    */
-   olsr_plugin_exit();
- 
-   return;
- }
- 
- 
- 
- /**
-  *Register needed functions and pointers
-  *
-  *This function should not be changed!
-  *
-  */
- int
- register_olsr_data(struct olsr_plugin_data *data)
- {
-   /* IPversion */
-   ipversion = data->ipversion;
-   /* Main address */
-   main_addr = data->main_addr;
- 
-   /* Multi-purpose function */
-   olsr_plugin_io = data->olsr_plugin_io;
- 
-   /* Set size of IP address */
-   if(ipversion == AF_INET)
-     {
-       ipsize = sizeof(olsr_u32_t);
-     }
-   else
-     {
-       ipsize = sizeof(struct in6_addr);
-     }
- 
-   if(!fetch_olsrd_data())
-     {
-       fprintf(stderr, "Could not fetch the neccessary functions from olsrd!\n");
-       return 0;
-     }
- 
-   /* Calls the initialization function
-    * olsr_plugin_init()
-    * This function should be present in your
-    * sourcefile and all data initialization
-    * should happen there - NOT HERE!
-    */
-   if(!olsr_plugin_init())
-     {
-       fprintf(stderr, "Could not initialize plugin!\n");
-       return 0;
-     }
- 
-   return 1;
- 
- }
- 
- 
- 
- int
- fetch_olsrd_data()
- {
-   int retval = 1;
- 
- 
-   /* Olsr debug output function */
-   if(!olsr_plugin_io(GETF__OLSR_PRINTF, 
- 		     &olsr_printf, 
- 		     sizeof(olsr_printf)))
-   {
-     olsr_printf = NULL;
-     retval = 0;
-   }
- 
-   /* Scheduler event registration */
-   if(!olsr_plugin_io(GETF__OLSR_REGISTER_SCHEDULER_EVENT, 
- 		     &olsr_register_scheduler_event, 
- 		     sizeof(olsr_register_scheduler_event)))
-   {
-     olsr_register_scheduler_event = NULL;
-     retval = 0;
-   }
- 
- 
-   /* Add hna net IPv4 */
-   if(!olsr_plugin_io(GETF__ADD_LOCAL_HNA4_ENTRY, &add_local_hna4_entry, sizeof(add_local_hna4_entry)))
-   {
-     add_local_hna4_entry = NULL;
-     retval = 0;
-   }
- 
-   /* Remove hna net IPv4 */
-   if(!olsr_plugin_io(GETF__REMOVE_LOCAL_HNA4_ENTRY, &remove_local_hna4_entry, sizeof(remove_local_hna4_entry)))
-   {
-     remove_local_hna4_entry = NULL;
-     retval = 0;
-   }
- 
-   return retval;
- 
- }
--- 82,83 ----




More information about the Olsr-cvs mailing list