[Olsr-cvs] olsrd-current/lib/pgraph/src olsrd_pgraph.c, 1.6, 1.7 olsrd_pgraph.h, 1.2, 1.3 olsrd_plugin.c, 1.2, NONE

Bernd Petrovitsch (spam-protected)
Fri Aug 31 00:49:15 CEST 2007


Update of /cvsroot/olsrd/olsrd-current/lib/pgraph/src
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv19006/lib/pgraph/src

Modified Files:
	olsrd_pgraph.c olsrd_pgraph.h 
Removed Files:
	olsrd_plugin.c 
Log Message:
* converted to interface version 5 and simplified a little bit

Index: olsrd_pgraph.h
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/lib/pgraph/src/olsrd_pgraph.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** olsrd_pgraph.h	20 Apr 2007 13:46:03 -0000	1.2
--- olsrd_pgraph.h	30 Aug 2007 22:49:12 -0000	1.3
***************
*** 71,90 ****
  #include "link_set.h"
  
! extern struct in_addr ipc_accept_ip;
! extern int ipc_port;
! 
! extern char netmask[5];
! 
! /* Event function to register with the sceduler */
! int
! pcf_event(int, int, int);
! 
! void
! ipc_action(int);
! 
! char *
! olsr_netmask_to_string(union hna_netmask *);
  
! struct link_entry *olsr_neighbor_best_link(union olsr_ip_addr *main);
  
  #endif
--- 71,77 ----
  #include "link_set.h"
  
! void olsrd_get_plugin_parameters(const struct olsrd_plugin_parameters **params, int *size);
  
! int olsrd_plugin_interface_version(void);
  
  #endif

Index: olsrd_pgraph.c
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/lib/pgraph/src/olsrd_pgraph.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** olsrd_pgraph.c	2 Aug 2007 14:38:34 -0000	1.6
--- olsrd_pgraph.c	30 Aug 2007 22:49:12 -0000	1.7
***************
*** 47,50 ****
--- 47,52 ----
  #include "olsrd_pgraph.h"
  #include "socket_parser.h"
+ #include "olsrd_plugin.h"
+ #include "plugin_util.h"
  
  #include <stdio.h>
***************
*** 57,91 ****
  #endif
  
  static int ipc_socket;
- static int ipc_open;
  static int ipc_connection;
- static int ipc_socket_up;
  
! static void
! ipc_print_neigh_link(struct neighbor_entry *neighbor);
  
! static void
! ipc_print_tc_link(struct tc_entry *entry, struct topo_dst *dst_entry);
  
  #if 0
! static void
! ipc_print_net(union olsr_ip_addr *, union olsr_ip_addr *, union hna_netmask *);
  #endif
  
! static int
! ipc_send(const char *, int);
  
! static void
! ipc_print_neigh_link(struct neighbor_entry *);
  
! static int
! plugin_ipc_init(void);
  
! void
! olsr_plugin_exit(void);
  
  
! static void
! ipc_print_neigh_link(struct neighbor_entry *neighbor)
  {
    char buf[256];
--- 59,163 ----
  #endif
  
+ #define PLUGIN_NAME    "OLSRD pgraph plugin"
+ #define PLUGIN_VERSION "0.1"
+ #define PLUGIN_AUTHOR   "Richard Gopaul"
+ #define MOD_DESC PLUGIN_NAME " " PLUGIN_VERSION " by " PLUGIN_AUTHOR
+ #define PLUGIN_INTERFACE_VERSION 5
+ 
+ static union olsr_ip_addr ipc_accept_ip;
+ static int ipc_port;
+ 
  static int ipc_socket;
  static int ipc_connection;
  
! void my_init(void) __attribute__((constructor));
  
! void my_fini(void) __attribute__((destructor));
! 
! /*
!  * Defines the version of the plugin interface that is used
!  * THIS IS NOT THE VERSION OF YOUR PLUGIN!
!  * Do not alter unless you know what you are doing!
!  */
! int 
! olsrd_plugin_interface_version(void)
! {
!    return PLUGIN_INTERFACE_VERSION;
! }
! 
! 
! /**
!  *Constructor
!  */
! void
! my_init(void)
! {
!   /* Print plugin info to stdout */
!   printf("%s\n", MOD_DESC);
! 
!   /* defaults for parameters */
!   ipc_port = 2004;
!   if (olsr_cnf->ip_version == AF_INET) {
!     ipc_accept_ip.v4 = htonl(INADDR_LOOPBACK);
!   } else {
!     ipc_accept_ip.v6 = in6addr_loopback;
!   }
!   ipc_socket = -1;
!   ipc_connection = -1;
! }
! 
! /**
!  *Destructor
!  */
! void
! my_fini(void)
! {
!   if(ipc_socket >= 0) {
!     close(ipc_socket);
!     ipc_socket = -1;
!   }
!   if(ipc_connection >= 0) {
!     close(ipc_connection);
!     ipc_connection = -1;
!   }
! 
! }
! 
! static const struct olsrd_plugin_parameters plugin_parameters[] = {
!     { .name = "port",   .set_plugin_parameter = &set_plugin_port,      .data = &ipc_port },
!     { .name = "accept", .set_plugin_parameter = &set_plugin_ipaddress, .data = &ipc_accept_ip },
! };
! 
! void olsrd_get_plugin_parameters(const struct olsrd_plugin_parameters **params, int *size)
! {
!     *params = plugin_parameters;
!     *size = sizeof(plugin_parameters)/sizeof(*plugin_parameters);
! }
! 
! /* Event function to register with the sceduler */
! static int pcf_event(int, int, int);
! 
! static void ipc_action(int);
  
  #if 0
! static struct link_entry *olsr_neighbor_best_link(union olsr_ip_addr *main);
  #endif
  
! static void ipc_print_neigh_link(struct neighbor_entry *neighbor);
  
! static void ipc_print_tc_link(struct tc_entry *entry, struct topo_dst *dst_entry);
  
! #if 0
! static void ipc_print_net(union olsr_ip_addr *, union olsr_ip_addr *, union hna_netmask *);
! #endif
  
! static int ipc_send(const char *, int);
  
+ static void ipc_print_neigh_link(struct neighbor_entry *);
  
! static int plugin_ipc_init(void);
! 
! 
! static void ipc_print_neigh_link(struct neighbor_entry *neighbor)
  {
    char buf[256];
***************
*** 134,144 ****
   *function in uolsrd_plugin.c
   */
! int
! olsrd_plugin_init(void)
  {
  
    /* Initial IPC value */
!   ipc_open = 0;
!   ipc_socket_up = 0;
  
    /* Register the "ProcessChanges" function */
--- 206,214 ----
   *function in uolsrd_plugin.c
   */
! int olsrd_plugin_init(void)
  {
  
    /* Initial IPC value */
!   ipc_socket = -1;
  
    /* Register the "ProcessChanges" function */
***************
*** 148,153 ****
  }
  
! static int
! plugin_ipc_init(void)
  {
    struct sockaddr_in sin;
--- 218,222 ----
  }
  
! static int plugin_ipc_init(void)
  {
    struct sockaddr_in sin;
***************
*** 171,175 ****
        if (setsockopt(ipc_socket, SOL_SOCKET, SO_NOSIGPIPE, (char *)&yes, sizeof(yes)) < 0) 
        {
! 	perror("SO_REUSEADDR failed");
  	return 0;
        }
--- 240,244 ----
        if (setsockopt(ipc_socket, SOL_SOCKET, SO_NOSIGPIPE, (char *)&yes, sizeof(yes)) < 0) 
        {
! 	perror("SO_NOSIGPIPE failed");
  	return 0;
        }
***************
*** 201,205 ****
        /* Register with olsrd */
        add_olsr_socket(ipc_socket, &ipc_action);
-       ipc_socket_up = 1;
      }
  
--- 270,273 ----
***************
*** 207,212 ****
  }
  
! void
! ipc_action(int fd __attribute__((unused)))
  {
    struct sockaddr_in pin;
--- 275,279 ----
  }
  
! static void ipc_action(int fd __attribute__((unused)))
  {
    struct sockaddr_in pin;
***************
*** 236,240 ****
  	{
  */
- 	  ipc_open = 1;
  	  olsr_printf(1, "(DOT DRAW)IPC: Connection from %s\n",addr);
            len = sprintf(buf, "add node %s\n", olsr_ip_to_string(&olsr_cnf->main_addr));
--- 303,306 ----
***************
*** 246,268 ****
  }
  
- /*
-  * destructor - called at unload
-  */
- void
- olsr_plugin_exit(void)
- {
-   if(ipc_open)
-     close(ipc_socket);
- }
- 
- 
- 
  /**
   *Scheduled event
   */
! int
! pcf_event(int changes_neighborhood,
! 	  int changes_topology,
! 	  int changes_hna __attribute__((unused)))
  {
    int res;
--- 312,321 ----
  }
  
  /**
   *Scheduled event
   */
! static int pcf_event(int changes_neighborhood,
!                      int changes_topology,
!                      int changes_hna __attribute__((unused)))
  {
    int res;
***************
*** 341,345 ****
  
  
!   if(!ipc_socket_up)
      plugin_ipc_init();
  
--- 394,398 ----
  
  
!   if(ipc_socket == -1)
      plugin_ipc_init();
  
***************
*** 349,354 ****
  #if 0
  #define MIN_LINK_QUALITY 0.01
! static double 
! calc_etx(double loss, double neigh_loss) 
  {
    if (loss < MIN_LINK_QUALITY || neigh_loss < MIN_LINK_QUALITY)
--- 402,406 ----
  #if 0
  #define MIN_LINK_QUALITY 0.01
! static double calc_etx(double loss, double neigh_loss) 
  {
    if (loss < MIN_LINK_QUALITY || neigh_loss < MIN_LINK_QUALITY)
***************
*** 359,364 ****
  #endif
  
! static void
! ipc_print_tc_link(struct tc_entry *entry, struct topo_dst *dst_entry)
  {
    char buf[256];
--- 411,415 ----
  #endif
  
! static void ipc_print_tc_link(struct tc_entry *entry, struct topo_dst *dst_entry)
  {
    char buf[256];
***************
*** 402,420 ****
  
  
! static int
! ipc_send(const char *data, int size)
  {
!   if(!ipc_open)
      return 0;
  
  #if defined __FreeBSD__ || defined __MacOSX__
!   if (send(ipc_connection, data, size, 0) < 0) 
  #else
!   if (send(ipc_connection, data, size, MSG_NOSIGNAL) < 0) 
  #endif
      {
        olsr_printf(1, "(DOT DRAW)IPC connection lost!\n");
        close(ipc_connection);
!       ipc_open = 0;
        return -1;
      }
--- 453,471 ----
  
  
! static int ipc_send(const char *data, int size)
  {
!   if(ipc_connection == -1)
      return 0;
  
  #if defined __FreeBSD__ || defined __MacOSX__
! #define FLAG 0
  #else
! #define FLAG MSG_NOSIGNAL
  #endif
+   if (send(ipc_connection, data, size, FLAG) < 0) 
      {
        olsr_printf(1, "(DOT DRAW)IPC connection lost!\n");
        close(ipc_connection);
!       ipc_connection = -1;
        return -1;
      }
***************
*** 423,428 ****
  }
  
! 
! struct link_entry *olsr_neighbor_best_link(union olsr_ip_addr *main)
  {
    struct link_entry *walker;
--- 474,479 ----
  }
  
! #if 0
! static struct link_entry *olsr_neighbor_best_link(union olsr_ip_addr *main)
  {
    struct link_entry *walker;
***************
*** 451,453 ****
    return res;
  }
! 
--- 502,504 ----
    return res;
  }
! #endif

--- olsrd_plugin.c DELETED ---





More information about the Olsr-cvs mailing list