[Olsr-cvs] olsrd-current/lib/tas/src http.c, 1.3, 1.4 os_unix.c, 1.2, 1.3 os_unix.h, 1.2, 1.3 plugin.c, 1.4, 1.5

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


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

Modified Files:
	http.c os_unix.c os_unix.h plugin.c 
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: os_unix.h
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/lib/tas/src/os_unix.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** os_unix.h	13 Apr 2005 22:10:23 -0000	1.2
--- os_unix.h	29 May 2005 12:47:44 -0000	1.3
***************
*** 71,75 ****
  extern int addrLen(int family);
  
! extern void now(struct timeStamp *timeStamp);
  extern int timedOut(struct timeStamp *timeStamp, int sec);
  
--- 71,75 ----
  extern int addrLen(int family);
  
! extern void os_now(struct timeStamp *timeStamp);
  extern int timedOut(struct timeStamp *timeStamp, int sec);
  

Index: http.c
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/lib/tas/src/http.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** http.c	13 Apr 2005 22:10:22 -0000	1.3
--- http.c	29 May 2005 12:47:44 -0000	1.4
***************
*** 383,387 ****
    info->data = NULL;
  
!   now(&info->time);
  
    debug(DEBUG_SESSION, "new session, id = %u\n", info->id);
--- 383,387 ----
    info->data = NULL;
  
!   os_now(&info->time);
  
    debug(DEBUG_SESSION, "new session, id = %u\n", info->id);
***************
*** 1604,1608 ****
          currSess = sess[i];
  
!         now(&currSess->time);
        }
      }
--- 1604,1608 ----
          currSess = sess[i];
  
!         os_now(&currSess->time);
        }
      }
***************
*** 1869,1873 ****
    msg->next = NULL;
  
!   now(&msg->time);
  
    msg->service = myStrdup(service);
--- 1869,1873 ----
    msg->next = NULL;
  
!   os_now(&msg->time);
  
    msg->service = myStrdup(service);

Index: plugin.c
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/lib/tas/src/plugin.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** plugin.c	13 Apr 2005 22:53:13 -0000	1.4
--- plugin.c	29 May 2005 12:47:44 -0000	1.5
***************
*** 52,57 ****
  #include "glua_ext.h"
  
! #include <olsr_plugin_io.h>
! #include <plugin_loader.h>
  #include <link_set.h>
  #include <neighbor_table.h>
--- 52,59 ----
  #include "glua_ext.h"
  
! #include <defs.h>
! #include <olsr.h>
! #include <scheduler.h>
! #include <parser.h>
  #include <link_set.h>
  #include <neighbor_table.h>
***************
*** 63,73 ****
  #include <olsr_protocol.h>
  #include <lq_route.h>
  
  #define MESSAGE_TYPE 129
  
! int get_plugin_interface_version(void);
! int plugin_io(int cmd, void *data, int len);
! int register_olsr_data(struct olsr_plugin_data *data);
! int register_olsr_param(char *name, char *value);
  
  static int ipAddrLen;
--- 65,76 ----
  #include <olsr_protocol.h>
  #include <lq_route.h>
+ #include <mpr_selector_set.h>
+ #include <duplicate_set.h>
  
  #define MESSAGE_TYPE 129
  
! int olsrd_plugin_interface_version(void);
! int olsrd_plugin_register_param(char *name, char *value);
! int olsrd_plugin_init(void);
  
  static int ipAddrLen;
***************
*** 82,105 ****
  static struct olsrd_config *config = NULL;
  
- static int (*pluginIo)(int which, void *data, int len);
- 
- static int (*regTimeout)(void (*timeoutFunc)(void));
- static int (*regParser)(void (*parserFunc)(unsigned char *mess,
-                                            struct interface *inInt,
-                                            union olsr_ip_addr *neighIntAddr),
-                         int type, int forward);
- static int (*checkLink)(union olsr_ip_addr *neighIntAddr);
- static int (*checkDup)(union olsr_ip_addr *origAddr, unsigned short seqNo);
- static int (*forward)(unsigned char *mess, union olsr_ip_addr *origAddr,
-                       unsigned short seqNo, struct interface *inInt,
-                       union olsr_ip_addr *neighIntAddr);
- 
- static unsigned short (*getSeqNo)(void);
- static int (*netPush)(struct interface *outInt, void *mess,
-                       unsigned short size);
- static int (*netOutput)(struct interface *outInt);
- 
- static void *(*lookupMprs)(union olsr_ip_addr *neighAddr);
- 
  static int iterIndex;
  static struct interface *iterIntTab = NULL;
--- 85,88 ----
***************
*** 149,159 ****
  void iterLinkTabInit(void)
  {
!   if (pluginIo == NULL)
!   {
!     iterLinkTab = NULL;
!     return;
!   }
! 
!   pluginIo(GETD__LINK_SET, &iterLinkTab, sizeof (iterLinkTab));
  }
  
--- 132,136 ----
  void iterLinkTabInit(void)
  {
!   iterLinkTab = get_link_set();
  }
  
***************
*** 172,176 ****
                   iterNeighTab->status == SYM ? "true" : "false",
                   iterNeighTab->is_mpr != 0 ? "true" : "false",
!                  lookupMprs(&iterNeighTab->neighbor_main_addr) != NULL ?
                   "true" : "false",
                   iterNeighTab->willingness);
--- 149,153 ----
                   iterNeighTab->status == SYM ? "true" : "false",
                   iterNeighTab->is_mpr != 0 ? "true" : "false",
!                  olsr_lookup_mprs_set(&iterNeighTab->neighbor_main_addr) != NULL ?
                   "true" : "false",
                   iterNeighTab->willingness);
***************
*** 362,366 ****
      return;
  
!   if (checkLink(neighIntAddr) != SYM_LINK)
    {
      error("TAS message not from symmetric neighbour\n");
--- 339,343 ----
      return;
  
!   if (check_neighbor_link(neighIntAddr) != SYM_LINK)
    {
      error("TAS message not from symmetric neighbour\n");
***************
*** 374,378 ****
    }
  
!   if (checkDup(orig, seqNo) != 0)
    {
      len -= ipAddrLen + 8;
--- 351,355 ----
    }
  
!   if (olsr_check_dup_table_proc(orig, seqNo) != 0)
    {
      len -= ipAddrLen + 8;
***************
*** 407,411 ****
    }
  
!   forward(mess, orig, seqNo, inInt, neighIntAddr);
  }
  
--- 384,388 ----
    }
  
!   olsr_forward_message((union olsr_message *)mess, orig, seqNo, inInt, neighIntAddr);
  }
  
***************
*** 425,429 ****
    walker = mess = allocMem(len);
  
!   seqNo = getSeqNo();
  
    *walker++ = MESSAGE_TYPE;
--- 402,406 ----
    walker = mess = allocMem(len);
  
!   seqNo = get_msg_seqno();
  
    *walker++ = MESSAGE_TYPE;
***************
*** 455,462 ****
    for (inter = intTab; inter != NULL; inter = inter->int_next)
    {
!     if (netPush(inter, mess, len) != len)
      {
!       netOutput(inter);
!       netPush(inter, mess, len);
      }
    }
--- 432,439 ----
    for (inter = intTab; inter != NULL; inter = inter->int_next)
    {
!     if (net_outbuffer_push(inter, mess, len) != len)
      {
!       net_output(inter);
!       net_outbuffer_push(inter, mess, len);
      }
    }
***************
*** 479,529 ****
  }
  
! int get_plugin_interface_version(void)
! {
!   httpInit();
! 
!   return 3;
! }
! 
! int plugin_io(int cmd, void *data, int len)
  {
!   return 0;
  }
  
! int register_olsr_data(struct olsr_plugin_data *data)
  {
!   ipAddrLen = addrLen(data->ipversion);
!   mainAddr = data->main_addr;
! 
!   pluginIo = (int (*)(int, void *, int))data->olsr_plugin_io;
! 
!   pluginIo(GETD__IFNET, &intTab, sizeof (intTab));
!   pluginIo(GETD__NEIGHBORTABLE, &neighTab, sizeof (neighTab));
!   pluginIo(GETD__MID_SET, &midTab, sizeof (midTab));
!   pluginIo(GETD__TC_TABLE, &tcTab, sizeof (tcTab));
!   pluginIo(GETD__HNA_SET, &hnaTab, sizeof (hnaTab));
!   pluginIo(GETD__ROUTINGTABLE, &routeTab, sizeof (routeTab));
!   pluginIo(GETD__OLSR_CNF, &config, sizeof (config));
! 
!   pluginIo(GETF__OLSR_REGISTER_TIMEOUT_FUNCTION, &regTimeout,
!            sizeof (regTimeout));
!   pluginIo(GETF__OLSR_PARSER_ADD_FUNCTION, &regParser, sizeof (regParser));
!   pluginIo(GETF__CHECK_NEIGHBOR_LINK, &checkLink, sizeof (checkLink));
!   pluginIo(GETF__OLSR_CHECK_DUP_TABLE_PROC, &checkDup, sizeof (checkDup));
!   pluginIo(GETF__OLSR_FORWARD_MESSAGE, &forward, sizeof (forward));
! 
!   pluginIo(GETF__GET_MSG_SEQNO, &getSeqNo, sizeof (getSeqNo));
!   pluginIo(GETF__NET_OUTBUFFER_PUSH, &netPush, sizeof (netPush));
!   pluginIo(GETF__NET_OUTPUT, &netOutput, sizeof (netOutput));
  
!   pluginIo(GETF__OLSR_LOOKUP_MPRS_SET, &lookupMprs, sizeof (lookupMprs));
  
!   regTimeout(serviceFunc);
!   regParser(parserFunc, MESSAGE_TYPE, 1);
  
    return 0;
  }
  
! int register_olsr_param(char *name, char *value)
  {
    if (strcmp(name, "address") == 0)
--- 456,486 ----
  }
  
! int olsrd_plugin_interface_version(void)
  {
!   return 4;
  }
  
! int olsrd_plugin_init()
  {
!   ipAddrLen = ipsize;
!   mainAddr = &main_addr;
  
!   intTab = ifnet;
!   neighTab = neighbortable;
!   midTab = mid_set;
!   tcTab = tc_table;
!   hnaTab = hna_set;
!   routeTab = routingtable;
!   config = olsr_cnf;
  
!   httpInit();
!   
!   olsr_register_timeout_function(serviceFunc);
!   olsr_parser_add_function(parserFunc, MESSAGE_TYPE, 1);
  
    return 0;
  }
  
! int olsrd_plugin_register_param(char *name, char *value)
  {
    if (strcmp(name, "address") == 0)

Index: os_unix.c
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/lib/tas/src/os_unix.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** os_unix.c	13 Apr 2005 22:10:23 -0000	1.2
--- os_unix.c	29 May 2005 12:47:44 -0000	1.3
***************
*** 82,86 ****
  }
  
! void now(struct timeStamp *timeStamp)
  {
    time((time_t *)&timeStamp->time);
--- 82,86 ----
  }
  
! void os_now(struct timeStamp *timeStamp)
  {
    time((time_t *)&timeStamp->time);




More information about the Olsr-cvs mailing list