From (spam-protected) Fri May 27 01:54:10 2005 From: (spam-protected) (Lars Strand) Date: Fri, 27 May 2005 01:54:10 +0200 Subject: [Olsr-cvs] First post Message-ID: <20050526235410.GA24607@trinity.gnist.org> Testing only. Please ignore. -- Lars Strand GnuPG/PGP Key: http://www.gnist.org/~lars/pubkey.asc ID: 972F4325 "The Internet? Is that thing still around?" -- Homer Simpson From (spam-protected) Fri May 27 10:22:25 2005 From: (spam-protected) (=?ISO-8859-1?Q?Andreas_T=F8nnesen?=) Date: Fri, 27 May 2005 10:22:25 +0200 Subject: [Olsr-cvs] test Message-ID: <4296D8C1.6040106@olsr.org> test -- Andreas Tønnesen http://www.olsr.org From (spam-protected) Sat May 28 14:49:54 2005 From: (spam-protected) (Bruno Randolf) Date: Sat, 28 May 2005 12:49:54 +0000 Subject: [Olsr-cvs] olsrd-current/lib/mini olsrd_mini.so.0.1,1.1,NONE Message-ID: Update of /cvsroot/olsrd/olsrd-current/lib/mini In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21165 Removed Files: olsrd_mini.so.0.1 Log Message: remove mini binary --- olsrd_mini.so.0.1 DELETED --- From (spam-protected) Sun May 29 14:47:46 2005 From: (spam-protected) (Bruno Randolf) Date: Sun, 29 May 2005 12:47:46 +0000 Subject: [Olsr-cvs] olsrd-current/lib/tas version-script.txt,1.1,1.2 Message-ID: Update of /cvsroot/olsrd/olsrd-current/lib/tas In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25973/lib/tas Modified Files: version-script.txt 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: version-script.txt =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/lib/tas/version-script.txt,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** version-script.txt 12 Apr 2005 17:17:25 -0000 1.1 --- version-script.txt 29 May 2005 12:47:44 -0000 1.2 *************** *** 2,25 **** { global: ! get_plugin_interface_version; ! register_olsr_data; ! plugin_io; ! register_olsr_param; ! httpInit; ! httpSetAddress; ! httpSetPort; ! httpSetRootDir; ! httpSetWorkDir; ! httpSetIndexFile; ! httpSetUser; ! httpSetPassword; ! httpSetSessTime; ! httpSetPubDir; ! httpSetQuantum; ! httpSetMessTime; ! httpSetMessLimit; ! httpSetup; ! httpService; ! httpShutdown; local: --- 2,8 ---- { global: ! olsrd_plugin_interface_version; ! olsrd_plugin_register_param; ! olsrd_plugin_init; local: From (spam-protected) Sun May 29 14:47:47 2005 From: (spam-protected) (Bruno Randolf) Date: Sun, 29 May 2005 12:47:47 +0000 Subject: [Olsr-cvs] olsrd-current/lib/tas/src http.c, 1.3, 1.4 os_unix.c, 1.2, 1.3 os_unix.h, 1.2, 1.3 plugin.c, 1.4, 1.5 Message-ID: Update of /cvsroot/olsrd/olsrd-current/lib/tas/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25973/lib/tas/src Modified Files: http.c os_unix.c os_unix.h plugin.c 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: os_unix.h =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/lib/tas/src/os_unix.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** os_unix.h 13 Apr 2005 22:10:23 -0000 1.2 --- os_unix.h 29 May 2005 12:47:44 -0000 1.3 *************** *** 71,75 **** extern int addrLen(int family); ! extern void now(struct timeStamp *timeStamp); extern int timedOut(struct timeStamp *timeStamp, int sec); --- 71,75 ---- extern int addrLen(int family); ! extern void os_now(struct timeStamp *timeStamp); extern int timedOut(struct timeStamp *timeStamp, int sec); Index: http.c =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/lib/tas/src/http.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** http.c 13 Apr 2005 22:10:22 -0000 1.3 --- http.c 29 May 2005 12:47:44 -0000 1.4 *************** *** 383,387 **** info->data = NULL; ! now(&info->time); debug(DEBUG_SESSION, "new session, id = %u\n", info->id); --- 383,387 ---- info->data = NULL; ! os_now(&info->time); debug(DEBUG_SESSION, "new session, id = %u\n", info->id); *************** *** 1604,1608 **** currSess = sess[i]; ! now(&currSess->time); } } --- 1604,1608 ---- currSess = sess[i]; ! os_now(&currSess->time); } } *************** *** 1869,1873 **** msg->next = NULL; ! now(&msg->time); msg->service = myStrdup(service); --- 1869,1873 ---- msg->next = NULL; ! os_now(&msg->time); msg->service = myStrdup(service); Index: plugin.c =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/lib/tas/src/plugin.c,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** plugin.c 13 Apr 2005 22:53:13 -0000 1.4 --- plugin.c 29 May 2005 12:47:44 -0000 1.5 *************** *** 52,57 **** #include "glua_ext.h" ! #include ! #include #include #include --- 52,59 ---- #include "glua_ext.h" ! #include ! #include ! #include ! #include #include #include *************** *** 63,73 **** #include #include #define MESSAGE_TYPE 129 ! int get_plugin_interface_version(void); ! int plugin_io(int cmd, void *data, int len); ! int register_olsr_data(struct olsr_plugin_data *data); ! int register_olsr_param(char *name, char *value); static int ipAddrLen; --- 65,76 ---- #include #include + #include + #include #define MESSAGE_TYPE 129 ! int olsrd_plugin_interface_version(void); ! int olsrd_plugin_register_param(char *name, char *value); ! int olsrd_plugin_init(void); static int ipAddrLen; *************** *** 82,105 **** static struct olsrd_config *config = NULL; - static int (*pluginIo)(int which, void *data, int len); - - static int (*regTimeout)(void (*timeoutFunc)(void)); - static int (*regParser)(void (*parserFunc)(unsigned char *mess, - struct interface *inInt, - union olsr_ip_addr *neighIntAddr), - int type, int forward); - static int (*checkLink)(union olsr_ip_addr *neighIntAddr); - static int (*checkDup)(union olsr_ip_addr *origAddr, unsigned short seqNo); - static int (*forward)(unsigned char *mess, union olsr_ip_addr *origAddr, - unsigned short seqNo, struct interface *inInt, - union olsr_ip_addr *neighIntAddr); - - static unsigned short (*getSeqNo)(void); - static int (*netPush)(struct interface *outInt, void *mess, - unsigned short size); - static int (*netOutput)(struct interface *outInt); - - static void *(*lookupMprs)(union olsr_ip_addr *neighAddr); - static int iterIndex; static struct interface *iterIntTab = NULL; --- 85,88 ---- *************** *** 149,159 **** void iterLinkTabInit(void) { ! if (pluginIo == NULL) ! { ! iterLinkTab = NULL; ! return; ! } ! ! pluginIo(GETD__LINK_SET, &iterLinkTab, sizeof (iterLinkTab)); } --- 132,136 ---- void iterLinkTabInit(void) { ! iterLinkTab = get_link_set(); } *************** *** 172,176 **** iterNeighTab->status == SYM ? "true" : "false", iterNeighTab->is_mpr != 0 ? "true" : "false", ! lookupMprs(&iterNeighTab->neighbor_main_addr) != NULL ? "true" : "false", iterNeighTab->willingness); --- 149,153 ---- iterNeighTab->status == SYM ? "true" : "false", iterNeighTab->is_mpr != 0 ? "true" : "false", ! olsr_lookup_mprs_set(&iterNeighTab->neighbor_main_addr) != NULL ? "true" : "false", iterNeighTab->willingness); *************** *** 362,366 **** return; ! if (checkLink(neighIntAddr) != SYM_LINK) { error("TAS message not from symmetric neighbour\n"); --- 339,343 ---- return; ! if (check_neighbor_link(neighIntAddr) != SYM_LINK) { error("TAS message not from symmetric neighbour\n"); *************** *** 374,378 **** } ! if (checkDup(orig, seqNo) != 0) { len -= ipAddrLen + 8; --- 351,355 ---- } ! if (olsr_check_dup_table_proc(orig, seqNo) != 0) { len -= ipAddrLen + 8; *************** *** 407,411 **** } ! forward(mess, orig, seqNo, inInt, neighIntAddr); } --- 384,388 ---- } ! olsr_forward_message((union olsr_message *)mess, orig, seqNo, inInt, neighIntAddr); } *************** *** 425,429 **** walker = mess = allocMem(len); ! seqNo = getSeqNo(); *walker++ = MESSAGE_TYPE; --- 402,406 ---- walker = mess = allocMem(len); ! seqNo = get_msg_seqno(); *walker++ = MESSAGE_TYPE; *************** *** 455,462 **** for (inter = intTab; inter != NULL; inter = inter->int_next) { ! if (netPush(inter, mess, len) != len) { ! netOutput(inter); ! netPush(inter, mess, len); } } --- 432,439 ---- for (inter = intTab; inter != NULL; inter = inter->int_next) { ! if (net_outbuffer_push(inter, mess, len) != len) { ! net_output(inter); ! net_outbuffer_push(inter, mess, len); } } *************** *** 479,529 **** } ! int get_plugin_interface_version(void) ! { ! httpInit(); ! ! return 3; ! } ! ! int plugin_io(int cmd, void *data, int len) { ! return 0; } ! int register_olsr_data(struct olsr_plugin_data *data) { ! ipAddrLen = addrLen(data->ipversion); ! mainAddr = data->main_addr; ! ! pluginIo = (int (*)(int, void *, int))data->olsr_plugin_io; ! ! pluginIo(GETD__IFNET, &intTab, sizeof (intTab)); ! pluginIo(GETD__NEIGHBORTABLE, &neighTab, sizeof (neighTab)); ! pluginIo(GETD__MID_SET, &midTab, sizeof (midTab)); ! pluginIo(GETD__TC_TABLE, &tcTab, sizeof (tcTab)); ! pluginIo(GETD__HNA_SET, &hnaTab, sizeof (hnaTab)); ! pluginIo(GETD__ROUTINGTABLE, &routeTab, sizeof (routeTab)); ! pluginIo(GETD__OLSR_CNF, &config, sizeof (config)); ! ! pluginIo(GETF__OLSR_REGISTER_TIMEOUT_FUNCTION, ®Timeout, ! sizeof (regTimeout)); ! pluginIo(GETF__OLSR_PARSER_ADD_FUNCTION, ®Parser, sizeof (regParser)); ! pluginIo(GETF__CHECK_NEIGHBOR_LINK, &checkLink, sizeof (checkLink)); ! pluginIo(GETF__OLSR_CHECK_DUP_TABLE_PROC, &checkDup, sizeof (checkDup)); ! pluginIo(GETF__OLSR_FORWARD_MESSAGE, &forward, sizeof (forward)); ! ! pluginIo(GETF__GET_MSG_SEQNO, &getSeqNo, sizeof (getSeqNo)); ! pluginIo(GETF__NET_OUTBUFFER_PUSH, &netPush, sizeof (netPush)); ! pluginIo(GETF__NET_OUTPUT, &netOutput, sizeof (netOutput)); ! pluginIo(GETF__OLSR_LOOKUP_MPRS_SET, &lookupMprs, sizeof (lookupMprs)); ! regTimeout(serviceFunc); ! regParser(parserFunc, MESSAGE_TYPE, 1); return 0; } ! int register_olsr_param(char *name, char *value) { if (strcmp(name, "address") == 0) --- 456,486 ---- } ! int olsrd_plugin_interface_version(void) { ! return 4; } ! int olsrd_plugin_init() { ! ipAddrLen = ipsize; ! mainAddr = &main_addr; ! intTab = ifnet; ! neighTab = neighbortable; ! midTab = mid_set; ! tcTab = tc_table; ! hnaTab = hna_set; ! routeTab = routingtable; ! config = olsr_cnf; ! httpInit(); ! ! olsr_register_timeout_function(serviceFunc); ! olsr_parser_add_function(parserFunc, MESSAGE_TYPE, 1); return 0; } ! int olsrd_plugin_register_param(char *name, char *value) { if (strcmp(name, "address") == 0) Index: os_unix.c =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/lib/tas/src/os_unix.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** os_unix.c 13 Apr 2005 22:10:23 -0000 1.2 --- os_unix.c 29 May 2005 12:47:44 -0000 1.3 *************** *** 82,86 **** } ! void now(struct timeStamp *timeStamp) { time((time_t *)&timeStamp->time); --- 82,86 ---- } ! void os_now(struct timeStamp *timeStamp) { time((time_t *)&timeStamp->time); From (spam-protected) Sun May 29 14:47:48 2005 From: (spam-protected) (Bruno Randolf) Date: Sun, 29 May 2005 12:47:48 +0000 Subject: [Olsr-cvs] olsrd-current/src defs.c, NONE, 1.1 olsrd_plugin.h, NONE, 1.1 apm.h, 1.8, 1.9 defs.h, 1.48, 1.49 hna_set.c, 1.16, 1.17 hna_set.h, 1.13, 1.14 interfaces.c, 1.24, 1.25 interfaces.h, 1.27, 1.28 link_set.c, 1.58, 1.59 link_set.h, 1.26, 1.27 mantissa.h, 1.8, 1.9 mid_set.c, 1.14, 1.15 mid_set.h, 1.12, 1.13 mpr_selector_set.h, 1.11, 1.12 neighbor_table.c, 1.27, 1.28 neighbor_table.h, 1.13, 1.14 olsr.c, 1.45, 1.46 olsr.h, 1.23, 1.24 packet.h, 1.16, 1.17 parser.c, 1.23, 1.24 parser.h, 1.8, 1.9 plugin_loader.c, 1.22, 1.23 plugin_loader.h, 1.14, 1.15 process_routes.c, 1.25, 1.26 process_routes.h, 1.8, 1.9 routing_table.c, 1.21, 1.22 routing_table.h, 1.15, 1.16 socket_parser.c, 1.22, 1.23 socket_parser.h, 1.9, 1.10 tc_set.c, 1.21, 1.22 tc_set.h, 1.14, 1.15 two_hop_neighbor_table.c, 1.15, 1.16 two_hop_neighbor_table.h, 1.13, 1.14 olsr_plugin_io.h, 1.16, NONE plugin.c, 1.20, NONE Message-ID: Update of /cvsroot/olsrd/olsrd-current/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25973/src Modified Files: apm.h defs.h hna_set.c hna_set.h interfaces.c interfaces.h link_set.c link_set.h mantissa.h mid_set.c mid_set.h mpr_selector_set.h neighbor_table.c neighbor_table.h olsr.c olsr.h packet.h parser.c parser.h plugin_loader.c plugin_loader.h process_routes.c process_routes.h routing_table.c routing_table.h socket_parser.c socket_parser.h tc_set.c tc_set.h two_hop_neighbor_table.c two_hop_neighbor_table.h Added Files: defs.c olsrd_plugin.h Removed Files: olsr_plugin_io.h plugin.c 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: mid_set.h =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/src/mid_set.h,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** mid_set.h 20 Feb 2005 18:52:18 -0000 1.12 --- mid_set.h 29 May 2005 12:47:45 -0000 1.13 *************** *** 41,45 **** - #ifndef _OLSR_MID #define _OLSR_MID --- 41,44 ---- *************** *** 72,79 **** ! #ifndef OLSR_PLUGIN - struct mid_entry mid_set[HASHSIZE]; - struct mid_address reverse_mid_set[HASHSIZE]; int --- 71,77 ---- ! extern struct mid_entry mid_set[HASHSIZE]; ! extern struct mid_address reverse_mid_set[HASHSIZE]; int *************** *** 105,107 **** #endif - #endif --- 103,104 ---- Index: packet.h =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/src/packet.h,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** packet.h 20 Feb 2005 17:34:10 -0000 1.16 --- packet.h 29 May 2005 12:47:45 -0000 1.17 *************** *** 40,44 **** */ - #ifndef OLSR_PLUGIN #ifndef _OLSR_PACKET #define _OLSR_PACKET --- 40,43 ---- *************** *** 173,175 **** #endif - #endif --- 172,173 ---- --- NEW FILE: defs.c --- #include "defs.h" FILE *debug_handle; struct olsrd_config *olsr_cnf; olsr_u16_t system_tick_divider; int exit_value; /* Timer data */ clock_t now_times; /* current idea of times(2) reported uptime */ struct timeval now; /* current idea of time */ struct tm *nowtm; /* current idea of time (in tm) */ olsr_bool disp_pack_in; /* display incoming packet content? */ olsr_bool disp_pack_out; /* display outgoing packet content? */ olsr_bool del_gws; float will_int; float max_jitter; size_t ipsize; union olsr_ip_addr main_addr; int olsr_udp_port; int ioctl_s; #if defined __FreeBSD__ || defined __MacOSX__ || defined __NetBSD__ || defined __OpenBSD__ int rts; #endif float max_tc_vtime; clock_t fwdtimer[MAX_IFS]; /* forwarding timer */ int minsize; olsr_bool changes; /* is set if changes occur in MPRS set */ /* TC empty message sending */ clock_t send_empty_tc; Index: olsr.h =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/src/olsr.h,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** olsr.h 28 May 2005 14:01:59 -0000 1.23 --- olsr.h 29 May 2005 12:47:45 -0000 1.24 *************** *** 47,53 **** #include "interfaces.h" ! olsr_bool changes_topology; ! olsr_bool changes_neighborhood; ! olsr_bool changes_hna; void --- 47,53 ---- #include "interfaces.h" ! extern olsr_bool changes_topology; ! extern olsr_bool changes_neighborhood; ! extern olsr_bool changes_hna; void Index: defs.h =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/src/defs.h,v retrieving revision 1.48 retrieving revision 1.49 diff -C2 -d -r1.48 -r1.49 *** defs.h 25 May 2005 20:59:46 -0000 1.48 --- defs.h 29 May 2005 12:47:45 -0000 1.49 *************** *** 40,44 **** */ - #ifndef OLSR_PLUGIN #ifndef _OLSR_DEFS --- 40,43 ---- *************** *** 83,87 **** #endif ! FILE *debug_handle; #ifdef NODEBUG --- 82,86 ---- #endif ! extern FILE *debug_handle; #ifdef NODEBUG *************** *** 126,146 **** */ ! struct olsrd_config *olsr_cnf; /* Global tick resolution */ ! olsr_u16_t system_tick_divider; ! int exit_value; /* Global return value for process termination */ /* Timer data */ ! clock_t now_times; /* current idea of times(2) reported uptime */ ! struct timeval now; /* current idea of time */ ! struct tm *nowtm; /* current idea of time (in tm) */ ! olsr_bool disp_pack_in; /* display incoming packet content? */ ! olsr_bool disp_pack_out; /* display outgoing packet content? */ ! olsr_bool del_gws; /* --- 125,145 ---- */ ! extern struct olsrd_config *olsr_cnf; /* Global tick resolution */ ! extern olsr_u16_t system_tick_divider; ! extern int exit_value; /* Global return value for process termination */ /* Timer data */ ! extern clock_t now_times; /* current idea of times(2) reported uptime */ ! extern struct timeval now; /* current idea of time */ ! extern struct tm *nowtm; /* current idea of time (in tm) */ ! extern olsr_bool disp_pack_in; /* display incoming packet content? */ ! extern olsr_bool disp_pack_out; /* display outgoing packet content? */ ! extern olsr_bool del_gws; /* *************** *** 148,180 **** */ ! float will_int; ! float max_jitter; ! size_t ipsize; /* Main address of this node */ ! union olsr_ip_addr main_addr; /* OLSR UPD port */ ! int olsr_udp_port; /* The socket used for all ioctls */ ! int ioctl_s; /* routing socket */ #if defined __FreeBSD__ || defined __MacOSX__ || defined __NetBSD__ || defined __OpenBSD__ ! int rts; #endif ! float max_tc_vtime; ! clock_t fwdtimer[MAX_IFS]; /* forwarding timer */ ! int minsize; ! olsr_bool changes; /* is set if changes occur in MPRS set */ /* TC empty message sending */ ! clock_t send_empty_tc; /* --- 147,179 ---- */ ! extern float will_int; ! extern float max_jitter; ! extern size_t ipsize; /* Main address of this node */ ! extern union olsr_ip_addr main_addr; /* OLSR UPD port */ ! extern int olsr_udp_port; /* The socket used for all ioctls */ ! extern int ioctl_s; /* routing socket */ #if defined __FreeBSD__ || defined __MacOSX__ || defined __NetBSD__ || defined __OpenBSD__ ! extern int rts; #endif ! extern float max_tc_vtime; ! extern clock_t fwdtimer[MAX_IFS]; /* forwarding timer */ ! extern int minsize; ! extern olsr_bool changes; /* is set if changes occur in MPRS set */ /* TC empty message sending */ ! extern clock_t send_empty_tc; /* *************** *** 202,207 **** ipc_route_send_rtentry(union olsr_ip_addr*, union olsr_ip_addr *, int, int, char *); - - - #endif #endif --- 201,203 ---- Index: mid_set.c =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/src/mid_set.c,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** mid_set.c 26 Feb 2005 23:01:41 -0000 1.14 --- mid_set.c 29 May 2005 12:47:45 -0000 1.15 *************** *** 48,51 **** --- 48,56 ---- #include "link_set.h" + + struct mid_entry mid_set[HASHSIZE]; + struct mid_address reverse_mid_set[HASHSIZE]; + + /** * Initialize the MID set --- plugin.c DELETED --- --- olsr_plugin_io.h DELETED --- Index: hna_set.c =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/src/hna_set.c,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** hna_set.c 27 Feb 2005 10:43:38 -0000 1.16 --- hna_set.c 29 May 2005 12:47:45 -0000 1.17 *************** *** 45,48 **** --- 45,52 ---- + struct hna_entry hna_set[HASHSIZE]; + size_t netmask_size; + + /** *Initialize the HNA set Index: two_hop_neighbor_table.h =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/src/two_hop_neighbor_table.h,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** two_hop_neighbor_table.h 19 Feb 2005 17:43:28 -0000 1.13 --- two_hop_neighbor_table.h 29 May 2005 12:47:46 -0000 1.14 *************** *** 72,78 **** }; - #ifndef OLSR_PLUGIN ! struct neighbor_2_entry two_hop_neighbortable[HASHSIZE]; int --- 72,78 ---- }; ! extern struct neighbor_2_entry two_hop_neighbortable[HASHSIZE]; ! int *************** *** 98,100 **** #endif - #endif --- 98,99 ---- Index: two_hop_neighbor_table.c =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/src/two_hop_neighbor_table.c,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** two_hop_neighbor_table.c 26 Feb 2005 23:01:41 -0000 1.15 --- two_hop_neighbor_table.c 29 May 2005 12:47:46 -0000 1.16 *************** *** 48,51 **** --- 48,54 ---- + struct neighbor_2_entry two_hop_neighbortable[HASHSIZE]; + + /** *Initialize 2 hop neighbor table Index: neighbor_table.h =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/src/neighbor_table.h,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** neighbor_table.h 20 Feb 2005 18:52:18 -0000 1.13 --- neighbor_table.h 29 May 2005 12:47:45 -0000 1.14 *************** *** 74,84 **** - #ifndef OLSR_PLUGIN - /* * The neighbor table */ - struct neighbor_entry neighbortable[HASHSIZE]; void --- 74,82 ---- /* * The neighbor table */ + extern struct neighbor_entry neighbortable[HASHSIZE]; void *************** *** 117,119 **** #endif - #endif --- 115,116 ---- Index: process_routes.h =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/src/process_routes.h,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** process_routes.h 21 Nov 2004 11:28:56 -0000 1.8 --- process_routes.h 29 May 2005 12:47:45 -0000 1.9 *************** *** 48,54 **** #include ! ! struct rt_entry old_routes[HASHSIZE]; ! struct rt_entry old_hna[HASHSIZE]; int --- 48,53 ---- #include ! extern struct rt_entry old_routes[HASHSIZE]; ! extern struct rt_entry old_hna[HASHSIZE]; int Index: socket_parser.h =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/src/socket_parser.h,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** socket_parser.h 21 Nov 2004 11:28:56 -0000 1.9 --- socket_parser.h 29 May 2005 12:47:45 -0000 1.10 *************** *** 52,56 **** }; ! struct olsr_socket_entry *olsr_socket_entries; --- 52,57 ---- }; ! ! extern struct olsr_socket_entry *olsr_socket_entries; Index: apm.h =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/src/apm.h,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** apm.h 7 Apr 2005 18:22:43 -0000 1.8 --- apm.h 29 May 2005 12:47:45 -0000 1.9 *************** *** 58,62 **** }; - #ifndef OLSR_PLUGIN int apm_init(void); --- 58,61 ---- *************** *** 74,76 **** #endif - #endif --- 73,74 ---- --- NEW FILE: olsrd_plugin.h --- (This appears to be a binary file; contents omitted.) Index: process_routes.c =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/src/process_routes.c,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** process_routes.c 23 May 2005 17:27:41 -0000 1.25 --- process_routes.c 29 May 2005 12:47:45 -0000 1.26 *************** *** 53,56 **** --- 53,59 ---- + struct rt_entry old_routes[HASHSIZE]; + struct rt_entry old_hna[HASHSIZE]; + int Index: neighbor_table.c =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/src/neighbor_table.c,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** neighbor_table.c 26 Feb 2005 23:01:41 -0000 1.27 --- neighbor_table.c 29 May 2005 12:47:45 -0000 1.28 *************** *** 52,55 **** --- 52,59 ---- #include "mpr_selector_set.h" + + struct neighbor_entry neighbortable[HASHSIZE]; + + void olsr_init_neighbor_table() Index: hna_set.h =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/src/hna_set.h,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** hna_set.h 20 Feb 2005 17:34:10 -0000 1.13 --- hna_set.h 29 May 2005 12:47:45 -0000 1.14 *************** *** 41,45 **** - #ifndef _OLSR_HNA #define _OLSR_HNA --- 41,44 ---- *************** *** 67,74 **** }; - #ifndef OLSR_PLUGIN ! struct hna_entry hna_set[HASHSIZE]; ! size_t netmask_size; int --- 66,73 ---- }; ! extern struct hna_entry hna_set[HASHSIZE]; ! extern size_t netmask_size; ! int *************** *** 96,100 **** olsr_print_hna_set(void); - - #endif #endif --- 95,97 ---- Index: tc_set.h =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/src/tc_set.h,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** tc_set.h 20 Feb 2005 18:52:19 -0000 1.14 --- tc_set.h 29 May 2005 12:47:46 -0000 1.15 *************** *** 69,76 **** - #ifndef OLSR_PLUGIN - /* Queue */ ! struct tc_entry tc_table[HASHSIZE]; int --- 69,75 ---- /* Queue */ ! extern struct tc_entry tc_table[HASHSIZE]; ! int *************** *** 108,110 **** #endif - #endif --- 107,108 ---- Index: mpr_selector_set.h =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/src/mpr_selector_set.h,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** mpr_selector_set.h 6 Mar 2005 19:33:35 -0000 1.11 --- mpr_selector_set.h 29 May 2005 12:47:45 -0000 1.12 *************** *** 41,50 **** - #ifndef _OLSR_MPRS_SET #define _OLSR_MPRS_SET - struct mpr_selector { --- 41,48 ---- *************** *** 56,61 **** - #ifndef OLSR_PLUGIN - olsr_u16_t get_local_ansn(void); --- 54,57 ---- *************** *** 88,90 **** #endif - #endif --- 84,85 ---- Index: interfaces.c =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/src/interfaces.c,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** interfaces.c 25 May 2005 14:32:52 -0000 1.24 --- interfaces.c 29 May 2005 12:47:45 -0000 1.25 *************** *** 46,51 **** --- 46,60 ---- #include "olsr.h" + static olsr_u32_t if_property_id; + /* The interface linked-list */ + struct interface *ifnet; + + /* Datastructures to use when creating new sockets */ + struct sockaddr_in addrsock; + struct sockaddr_in6 addrsock6; + + /* Ifchange functions */ struct ifchgf Index: link_set.c =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/src/link_set.c,v retrieving revision 1.58 retrieving revision 1.59 diff -C2 -d -r1.58 -r1.59 *** link_set.c 23 May 2005 17:43:01 -0000 1.58 --- link_set.c 29 May 2005 12:47:45 -0000 1.59 *************** *** 55,61 **** #include "lq_route.h" static clock_t hold_time_neighbor; ! static struct link_entry *link_set; static int --- 55,63 ---- #include "lq_route.h" + static clock_t hold_time_neighbor; ! struct link_entry *link_set; ! static int Index: mantissa.h =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/src/mantissa.h,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** mantissa.h 25 May 2005 13:36:26 -0000 1.8 --- mantissa.h 29 May 2005 12:47:45 -0000 1.9 *************** *** 64,72 **** (double)(VTIME_SCALE_FACTOR*(1+(double)(me>>4)/16)*(double)(1<<(me&0x0F))) - #ifndef OLSR_PLUGIN - olsr_u8_t double_to_me(double); #endif - #endif --- 64,69 ---- Index: plugin_loader.c =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/src/plugin_loader.c,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** plugin_loader.c 28 May 2005 15:56:47 -0000 1.22 --- plugin_loader.c 29 May 2005 12:47:45 -0000 1.23 *************** *** 41,44 **** --- 41,45 ---- #include "plugin_loader.h" + #include "olsrd_plugin.h" #include "defs.h" #include "olsr.h" *************** *** 106,123 **** } ! /* Fetch the interface version function */ OLSR_PRINTF(1, "Checking plugin interface version... ") ! if((get_interface_version = dlsym(new_entry.dlhandle, "get_plugin_interface_version")) == NULL) { ! OLSR_PRINTF(1, "trying v1 detection... ") ! if((interface_version = dlsym(new_entry.dlhandle, "plugin_interface_version")) == NULL) { ! OLSR_PRINTF(1, "FAILED: \"%s\"\n", dlerror()) ! dlclose(new_entry.dlhandle); ! return -1; } else { ! new_entry.plugin_interface_version = *interface_version; } } --- 107,132 ---- } ! /* Fetch the interface version function, 3 different ways */ OLSR_PRINTF(1, "Checking plugin interface version... ") ! if((get_interface_version = dlsym(new_entry.dlhandle, "olsrd_plugin_interface_version")) == NULL) { ! OLSR_PRINTF(1, "trying v2 detection... ") ! if((get_interface_version = dlsym(new_entry.dlhandle, "get_plugin_interface_version")) == NULL) { ! OLSR_PRINTF(1, "trying v1 detection... ") ! if((interface_version = dlsym(new_entry.dlhandle, "plugin_interface_version")) == NULL) ! { ! OLSR_PRINTF(1, "FAILED: \"%s\"\n", dlerror()) ! dlclose(new_entry.dlhandle); ! return -1; ! } ! else ! { ! new_entry.plugin_interface_version = *interface_version; ! } } else { ! new_entry.plugin_interface_version = get_interface_version(); } } *************** *** 131,154 **** { /* old plugin interface */ - OLSR_PRINTF(1, "\nWARNING: YOU ARE USING THE OLD PLUGIN INTERFACE! DETECTED %d CURRENT VERSION %d\nPLEASE CONSIDER CHANGING YOUR PLUGIN TO THE NEW VERSION!\nWILL CONTINUE IN 5 SECONDS...\n\n", get_interface_version(), PLUGIN_INTERFACE_VERSION) sleep(5); ! ! OLSR_PRINTF(1, "Trying to fetch register function... ") ! if((new_entry.register_olsr_data = dlsym(new_entry.dlhandle, "register_olsr_data")) == NULL) ! { ! /* This function must be present */ ! OLSR_PRINTF(1, "\nCould not find function registration function in plugin!\n%s\nCRITICAL ERROR - aborting!\n", dlerror()) ! dlclose(new_entry.dlhandle); ! return -1; ! } ! OLSR_PRINTF(1, "OK\n") ! ! /* Fetch the multipurpose function */ ! OLSR_PRINTF(1, "Trying to fetch plugin IO function... ") ! if((new_entry.plugin_io = dlsym(new_entry.dlhandle, "plugin_io")) == NULL) ! OLSR_PRINTF(1, "FAILED: \"%s\"\n", dlerror()) ! else ! OLSR_PRINTF(1, "OK\n") } else --- 140,149 ---- { /* old plugin interface */ + + OLSR_PRINTF(1, "\nWARNING: YOU ARE USING AN OLD DEPRECATED PLUGIN INTERFACE! DETECTED VERSION %d CURRENT VERSION %d\nPLEASE UPGRADE YOUR PLUGIN!\nWILL CONTINUE IN 5 SECONDS...\n\n", new_entry.plugin_interface_version, OLSRD_PLUGIN_INTERFACE_VERSION) sleep(5); ! dlclose(new_entry.dlhandle); ! return -1; } else *************** *** 156,162 **** /* new plugin interface */ ! if ( new_entry.plugin_interface_version != PLUGIN_INTERFACE_VERSION ) { ! OLSR_PRINTF(1, "\n\nWARNING: VERSION MISSMATCH! DETECTED %d CURRENT VERSION %d\nTHIS CAN CAUSE UNEXPECTED BEHAVIOUR AND CRASHES!\nWILL CONTINUE IN 5 SECONDS...\n\n", get_interface_version(), PLUGIN_INTERFACE_VERSION) sleep(5); } --- 151,157 ---- /* new plugin interface */ ! if ( new_entry.plugin_interface_version != OLSRD_PLUGIN_INTERFACE_VERSION ) { ! OLSR_PRINTF(1, "\n\nWARNING: VERSION MISSMATCH! DETECTED %d CURRENT VERSION %d\nTHIS CAN CAUSE UNEXPECTED BEHAVIOUR AND CRASHES!\nWILL CONTINUE IN 5 SECONDS...\n\n", get_interface_version(), OLSRD_PLUGIN_INTERFACE_VERSION) sleep(5); } *************** *** 164,170 **** /* Fetch the init function */ OLSR_PRINTF(1, "Trying to fetch plugin init function... ") ! if((new_entry.plugin_init = dlsym(new_entry.dlhandle, "plugin_init")) == NULL) ! { ! OLSR_PRINTF(1, "FAILED: \"%s\"\n", dlerror()) dlclose(new_entry.dlhandle); return -1; --- 159,165 ---- /* Fetch the init function */ OLSR_PRINTF(1, "Trying to fetch plugin init function... ") ! if((new_entry.plugin_init = dlsym(new_entry.dlhandle, "olsrd_plugin_init")) == NULL) ! { ! OLSR_PRINTF(1, "FAILED: \"%s\"\n", dlerror()) dlclose(new_entry.dlhandle); return -1; *************** *** 178,182 **** /* Fetch the parameter function */ OLSR_PRINTF(1, "Trying to fetch param function... ") ! if((new_entry.register_param = dlsym(new_entry.dlhandle, "register_olsr_param")) == NULL) OLSR_PRINTF(1, "FAILED: \"%s\"\n", dlerror()) else --- 173,177 ---- /* Fetch the parameter function */ OLSR_PRINTF(1, "Trying to fetch param function... ") ! if((new_entry.register_param = dlsym(new_entry.dlhandle, "olsrd_plugin_register_param")) == NULL) OLSR_PRINTF(1, "FAILED: \"%s\"\n", dlerror()) else *************** *** 213,217 **** init_olsr_plugin(struct olsr_plugin *entry) { - struct olsr_plugin_data plugin_data; struct plugin_param *params = entry->params; int retval; --- 208,211 ---- *************** *** 233,256 **** } } ! ! if (entry->plugin_interface_version < 4) ! { ! /* old plugin interface */ ! ! OLSR_PRINTF(1, "Running registration function...\n") ! /* Fill struct */ ! plugin_data.ipversion = olsr_cnf->ip_version; ! plugin_data.main_addr = &main_addr; ! plugin_data.olsr_plugin_io = &olsr_plugin_io; ! ! /* Register data with plugin */ ! entry->register_olsr_data(&plugin_data); ! } ! else ! { ! /* new plugin interface */ ! OLSR_PRINTF(1, "Running plugin_init function...\n") ! entry->plugin_init(); ! } } --- 227,233 ---- } } ! ! OLSR_PRINTF(1, "Running plugin_init function...\n") ! entry->plugin_init(); } Index: socket_parser.c =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/src/socket_parser.c,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** socket_parser.c 27 Feb 2005 18:39:43 -0000 1.22 --- socket_parser.c 29 May 2005 12:47:45 -0000 1.23 *************** *** 57,60 **** --- 57,62 ---- + struct olsr_socket_entry *olsr_socket_entries; + static int hfd = 0; Index: tc_set.c =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/src/tc_set.c,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** tc_set.c 26 Feb 2005 23:01:41 -0000 1.21 --- tc_set.c 29 May 2005 12:47:46 -0000 1.22 *************** *** 46,49 **** --- 46,53 ---- #include "lq_route.h" + + struct tc_entry tc_table[HASHSIZE]; + + /** * Initialize the topology set Index: interfaces.h =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/src/interfaces.h,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** interfaces.h 23 May 2005 14:12:57 -0000 1.27 --- interfaces.h 29 May 2005 12:47:45 -0000 1.28 *************** *** 143,148 **** #define OLSR_DEFAULT_MTU 1500 - #ifndef OLSR_PLUGIN - /* Ifchange actions */ --- 143,146 ---- *************** *** 154,163 **** #define IFCHANGES_POLL_INT 2.5 /* The interface linked-list */ ! struct interface *ifnet; /* Datastructures to use when creating new sockets */ ! struct sockaddr_in addrsock; ! struct sockaddr_in6 addrsock6; int --- 152,163 ---- #define IFCHANGES_POLL_INT 2.5 + /* The interface linked-list */ ! extern struct interface *ifnet; /* Datastructures to use when creating new sockets */ ! extern struct sockaddr_in addrsock; ! extern struct sockaddr_in6 addrsock6; ! int *************** *** 198,200 **** #endif - #endif --- 198,199 ---- Index: olsr.c =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/src/olsr.c,v retrieving revision 1.45 retrieving revision 1.46 diff -C2 -d -r1.45 -r1.46 *** olsr.c 28 May 2005 14:01:59 -0000 1.45 --- olsr.c 29 May 2005 12:47:45 -0000 1.46 *************** *** 66,69 **** --- 66,74 ---- + olsr_bool changes_topology; + olsr_bool changes_neighborhood; + olsr_bool changes_hna; + + /** * Process changes functions Index: parser.c =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/src/parser.c,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** parser.c 26 May 2005 09:55:11 -0000 1.23 --- parser.c 29 May 2005 12:47:45 -0000 1.24 *************** *** 62,65 **** --- 62,67 ---- #endif + struct parse_function_entry *parse_functions; + static char inbuf[MAXMESSAGESIZE+1]; Index: plugin_loader.h =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/src/plugin_loader.h,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** plugin_loader.h 26 May 2005 16:09:26 -0000 1.14 --- plugin_loader.h 29 May 2005 12:47:45 -0000 1.15 *************** *** 48,64 **** #include "olsr_cfg.h" - /* Data to sent to the plugin with the register_olsr_function call */ - struct olsr_plugin_data - { - int ipversion; - union olsr_ip_addr *main_addr; - int (*olsr_plugin_io)(int, void *, size_t); - }; - #ifndef OLSR_PLUGIN #define MAX_LIBS 10 - #define PLUGIN_INTERFACE_VERSION 4 - struct olsr_plugin --- 48,54 ---- *************** *** 70,78 **** int plugin_interface_version; - /* old interface (PLUGIN_INTERFACE_VERSION <= 3) */ - int (*register_olsr_data)(struct olsr_plugin_data *); - int (*plugin_io)(int, void *, size_t); /* Multi - purpose function */ - - /* new interface (PLUGIN_INTERFACE_VERSION >= 4)*/ int (*register_param)(char *, char *); int (*plugin_init)(void); --- 60,63 ---- Index: routing_table.h =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/src/routing_table.h,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** routing_table.h 20 Apr 2005 17:52:12 -0000 1.15 --- routing_table.h 29 May 2005 12:47:45 -0000 1.16 *************** *** 91,98 **** ! #ifndef OLSR_PLUGIN ! ! struct rt_entry routingtable[HASHSIZE]; ! struct rt_entry hna_routes[HASHSIZE]; --- 91,96 ---- ! extern struct rt_entry routingtable[HASHSIZE]; ! extern struct rt_entry hna_routes[HASHSIZE]; *************** *** 119,121 **** #endif - #endif --- 117,118 ---- Index: link_set.h =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/src/link_set.h,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** link_set.h 23 May 2005 17:43:01 -0000 1.26 --- link_set.h 29 May 2005 12:47:45 -0000 1.27 *************** *** 48,54 **** #define _LINK_SET_H - #ifndef OLSR_PLUGIN #include "packet.h" - #endif #define MID_ALIAS_HACK_VTIME 10.0 --- 48,52 ---- *************** *** 104,108 **** }; ! #ifndef OLSR_PLUGIN /* Function prototypes */ --- 102,109 ---- }; ! ! extern struct link_entry *link_set; ! ! /* Function prototypes */ *************** *** 143,147 **** void olsr_print_link_set(void); - #endif #endif --- 144,147 ---- Index: parser.h =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/src/parser.h,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** parser.h 10 Mar 2005 07:01:48 -0000 1.8 --- parser.h 29 May 2005 12:47:45 -0000 1.9 *************** *** 58,62 **** ! struct parse_function_entry *parse_functions; void --- 58,62 ---- ! extern struct parse_function_entry *parse_functions; void Index: routing_table.c =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/src/routing_table.c,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** routing_table.c 19 May 2005 20:26:22 -0000 1.21 --- routing_table.c 29 May 2005 12:47:45 -0000 1.22 *************** *** 51,54 **** --- 51,58 ---- + struct rt_entry routingtable[HASHSIZE]; + struct rt_entry hna_routes[HASHSIZE]; + + /* Begin: * Prototypes for internal functions From (spam-protected) Sun May 29 14:47:42 2005 From: (spam-protected) (Bruno Randolf) Date: Sun, 29 May 2005 12:47:42 +0000 Subject: [Olsr-cvs] olsrd-current/lib/dot_draw version-script.txt,1.1,1.2 Message-ID: Update of /cvsroot/olsrd/olsrd-current/lib/dot_draw In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25973/lib/dot_draw Modified Files: version-script.txt 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: version-script.txt =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/lib/dot_draw/version-script.txt,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** version-script.txt 8 Nov 2004 23:43:13 -0000 1.1 --- version-script.txt 29 May 2005 12:47:35 -0000 1.2 *************** *** 2,9 **** { global: ! get_plugin_interface_version; ! register_olsr_data; ! plugin_io; ! register_olsr_param; local: --- 2,8 ---- { global: ! olsrd_plugin_interface_version; ! olsrd_plugin_register_param; ! olsrd_plugin_init; local: From (spam-protected) Sun May 29 14:47:42 2005 From: (spam-protected) (Bruno Randolf) Date: Sun, 29 May 2005 12:47:42 +0000 Subject: [Olsr-cvs] olsrd-current/lib/dyn_gw version-script.txt,1.1,1.2 Message-ID: Update of /cvsroot/olsrd/olsrd-current/lib/dyn_gw In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25973/lib/dyn_gw Modified Files: version-script.txt 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: version-script.txt =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/lib/dyn_gw/version-script.txt,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** version-script.txt 8 Nov 2004 23:43:13 -0000 1.1 --- version-script.txt 29 May 2005 12:47:40 -0000 1.2 *************** *** 2,9 **** { global: ! get_plugin_interface_version; ! register_olsr_data; ! plugin_io; ! register_olsr_param; local: --- 2,8 ---- { global: ! olsrd_plugin_interface_version; ! olsrd_plugin_register_param; ! olsrd_plugin_init; local: From (spam-protected) Sun May 29 14:47:43 2005 From: (spam-protected) (Bruno Randolf) Date: Sun, 29 May 2005 12:47:43 +0000 Subject: [Olsr-cvs] olsrd-current/lib/mini version-script.txt,1.1,1.2 Message-ID: Update of /cvsroot/olsrd/olsrd-current/lib/mini In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25973/lib/mini Modified Files: version-script.txt 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: version-script.txt =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/lib/mini/version-script.txt,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** version-script.txt 26 May 2005 16:09:25 -0000 1.1 --- version-script.txt 29 May 2005 12:47:41 -0000 1.2 *************** *** 2,5 **** --- 2,10 ---- { global: + olsrd_plugin_interface_version; + olsrd_plugin_register_param; + olsrd_plugin_init; + + local: *; }; From (spam-protected) Sun May 29 14:47:44 2005 From: (spam-protected) (Bruno Randolf) Date: Sun, 29 May 2005 12:47:44 +0000 Subject: [Olsr-cvs] olsrd-current/lib/mini/src olsrd_plugin.c, 1.1, 1.2 olsrd_plugin.h, 1.1, NONE Message-ID: Update of /cvsroot/olsrd/olsrd-current/lib/mini/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25973/lib/mini/src Modified Files: olsrd_plugin.c 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 --- olsrd_plugin.h DELETED --- Index: olsrd_plugin.c =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/lib/mini/src/olsrd_plugin.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** olsrd_plugin.c 26 May 2005 16:09:25 -0000 1.1 --- olsrd_plugin.c 29 May 2005 12:47:41 -0000 1.2 *************** *** 54,60 **** */ int ! get_plugin_interface_version() { ! return PLUGIN_INTERFACE_VERSION; } --- 54,60 ---- */ int ! olsrd_plugin_interface_version() { ! return OLSRD_PLUGIN_INTERFACE_VERSION; } *************** *** 65,69 **** */ int ! register_olsr_param(char *key, char *value) { if(!strcmp(key, "test")) { --- 65,69 ---- */ int ! olsrd_plugin_register_param(char *key, char *value) { if(!strcmp(key, "test")) { *************** *** 80,84 **** */ int ! plugin_init() { printf("*** MINI: plugin_init\n"); --- 80,84 ---- */ int ! olsrd_plugin_init() { printf("*** MINI: plugin_init\n"); *************** *** 97,100 **** --- 97,107 ---- /* attention: make static to avoid name clashes */ + static void __attribute__ ((constructor)) + my_init(void); + + static void __attribute__ ((destructor)) + my_fini(void); + + /** * Optional Private Constructor From (spam-protected) Sun May 29 14:47:43 2005 From: (spam-protected) (Bruno Randolf) Date: Sun, 29 May 2005 12:47:43 +0000 Subject: [Olsr-cvs] olsrd-current/lib/httpinfo version-script.txt,1.1,1.2 Message-ID: Update of /cvsroot/olsrd/olsrd-current/lib/httpinfo In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25973/lib/httpinfo Modified Files: version-script.txt 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: version-script.txt =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/lib/httpinfo/version-script.txt,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** version-script.txt 15 Dec 2004 20:11:49 -0000 1.1 --- version-script.txt 29 May 2005 12:47:41 -0000 1.2 *************** *** 2,9 **** { global: ! get_plugin_interface_version; ! register_olsr_data; ! plugin_io; ! register_olsr_param; local: --- 2,8 ---- { global: ! olsrd_plugin_interface_version; ! olsrd_plugin_register_param; ! olsrd_plugin_init; local: From (spam-protected) Sun May 29 14:47:42 2005 From: (spam-protected) (Bruno Randolf) Date: Sun, 29 May 2005 12:47:42 +0000 Subject: [Olsr-cvs] olsrd-current/lib/dot_draw/src olsrd_dot_draw.c, 1.13, 1.14 olsrd_dot_draw.h, 1.6, 1.7 olsrd_plugin.c, 1.10, 1.11 olsrd_plugin.h, 1.17, NONE Message-ID: Update of /cvsroot/olsrd/olsrd-current/lib/dot_draw/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25973/lib/dot_draw/src Modified Files: olsrd_dot_draw.c olsrd_dot_draw.h olsrd_plugin.c 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 --- olsrd_plugin.h DELETED --- Index: olsrd_dot_draw.h =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/lib/dot_draw/src/olsrd_dot_draw.h,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** olsrd_dot_draw.h 20 Feb 2005 15:51:15 -0000 1.6 --- olsrd_dot_draw.h 29 May 2005 12:47:40 -0000 1.7 *************** *** 45,82 **** */ ! #ifndef _OLSRD_PLUGIN_TEST ! #define _OLSRD_PLUGIN_TEST - #include "olsrd_plugin.h" - char netmask[5]; - /* Event function to register with the sceduler */ int ! pcf_event(int, int, int); void ! ipc_action(int); ! ! static void inline ! ipc_print_neigh_link(struct neighbor_entry *neighbor); ! ! static void inline ! ipc_print_tc_link(struct tc_entry *entry, struct topo_dst *dst_entry); ! ! static void inline ! ipc_print_net(union olsr_ip_addr *, union olsr_ip_addr *, union hna_netmask *); ! ! int ! ipc_send(char *, int); ! ! char * ! olsr_ip_to_string(union olsr_ip_addr *); ! ! char * ! olsr_netmask_to_string(union hna_netmask *); ! ! struct link_entry *olsr_neighbor_best_link(union olsr_ip_addr *main); #endif --- 45,61 ---- */ ! #ifndef _OLSRD_DOT_DRAW ! #define _OLSRD_DOT_DRAW + extern struct in_addr ipc_accept_ip; + extern int ipc_port; int ! olsrd_plugin_init(void); void ! olsr_plugin_exit(void); #endif Index: olsrd_dot_draw.c =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/lib/dot_draw/src/olsrd_dot_draw.c,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** olsrd_dot_draw.c 25 May 2005 16:33:24 -0000 1.13 --- olsrd_dot_draw.c 29 May 2005 12:47:40 -0000 1.14 *************** *** 45,49 **** */ ! #include "olsrd_dot_draw.h" #include #include --- 45,56 ---- */ ! ! #include ! #include ! #include ! #include ! #include ! #include ! #include #include #include *************** *** 51,58 **** --- 58,81 ---- #include #include + + #include "olsr.h" + #include "olsr_types.h" + #include "neighbor_table.h" + #include "two_hop_neighbor_table.h" + #include "tc_set.h" + #include "hna_set.h" + #include "mid_set.h" + #include "link_set.h" + #include "socket_parser.h" + + #include "olsrd_dot_draw.h" + #include "olsrd_plugin.h" + + #ifdef WIN32 #define close(x) closesocket(x) #endif + int ipc_socket; int ipc_open; *************** *** 60,63 **** --- 83,113 ---- int ipc_socket_up; + + /* IPC initialization function */ + static int + plugin_ipc_init(void); + + static char* + olsr_netmask_to_string(union hna_netmask *mask); + + /* Event function to register with the sceduler */ + static int + pcf_event(int, int, int); + + static void + ipc_action(int); + + static void inline + ipc_print_neigh_link(struct neighbor_entry *neighbor); + + static void inline + ipc_print_tc_link(struct tc_entry *entry, struct topo_dst *dst_entry); + + static void inline + ipc_print_net(union olsr_ip_addr *, union olsr_ip_addr *, union hna_netmask *); + + static int + ipc_send(char *, int); + static double calc_etx(double, double); *************** *** 67,70 **** --- 117,149 ---- + /** + *Do initialization here + * + *This function is called by the my_init + *function in uolsrd_plugin.c + */ + int + olsrd_plugin_init() + { + /* Initial IPC value */ + ipc_open = 0; + ipc_socket_up = 0; + + /* Register the "ProcessChanges" function */ + register_pcf(&pcf_event); + + return 1; + } + + + /** + * destructor - called at unload + */ + void + olsr_plugin_exit() + { + if(ipc_open) + close(ipc_socket); + } *************** *** 78,82 **** char* style = "solid"; struct link_entry* link; ! adr = olsr_ip_to_string(main_addr); len = sprintf( buf, "\"%s\" -> ", adr ); ipc_send(buf, len); --- 157,161 ---- char* style = "solid"; struct link_entry* link; ! adr = olsr_ip_to_string(&main_addr); len = sprintf( buf, "\"%s\" -> ", adr ); ipc_send(buf, len); *************** *** 87,101 **** style = "dashed"; } ! else { ! /* find best link to neighbor for the ETX */ ! //? why cant i just get it one time at fetch_olsrd_data??? (br1) ! if(olsr_plugin_io(GETD__LINK_SET, &link, sizeof(link)) && link) ! { ! link_set = link; // for olsr_neighbor_best_link ! link = olsr_neighbor_best_link(&neighbor->neighbor_main_addr); if (link) { etx = calc_etx( link->loss_link_quality, link->neigh_link_quality); } - } } --- 166,174 ---- style = "dashed"; } ! else { ! link = get_best_link_to_neighbor(&neighbor->neighbor_main_addr); if (link) { etx = calc_etx( link->loss_link_quality, link->neigh_link_quality); } } *************** *** 109,133 **** } - /** - *Do initialization here - * - *This function is called by the my_init - *function in uolsrd_plugin.c - */ - int - olsr_plugin_init() - { ! /* Initial IPC value */ ! ipc_open = 0; ! ipc_socket_up = 0; ! ! /* Register the "ProcessChanges" function */ ! register_pcf(&pcf_event); ! ! return 1; ! } ! ! int plugin_ipc_init() { --- 182,187 ---- } ! static int plugin_ipc_init() { *************** *** 188,192 **** } ! void ipc_action(int fd) { --- 242,247 ---- } ! ! static void ipc_action(int fd) { *************** *** 218,257 **** } } - } - /* - * destructor - called at unload - */ - void - olsr_plugin_exit() - { - if(ipc_open) - close(ipc_socket); - } - - - - /* Mulitpurpose funtion */ - int - plugin_io(int cmd, void *data, size_t size) - { - - switch(cmd) - { - default: - return 0; - } - - return 1; - } - - - /** *Scheduled event */ ! int pcf_event(int changes_neighborhood, int changes_topology, --- 273,283 ---- } } } /** *Scheduled event */ ! static int pcf_event(int changes_neighborhood, int changes_topology, *************** *** 339,342 **** --- 365,369 ---- } + #define MIN_LINK_QUALITY 0.01 static double *************** *** 367,370 **** --- 394,398 ---- } + static void inline ipc_print_net(union olsr_ip_addr *gw, union olsr_ip_addr *net, union hna_netmask *mask) *************** *** 393,398 **** ! ! int ipc_send(char *data, int size) { --- 421,425 ---- ! static int ipc_send(char *data, int size) { *************** *** 416,470 **** ! ! ! /** ! *Converts a olsr_ip_addr to a string ! *Goes for both IPv4 and IPv6 ! * ! *@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) ! { ! static int index = 0; ! static char buff[4][100]; ! 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)); ! } ! ! strncpy(buff[index], ret, 100); ! ! ret = buff[index]; ! ! index = (index + 1) & 3; ! ! return ret; ! } ! ! ! /** ! *This function is just as bad as the previous one :-( ! */ ! char * olsr_netmask_to_string(union hna_netmask *mask) { char *ret; struct in_addr in; ! ! if(ipversion == AF_INET) { in.s_addr = mask->v4; --- 443,455 ---- + static char netmask[5]; ! static char* olsr_netmask_to_string(union hna_netmask *mask) { char *ret; struct in_addr in; ! ! if(olsr_cnf->ip_version == AF_INET) { in.s_addr = mask->v4; *************** *** 482,513 **** return ret; } - - #define COMP_IP(ip1, ip2) (!memcmp(ip1, ip2, ipsize)) - struct link_entry *olsr_neighbor_best_link(union olsr_ip_addr *main) - { - struct link_entry *walker; - double best = 0.0; - double curr; - struct link_entry *res = NULL; - - // loop through all links - - for (walker = link_set; walker != NULL; walker = walker->next) - { - // check whether it's a link to the requested neighbor and - // whether the link's quality is better than what we have - if(COMP_IP(main, &walker->neighbor->neighbor_main_addr)) - { - curr = walker->loss_link_quality * walker->neigh_link_quality; - - if (curr >= best) - { - best = curr; - res = walker; - } - } - } - - return res; - } - --- 467,468 ---- Index: olsrd_plugin.c =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/lib/dot_draw/src/olsrd_plugin.c,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** olsrd_plugin.c 25 Feb 2005 22:43:21 -0000 1.10 --- olsrd_plugin.c 29 May 2005 12:47:40 -0000 1.11 *************** *** 45,79 **** - #include "olsrd_plugin.h" #include #include #include ! #include "plugin_loader.h" - 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); ! /* ! * 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 ! get_plugin_interface_version() ! { ! return PLUGIN_INTERFACE_VERSION; ! } --- 45,73 ---- #include #include #include ! #include + #include "olsrd_plugin.h" + #include "olsrd_dot_draw.h" ! #define PLUGIN_NAME "OLSRD dot draw plugin" ! #define PLUGIN_VERSION "0.3" ! #define PLUGIN_AUTHOR "Andreas T�nnesen" ! #define MOD_DESC PLUGIN_NAME " " PLUGIN_VERSION " by " PLUGIN_AUTHOR ! #define PLUGIN_INTERFACE_VERSION 4 ! struct in_addr ipc_accept_ip; ! int ipc_port; ! static void __attribute__ ((constructor)) ! my_init(void); + static void __attribute__ ((destructor)) + my_fini(void); *************** *** 81,85 **** *Constructor */ ! void my_init() { --- 75,79 ---- *Constructor */ ! static void my_init() { *************** *** 90,104 **** ipc_port = 2004; ipc_accept_ip.s_addr = htonl(INADDR_LOOPBACK); - - return; } /** *Destructor */ ! void my_fini() { - /* Calls the destruction function * olsr_plugin_exit() --- 84,96 ---- ipc_port = 2004; ipc_accept_ip.s_addr = htonl(INADDR_LOOPBACK); } + /** *Destructor */ ! static void my_fini() { /* Calls the destruction function * olsr_plugin_exit() *************** *** 108,117 **** */ olsr_plugin_exit(); ! return; } int ! register_olsr_param(char *key, char *value) { if(!strcmp(key, "port")) --- 100,115 ---- */ olsr_plugin_exit(); + } ! ! int ! olsrd_plugin_interface_version() ! { ! return PLUGIN_INTERFACE_VERSION; } + int ! olsrd_plugin_register_param(char *key, char *value) { if(!strcmp(key, "port")) *************** *** 128,282 **** 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; - } - - if(!plugin_ipc_init()) - { - fprintf(stderr, "Could not initialize plugin IPC!\n"); - return 0; - } - - return 1; - - } - - - - int - fetch_olsrd_data() - { - int retval = 1; - - - /* Neighbor table */ - if(!olsr_plugin_io(GETD__NEIGHBORTABLE, - &neighbortable, - sizeof(neighbortable))) - { - neighbortable = NULL; - retval = 0; - } - - /* Two hop neighbor table */ - if(!olsr_plugin_io(GETD__TWO_HOP_NEIGHBORTABLE, - &two_hop_neighbortable, - sizeof(two_hop_neighbortable))) - { - two_hop_neighbortable = NULL; - retval = 0; - } - - /* link set */ - if(!olsr_plugin_io(GETD__LINK_SET, &link_set, sizeof(link_set))) { - link_set = NULL; - printf("********* err\n"); - retval = 0; - } - - /* Topoloy table */ - if(!olsr_plugin_io(GETD__TC_TABLE, - &tc_table, - sizeof(tc_table))) - { - tc_table = NULL; - retval = 0; - } - - /* HNA table */ - if(!olsr_plugin_io(GETD__HNA_SET, - &hna_set, - sizeof(hna_set))) - { - hna_set = 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; - } - - /* "ProcessChanges" event registration */ - if(!olsr_plugin_io(GETF__REGISTER_PCF, - ®ister_pcf, - sizeof(register_pcf))) - { - register_pcf = 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; - } - - /* Remove socket from OLSR select function */ - if(!olsr_plugin_io(GETF__REMOVE_OLSR_SOCKET, &remove_olsr_socket, sizeof(remove_olsr_socket))) - { - remove_olsr_socket = NULL; - retval = 0; - } - - return retval; - - } --- 126,127 ---- From (spam-protected) Sun May 29 14:47:44 2005 From: (spam-protected) (Bruno Randolf) Date: Sun, 29 May 2005 12:47:44 +0000 Subject: [Olsr-cvs] olsrd-current/lib/nameservice version-script.txt, 1.1, 1.2 Message-ID: Update of /cvsroot/olsrd/olsrd-current/lib/nameservice In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25973/lib/nameservice Modified Files: version-script.txt 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: version-script.txt =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/lib/nameservice/version-script.txt,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** version-script.txt 16 Jan 2005 13:06:11 -0000 1.1 --- version-script.txt 29 May 2005 12:47:42 -0000 1.2 *************** *** 2,9 **** { global: ! get_plugin_interface_version; ! register_olsr_data; ! plugin_io; ! register_olsr_param; local: --- 2,8 ---- { global: ! olsrd_plugin_interface_version; ! olsrd_plugin_register_param; ! olsrd_plugin_init; local: From (spam-protected) Sun May 29 14:47:43 2005 From: (spam-protected) (Bruno Randolf) Date: Sun, 29 May 2005 12:47:43 +0000 Subject: [Olsr-cvs] olsrd-current/lib/dyn_gw/src olsrd_dyn_gw.c, 1.16, 1.17 olsrd_dyn_gw.h, 1.10, 1.11 olsrd_plugin.c, 1.11, 1.12 olsrd_plugin.h, 1.15, NONE Message-ID: Update of /cvsroot/olsrd/olsrd-current/lib/dyn_gw/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25973/lib/dyn_gw/src Modified Files: olsrd_dyn_gw.c olsrd_dyn_gw.h olsrd_plugin.c 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_dyn_gw.c =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/lib/dyn_gw/src/olsrd_dyn_gw.c,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** olsrd_dyn_gw.c 25 May 2005 16:33:24 -0000 1.16 --- olsrd_dyn_gw.c 29 May 2005 12:47:40 -0000 1.17 *************** *** 46,50 **** --- 46,57 ---- */ + #include + + #include "olsr_types.h" #include "olsrd_dyn_gw.h" + #include "scheduler.h" + #include "olsr.h" + #include "local_hna_set.h" + #include #include *************** *** 83,86 **** --- 90,94 ---- #endif + /* set default interval, in case none is given in the config file */ static int check_interval = 5; *************** *** 99,103 **** struct hna_list { union olsr_ip_addr hna_net; ! union hna_netmask hna_netmask; struct ping_list *ping_hosts; int hna_added; --- 107,111 ---- struct hna_list { union olsr_ip_addr hna_net; ! union olsr_ip_addr hna_netmask; struct ping_list *ping_hosts; int hna_added; *************** *** 109,113 **** add_to_hna_list(struct hna_list *, union olsr_ip_addr *hna_net, ! union hna_netmask *hna_netmask ); struct hna_list *the_hna_list = NULL; --- 117,121 ---- add_to_hna_list(struct hna_list *, union olsr_ip_addr *hna_net, ! union olsr_ip_addr *hna_netmask ); struct hna_list *the_hna_list = NULL; *************** *** 117,121 **** static int ! check_gw(union olsr_ip_addr *, union hna_netmask *,struct ping_list *); static int --- 125,129 ---- static int ! check_gw(union olsr_ip_addr *, union olsr_ip_addr *,struct ping_list *); static int *************** *** 129,133 **** */ int ! register_olsr_param(char *key, char *value) { /* foo_addr is only used for call to inet_aton */ --- 137,141 ---- */ int ! olsrd_plugin_register_param(char *key, char *value) { /* foo_addr is only used for call to inet_aton */ *************** *** 136,140 **** int i; union olsr_ip_addr temp_net; ! union hna_netmask temp_netmask; char s_netaddr[16]; char s_mask[16]; --- 144,148 ---- int i; union olsr_ip_addr temp_net; ! union olsr_ip_addr temp_netmask; char s_netaddr[16]; char s_mask[16]; *************** *** 189,193 **** */ int ! olsr_plugin_init() { pthread_t ping_thread; --- 197,201 ---- */ int ! olsrd_plugin_init() { pthread_t ping_thread; *************** *** 215,246 **** - - /* - * destructor - called at unload - */ - void - olsr_plugin_exit() - { - - } - - - - /* Mulitpurpose funtion */ - int - plugin_io(int cmd, void *data, size_t size) - { - - switch(cmd) - { - default: - return 0; - } - - return 1; - } - - - /** * Scheduled event to update the hna table, --- 223,226 ---- *************** *** 248,252 **** */ void ! olsr_event_doing_hna() { struct hna_list *li; --- 228,232 ---- */ void ! olsr_event_doing_hna(void *foo) { struct hna_list *li; *************** *** 277,285 **** } } - - - - - --- 257,260 ---- *************** *** 309,313 **** /* the time to wait in "Interval" sec (see connfig), default=5sec */ struct timespec sleeptime_spec = {(time_t) check_interval, 0L }; ! li=the_hna_list; while(li){ --- 284,288 ---- /* the time to wait in "Interval" sec (see connfig), default=5sec */ struct timespec sleeptime_spec = {(time_t) check_interval, 0L }; ! li=the_hna_list; while(li){ *************** *** 326,330 **** static int ! check_gw(union olsr_ip_addr *net, union hna_netmask *mask, struct ping_list *the_ping_list) { char buff[1024], iface[16]; --- 301,305 ---- static int ! check_gw(union olsr_ip_addr *net, union olsr_ip_addr *mask, struct ping_list *the_ping_list) { char buff[1024], iface[16]; *************** *** 436,440 **** static struct hna_list * ! add_to_hna_list(struct hna_list * list_root, union olsr_ip_addr *hna_net, union hna_netmask *hna_netmask ) { struct hna_list *new = (struct hna_list *) malloc(sizeof(struct hna_list)); --- 411,415 ---- static struct hna_list * ! add_to_hna_list(struct hna_list * list_root, union olsr_ip_addr *hna_net, union olsr_ip_addr *hna_netmask ) { struct hna_list *new = (struct hna_list *) malloc(sizeof(struct hna_list)); Index: olsrd_dyn_gw.h =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/lib/dyn_gw/src/olsrd_dyn_gw.h,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** olsrd_dyn_gw.h 19 Feb 2005 17:56:05 -0000 1.10 --- olsrd_dyn_gw.h 29 May 2005 12:47:40 -0000 1.11 *************** *** 58,62 **** /* Event function to register with the scheduler */ void ! olsr_event_doing_hna(void); #endif --- 58,62 ---- /* Event function to register with the scheduler */ void ! olsr_event_doing_hna(void *); #endif --- olsrd_plugin.h DELETED --- Index: olsrd_plugin.c =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/lib/dyn_gw/src/olsrd_plugin.c,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** olsrd_plugin.c 25 Feb 2005 22:43:21 -0000 1.11 --- olsrd_plugin.c 29 May 2005 12:47:40 -0000 1.12 *************** *** 42,64 **** #include "olsrd_plugin.h" - #include "plugin_loader.h" #include /** * "Private" declarations */ ! 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); - /* --- 42,61 ---- #include "olsrd_plugin.h" #include + #define PLUGIN_NAME "OLSRD dynamic gateway plugin" + #define PLUGIN_VERSION "0.4" + #define PLUGIN_AUTHOR "Various artists" + #define MOD_DESC PLUGIN_NAME " " PLUGIN_VERSION " by " PLUGIN_AUTHOR + #define PLUGIN_INTERFACE_VERSION 4 + + /** * "Private" declarations */ ! static void __attribute__ ((constructor)) my_init(void); /* *************** *** 68,72 **** */ int ! get_plugin_interface_version() { return PLUGIN_INTERFACE_VERSION; --- 65,69 ---- */ int ! olsrd_plugin_interface_version() { return PLUGIN_INTERFACE_VERSION; *************** *** 85,200 **** 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; - } - - - - /** - *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; - - - /* Olsr debug output function */ - if(!olsr_plugin_io(GETF__OLSR_PRINTF, - &olsr_printf, - sizeof(olsr_printf))) - { - olsr_printf = 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; - } - - - /* Add hna net IPv4 */ - if(!olsr_plugin_io(GETF__ADD_LOCAL_HNA4_ENTRY, &add_local_hna4_entry, sizeof(add_local_hna4_entry))) - { - add_local_hna4_entry = NULL; - retval = 0; - } - - /* Remove hna net IPv4 */ - if(!olsr_plugin_io(GETF__REMOVE_LOCAL_HNA4_ENTRY, &remove_local_hna4_entry, sizeof(remove_local_hna4_entry))) - { - remove_local_hna4_entry = NULL; - retval = 0; - } - - return retval; - - } --- 82,83 ---- From (spam-protected) Sun May 29 14:47:45 2005 From: (spam-protected) (Bruno Randolf) Date: Sun, 29 May 2005 12:47:45 +0000 Subject: [Olsr-cvs] olsrd-current/lib/powerinfo version-script.txt,1.1,1.2 Message-ID: Update of /cvsroot/olsrd/olsrd-current/lib/powerinfo In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25973/lib/powerinfo Modified Files: version-script.txt 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: version-script.txt =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/lib/powerinfo/version-script.txt,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** version-script.txt 8 Nov 2004 23:43:13 -0000 1.1 --- version-script.txt 29 May 2005 12:47:43 -0000 1.2 *************** *** 2,9 **** { global: ! get_plugin_interface_version; ! register_olsr_data; ! plugin_io; ! register_olsr_param; local: --- 2,8 ---- { global: ! olsrd_plugin_interface_version; ! olsrd_plugin_register_param; ! olsrd_plugin_init; local: From (spam-protected) Sun May 29 14:47:45 2005 From: (spam-protected) (Bruno Randolf) Date: Sun, 29 May 2005 12:47:45 +0000 Subject: [Olsr-cvs] olsrd-current/lib/secure version-script.txt,1.1,1.2 Message-ID: Update of /cvsroot/olsrd/olsrd-current/lib/secure In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25973/lib/secure Modified Files: version-script.txt 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: version-script.txt =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/lib/secure/version-script.txt,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** version-script.txt 8 Nov 2004 23:43:14 -0000 1.1 --- version-script.txt 29 May 2005 12:47:43 -0000 1.2 *************** *** 2,9 **** { global: ! get_plugin_interface_version; ! register_olsr_data; ! plugin_io; ! register_olsr_param; local: --- 2,8 ---- { global: ! olsrd_plugin_interface_version; ! olsrd_plugin_register_param; ! olsrd_plugin_init; local: From (spam-protected) Sun May 29 14:47:43 2005 From: (spam-protected) (Bruno Randolf) Date: Sun, 29 May 2005 12:47:43 +0000 Subject: [Olsr-cvs] olsrd-current/lib/httpinfo/src admin_interface.c, 1.5, 1.6 olsrd_httpinfo.c, 1.52, 1.53 olsrd_httpinfo.h, 1.27, 1.28 olsrd_plugin.c, 1.11, 1.12 olsrd_plugin.h, 1.19, 1.20 Message-ID: Update of /cvsroot/olsrd/olsrd-current/lib/httpinfo/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25973/lib/httpinfo/src Modified Files: admin_interface.c olsrd_httpinfo.c olsrd_httpinfo.h olsrd_plugin.c 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_httpinfo.c =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/lib/httpinfo/src/olsrd_httpinfo.c,v retrieving revision 1.52 retrieving revision 1.53 diff -C2 -d -r1.52 -r1.53 *** olsrd_httpinfo.c 20 Apr 2005 17:52:11 -0000 1.52 --- olsrd_httpinfo.c 29 May 2005 12:47:41 -0000 1.53 *************** *** 44,54 **** */ - #include "olsrd_httpinfo.h" - #include "olsr_cfg.h" - #include "link_set.h" - #include "gfx.h" - #include "html.h" - #include "admin_interface.h" - #include "interfaces.h" #include #include --- 44,47 ---- *************** *** 56,60 **** --- 49,65 ---- #include #include + + #include "olsr.h" + #include "olsr_cfg.h" + #include "interfaces.h" #include "olsr_protocol.h" + #include "net_olsr.h" + #include "link_set.h" + #include "socket_parser.h" + + #include "olsrd_httpinfo.h" + #include "admin_interface.h" + #include "html.h" + #include "gfx.h" #ifdef OS *************** *** 122,125 **** --- 127,131 ---- }; + static int get_http_socket(int); *************** *** 229,233 **** */ int ! olsr_plugin_init() { get_copyright_string(); --- 235,239 ---- */ int ! olsrd_plugin_init() { get_copyright_string(); *************** *** 653,672 **** - /* Mulitpurpose funtion */ - int - plugin_io(int cmd, void *data, size_t size) - { - - switch(cmd) - { - default: - return 0; - } - - return 1; - - } - - static int build_frame(char *title, --- 659,662 ---- *************** *** 707,712 **** for(index = 0;index < HASHSIZE;index++) { ! for(routes = host_routes[index].next; ! routes != &host_routes[index]; routes = routes->next) { --- 697,702 ---- for(index = 0;index < HASHSIZE;index++) { ! for(routes = routingtable[index].next; ! routes != &routingtable[index]; routes = routes->next) { *************** *** 782,816 **** size += sprintf(&buf[size], "\n"); ! size += sprintf(&buf[size], "\n", olsr_ip_to_string(main_addr)); ! size += sprintf(&buf[size], "\n", cfg->ip_version == AF_INET ? 4 : 6); ! size += sprintf(&buf[size], "\n", cfg->debug_level); size += sprintf(&buf[size], "\n\n"); ! size += sprintf(&buf[size], "\n", cfg->pollrate); ! size += sprintf(&buf[size], "\n", cfg->tc_redundancy); ! size += sprintf(&buf[size], "\n", cfg->mpr_coverage); size += sprintf(&buf[size], "\n\n"); ! size += sprintf(&buf[size], "\n", cfg->tos); ! size += sprintf(&buf[size], "\n", cfg->willingness, cfg->willingness_auto ? "(auto)" : ""); size += sprintf(&buf[size], "\n\n"); ! size += sprintf(&buf[size], "\n", cfg->use_hysteresis ? "Enabled" : "Disabled"); ! size += sprintf(&buf[size], "\n", cfg->hysteresis_param.scaling); ! size += sprintf(&buf[size], "\n", cfg->hysteresis_param.thr_low, cfg->hysteresis_param.thr_high); size += sprintf(&buf[size], "\n\n"); ! size += sprintf(&buf[size], "\n", cfg->lq_level ? "Enabled" : "Disabled"); ! size += sprintf(&buf[size], "\n", cfg->lq_level); ! size += sprintf(&buf[size], "\n", cfg->lq_wsize); size += sprintf(&buf[size], "\n"); --- 772,806 ---- size += sprintf(&buf[size], "
Main address: %sIP version: %dDebug level: %d
Pollrate: %0.2fTC redundancy: %dMPR coverage: %d
TOS: 0x%04xWillingness: %d %s
Hysteresis: %sHyst scaling: %0.2fHyst lower/upper: %0.2f/%0.2f
LQ extention: %sLQ level: %dLQ winsize: %d
\n"); ! size += sprintf(&buf[size], "\n", olsr_ip_to_string(&main_addr)); ! size += sprintf(&buf[size], "\n", olsr_cnf->ip_version == AF_INET ? 4 : 6); ! size += sprintf(&buf[size], "\n", olsr_cnf->debug_level); size += sprintf(&buf[size], "\n\n"); ! size += sprintf(&buf[size], "\n", olsr_cnf->pollrate); ! size += sprintf(&buf[size], "\n", olsr_cnf->tc_redundancy); ! size += sprintf(&buf[size], "\n", olsr_cnf->mpr_coverage); size += sprintf(&buf[size], "\n\n"); ! size += sprintf(&buf[size], "\n", olsr_cnf->tos); ! size += sprintf(&buf[size], "\n", olsr_cnf->willingness, olsr_cnf->willingness_auto ? "(auto)" : ""); size += sprintf(&buf[size], "\n\n"); ! size += sprintf(&buf[size], "\n", olsr_cnf->use_hysteresis ? "Enabled" : "Disabled"); ! size += sprintf(&buf[size], "\n", olsr_cnf->hysteresis_param.scaling); ! size += sprintf(&buf[size], "\n", olsr_cnf->hysteresis_param.thr_low, olsr_cnf->hysteresis_param.thr_high); size += sprintf(&buf[size], "\n\n"); ! size += sprintf(&buf[size], "\n", olsr_cnf->lq_level ? "Enabled" : "Disabled"); ! size += sprintf(&buf[size], "\n", olsr_cnf->lq_level); ! size += sprintf(&buf[size], "\n", olsr_cnf->lq_wsize); size += sprintf(&buf[size], "\n"); *************** *** 823,827 **** ! for(ifs = cfg->interfaces; ifs; ifs = ifs->next) { struct interface *rifs = ifs->interf; --- 813,817 ---- ! for(ifs = olsr_cnf->interfaces; ifs; ifs = ifs->next) { struct interface *rifs = ifs->interf; *************** *** 834,838 **** } ! if(cfg->ip_version == AF_INET) { size += sprintf(&buf[size], "\n", --- 824,828 ---- } ! if(olsr_cnf->ip_version == AF_INET) { size += sprintf(&buf[size], "\n", *************** *** 860,864 **** size += sprintf(&buf[size], "
Main address: %sIP version: %dDebug level: %d
Pollrate: %0.2fTC redundancy: %dMPR coverage: %d
TOS: 0x%04xWillingness: %d %s
Hysteresis: %sHyst scaling: %0.2fHyst lower/upper: %0.2f/%0.2f
LQ extention: %sLQ level: %dLQ winsize: %d
IP: %s
IP: %s
\n"); ! if(cfg->allow_no_interfaces) size += sprintf(&buf[size], "Olsrd is configured to run even if no interfaces are available
\n"); else --- 850,854 ---- size += sprintf(&buf[size], "\n"); ! if(olsr_cnf->allow_no_interfaces) size += sprintf(&buf[size], "Olsrd is configured to run even if no interfaces are available
\n"); else *************** *** 869,873 **** size += sprintf(&buf[size], "\n"); ! for(pentry = cfg->plugins; pentry; pentry = pentry->next) { size += sprintf(&buf[size], "\n", pentry->name); --- 859,863 ---- size += sprintf(&buf[size], "
NameParameters
%s
\n"); ! for(pentry = olsr_cnf->plugins; pentry; pentry = pentry->next) { size += sprintf(&buf[size], "\n", pentry->name); *************** *** 889,893 **** ! if((cfg->ip_version == AF_INET) && (cfg->hna4_entries)) { struct hna4_entry *hna4; --- 879,883 ---- ! if((olsr_cnf->ip_version == AF_INET) && (olsr_cnf->hna4_entries)) { struct hna4_entry *hna4; *************** *** 896,900 **** size += sprintf(&buf[size], "
NameParameters
%s
\n"); ! for(hna4 = cfg->hna4_entries; hna4; hna4 = hna4->next) { size += sprintf(&buf[size], "\n", --- 886,890 ---- size += sprintf(&buf[size], "
NetworkNetmask
%s%s
\n"); ! for(hna4 = olsr_cnf->hna4_entries; hna4; hna4 = hna4->next) { size += sprintf(&buf[size], "\n", *************** *** 905,909 **** size += sprintf(&buf[size], "
NetworkNetmask
%s%s
\n"); } ! else if((cfg->ip_version == AF_INET6) && (cfg->hna6_entries)) { struct hna6_entry *hna6; --- 895,899 ---- size += sprintf(&buf[size], "\n"); } ! else if((olsr_cnf->ip_version == AF_INET6) && (olsr_cnf->hna6_entries)) { struct hna6_entry *hna6; *************** *** 912,916 **** size += sprintf(&buf[size], "\n"); ! for(hna6 = cfg->hna6_entries; hna6; hna6 = hna6->next) { size += sprintf(&buf[size], "\n", --- 902,906 ---- size += sprintf(&buf[size], "
NetworkPrefix length
%s%d
\n"); ! for(hna6 = olsr_cnf->hna6_entries; hna6; hna6 = hna6->next) { size += sprintf(&buf[size], "\n", *************** *** 940,945 **** /* Link set */ ! if(olsr_plugin_io(GETD__LINK_SET, &link, sizeof(link)) && link) ! { while(link) { --- 930,934 ---- /* Link set */ ! link = link_set; while(link) { *************** *** 956,960 **** link = link->next; } - } size += sprintf(&buf[size], "
NetworkPrefix length
%s%d
\n"); --- 945,948 ---- *************** *** 1182,1186 **** } ! size += olsrd_write_cnf_buf(cfg, &buf[size], bufsize-size); if(size < 0) --- 1170,1174 ---- } ! size += olsrd_write_cnf_buf(olsr_cnf, &buf[size], bufsize-size); if(size < 0) *************** *** 1230,1273 **** /** - *Converts a olsr_ip_addr to a string - *Goes for both IPv4 and IPv6 - * - *@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) - { - static int index = 0; - static char buff[4][100]; - 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)); - } - - strncpy(buff[index], ret, 100); - - ret = buff[index]; - - index = (index + 1) & 3; - - return ret; - } - - - - - /** *This function is just as bad as the previous one :-( */ --- 1218,1221 ---- *************** *** 1279,1283 **** static char netmask[5]; ! if(ipversion == AF_INET) { in.s_addr = mask->v4; --- 1227,1231 ---- static char netmask[5]; ! if(olsr_cnf->ip_version == AF_INET) { in.s_addr = mask->v4; *************** *** 1299,1313 **** - char * - sockaddr_to_string(struct sockaddr *address_to_convert) - { - struct sockaddr_in *address; - - address=(struct sockaddr_in *)address_to_convert; - return(inet_ntoa(address->sin_addr)); - - } - - static char * get_copyright_string() --- 1247,1250 ---- Index: olsrd_httpinfo.h =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/lib/httpinfo/src/olsrd_httpinfo.h,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** olsrd_httpinfo.h 24 Jan 2005 07:55:35 -0000 1.27 --- olsrd_httpinfo.h 29 May 2005 12:47:41 -0000 1.28 *************** *** 78,81 **** --- 78,85 ---- }; + + extern struct olsrd_config *olsr_cfg; + + char * olsr_ip_to_string(union olsr_ip_addr *); *************** *** 84,87 **** --- 88,94 ---- olsr_netmask_to_string(union hna_netmask *); + /* Destructor function */ + void + olsr_plugin_exit(void); #endif Index: olsrd_plugin.h =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/lib/httpinfo/src/olsrd_plugin.h,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** olsrd_plugin.h 25 May 2005 16:33:24 -0000 1.19 --- olsrd_plugin.h 29 May 2005 12:47:41 -0000 1.20 *************** *** 57,61 **** #include - #include "olsr_plugin_io.h" #include "olsr_types.h" #include "neighbor_table.h" --- 57,60 ---- *************** *** 71,75 **** #define PLUGIN_AUTHOR "Andreas T�nnesen" #define MOD_DESC PLUGIN_NAME " " PLUGIN_VERSION " by " PLUGIN_AUTHOR ! #define PLUGIN_INTERFACE_VERSION 3 int http_port; --- 70,74 ---- #define PLUGIN_AUTHOR "Andreas T�nnesen" #define MOD_DESC PLUGIN_NAME " " PLUGIN_VERSION " by " PLUGIN_AUTHOR ! #define PLUGIN_INTERFACE_VERSION 4 int http_port; *************** *** 93,154 **** struct allowed_net *allowed_nets; - /* The lists */ - struct neighbor_entry *neighbortable; - struct neighbor_2_entry *two_hop_neighbortable; - struct link_entry *link_set; - struct tc_entry *tc_table; - struct hna_entry *hna_set; - struct mid_entry *mid_set; - struct rt_entry *host_routes; - struct rt_entry *hna_routes; - - - /* Buffer for olsr_ip_to_string */ - - char ipv6_buf[100]; /* buffer for IPv6 inet_htop */ - - /* Global config pointer */ - struct olsrd_config *cfg; - - /**************************************************************************** - * Function pointers to functions in olsrd * - * These allow direct access to olsrd functions * - ****************************************************************************/ - - /* The multi-purpose funtion. All other functions are fetched trough this */ - int (*olsr_plugin_io)(int, void *, size_t); - - /* Add a socket to the main olsrd select loop */ - void (*add_olsr_socket)(int, void(*)(int)); - - /* Lookup MPR entry */ - struct mpr_selector *(*olsr_lookup_mprs_set)(union olsr_ip_addr *); - - - /* olsrd printf wrapper */ - int (*olsr_printf)(int, char *, ...); - - /* olsrd malloc wrapper */ - void *(*olsr_malloc)(size_t, const char *); - - /* Add hna net IPv4 */ - void (*add_local_hna4_entry)(union olsr_ip_addr *, union hna_netmask *); - - /* Remove hna net IPv4 */ - int (*remove_local_hna4_entry)(union olsr_ip_addr *, union hna_netmask *); - - /**************************************************************************** - * Data from olsrd * - * NOTE THAT POINTERS POINT TO THE DATA USED BY OLSRD! * - * NEVER ALTER DATA POINTED TO BY THESE POINTERS * - * UNLESS YOU KNOW WHAT YOU ARE DOING!!! * - ****************************************************************************/ - - /* These two are set automatically by olsrd at load time */ - int ipversion; /* IPversion in use */ - union olsr_ip_addr *main_addr; /* Main address */ - - - size_t ipsize; /* Size of the ipadresses used */ /**************************************************************************** --- 92,95 ---- *************** *** 159,181 **** /* Initialization function */ int ! olsr_plugin_init(void); ! ! /* IPC initialization function */ ! int ! plugin_ipc_init(void); ! ! int ! register_olsr_param(char *, char *); ! ! /* Destructor function */ ! void ! olsr_plugin_exit(void); - /* Mulitpurpose funtion */ int ! plugin_io(int, void *, size_t); int ! get_plugin_interface_version(void); #endif --- 100,110 ---- /* Initialization function */ int ! olsrd_plugin_init(void); int ! olsrd_plugin_register_param(char *, char *); int ! olsrd_plugin_interface_version(void); #endif Index: admin_interface.c =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/lib/httpinfo/src/admin_interface.c,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** admin_interface.c 14 Mar 2005 19:38:39 -0000 1.5 --- admin_interface.c 29 May 2005 12:47:41 -0000 1.6 *************** *** 72,78 **** size += sprintf(&buf[size], admin_basic_setting_int, ! "Debug level:", "debug_level", 2, cfg->debug_level); size += sprintf(&buf[size], admin_basic_setting_float, ! "Pollrate:", "pollrate", 4, cfg->pollrate); size += sprintf(&buf[size], admin_basic_setting_string, "TOS:", "tos", 6, "TBD"); --- 72,78 ---- size += sprintf(&buf[size], admin_basic_setting_int, ! "Debug level:", "debug_level", 2, olsr_cnf->debug_level); size += sprintf(&buf[size], admin_basic_setting_float, ! "Pollrate:", "pollrate", 4, olsr_cnf->pollrate); size += sprintf(&buf[size], admin_basic_setting_string, "TOS:", "tos", 6, "TBD"); *************** *** 82,103 **** size += sprintf(&buf[size], admin_basic_setting_int, ! "TC redundancy:", "tc_redundancy", 1, cfg->tc_redundancy); size += sprintf(&buf[size], admin_basic_setting_int, ! "MPR coverage:", "mpr_coverage", 1, cfg->mpr_coverage); size += sprintf(&buf[size], admin_basic_setting_int, ! "Willingness:", "willingness", 1, cfg->willingness); size += sprintf(&buf[size], "\n"); size += sprintf(&buf[size], "\n"); ! if(cfg->use_hysteresis) { size += sprintf(&buf[size], admin_basic_setting_float, ! "Hyst scaling:", "hyst_scaling", 4, cfg->hysteresis_param.scaling); size += sprintf(&buf[size], admin_basic_setting_float, ! "Lower thr:", "hyst_lower", 4, cfg->hysteresis_param.thr_low); size += sprintf(&buf[size], admin_basic_setting_float, ! "Upper thr:", "hyst_upper", 4, cfg->hysteresis_param.thr_high); } else --- 82,103 ---- size += sprintf(&buf[size], admin_basic_setting_int, ! "TC redundancy:", "tc_redundancy", 1, olsr_cnf->tc_redundancy); size += sprintf(&buf[size], admin_basic_setting_int, ! "MPR coverage:", "mpr_coverage", 1, olsr_cnf->mpr_coverage); size += sprintf(&buf[size], admin_basic_setting_int, ! "Willingness:", "willingness", 1, olsr_cnf->willingness); size += sprintf(&buf[size], "\n"); size += sprintf(&buf[size], "\n"); ! if(olsr_cnf->use_hysteresis) { size += sprintf(&buf[size], admin_basic_setting_float, ! "Hyst scaling:", "hyst_scaling", 4, olsr_cnf->hysteresis_param.scaling); size += sprintf(&buf[size], admin_basic_setting_float, ! "Lower thr:", "hyst_lower", 4, olsr_cnf->hysteresis_param.thr_low); size += sprintf(&buf[size], admin_basic_setting_float, ! "Upper thr:", "hyst_upper", 4, olsr_cnf->hysteresis_param.thr_high); } else *************** *** 109,118 **** size += sprintf(&buf[size], "\n"); ! if(cfg->lq_level) { size += sprintf(&buf[size], admin_basic_setting_int, ! "LQ level:", "lq_level", 1, cfg->lq_level); size += sprintf(&buf[size], admin_basic_setting_int, ! "LQ winsize:", "lq_wsize", 2, cfg->lq_wsize); } else --- 109,118 ---- size += sprintf(&buf[size], "\n"); ! if(olsr_cnf->lq_level) { size += sprintf(&buf[size], admin_basic_setting_int, ! "LQ level:", "lq_level", 1, olsr_cnf->lq_level); size += sprintf(&buf[size], admin_basic_setting_int, ! "LQ winsize:", "lq_wsize", 2, olsr_cnf->lq_wsize); } else *************** *** 140,148 **** i++; ! if((cfg->ip_version == AF_INET) && (cfg->hna4_entries)) { struct hna4_entry *hna4; ! for(hna4 = cfg->hna4_entries; hna4; hna4 = hna4->next) { size += sprintf(&buf[size], admin_frame[i], --- 140,148 ---- i++; ! if((olsr_cnf->ip_version == AF_INET) && (olsr_cnf->hna4_entries)) { struct hna4_entry *hna4; ! for(hna4 = olsr_cnf->hna4_entries; hna4; hna4 = hna4->next) { size += sprintf(&buf[size], admin_frame[i], *************** *** 153,161 **** } } ! else if((cfg->ip_version == AF_INET6) && (cfg->hna6_entries)) { struct hna6_entry *hna6; ! for(hna6 = cfg->hna6_entries; hna6; hna6 = hna6->next) { size += sprintf(&buf[size], admin_frame[i], --- 153,161 ---- } } ! else if((olsr_cnf->ip_version == AF_INET6) && (olsr_cnf->hna6_entries)) { struct hna6_entry *hna6; ! for(hna6 = olsr_cnf->hna6_entries; hna6; hna6 = hna6->next) { size += sprintf(&buf[size], admin_frame[i], *************** *** 191,195 **** return -1; ! cfg->debug_level = ival; return 1; } --- 191,195 ---- return -1; ! olsr_cnf->debug_level = ival; return 1; } *************** *** 201,205 **** return -1; ! cfg->tc_redundancy = ival; return 1; } --- 201,205 ---- return -1; ! olsr_cnf->tc_redundancy = ival; return 1; } *************** *** 211,215 **** return -1; ! cfg->mpr_coverage = ival; return 1; } --- 211,215 ---- return -1; ! olsr_cnf->mpr_coverage = ival; return 1; } *************** *** 221,225 **** return -1; ! cfg->willingness = ival; return 1; } --- 221,225 ---- return -1; ! olsr_cnf->willingness = ival; return 1; } *************** *** 231,235 **** return -1; ! cfg->lq_level = ival; return 1; } --- 231,235 ---- return -1; ! olsr_cnf->lq_level = ival; return 1; } *************** *** 241,245 **** return -1; ! cfg->lq_wsize = ival; return 1; } --- 241,245 ---- return -1; ! olsr_cnf->lq_wsize = ival; return 1; } *************** *** 253,257 **** printf("HYST SCALING: %f\n", fval); ! cfg->hysteresis_param.scaling = fval; return 1; } --- 253,257 ---- printf("HYST SCALING: %f\n", fval); ! olsr_cnf->hysteresis_param.scaling = fval; return 1; } *************** *** 264,268 **** return -1; ! cfg->hysteresis_param.scaling = fval; return 1; } --- 264,268 ---- return -1; ! olsr_cnf->hysteresis_param.scaling = fval; return 1; } *************** *** 275,279 **** return -1; ! cfg->hysteresis_param.thr_low = fval; return 1; } --- 275,279 ---- return -1; ! olsr_cnf->hysteresis_param.thr_low = fval; return 1; } *************** *** 286,290 **** return -1; ! cfg->hysteresis_param.thr_high = fval; return 1; } --- 286,290 ---- return -1; ! olsr_cnf->hysteresis_param.thr_high = fval; return 1; } *************** *** 297,301 **** return -1; ! cfg->pollrate = fval; return 1; } --- 297,301 ---- return -1; ! olsr_cnf->pollrate = fval; return 1; } Index: olsrd_plugin.c =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/lib/httpinfo/src/olsrd_plugin.c,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** olsrd_plugin.c 25 May 2005 16:33:24 -0000 1.11 --- olsrd_plugin.c 29 May 2005 12:47:41 -0000 1.12 *************** *** 44,48 **** */ ! #include "olsrd_plugin.h" #include "olsr_cfg.h" --- 44,48 ---- */ ! #include "olsr.h" #include "olsrd_plugin.h" #include "olsr_cfg.h" *************** *** 50,67 **** #include #include ! #include "plugin_loader.h" ! 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); - /* --- 50,61 ---- #include #include ! #include "olsrd_httpinfo.h" ! static void __attribute__ ((constructor)) my_init(void); ! static void __attribute__ ((destructor)) my_fini(void); /* *************** *** 71,75 **** */ int ! get_plugin_interface_version() { return PLUGIN_INTERFACE_VERSION; --- 65,69 ---- */ int ! olsrd_plugin_interface_version() { return PLUGIN_INTERFACE_VERSION; *************** *** 81,85 **** *Constructor */ ! void my_init() { --- 75,79 ---- *Constructor */ ! static void my_init() { *************** *** 93,97 **** *Destructor */ ! void my_fini() { --- 87,91 ---- *Destructor */ ! static void my_fini() { *************** *** 108,113 **** } int ! register_olsr_param(char *key, char *value) { if(!strcmp(key, "port") || !strcmp(key, "Port")) --- 102,108 ---- } + int ! olsrd_plugin_register_param(char *key, char *value) { if(!strcmp(key, "port") || !strcmp(key, "Port")) *************** *** 173,356 **** 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; - - - /* Neighbor table */ - if(!olsr_plugin_io(GETD__NEIGHBORTABLE, - &neighbortable, - sizeof(neighbortable))) - { - neighbortable = NULL; - retval = 0; - } - - /* Two hop neighbor table */ - if(!olsr_plugin_io(GETD__TWO_HOP_NEIGHBORTABLE, - &two_hop_neighbortable, - sizeof(two_hop_neighbortable))) - { - two_hop_neighbortable = NULL; - retval = 0; - } - - /* Topoloy table */ - if(!olsr_plugin_io(GETD__TC_TABLE, - &tc_table, - sizeof(tc_table))) - { - tc_table = NULL; - retval = 0; - } - - /* HNA table */ - if(!olsr_plugin_io(GETD__HNA_SET, - &hna_set, - sizeof(hna_set))) - { - hna_set = NULL; - retval = 0; - } - - /* MID table */ - if(!olsr_plugin_io(GETD__MID_SET, - &mid_set, - sizeof(mid_set))) - { - mid_set = NULL; - retval = 0; - } - - - if(!olsr_plugin_io(GETD__ROUTINGTABLE, - &host_routes, - sizeof(host_routes))) - { - host_routes = NULL; - retval = 0; - } - - if(!olsr_plugin_io(GETD__HNA_ROUTES, - &hna_routes, - sizeof(hna_routes))) - { - hna_routes = NULL; - retval = 0; - } - - - /* Configuration */ - if(!olsr_plugin_io(GETD__OLSR_CNF, - &cfg, - sizeof(cfg))) - { - cfg = NULL; - retval = 0; - } - - if(!olsr_plugin_io(GETF__OLSR_LOOKUP_MPRS_SET, - &olsr_lookup_mprs_set, - sizeof(olsr_lookup_mprs_set))) - { - olsr_lookup_mprs_set = 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; - } - - /* 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; - } - - /* Add hna net IPv4 */ - if(!olsr_plugin_io(GETF__ADD_LOCAL_HNA4_ENTRY, &add_local_hna4_entry, sizeof(add_local_hna4_entry))) - { - add_local_hna4_entry = NULL; - retval = 0; - } - - /* Remove hna net IPv4 */ - if(!olsr_plugin_io(GETF__REMOVE_LOCAL_HNA4_ENTRY, &remove_local_hna4_entry, sizeof(remove_local_hna4_entry))) - { - remove_local_hna4_entry = NULL; - retval = 0; - } - - return retval; - - } --- 168,169 ---- From (spam-protected) Sun May 29 14:47:45 2005 From: (spam-protected) (Bruno Randolf) Date: Sun, 29 May 2005 12:47:45 +0000 Subject: [Olsr-cvs] olsrd-current/lib/powerinfo/src olsrd_plugin.c, 1.6, 1.7 olsrd_power.c, 1.12, 1.13 olsrd_power.h, 1.3, 1.4 olsr_plugin_io.h, 1.5, NONE olsrd_plugin.h, 1.11, NONE Message-ID: Update of /cvsroot/olsrd/olsrd-current/lib/powerinfo/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25973/lib/powerinfo/src Modified Files: olsrd_plugin.c olsrd_power.c olsrd_power.h Removed Files: olsr_plugin_io.h 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_power.c =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/lib/powerinfo/src/olsrd_power.c,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** olsrd_power.c 25 May 2005 16:33:24 -0000 1.12 --- olsrd_power.c 29 May 2005 12:47:43 -0000 1.13 *************** *** 37,40 **** --- 37,52 ---- #include "olsrd_power.h" + #include "olsrd_plugin.h" + + #include "olsr.h" + #include "mantissa.h" + #include "parser.h" + #include "scheduler.h" + #include "link_set.h" + #include "socket_parser.h" + #include "interfaces.h" + #include "duplicate_set.h" + #include "apm.h" + #include #include *************** *** 61,64 **** --- 73,85 ---- #endif + /* The database - (using hashing) */ + static struct pwrentry list[HASHSIZE]; + + + static int has_apm; + + /* set buffer to size of IPv6 message */ + static char buffer[sizeof(struct olsrmsg6)]; + int ipc_socket; int ipc_open; *************** *** 77,86 **** */ int ! olsr_plugin_init() { int i; struct olsr_apm_info apm_info; ! if(ipversion != AF_INET) { fprintf(stderr, "This plugin only supports IPv4!\n"); --- 98,107 ---- */ int ! olsrd_plugin_init() { int i; struct olsr_apm_info apm_info; ! if(olsr_cnf->ip_version != AF_INET) { fprintf(stderr, "This plugin only supports IPv4!\n"); *************** *** 220,240 **** - - /* Mulitpurpose funtion */ - int - plugin_io(int cmd, void *data, size_t size) - { - - switch(cmd) - { - default: - return 0; - } - - return 1; - } - - - /** *A timeoutfunction called every time --- 241,244 ---- *************** *** 285,289 **** olsr_event(void *foo) { ! union olsr_message *message = (union olsr_message*)buffer; struct interface *ifn; --- 289,293 ---- olsr_event(void *foo) { ! union p_olsr_message *message = (union p_olsr_message*)buffer; struct interface *ifn; *************** *** 295,303 **** /* looping trough interfaces */ ! for (ifn = ifs; ifn ; ifn = ifn->int_next) { olsr_printf(3, "[%s] ", ifn->int_name); /* Fill message */ ! if(ipversion == AF_INET) { /* IPv4 */ --- 299,307 ---- /* looping trough interfaces */ ! for (ifn = ifnet; ifn ; ifn = ifn->int_next) { olsr_printf(3, "[%s] ", ifn->int_name); /* Fill message */ ! if(olsr_cnf->ip_version == AF_INET) { /* IPv4 */ *************** *** 305,309 **** message->v4.olsr_vtime = double_to_me(7.5); message->v4.olsr_msgsize = htons(sizeof(struct olsrmsg)); ! memcpy(&message->v4.originator, main_addr, ipsize); message->v4.ttl = MAX_TTL; message->v4.hopcnt = 0; --- 309,313 ---- message->v4.olsr_vtime = double_to_me(7.5); message->v4.olsr_msgsize = htons(sizeof(struct olsrmsg)); ! memcpy(&message->v4.originator, &main_addr, ipsize); message->v4.ttl = MAX_TTL; message->v4.hopcnt = 0; *************** *** 328,332 **** message->v6.olsr_vtime = double_to_me(7.5); message->v6.olsr_msgsize = htons(sizeof(struct olsrmsg)); ! memcpy(&message->v6.originator, main_addr, ipsize); message->v6.ttl = MAX_TTL; message->v6.hopcnt = 0; --- 332,336 ---- message->v6.olsr_vtime = double_to_me(7.5); message->v6.olsr_msgsize = htons(sizeof(struct olsrmsg)); ! memcpy(&message->v6.originator, &main_addr, ipsize); message->v6.ttl = MAX_TTL; message->v6.hopcnt = 0; *************** *** 362,368 **** --- 366,375 ---- olsr_parser(union olsr_message *m, struct interface *in_if, union olsr_ip_addr *in_addr) { + union p_olsr_message* pm; struct powermsg *message; union olsr_ip_addr originator; double vtime; + + pm = (union p_olsr_message*)m; /* Fetch the originator of the messsage */ *************** *** 370,386 **** /* Fetch the message based on IP version */ ! if(ipversion == AF_INET) { ! message = &m->v4.msg; vtime = ME_TO_DOUBLE(m->v4.olsr_vtime); } else { ! message = &m->v6.msg; vtime = ME_TO_DOUBLE(m->v6.olsr_vtime); } /* Check if message originated from this node */ ! if(memcmp(&originator, main_addr, ipsize) == 0) /* If so - back off */ return; --- 377,393 ---- /* Fetch the message based on IP version */ ! if(olsr_cnf->ip_version == AF_INET) { ! message = &pm->v4.msg; vtime = ME_TO_DOUBLE(m->v4.olsr_vtime); } else { ! message = &pm->v6.msg; vtime = ME_TO_DOUBLE(m->v6.olsr_vtime); } /* Check if message originated from this node */ ! if(memcmp(&originator, &main_addr, ipsize) == 0) /* If so - back off */ return; *************** *** 399,403 **** * processed if nessecary */ ! if(!check_dup_proc(&originator, ntohs(m->v4.seqno))) /* REMEMBER NTOHS!! */ { --- 406,410 ---- * processed if nessecary */ ! if(!olsr_check_dup_table_proc(&originator, ntohs(m->v4.seqno))) /* REMEMBER NTOHS!! */ { *************** *** 420,424 **** * default_fwd does all the work for us! */ ! default_fwd(m, &originator, ntohs(m->v4.seqno), /* IMPORTANT!!! */ --- 427,431 ---- * default_fwd does all the work for us! */ ! olsr_forward_message(m, &originator, ntohs(m->v4.seqno), /* IMPORTANT!!! */ *************** *** 605,609 **** char *tmp; ! if(ipversion == AF_INET) /* IPv4 */ hash = (ntohl(address->v4)); --- 612,616 ---- char *tmp; ! if(olsr_cnf->ip_version == AF_INET) /* IPv4 */ hash = (ntohl(address->v4)); *************** *** 634,638 **** olsr_timed_out(struct timeval *timer) { ! return(timercmp(timer, now, <)); } --- 641,645 ---- olsr_timed_out(struct timeval *timer) { ! return(timercmp(timer, &now, <)); } *************** *** 680,723 **** 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; - } - --- 687,694 ---- 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); } Index: olsrd_power.h =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/lib/powerinfo/src/olsrd_power.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** olsrd_power.h 30 Nov 2004 17:04:45 -0000 1.3 --- olsrd_power.h 29 May 2005 12:47:43 -0000 1.4 *************** *** 37,40 **** --- 37,43 ---- #define _OLSRD_PLUGIN_TEST + #include "hashing.h" + #include "defs.h" + #include "olsrd_plugin.h" *************** *** 56,67 **** ! /* The database - (using hashing) */ ! struct pwrentry list[HASHSIZE]; ! int has_apm; ! /* set buffer to size of IPv6 message */ ! static char buffer[sizeof(struct olsrmsg6)]; --- 59,143 ---- ! /***************************************************************************** ! * Plugin data * ! * ALTER THIS TO YOUR OWN NEED * ! *****************************************************************************/ ! ! #define PLUGIN_NAME "OLSRD Powerstatus plugin" ! #define PLUGIN_VERSION "0.3" ! #define PLUGIN_AUTHOR "Andreas T�nnesen" ! #define MOD_DESC PLUGIN_NAME " " PLUGIN_VERSION " by " PLUGIN_AUTHOR + /* The type of message you will use */ + #define MESSAGE_TYPE 128 ! /* The type of messages we will receive - can be set to promiscuous */ ! #define PARSER_TYPE MESSAGE_TYPE ! ! /**************************************************************************** ! * PACKET SECTION * ! ****************************************************************************/ ! ! ! /********************************** ! * DEFINE YOUR CUSTOM PACKET HERE * ! **********************************/ ! ! struct powermsg ! { ! olsr_u8_t source_type; ! olsr_u8_t percentage; ! olsr_u16_t time_left; ! }; ! ! /* ! * OLSR message (several can exist in one OLSR packet) ! */ ! ! struct p_olsrmsg ! { ! olsr_u8_t olsr_msgtype; ! olsr_u8_t olsr_vtime; ! olsr_u16_t olsr_msgsize; ! olsr_u32_t originator; ! olsr_u8_t ttl; ! olsr_u8_t hopcnt; ! olsr_u16_t seqno; ! ! /* YOUR PACKET GOES HERE */ ! struct powermsg msg; ! ! }; ! ! /* ! *IPv6 ! */ ! ! struct p_olsrmsg6 ! { ! olsr_u8_t olsr_msgtype; ! olsr_u8_t olsr_vtime; ! olsr_u16_t olsr_msgsize; ! struct in6_addr originator; ! olsr_u8_t ttl; ! olsr_u8_t hopcnt; ! olsr_u16_t seqno; ! ! /* YOUR PACKET GOES HERE */ ! struct powermsg msg; ! ! }; ! ! /* ! * ALWAYS USE THESE WRAPPERS TO ! * ENSURE IPv4 <-> IPv6 compability ! */ ! ! union p_olsr_message ! { ! struct p_olsrmsg v4; ! struct p_olsrmsg6 v6; ! }; *************** *** 90,92 **** --- 166,186 ---- print_power_table(void); + int + olsrd_plugin_init(void); + + int + plugin_ipc_init(void); + + void + olsr_plugin_exit(void); + + void + olsr_get_timestamp(olsr_u32_t, struct timeval *); + + void + olsr_init_timer(olsr_u32_t, struct timeval *); + + int + olsr_timed_out(struct timeval *); + #endif --- olsrd_plugin.h DELETED --- --- olsr_plugin_io.h DELETED --- Index: olsrd_plugin.c =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/lib/powerinfo/src/olsrd_plugin.c,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** olsrd_plugin.c 25 May 2005 13:41:47 -0000 1.6 --- olsrd_plugin.c 29 May 2005 12:47:43 -0000 1.7 *************** *** 39,44 **** #include "olsrd_plugin.h" #include - #include "plugin_loader.h" void __attribute__ ((constructor)) --- 39,44 ---- #include "olsrd_plugin.h" + #include "olsrd_power.h" #include void __attribute__ ((constructor)) *************** *** 48,56 **** my_fini(void); - int - register_olsr_data(struct olsr_plugin_data *); - - int - fetch_olsrd_data(void); /* --- 48,51 ---- *************** *** 59,65 **** */ int ! get_plugin_interface_version() { ! return PLUGIN_INTERFACE_VERSION; } --- 54,66 ---- */ int ! olsrd_plugin_interface_version() { ! return OLSRD_PLUGIN_INTERFACE_VERSION; ! } ! ! int ! olsrd_plugin_register_param(char *key, char *value) ! { ! return 1; } *************** *** 72,79 **** /* Print plugin info to stdout */ printf("%s\n", MOD_DESC); - - ifs = NULL; - - return; } --- 73,76 ---- *************** *** 92,295 **** */ olsr_plugin_exit(); - - return; - } - - int - register_olsr_param(char *key, char *value) - { - 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; - } - - if(!plugin_ipc_init()) - { - fprintf(stderr, "Could not initialize plugin IPC!\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; - } - - - /* Apm info */ - if(!olsr_plugin_io(GETF__APM_READ, &apm_read, sizeof(apm_read))) - { - apm_read = NULL; - retval = 0; - } - - return retval; - } --- 89,91 ---- From (spam-protected) Sun May 29 14:47:45 2005 From: (spam-protected) (Bruno Randolf) Date: Sun, 29 May 2005 12:47:45 +0000 Subject: [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 Message-ID: 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 ! #include ! #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 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 #include - #include "nameservice.h" - #include "olsrd_copy.h" #include "routing_table.h" #include "mantissa.h" /* send buffer: huge */ --- 40,56 ---- #include #include + #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 /* 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 From (spam-protected) Sun May 29 14:47:46 2005 From: (spam-protected) (Bruno Randolf) Date: Sun, 29 May 2005 12:47:46 +0000 Subject: [Olsr-cvs] olsrd-current/lib/secure/src secure_messages.h, NONE, 1.1 olsrd_plugin.c, 1.9, 1.10 olsrd_secure.c, 1.13, 1.14 olsrd_secure.h, 1.4, 1.5 olsrd_plugin.h, 1.14, NONE Message-ID: Update of /cvsroot/olsrd/olsrd-current/lib/secure/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25973/lib/secure/src Modified Files: olsrd_plugin.c olsrd_secure.c olsrd_secure.h Added Files: secure_messages.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 --- NEW FILE: secure_messages.h --- /* * Secure OLSR plugin * http://www.olsr.org * * Copyright (c) 2004, Andreas T�nnesen(andreto at olsr.org) * All rights reserved. * * Redistribution and use in source and binary forms, with or * without modification, are permitted provided that the following * conditions are met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * Neither the name of olsrd, olsr.org nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * * $Id: secure_messages.h,v 1.1 2005/05/29 12:47:44 br1 Exp $ */ /* * olsr.org olsr daemon security plugin */ #ifndef _OLSRD_SECURE_MSG #define _OLSRD_SECURE_MSG #include #include #include #include #include #include #include #include #include "olsr_types.h" #include "interfaces.h" /* The type of message you will use */ #define MESSAGE_TYPE 10 /* The type of messages we will receive - can be set to promiscuous */ #define PARSER_TYPE MESSAGE_TYPE #define TYPE_CHALLENGE 11 #define TYPE_CRESPONSE 12 #define TYPE_RRESPONSE 13 char keyfile[FILENAME_MAX]; #ifdef USE_OPENSSL #define SIGSIZE 20 #else #define SIGSIZE 16 #endif /**************************************************************************** * PACKET SECTION * ****************************************************************************/ struct sig_msg { olsr_u8_t type; olsr_u8_t algorithm; olsr_u16_t reserved; time_t timestamp; char signature[SIGSIZE]; }; /* * OLSR message (several can exist in one OLSR packet) */ struct s_olsrmsg { olsr_u8_t olsr_msgtype; olsr_u8_t olsr_vtime; olsr_u16_t olsr_msgsize; olsr_u32_t originator; olsr_u8_t ttl; olsr_u8_t hopcnt; olsr_u16_t seqno; /* YOUR PACKET GOES HERE */ struct sig_msg sig; }; /* * Challenge response messages */ struct challengemsg { olsr_u8_t olsr_msgtype; olsr_u8_t olsr_vtime; olsr_u16_t olsr_msgsize; olsr_u32_t originator; olsr_u8_t ttl; olsr_u8_t hopcnt; olsr_u16_t seqno; olsr_u32_t destination; olsr_u32_t challenge; char signature[SIGSIZE]; }; struct c_respmsg { olsr_u8_t olsr_msgtype; olsr_u8_t olsr_vtime; olsr_u16_t olsr_msgsize; olsr_u32_t originator; olsr_u8_t ttl; olsr_u8_t hopcnt; olsr_u16_t seqno; olsr_u32_t destination; olsr_u32_t challenge; time_t timestamp; char res_sig[SIGSIZE]; char signature[SIGSIZE]; }; struct r_respmsg { olsr_u8_t olsr_msgtype; olsr_u8_t olsr_vtime; olsr_u16_t olsr_msgsize; olsr_u32_t originator; olsr_u8_t ttl; olsr_u8_t hopcnt; olsr_u16_t seqno; olsr_u32_t destination; time_t timestamp; char res_sig[SIGSIZE]; char signature[SIGSIZE]; }; /* *IPv6 */ struct s_olsrmsg6 { olsr_u8_t olsr_msgtype; olsr_u8_t olsr_vtime; olsr_u16_t olsr_msgsize; struct in6_addr originator; olsr_u8_t ttl; olsr_u8_t hopcnt; olsr_u16_t seqno; /* YOUR PACKET GOES HERE */ struct sig_msg sig; }; /* * Generic OLSR packet - DO NOT ALTER */ struct s_olsr { olsr_u16_t olsr_packlen; /* packet length */ olsr_u16_t olsr_seqno; struct s_olsrmsg olsr_msg[1]; /* variable messages */ }; struct s_olsr6 { olsr_u16_t olsr_packlen; /* packet length */ olsr_u16_t olsr_seqno; struct s_olsrmsg6 olsr_msg[1]; /* variable messages */ }; #endif Index: olsrd_secure.h =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/lib/secure/src/olsrd_secure.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** olsrd_secure.h 10 Mar 2005 19:57:48 -0000 1.4 --- olsrd_secure.h 29 May 2005 12:47:44 -0000 1.5 *************** *** 42,46 **** #define _OLSRD_PLUGIN_TEST ! #include "olsrd_plugin.h" #define KEYFILE "/root/.olsr/olsrd_secure_key" --- 42,49 ---- #define _OLSRD_PLUGIN_TEST ! #include "secure_messages.h" ! ! #include "hashing.h" ! #define KEYFILE "/root/.olsr/olsrd_secure_key" *************** *** 53,58 **** #define MD5_INCLUDING_KEY 2 - #define MAXMESSAGESIZE 512 - #ifdef USE_OPENSSL #define SIGNATURE_SIZE 20 --- 56,59 ---- *************** *** 145,149 **** void ! timeout_timestamps(void); int --- 146,150 ---- void ! timeout_timestamps(void*); int *************** *** 156,158 **** --- 157,177 ---- read_key_from_file(char *); + void + olsr_get_timestamp(olsr_u32_t, struct timeval *); + + void + olsr_init_timer(olsr_u32_t, struct timeval *); + + int + olsr_timed_out(struct timeval *); + + int + secure_plugin_init(void); + + void + secure_plugin_exit(void); + + int + plugin_ipc_init(void); + #endif Index: olsrd_plugin.c =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/lib/secure/src/olsrd_plugin.c,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** olsrd_plugin.c 25 Feb 2005 22:43:11 -0000 1.9 --- olsrd_plugin.c 29 May 2005 12:47:43 -0000 1.10 *************** *** 40,58 **** #include "olsrd_plugin.h" #include #include - #include "plugin_loader.h" ! 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); /* --- 40,60 ---- #include "olsrd_plugin.h" + #include "olsrd_secure.h" #include #include ! ! #define PLUGIN_NAME "OLSRD signature plugin" ! #define PLUGIN_VERSION "0.5" ! #define PLUGIN_AUTHOR "Andreas T�nnesen" ! #define MOD_DESC PLUGIN_NAME " " PLUGIN_VERSION " by " PLUGIN_AUTHOR ! ! ! static void __attribute__ ((constructor)) my_init(void); ! static void __attribute__ ((destructor)) my_fini(void); /* *************** *** 62,68 **** */ int ! get_plugin_interface_version() { ! return PLUGIN_INTERFACE_VERSION; } --- 64,70 ---- */ int ! olsrd_plugin_interface_version() { ! return OLSRD_PLUGIN_INTERFACE_VERSION; } *************** *** 72,76 **** *Constructor */ ! void my_init() { --- 74,78 ---- *Constructor */ ! static void my_init() { *************** *** 79,85 **** printf("%s\n", MOD_DESC); printf("[ENC]Accepted parameter pairs: (\"Keyfile\" )\n"); - ifs = NULL; - - return; } --- 81,84 ---- *************** *** 87,91 **** *Destructor */ ! void my_fini() { --- 86,90 ---- *Destructor */ ! static void my_fini() { *************** *** 97,108 **** * should happen there - NOT HERE! */ ! olsr_plugin_exit(); ! ! return; } int ! register_olsr_param(char *key, char *value) { if(!strcmp(key, "Keyfile")) --- 96,105 ---- * should happen there - NOT HERE! */ ! secure_plugin_exit(); } int ! olsrd_plugin_register_param(char *key, char *value) { if(!strcmp(key, "Keyfile")) *************** *** 115,151 **** - /** - *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() --- 112,117 ---- int ! olsrd_plugin_init() { /* Calls the initialization function * olsr_plugin_init() *************** *** 154,158 **** * should happen there - NOT HERE! */ ! if(!olsr_plugin_init()) { fprintf(stderr, "Could not initialize plugin!\n"); --- 120,124 ---- * should happen there - NOT HERE! */ ! if(!secure_plugin_init()) { fprintf(stderr, "Could not initialize plugin!\n"); *************** *** 168,337 **** } - - - - int - fetch_olsrd_data() - { - int retval = 1; - - - if(!olsr_plugin_io(GETF__NET_RESERVE_BUFSPACE, - &net_reserve_bufspace, - sizeof(net_reserve_bufspace))) - { - net_reserve_bufspace = NULL; - retval = 0; - } - - if(!olsr_plugin_io(GETF__NET_OUTBUFFER_PUSH_RESERVED, - &net_outbuffer_push_reserved, - sizeof(net_outbuffer_push_reserved))) - { - net_outbuffer_push_reserved = NULL; - retval = 0; - } - - if(!olsr_plugin_io(GETF__NET_OUTBUFFER_PUSH, - &net_outbuffer_push, - sizeof(net_outbuffer_push))) - { - net_outbuffer_push = NULL; - retval = 0; - } - - - if(!olsr_plugin_io(GETF__OLSR_PRINTF, - &olsr_printf, - sizeof(olsr_printf))) - { - olsr_printf = NULL; - retval = 0; - } - - if(!olsr_plugin_io(GETD__NOW, - &now, - sizeof(now))) - { - now = NULL; - retval = 0; - } - - if(!olsr_plugin_io(GETF__NET_OUTPUT, - &net_output, - sizeof(net_output))) - { - net_output = NULL; - retval = 0; - } - - /* Olsr malloc wrapper */ - if(!olsr_plugin_io(GETF__OLSR_MALLOC, - &olsr_malloc, - sizeof(olsr_malloc))) - { - olsr_malloc = 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; - } - - - /* Interface list */ - if(!olsr_plugin_io(GETD__IFNET, &ifs, sizeof(ifs))) - { - ifs = 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; - } - - /* Remove socket from OLSR select function */ - if(!olsr_plugin_io(GETF__REMOVE_OLSR_SOCKET, &remove_olsr_socket, sizeof(remove_olsr_socket))) - { - remove_olsr_socket = NULL; - retval = 0; - } - - /* Add packet transform function */ - if(!olsr_plugin_io(GETF__ADD_PTF, &add_ptf, sizeof(add_ptf))) - { - add_ptf = NULL; - retval = 0; - } - - /* Remove packet transform function */ - if(!olsr_plugin_io(GETF__DEL_PTF, &del_ptf, sizeof(del_ptf))) - { - del_ptf = NULL; - retval = 0; - } - - /* Get message seqno function */ - if(!olsr_plugin_io(GETF__GET_MSG_SEQNO, &get_msg_seqno, sizeof(get_msg_seqno))) - { - get_msg_seqno = NULL; - retval = 0; - } - - /* Socket read function */ - if(!olsr_plugin_io(GETF__OLSR_INPUT, &olsr_input, sizeof(olsr_input))) - { - olsr_input = NULL; - retval = 0; - } - - /* Default packet parser */ - if(!olsr_plugin_io(GETF__PARSE_PACKET, &parse_packet, sizeof(parse_packet))) - { - parse_packet = NULL; - retval = 0; - } - - /* Find interface by socket */ - if(!olsr_plugin_io(GETF__IF_IFWITHSOCK, &if_ifwithsock, sizeof(if_ifwithsock))) - { - if_ifwithsock = NULL; - retval = 0; - } - - /* Find interface by address */ - if(!olsr_plugin_io(GETF__IF_IFWITHADDR, &if_ifwithaddr, sizeof(if_ifwithaddr))) - { - if_ifwithaddr = NULL; - retval = 0; - } - - - /* Add ifchange function */ - if(!olsr_plugin_io(GETF__ADD_IFCHGF, &add_ifchgf, sizeof(add_ifchgf))) - { - add_ifchgf = NULL; - retval = 0; - } - - /* Remove ifchange function */ - if(!olsr_plugin_io(GETF__DEL_IFCHGF, &del_ifchgf, sizeof(del_ifchgf))) - { - del_ifchgf = NULL; - retval = 0; - } - - - return retval; - - } --- 134,135 ---- --- olsrd_plugin.h DELETED --- Index: olsrd_secure.c =================================================================== RCS file: /cvsroot/olsrd/olsrd-current/lib/secure/src/olsrd_secure.c,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** olsrd_secure.c 25 May 2005 13:50:22 -0000 1.13 --- olsrd_secure.c 29 May 2005 12:47:44 -0000 1.14 *************** *** 43,46 **** --- 43,47 ---- #include "olsrd_secure.h" + #include #include *************** *** 53,56 **** --- 54,63 ---- #include + #include "defs.h" + #include "olsr.h" + #include "socket_parser.h" + #include "parser.h" + #include "scheduler.h" + #ifdef USE_OPENSSL /* OpenSSL stuff */ *************** *** 112,116 **** int ! olsr_plugin_init() { struct interface *ints; --- 119,123 ---- int ! secure_plugin_init() { struct interface *ints; *************** *** 149,153 **** /* Hijack OLSR socket parser functions */ ! ints = ifs; while(ints) { --- 156,160 ---- /* Hijack OLSR socket parser functions */ ! ints = ifnet; while(ints) { *************** *** 158,162 **** /* Reducing maxmessagesize */ ! net_reserve_bufspace(ints, sizeof(struct olsrmsg)); ints = ints->int_next; --- 165,169 ---- /* Reducing maxmessagesize */ ! net_reserve_bufspace(ints, sizeof(struct s_olsrmsg)); ints = ints->int_next; *************** *** 169,172 **** --- 176,180 ---- } + int plugin_ipc_init() *************** *** 180,205 **** */ void ! olsr_plugin_exit() ! { ! } ! ! ! ! /* Mulitpurpose funtion */ ! int ! plugin_io(int cmd, void *data, size_t size) { - - switch(cmd) - { - default: - return 0; - } - - return 1; } - /** *Scheduled event --- 188,196 ---- */ void ! secure_plugin_exit() { } /** *Scheduled event *************** *** 232,236 **** add_olsr_socket(ifn->olsr_socket, &packet_parser); /* Reducing maxmessagesize */ ! net_reserve_bufspace(ifn, sizeof(struct olsrmsg)); break; --- 223,227 ---- add_olsr_socket(ifn->olsr_socket, &packet_parser); /* Reducing maxmessagesize */ ! net_reserve_bufspace(ifn, sizeof(struct s_olsrmsg)); break; *************** *** 283,287 **** } ! if(ipversion == AF_INET) { /* IPv4 sender address */ --- 274,278 ---- } ! if(olsr_cnf->ip_version == AF_INET) { /* IPv4 sender address */ *************** *** 345,351 **** //printf("\nCC: %d FROMLEN: %d\n\n", cc, fromlen); ! if ((ipversion == AF_INET) && (fromlen != sizeof (struct sockaddr_in))) break; ! else if ((ipversion == AF_INET6) && (fromlen != sizeof (struct sockaddr_in6))) break; --- 336,342 ---- //printf("\nCC: %d FROMLEN: %d\n\n", cc, fromlen); ! if ((olsr_cnf->ip_version == AF_INET) && (fromlen != sizeof (struct sockaddr_in))) break; ! else if ((olsr_cnf->ip_version == AF_INET6) && (fromlen != sizeof (struct sockaddr_in6))) break; *************** *** 410,414 **** add_signature(char *pck, int *size) { ! struct olsrmsg *msg; #ifdef DEBUG int i, j; --- 401,405 ---- add_signature(char *pck, int *size) { ! struct s_olsrmsg *msg; #ifdef DEBUG int i, j; *************** *** 419,431 **** fflush(stdout); ! msg = (struct olsrmsg *)&pck[*size]; /* Update size */ ! ((struct olsr*)pck)->olsr_packlen = htons(*size + sizeof(struct olsrmsg)); /* Fill packet header */ msg->olsr_msgtype = MESSAGE_TYPE; msg->olsr_vtime = 0; ! msg->olsr_msgsize = htons(sizeof(struct olsrmsg)); ! memcpy(&msg->originator, main_addr, ipsize); msg->ttl = 1; msg->hopcnt = 0; --- 410,422 ---- fflush(stdout); ! msg = (struct s_olsrmsg *)&pck[*size]; /* Update size */ ! ((struct olsr*)pck)->olsr_packlen = htons(*size + sizeof(struct s_olsrmsg)); /* Fill packet header */ msg->olsr_msgtype = MESSAGE_TYPE; msg->olsr_vtime = 0; ! msg->olsr_msgsize = htons(sizeof(struct s_olsrmsg)); ! memcpy(&msg->originator, &main_addr, ipsize); msg->ttl = 1; msg->hopcnt = 0; *************** *** 438,446 **** /* Add timestamp */ ! msg->sig.timestamp = htonl(now->tv_sec); ! olsr_printf(3, "[ENC]timestamp: %d\n", now->tv_sec); /* Set the new size */ ! *size = *size + sizeof(struct olsrmsg); /* Create packet + key cache */ --- 429,437 ---- /* Add timestamp */ ! msg->sig.timestamp = htonl(now.tv_sec); ! olsr_printf(3, "[ENC]timestamp: %d\n", now.tv_sec); /* Set the new size */ ! *size = *size + sizeof(struct s_olsrmsg); /* Create packet + key cache */ *************** *** 460,464 **** sigmsg = (char *)msg; ! for(i = 0; i < sizeof(struct olsrmsg); i++) { olsr_printf(1, " %3i", (u_char) sigmsg[i]); --- 451,455 ---- sigmsg = (char *)msg; ! for(i = 0; i < sizeof(struct s_olsrmsg); i++) { olsr_printf(1, " %3i", (u_char) sigmsg[i]); *************** *** 484,488 **** int packetsize; char sha1_hash[SIGNATURE_SIZE]; ! struct olsrmsg *sig; time_t rec_time; --- 475,479 ---- int packetsize; char sha1_hash[SIGNATURE_SIZE]; ! struct s_olsrmsg *sig; time_t rec_time; *************** *** 493,502 **** /* Find size - signature message */ ! packetsize = *size - sizeof(struct olsrmsg); if(packetsize < 4) return 0; ! sig = (struct olsrmsg *)&pck[packetsize]; //olsr_printf(1, "Size: %d\n", packetsize); --- 484,493 ---- /* Find size - signature message */ ! packetsize = *size - sizeof(struct s_olsrmsg); if(packetsize < 4) return 0; ! sig = (struct s_olsrmsg *)&pck[packetsize]; //olsr_printf(1, "Size: %d\n", packetsize); *************** *** 508,512 **** sigmsg = (char *)sig; ! for(i = 0; i < sizeof(struct olsrmsg); i++) { olsr_printf(1, " %3i", (u_char) sigmsg[i]); --- 499,503 ---- sigmsg = (char *)sig; ! for(i = 0; i < sizeof(struct s_olsrmsg); i++) { olsr_printf(1, " %3i", (u_char) sigmsg[i]); *************** *** 523,527 **** if((sig->olsr_msgtype != MESSAGE_TYPE) || (sig->olsr_vtime) || ! (sig->olsr_msgsize != ntohs(sizeof(struct olsrmsg))) || (sig->ttl != 1) || (sig->hopcnt != 0)) --- 514,518 ---- if((sig->olsr_msgtype != MESSAGE_TYPE) || (sig->olsr_vtime) || ! (sig->olsr_msgsize != ntohs(sizeof(struct s_olsrmsg))) || (sig->ttl != 1) || (sig->hopcnt != 0)) *************** *** 603,607 **** } ! olsr_printf(1, "[ENC]Received timestamp %d diff: %d\n", rec_time, now->tv_sec - rec_time); /* Remove signature message */ --- 594,598 ---- } ! olsr_printf(1, "[ENC]Received timestamp %d diff: %d\n", rec_time, now.tv_sec - rec_time); /* Remove signature message */ *************** *** 634,638 **** } ! diff = entry->diff - (now->tv_sec - tstamp); olsr_printf(3, "[ENC]Timestamp slack: %d\n", diff); --- 625,629 ---- } ! diff = entry->diff - (now.tv_sec - tstamp); olsr_printf(3, "[ENC]Timestamp slack: %d\n", diff); *************** *** 645,650 **** /* ok - update diff */ ! entry->diff = ((now->tv_sec - tstamp) + entry->diff) ? ! ((now->tv_sec - tstamp) + entry->diff) / 2 : 0; olsr_printf(3, "[ENC]Diff set to : %d\n", entry->diff); --- 636,641 ---- /* ok - update diff */ ! entry->diff = ((now.tv_sec - tstamp) + entry->diff) ? ! ((now.tv_sec - tstamp) + entry->diff) / 2 : 0; olsr_printf(3, "[ENC]Diff set to : %d\n", entry->diff); *************** *** 684,688 **** cmsg.olsr_vtime = 0; cmsg.olsr_msgsize = htons(sizeof(struct challengemsg)); ! memcpy(&cmsg.originator, main_addr, ipsize); cmsg.ttl = 1; cmsg.hopcnt = 0; --- 675,679 ---- cmsg.olsr_vtime = 0; cmsg.olsr_msgsize = htons(sizeof(struct challengemsg)); ! memcpy(&cmsg.originator, &main_addr, ipsize); cmsg.ttl = 1; cmsg.hopcnt = 0; *************** *** 820,824 **** entry->challenge = 0; entry->validated = 1; ! entry->diff = now->tv_sec - msg->timestamp; /* update validtime - validated entry */ --- 811,815 ---- entry->challenge = 0; entry->validated = 1; ! entry->diff = now.tv_sec - msg->timestamp; /* update validtime - validated entry */ *************** *** 915,919 **** entry->challenge = 0; entry->validated = 1; ! entry->diff = now->tv_sec - msg->timestamp; /* update validtime - validated entry */ --- 906,910 ---- entry->challenge = 0; entry->validated = 1; ! entry->diff = now.tv_sec - msg->timestamp; /* update validtime - validated entry */ *************** *** 1045,1049 **** crmsg.olsr_vtime = 0; crmsg.olsr_msgsize = htons(sizeof(struct c_respmsg)); ! memcpy(&crmsg.originator, main_addr, ipsize); crmsg.ttl = 1; crmsg.hopcnt = 0; --- 1036,1040 ---- crmsg.olsr_vtime = 0; crmsg.olsr_msgsize = htons(sizeof(struct c_respmsg)); ! memcpy(&crmsg.originator, &main_addr, ipsize); crmsg.ttl = 1; crmsg.hopcnt = 0; *************** *** 1051,1055 **** /* set timestamp */ ! crmsg.timestamp = now->tv_sec; olsr_printf(3, "[ENC]Timestamp %d\n", crmsg.timestamp); --- 1042,1046 ---- /* set timestamp */ ! crmsg.timestamp = now.tv_sec; olsr_printf(3, "[ENC]Timestamp %d\n", crmsg.timestamp); *************** *** 1119,1123 **** rrmsg.olsr_vtime = 0; rrmsg.olsr_msgsize = htons(sizeof(struct r_respmsg)); ! memcpy(&rrmsg.originator, main_addr, ipsize); rrmsg.ttl = 1; rrmsg.hopcnt = 0; --- 1110,1114 ---- rrmsg.olsr_vtime = 0; rrmsg.olsr_msgsize = htons(sizeof(struct r_respmsg)); ! memcpy(&rrmsg.originator, &main_addr, ipsize); rrmsg.ttl = 1; rrmsg.hopcnt = 0; *************** *** 1125,1129 **** /* set timestamp */ ! rrmsg.timestamp = now->tv_sec; olsr_printf(3, "[ENC]Timestamp %d\n", rrmsg.timestamp); --- 1116,1120 ---- /* set timestamp */ ! rrmsg.timestamp = now.tv_sec; olsr_printf(3, "[ENC]Timestamp %d\n", rrmsg.timestamp); *************** *** 1204,1208 **** */ void ! timeout_timestamps() { struct stamp *tmp_list; --- 1195,1199 ---- */ void ! timeout_timestamps(void* foo) { struct stamp *tmp_list; *************** *** 1278,1311 **** /** - *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; - } - - - - /** *Checks if a timer has times out. That means *if it is smaller than present time. --- 1269,1272 ---- *************** *** 1318,1322 **** olsr_timed_out(struct timeval *timer) { ! return(timercmp(timer, now, <)); } --- 1279,1283 ---- olsr_timed_out(struct timeval *timer) { ! return(timercmp(timer, &now, <)); } *************** *** 1364,1407 **** 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; } - --- 1325,1330 ---- 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); }