[Olsr-cvs] olsrd-current/src/unix ifnet.c,1.32,1.33
Andreas T�nnesen
(spam-protected)
Sat Jan 7 09:16:28 CET 2006
Update of /cvsroot/olsrd/olsrd-current/src/unix
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15798/unix
Modified Files:
ifnet.c
Log Message:
Cleanup in use of extern variables. Rather trivial changes, but a lot of them
Index: ifnet.c
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/src/unix/ifnet.c,v
retrieving revision 1.32
retrieving revision 1.33
diff -C2 -d -r1.32 -r1.33
*** ifnet.c 6 Jan 2006 06:54:04 -0000 1.32
--- ifnet.c 7 Jan 2006 08:16:24 -0000 1.33
***************
*** 83,87 ****
/* Get flags */
! if (ioctl(ioctl_s, SIOCGIFFLAGS, &ifr) < 0)
{
fprintf(stderr,"ioctl (get interface flags)");
--- 83,87 ----
/* Get flags */
! if (ioctl(olsr_cnf->ioctl_s, SIOCGIFFLAGS, &ifr) < 0)
{
fprintf(stderr,"ioctl (get interface flags)");
***************
*** 98,102 ****
ifr.ifr_flags |= (IFF_UP | IFF_RUNNING);
/* Set flags + UP */
! if(ioctl(ioctl_s, SIOCSIFFLAGS, &ifr) < 0)
{
fprintf(stderr, "ERROR(%s): %s\n", ifr.ifr_name, strerror(errno));
--- 98,102 ----
ifr.ifr_flags |= (IFF_UP | IFF_RUNNING);
/* Set flags + UP */
! if(ioctl(olsr_cnf->ioctl_s, SIOCSIFFLAGS, &ifr) < 0)
{
fprintf(stderr, "ERROR(%s): %s\n", ifr.ifr_name, strerror(errno));
***************
*** 174,178 ****
/* Get flags (and check if interface exists) */
! if (ioctl(ioctl_s, SIOCGIFFLAGS, &ifr) < 0)
{
OLSR_PRINTF(3, "No such interface: %s\n", iface->name)
--- 174,178 ----
/* Get flags (and check if interface exists) */
! if (ioctl(olsr_cnf->ioctl_s, SIOCGIFFLAGS, &ifr) < 0)
{
OLSR_PRINTF(3, "No such interface: %s\n", iface->name)
***************
*** 225,229 ****
/* Get MTU */
! if (ioctl(ioctl_s, SIOCGIFMTU, &ifr) < 0)
ifp->int_mtu = 0;
else
--- 225,229 ----
/* Get MTU */
! if (ioctl(olsr_cnf->ioctl_s, SIOCGIFMTU, &ifr) < 0)
ifp->int_mtu = 0;
else
***************
*** 268,272 ****
#endif
! if(memcmp(&tmp_saddr6.sin6_addr, &ifp->int6_addr.sin6_addr, ipsize) != 0)
{
OLSR_PRINTF(1, "New IP address for %s:\n", ifr.ifr_name)
--- 268,272 ----
#endif
! if(memcmp(&tmp_saddr6.sin6_addr, &ifp->int6_addr.sin6_addr, olsr_cnf->ipsize) != 0)
{
OLSR_PRINTF(1, "New IP address for %s:\n", ifr.ifr_name)
***************
*** 275,287 ****
/* Check main addr */
! if(memcmp(&main_addr, &tmp_saddr6.sin6_addr, ipsize) == 0)
{
/* Update main addr */
! memcpy(&main_addr, &tmp_saddr6.sin6_addr, ipsize);
}
/* Update address */
! memcpy(&ifp->int6_addr.sin6_addr, &tmp_saddr6.sin6_addr, ipsize);
! memcpy(&ifp->ip_addr, &tmp_saddr6.sin6_addr, ipsize);
run_ifchg_cbs(ifp, IFCHG_IF_UPDATE);
--- 275,287 ----
/* Check main addr */
! if(memcmp(&olsr_cnf->main_addr, &tmp_saddr6.sin6_addr, olsr_cnf->ipsize) == 0)
{
/* Update main addr */
! memcpy(&olsr_cnf->main_addr, &tmp_saddr6.sin6_addr, olsr_cnf->ipsize);
}
/* Update address */
! memcpy(&ifp->int6_addr.sin6_addr, &tmp_saddr6.sin6_addr, olsr_cnf->ipsize);
! memcpy(&ifp->ip_addr, &tmp_saddr6.sin6_addr, olsr_cnf->ipsize);
run_ifchg_cbs(ifp, IFCHG_IF_UPDATE);
***************
*** 296,300 ****
{
/* Check interface address (IPv4)*/
! if(ioctl(ioctl_s, SIOCGIFADDR, &ifr) < 0)
{
OLSR_PRINTF(1, "\tCould not get address of interface - removing it\n")
--- 296,300 ----
{
/* Check interface address (IPv4)*/
! if(ioctl(olsr_cnf->ioctl_s, SIOCGIFADDR, &ifr) < 0)
{
OLSR_PRINTF(1, "\tCould not get address of interface - removing it\n")
***************
*** 308,312 ****
if(memcmp(&((struct sockaddr_in *)&ifp->int_addr)->sin_addr.s_addr,
&((struct sockaddr_in *)&ifr.ifr_addr)->sin_addr.s_addr,
! ipsize) != 0)
{
/* New address */
--- 308,312 ----
if(memcmp(&((struct sockaddr_in *)&ifp->int_addr)->sin_addr.s_addr,
&((struct sockaddr_in *)&ifr.ifr_addr)->sin_addr.s_addr,
! olsr_cnf->ipsize) != 0)
{
/* New address */
***************
*** 315,327 ****
OLSR_PRINTF(1, "\tNew:%s\n", sockaddr_to_string(&ifr.ifr_addr))
! if(memcmp(&main_addr,
&((struct sockaddr_in *)&ifp->int_addr)->sin_addr.s_addr,
! ipsize) == 0)
{
OLSR_PRINTF(1, "New main address: %s\n", sockaddr_to_string(&ifr.ifr_addr))
olsr_syslog(OLSR_LOG_INFO, "New main address: %s\n", sockaddr_to_string(&ifr.ifr_addr));
! memcpy(&main_addr,
&((struct sockaddr_in *)&ifp->int_addr)->sin_addr.s_addr,
! ipsize);
}
--- 315,327 ----
OLSR_PRINTF(1, "\tNew:%s\n", sockaddr_to_string(&ifr.ifr_addr))
! if(memcmp(&olsr_cnf->main_addr,
&((struct sockaddr_in *)&ifp->int_addr)->sin_addr.s_addr,
! olsr_cnf->ipsize) == 0)
{
OLSR_PRINTF(1, "New main address: %s\n", sockaddr_to_string(&ifr.ifr_addr))
olsr_syslog(OLSR_LOG_INFO, "New main address: %s\n", sockaddr_to_string(&ifr.ifr_addr));
! memcpy(&olsr_cnf->main_addr,
&((struct sockaddr_in *)&ifp->int_addr)->sin_addr.s_addr,
! olsr_cnf->ipsize);
}
***************
*** 329,333 ****
memcpy(&ifp->ip_addr,
&((struct sockaddr_in *)&ifp->int_addr)->sin_addr.s_addr,
! ipsize);
if_changes = 1;
--- 329,333 ----
memcpy(&ifp->ip_addr,
&((struct sockaddr_in *)&ifp->int_addr)->sin_addr.s_addr,
! olsr_cnf->ipsize);
if_changes = 1;
***************
*** 335,339 ****
/* Check netmask */
! if (ioctl(ioctl_s, SIOCGIFNETMASK, &ifr) < 0)
{
olsr_syslog(OLSR_LOG_ERR, "%s: ioctl (get broadaddr)", ifr.ifr_name);
--- 335,339 ----
/* Check netmask */
! if (ioctl(olsr_cnf->ioctl_s, SIOCGIFNETMASK, &ifr) < 0)
{
olsr_syslog(OLSR_LOG_ERR, "%s: ioctl (get broadaddr)", ifr.ifr_name);
***************
*** 347,351 ****
if(memcmp(&((struct sockaddr_in *)&ifp->int_netmask)->sin_addr.s_addr,
&((struct sockaddr_in *)&ifr.ifr_netmask)->sin_addr.s_addr,
! ipsize) != 0)
{
/* New address */
--- 347,351 ----
if(memcmp(&((struct sockaddr_in *)&ifp->int_netmask)->sin_addr.s_addr,
&((struct sockaddr_in *)&ifr.ifr_netmask)->sin_addr.s_addr,
! olsr_cnf->ipsize) != 0)
{
/* New address */
***************
*** 362,366 ****
{
/* Check broadcast address */
! if (ioctl(ioctl_s, SIOCGIFBRDADDR, &ifr) < 0)
{
olsr_syslog(OLSR_LOG_ERR, "%s: ioctl (get broadaddr)", ifr.ifr_name);
--- 362,366 ----
{
/* Check broadcast address */
! if (ioctl(olsr_cnf->ioctl_s, SIOCGIFBRDADDR, &ifr) < 0)
{
olsr_syslog(OLSR_LOG_ERR, "%s: ioctl (get broadaddr)", ifr.ifr_name);
***************
*** 374,378 ****
if(memcmp(&((struct sockaddr_in *)&ifp->int_broadaddr)->sin_addr.s_addr,
&((struct sockaddr_in *)&ifr.ifr_broadaddr)->sin_addr.s_addr,
! ipsize) != 0)
{
--- 374,378 ----
if(memcmp(&((struct sockaddr_in *)&ifp->int_broadaddr)->sin_addr.s_addr,
&((struct sockaddr_in *)&ifr.ifr_broadaddr)->sin_addr.s_addr,
! olsr_cnf->ipsize) != 0)
{
***************
*** 423,439 ****
/* Check main addr */
! if(COMP_IP(&main_addr, &ifp->ip_addr))
{
if(ifnet == NULL)
{
/* No more interfaces */
! memset(&main_addr, 0, ipsize);
OLSR_PRINTF(1, "No more interfaces...\n")
}
else
{
! COPY_IP(&main_addr, &ifnet->ip_addr);
! OLSR_PRINTF(1, "New main address: %s\n", olsr_ip_to_string(&main_addr))
! olsr_syslog(OLSR_LOG_INFO, "New main address: %s\n", olsr_ip_to_string(&main_addr));
}
}
--- 423,439 ----
/* Check main addr */
! if(COMP_IP(&olsr_cnf->main_addr, &ifp->ip_addr))
{
if(ifnet == NULL)
{
/* No more interfaces */
! memset(&olsr_cnf->main_addr, 0, olsr_cnf->ipsize);
OLSR_PRINTF(1, "No more interfaces...\n")
}
else
{
! COPY_IP(&olsr_cnf->main_addr, &ifnet->ip_addr);
! OLSR_PRINTF(1, "New main address: %s\n", olsr_ip_to_string(&olsr_cnf->main_addr))
! olsr_syslog(OLSR_LOG_INFO, "New main address: %s\n", olsr_ip_to_string(&olsr_cnf->main_addr));
}
}
***************
*** 502,506 ****
OLSR_PRINTF(1, "No more active interfaces - exiting.\n")
olsr_syslog(OLSR_LOG_INFO, "No more active interfaces - exiting.\n");
! exit_value = EXIT_FAILURE;
kill(getpid(), SIGINT);
}
--- 502,506 ----
OLSR_PRINTF(1, "No more active interfaces - exiting.\n")
olsr_syslog(OLSR_LOG_INFO, "No more active interfaces - exiting.\n");
! olsr_cnf->exit_value = EXIT_FAILURE;
kill(getpid(), SIGINT);
}
***************
*** 548,557 ****
ifnet = ifp;
! memset(&null_addr, 0, ipsize);
! if(COMP_IP(&null_addr, &main_addr))
{
! COPY_IP(&main_addr, &iface->hemu_ip);
! OLSR_PRINTF(1, "New main address: %s\n", olsr_ip_to_string(&main_addr))
! olsr_syslog(OLSR_LOG_INFO, "New main address: %s\n", olsr_ip_to_string(&main_addr));
}
--- 548,557 ----
ifnet = ifp;
! memset(&null_addr, 0, olsr_cnf->ipsize);
! if(COMP_IP(&null_addr, &olsr_cnf->main_addr))
{
! COPY_IP(&olsr_cnf->main_addr, &iface->hemu_ip);
! OLSR_PRINTF(1, "New main address: %s\n", olsr_ip_to_string(&olsr_cnf->main_addr))
! olsr_syslog(OLSR_LOG_INFO, "New main address: %s\n", olsr_ip_to_string(&olsr_cnf->main_addr));
}
***************
*** 580,584 ****
ifp->ip_addr.v4 = iface->hemu_ip.v4;
! memcpy(&((struct sockaddr_in *)&ifp->int_addr)->sin_addr, &iface->hemu_ip, ipsize);
/*
--- 580,584 ----
ifp->ip_addr.v4 = iface->hemu_ip.v4;
! memcpy(&((struct sockaddr_in *)&ifp->int_addr)->sin_addr, &iface->hemu_ip, olsr_cnf->ipsize);
/*
***************
*** 594,598 ****
fprintf(stderr, "Could not initialize socket... exiting!\n\n");
olsr_syslog(OLSR_LOG_ERR, "Could not initialize socket... exiting!\n\n");
! exit_value = EXIT_FAILURE;
kill(getpid(), SIGINT);
}
--- 594,598 ----
fprintf(stderr, "Could not initialize socket... exiting!\n\n");
olsr_syslog(OLSR_LOG_ERR, "Could not initialize socket... exiting!\n\n");
! olsr_cnf->exit_value = EXIT_FAILURE;
kill(getpid(), SIGINT);
}
***************
*** 602,606 ****
{
/* IP version 6 */
! memcpy(&ifp->ip_addr, &iface->hemu_ip, ipsize);
#if 0
--- 602,606 ----
{
/* IP version 6 */
! memcpy(&ifp->ip_addr, &iface->hemu_ip, olsr_cnf->ipsize);
#if 0
***************
*** 619,623 ****
fprintf(stderr, "Could not initialize socket... exiting!\n\n");
olsr_syslog(OLSR_LOG_ERR, "Could not initialize socket... exiting!\n\n");
! exit_value = EXIT_FAILURE;
kill(getpid(), SIGINT);
}
--- 619,623 ----
fprintf(stderr, "Could not initialize socket... exiting!\n\n");
olsr_syslog(OLSR_LOG_ERR, "Could not initialize socket... exiting!\n\n");
! olsr_cnf->exit_value = EXIT_FAILURE;
kill(getpid(), SIGINT);
}
***************
*** 627,631 ****
/* Send IP as first 4/16 bytes on socket */
! memcpy(addr, iface->hemu_ip.v6.s6_addr, ipsize);
addr[0] = htonl(addr[0]);
addr[1] = htonl(addr[1]);
--- 627,631 ----
/* Send IP as first 4/16 bytes on socket */
! memcpy(addr, iface->hemu_ip.v6.s6_addr, olsr_cnf->ipsize);
addr[0] = htonl(addr[0]);
addr[1] = htonl(addr[1]);
***************
*** 633,637 ****
addr[3] = htonl(addr[3]);
! if(send(ifp->olsr_socket, addr , ipsize, 0) != (int)ipsize)
{
fprintf(stderr, "Error sending IP!");
--- 633,637 ----
addr[3] = htonl(addr[3]);
! if(send(ifp->olsr_socket, addr , olsr_cnf->ipsize, 0) != (int)olsr_cnf->ipsize)
{
fprintf(stderr, "Error sending IP!");
***************
*** 683,692 ****
/* Recalculate max jitter */
! if((max_jitter == 0) || ((iface->cnf->hello_params.emission_interval / 4) < max_jitter))
! max_jitter = iface->cnf->hello_params.emission_interval / 4;
/* Recalculate max topology hold time */
! if(max_tc_vtime < iface->cnf->tc_params.emission_interval)
! max_tc_vtime = iface->cnf->tc_params.emission_interval;
ifp->hello_etime = iface->cnf->hello_params.emission_interval;
--- 683,693 ----
/* Recalculate max jitter */
! if((olsr_cnf->max_jitter == 0) ||
! ((iface->cnf->hello_params.emission_interval / 4) < olsr_cnf->max_jitter))
! olsr_cnf->max_jitter = iface->cnf->hello_params.emission_interval / 4;
/* Recalculate max topology hold time */
! if(olsr_cnf->max_tc_vtime < iface->cnf->tc_params.emission_interval)
! olsr_cnf->max_tc_vtime = iface->cnf->tc_params.emission_interval;
ifp->hello_etime = iface->cnf->hello_params.emission_interval;
***************
*** 727,731 ****
/* Get flags (and check if interface exists) */
! if (ioctl(ioctl_s, SIOCGIFFLAGS, &ifr) < 0)
{
OLSR_PRINTF(debuglvl, "\tNo such interface!\n")
--- 728,732 ----
/* Get flags (and check if interface exists) */
! if (ioctl(olsr_cnf->ioctl_s, SIOCGIFFLAGS, &ifr) < 0)
{
OLSR_PRINTF(debuglvl, "\tNo such interface!\n")
***************
*** 793,797 ****
ifs.int6_multaddr.sin6_family = AF_INET6;
/* Set port */
! ifs.int6_multaddr.sin6_port = olsr_udp_port;
OLSR_PRINTF(debuglvl, "\tMulticast: %s\n", ip6_to_string(&ifs.int6_multaddr.sin6_addr))
--- 794,798 ----
ifs.int6_multaddr.sin6_family = AF_INET6;
/* Set port */
! ifs.int6_multaddr.sin6_port = htons(OLSRPORT);
OLSR_PRINTF(debuglvl, "\tMulticast: %s\n", ip6_to_string(&ifs.int6_multaddr.sin6_addr))
***************
*** 802,806 ****
{
/* Get interface address (IPv4)*/
! if(ioctl(ioctl_s, SIOCGIFADDR, &ifr) < 0)
{
OLSR_PRINTF(debuglvl, "\tCould not get address of interface - skipping it\n")
--- 803,807 ----
{
/* Get interface address (IPv4)*/
! if(ioctl(olsr_cnf->ioctl_s, SIOCGIFADDR, &ifr) < 0)
{
OLSR_PRINTF(debuglvl, "\tCould not get address of interface - skipping it\n")
***************
*** 812,816 ****
/* Find netmask */
! if (ioctl(ioctl_s, SIOCGIFNETMASK, &ifr) < 0)
{
olsr_syslog(OLSR_LOG_ERR, "%s: ioctl (get netmask)", ifr.ifr_name);
--- 813,817 ----
/* Find netmask */
! if (ioctl(olsr_cnf->ioctl_s, SIOCGIFNETMASK, &ifr) < 0)
{
olsr_syslog(OLSR_LOG_ERR, "%s: ioctl (get netmask)", ifr.ifr_name);
***************
*** 832,836 ****
{
/* Autodetect */
! if (ioctl(ioctl_s, SIOCGIFBRDADDR, &ifr) < 0)
{
olsr_syslog(OLSR_LOG_ERR, "%s: ioctl (get broadaddr)", ifr.ifr_name);
--- 833,837 ----
{
/* Autodetect */
! if (ioctl(olsr_cnf->ioctl_s, SIOCGIFBRDADDR, &ifr) < 0)
{
olsr_syslog(OLSR_LOG_ERR, "%s: ioctl (get broadaddr)", ifr.ifr_name);
***************
*** 867,871 ****
/* Get MTU */
! if (ioctl(ioctl_s, SIOCGIFMTU, &ifr) < 0)
ifs.int_mtu = OLSR_DEFAULT_MTU;
else
--- 868,872 ----
/* Get MTU */
! if (ioctl(olsr_cnf->ioctl_s, SIOCGIFMTU, &ifr) < 0)
ifs.int_mtu = OLSR_DEFAULT_MTU;
else
***************
*** 925,929 ****
fprintf(stderr, "Could not initialize socket... exiting!\n\n");
olsr_syslog(OLSR_LOG_ERR, "Could not initialize socket... exiting!\n\n");
! exit_value = EXIT_FAILURE;
kill(getpid(), SIGINT);
}
--- 926,930 ----
fprintf(stderr, "Could not initialize socket... exiting!\n\n");
olsr_syslog(OLSR_LOG_ERR, "Could not initialize socket... exiting!\n\n");
! olsr_cnf->exit_value = EXIT_FAILURE;
kill(getpid(), SIGINT);
}
***************
*** 936,940 ****
fprintf(stderr, "Could not initialize libnet... exiting!\n\n");
olsr_syslog(OLSR_LOG_ERR, "Could not initialize libnet... exiting!\n\n");
! exit_value = EXIT_FAILURE;
kill(getpid(), SIGINT);
}
--- 937,941 ----
fprintf(stderr, "Could not initialize libnet... exiting!\n\n");
olsr_syslog(OLSR_LOG_ERR, "Could not initialize libnet... exiting!\n\n");
! olsr_cnf->exit_value = EXIT_FAILURE;
kill(getpid(), SIGINT);
}
***************
*** 946,950 ****
{
/* IP version 6 */
! memcpy(&ifp->ip_addr, &ifp->int6_addr.sin6_addr, ipsize);
--- 947,951 ----
{
/* IP version 6 */
! memcpy(&ifp->ip_addr, &ifp->int6_addr.sin6_addr, olsr_cnf->ipsize);
***************
*** 963,967 ****
fprintf(stderr, "Could not initialize socket... exiting!\n\n");
olsr_syslog(OLSR_LOG_ERR, "Could not initialize socket... exiting!\n\n");
! exit_value = EXIT_FAILURE;
kill(getpid(), SIGINT);
}
--- 964,968 ----
fprintf(stderr, "Could not initialize socket... exiting!\n\n");
olsr_syslog(OLSR_LOG_ERR, "Could not initialize socket... exiting!\n\n");
! olsr_cnf->exit_value = EXIT_FAILURE;
kill(getpid(), SIGINT);
}
***************
*** 995,1004 ****
* Set main address if this is the only interface
*/
! memset(&null_addr, 0, ipsize);
! if(COMP_IP(&null_addr, &main_addr))
{
! COPY_IP(&main_addr, &ifp->ip_addr);
! OLSR_PRINTF(1, "New main address: %s\n", olsr_ip_to_string(&main_addr))
! olsr_syslog(OLSR_LOG_INFO, "New main address: %s\n", olsr_ip_to_string(&main_addr));
}
--- 996,1005 ----
* Set main address if this is the only interface
*/
! memset(&null_addr, 0, olsr_cnf->ipsize);
! if(COMP_IP(&null_addr, &olsr_cnf->main_addr))
{
! COPY_IP(&olsr_cnf->main_addr, &ifp->ip_addr);
! OLSR_PRINTF(1, "New main address: %s\n", olsr_ip_to_string(&olsr_cnf->main_addr))
! olsr_syslog(OLSR_LOG_INFO, "New main address: %s\n", olsr_ip_to_string(&olsr_cnf->main_addr));
}
***************
*** 1048,1057 ****
/* Recalculate max jitter */
! if((max_jitter == 0) || ((iface->cnf->hello_params.emission_interval / 4) < max_jitter))
! max_jitter = iface->cnf->hello_params.emission_interval / 4;
/* Recalculate max topology hold time */
! if(max_tc_vtime < iface->cnf->tc_params.emission_interval)
! max_tc_vtime = iface->cnf->tc_params.emission_interval;
ifp->hello_etime = iface->cnf->hello_params.emission_interval;
--- 1049,1059 ----
/* Recalculate max jitter */
! if((olsr_cnf->max_jitter == 0) ||
! ((iface->cnf->hello_params.emission_interval / 4) < olsr_cnf->max_jitter))
! olsr_cnf->max_jitter = iface->cnf->hello_params.emission_interval / 4;
/* Recalculate max topology hold time */
! if(olsr_cnf->max_tc_vtime < iface->cnf->tc_params.emission_interval)
! olsr_cnf->max_tc_vtime = iface->cnf->tc_params.emission_interval;
ifp->hello_etime = iface->cnf->hello_params.emission_interval;
More information about the Olsr-cvs
mailing list