[Olsr-cvs] olsrd-current/lib/nameservice/src nameservice.c, 1.16, 1.17 nameservice.h, 1.9, 1.10 nameservice_msg.h, 1.6, 1.7
Bernd Petrovitsch
(spam-protected)
Sun Feb 4 22:11:50 CET 2007
Update of /cvsroot/olsrd/olsrd-current/lib/nameservice/src
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv2671/lib/nameservice/src
Modified Files:
nameservice.c nameservice.h nameservice_msg.h
Log Message:
* merged it also and fixed lots of stuff by hand
It seems to work on my node.
Index: nameservice.h
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/lib/nameservice/src/nameservice.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** nameservice.h 2 Jun 2005 15:34:00 -0000 1.9
--- nameservice.h 4 Feb 2007 21:11:48 -0000 1.10
***************
*** 40,43 ****
--- 40,44 ----
#include <sys/time.h>
+ #include <regex.h>
#include "olsr_types.h"
***************
*** 52,68 ****
#define PLUGIN_AUTHOR "Bruno Randolf"
#define MESSAGE_TYPE 130
#define PARSER_TYPE MESSAGE_TYPE
#define EMISSION_INTERVAL 120 /* two minutes */
! #define NAME_VALID_TIME 3600 /* one hour */
#define NAME_PROTOCOL_VERSION 1
! #define MAX_NAME 255
#define MAX_FILE 255
! #define MAX_SUFFIX 255
!
struct name_entry
{
--- 53,77 ----
#define PLUGIN_AUTHOR "Bruno Randolf"
+ // useful to set for the freifunkfirmware to remove all
+ // calls to olsr_printf by the empty statement ";"
+ //#define olsr_printf(...) ;
#define MESSAGE_TYPE 130
#define PARSER_TYPE MESSAGE_TYPE
#define EMISSION_INTERVAL 120 /* two minutes */
! #define NAME_VALID_TIME 1800 /* half one hour */
#define NAME_PROTOCOL_VERSION 1
! #define MAX_NAME 127
#define MAX_FILE 255
! #define MAX_SUFFIX 63
+ /**
+ * a linked list of name_entry
+ * if type is NAME_HOST, name is a hostname and ip its IP addr
+ * if type is NAME_FORWARDER, then ip is a dns-server (and name is irrelevant)
+ * if type is NAME_SERVICE, then name is a service-line (and the ip is irrelevant)
+ */
struct name_entry
{
***************
*** 74,78 ****
};
! /* database entry */
struct db_entry
{
--- 83,97 ----
};
! /* *
! * linked list of db_entries for each originator with
! * originator being its main_addr
! *
! * names points to the name_entry with its hostname, dns-server or
! * service-line entry
! *
! * all the db_entries are hashed in nameservice.c to avoid a too long list
! * for many nodes in a net
! *
! * */
struct db_entry
{
***************
*** 99,104 ****
encap_namemsg(struct namemsg *);
void
! decap_namemsg(struct namemsg *, int, struct name_entry**);
void
--- 118,141 ----
encap_namemsg(struct namemsg *);
+ struct name_entry*
+ add_name_to_list(struct name_entry *my_list, char *value, int type, struct in_addr *ip);
+
+ struct name_entry*
+ remove_nonvalid_names_from_list(struct name_entry *my_list, int type);
+
+ void
+ free_all_list_entries(struct db_entry **this_db_list) ;
+
void
! timeout_old_names(struct db_entry **this_list, olsr_bool *this_table_changed);
!
! void
! decap_namemsg(struct name *from_packet, struct name_entry **to, olsr_bool *this_table_changed );
!
! void
! insert_new_name_in_list(union olsr_ip_addr *originator, struct db_entry **this_list, struct name *from_packet, olsr_bool *this_table_changed, double vtime);
!
! olsr_bool
! allowed_hostname_or_ip_in_service(char *service_line, regmatch_t *hostname_or_ip);
void
***************
*** 109,112 ****
--- 146,152 ----
void
+ write_services_file(void);
+
+ void
write_resolv_file(void);
***************
*** 120,123 ****
--- 160,175 ----
allowed_ip(union olsr_ip_addr *addr);
+ olsr_bool
+ allowed_service(char *service_line);
+
+ olsr_bool
+ is_name_wellformed(char *service_line);
+
+ olsr_bool
+ is_service_wellformed(char *service_line);
+
+ char*
+ create_packet(struct name *to, struct name_entry *from);
+
void
name_constructor(void);
Index: nameservice.c
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/lib/nameservice/src/nameservice.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -d -r1.16 -r1.17
*** nameservice.c 12 Dec 2006 10:54:52 -0000 1.16
--- nameservice.c 4 Feb 2007 21:11:48 -0000 1.17
***************
*** 1,3 ****
--- 1,4 ----
/*
+ * Copyright (c) 2006, Jens Nachtigall <(spam-protected)>
* Copyright (c) 2005, Bruno Randolf <(spam-protected)>
* Copyright (c) 2004, Andreas Tønnesen(andreto-at-olsr.org)
***************
*** 40,43 ****
--- 41,47 ----
#include <stdlib.h>
#include <unistd.h>
[...1263 lines suppressed...]
+
+ /**
+ * check if the service matches the syntax
+ * of "protocol://host:port/path|tcp_or_udp|a short description",
+ * which is given in the regex regex_t_service
+ */
+ olsr_bool
+ is_service_wellformed(char *service_line)
+ {
+ return regexec(®ex_t_service, service_line, pmatch_service, regmatch_t_service, 0) == 0;
+ }
+
+ /*
+ * Local Variables:
+ * mode: c
+ * c-indent-tabs-mode: t
+ * c-basic-offset: 4
+ * tab-width: 4
+ * End:
+ */
Index: nameservice_msg.h
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/lib/nameservice/src/nameservice_msg.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** nameservice_msg.h 17 Mar 2005 21:41:30 -0000 1.6
--- nameservice_msg.h 4 Feb 2007 21:11:48 -0000 1.7
***************
*** 39,57 ****
#define _NAMESEVICE_MSG
!
typedef enum {
NAME_HOST = 0,
NAME_FORWARDER = 1,
! NAME_SERVICE = 2
} NAME_TYPE;
!
struct name
{
olsr_u16_t type;
olsr_u16_t len; // length of the name
union olsr_ip_addr ip;
/*
! * name is written in plain text after this struct and padded to 4 byte
*/
};
--- 39,62 ----
#define _NAMESEVICE_MSG
! /* type of the packet of name_entry */
typedef enum {
NAME_HOST = 0,
NAME_FORWARDER = 1,
! NAME_SERVICE = 2,
} NAME_TYPE;
! /**
! * the name, forwarder or service entry as found in a packet within a
! * message
! **/
struct name
{
olsr_u16_t type;
olsr_u16_t len; // length of the name
+ // the ip of the hostname, or the ip of the dns-server
+ // ip is irrelevant for services
union olsr_ip_addr ip;
/*
! * name or service is written in plain text after this struct and padded to 4 byte
*/
};
***************
*** 60,65 ****
struct namemsg
{
! olsr_u16_t version;
! olsr_u16_t nr_names; // number of following name messages
/*
* at least one struct name following
--- 65,70 ----
struct namemsg
{
! olsr_u16_t version; // version number of the nameservice plugin
! olsr_u16_t nr_names; // number of following packets including names, forwarders or services
/*
* at least one struct name following
More information about the Olsr-cvs
mailing list