[Olsr-cvs] olsrd-current/lib/httpinfo/src admin_interface.c, 1.5, 1.6 olsrd_httpinfo.c, 1.52, 1.53 olsrd_httpinfo.h, 1.27, 1.28 olsrd_plugin.c, 1.11, 1.12 olsrd_plugin.h, 1.19, 1.20

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


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

Modified Files:
	admin_interface.c olsrd_httpinfo.c olsrd_httpinfo.h 
	olsrd_plugin.c 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_httpinfo.c
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/lib/httpinfo/src/olsrd_httpinfo.c,v
retrieving revision 1.52
retrieving revision 1.53
diff -C2 -d -r1.52 -r1.53
*** olsrd_httpinfo.c	20 Apr 2005 17:52:11 -0000	1.52
--- olsrd_httpinfo.c	29 May 2005 12:47:41 -0000	1.53
***************
*** 44,54 ****
   */
  
- #include "olsrd_httpinfo.h"
- #include "olsr_cfg.h"
- #include "link_set.h"
- #include "gfx.h"
- #include "html.h"
- #include "admin_interface.h"
- #include "interfaces.h"
  #include <stdio.h>
  #include <string.h>
--- 44,47 ----
***************
*** 56,60 ****
--- 49,65 ----
  #include <unistd.h>
  #include <errno.h>
+ 
+ #include "olsr.h"
+ #include "olsr_cfg.h"
+ #include "interfaces.h"
  #include "olsr_protocol.h"
+ #include "net_olsr.h"
+ #include "link_set.h"
+ #include "socket_parser.h"
+ 
+ #include "olsrd_httpinfo.h"
+ #include "admin_interface.h"
+ #include "html.h"
+ #include "gfx.h"
  
  #ifdef OS
***************
*** 122,125 ****
--- 127,131 ----
  };
  
+ 
  static int
  get_http_socket(int);
***************
*** 229,233 ****
   */
  int
! olsr_plugin_init()
  {
    get_copyright_string();
--- 235,239 ----
   */
  int
! olsrd_plugin_init()
  {
    get_copyright_string();
***************
*** 653,672 ****
  
  
- /* Mulitpurpose funtion */
- int
- plugin_io(int cmd, void *data, size_t size)
- {
- 
-   switch(cmd)
-     {
-     default:
-       return 0;
-     }
-   
-   return 1;
- 
- }
- 
- 
  static int
  build_frame(char *title, 
--- 659,662 ----
***************
*** 707,712 ****
    for(index = 0;index < HASHSIZE;index++)
      {
!       for(routes = host_routes[index].next;
! 	  routes != &host_routes[index];
  	  routes = routes->next)
  	{
--- 697,702 ----
    for(index = 0;index < HASHSIZE;index++)
      {
!       for(routes = routingtable[index].next;
! 	  routes != &routingtable[index];
  	  routes = routes->next)
  	{
***************
*** 782,816 ****
      size += sprintf(&buf[size], "<table width=\"100%%\" border=0>\n<tr>");
  
!     size += sprintf(&buf[size], "<td>Main address: <b>%s</b></td>\n", olsr_ip_to_string(main_addr));
      
!     size += sprintf(&buf[size], "<td>IP version: %d</td>\n", cfg->ip_version == AF_INET ? 4 : 6);
  
!     size += sprintf(&buf[size], "<td>Debug level: %d</td>\n", cfg->debug_level);
  
      size += sprintf(&buf[size], "</tr>\n<tr>\n");
  
!     size += sprintf(&buf[size], "<td>Pollrate: %0.2f</td>\n", cfg->pollrate);
!     size += sprintf(&buf[size], "<td>TC redundancy: %d</td>\n", cfg->tc_redundancy);
!     size += sprintf(&buf[size], "<td>MPR coverage: %d</td>\n", cfg->mpr_coverage);
  
  
      size += sprintf(&buf[size], "</tr>\n<tr>\n");
  
!     size += sprintf(&buf[size], "<td>TOS: 0x%04x</td>\n", cfg->tos);
  
!     size += sprintf(&buf[size], "<td>Willingness: %d %s</td>\n", cfg->willingness, cfg->willingness_auto ? "(auto)" : "");
      
      size += sprintf(&buf[size], "</tr>\n<tr>\n");
  
!     size += sprintf(&buf[size], "<td>Hysteresis: %s</td>\n", cfg->use_hysteresis ? "Enabled" : "Disabled");
  	
!     size += sprintf(&buf[size], "<td>Hyst scaling: %0.2f</td>\n", cfg->hysteresis_param.scaling);
!     size += sprintf(&buf[size], "<td>Hyst lower/upper: %0.2f/%0.2f</td>\n", cfg->hysteresis_param.thr_low, cfg->hysteresis_param.thr_high);
  
      size += sprintf(&buf[size], "</tr>\n<tr>\n");
  
!     size += sprintf(&buf[size], "<td>LQ extention: %s</td>\n", cfg->lq_level ? "Enabled" : "Disabled");
!     size += sprintf(&buf[size], "<td>LQ level: %d</td>\n", cfg->lq_level);
!     size += sprintf(&buf[size], "<td>LQ winsize: %d</td>\n", cfg->lq_wsize);
      size += sprintf(&buf[size], "<td></td>\n");
  
--- 772,806 ----
      size += sprintf(&buf[size], "<table width=\"100%%\" border=0>\n<tr>");
  
!     size += sprintf(&buf[size], "<td>Main address: <b>%s</b></td>\n", olsr_ip_to_string(&main_addr));
      
!     size += sprintf(&buf[size], "<td>IP version: %d</td>\n", olsr_cnf->ip_version == AF_INET ? 4 : 6);
  
!     size += sprintf(&buf[size], "<td>Debug level: %d</td>\n", olsr_cnf->debug_level);
  
      size += sprintf(&buf[size], "</tr>\n<tr>\n");
  
!     size += sprintf(&buf[size], "<td>Pollrate: %0.2f</td>\n", olsr_cnf->pollrate);
!     size += sprintf(&buf[size], "<td>TC redundancy: %d</td>\n", olsr_cnf->tc_redundancy);
!     size += sprintf(&buf[size], "<td>MPR coverage: %d</td>\n", olsr_cnf->mpr_coverage);
  
  
      size += sprintf(&buf[size], "</tr>\n<tr>\n");
  
!     size += sprintf(&buf[size], "<td>TOS: 0x%04x</td>\n", olsr_cnf->tos);
  
!     size += sprintf(&buf[size], "<td>Willingness: %d %s</td>\n", olsr_cnf->willingness, olsr_cnf->willingness_auto ? "(auto)" : "");
      
      size += sprintf(&buf[size], "</tr>\n<tr>\n");
  
!     size += sprintf(&buf[size], "<td>Hysteresis: %s</td>\n", olsr_cnf->use_hysteresis ? "Enabled" : "Disabled");
  	
!     size += sprintf(&buf[size], "<td>Hyst scaling: %0.2f</td>\n", olsr_cnf->hysteresis_param.scaling);
!     size += sprintf(&buf[size], "<td>Hyst lower/upper: %0.2f/%0.2f</td>\n", olsr_cnf->hysteresis_param.thr_low, olsr_cnf->hysteresis_param.thr_high);
  
      size += sprintf(&buf[size], "</tr>\n<tr>\n");
  
!     size += sprintf(&buf[size], "<td>LQ extention: %s</td>\n", olsr_cnf->lq_level ? "Enabled" : "Disabled");
!     size += sprintf(&buf[size], "<td>LQ level: %d</td>\n", olsr_cnf->lq_level);
!     size += sprintf(&buf[size], "<td>LQ winsize: %d</td>\n", olsr_cnf->lq_wsize);
      size += sprintf(&buf[size], "<td></td>\n");
  
***************
*** 823,827 ****
  
  
!     for(ifs = cfg->interfaces; ifs; ifs = ifs->next)
        {
  	struct interface *rifs = ifs->interf;
--- 813,817 ----
  
  
!     for(ifs = olsr_cnf->interfaces; ifs; ifs = ifs->next)
        {
  	struct interface *rifs = ifs->interf;
***************
*** 834,838 ****
  	  }
  	
! 	if(cfg->ip_version == AF_INET)
  	  {
  	    size += sprintf(&buf[size], "<tr><td>IP: %s</td>\n", 
--- 824,828 ----
  	  }
  	
! 	if(olsr_cnf->ip_version == AF_INET)
  	  {
  	    size += sprintf(&buf[size], "<tr><td>IP: %s</td>\n", 
***************
*** 860,864 ****
      size += sprintf(&buf[size], "</table>\n");
  
!     if(cfg->allow_no_interfaces)
        size += sprintf(&buf[size], "<i>Olsrd is configured to run even if no interfaces are available</i><br>\n");
      else
--- 850,854 ----
      size += sprintf(&buf[size], "</table>\n");
  
!     if(olsr_cnf->allow_no_interfaces)
        size += sprintf(&buf[size], "<i>Olsrd is configured to run even if no interfaces are available</i><br>\n");
      else
***************
*** 869,873 ****
      size += sprintf(&buf[size], "<table width=\"100%%\" border=0><tr><th>Name</th><th>Parameters</th></tr>\n");
  
!     for(pentry = cfg->plugins; pentry; pentry = pentry->next)
        {
  	size += sprintf(&buf[size], "<tr><td>%s</td>\n", pentry->name);
--- 859,863 ----
      size += sprintf(&buf[size], "<table width=\"100%%\" border=0><tr><th>Name</th><th>Parameters</th></tr>\n");
  
!     for(pentry = olsr_cnf->plugins; pentry; pentry = pentry->next)
        {
  	size += sprintf(&buf[size], "<tr><td>%s</td>\n", pentry->name);
***************
*** 889,893 ****
  
  
!     if((cfg->ip_version == AF_INET) && (cfg->hna4_entries))
        {
  	struct hna4_entry *hna4;
--- 879,883 ----
  
  
!     if((olsr_cnf->ip_version == AF_INET) && (olsr_cnf->hna4_entries))
        {
  	struct hna4_entry *hna4;
***************
*** 896,900 ****
  	size += sprintf(&buf[size], "<table width=\"100%%\" BORDER=0 CELLSPACING=0 CELLPADDING=0 ALIGN=center><tr><th>Network</th><th>Netmask</th></tr>\n");
  	
! 	for(hna4 = cfg->hna4_entries; hna4; hna4 = hna4->next)
  	  {
  	    size += sprintf(&buf[size], "<tr><td>%s</td><td>%s</td></tr>\n", 
--- 886,890 ----
  	size += sprintf(&buf[size], "<table width=\"100%%\" BORDER=0 CELLSPACING=0 CELLPADDING=0 ALIGN=center><tr><th>Network</th><th>Netmask</th></tr>\n");
  	
! 	for(hna4 = olsr_cnf->hna4_entries; hna4; hna4 = hna4->next)
  	  {
  	    size += sprintf(&buf[size], "<tr><td>%s</td><td>%s</td></tr>\n", 
***************
*** 905,909 ****
  	size += sprintf(&buf[size], "</table>\n");
        }
!     else if((cfg->ip_version == AF_INET6) && (cfg->hna6_entries))
        {
  	struct hna6_entry *hna6;
--- 895,899 ----
  	size += sprintf(&buf[size], "</table>\n");
        }
!     else if((olsr_cnf->ip_version == AF_INET6) && (olsr_cnf->hna6_entries))
        {
  	struct hna6_entry *hna6;
***************
*** 912,916 ****
  	size += sprintf(&buf[size], "<table width=\"100%%\" BORDER=0 CELLSPACING=0 CELLPADDING=0 ALIGN=center><tr><th>Network</th><th>Prefix length</th></tr>\n");
  	
! 	for(hna6 = cfg->hna6_entries; hna6; hna6 = hna6->next)
  	  {
  	    size += sprintf(&buf[size], "<tr><td>%s</td><td>%d</td></tr>\n", 
--- 902,906 ----
  	size += sprintf(&buf[size], "<table width=\"100%%\" BORDER=0 CELLSPACING=0 CELLPADDING=0 ALIGN=center><tr><th>Network</th><th>Prefix length</th></tr>\n");
  	
! 	for(hna6 = olsr_cnf->hna6_entries; hna6; hna6 = hna6->next)
  	  {
  	    size += sprintf(&buf[size], "<tr><td>%s</td><td>%d</td></tr>\n", 
***************
*** 940,945 ****
  
    /* Link set */
!   if(olsr_plugin_io(GETD__LINK_SET, &link, sizeof(link)) && link)
!   {
      while(link)
        {
--- 930,934 ----
  
    /* Link set */
!   link = link_set;
      while(link)
        {
***************
*** 956,960 ****
  	link = link->next;
        }
-   }
  
    size += sprintf(&buf[size], "</table>\n");
--- 945,948 ----
***************
*** 1182,1186 ****
      }
  
!   size += olsrd_write_cnf_buf(cfg, &buf[size], bufsize-size);
    
    if(size < 0)
--- 1170,1174 ----
      }
  
!   size += olsrd_write_cnf_buf(olsr_cnf, &buf[size], bufsize-size);
    
    if(size < 0)
***************
*** 1230,1273 ****
  
  /**
-  *Converts a olsr_ip_addr to a string
-  *Goes for both IPv4 and IPv6
-  *
-  *@param the IP to convert
-  *@return a pointer to a static string buffer
-  *representing the address in "dots and numbers"
-  *
-  */
- char *
- olsr_ip_to_string(union olsr_ip_addr *addr)
- {
-   static int index = 0;
-   static char buff[4][100];
-   char *ret;
-   struct in_addr in;
-  
-   if(ipversion == AF_INET)
-     {
-       in.s_addr=addr->v4;
-       ret = inet_ntoa(in);
-     }
-   else
-     {
-       /* IPv6 */
-       ret = (char *)inet_ntop(AF_INET6, &addr->v6, ipv6_buf, sizeof(ipv6_buf));
-     }
- 
-   strncpy(buff[index], ret, 100);
- 
-   ret = buff[index];
- 
-   index = (index + 1) & 3;
- 
-   return ret;
- }
- 
- 
- 
- 
- /**
   *This function is just as bad as the previous one :-(
   */
--- 1218,1221 ----
***************
*** 1279,1283 ****
    static char netmask[5];
  
!   if(ipversion == AF_INET)
      {
        in.s_addr = mask->v4;
--- 1227,1231 ----
    static char netmask[5];
  
!   if(olsr_cnf->ip_version == AF_INET)
      {
        in.s_addr = mask->v4;
***************
*** 1299,1313 ****
  
  
- char *
- sockaddr_to_string(struct sockaddr *address_to_convert)
- {
-   struct sockaddr_in           *address;
-   
-   address=(struct sockaddr_in *)address_to_convert; 
-   return(inet_ntoa(address->sin_addr));
-   
- }
- 
- 
  static char *
  get_copyright_string()
--- 1247,1250 ----

Index: olsrd_httpinfo.h
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/lib/httpinfo/src/olsrd_httpinfo.h,v
retrieving revision 1.27
retrieving revision 1.28
diff -C2 -d -r1.27 -r1.28
*** olsrd_httpinfo.h	24 Jan 2005 07:55:35 -0000	1.27
--- olsrd_httpinfo.h	29 May 2005 12:47:41 -0000	1.28
***************
*** 78,81 ****
--- 78,85 ----
  };
  
+ 
+ extern struct olsrd_config *olsr_cfg;
+ 
+ 
  char *
  olsr_ip_to_string(union olsr_ip_addr *);
***************
*** 84,87 ****
--- 88,94 ----
  olsr_netmask_to_string(union hna_netmask *);
  
+ /* Destructor function */
+ void
+ olsr_plugin_exit(void);
  
  #endif

Index: olsrd_plugin.h
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/lib/httpinfo/src/olsrd_plugin.h,v
retrieving revision 1.19
retrieving revision 1.20
diff -C2 -d -r1.19 -r1.20
*** olsrd_plugin.h	25 May 2005 16:33:24 -0000	1.19
--- olsrd_plugin.h	29 May 2005 12:47:41 -0000	1.20
***************
*** 57,61 ****
  #include <math.h>
  
- #include "olsr_plugin_io.h"
  #include "olsr_types.h"
  #include "neighbor_table.h"
--- 57,60 ----
***************
*** 71,75 ****
  #define PLUGIN_AUTHOR   "Andreas Tønnesen"
  #define MOD_DESC PLUGIN_NAME " " PLUGIN_VERSION " by " PLUGIN_AUTHOR
! #define PLUGIN_INTERFACE_VERSION 3
  
  int http_port;
--- 70,74 ----
  #define PLUGIN_AUTHOR   "Andreas Tønnesen"
  #define MOD_DESC PLUGIN_NAME " " PLUGIN_VERSION " by " PLUGIN_AUTHOR
! #define PLUGIN_INTERFACE_VERSION 4
  
  int http_port;
***************
*** 93,154 ****
  struct allowed_net    *allowed_nets;
  
- /* The lists */
- struct neighbor_entry *neighbortable;
- struct neighbor_2_entry *two_hop_neighbortable;
- struct link_entry *link_set;
- struct tc_entry *tc_table;
- struct hna_entry *hna_set;
- struct mid_entry *mid_set;
- struct rt_entry *host_routes;
- struct rt_entry *hna_routes;
- 
- 
- /* Buffer for olsr_ip_to_string */
- 
- char ipv6_buf[100]; /* buffer for IPv6 inet_htop */
- 
- /* Global config pointer */
- struct olsrd_config *cfg;
- 
- /****************************************************************************
-  *                Function pointers to functions in olsrd                   *
-  *              These allow direct access to olsrd functions                *
-  ****************************************************************************/
- 
- /* The multi-purpose funtion. All other functions are fetched trough this */
- int (*olsr_plugin_io)(int, void *, size_t);
- 
- /* Add a socket to the main olsrd select loop */
- void (*add_olsr_socket)(int, void(*)(int));
- 
- /* Lookup MPR entry */
- struct mpr_selector *(*olsr_lookup_mprs_set)(union olsr_ip_addr *);
- 
- 
- /* olsrd printf wrapper */
- int (*olsr_printf)(int, char *, ...);
- 
- /* olsrd malloc wrapper */
- void *(*olsr_malloc)(size_t, const char *);
- 
- /* Add hna net IPv4 */
- void (*add_local_hna4_entry)(union olsr_ip_addr *, union hna_netmask *);
- 
- /* Remove hna net IPv4 */
- int (*remove_local_hna4_entry)(union olsr_ip_addr *, union hna_netmask *);
- 
- /****************************************************************************
-  *                             Data from olsrd                              *
-  *           NOTE THAT POINTERS POINT TO THE DATA USED BY OLSRD!            *
-  *               NEVER ALTER DATA POINTED TO BY THESE POINTERS              * 
-  *                   UNLESS YOU KNOW WHAT YOU ARE DOING!!!                  *
-  ****************************************************************************/
- 
- /* These two are set automatically by olsrd at load time */
- int                ipversion;  /* IPversion in use */
- union olsr_ip_addr *main_addr; /* Main address */
- 
- 
- size_t             ipsize;     /* Size of the ipadresses used */
  
  /****************************************************************************
--- 92,95 ----
***************
*** 159,181 ****
  /* Initialization function */
  int
! olsr_plugin_init(void);
! 
! /* IPC initialization function */
! int
! plugin_ipc_init(void);
! 
! int
! register_olsr_param(char *, char *);
! 
! /* Destructor function */
! void
! olsr_plugin_exit(void);
  
- /* Mulitpurpose funtion */
  int
! plugin_io(int, void *, size_t);
  
  int 
! get_plugin_interface_version(void);
  
  #endif
--- 100,110 ----
  /* Initialization function */
  int
! olsrd_plugin_init(void);
  
  int
! olsrd_plugin_register_param(char *, char *);
  
  int 
! olsrd_plugin_interface_version(void);
  
  #endif

Index: admin_interface.c
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/lib/httpinfo/src/admin_interface.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** admin_interface.c	14 Mar 2005 19:38:39 -0000	1.5
--- admin_interface.c	29 May 2005 12:47:41 -0000	1.6
***************
*** 72,78 ****
  
    size += sprintf(&buf[size], admin_basic_setting_int,
! 		  "Debug level:", "debug_level", 2, cfg->debug_level);
    size += sprintf(&buf[size], admin_basic_setting_float,
! 		  "Pollrate:", "pollrate", 4, cfg->pollrate);
    size += sprintf(&buf[size], admin_basic_setting_string,
  		  "TOS:", "tos", 6, "TBD");
--- 72,78 ----
  
    size += sprintf(&buf[size], admin_basic_setting_int,
! 		  "Debug level:", "debug_level", 2, olsr_cnf->debug_level);
    size += sprintf(&buf[size], admin_basic_setting_float,
! 		  "Pollrate:", "pollrate", 4, olsr_cnf->pollrate);
    size += sprintf(&buf[size], admin_basic_setting_string,
  		  "TOS:", "tos", 6, "TBD");
***************
*** 82,103 ****
  
    size += sprintf(&buf[size], admin_basic_setting_int,
! 		  "TC redundancy:", "tc_redundancy", 1, cfg->tc_redundancy);
    size += sprintf(&buf[size], admin_basic_setting_int,
! 		  "MPR coverage:", "mpr_coverage", 1, cfg->mpr_coverage);
    size += sprintf(&buf[size], admin_basic_setting_int,
! 		  "Willingness:", "willingness", 1, cfg->willingness);
  
    size += sprintf(&buf[size], "</tr>\n");
    size += sprintf(&buf[size], "<tr>\n");
  
!   if(cfg->use_hysteresis)
      {
        size += sprintf(&buf[size], admin_basic_setting_float,
! 		      "Hyst scaling:", "hyst_scaling", 4, cfg->hysteresis_param.scaling);
  
        size += sprintf(&buf[size], admin_basic_setting_float,
! 		      "Lower thr:", "hyst_lower", 4, cfg->hysteresis_param.thr_low);
        size += sprintf(&buf[size], admin_basic_setting_float,
! 		      "Upper thr:", "hyst_upper", 4, cfg->hysteresis_param.thr_high);
      }
    else
--- 82,103 ----
  
    size += sprintf(&buf[size], admin_basic_setting_int,
! 		  "TC redundancy:", "tc_redundancy", 1, olsr_cnf->tc_redundancy);
    size += sprintf(&buf[size], admin_basic_setting_int,
! 		  "MPR coverage:", "mpr_coverage", 1, olsr_cnf->mpr_coverage);
    size += sprintf(&buf[size], admin_basic_setting_int,
! 		  "Willingness:", "willingness", 1, olsr_cnf->willingness);
  
    size += sprintf(&buf[size], "</tr>\n");
    size += sprintf(&buf[size], "<tr>\n");
  
!   if(olsr_cnf->use_hysteresis)
      {
        size += sprintf(&buf[size], admin_basic_setting_float,
! 		      "Hyst scaling:", "hyst_scaling", 4, olsr_cnf->hysteresis_param.scaling);
  
        size += sprintf(&buf[size], admin_basic_setting_float,
! 		      "Lower thr:", "hyst_lower", 4, olsr_cnf->hysteresis_param.thr_low);
        size += sprintf(&buf[size], admin_basic_setting_float,
! 		      "Upper thr:", "hyst_upper", 4, olsr_cnf->hysteresis_param.thr_high);
      }
    else
***************
*** 109,118 ****
    size += sprintf(&buf[size], "<tr>\n");
    
!   if(cfg->lq_level)
      {
        size += sprintf(&buf[size], admin_basic_setting_int,
! 		      "LQ level:", "lq_level", 1, cfg->lq_level);
        size += sprintf(&buf[size], admin_basic_setting_int,
! 		      "LQ winsize:", "lq_wsize", 2, cfg->lq_wsize);
      }
    else
--- 109,118 ----
    size += sprintf(&buf[size], "<tr>\n");
    
!   if(olsr_cnf->lq_level)
      {
        size += sprintf(&buf[size], admin_basic_setting_int,
! 		      "LQ level:", "lq_level", 1, olsr_cnf->lq_level);
        size += sprintf(&buf[size], admin_basic_setting_int,
! 		      "LQ winsize:", "lq_wsize", 2, olsr_cnf->lq_wsize);
      }
    else
***************
*** 140,148 ****
    i++;
  
!   if((cfg->ip_version == AF_INET) && (cfg->hna4_entries))
      {
        struct hna4_entry *hna4;
        
!       for(hna4 = cfg->hna4_entries; hna4; hna4 = hna4->next)
  	{
  	  size += sprintf(&buf[size], admin_frame[i], 
--- 140,148 ----
    i++;
  
!   if((olsr_cnf->ip_version == AF_INET) && (olsr_cnf->hna4_entries))
      {
        struct hna4_entry *hna4;
        
!       for(hna4 = olsr_cnf->hna4_entries; hna4; hna4 = hna4->next)
  	{
  	  size += sprintf(&buf[size], admin_frame[i], 
***************
*** 153,161 ****
  	}
      }
!   else if((cfg->ip_version == AF_INET6) && (cfg->hna6_entries))
      {
        struct hna6_entry *hna6;
  	
!       for(hna6 = cfg->hna6_entries; hna6; hna6 = hna6->next)
  	{
  	  size += sprintf(&buf[size], admin_frame[i], 
--- 153,161 ----
  	}
      }
!   else if((olsr_cnf->ip_version == AF_INET6) && (olsr_cnf->hna6_entries))
      {
        struct hna6_entry *hna6;
  	
!       for(hna6 = olsr_cnf->hna6_entries; hna6; hna6 = hna6->next)
  	{
  	  size += sprintf(&buf[size], admin_frame[i], 
***************
*** 191,195 ****
  	return -1;
  
!       cfg->debug_level = ival;
        return 1;
      }
--- 191,195 ----
  	return -1;
  
!       olsr_cnf->debug_level = ival;
        return 1;
      }
***************
*** 201,205 ****
  	return -1;
  
!       cfg->tc_redundancy = ival;
        return 1;
      }
--- 201,205 ----
  	return -1;
  
!       olsr_cnf->tc_redundancy = ival;
        return 1;
      }
***************
*** 211,215 ****
  	return -1;
  
!       cfg->mpr_coverage = ival;
        return 1;
      }
--- 211,215 ----
  	return -1;
  
!       olsr_cnf->mpr_coverage = ival;
        return 1;
      }
***************
*** 221,225 ****
  	return -1;
  
!       cfg->willingness = ival;
        return 1;
      }
--- 221,225 ----
  	return -1;
  
!       olsr_cnf->willingness = ival;
        return 1;
      }
***************
*** 231,235 ****
  	return -1;
  
!       cfg->lq_level = ival;
        return 1;
      }
--- 231,235 ----
  	return -1;
  
!       olsr_cnf->lq_level = ival;
        return 1;
      }
***************
*** 241,245 ****
  	return -1;
  
!       cfg->lq_wsize = ival;
        return 1;
      }
--- 241,245 ----
  	return -1;
  
!       olsr_cnf->lq_wsize = ival;
        return 1;
      }
***************
*** 253,257 ****
  
        printf("HYST SCALING: %f\n", fval);
!       cfg->hysteresis_param.scaling = fval;
        return 1;
      }
--- 253,257 ----
  
        printf("HYST SCALING: %f\n", fval);
!       olsr_cnf->hysteresis_param.scaling = fval;
        return 1;
      }
***************
*** 264,268 ****
  	return -1;
  
!       cfg->hysteresis_param.scaling = fval;
        return 1;
      }
--- 264,268 ----
  	return -1;
  
!       olsr_cnf->hysteresis_param.scaling = fval;
        return 1;
      }
***************
*** 275,279 ****
  	return -1;
  
!       cfg->hysteresis_param.thr_low = fval;
        return 1;
      }
--- 275,279 ----
  	return -1;
  
!       olsr_cnf->hysteresis_param.thr_low = fval;
        return 1;
      }
***************
*** 286,290 ****
  	return -1;
  
!       cfg->hysteresis_param.thr_high = fval;
        return 1;
      }
--- 286,290 ----
  	return -1;
  
!       olsr_cnf->hysteresis_param.thr_high = fval;
        return 1;
      }
***************
*** 297,301 ****
  	return -1;
  
!       cfg->pollrate = fval;
        return 1;
      }
--- 297,301 ----
  	return -1;
  
!       olsr_cnf->pollrate = fval;
        return 1;
      }

Index: olsrd_plugin.c
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/lib/httpinfo/src/olsrd_plugin.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** olsrd_plugin.c	25 May 2005 16:33:24 -0000	1.11
--- olsrd_plugin.c	29 May 2005 12:47:41 -0000	1.12
***************
*** 44,48 ****
   */
  
! 
  #include "olsrd_plugin.h"
  #include "olsr_cfg.h"
--- 44,48 ----
   */
  
! #include "olsr.h"
  #include "olsrd_plugin.h"
  #include "olsr_cfg.h"
***************
*** 50,67 ****
  #include <string.h>
  #include <stdlib.h>
! #include "plugin_loader.h"
  
! 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);
- 
  
  /*
--- 50,61 ----
  #include <string.h>
  #include <stdlib.h>
! #include "olsrd_httpinfo.h"
  
! static void __attribute__ ((constructor)) 
  my_init(void);
  
! static void __attribute__ ((destructor)) 
  my_fini(void);
  
  
  /*
***************
*** 71,75 ****
   */
  int 
! get_plugin_interface_version()
  {
    return PLUGIN_INTERFACE_VERSION;
--- 65,69 ----
   */
  int 
! olsrd_plugin_interface_version()
  {
    return PLUGIN_INTERFACE_VERSION;
***************
*** 81,85 ****
   *Constructor
   */
! void
  my_init()
  {
--- 75,79 ----
   *Constructor
   */
! static void
  my_init()
  {
***************
*** 93,97 ****
   *Destructor
   */
! void
  my_fini()
  {
--- 87,91 ----
   *Destructor
   */
! static void
  my_fini()
  {
***************
*** 108,113 ****
  }
  
  int
! register_olsr_param(char *key, char *value)
  {
    if(!strcmp(key, "port") || !strcmp(key, "Port"))
--- 102,108 ----
  }
  
+ 
  int
! olsrd_plugin_register_param(char *key, char *value)
  {
    if(!strcmp(key, "port") || !strcmp(key, "Port"))
***************
*** 173,356 ****
    return 1;
  }
- 
- /**
-  *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;
- 
-   
-   /* Neighbor table */
-   if(!olsr_plugin_io(GETD__NEIGHBORTABLE, 
- 		     &neighbortable, 
- 		     sizeof(neighbortable)))
-   {
-     neighbortable = NULL;
-     retval = 0;
-   }
-   
-   /* Two hop neighbor table */
-   if(!olsr_plugin_io(GETD__TWO_HOP_NEIGHBORTABLE, 
- 		     &two_hop_neighbortable, 
- 		     sizeof(two_hop_neighbortable)))
-   {
-     two_hop_neighbortable = NULL;
-     retval = 0;
-   }
- 
-   /* Topoloy table */
-   if(!olsr_plugin_io(GETD__TC_TABLE, 
- 		     &tc_table, 
- 		     sizeof(tc_table)))
-   {
-     tc_table = NULL;
-     retval = 0;
-   }
- 
-   /* HNA table */
-   if(!olsr_plugin_io(GETD__HNA_SET, 
- 		     &hna_set, 
- 		     sizeof(hna_set)))
-   {
-     hna_set = NULL;
-     retval = 0;
-   }
- 
-   /* MID table */
-   if(!olsr_plugin_io(GETD__MID_SET, 
- 		     &mid_set, 
- 		     sizeof(mid_set)))
-   {
-     mid_set = NULL;
-     retval = 0;
-   }
- 
- 
-   if(!olsr_plugin_io(GETD__ROUTINGTABLE,
- 		     &host_routes,
- 		     sizeof(host_routes)))
-   {
-     host_routes = NULL;
-     retval = 0;
-   }
- 
-   if(!olsr_plugin_io(GETD__HNA_ROUTES,
- 		     &hna_routes,
- 		     sizeof(hna_routes)))
-   {
-     hna_routes = NULL;
-     retval = 0;
-   }
- 
- 
-   /* Configuration */
-   if(!olsr_plugin_io(GETD__OLSR_CNF, 
- 		     &cfg, 
- 		     sizeof(cfg)))
-     {
-       cfg = NULL;
-       retval = 0;
-     }
- 
-   if(!olsr_plugin_io(GETF__OLSR_LOOKUP_MPRS_SET, 
- 		     &olsr_lookup_mprs_set, 
- 		     sizeof(olsr_lookup_mprs_set)))
-   {
-     olsr_lookup_mprs_set = NULL;
-     retval = 0;
-   }
- 
-   /* Olsr debug output function */
-   if(!olsr_plugin_io(GETF__OLSR_PRINTF, 
- 		     &olsr_printf, 
- 		     sizeof(olsr_printf)))
-   {
-     olsr_printf = NULL;
-     retval = 0;
-   }
- 
-   /* Olsr malloc wrapper */
-   if(!olsr_plugin_io(GETF__OLSR_MALLOC, 
- 		     &olsr_malloc, 
- 		     sizeof(olsr_malloc)))
-   {
-     olsr_malloc = NULL;
-     retval = 0;
-   }
- 
-   /* Add socket to OLSR select function */
-   if(!olsr_plugin_io(GETF__ADD_OLSR_SOCKET, 
- 		     &add_olsr_socket, 
- 		     sizeof(add_olsr_socket)))
-   {
-     add_olsr_socket = 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;
- 
- }
--- 168,169 ----




More information about the Olsr-cvs mailing list