[Olsr-dev] Nameservice patch (add mid entries, seeking comments)

Sven-Ola Tuecke (spam-protected)
Fri Dec 28 12:09:46 CET 2007


Hi Jow,

that's a sender-side fix, if the multihomed owner forget to insert names for 
the additional interfaces, right? Haven't looked into that patch, so I 
simply ask: What happens if a node owner configures names for mid IPs on his 
side?

// Sven-Ola

"Jo-Philipp Wich" <(spam-protected)> schrieb im Newsbeitrag 
news:(spam-protected)
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Hello List,
>
> I developed a patch against the nameservice plugin to also include known
> MID entries in the hosts file. We're using this modification since
> v0.4.8 of OLSRd in our Freifunk Leipzig Firmware without any problems
> observed (so far) ;)
>
> I changed the write_hosts_file() function to lookup known MIDs for every
> IP/hostname pair that's about to be written to the hosts file. Every MID
> will be written as additional hostname "midX.hostname.domain" to the file.
>
> Here's an excerpt from my /etc/hosts generated by the patched
> nameservice plugin:
>
> - --- 8< ---
> 104.61.150.5    150-5.olsr      # 104.61.150.5
> 104.61.239.208  mid1.150-5.olsr # 104.61.150.5 (mid #1)
> 104.61.150.205  mid2.150-5.olsr # 104.61.150.5 (mid #2)
> - --- >8 ---
>
> The "midX." prefix format is declared as #define in nameservice.h .
> I know that it will be better to make this configurable via a plugin
> parameter or something like that. Unfortunately that's beyond my
> knowledge and I'll need help to achieve that.
>
> The attached patch should apply against current HEAD, I've used it
> yesterday to compile the newest OLSR version for 24c3.
>
> What are your opinions or suggestions about the patch?
>
>
> Greetings from Leipzig,
> jow / xM
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.6 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>
> iD8DBQFHc8tVdputYINPTPMRAvDtAJwLzblFonLHcePSccFFF4Tkhwlu9QCfaE7Q
> IbPoLcFmnhEam59zCNh6IWg=
> =+j/O
> -----END PGP SIGNATURE-----
>


--------------------------------------------------------------------------------


> diff -urb olsrd-0.5.4.orig/lib/nameservice/src/nameservice.c 
> olsrd-0.5.4/lib/nameservice/src/nameservice.c
> --- olsrd-0.5.4.orig/lib/nameservice/src/nameservice.c 2007-12-25 
> 21:57:19.000000000 +0100
> +++ olsrd-0.5.4/lib/nameservice/src/nameservice.c 2007-12-25 
> 21:56:53.000000000 +0100
> @@ -991,6 +991,10 @@
>  int c=0;
>  time_t currtime;
>
> +#ifdef MID_ENTRIES
> + struct mid_address *alias;
> +#endif
> +
>  if (!name_table_changed)
>  return;
>
> @@ -1037,11 +1041,54 @@
>  for (name = entry->names; name != NULL; name = name->next)
>  {
>  struct ipaddr_str strbuf;
> - OLSR_PRINTF(6, "%s\t%s%s", olsr_ip_to_string(&strbuf, &name->ip), 
> name->name, my_suffix);
> - OLSR_PRINTF(6, "\t#%s\n", olsr_ip_to_string(&strbuf, 
> &entry->originator));
>
> - fprintf(hosts, "%s\t%s%s", olsr_ip_to_string(&strbuf, &name->ip), 
> name->name, my_suffix);
> - fprintf(hosts, "\t# %s\n", olsr_ip_to_string(&strbuf, 
> &entry->originator));
> + OLSR_PRINTF(
> + 6, "%s\t%s%s\t#%s\n",
> + olsr_ip_to_string( &strbuf, &name->ip ), name->name, my_suffix,
> + olsr_ip_to_string( &strbuf, &entry->originator )
> + );
> +
> + fprintf(
> + hosts, "%s\t%s%s\t# %s\n",
> + olsr_ip_to_string( &strbuf, &name->ip ), name->name, my_suffix,
> + olsr_ip_to_string( &strbuf, &entry->originator )
> + );
> +
> +#ifdef MID_ENTRIES
> + // write mid entries
> + if( ( alias = mid_lookup_aliases( &name->ip ) ) != NULL )
> + {
> + unsigned short mid_num = 1;
> + char    mid_prefix[MID_MAXLEN];
> +
> + while( alias != NULL )
> + {
> + struct ipaddr_str midbuf;
> +
> + // generate mid prefix
> + sprintf( mid_prefix, MID_PREFIX, mid_num );
> +
> + OLSR_PRINTF(
> + 6, "%s\t%s%s%s\t# %s (mid #%i)\n",
> + olsr_ip_to_string( &midbuf, &alias->alias ),
> + mid_prefix, name->name, my_suffix,
> + olsr_ip_to_string( &strbuf, &entry->originator ),
> + mid_num
> + );
> +
> + fprintf(
> + hosts, "%s\t%s%s%s\t# %s (mid #%i)\n",
> + olsr_ip_to_string( &midbuf, &alias->alias ),
> + mid_prefix, name->name, my_suffix,
> + olsr_ip_to_string( &strbuf, &entry->originator ),
> + mid_num
> + );
> +
> + alias = alias->next_alias;
> + mid_num++;
> + }
> + }
> +#endif
>  }
>  }
>  }
> diff -urb olsrd-0.5.4.orig/lib/nameservice/src/nameservice.h 
> olsrd-0.5.4/lib/nameservice/src/nameservice.h
> --- olsrd-0.5.4.orig/lib/nameservice/src/nameservice.h 2007-12-25 
> 21:57:18.000000000 +0100
> +++ olsrd-0.5.4/lib/nameservice/src/nameservice.h 2007-12-25 
> 21:41:43.000000000 +0100
> @@ -70,6 +70,10 @@
> #define MAX_FILE 255
> #define MAX_SUFFIX 63
>
> +#define MID_ENTRIES 1
> +#define MID_MAXLEN 16
> +#define MID_PREFIX "mid%i."
> +
> /**
>  * a linked list of name_entry
>  * if type is NAME_HOST, name is a hostname and ip its IP addr
>


--------------------------------------------------------------------------------


> -- 
> Olsr-dev mailing list
> (spam-protected)
> http://lists.olsr.org/mailman/listinfo/olsr-dev 





More information about the Olsr-dev mailing list