[Olsr-cvs] olsrd-current/src process_routes.c, 1.39, 1.40 process_routes.h, 1.13, 1.14
Bernd Petrovitsch
(spam-protected)
Thu Nov 29 01:18:56 CET 2007
Update of /cvsroot/olsrd/olsrd-current/src
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv5107/src
Modified Files:
process_routes.c process_routes.h
Log Message:
Patch from Sven-Ola Tücke <(spam-protected)> from
http://download-master.berlin.freifunk.net/sven-ola/nylon/packages/olsrd/files/103-olsrd-rt-exportroute-cleanup.patch:
avoid a malloc()ed list of functions
Index: process_routes.c
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/src/process_routes.c,v
retrieving revision 1.39
retrieving revision 1.40
diff -C2 -d -r1.39 -r1.40
*** process_routes.c 11 Nov 2007 23:10:25 -0000 1.39
--- process_routes.c 29 Nov 2007 00:18:53 -0000 1.40
***************
*** 6,10 ****
*
* export_route_entry interface added by Immo 'FaUl Wehrenberg
! * <(spam-protected)>
*
* Redistribution and use in source and binary forms, with or without
--- 6,10 ----
*
* export_route_entry interface added by Immo 'FaUl Wehrenberg
! * <(spam-protected)> and reworked by sven-ola 2007
*
* Redistribution and use in source and binary forms, with or without
***************
*** 56,70 ****
#endif
- struct export_route_entry
- {
- olsr_u8_t type; /* AF_INET/AF_INET6 */
- export_route_function function;
- struct export_route_entry *next;
- };
-
-
- static struct export_route_entry *add_routes;
- static struct export_route_entry *del_routes;
-
static struct list_node add_kernel_list;
static struct list_node chg_kernel_list;
--- 56,59 ----
***************
*** 98,153 ****
! static void
! olsr_route_add_function(struct export_route_entry **routes, export_route_function function, olsr_u8_t type)
! {
! struct export_route_entry *tmp = olsr_malloc(sizeof(*tmp), __func__);
! tmp->type = type;
! tmp->function = function;
! tmp->next = *routes;
! *routes = tmp;
! }
!
! void
! olsr_addroute_add_function(export_route_function function, olsr_u8_t type)
! {
! olsr_route_add_function(&add_routes, function, type);
! }
!
! void
! olsr_delroute_add_function(export_route_function function, olsr_u8_t type)
! {
! olsr_route_add_function(&del_routes, function, type);
! }
!
!
! static int
! olsr_route_remove_function(struct export_route_entry **routes, export_route_function function, olsr_u8_t type)
! {
! struct export_route_entry *tmp, *prev;
! for (tmp = *routes, prev = NULL; tmp != NULL; prev = tmp, tmp = tmp->next) {
! if (function == tmp->function && type == tmp->type) {
! if (prev == NULL) { /* i.e. tmp == *routes */
! *routes = (*routes)->next;
! } else {
! prev->next = tmp->next;
! }
! free(tmp);
! return 1;
! }
! }
! return 0;
! }
!
! int
! olsr_addroute_remove_function(export_route_function function, olsr_u8_t type)
! {
! return olsr_route_remove_function(&add_routes, function, type);
! }
!
! int
! olsr_delroute_remove_function(export_route_function function, olsr_u8_t type)
! {
! return olsr_route_remove_function(&del_routes, function, type);
! }
--- 87,94 ----
! export_route_function olsr_addroute_function;
! export_route_function olsr_addroute6_function;
! export_route_function olsr_delroute_function;
! export_route_function olsr_delroute6_function;
***************
*** 160,180 ****
list_head_init(&del_kernel_list);
! olsr_addroute_add_function(&olsr_ioctl_add_route, AF_INET);
! olsr_addroute_add_function(&olsr_ioctl_add_route6, AF_INET6);
! olsr_delroute_add_function(&olsr_ioctl_del_route, AF_INET);
! olsr_delroute_add_function(&olsr_ioctl_del_route6, AF_INET6);
! }
!
! static int
! olsr_export_route(struct export_route_entry *routes, const struct rt_entry *rt, int ip_version)
! {
! int retval = 0;
! struct export_route_entry *tmp;
! for (tmp = routes; tmp != NULL; tmp = tmp->next) {
! if (tmp->type == ip_version) {
! retval = tmp->function(rt);
! }
! }
! return retval;
}
--- 101,108 ----
list_head_init(&del_kernel_list);
! olsr_addroute_function = olsr_ioctl_add_route;
! olsr_addroute6_function = olsr_ioctl_add_route6;
! olsr_delroute_function = olsr_ioctl_del_route;
! olsr_delroute6_function = olsr_ioctl_del_route6;
}
***************
*** 234,238 ****
{
if(!olsr_cnf->host_emul) {
! olsr_16_t error = olsr_export_route(del_routes, rt, olsr_cnf->ip_version);
if(error < 0) {
--- 162,167 ----
{
if(!olsr_cnf->host_emul) {
! olsr_16_t error = olsr_cnf->ip_version == AF_INET ?
! olsr_delroute_function(rt) : olsr_delroute6_function(rt);
if(error < 0) {
***************
*** 258,262 ****
if(!olsr_cnf->host_emul) {
! olsr_16_t error = olsr_export_route(add_routes, rt, olsr_cnf->ip_version);
if(error < 0) {
--- 187,192 ----
if(!olsr_cnf->host_emul) {
! olsr_16_t error = olsr_cnf->ip_version == AF_INET ?
! olsr_addroute_function(rt) : olsr_addroute6_function(rt);
if(error < 0) {
Index: process_routes.h
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/src/process_routes.h,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** process_routes.h 11 Nov 2007 23:10:25 -0000 1.13
--- process_routes.h 29 Nov 2007 00:18:53 -0000 1.14
***************
*** 48,65 ****
typedef int (*export_route_function)(const struct rt_entry*);
! void
! olsr_init_export_route(void);
!
! void
! olsr_addroute_add_function(export_route_function, olsr_u8_t);
!
! int
! olsr_addroute_remove_function(export_route_function, olsr_u8_t);
void
! olsr_delroute_add_function(export_route_function, olsr_u8_t);
!
! int
! olsr_delroute_remove_function(export_route_function, olsr_u8_t);
void
--- 48,58 ----
typedef int (*export_route_function)(const struct rt_entry*);
! extern export_route_function olsr_addroute_function;
! extern export_route_function olsr_addroute6_function;
! extern export_route_function olsr_delroute_function;
! extern export_route_function olsr_delroute6_function;
void
! olsr_init_export_route(void);
void
More information about the Olsr-cvs
mailing list