[Olsr-cvs] olsrd-current/src/unix ifnet.c,1.53,1.54
Bernd Petrovitsch
(spam-protected)
Thu Nov 29 01:49:42 CET 2007
Update of /cvsroot/olsrd/olsrd-current/src/unix
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv16024/src/unix
Modified Files:
ifnet.c
Log Message:
Major Changes:
- renamed "struct local_hna_entry" to "struct ip_prefix_list" since
it is exactly that. Renamed the functions in src/local_hna_set.{c,h}
in the same way.
- each IPv4 and IPv6 function pairs in src/local_hna_set.{c,h} is
called from the same place and have the same signature. So I
condensed each of them.
- Since we have only 3 functions left in src/local_hna_set.{c,h}
and they are used for the configuration, the .h file is now part
of src/olsr_cfg.h and the ,c file of src/cfgparser/olsrd_conf.c.
- replaced "struct ipc_net" with "struct ip_prefix_list" since it
serves the same purpose as the "struct ip_prefix_list"
- replaced "struct ipc_host" with "struct ip_prefix_list" since it
serves the same purpose as the "struct ip_prefix_list" and is
just a special case. No need to duplicate code etc.
- removed "union hna_netmask" from src/olsr_types since we use the
prefix_len everywhere (and that is an olsr_u8_t in several other
struct's).
That implies changes and simplifications in the code handling
them (since the IPv4 is similar to IPv6).
- the config file parser now understands for IPv4 addresses also
"/$prefix".
- On the output side, the patch generates only "/$prefix" which
kills code since it is the same as the IPv6 handling.
- There are some netmask conversions left (mainly in the plugins)
but that be cleaned up afterwards.
- extracted ip{,4,6}{cmp,equal} and formatting functions from
net_olsr.{c,h} into src/ipcalc.{c,h} since net_olsr.h became
IMHO to much of a "put anything in there".
- renamed "sockaddr_to_string()" to "sockaddr4_to_string()"
since it is exactly that (unless I'm missing something).
Minor Changes:
- lib/httpinfo/src/admin_html.h contained just some variable
definitions so it is now integrated in the only user:
admin_interface.c
- olsrd_dot_draw.c got rid of two indicator variables if
a socket is valid or not. Since sockets may use "-1" as the
"not open", "invalid" value, there is no need for two more
ints.
- and the dot_draw plugin is somewhat smaller and easier to read.
- const'ified some functions
Index: ifnet.c
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/src/unix/ifnet.c,v
retrieving revision 1.53
retrieving revision 1.54
diff -C2 -d -r1.53 -r1.54
*** ifnet.c 8 Nov 2007 22:47:42 -0000 1.53
--- ifnet.c 29 Nov 2007 00:49:40 -0000 1.54
***************
*** 45,50 ****
#endif
- #include "interfaces.h"
#include "ifnet.h"
#include "defs.h"
#include "olsr.h"
--- 45,51 ----
#endif
#include "ifnet.h"
+ #include "ipcalc.h"
+ #include "interfaces.h"
#include "defs.h"
#include "olsr.h"
***************
*** 320,324 ****
#ifdef DEBUG
! OLSR_PRINTF(3, "\tAddress:%s\n", sockaddr_to_string(&buf, &ifr.ifr_addr));
#endif
--- 321,325 ----
#ifdef DEBUG
! OLSR_PRINTF(3, "\tAddress:%s\n", sockaddr4_to_string(&buf, &ifr.ifr_addr));
#endif
***************
*** 330,334 ****
OLSR_PRINTF(1, "IPv4 address changed for %s\n", ifr.ifr_name);
OLSR_PRINTF(1, "\tOld:%s\n", ip4_to_string(&buf, ifp->int_addr.sin_addr));
! OLSR_PRINTF(1, "\tNew:%s\n", sockaddr_to_string(&buf, &ifr.ifr_addr));
ifp->int_addr = *(struct sockaddr_in *)&ifr.ifr_addr;
--- 331,335 ----
OLSR_PRINTF(1, "IPv4 address changed for %s\n", ifr.ifr_name);
OLSR_PRINTF(1, "\tOld:%s\n", ip4_to_string(&buf, ifp->int_addr.sin_addr));
! OLSR_PRINTF(1, "\tNew:%s\n", sockaddr4_to_string(&buf, &ifr.ifr_addr));
ifp->int_addr = *(struct sockaddr_in *)&ifr.ifr_addr;
***************
*** 338,343 ****
olsr_cnf->ipsize) == 0)
{
! OLSR_PRINTF(1, "New main address: %s\n", sockaddr_to_string(&buf, &ifr.ifr_addr));
! olsr_syslog(OLSR_LOG_INFO, "New main address: %s\n", sockaddr_to_string(&buf, &ifr.ifr_addr));
memcpy(&olsr_cnf->main_addr,
&((struct sockaddr_in *)&ifr.ifr_addr)->sin_addr.s_addr,
--- 339,344 ----
olsr_cnf->ipsize) == 0)
{
! OLSR_PRINTF(1, "New main address: %s\n", sockaddr4_to_string(&buf, &ifr.ifr_addr));
! olsr_syslog(OLSR_LOG_INFO, "New main address: %s\n", sockaddr4_to_string(&buf, &ifr.ifr_addr));
memcpy(&olsr_cnf->main_addr,
&((struct sockaddr_in *)&ifr.ifr_addr)->sin_addr.s_addr,
***************
*** 360,364 ****
#ifdef DEBUG
! OLSR_PRINTF(3, "\tNetmask:%s\n", sockaddr_to_string(&buf, &ifr.ifr_netmask));
#endif
--- 361,365 ----
#ifdef DEBUG
! OLSR_PRINTF(3, "\tNetmask:%s\n", sockaddr4_to_string(&buf, &ifr.ifr_netmask));
#endif
***************
*** 373,377 ****
OLSR_PRINTF(1, "IPv4 netmask changed for %s\n", ifr.ifr_name);
OLSR_PRINTF(1, "\tOld:%s\n", ip4_to_string(&buf, ifp->int_netmask.sin_addr));
! OLSR_PRINTF(1, "\tNew:%s\n", sockaddr_to_string(&buf, &ifr.ifr_netmask));
ifp->int_netmask = *(struct sockaddr_in *)&ifr.ifr_netmask;
--- 374,378 ----
OLSR_PRINTF(1, "IPv4 netmask changed for %s\n", ifr.ifr_name);
OLSR_PRINTF(1, "\tOld:%s\n", ip4_to_string(&buf, ifp->int_netmask.sin_addr));
! OLSR_PRINTF(1, "\tNew:%s\n", sockaddr4_to_string(&buf, &ifr.ifr_netmask));
ifp->int_netmask = *(struct sockaddr_in *)&ifr.ifr_netmask;
***************
*** 390,394 ****
#ifdef DEBUG
! OLSR_PRINTF(3, "\tBroadcast address:%s\n", sockaddr_to_string(&buf, &ifr.ifr_broadaddr));
#endif
--- 391,395 ----
#ifdef DEBUG
! OLSR_PRINTF(3, "\tBroadcast address:%s\n", sockaddr4_to_string(&buf, &ifr.ifr_broadaddr));
#endif
***************
*** 401,405 ****
OLSR_PRINTF(1, "IPv4 broadcast changed for %s\n", ifr.ifr_name);
OLSR_PRINTF(1, "\tOld:%s\n", ip4_to_string(&buf, ifp->int_broadaddr.sin_addr));
! OLSR_PRINTF(1, "\tNew:%s\n", sockaddr_to_string(&buf, &ifr.ifr_broadaddr));
ifp->int_broadaddr = *(struct sockaddr_in *)&ifr.ifr_broadaddr;
--- 402,406 ----
OLSR_PRINTF(1, "IPv4 broadcast changed for %s\n", ifr.ifr_name);
OLSR_PRINTF(1, "\tOld:%s\n", ip4_to_string(&buf, ifp->int_broadaddr.sin_addr));
! OLSR_PRINTF(1, "\tNew:%s\n", sockaddr4_to_string(&buf, &ifr.ifr_broadaddr));
ifp->int_broadaddr = *(struct sockaddr_in *)&ifr.ifr_broadaddr;
More information about the Olsr-cvs
mailing list