[Olsr-cvs] olsrd-current/lib/quagga/src olsrd_plugin.c, 1.7, 1.8 quagga.c, 1.7, 1.8 quagga.h, 1.4, 1.5
Bernd Petrovitsch
(spam-protected)
Wed Oct 10 23:24:56 CEST 2007
Update of /cvsroot/olsrd/olsrd-current/lib/quagga/src
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv5038/lib/quagga/src
Modified Files:
olsrd_plugin.c quagga.c quagga.h
Log Message:
* updated to SVN trunk - revision 48
Index: olsrd_plugin.c
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/lib/quagga/src/olsrd_plugin.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** olsrd_plugin.c 4 Oct 2007 22:40:19 -0000 1.7
--- olsrd_plugin.c 10 Oct 2007 21:24:54 -0000 1.8
***************
*** 20,23 ****
--- 20,24 ----
#include "olsrd_plugin.h"
+ #include "plugin_util.h"
#include "olsr.h"
#include "scheduler.h"
***************
*** 30,90 ****
#define PLUGIN_AUTHOR "Immo 'FaUl' Wehrenberg"
#define MOD_DESC PLUGIN_NAME " " PLUGIN_VERSION " by " PLUGIN_AUTHOR
! #define PLUGIN_INTERFACE_VERSION 4
static void __attribute__ ((constructor)) my_init(void);
static void __attribute__ ((destructor)) my_fini(void);
! int olsrd_plugin_interface_version(void) {
return PLUGIN_INTERFACE_VERSION;
}
! int olsrd_plugin_register_param(char *key, char *value) {
! const char *zebra_route_types[] = {"system","kernel","connect","static",
! "rip","ripng","ospf","ospf6","isis",
! "bgp","hsls", NULL};
! unsigned char i = 0;
! if(!strcmp(key, "redistribute")) {
! for (i = 0; zebra_route_types[i]; i++)
! if (!strcmp(value, zebra_route_types[i])) {
! zebra_redistribute(i);
! return 1;
! }
! }
! else if(!strcmp(key, "ExportRoutes")) {
! if (!strcmp(value, "only")) {
! if (!olsr_addroute_remove_function(&olsr_ioctl_add_route, AF_INET))
! puts ("AIII, could not remove the kernel route exporter");
! if (!olsr_delroute_remove_function(&olsr_ioctl_del_route, AF_INET))
! puts ("AIII, could not remove the kernel route deleter");
! olsr_addroute_add_function(&zebra_add_olsr_v4_route, AF_INET);
! olsr_delroute_add_function(&zebra_del_olsr_v4_route, AF_INET);
! zebra_export_routes(1);
! return 1;
! }
! else if (!strcmp(value, "additional")) {
! olsr_addroute_add_function(&zebra_add_olsr_v4_route, AF_INET);
! olsr_delroute_add_function(&zebra_del_olsr_v4_route, AF_INET);
! zebra_export_routes(1);
! return 1;
}
- else zebra_export_routes(0);
}
! else if (!strcmp(key, "Distance")) {
! unsigned int distance = atoi (value);
! if (distance < 255)
! zebra_olsr_distance(distance);
! return 1;
}
!
! else if (!strcmp(key, "LocalPref")) {
! if (!strcmp(value, "true"))
! zebra_olsr_localpref();
! else if (strcmp (value, "false"))
! return -1;
! return 1;
}
! return -1;
}
--- 31,117 ----
#define PLUGIN_AUTHOR "Immo 'FaUl' Wehrenberg"
#define MOD_DESC PLUGIN_NAME " " PLUGIN_VERSION " by " PLUGIN_AUTHOR
! #define PLUGIN_INTERFACE_VERSION 5
static void __attribute__ ((constructor)) my_init(void);
static void __attribute__ ((destructor)) my_fini(void);
! static set_plugin_parameter set_redistribute;
! static set_plugin_parameter set_exportroutes;
! static set_plugin_parameter set_distance;
! static set_plugin_parameter set_localpref;
!
!
! int olsrd_plugin_interface_version (void) {
return PLUGIN_INTERFACE_VERSION;
}
+ static const struct olsrd_plugin_parameters plugin_parameters[] = {
+ { .name = "redistribute", .set_plugin_parameter = &set_redistribute, },
+ { .name = "ExportRoutes", .set_plugin_parameter = &set_exportroutes, },
+ { .name = "Distance", .set_plugin_parameter = &set_distance, },
+ { .name = "LocalPref", .set_plugin_parameter = &set_localpref, },
+ };
! void olsrd_get_plugin_parameters (const struct olsrd_plugin_parameters **params,
! int *size) {
! *params = plugin_parameters;
! *size = sizeof plugin_parameters / sizeof *plugin_parameters;
! }
! static int set_redistribute (const char *value,
! void *data __attribute__((unused)),
! set_plugin_parameter_addon addon __attribute__((unused))) {
! const char *zebra_route_types[] = {"system","kernel","connect",
! "static","rip","ripng","ospf",
! "ospf6","isis","bgp","hsls"};
! unsigned int i;
!
! for (i = 0; i < ARRAYSIZE(zebra_route_types); i++) {
! if (!strcmp(value, zebra_route_types[i])) {
! zebra_redistribute(i);
! return 0;
}
}
! return 1;
! }
!
! static int set_exportroutes (const char *value,
! void *data __attribute__((unused)),
! set_plugin_parameter_addon addon __attribute__((unused))) {
! if (!strcmp(value, "only")) {
! if (!olsr_addroute_remove_function(&olsr_ioctl_add_route, AF_INET))
! puts ("AIII, could not remove the kernel route exporter");
! if (!olsr_delroute_remove_function(&olsr_ioctl_del_route, AF_INET))
! puts ("AIII, could not remove the kernel route deleter");
! olsr_addroute_add_function(&zebra_add_olsr_v4_route, AF_INET);
! olsr_delroute_add_function(&zebra_del_olsr_v4_route, AF_INET);
! zebra_export_routes(1);
}
! else if (!strcmp(value, "additional")) {
! olsr_addroute_add_function(&zebra_add_olsr_v4_route, AF_INET);
! olsr_delroute_add_function(&zebra_del_olsr_v4_route, AF_INET);
! zebra_export_routes(1);
}
! else zebra_export_routes(0);
! return 0;
! }
!
! static int set_distance(const char *value, void *data __attribute__((unused)),
! set_plugin_parameter_addon addon __attribute__((unused))) {
! int distance;
!
! if (set_plugin_int(value, &distance, addon)) return 1;
! if (distance < 0 || distance > 255) return 1;
! zebra_olsr_distance(distance);
! return 0;
! }
!
! static int set_localpref(const char *value, void *data __attribute__((unused)),
! set_plugin_parameter_addon addon __attribute__((unused))) {
! int b;
!
! if (set_plugin_boolean(value, &b, addon)) return 1;
! if (b) zebra_olsr_localpref();
! return 0;
}
Index: quagga.h
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/lib/quagga/src/quagga.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** quagga.h 25 Aug 2007 19:48:42 -0000 1.4
--- quagga.h 10 Oct 2007 21:24:54 -0000 1.5
***************
*** 63,70 ****
int add_hna4_route (struct ipv4_route);
int delete_hna4_route (struct ipv4_route);
! void *my_realloc (void *, size_t, const char*);
! int zebra_add_olsr_v4_route (struct rt_entry*);
! int zebra_del_olsr_v4_route (struct rt_entry*);
void zebra_olsr_localpref (void);
! void zebra_olsr_distance (char);
! void zebra_export_routes (unsigned char);
--- 63,70 ----
int add_hna4_route (struct ipv4_route);
int delete_hna4_route (struct ipv4_route);
! void *my_realloc (void *, size_t, const char *);
! int zebra_add_olsr_v4_route (struct rt_entry *);
! int zebra_del_olsr_v4_route (struct rt_entry *);
void zebra_olsr_localpref (void);
! void zebra_olsr_distance (unsigned char);
! void zebra_export_routes(unsigned char);
Index: quagga.c
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/lib/quagga/src/quagga.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** quagga.c 5 Sep 2007 16:17:35 -0000 1.7
--- quagga.c 10 Oct 2007 21:24:54 -0000 1.8
***************
*** 33,36 ****
--- 33,37 ----
#include "defs.h"
#include "local_hna_set.h"
+ #include "routing_table.h"
#ifdef USE_UNIX_DOMAIN_SOCKET
***************
*** 78,81 ****
--- 79,83 ----
static uint32_t prefixlentomask (uint8_t);
static void free_ipv4_route (struct ipv4_route);
+ /*
static void update_olsr_zebra_routes (struct ipv4_route*, struct ipv4_route*);
static struct ipv4_route *zebra_create_ipv4_route_table_entry (uint32_t,
***************
*** 84,88 ****
static struct ipv4_route *zebra_create_ipv4_route_table (void);
static void zebra_free_ipv4_route_table (struct ipv4_route*);
! static uint8_t masktoprefixlen (uint32_t);
--- 86,92 ----
static struct ipv4_route *zebra_create_ipv4_route_table (void);
static void zebra_free_ipv4_route_table (struct ipv4_route*);
! */
!
! /*static uint8_t masktoprefixlen (uint32_t);*/
***************
*** 164,175 ****
void zebra_cleanup (void) {
int i;
if (zebra.options & OPTION_EXPORT) {
! struct rt_entry *rt;
! OLSR_FOR_ALL_RT_ENTRIES(rt) {
! zebra_del_olsr_v4_route (rt);
! } OLSR_FOR_ALL_RT_ENTRIES_END(rt);
! }
! for (i = 0; ZEBRA_ROUTE_MAX - 1; i++)
if (zebra.redistribute[i]) zebra_disable_redistribute(i + 1);
}
--- 168,180 ----
void zebra_cleanup (void) {
int i;
+ struct rt_entry *tmp;
+
if (zebra.options & OPTION_EXPORT) {
! OLSR_FOR_ALL_RT_ENTRIES(tmp) {
! zebra_del_olsr_v4_route(tmp);
! } OLSR_FOR_ALL_RT_ENTRIES_END(tmp);
! }
! for (i = 0; i < ZEBRA_ROUTE_MAX; i++)
if (zebra.redistribute[i]) zebra_disable_redistribute(i + 1);
}
***************
*** 177,180 ****
--- 182,186 ----
static void zebra_reconnect (void) {
+ struct rt_entry *tmp;
int i;
***************
*** 183,193 ****
if (zebra.options & OPTION_EXPORT) {
! struct rt_entry *rt;
! OLSR_FOR_ALL_RT_ENTRIES(rt) {
! zebra_add_olsr_v4_route (rt);
! } OLSR_FOR_ALL_RT_ENTRIES_END(rt);
}
! for (i = 0; ZEBRA_ROUTE_MAX - 1; i++)
if (zebra.redistribute[i]) zebra_redistribute(i + 1);
/* Zebra sends us all routes of type it knows after
--- 189,198 ----
if (zebra.options & OPTION_EXPORT) {
! OLSR_FOR_ALL_RT_ENTRIES(tmp) {
! zebra_add_olsr_v4_route (tmp);
! } OLSR_FOR_ALL_RT_ENTRIES_END(tmp);
}
! for (i = 0; i < ZEBRA_ROUTE_MAX; i++)
if (zebra.redistribute[i]) zebra_redistribute(i + 1);
/* Zebra sends us all routes of type it knows after
***************
*** 199,202 ****
--- 204,209 ----
/* Connect to the zebra-daemon, returns a socket */
static void zebra_connect (void) {
+
+ int ret;
#ifndef USE_UNIX_DOMAIN_SOCKET
***************
*** 213,218 ****
#endif
- int ret;
-
if (zebra.sock <0 )
olsr_exit("(QUAGGA) Could not create socket!", EXIT_FAILURE);
--- 220,223 ----
***************
*** 237,241 ****
the command defined in zebra.h, options is the packet-payload,
optlen the length, of the payload */
! unsigned char zebra_send_command (unsigned char command, unsigned char * options, int optlen) {
#ifdef ZEBRA_HEADER_MARKER
--- 242,247 ----
the command defined in zebra.h, options is the packet-payload,
optlen the length, of the payload */
! unsigned char zebra_send_command (unsigned char command,
! unsigned char *options, int optlen) {
#ifdef ZEBRA_HEADER_MARKER
***************
*** 291,295 ****
/* Creates a Route-Packet-Payload, needs address, netmask, nexthop,
distance, and a pointer of an size_t */
! static unsigned char* zebra_route_packet (struct ipv4_route r, ssize_t *optlen) {
int count;
--- 297,302 ----
/* Creates a Route-Packet-Payload, needs address, netmask, nexthop,
distance, and a pointer of an size_t */
! static unsigned char* zebra_route_packet (struct ipv4_route r,
! ssize_t *optlen) {
int count;
***************
*** 298,302 ****
*optlen = 4; // first: type, flags, message, prefixlen
*optlen += r.prefixlen / 8 + (r.prefixlen % 8 ? 1 : 0); // + prefix
! if (r.message & ZAPI_MESSAGE_NEXTHOP)
if (r.nexthops->type == ZEBRA_NEXTHOP_IPV4
|| r.nexthops->type == ZEBRA_NEXTHOP_IPV4_IFINDEX){
--- 305,309 ----
*optlen = 4; // first: type, flags, message, prefixlen
*optlen += r.prefixlen / 8 + (r.prefixlen % 8 ? 1 : 0); // + prefix
! if (r.message & ZAPI_MESSAGE_NEXTHOP) {
if (r.nexthops->type == ZEBRA_NEXTHOP_IPV4
|| r.nexthops->type == ZEBRA_NEXTHOP_IPV4_IFINDEX){
***************
*** 306,309 ****
--- 313,317 ----
else if (r.nexthops->type == 0)
*optlen += 5;
+ }
if (r.message & ZAPI_MESSAGE_IFINDEX)
*optlen += r.ind_num * sizeof *r.index + 1;
***************
*** 402,408 ****
do {
ret = zebra_parse_packet (f, len);
! if (!ret) { // something wired happened
olsr_exit ("(QUAGGA) Zero message length??? ", EXIT_FAILURE);
- }
f += ret;
} while ((f - data) < len);
--- 410,415 ----
do {
ret = zebra_parse_packet (f, len);
! if (!ret) // something wired happened
olsr_exit ("(QUAGGA) Zero message length??? ", EXIT_FAILURE);
f += ret;
} while ((f - data) < len);
***************
*** 716,719 ****
--- 723,727 ----
}
+ /*
static uint8_t masktoprefixlen (uint32_t mask) {
***************
*** 727,730 ****
--- 735,739 ----
}
+ */
int zebra_add_olsr_v4_route (struct rt_entry *r) {
***************
*** 736,742 ****
route.message = ZAPI_MESSAGE_METRIC;
route.flags = zebra.flags;
! route.prefixlen = r->rt_dst.prefix_len;
route.prefix = r->rt_dst.prefix.v4;
! if ((r->rt_best->rtp_nexthop.gateway.v4 == r->rt_dst.prefix.v4 &&
route.prefixlen == 32)) {
route.message |= ZAPI_MESSAGE_IFINDEX | ZAPI_MESSAGE_NEXTHOP;
--- 745,751 ----
route.message = ZAPI_MESSAGE_METRIC;
route.flags = zebra.flags;
! route.prefixlen =(r->rt_dst.prefix_len);
route.prefix = r->rt_dst.prefix.v4;
! if ((r->rt_best->rtp_nexthop.gateway.v4 == r->rt_dst.prefix.v4 &&
route.prefixlen == 32)) {
route.message |= ZAPI_MESSAGE_IFINDEX | ZAPI_MESSAGE_NEXTHOP;
***************
*** 784,788 ****
route.prefixlen = r->rt_dst.prefix_len;
route.prefix = r->rt_dst.prefix.v4;
! if ((r->rt_best->rtp_nexthop.gateway.v4 == r->rt_dst.prefix.v4 && route.prefixlen == 32)){
route.message |= ZAPI_MESSAGE_IFINDEX;
route.ind_num = 1;
--- 793,798 ----
route.prefixlen = r->rt_dst.prefix_len;
route.prefix = r->rt_dst.prefix.v4;
! if ((r->rt_best->rtp_nexthop.gateway.v4 == r->rt_dst.prefix.v4 &&
! route.prefixlen == 32)){
route.message |= ZAPI_MESSAGE_IFINDEX;
route.ind_num = 1;
***************
*** 814,823 ****
}
! del_v4_route_status(route);
free_ipv4_route (route);
return retval;
}
! void zebra_olsr_distance (char dist) {
zebra.distance = dist;
}
--- 824,834 ----
}
! retval = zebra_delete_v4_route(route);
!
free_ipv4_route (route);
return retval;
}
! void zebra_olsr_distance (unsigned char dist) {
zebra.distance = dist;
}
***************
*** 827,831 ****
}
! void zebra_export (char t) {
if (t)
zebra.options |= OPTION_EXPORT;
--- 838,842 ----
}
! void zebra_export_routes (unsigned char t) {
if (t)
zebra.options |= OPTION_EXPORT;
More information about the Olsr-cvs
mailing list