[Olsr-cvs] olsrd-current/lib/nameservice/src compat.c, NONE, 1.1 compat.h, NONE, 1.1 nameservice.c, 1.13, 1.14 nameservice.h, 1.7, 1.8 olsrd_copy.c, 1.3, 1.4 olsrd_copy.h, 1.4, 1.5 olsrd_plugin.c, 1.10, 1.11 olsrd_plugin.h, 1.9, NONE

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


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

Modified Files:
	nameservice.c nameservice.h olsrd_copy.c olsrd_copy.h 
	olsrd_plugin.c 
Added Files:
	compat.c compat.h 
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_copy.h
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/lib/nameservice/src/olsrd_copy.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** olsrd_copy.h	20 Apr 2005 17:57:00 -0000	1.4
--- olsrd_copy.h	29 May 2005 12:47:42 -0000	1.5
***************
*** 39,46 ****
  #define _OLSRD_COPY
  
! // these functions are copied from the main olsrd source
! // TODO: there must be a better way!!!
  
! olsr_u32_t olsr_hashing(union olsr_ip_addr *address);
  
  int olsr_timed_out(struct timeval *timer);
--- 39,46 ----
  #define _OLSRD_COPY
  
! #include <sys/time.h>
! #include <time.h>
  
! #include "olsr_types.h"
  
  int olsr_timed_out(struct timeval *timer);
***************
*** 50,57 ****
  void olsr_get_timestamp(olsr_u32_t delay, struct timeval *hold_timer);
  
- char * olsr_ip_to_string(union olsr_ip_addr *addr);
- 
- struct rt_entry *
- olsr_lookup_routing_table(union olsr_ip_addr *dst);
  
  #endif
--- 50,53 ----

--- NEW FILE: compat.h ---
#ifndef _NAMESERVICE_COMPAT
#define _NAMESERVICE_COMPAT

#include <sys/types.h>

char *
strndup(const char *ptr, size_t size);

#endif

Index: nameservice.c
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/lib/nameservice/src/nameservice.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** nameservice.c	25 May 2005 13:43:30 -0000	1.13
--- nameservice.c	29 May 2005 12:47:42 -0000	1.14
***************
*** 40,48 ****
  #include <stdlib.h>
  #include <unistd.h>
- #include "nameservice.h"
- #include "olsrd_copy.h"
  
  #include "routing_table.h"
  #include "mantissa.h"
  
  /* send buffer: huge */
--- 40,56 ----
  #include <stdlib.h>
  #include <unistd.h>
  
+ #include "olsr.h"
+ #include "net_olsr.h"
  #include "routing_table.h"
  #include "mantissa.h"
+ #include "scheduler.h"
+ #include "parser.h"
+ #include "duplicate_set.h"
+ #include "link_set.h"
+ 
+ #include "nameservice.h"
+ #include "olsrd_copy.h"
+ #include "compat.h"
  
  /* send buffer: huge */
***************
*** 105,109 ****
   */
  int
! register_olsr_param(char *key, char *value)
  {
  	if(!strcmp(key, "interval")) {
--- 113,117 ----
   */
  int
! olsrd_plugin_register_param(char *key, char *value)
  {
  	if(!strcmp(key, "interval")) {
***************
*** 200,204 ****
   */
  int
! olsr_plugin_init()
  {
  	struct name_entry *name;
--- 208,212 ----
   */
  int
! name_init()
  {
  	struct name_entry *name;
***************
*** 209,213 ****
  		if (name->ip.v4 == 0) {
  			// insert main_addr
! 			memcpy(&name->ip, main_addr, ipsize);
  			prev = name;
  		} else {
--- 217,221 ----
  		if (name->ip.v4 == 0) {
  			// insert main_addr
! 			memcpy(&name->ip, &main_addr, ipsize);
  			prev = name;
  		} else {
***************
*** 232,236 ****
  	if (have_dns_server) {
  		if (my_dns_server.v4 == 0) {
! 			memcpy(&my_dns_server, main_addr, ipsize);
  			printf("\nNAME PLUGIN: announcing upstream DNS server: %s\n", 
  				olsr_ip_to_string(&my_dns_server));
--- 240,244 ----
  	if (have_dns_server) {
  		if (my_dns_server.v4 == 0) {
! 			memcpy(&my_dns_server, &main_addr, ipsize);
  			printf("\nNAME PLUGIN: announcing upstream DNS server: %s\n", 
  				olsr_ip_to_string(&my_dns_server));
***************
*** 261,265 ****
   */
  void
! olsr_plugin_exit()
  {
  	int i;
--- 269,273 ----
   */
  void
! name_destructor()
  {
  	int i;
***************
*** 337,351 ****
    
  	/* looping trough interfaces */
! 	for (ifn = ifs; ifn ; ifn = ifn->int_next) 
  	{
  		olsr_printf(3, "NAME PLUGIN: Generating packet - [%s]\n", ifn->int_name);
  
  		/* fill message */
! 		if(ipversion == AF_INET)
  		{
  			/* IPv4 */
  			message->v4.olsr_msgtype = MESSAGE_TYPE;
  			message->v4.olsr_vtime = double_to_me(my_timeout);
! 			memcpy(&message->v4.originator, main_addr, ipsize);
  			message->v4.ttl = MAX_TTL;
  			message->v4.hopcnt = 0;
--- 345,359 ----
    
  	/* looping trough interfaces */
! 	for (ifn = ifnet; ifn ; ifn = ifn->int_next) 
  	{
  		olsr_printf(3, "NAME PLUGIN: Generating packet - [%s]\n", ifn->int_name);
  
  		/* fill message */
! 		if(olsr_cnf->ip_version == AF_INET)
  		{
  			/* IPv4 */
  			message->v4.olsr_msgtype = MESSAGE_TYPE;
  			message->v4.olsr_vtime = double_to_me(my_timeout);
! 			memcpy(&message->v4.originator, &main_addr, ipsize);
  			message->v4.ttl = MAX_TTL;
  			message->v4.hopcnt = 0;
***************
*** 362,366 ****
  			message->v6.olsr_msgtype = MESSAGE_TYPE;
  			message->v6.olsr_vtime = double_to_me(my_timeout);
! 			memcpy(&message->v6.originator, main_addr, ipsize);
  			message->v6.ttl = MAX_TTL;
  			message->v6.hopcnt = 0;
--- 370,374 ----
  			message->v6.olsr_msgtype = MESSAGE_TYPE;
  			message->v6.olsr_vtime = double_to_me(my_timeout);
! 			memcpy(&message->v6.originator, &main_addr, ipsize);
  			message->v6.ttl = MAX_TTL;
  			message->v6.hopcnt = 0;
***************
*** 399,403 ****
  		
  	/* Fetch the message based on IP version */
! 	if(ipversion == AF_INET) {
  		vtime = ME_TO_DOUBLE(m->v4.olsr_vtime);
  		size = ntohs(m->v4.olsr_msgsize);
--- 407,411 ----
  		
  	/* Fetch the message based on IP version */
! 	if(olsr_cnf->ip_version == AF_INET) {
  		vtime = ME_TO_DOUBLE(m->v4.olsr_vtime);
  		size = ntohs(m->v4.olsr_msgsize);
***************
*** 412,416 ****
  	/* Check if message originated from this node. 
  	If so - back off */
! 	if(memcmp(&originator, main_addr, ipsize) == 0)
  		return;
  
--- 420,424 ----
  	/* Check if message originated from this node. 
  	If so - back off */
! 	if(memcmp(&originator, &main_addr, ipsize) == 0)
  		return;
  
***************
*** 426,430 ****
  	* processed if nessecary
  	*/
! 	if(!check_dup_proc(&originator, ntohs(m->v4.seqno))) {
  		/* If so - do not process */
  		goto forward;
--- 434,438 ----
  	* processed if nessecary
  	*/
! 	if(!olsr_check_dup_table_proc(&originator, ntohs(m->v4.seqno))) {
  		/* If so - do not process */
  		goto forward;
***************
*** 436,440 ****
  	/* Forward the message if nessecary
  	* default_fwd does all the work for us! */
! 	default_fwd(m, &originator, ntohs(m->v4.seqno), in_if, in_addr);
  }
  
--- 444,448 ----
  	/* Forward the message if nessecary
  	* default_fwd does all the work for us! */
! 	olsr_forward_message(m, &originator, ntohs(m->v4.seqno), in_if, in_addr);
  }
  
***************
*** 582,585 ****
--- 590,594 ----
  	/* insert a new entry */
  	entry = olsr_malloc(sizeof(struct db_entry), "new db_entry");
+ 	
  	memcpy(&entry->originator, originator, ipsize);
  	olsr_get_timestamp(vtime * 1000, &entry->timer);
***************
*** 801,805 ****
  	olsr_printf(6, "checking %s\n", olsr_ip_to_string(addr));
  	
! 	for(iface = ifs; iface; iface = iface->int_next)
  	{
  		olsr_printf(6, "interface %s\n", olsr_ip_to_string(&iface->ip_addr));
--- 810,814 ----
  	olsr_printf(6, "checking %s\n", olsr_ip_to_string(addr));
  	
! 	for(iface = ifnet; iface; iface = iface->int_next)
  	{
  		olsr_printf(6, "interface %s\n", olsr_ip_to_string(&iface->ip_addr));
***************
*** 810,814 ****
  	}
  	
! 	for (hna4 = cfg->hna4_entries; hna4; hna4 = hna4->next)
  	{
  		olsr_printf(6, "HNA %s/%s\n", 
--- 819,823 ----
  	}
  	
! 	for (hna4 = olsr_cnf->hna4_entries; hna4; hna4 = hna4->next)
  	{
  		olsr_printf(6, "HNA %s/%s\n", 

Index: olsrd_plugin.c
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/lib/nameservice/src/olsrd_plugin.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** olsrd_plugin.c	25 May 2005 13:43:30 -0000	1.10
--- olsrd_plugin.c	29 May 2005 12:47:42 -0000	1.11
***************
*** 33,37 ****
  
  /*
!  * Dynamic linked library for UniK OLSRd
   */
  
--- 33,37 ----
  
  /*
!  * Dynamic linked library for olsr.org olsrd
   */
  
***************
*** 41,331 ****
  #include "olsrd_plugin.h"
  #include "nameservice.h"
- #include "plugin_loader.h"
- 
- #ifndef linux
- 
- /* strndup() is a GNU extention */
- char *
- strndup(const char *ptr, size_t size)
- {
-   int len = strlen(ptr);
-   char *ret = NULL;
- 
-   if(!len)
-     return NULL;
- 
-   if(len > size)
-     len = size;
  
-   ret = malloc(len + 1);
-   
-   if(!ret)
-     return NULL;
  
!   strncpy(ret, ptr, len);
!   ret[len] = '\0';
! 
!   return ret;
! }
  
- #endif
  
! 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);
  
- /*
-  * Returns the version of the plugin interface that is used
-  * THIS IS NOT THE VERSION OF YOUR PLUGIN!
-  */
  int 
! get_plugin_interface_version()
! {
!   return PLUGIN_INTERFACE_VERSION;
! }
! 
! /**
!  *Constructor
!  */
! void
! my_init()
  {
!   /* Print plugin info to stdout */
!   printf("%s\n", MOD_DESC);
! 
!   ifs = NULL;
! 
!   name_constructor();
!   
!   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;
! }
! 
! /* Mulitpurpose funtion */
! int
! plugin_io(int cmd, void *data, size_t size)
  {
! 
!   switch(cmd)
!     {
!     default:
!       return 0;
!     }
!   
!   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;
! 
! 
!   /* Packet buffer */
!   if(!olsr_plugin_io(GETF__NET_OUTBUFFER_PUSH, &net_outbuffer_push, sizeof(net_outbuffer_push)))
!   {
!     net_outbuffer_push = 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;
!   }
! 
!   /* Parser registration */
!   if(!olsr_plugin_io(GETF__OLSR_PARSER_ADD_FUNCTION, 
! 		     &olsr_parser_add_function, 
! 		     sizeof(olsr_parser_add_function)))
!   {
!     olsr_parser_add_function = NULL;
!     retval = 0;
!   }
! 
!   /* Scheduler timeout registration */
!   if(!olsr_plugin_io(GETF__OLSR_REGISTER_TIMEOUT_FUNCTION, 
! 		     &olsr_register_timeout_function, 
! 		     sizeof(olsr_register_timeout_function)))
!   {
!     olsr_register_timeout_function = 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;
!   }
! 
!   /* Double to mantissa/exponent */
!   if(!olsr_plugin_io(GETF__DOUBLE_TO_ME, 
! 		     &double_to_me, 
! 		     sizeof(double_to_me)))
!   {
!     double_to_me = NULL;
!     retval = 0;
!   }
! 
!   /* Interface list */
!   if(!olsr_plugin_io(GETD__IFNET, &ifs, sizeof(ifs)))
!   {
!     ifs = NULL;
!     retval = 0;
!   }
! 
!   /* Messageseqno fetch function */
!   if(!olsr_plugin_io(GETF__GET_MSG_SEQNO, &get_msg_seqno, sizeof(get_msg_seqno)))
!   {
!     get_msg_seqno = NULL;
!     retval = 0;
!   }
! 
!   /* Scheduler maintained timestamp */
!   if(!olsr_plugin_io(GETD__NOW, &now, sizeof(now)))
!   {
!     now = NULL;
!     retval = 0;
!   }
! 
!   /* Output function */
!   if(!olsr_plugin_io(GETF__NET_OUTPUT, &net_output, sizeof(net_output)))
!   {
!     net_output = NULL;
!     retval = 0;
!   }
! 
!   /* Duplicate check (for processing) */
!   if(!olsr_plugin_io(GETF__OLSR_CHECK_DUP_TABLE_PROC, &check_dup_proc, sizeof(check_dup_proc)))
!   {
!     check_dup_proc = NULL;
!     retval = 0;
!   }
! 
!   /* Default forward function */
!   if(!olsr_plugin_io(GETF__OLSR_FORWARD_MESSAGE, &default_fwd, sizeof(default_fwd)))
!   {
!     default_fwd = 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;
!   }
! 
!   /* Neighbor link status lookup */
!   if(!olsr_plugin_io(GETF__CHECK_NEIGHBOR_LINK, &check_neighbor_link, sizeof(check_neighbor_link)))
!   {
!     check_neighbor_link = NULL;
!     retval = 0;
!   }
! 
!   /* Configuration */
!   if(!olsr_plugin_io(GETD__OLSR_CNF, &cfg, sizeof(cfg))) {
!       cfg = NULL;
!       retval = 0;
!   }
!   
!   if(!olsr_plugin_io(GETD__ROUTINGTABLE, &routingtable, sizeof(routingtable))) {
!     routingtable = NULL;
!     retval = 0;
!   }
!   
!   return retval;
  }
--- 41,87 ----
  #include "olsrd_plugin.h"
  #include "nameservice.h"
  
  
! #define PLUGIN_NAME    "OLSRD nameservice plugin"
! #define PLUGIN_VERSION "0.2"
! #define PLUGIN_AUTHOR   "Bruno Randolf"
! #define MOD_DESC PLUGIN_NAME " " PLUGIN_VERSION
  
  
! static void __attribute__ ((constructor)) 
  my_init(void);
  
! static void __attribute__ ((destructor)) 
  my_fini(void);
  
  
  int 
! olsrd_plugin_interface_version()
  {
! 	return OLSRD_PLUGIN_INTERFACE_VERSION;
  }
  
  
! int olsrd_plugin_init()
  {
! 	return name_init();
  }
  
  
! static void
! my_init()
  {
! 	/* Print plugin info to stdout */
! 	printf("%s\n", MOD_DESC);
  
! 	name_constructor();
!   
! 	return;
  }
  
  
! static void
! my_fini()
  {
! 	name_destructor();
  }

Index: olsrd_copy.c
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/lib/nameservice/src/olsrd_copy.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** olsrd_copy.c	20 Apr 2005 17:57:00 -0000	1.3
--- olsrd_copy.c	29 May 2005 12:47:42 -0000	1.4
***************
*** 47,79 ****
  #include "olsrd_copy.h"
  
! /**
!  *Hashing function. Creates a key based on
!  *an 32-bit address.
!  *@param address the address to hash
!  *@return the hash(a value in the 0-31 range)
!  */
! olsr_u32_t
! olsr_hashing(union olsr_ip_addr *address)
! {
!   olsr_u32_t hash;
!   char *tmp;
! 
!   if(ipversion == AF_INET)
!     /* IPv4 */  
!     hash = (ntohl(address->v4));
!   else
!     {
!       /* IPv6 */
!       tmp = (char *) &address->v6;
!       hash = (ntohl(*tmp));
!     }
! 
!   //hash &= 0x7fffffff; 
!   hash &= HASHMASK;
! 
!   return hash;
! }
! 
! 
  
  /**
--- 47,51 ----
  #include "olsrd_copy.h"
  
! #include "defs.h"
  
  /**
***************
*** 88,96 ****
  olsr_timed_out(struct timeval *timer)
  {
!   return(timercmp(timer, now, <));
  }
  
  
- 
  /**
   *Initiates a "timer", wich is a timeval structure,
--- 60,67 ----
  olsr_timed_out(struct timeval *timer)
  {
!   return(timercmp(timer, &now, <));
  }
  
  
  /**
   *Initiates a "timer", wich is a timeval structure,
***************
*** 114,122 ****
  
  
- 
- 
- 
  /**
!  *Generaties a timestamp a certain number of milliseconds
   *into the future.
   *
--- 85,90 ----
  
  
  /**
!  *Generates a timestamp a certain number of milliseconds
   *into the future.
   *
***************
*** 133,205 ****
    time_value_sec = delay/1000;
    time_value_msec= delay - (delay*1000);
- 
-   hold_timer->tv_sec = now->tv_sec + time_value_sec;
-   hold_timer->tv_usec = now->tv_usec + (time_value_msec*1000);   
- }
- 
- 
- /**
-  *Converts a olsr_ip_addr to a string
-  *Goes for both IPv4 and IPv6
-  *
-  *NON REENTRANT! If you need to use this
-  *function twice in e.g. the same printf
-  *it will not work.
-  *You must use it in different calls e.g.
-  *two different printfs
-  *
-  *@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)
- {
- 
-   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));
!     }
! 
!   return ret;
! }
! 
! 
! /**
!  *Look up an entry in the routing table.
!  *
!  *@param dst the address of the entry
!  *
!  *@return a pointer to a rt_entry struct 
!  *representing the route entry.
!  */
! struct rt_entry *
! olsr_lookup_routing_table(union olsr_ip_addr *dst)
! {
! 
!   struct rt_entry *rt_table;
!   olsr_u32_t      hash;
! 
!   hash = olsr_hashing(dst);
! 
!   for(rt_table = routingtable[hash].next;
!       rt_table != &routingtable[hash];
!       rt_table = rt_table->next)
!     {
!       if (COMP_IP(&rt_table->rt_dst, dst))
! 	{
! 	  return(rt_table);
! 	}
!     }
!   return(NULL); 
  }
--- 101,106 ----
    time_value_sec = delay/1000;
    time_value_msec= delay - (delay*1000);
    
!   hold_timer->tv_sec = now.tv_sec + time_value_sec;
!   hold_timer->tv_usec = now.tv_usec + (time_value_msec*1000);   
  }

--- olsrd_plugin.h DELETED ---

Index: nameservice.h
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/lib/nameservice/src/nameservice.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** nameservice.h	17 Mar 2005 21:41:30 -0000	1.7
--- nameservice.h	29 May 2005 12:47:42 -0000	1.8
***************
*** 39,42 ****
--- 39,46 ----
  #define _NAMESERVICE_PLUGIN
  
+ #include "olsr_types.h"
+ #include "interfaces.h"
+ #include "olsr_protocol.h"
+ 
  #include "olsrd_plugin.h"
  #include "nameservice_msg.h"
***************
*** 117,119 ****
--- 121,129 ----
  name_constructor(void);
  
+ void
+ name_destructor(void);
+ 
+ int
+ name_init(void);
+ 
  #endif

--- NEW FILE: compat.c ---
#include "compat.h"

#ifndef linux
#include <stdlib.h>

/* strndup() is a GNU extention */
char *
strndup(const char *ptr, size_t size)
{
  int len = strlen(ptr);
  char *ret = NULL;

  if(!len)
    return NULL;

  if(len > size)
    len = size;

  ret = malloc(len + 1);
  
  if(!ret)
    return NULL;

  strncpy(ret, ptr, len);
  ret[len] = '\0';

  return ret;
}

#endif




More information about the Olsr-cvs mailing list