[Olsr-cvs] olsrd-current/lib/txtinfo/src olsrd_txtinfo.c, 1.6, 1.7 olsrd_txtinfo.h, 1.1, 1.2

Aaron Kaplan (spam-protected)
Thu Aug 2 22:21:32 CEST 2007


some feedback for that:
Andreas's Thesis stated that the interface will always remain the  
same. AFAIK this was the reason to keep the version numbers in there.  
[1] Andreas, could you confirm this?

One reason is that there might be a bunch of plugins out there (some  
of them not open source) which depend on the old interface. IMHO we  
should not completely abandon the old interface but keep it as a  
compile option
(as you did anyway, Bernd) :)

ACK?

a.


[1] c.f. the diploma thesis, page 63


On Jul 16, 2007, at 2:29 AM, Bernd Petrovitsch wrote:

> Update of /cvsroot/olsrd/olsrd-current/lib/txtinfo/src
> In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv5004/lib/ 
> txtinfo/src
>
> Modified Files:
> 	olsrd_txtinfo.c olsrd_txtinfo.h
> Log Message:
>
> I started to clean up the plugin parameter handling:
> * Up to now some used case-insensitive, some used case-sensitive (with
>   differing cases BTW) parameter names.
> * Most plugins silently ignored unknown parameters.
> This makes it hard to find errors in the olsrd.conf file.
> Instead of simply fixing all the various plugins (and the mostly -  
> more
> or less - copied code), I reduced the plugin special code to a minimum
> and (more or less automatically) all plugins behave the same (with
> respect to the parameter handling).
>
> How does it look now?
> Every plugins exports a table of { parameter-name, parse-function,
> addr-of-storage } to allow to share more code, e.g. the parsing and
> checking of a port number or IP addresses.
> Every plugin will export a function
> ----  snip  ----
> void olsrd_get_plugin_parameters(const struct  
> olsrd_plugin_parameters **params, int *size);
> ----  snip  ----
> which delivers the address of the table and it's size. So in theory  
> the
> plugin could generate the table at load time though ATM all current
> ones export statically defined tables.
>
> What else is different?
> - I introduced SUPPORT_OLD_PLUGIN_VERSIONS to simplifiy the compile- 
> time
>   removal of legacy support. It is not that much but more of a start.
> - Plugin interface version 4 is supported until all plugins are
>   migrated.
> - The plugin loader produces now much more output - on good and error
>   cases. I had too often to look into the source to find that I  
> mistyped
>   some parameter .....
>
> ToDo:
> - Several plugins cannot handle IPv6 at all - only IPv4 is  
> implemented.
>   Some of these functions are locally now but fixed versions can (and
>   should IMHO) be shared by all plugins.
>
>
>
> Index: olsrd_txtinfo.c
> ===================================================================
> RCS file: /cvsroot/olsrd/olsrd-current/lib/txtinfo/src/ 
> olsrd_txtinfo.c,v
> retrieving revision 1.6
> retrieving revision 1.7
> diff -C2 -d -r1.6 -r1.7
> *** olsrd_txtinfo.c	9 May 2007 17:29:53 -0000	1.6
> --- olsrd_txtinfo.c	15 Jul 2007 19:29:37 -0000	1.7
> ***************
> *** 93,123 ****
>
>   /* IPC initialization function */
> ! static int
> ! plugin_ipc_init(void);
>
> ! static void
> ! send_info(int neighonly);
>
> ! static void
> ! ipc_action(int);
>
> ! static void
> ! ipc_print_neigh_link(void);
>
> ! static void
> ! ipc_print_routes(void);
>
> ! static void
> ! ipc_print_topology(void);
>
> ! static void
> ! ipc_print_hna(void);
>
> ! static void
> ! ipc_print_mid(void);
>
>   #define TXT_IPC_BUFSIZE 256
> ! static int
> ! ipc_sendf(const char* format, ...) __attribute__((format(printf,  
> 1, 2)));
>
>   /**
> --- 93,114 ----
>
>   /* IPC initialization function */
> ! static int plugin_ipc_init(void);
>
> ! static void  send_info(int neighonly);
>
> ! static void ipc_action(int);
>
> ! static void ipc_print_neigh_link(void);
>
> ! static void ipc_print_routes(void);
>
> ! static void ipc_print_topology(void);
>
> ! static void ipc_print_hna(void);
>
> ! static void ipc_print_mid(void);
>
>   #define TXT_IPC_BUFSIZE 256
> ! static int ipc_sendf(const char* format, ...) __attribute__ 
> ((format(printf, 1, 2)));
>
>   /**
> ***************
> *** 130,139 ****
>   olsrd_plugin_init(void)
>   {
> !   /* Initial IPC value */
> !   ipc_open = 0;
> !   ipc_socket_up = 0;
>
> !   plugin_ipc_init();
> !   return 1;
>   }
>
> --- 121,130 ----
>   olsrd_plugin_init(void)
>   {
> !     /* Initial IPC value */
> !     ipc_open = 0;
> !     ipc_socket_up = 0;
>
> !     plugin_ipc_init();
> !     return 1;
>   }
>
> ***************
> *** 142,150 ****
>    * destructor - called at unload
>    */
> ! void
> ! olsr_plugin_exit(void)
>   {
> !   if(ipc_open)
> !     close(ipc_socket);
>   }
>
> --- 133,140 ----
>    * destructor - called at unload
>    */
> ! void olsr_plugin_exit(void)
>   {
> !     if(ipc_open)
> !         close(ipc_socket);
>   }
>
> ***************
> *** 154,497 ****
>   plugin_ipc_init(void)
>   {
> !   struct sockaddr_in sin;
> !   olsr_u32_t yes = 1;
>
> !   /* Init ipc socket */
> !   if ((ipc_socket = socket(AF_INET, SOCK_STREAM, 0)) == -1)
> !     {
>   #ifndef NODEBUG
> !       olsr_printf(1, "(TXTINFO) socket()=%s\n", strerror(errno));
>   #endif
> !       return 0;
> !     }
> !   else
> !     {
> !       if (setsockopt(ipc_socket, SOL_SOCKET, SO_REUSEADDR, (char  
> *)&yes, sizeof(yes)) < 0)
> !       {
>   #ifndef NODEBUG
> ! 	olsr_printf(1, "(TXTINFO) setsockopt()=%s\n", strerror(errno));
>   #endif
> ! 	return 0;
> !       }
>
>   #if defined __FreeBSD__ && defined SO_NOSIGPIPE
> !       if (setsockopt(ipc_socket, SOL_SOCKET, SO_NOSIGPIPE, (char  
> *)&yes, sizeof(yes)) < 0)
> !       {
> ! 	perror("SO_REUSEADDR failed");
> ! 	return 0;
> !       }
>   #endif
>
> !       /* Bind the socket */
> !
> !       /* complete the socket structure */
> !       memset(&sin, 0, sizeof(sin));
> !       sin.sin_family = AF_INET;
> !       sin.sin_addr.s_addr = INADDR_ANY;
> !       sin.sin_port = htons(ipc_port);
>
> !       /* bind the socket to the port number */
> !       if (bind(ipc_socket, (struct sockaddr *) &sin, sizeof(sin))  
> == -1)
> ! 	{
>   #ifndef NODEBUG
> ! 	  olsr_printf(1, "(TXTINFO) bind()=%s\n", strerror(errno));
>   #endif
> ! 	  return 0;
> ! 	}
> !
> !       /* show that we are willing to listen */
> !       if (listen(ipc_socket, 1) == -1)
> ! 	{
>   #ifndef NODEBUG
> ! 	  olsr_printf(1, "(TXTINFO) listen()=%s\n", strerror(errno));
>   #endif
> ! 	  return 0;
> ! 	}
> ! 	
> !       /* Register with olsrd */
> !       add_olsr_socket(ipc_socket, &ipc_action);
>
>   #ifndef NODEBUG
> !       olsr_printf(2, "(TXTINFO) listening on port %d\n",ipc_port);
>   #endif
> !       ipc_socket_up = 1;
>       }
> !
> !   return 1;
>   }
>
>
> ! static void
> ! ipc_action(int fd)
>   {
> !   struct sockaddr_in pin;
> !   socklen_t addrlen;
> !   char *addr;
>
> !   addrlen = sizeof(struct sockaddr_in);
>
> !   if(ipc_open)
> !     return;
>
> !   if ((ipc_connection = accept(fd, (struct sockaddr *)  &pin,  
> &addrlen)) == -1)
> !     {
>   #ifndef NODEBUG
> !       olsr_printf(1, "(TXTINFO) accept()=%s\n", strerror(errno));
>   #endif
> !       exit(1);
>       }
> -   else
> -     {
> -       fd_set rfds;
> -       struct timeval tv = {0,0};
> -       int neighonly = 0;
>
> !       addr = inet_ntoa(pin.sin_addr);
> !       if(ntohl(pin.sin_addr.s_addr) != ntohl(ipc_accept_ip.s_addr))
> ! 	{
> ! 	  olsr_printf(1, "(TXTINFO) From host(%s) not allowed!\n", addr);
> ! 	  close(ipc_connection);
> ! 	  return;
> ! 	}
> !       else
> ! 	{
> !       ipc_open = 1;
>   #ifndef NODEBUG
> !       olsr_printf(2, "(TXTINFO) Connect from %s\n",addr);
>   #endif
>
> !       /* purge read buffer to prevent blocking on linux*/
> !       FD_ZERO(&rfds);
> !       FD_SET((unsigned int)ipc_connection, &rfds); /* Win32 needs  
> the cast here */
> !       if(select(ipc_connection+1, &rfds, NULL, NULL, &tv)) {
>           char requ[128];
>           ssize_t s = recv(ipc_connection, (void*)&requ, sizeof 
> (requ), 0); /* Win32 needs the cast here */
>           if (0 < s) {
> !           requ[s] = 0;
> !           /* To print out neighbours only on the Freifunk Status
> !            * page the normal output is somewhat lengthy. The
> !            * header parsing is sufficient for standard wget.
> !            */
> !           neighonly = (0 != strstr(requ, "/neighbours"));
>           }
> !       }
>
> !       send_info(neighonly);
>   	
> !       close(ipc_connection);
> !       ipc_open = 0;
> !     }
> !   }
>   }
>
> ! static void
> ! ipc_print_neigh_link(void)
>   {
> !   struct neighbor_entry *neigh;
> !   struct neighbor_2_list_entry *list_2;
> !   struct link_entry *link = NULL;
> !   int index, thop_cnt;
>
> ! 	ipc_sendf("Table: Links\nLocal IP\tremote IP\tHysteresis 
> \tLinkQuality\tlost\ttotal\tNLQ\tETX\n");
>
> !   /* Link set */
> !   link = link_set;
> ! 	while(link)
> ! 	{
>   	ipc_sendf( "%s\t%s\t%0.2f\t%0.2f\t%d\t%d\t%0.2f\t%0.2f\t\n",
> ! 			olsr_ip_to_string(&link->local_iface_addr),
> ! 			olsr_ip_to_string(&link->neighbor_iface_addr),
> ! 			link->L_link_quality,
> ! 			link->loss_link_quality,
> ! 			link->lost_packets,
> ! 			link->total_packets,
> ! 			link->neigh_link_quality,
> ! 			(link->loss_link_quality * link->neigh_link_quality) ? 1.0 /  
> (link->loss_link_quality * link->neigh_link_quality) : 0.0);
> ! 		link = link->next;
> !       }
> !   	ipc_sendf("\nTable: Neighbors\nIP address\tSYM\tMPR\tMPRS 
> \tWillingness\t2 Hop Neighbors\n");
> !
> !   /* Neighbors */
> !   for(index=0;index<HASHSIZE;index++)
> !     {
> !       for(neigh = neighbortable[index].next;
> ! 	  neigh != &neighbortable[index];
> ! 	  neigh = neigh->next)
> ! 	{
> ! 		ipc_sendf(
> ! 			  "%s\t%s\t%s\t%s\t%d\t",
> ! 			  olsr_ip_to_string(&neigh->neighbor_main_addr),
> ! 			  (neigh->status == SYM) ? "YES" : "NO",
> ! 			  neigh->is_mpr ? "YES" : "NO",
> ! 			  olsr_lookup_mprs_set(&neigh->neighbor_main_addr) ? "YES" :  
> "NO",
> ! 			  neigh->willingness);
>
> ! 	  thop_cnt = 0;
>
> ! 	  for(list_2 = neigh->neighbor_2_list.next;
> ! 	      list_2 != &neigh->neighbor_2_list;
> ! 	      list_2 = list_2->next)
> ! 	    {
> ! 	      //size += sprintf(&buf[size], "<option>%s</option>\n",  
> olsr_ip_to_string(&list_2->neighbor_2->neighbor_2_addr));
> ! 	      thop_cnt ++;
> ! 	    }
> !   		ipc_sendf("%d\n", thop_cnt);
>   	}
>       }
> !
> ! 	ipc_sendf("\n");
>   }
>
> !
> ! static void
> ! ipc_print_routes(void)
>   {
> !   int size = 0, index;
> !   struct rt_entry *routes;
>
> ! 	ipc_sendf("Table: Routes\nDestination\tGateway\tMetric\tETX 
> \tInterface\tType\n");
>
> !   /* Neighbors */
> !   for(index = 0;index < HASHSIZE;index++)
> !     {
> !       for(routes = routingtable[index].next;
> ! 	  routes != &routingtable[index];
> ! 	  routes = routes->next)
> ! 	{
> ! 		size = 0;
> !   		ipc_sendf( "%s\t%s\t%d\t%.2f\t%s\tHOST\n",
> ! 			  olsr_ip_to_string(&routes->rt_dst),
> ! 			  olsr_ip_to_string(&routes->rt_router),
> ! 			  routes->rt_metric,
> ! 			  routes->rt_etx,
> ! 			  routes->rt_if->int_name);
>   	}
>       }
>
> !   /* HNA */
> !   for(index = 0;index < HASHSIZE;index++)
> !     {
> !       for(routes = hna_routes[index].next;
> ! 	  routes != &hna_routes[index];
> ! 	  routes = routes->next)
> ! 	{
> !   		ipc_sendf("%s\t%s\t%d\t%s\t\tHNA\n",
> ! 			  olsr_ip_to_string(&routes->rt_dst),
> ! 			  olsr_ip_to_string(&routes->rt_router),
> ! 			  routes->rt_metric,
> ! 			  routes->rt_if->int_name);
>   	}
>       }
> !
> ! 	ipc_sendf("\n");
>
>   }
>
> ! static void
> ! ipc_print_topology(void)
>   {
> !   olsr_u8_t index;
> !   struct tc_entry *entry;
> !   struct topo_dst *dst_entry;
> !
>
> !   ipc_sendf("Table: Topology\nDestination IP\tLast hop IP\tLQ\tILQ 
> \tETX\n");
>
> !   /* Topology */
> !   for(index=0;index<HASHSIZE;index++)
> !     {
> !       /* For all TC entries */
> !       entry = tc_table[index].next;
> !       while(entry != &tc_table[index])
> ! 	{
> ! 	  /* For all destination entries of that TC entry */
> ! 	  dst_entry = entry->destinations.next;
> ! 	  while(dst_entry != &entry->destinations)
> ! 	    {
> ! 			ipc_sendf( "%s\t%s\t%0.2f\t%0.2f\t%0.2f\n",
> ! 			      olsr_ip_to_string(&dst_entry->T_dest_addr),
> ! 			      olsr_ip_to_string(&entry->T_last_addr),
> ! 			      dst_entry->link_quality,
> ! 			      dst_entry->inverse_link_quality,
> ! 			      (dst_entry->link_quality * dst_entry- 
> >inverse_link_quality) ? 1.0 / (dst_entry->link_quality * dst_entry- 
> >inverse_link_quality) : 0.0);
>   		
> ! 	      dst_entry = dst_entry->next;
>   	    }
> ! 	  entry = entry->next;
>   	}
>       }
> !
> !   ipc_sendf("\n");
>   }
>
> ! static void
> ! ipc_print_hna(void)
>   {
> !   int size;
> !   olsr_u8_t index;
> !   struct hna_entry *tmp_hna;
> !   struct hna_net *tmp_net;
> !   struct hna4_entry *hna4;
> !   struct hna6_entry *hna6;
>
> !   size = 0;
>
> !   ipc_sendf("Table: HNA\nNetwork\tNetmask\tGateway\n");
>
> !   /* Announced HNA entries */
> ! 	for(hna4 = olsr_cnf->hna4_entries; hna4; hna4 = hna4->next)
> ! 	  {
> ! 			ipc_sendf("%s\t%s\t%s\n",
> ! 			  olsr_ip_to_string(&hna4->net),
> ! 			  olsr_ip_to_string(&hna4->netmask),
> ! 				olsr_ip_to_string(&olsr_cnf->main_addr));
> ! 	  }
> ! 	for(hna6 = olsr_cnf->hna6_entries; hna6; hna6 = hna6->next)
> ! 	  {
> ! 			ipc_sendf("%s\t%d\t%s\n",
> ! 			  olsr_ip_to_string(&hna6->net),
> ! 				hna6->prefix_len,
> ! 		  	olsr_ip_to_string(&olsr_cnf->main_addr));
> ! 		}
>
> !   /* HNA entries */
> !   for(index=0;index<HASHSIZE;index++)
> !     {
> !       tmp_hna = hna_set[index].next;
> !       /* Check all entrys */
> !       while(tmp_hna != &hna_set[index])
> ! 	{
> ! 	  /* Check all networks */
> ! 	  tmp_net = tmp_hna->networks.next;
>   	
> ! 	  while(tmp_net != &tmp_hna->networks)
> ! 	    {
>   		if (AF_INET == olsr_cnf->ip_version) {
> ! 			ipc_sendf("%s\t%s\t%s\n",
> ! 				olsr_ip_to_string(&tmp_net->A_network_addr),
> ! 				olsr_ip_to_string((union olsr_ip_addr *)&tmp_net->A_netmask.v4),
> ! 				olsr_ip_to_string(&tmp_hna->A_gateway_addr));
> ! 		}
> ! 		else {
> ! 			ipc_sendf("%s\t%d\t%s\n",
> ! 				olsr_ip_to_string(&tmp_net->A_network_addr),
> ! 				tmp_net->A_netmask.v6,
> ! 				olsr_ip_to_string(&tmp_hna->A_gateway_addr));
>   		}
> ! 	      tmp_net = tmp_net->next;
>   	    }
>   	
> ! 	  tmp_hna = tmp_hna->next;
>   	}
>       }
> !
> ! 	ipc_sendf("\n");
>
>   }
>
> ! static void
> ! ipc_print_mid(void)
>   {
> !     olsr_u8_t index;
>       unsigned short is_first;
>       struct mid_entry *entry;
> --- 144,440 ----
>   plugin_ipc_init(void)
>   {
> !     struct sockaddr_in sin;
> !     olsr_u32_t yes = 1;
>
> !     /* Init ipc socket */
> !     if ((ipc_socket = socket(AF_INET, SOCK_STREAM, 0)) == -1) {
>   #ifndef NODEBUG
> !         olsr_printf(1, "(TXTINFO) socket()=%s\n", strerror(errno));
>   #endif
> !         return 0;
> !     } else {
> !         if (setsockopt(ipc_socket, SOL_SOCKET, SO_REUSEADDR,  
> (char *)&yes, sizeof(yes)) < 0) {
>   #ifndef NODEBUG
> !             olsr_printf(1, "(TXTINFO) setsockopt()=%s\n", strerror 
> (errno));
>   #endif
> !             return 0;
> !         }
>
>   #if defined __FreeBSD__ && defined SO_NOSIGPIPE
> !         if (setsockopt(ipc_socket, SOL_SOCKET, SO_NOSIGPIPE,  
> (char *)&yes, sizeof(yes)) < 0) {
> !             perror("SO_REUSEADDR failed");
> !             return 0;
> !         }
>   #endif
> +         /* Bind the socket */
>
> !         /* complete the socket structure */
> !         memset(&sin, 0, sizeof(sin));
> !         sin.sin_family = AF_INET;
> !         sin.sin_addr.s_addr = INADDR_ANY;
> !         sin.sin_port = htons(ipc_port);
>
> !         /* bind the socket to the port number */
> !         if (bind(ipc_socket, (struct sockaddr *) &sin, sizeof 
> (sin)) == -1) {
>   #ifndef NODEBUG
> !             olsr_printf(1, "(TXTINFO) bind()=%s\n", strerror 
> (errno));
>   #endif
> !             return 0;
> !         }
> !
> !         /* show that we are willing to listen */
> !         if (listen(ipc_socket, 1) == -1) {
>   #ifndef NODEBUG
> !             olsr_printf(1, "(TXTINFO) listen()=%s\n", strerror 
> (errno));
>   #endif
> !             return 0;
> !         }
>
> +         /* Register with olsrd */
> +         add_olsr_socket(ipc_socket, &ipc_action);
> +
>   #ifndef NODEBUG
> !         olsr_printf(2, "(TXTINFO) listening on port %d\n",ipc_port);
>   #endif
> !         ipc_socket_up = 1;
>       }
> !     return 1;
>   }
>
>
> ! static void ipc_action(int fd)
>   {
> !     struct sockaddr_in pin;
> !     char *addr;
> !     fd_set rfds;
> !     struct timeval tv;
> !     int neighonly = 0;
>
> !     socklen_t addrlen = sizeof(struct sockaddr_in);
>
> !     if(ipc_open)
> !         return;
>
> !     if ((ipc_connection = accept(fd, (struct sockaddr *)  &pin,  
> &addrlen)) == -1) {
>   #ifndef NODEBUG
> !         olsr_printf(1, "(TXTINFO) accept()=%s\n", strerror(errno));
>   #endif
> !         return;
>       }
>
> !     tv.tv_sec = tv.tv_usec = 0;
> !     addr = inet_ntoa(pin.sin_addr);
> !     if (ntohl(pin.sin_addr.s_addr) != ntohl(ipc_accept_ip.v4)) {
> !         olsr_printf(1, "(TXTINFO) From host(%s) not allowed!\n",  
> addr);
> !         close(ipc_connection);
> !         return;
> !     }
> !     ipc_open = 1;
>   #ifndef NODEBUG
> !     olsr_printf(2, "(TXTINFO) Connect from %s\n",addr);
>   #endif
>
> !     /* purge read buffer to prevent blocking on linux*/
> !     FD_ZERO(&rfds);
> !     FD_SET((unsigned int)ipc_connection, &rfds); /* Win32 needs  
> the cast here */
> !     if(select(ipc_connection+1, &rfds, NULL, NULL, &tv)) {
>           char requ[128];
>           ssize_t s = recv(ipc_connection, (void*)&requ, sizeof 
> (requ), 0); /* Win32 needs the cast here */
>           if (0 < s) {
> !             requ[s] = 0;
> !             /* To print out neighbours only on the Freifunk Status
> !              * page the normal output is somewhat lengthy. The
> !              * header parsing is sufficient for standard wget.
> !              */
> !             neighonly = (0 != strstr(requ, "/neighbours"));
>           }
> !     }
>
> !     send_info(neighonly);
>   	
> !     close(ipc_connection);
> !     ipc_open = 0;
>   }
>
> ! static void ipc_print_neigh_link(void)
>   {
> !     struct neighbor_entry *neigh;
> !     struct neighbor_2_list_entry *list_2;
> !     struct link_entry *link = NULL;
> !     int index, thop_cnt;
>
> !     ipc_sendf("Table: Links\nLocal IP\tremote IP\tHysteresis 
> \tLinkQuality\tlost\ttotal\tNLQ\tETX\n");
>
> !     /* Link set */
> !     link = link_set;
> !     while(link)	{
>   	ipc_sendf( "%s\t%s\t%0.2f\t%0.2f\t%d\t%d\t%0.2f\t%0.2f\t\n",
> !                    olsr_ip_to_string(&link->local_iface_addr),
> !                    olsr_ip_to_string(&link->neighbor_iface_addr),
> !                    link->L_link_quality,
> !                    link->loss_link_quality,
> !                    link->lost_packets,
> !                    link->total_packets,
> !                    link->neigh_link_quality,
> !                    (link->loss_link_quality * link- 
> >neigh_link_quality) ? 1.0 / (link->loss_link_quality * link- 
> >neigh_link_quality) : 0.0);
> !         link = link->next;
> !     }
> !     ipc_sendf("\nTable: Neighbors\nIP address\tSYM\tMPR\tMPRS 
> \tWillingness\t2 Hop Neighbors\n");
>
> !     /* Neighbors */
> !     for(index = 0; index < HASHSIZE; index++) {
> !         for(neigh = neighbortable[index].next;
> !             neigh != &neighbortable[index];
> !             neigh = neigh->next) {
> !             ipc_sendf("%s\t%s\t%s\t%s\t%d\t",
> !                       olsr_ip_to_string(&neigh->neighbor_main_addr),
> !                       (neigh->status == SYM) ? "YES" : "NO",
> !                       neigh->is_mpr ? "YES" : "NO",
> !                       olsr_lookup_mprs_set(&neigh- 
> >neighbor_main_addr) ? "YES" : "NO",
> !                       neigh->willingness);
> !             thop_cnt = 0;
>
> !             for(list_2 = neigh->neighbor_2_list.next;
> !                 list_2 != &neigh->neighbor_2_list;
> !                 list_2 = list_2->next)
> !                 {
> !                     //size += sprintf(&buf[size], "<option>%s</ 
> option>\n", olsr_ip_to_string(&list_2->neighbor_2->neighbor_2_addr));
> !                     thop_cnt ++;
> !                 }
> !             ipc_sendf("%d\n", thop_cnt);
>   	}
>       }
> !     ipc_sendf("\n");
>   }
>
> ! static void ipc_print_routes(void)
>   {
> !     int size = 0, index;
> !     struct rt_entry *routes;
>
> !     ipc_sendf("Table: Routes\nDestination\tGateway\tMetric\tETX 
> \tInterface\tType\n");
>
> !     /* Neighbors */
> !     for(index = 0;index < HASHSIZE; index++) {
> !         for(routes = routingtable[index].next;
> !             routes != &routingtable[index];
> !             routes = routes->next) {
> !             size = 0;
> !             ipc_sendf( "%s\t%s\t%d\t%.2f\t%s\tHOST\n",
> !                        olsr_ip_to_string(&routes->rt_dst),
> !                        olsr_ip_to_string(&routes->rt_router),
> !                        routes->rt_metric,
> !                        routes->rt_etx,
> !                        routes->rt_if->int_name);
>   	}
>       }
>
> !     /* HNA */
> !     for(index = 0;index < HASHSIZE;index++) {
> !         for(routes = hna_routes[index].next;
> !             routes != &hna_routes[index];
> !             routes = routes->next) {
> !             ipc_sendf("%s\t%s\t%d\t%s\t\tHNA\n",
> !                       olsr_ip_to_string(&routes->rt_dst),
> !                       olsr_ip_to_string(&routes->rt_router),
> !                       routes->rt_metric,
> !                       routes->rt_if->int_name);
>   	}
>       }
> !     ipc_sendf("\n");
>
>   }
>
> ! static void ipc_print_topology(void)
>   {
> !     int index;
> !     struct tc_entry *entry;
> !     struct topo_dst *dst_entry;
>
> !     ipc_sendf("Table: Topology\nDestination IP\tLast hop IP\tLQ 
> \tILQ\tETX\n");
>
> !     /* Topology */
> !     for(index = 0; index < HASHSIZE; index++) {
> !         /* For all TC entries */
> !         entry = tc_table[index].next;
> !         while(entry != &tc_table[index]) {
> !             /* For all destination entries of that TC entry */
> !             dst_entry = entry->destinations.next;
> !             while(dst_entry != &entry->destinations) {
> !                 ipc_sendf( "%s\t%s\t%0.2f\t%0.2f\t%0.2f\n",
> !                            olsr_ip_to_string(&dst_entry- 
> >T_dest_addr),
> !                            olsr_ip_to_string(&entry->T_last_addr),
> !                            dst_entry->link_quality,
> !                            dst_entry->inverse_link_quality,
> !                            (dst_entry->link_quality * dst_entry- 
> >inverse_link_quality) ? 1.0 / (dst_entry->link_quality * dst_entry- 
> >inverse_link_quality) : 0.0);
>   		
> !                 dst_entry = dst_entry->next;
>   	    }
> !             entry = entry->next;
>   	}
>       }
> !     ipc_sendf("\n");
>   }
>
> ! static void ipc_print_hna(void)
>   {
> !     int size;
> !     olsr_u8_t index;
> !     struct hna_entry *tmp_hna;
> !     struct hna_net *tmp_net;
> !     struct hna4_entry *hna4;
> !     struct hna6_entry *hna6;
>
> !     size = 0;
>
> !     ipc_sendf("Table: HNA\nNetwork\tNetmask\tGateway\n");
>
> !     /* Announced HNA entries */
> !     for(hna4 = olsr_cnf->hna4_entries; hna4; hna4 = hna4->next) {
> !         ipc_sendf("%s\t%s\t%s\n",
> !                   olsr_ip_to_string(&hna4->net),
> !                   olsr_ip_to_string(&hna4->netmask),
> !                   olsr_ip_to_string(&olsr_cnf->main_addr));
> !     }
> !     for(hna6 = olsr_cnf->hna6_entries; hna6; hna6 = hna6->next) {
> !         ipc_sendf("%s\t%d\t%s\n",
> !                   olsr_ip_to_string(&hna6->net),
> !                   hna6->prefix_len,
> !                   olsr_ip_to_string(&olsr_cnf->main_addr));
> !     }
>
> !     /* HNA entries */
> !     for(index = 0; index < HASHSIZE; index++) {
> !         tmp_hna = hna_set[index].next;
> !         /* Check all entrys */
> !         while(tmp_hna != &hna_set[index]) {
> !             /* Check all networks */
> !             tmp_net = tmp_hna->networks.next;
>   	
> !             while(tmp_net != &tmp_hna->networks) {
>   		if (AF_INET == olsr_cnf->ip_version) {
> !                     ipc_sendf("%s\t%s\t%s\n",
> !                               olsr_ip_to_string(&tmp_net- 
> >A_network_addr),
> !                               olsr_ip_to_string((union  
> olsr_ip_addr *)&tmp_net->A_netmask.v4),
> !                               olsr_ip_to_string(&tmp_hna- 
> >A_gateway_addr));
> ! 		} else {
> !                     ipc_sendf("%s\t%d\t%s\n",
> !                               olsr_ip_to_string(&tmp_net- 
> >A_network_addr),
> !                               tmp_net->A_netmask.v6,
> !                               olsr_ip_to_string(&tmp_hna- 
> >A_gateway_addr));
>   		}
> !                 tmp_net = tmp_net->next;
>   	    }
>   	
> !             tmp_hna = tmp_hna->next;
>   	}
>       }
> !     ipc_sendf("\n");
>
>   }
>
> ! static void ipc_print_mid(void)
>   {
> !     int index;
>       unsigned short is_first;
>       struct mid_entry *entry;
> ***************
> *** 501,558 ****
>
>       /* MID */
> !     for( index = 0; index < HASHSIZE; index++ )
> !     {
>           entry = mid_set[index].next;
> !
> !         while( entry != &mid_set[index] )
> !         {
>               ipc_sendf( olsr_ip_to_string( &entry->main_addr ) );
>               alias = entry->aliases;
>               is_first = 1;
>
> !             while( alias )
> !             {
>                   ipc_sendf( "%s%s",
> !                     ( is_first ? "\t" : ";" ),
> !                     olsr_ip_to_string( &alias->alias )
> !                 );
>
>                   alias = alias->next_alias;
>                   is_first = 0;
>               }
> -
>               entry = entry->next;
>               ipc_sendf("\n");
>           }
>       }
> !
> ! 	ipc_sendf("\n");
>   }
>
>
> ! static void
> ! send_info(int neighonly)
>   {
> ! 	
> ! 	/* Print minimal http header */
> ! 	ipc_sendf("HTTP/1.0 200 OK\n");
> ! 	ipc_sendf("Content-type: text/plain\n\n");
>
> ! 	/* Print tables to IPC socket */
>   	
> ! 	/* links + Neighbors */
> ! 	ipc_print_neigh_link();
>   	
> ! 	/* topology */
> ! 	if (!neighonly) ipc_print_topology();
>   	
> !  	/* hna */
> ! 	if (!neighonly) ipc_print_hna();
>
> !  	/* mid */
> ! 	if (!neighonly) ipc_print_mid();
>
> ! 	/* routes */
> ! 	if (!neighonly) ipc_print_routes();
>   }
>
> --- 444,494 ----
>
>       /* MID */
> !     for(index = 0; index < HASHSIZE; index++) {
>           entry = mid_set[index].next;
> !
> !         while( entry != &mid_set[index] ) {
>               ipc_sendf( olsr_ip_to_string( &entry->main_addr ) );
>               alias = entry->aliases;
>               is_first = 1;
>
> !             while( alias ) {
>                   ipc_sendf( "%s%s",
> !                            ( is_first ? "\t" : ";" ),
> !                            olsr_ip_to_string( &alias->alias )
> !                            );
>
>                   alias = alias->next_alias;
>                   is_first = 0;
>               }
>               entry = entry->next;
>               ipc_sendf("\n");
>           }
>       }
> !     ipc_sendf("\n");
>   }
>
>
> ! static void  send_info(int neighonly)
>   {
> !     /* Print minimal http header */
> !     ipc_sendf("HTTP/1.0 200 OK\n");
> !     ipc_sendf("Content-type: text/plain\n\n");
>
> !     /* Print tables to IPC socket */
>   	
> !     /* links + Neighbors */
> !     ipc_print_neigh_link();
>   	
> !     /* topology */
> !     if (!neighonly) ipc_print_topology();
>   	
> !     /* hna */
> !     if (!neighonly) ipc_print_hna();
>
> !     /* mid */
> !     if (!neighonly) ipc_print_mid();
>
> !     /* routes */
> !     if (!neighonly) ipc_print_routes();
>   }
>
> ***************
> *** 564,591 ****
>    */
>
> ! static int
> ! ipc_sendf(const char* format, ...)
>   {
> ! 	char txtnetbuf[TXT_IPC_BUFSIZE];
>
> ! 	va_list arg;
> ! 	int rv;
>   #if defined __FreeBSD__ || defined __NetBSD__ || defined  
> __OpenBSD__ || defined __MacOSX__
> ! 	int flags = 0;
>   #else
> ! 	int flags = MSG_NOSIGNAL;
>   #endif
> ! 	va_start(arg, format);
> ! 	rv = vsnprintf(txtnetbuf, sizeof(txtnetbuf), format, arg);
> ! 	va_end(arg);
> ! 	if(ipc_socket_up) {
> ! 		if (0 > send(ipc_connection, txtnetbuf, rv, flags)) {
>   #ifndef NODEBUG
> ! 			olsr_printf(1, "(TXTINFO) Failed sending data to client!\n");
>   #endif
> ! 			close(ipc_connection);
> ! 			return - 1;
> ! 		}
> ! 	}
> ! 	return rv;
>   }
> --- 500,535 ----
>    */
>
> ! static int  ipc_sendf(const char* format, ...)
>   {
> !     char txtnetbuf[TXT_IPC_BUFSIZE];
>
> !     va_list arg;
> !     int rv;
>   #if defined __FreeBSD__ || defined __NetBSD__ || defined  
> __OpenBSD__ || defined __MacOSX__
> !     int flags = 0;
>   #else
> !     int flags = MSG_NOSIGNAL;
>   #endif
> !     va_start(arg, format);
> !     rv = vsnprintf(txtnetbuf, sizeof(txtnetbuf), format, arg);
> !     va_end(arg);
> !     if(ipc_socket_up) {
> !         if (0 > send(ipc_connection, txtnetbuf, rv, flags)) {
>   #ifndef NODEBUG
> !             olsr_printf(1, "(TXTINFO) Failed sending data to  
> client!\n");
>   #endif
> !             close(ipc_connection);
> !             return - 1;
> !         }
> !     }
> !     return rv;
>   }
> +
> + /*
> +  * Local Variables:
> +  * mode: c
> +  * style: linux
> +  * c-basic-offset: 4
> +  * indent-tabs-mode: nil
> +  * End:
> +  */
>
> Index: olsrd_txtinfo.h
> ===================================================================
> RCS file: /cvsroot/olsrd/olsrd-current/lib/txtinfo/src/ 
> olsrd_txtinfo.h,v
> retrieving revision 1.1
> retrieving revision 1.2
> diff -C2 -d -r1.1 -r1.2
> *** olsrd_txtinfo.h	31 Jan 2007 12:38:26 -0000	1.1
> --- olsrd_txtinfo.h	15 Jul 2007 19:29:37 -0000	1.2
> ***************
> *** 45,62 ****
>    */
>
> ! #ifndef _OLSRD_DOT_DRAW
> ! #define _OLSRD_DOT_DRAW
>
>
> ! extern struct in_addr ipc_accept_ip;
>   extern int ipc_port;
>   extern int nompr;
>
> !
> ! int
> ! olsrd_plugin_init(void);
> !
> ! void
> ! olsr_plugin_exit(void);
>
>   #endif
> --- 45,63 ----
>    */
>
> ! #ifndef _OLSRD_TXTINFO
> ! #define _OLSRD_TXTINFO
>
> + #include "olsr_types.h"
> + #include "olsrd_plugin.h"
> + #include "plugin_util.h"
>
> ! extern union olsr_ip_addr ipc_accept_ip;
>   extern int ipc_port;
>   extern int nompr;
>
> ! int olsrd_plugin_interface_version(void);
> ! int olsrd_plugin_init(void);
> ! void olsr_plugin_exit(void);
> ! void olsrd_get_plugin_parameters(const struct  
> olsrd_plugin_parameters **params, int *size);
>
>   #endif
>
>
> -- 
> Olsr-cvs mailing list
> (spam-protected)
> http://lists.olsr.org/mailman/listinfo/olsr-cvs
>

---
there's no place like 127.0.0.1
until we found ::1 -- which is even bigger







More information about the Olsr-cvs mailing list