Sync with latest KAME code.

Obtained from:	KAME
This commit is contained in:
Kris Kennaway 2000-07-06 01:48:08 +00:00
parent 375477fbf6
commit 5bca844f39
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=62663
58 changed files with 1549 additions and 2385 deletions

View File

@ -1,7 +1,7 @@
$Id: BUGS.TODO,v 1.1.1.1 1999/08/08 23:30:57 itojun Exp $
$FreeBSD$
THIS LIST IS FAR AWAY FROM BEING COMPLETE, so these are the few things
THIS LIST IS FAR AWAY FROM BEING COMPLETE, so these are the few things
that came up at the right moment to be written down.
* Experimental kernel MFC (*,G) related:
@ -24,12 +24,12 @@ that came up at the right moment to be written down.
* Use NetBSD's definition for IPADDR (netinet/in.h):
#ifdef _KERNEL
#define __IPADDR(x) ((u_int32_t) htonl((u_int32_t)(x)))
#define __IPADDR(x) ((u_int32_t) htonl((u_int32_t)(x)))
#else
#define __IPADDR(x) ((u_int32_t)(x))
#define __IPADDR(x) ((u_int32_t)(x))
#endif
* The (S,G)RPbit in the DR for the sender and the (S,G)SPT in the
downstream router won't timeout and will refresh each other even
if the sender is not active:
@ -57,12 +57,12 @@ that came up at the right moment to be written down.
same host as the RP for the multicast group (probably was fixed with alpha6,
because I cannot reproduce it anymore)
* Do more precise error check for the received PIM messages. In most cases,
* Do more precise error check for the received PIM messages. In most cases,
the whole message must be parsed completely before starting processing it.
* Clean up the debugging messages.
* Use Patricia tree to search the routing table
* Use Patricia tree to search the routing table
(There is a nice paper in Sigcomm '97 about fast routing tables
implementation, so need to check it as well)
@ -86,7 +86,7 @@ that came up at the right moment to be written down.
* Send Initial_Reply RSRR message if the interfaces detected by pimd change
* SNMP support
* SNMP support
===TODO by function name===
igmp_proto.c:

View File

@ -1,4 +1,4 @@
$FreeBSD$
$FreeBSD$
Write your bugs reports here

View File

@ -1,4 +1,4 @@
$FreeBSD$
$FreeBSD$
The mrouted program is covered by the following license. Use of the
mrouted program represents acceptance of these terms and conditions.

View File

@ -29,4 +29,3 @@
* $FreeBSD$
*/

View File

@ -28,7 +28,7 @@
*/
/*
* Questions concerning this software should be directed to
* Mickael Hoerdt (hoerdt@clarinet.u-strasbg.fr) LSIIT Strasbourg.
* Mickael Hoerdt (hoerdt@clarinet.u-strasbg.fr) LSIIT Strasbourg.
*
* $FreeBSD$
*/

View File

@ -19,7 +19,7 @@
* ABOUT THE SUITABILITY OF THIS SOFTWARE FOR ANY PURPOSE. THIS SOFTWARE IS
* PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, TITLE, AND
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, TITLE, AND
* NON-INFRINGEMENT.
*
* IN NO EVENT SHALL USC, OR ANY OTHER CONTRIBUTOR BE LIABLE FOR ANY
@ -31,7 +31,7 @@
* noted when applicable.
*/
/*
* Questions concerning this software should be directed to
* Questions concerning this software should be directed to
* Pavlin Ivanov Radoslavov (pavlin@catarina.usc.edu)
*
* $Id: LICENSE.pimd,v 1.1.1.1 1999/08/08 23:30:57 itojun Exp $

View File

@ -11,7 +11,7 @@
# 3. Neither the name of the project 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 PROJECT 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
@ -23,6 +23,56 @@
# 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.
# Copyright (c) 1998 by the University of Oregon.
# All rights reserved.
#
# Permission to use, copy, modify, and distribute this software and
# its documentation in source and binary forms for lawful
# purposes and without fee is hereby granted, provided
# that the above copyright notice appear in all copies and that both
# the copyright notice and this permission notice appear in supporting
# documentation, and that any documentation, advertising materials,
# and other materials related to such distribution and use acknowledge
# that the software was developed by the University of Oregon.
# The name of the University of Oregon may not be used to endorse or
# promote products derived from this software without specific prior
# written permission.
#
# THE UNIVERSITY OF OREGON DOES NOT MAKE ANY REPRESENTATIONS
# ABOUT THE SUITABILITY OF THIS SOFTWARE FOR ANY PURPOSE. THIS SOFTWARE IS
# PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
# INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, TITLE, AND
# NON-INFRINGEMENT.
#
# IN NO EVENT SHALL UO, OR ANY OTHER CONTRIBUTOR BE LIABLE FOR ANY
# SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES, WHETHER IN CONTRACT,
# TORT, OR OTHER FORM OF ACTION, ARISING OUT OF OR IN CONNECTION WITH,
# THE USE OR PERFORMANCE OF THIS SOFTWARE.
#
# Other copyrights might apply to parts of this software and are so
# noted when applicable.
#
#
# Questions concerning this software should be directed to
# Kurt Windisch (kurtw@antc.uoregon.edu)
#
# $Id: Makefile,v 1.8 2000/02/25 06:32:22 itojun Exp $
#
#
#Part of this program has been derived from PIM sparse-mode pimd.
#The pimd program is covered by the license in the accompanying file
#named "LICENSE.pimd".
#
#The pimd program is COPYRIGHT 1998 by University of Southern California.
#
#Part of this program has been derived from mrouted.
#The mrouted program is covered by the license in the accompanying file
#named "LICENSE.mrouted".
#
#The mrouted program is COPYRIGHT 1989 by The Board of Trustees of
#Leland Stanford Junior University.
# $FreeBSD$
PROG= pim6sd
@ -33,8 +83,8 @@ SRCS= mld6.c mld6_proto.c\
SRCS+= y.tab.h
y.tab.h: cfparse.y
CLEANFILES+= lex.yy.c y.tab.h y.tab.c
CFLAGS+= -g
CFLAGS+=-DINET6 -DPIM -DIOCTL_OK_ON_RAW_SOCKET -I${.OBJDIR}
CFLAGS+=-Wall
CFLAGS+=-DINET6 -DPIM -DIOCTL_OK_ON_RAW_SOCKET -DHAVE_GETIFADDRS
CFLAGS+=-DHAVE_STDARG_H
DPADD= ${LIBY} ${LIBL}
LDADD= -ly -ll

View File

@ -1,4 +1,4 @@
$FreeBSD$
$FreeBSD$
WARNING WARNING WARNING:

View File

@ -33,6 +33,7 @@
#include <stdlib.h>
#include "debug.h"
#include "defs.h"
#include "callout.h"
/* the code below implements a callout queue */

View File

@ -32,13 +32,13 @@
*
*/
/*
* This program has been derived from pim6dd.
* This program has been derived from pim6dd.
* The pim6dd program is covered by the license in the accompanying file
* named "LICENSE.pim6dd".
*
*/
/*
* This program has been derived from pimd.
* This program has been derived from pimd.
* The pimd program is covered by the license in the accompanying file
* named "LICENSE.pimd".
*
@ -47,7 +47,7 @@
#ifndef CALLOUT_H
#define CALLOUT_H
#define CALLOUT_H
#include "defs.h"

View File

@ -1,7 +1,7 @@
/*
* Copyright (C) 1999 WIDE Project.
* All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@ -13,7 +13,7 @@
* 3. Neither the name of the project 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 PROJECT 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

View File

@ -1,7 +1,7 @@
/*
* Copyright (C) 1999 WIDE Project.
* All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@ -13,7 +13,7 @@
* 3. Neither the name of the project 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 PROJECT 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
@ -50,7 +50,7 @@
#include "timer.h"
#include "inet6.h"
#define set_param(var,val,p) \
#define set_param(var,val,p) \
do {\
if ((var) != -1) {\
yywarn("%s doubly defined(ignore %d)", (p), (val));\
@ -76,7 +76,8 @@ struct attr_list {
};
enum {IFA_FLAG, IFA_PREFERENCE, IFA_METRIC, RPA_PRIORITY, RPA_TIME,
BSRA_PRIORITY, BSRA_TIME, IN6_PREFIX, THRESA_RATE, THRESA_INTERVAL};
BSRA_PRIORITY, BSRA_TIME, BSRA_MASKLEN, IN6_PREFIX, THRESA_RATE,
THRESA_INTERVAL};
static int strict; /* flag if the grammer check is strict */
static struct attr_list *rp_attr, *bsr_attr, *grp_prefix, *regthres_attr,
@ -87,6 +88,8 @@ static int srcmetric, srcpref, helloperiod, jpperiod, granularity,
static double helloperiod_coef, jpperiod_coef;
static int debugonly;
extern int yylex __P((void));
%}
%union {
@ -102,7 +105,7 @@ static int debugonly;
%token REVERSELOOKUP
%token PHYINT IFNAME DISABLE PREFERENCE METRIC NOLISTENER
%token GRPPFX
%token CANDRP CANDBSR TIME PRIORITY
%token CANDRP CANDBSR TIME PRIORITY MASKLEN
%token NUMBER STRING SLASH
%token REGTHRES DATATHRES RATE INTERVAL
%token SRCMETRIC SRCPREF HELLOPERIOD GRANULARITY JPPERIOD
@ -295,6 +298,18 @@ bsr_attributes:
== NULL)
return(-1);
}
| bsr_attributes MASKLEN NUMBER
{
int masklen = $3;
if (masklen < 0 || masklen > 128)
yywarn("invalid mask length: %d (ignored)",
masklen);
else if (($$ = add_attribute_num($1, BSRA_MASKLEN,
masklen))
== NULL)
return(-1);
}
;
/* group_prefix <group-addr>/<prefix_len> */
@ -315,6 +330,13 @@ grppfx_statement:
prefix.plen);
prefixok = 0;
}
if (IN6_IS_ADDR_MC_NODELOCAL(&prefix.paddr) ||
IN6_IS_ADDR_MC_LINKLOCAL(&prefix.paddr)) {
yywarn("group prefix (%s/%d) has a narrow scope "
"(ignored)",
inet6_fmt(&prefix.paddr), prefix.plen);
prefixok = 0;
}
if (prefixok) {
struct attr_list *new;
@ -328,7 +350,7 @@ grppfx_statement:
new->type = IN6_PREFIX;
new->attru.prefix = prefix;
new->next = grp_prefix;
grp_prefix = new;
}
}
@ -369,7 +391,7 @@ thres_attributes:
return(-1);
}
/*
/*
* switch_data_threshold [rate <number> interval <number>]
* Operation: reads and assigns the switch to the spt threshold due to
* data packets, if used as DR.
@ -418,6 +440,10 @@ param_statement:
{
set_param(granularity, $2, "granularity");
}
| DATATIME NUMBER EOS
{
set_param(datatimo, $2, "data_timeout");
}
| REGSUPTIME NUMBER EOS
{
set_param(regsuptimo, $2, "register_suppression_timeout");
@ -433,6 +459,19 @@ param_statement:
;
%%
static struct attr_list *add_attribute_flag __P((struct attr_list *, int,
unsigned int));
static struct attr_list *add_attribute_num __P((struct attr_list *, int,
double));
static void free_attr_list __P((struct attr_list *));
static int param_config __P((void));
static int phyint_config __P((void));
static int rp_config __P((void));
static int bsr_config __P((void));
static int grp_prefix_config __P((void));
static int regthres_config __P((void));
static int datathres_config __P((void));
static struct attr_list *
add_attribute_flag(list, type, flag)
struct attr_list *list;
@ -440,7 +479,7 @@ add_attribute_flag(list, type, flag)
unsigned int flag;
{
struct attr_list *p;
if ((p = malloc(sizeof(*p))) == NULL) {
yyerror("malloc failed");
return(NULL);
@ -461,7 +500,7 @@ add_attribute_num(list, type, num)
double num;
{
struct attr_list *p;
if ((p = malloc(sizeof(*p))) == NULL) {
yyerror("malloc failed");
return(NULL);
@ -486,7 +525,7 @@ free_attr_list(list)
}
}
int
static int
param_config()
{
struct uvif *v;
@ -533,17 +572,35 @@ param_config()
log(LOG_DEBUG, 0, "pim_join_prune_holdtime set to: %u",
pim_join_prune_holdtime);
}
IF_DEBUG(DEBUG_TIMER) {
log(LOG_DEBUG,0 , "timer interval set to: %u", timer_interval);
}
IF_DEBUG(DEBUG_PIM_TIMER) {
log(LOG_DEBUG,0 , "PIM data timeout set to: %u",
pim_data_timeout);
}
IF_DEBUG(DEBUG_PIM_REGISTER) {
log(LOG_DEBUG, 0,
"PIM register suppression timeout set to: %u",
pim_register_suppression_timeout);
log(LOG_DEBUG, 0, "PIM register probe time set to: %u",
pim_register_probe_time);
}
IF_DEBUG(DEBUG_PIM_ASSERT) {
log(LOG_DEBUG, 0,
"PIM assert timeout set to: %u",
pim_assert_timeout);
}
return(0);
}
int
static int
phyint_config()
{
struct uvif *v;
vifi_t vifi;
struct attr_list *al;
for (vifi = 0, v = uvifs; vifi < numvifs ; ++vifi , ++v) {
for (al = (struct attr_list *)v->config_attr; al; al = al->next) {
switch(al->type) {
@ -587,7 +644,7 @@ phyint_config()
return(0);
}
int
static int
rp_config()
{
struct sockaddr_in6 *sa6_rp = NULL;
@ -686,15 +743,17 @@ rp_config()
return(0);
}
int
static int
bsr_config()
{
struct sockaddr_in6 *sa6_bsr = NULL;
struct attr_list *al;
int my_bsr_hash_masklen;
/* initialization by default values */
my_bsr_period = PIM_DEFAULT_BOOTSTRAP_PERIOD;
my_bsr_priority = PIM_DEFAULT_BSR_PRIORITY;
my_bsr_hash_masklen = RP_DEFAULT_IPV6_HASHMASKLEN;
if (cand_bsr_ifname) {
sa6_bsr = local_iface(cand_bsr_ifname);
@ -711,6 +770,10 @@ bsr_config()
if (al->attru.number >= 0)
my_bsr_priority = al->attru.number;
break;
case BSRA_MASKLEN:
/* validation has been done. */
my_bsr_hash_masklen = al->attru.number;
break;
case BSRA_TIME:
if (al->attru.number < 10)
my_bsr_period = 10;
@ -729,22 +792,22 @@ bsr_config()
if (!sa6_bsr)
sa6_bsr = max_global_address(); /* this MUST suceed */
my_bsr_address = *sa6_bsr;
MASKLEN_TO_MASK6(my_bsr_hash_masklen, my_bsr_hash_mask);
IF_DEBUG(DEBUG_PIM_BOOTSTRAP) {
log(LOG_DEBUG, 0,
"Local BSR address: %s",
log(LOG_DEBUG, 0, "Local BSR address: %s",
inet6_fmt(&my_bsr_address.sin6_addr));
log(LOG_DEBUG, 0,
"Local BSR priority : %u",my_bsr_priority);
log(LOG_DEBUG,0,
"Local BSR period is : %u sec.",
log(LOG_DEBUG, 0, "Local BSR priority : %u", my_bsr_priority);
log(LOG_DEBUG, 0, "Local BSR period is : %u sec.",
my_bsr_period);
log(LOG_DEBUG, 0, "Local BSR hash mask length: %d",
my_bsr_hash_masklen);
}
return(0);
}
int
static int
grp_prefix_config()
{
struct attr_list *pl;
@ -786,7 +849,7 @@ grp_prefix_config()
return(0);
}
int
static int
regthres_config()
{
struct attr_list *al;
@ -836,7 +899,7 @@ regthres_config()
return(0);
}
int
static int
datathres_config()
{
struct attr_list *al;

View File

@ -2,7 +2,7 @@
/*
* Copyright (C) 1999 WIDE Project.
* All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@ -14,7 +14,7 @@
* 3. Neither the name of the project 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 PROJECT 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
@ -52,7 +52,11 @@ int yy_first_time = 1;
extern char configfilename[];
#if 0
static void cfdebug_print __P((char *, char *, int));
#endif
extern int yylex __P((void));
%}
/* common seciton */
@ -536,6 +540,7 @@ slash \/
/* cand_bootstrap_router */
<S_CNF>cand_bootstrap_router { DP("begin cand_bsr"); BEGIN S_CANDBSR; return(CANDBSR); }
<S_CANDBSR>priority { YYD_ECHO; return(PRIORITY); }
<S_CANDBSR>masklen { YYD_ECHO; return(MASKLEN); }
<S_CANDBSR>time { YYD_ECHO; return(TIME); }
<S_CANDBSR>{ifname} {
YYD_ECHO;
@ -588,6 +593,7 @@ slash \/
}
%%
#if 0
static void
cfdebug_print(w, t, l)
char *w, *t;
@ -595,6 +601,7 @@ cfdebug_print(w, t, l)
{
printf("<%d>%s [%s] (%d)\n", yy_start, w, t, l);
}
#endif
static void
yyerror0(char *s, va_list ap)
@ -636,7 +643,7 @@ cfparse(strict, debugonly)
int strict, debugonly;
{
if ((yyin = fopen(configfilename, "r")) == NULL) {
fprintf(stderr, "cfparse: fopen(%s)", configfilename);
fprintf(stderr, "cfparse: fopen(%s)\n", configfilename);
return(-1);
}

File diff suppressed because it is too large Load Diff

View File

@ -32,12 +32,12 @@
*
*/
/*
* This program has been derived from pim6dd.
* This program has been derived from pim6dd.
* The pim6dd program is covered by the license in the accompanying file
* named "LICENSE.pim6dd".
*/
/*
* This program has been derived from pimd.
* This program has been derived from pimd.
* The pimd program is covered by the license in the accompanying file
* named "LICENSE.pimd".
*
@ -45,29 +45,29 @@
*/
#ifndef CONFIG_H
#define CONFIG_H
#define CONFIG_H
#define UNKNOWN -1
#define EMPTY 1
#define PHYINT 2
#define CANDIDATE_RP 3
#define GROUP_PREFIX 4
#define BOOTSTRAP_RP 5
#define REG_THRESHOLD 6
#define DATA_THRESHOLD 7
#define DEFAULT_SOURCE_METRIC 8
#define DEFAULT_SOURCE_PREFERENCE 9
#define HELLO_PERIOD 10
#define GRANULARITY 11
#define JOIN_PRUNE_PERIOD 12
#define DATA_TIMEOUT 13
#define REGISTER_SUPPRESSION_TIMEOUT 14
#define PROBE_TIME 15
#define ASSERT_TIMEOUT 16
#define UNKNOWN -1
#define EMPTY 1
#define PHYINT 2
#define CANDIDATE_RP 3
#define GROUP_PREFIX 4
#define BOOTSTRAP_RP 5
#define REG_THRESHOLD 6
#define DATA_THRESHOLD 7
#define DEFAULT_SOURCE_METRIC 8
#define DEFAULT_SOURCE_PREFERENCE 9
#define HELLO_PERIOD 10
#define GRANULARITY 11
#define JOIN_PRUNE_PERIOD 12
#define DATA_TIMEOUT 13
#define REGISTER_SUPPRESSION_TIMEOUT 14
#define PROBE_TIME 15
#define ASSERT_TIMEOUT 16
#define EQUAL(s1, s2) (strcmp((s1), (s2)) == 0)
#define EQUAL(s1, s2) (strcmp((s1), (s2)) == 0)
void config_vifs_from_kernel();
void config_vifs_from_file();
void config_vifs_from_kernel __P((void));
void config_vifs_from_file __P((void));
#endif

View File

@ -40,58 +40,64 @@
*/
/* CRC implantation : stolen from RFC 2083 section 15.*/
#include <sys/cdefs.h>
#include "crc.h"
/* Table of CRCs of all 8-bit messages. */
unsigned long crc_table[256];
/* Flag: has the table been computed? Initially false. */
int crc_table_computed = 0;
/* Make the table for a fast CRC. */
/* Make the table for a fast CRC. */
static void make_crc_table __P((void));
static unsigned long update_crc __P((unsigned long, unsigned char *, int));
void make_crc_table(void)
static void make_crc_table(void)
{
unsigned long c;
unsigned long c;
int n, k;
for (n = 0; n < 256; n++)
for (n = 0; n < 256; n++)
{
c = (unsigned long) n;
for (k = 0; k < 8; k++)
for (k = 0; k < 8; k++)
{
if (c & 1)
if (c & 1)
c = 0xedb88320L ^ (c >> 1);
else
c = c >> 1;
}
else
c = c >> 1;
}
crc_table[n] = c;
}
}
crc_table_computed = 1;
}
}
/* Update a running CRC with the bytes buf[0..len-1]--the CRC
should be initialized to all 1's, and the transmitted value
is the 1's complement of the final running CRC (see the
crc() routine below)). */
unsigned long update_crc(unsigned long crc, unsigned char *buf,
static unsigned long update_crc(unsigned long crc, unsigned char *buf,
int len)
{
{
unsigned long c = crc;
int n;
int n;
if (!crc_table_computed)
make_crc_table();
for (n = 0; n < len; n++)
for (n = 0; n < len; n++)
{
c = crc_table[(c ^ buf[n]) & 0xff] ^ (c >> 8);
}
}
return c;
}
}
/* Return the CRC of the bytes buf[0..len-1]. */
unsigned long crc(unsigned char *buf, int len)
{
{
return update_crc(0xffffffffL, buf, len) ^ 0xffffffffL;
}
}

View File

@ -25,8 +25,6 @@
* 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.
*
* $FreeBSD$
*/
/*
* Questions concerning this software should be directed to
@ -38,11 +36,12 @@
* The pimd program is covered by the license in the accompanying file
* named "LICENSE.pimd".
*
* $FreeBSD$
*/
#ifndef CRC_H
#define CRC_H
extern long crc __P((unsigned char *buf, int len));
extern unsigned long crc __P((unsigned char *buf, int len));
#endif

View File

@ -29,8 +29,6 @@
*
* Other copyrights might apply to parts of this software and are so
* noted when applicable.
*
* $FreeBSD$
*/
/*
* Questions concerning this software should be directed to
@ -56,6 +54,7 @@
* The mrouted program is COPYRIGHT 1989 by The Board of Trustees of
* Leland Stanford Junior University.
*
* $FreeBSD$
*/
#include <stdio.h>
@ -94,6 +93,39 @@ static char dumpfilename[] = _PATH_PIM6D_DUMP;
static char cachefilename[] = _PATH_PIM6D_CACHE; /* TODO: notused */
static char statfilename[] = _PATH_PIM6D_STAT;
static char *sec2str __P((time_t));
static char *
sec2str(total)
time_t total;
{
static char result[256];
int days, hours, mins, secs;
int first = 1;
char *p = result;
days = total / 3600 / 24;
hours = (total / 3600) % 24;
mins = (total / 60) % 60;
secs = total % 60;
if (days) {
first = 0;
p += sprintf(p, "%dd", days);
}
if (!first || hours) {
first = 0;
p += sprintf(p, "%dh", hours);
}
if (!first || mins) {
first = 0;
p += sprintf(p, "%dm", mins);
}
sprintf(p, "%ds", secs);
return(result);
}
char *
packet_kind(proto, type, code)
u_int proto,
@ -264,6 +296,7 @@ fdump(i)
{
dump_vifs(fp);
dump_nbrs(fp);
dump_mldqueriers(fp);
dump_pim_mrt(fp);
dump_rp_set(fp);
(void) fclose(fp);
@ -311,72 +344,95 @@ dump_stat()
continue;
#endif
fprintf(fp, " Mif=%d, PhyIF=%s\n", vifi, v->uv_name);
fprintf(fp, "\t%qu pim6 hello received\n", v->uv_in_pim6_hello);
fprintf(fp, "\t%qu pim6 hello received\n",
(unsigned long long)v->uv_in_pim6_hello);
fprintf(fp, "\t%qu pim6 join-prune received\n",
v->uv_in_pim6_join_prune);
(unsigned long long)v->uv_in_pim6_join_prune);
fprintf(fp, "\t%qu pim6 bootstrap received\n",
v->uv_in_pim6_bootsrap);
fprintf(fp, "\t%qu pim6 assert received\n", v->uv_in_pim6_assert);
(unsigned long long)v->uv_in_pim6_bootsrap);
fprintf(fp, "\t%qu pim6 assert received\n",
(unsigned long long)v->uv_in_pim6_assert);
fprintf(fp, "\t%qu pim6 hello sent\n", v->uv_out_pim6_hello);
fprintf(fp, "\t%qu pim6 hello sent\n",
(unsigned long long)v->uv_out_pim6_hello);
fprintf(fp, "\t%qu pim6 join-prune sent\n",
v->uv_out_pim6_join_prune);
(unsigned long long)v->uv_out_pim6_join_prune);
fprintf(fp, "\t%qu pim6 bootstrap sent\n",
v->uv_out_pim6_bootsrap);
fprintf(fp, "\t%qu pim6 assert sent\n", v->uv_out_pim6_assert);
(unsigned long long)v->uv_out_pim6_bootsrap);
fprintf(fp, "\t%qu pim6 assert sent\n",
(unsigned long long)v->uv_out_pim6_assert);
fprintf(fp, "\t%qu MLD query received\n", v->uv_in_mld_query);
fprintf(fp, "\t%qu MLD report received\n", v->uv_in_mld_report);
fprintf(fp, "\t%qu MLD done received\n", v->uv_in_mld_done);
fprintf(fp, "\t%qu MLD query received\n",
(unsigned long long)v->uv_in_mld_query);
fprintf(fp, "\t%qu MLD report received\n",
(unsigned long long)v->uv_in_mld_report);
fprintf(fp, "\t%qu MLD done received\n",
(unsigned long long)v->uv_in_mld_done);
fprintf(fp, "\t%qu MLD query sent\n", v->uv_out_mld_query);
fprintf(fp, "\t%qu MLD report sent\n", v->uv_out_mld_report);
fprintf(fp, "\t%qu MLD done sent\n", v->uv_out_mld_done);
fprintf(fp, "\t%qu MLD query sent\n",
(unsigned long long)v->uv_out_mld_query);
fprintf(fp, "\t%qu MLD report sent\n",
(unsigned long long)v->uv_out_mld_report);
fprintf(fp, "\t%qu MLD done sent\n",
(unsigned long long)v->uv_out_mld_done);
fprintf(fp, "\t%qu forwarding cache miss\n", v->uv_cache_miss);
fprintf(fp, "\t%qu forwarding cache miss\n",
(unsigned long long)v->uv_cache_miss);
fprintf(fp, "\t%qu forwarding cache miss and not created\n",
v->uv_cache_notcreated);
(unsigned long long)v->uv_cache_notcreated);
fprintf(fp, "\t%qu PIM neighbor timeouts\n", v->uv_pim6_nbr_timo);
fprintf(fp, "\t%qu MLD listener timeouts\n", v->uv_listener_timo);
fprintf(fp, "\t%qu out-I/F timeouts\n", v->uv_outif_timo);
fprintf(fp, "\t%qu PIM neighbor timeouts\n",
(unsigned long long)v->uv_pim6_nbr_timo);
fprintf(fp, "\t%qu MLD listener timeouts\n",
(unsigned long long)v->uv_listener_timo);
fprintf(fp, "\t%qu MLD querier timeouts\n",
(unsigned long long)v->uv_querier_timo);
fprintf(fp, "\t%qu out-I/F timeouts\n",
(unsigned long long)v->uv_outif_timo);
}
fprintf(fp, "\npim6sd interface independent statistics\n");
fprintf(fp, "\t%qu pim6 register received\n", pim6dstat.in_pim6_register);
fprintf(fp, "\t%qu pim6 register received\n",
(unsigned long long)pim6dstat.in_pim6_register);
fprintf(fp, "\t%qu pim6 register-stop received\n",
pim6dstat.in_pim6_register_stop);
fprintf(fp, "\t%qu pim6 cand-RP received\n", pim6dstat.in_pim6_cand_rp);
fprintf(fp, "\t%qu pim6 graft received\n", pim6dstat.in_pim6_graft);
(unsigned long long)pim6dstat.in_pim6_register_stop);
fprintf(fp, "\t%qu pim6 cand-RP received\n",
(unsigned long long)pim6dstat.in_pim6_cand_rp);
fprintf(fp, "\t%qu pim6 graft received\n",
(unsigned long long)pim6dstat.in_pim6_graft);
fprintf(fp, "\t%qu pim6 graft ack received\n",
pim6dstat.in_pim6_graft_ack);
(unsigned long long)pim6dstat.in_pim6_graft_ack);
fprintf(fp, "\t%qu pim6 register sent\n", pim6dstat.out_pim6_register);
fprintf(fp, "\t%qu pim6 register sent\n",
(unsigned long long)pim6dstat.out_pim6_register);
fprintf(fp, "\t%qu pim6 register-stop sent\n",
pim6dstat.out_pim6_register_stop);
fprintf(fp, "\t%qu pim6 cand-RP sent\n", pim6dstat.out_pim6_cand_rp);
(unsigned long long)pim6dstat.out_pim6_register_stop);
fprintf(fp, "\t%qu pim6 cand-RP sent\n",
(unsigned long long)pim6dstat.out_pim6_cand_rp);
fprintf(fp, "\t%qu transitions of forwarder initiated SPT\n",
pim6dstat.pim6_trans_spt_forward);
(unsigned long long)pim6dstat.pim6_trans_spt_forward);
fprintf(fp, "\t%qu transitions of RP initiated SPT\n",
pim6dstat.pim6_trans_spt_rp);
(unsigned long long)pim6dstat.pim6_trans_spt_rp);
fprintf(fp, "\t%qu pim6 bootstrap timeouts\n",
pim6dstat.pim6_bootstrap_timo);
(unsigned long long)pim6dstat.pim6_bootstrap_timo);
fprintf(fp, "\t%qu pim6 RP group entry timeouts\n",
pim6dstat.pim6_rpgrp_timo);
(unsigned long long)pim6dstat.pim6_rpgrp_timo);
fprintf(fp, "\t%qu pim6 routing entry timeouts\n",
pim6dstat.pim6_rtentry_timo);
(unsigned long long)pim6dstat.pim6_rtentry_timo);
fprintf(fp, "\t%qu kernel cache additions\n", pim6dstat.kern_add_cache);
fprintf(fp, "\t%qu kernel cache additions\n",
(unsigned long long)pim6dstat.kern_add_cache);
fprintf(fp, "\t%qu kernel cache addition failures\n",
pim6dstat.kern_add_cache_fail);
fprintf(fp, "\t%qu kernel cache deletions\n", pim6dstat.kern_del_cache);
(unsigned long long)pim6dstat.kern_add_cache_fail);
fprintf(fp, "\t%qu kernel cache deletions\n",
(unsigned long long)pim6dstat.kern_del_cache);
fprintf(fp, "\t%qu kernel cache deletion failures\n",
pim6dstat.kern_del_cache_fail);
(unsigned long long)pim6dstat.kern_del_cache_fail);
fprintf(fp, "\t%qu failures of getting kernel cache\n",
pim6dstat.kern_sgcnt_fail);
(unsigned long long)pim6dstat.kern_sgcnt_fail);
fclose(fp);
}
@ -425,6 +481,8 @@ dump_vifs(fp)
fprintf(fp, " DR");
if (v->uv_flags & VIFF_PIM_NBR)
fprintf(fp, " PIM");
if (v->uv_flags & VIFF_QUERIER)
fprintf(fp, " QRY");
#if 0 /* impossible */
if (v->uv_flags & VIFF_DVMRP_NBR)
{
@ -432,7 +490,7 @@ dump_vifs(fp)
}
#endif
if (v->uv_flags & VIFF_NONBRS)
fprintf(fp, " %-12s", "NO-NBR");
fprintf(fp, " NO-NBR");
fprintf(fp, "\n");
}
@ -462,7 +520,7 @@ dump_nbrs(fp)
int first = 1;
fprintf(fp, " %-3u %6s", vifi,
(v->uv_flags & MIFF_REGISTER)?"regist":
(v->uv_flags & MIFF_REGISTER) ? "regist":
v->uv_name);
for (; n != NULL; n = n->next) {
if (first)
@ -479,6 +537,35 @@ dump_nbrs(fp)
fprintf(fp, "\n");
}
void
dump_mldqueriers(fp)
FILE *fp;
{
struct uvif *v;
vifi_t vifi;
time_t now;
fprintf(fp, "MLD Querier List\n");
fprintf(fp, " %-3s %6s %-40s %-5s %15s\n",
"Mif", "PhyIF", "Address", "Timer", "Last");
(void)time(&now);
for (vifi = 0, v = uvifs; vifi < numvifs; ++vifi, ++v) {
if (v->uv_querier) {
fprintf(fp, " %-3u %6s", vifi,
(v->uv_flags & MIFF_REGISTER) ? "regist":
v->uv_name);
fprintf(fp, " %-40s %5lu %15s\n",
sa6_fmt(&v->uv_querier->al_addr),
(u_long)v->uv_querier->al_timer,
sec2str(now - v->uv_querier->al_ctime));
}
}
fprintf(fp, "\n");
}
/*
* Log errors and other messages to the system log daemon and to stderr,
* according to the severity of the message and the current debug level. For
@ -532,7 +619,8 @@ va_dcl
if (!debug)
fprintf(fp, "%s: ", progname);
fprintf(fp, "%02d:%02d:%02d.%03ld %s", thyme->tm_hour,
thyme->tm_min, thyme->tm_sec, now.tv_usec / 1000, msg);
thyme->tm_min, thyme->tm_sec, (long int)now.tv_usec / 1000,
msg);
if (syserr == 0)
fprintf(fp, "\n");
else
@ -663,7 +751,7 @@ dump_pim_mrt(fp)
fprintf(fp, "Asserted oifs: %-20s\n", asserted_oifs);
fprintf(fp, "Outgoing oifs: %-20s\n", oifs);
fprintf(fp, "Incoming : %-20s\n", incoming_iif);
fprintf(fp, "Upstream nbr: %s\n",
r->upstream ? inet6_fmt(&r->upstream->address.sin6_addr) : "NONE");

View File

@ -25,8 +25,6 @@
* 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.
*
* $FreeBSD$
*/
/*
* Questions concerning this software should be directed to
@ -34,104 +32,105 @@
*
*/
/*
* This program has been derived from pim6dd.
* This program has been derived from pim6dd.
* The pim6dd program is covered by the license in the accompanying file
* named "LICENSE.pim6dd".
*/
/*
* This program has been derived from pimd.
* This program has been derived from pimd.
* The pimd program is covered by the license in the accompanying file
* named "LICENSE.pimd".
*
* $FreeBSD$
*/
#ifndef DEBUG_H
#define DEBUG_H
#define DEBUG_H
#include <sys/types.h>
#include <stdio.h>
extern unsigned long debug;
extern int log_nmsgs;
extern FILE *log_fp;
#define IF_DEBUG(l) if (debug && debug & (l))
#define IF_DEBUG(l) if (debug && debug & (l))
#define LOG_MAX_MSGS 20 /* if > 20/minute then shut up for a while */
#define LOG_SHUT_UP 600 /* shut up for 10 minutes */
#define LOG_MAX_MSGS 20 /* if > 20/minute then shut up for a while */
#define LOG_SHUT_UP 600 /* shut up for 10 minutes */
/* Debug values definition */
/* DVMRP reserved for future use */
#define DEBUG_DVMRP_PRUNE 0x00000001
#define DEBUG_DVMRP_ROUTE 0x00000002
#define DEBUG_DVMRP_PEER 0x00000004
#define DEBUG_DVMRP_TIMER 0x00000008
#define DEBUG_DVMRP_DETAIL 0x01000000
#define DEBUG_DVMRP ( DEBUG_DVMRP_PRUNE | DEBUG_DVMRP_ROUTE | \
#define DEBUG_DVMRP_PRUNE 0x00000001
#define DEBUG_DVMRP_ROUTE 0x00000002
#define DEBUG_DVMRP_PEER 0x00000004
#define DEBUG_DVMRP_TIMER 0x00000008
#define DEBUG_DVMRP_DETAIL 0x01000000
#define DEBUG_DVMRP ( DEBUG_DVMRP_PRUNE | DEBUG_DVMRP_ROUTE | \
DEBUG_DVMRP_PEER )
/* MLD related */
#define DEBUG_MLD_PROTO 0x00000010
#define DEBUG_MLD_TIMER 0x00000020
#define DEBUG_MLD_MEMBER 0x00000040
#define DEBUG_MEMBER DEBUG_MLD_MEMBER
#define DEBUG_MLD ( DEBUG_MLD_PROTO | DEBUG_MLD_TIMER | \
#define DEBUG_MLD_PROTO 0x00000010
#define DEBUG_MLD_TIMER 0x00000020
#define DEBUG_MLD_MEMBER 0x00000040
#define DEBUG_MEMBER DEBUG_MLD_MEMBER
#define DEBUG_MLD ( DEBUG_MLD_PROTO | DEBUG_MLD_TIMER | \
DEBUG_MLD_MEMBER )
/* Misc */
#define DEBUG_TRACE 0x00000080
#define DEBUG_TIMEOUT 0x00000100
#define DEBUG_PKT 0x00000200
#define DEBUG_TRACE 0x00000080
#define DEBUG_TIMEOUT 0x00000100
#define DEBUG_PKT 0x00000200
/* Kernel related */
#define DEBUG_IF 0x00000400
#define DEBUG_KERN 0x00000800
#define DEBUG_MFC 0x00001000
#define DEBUG_RSRR 0x00002000
#define DEBUG_IF 0x00000400
#define DEBUG_KERN 0x00000800
#define DEBUG_MFC 0x00001000
#define DEBUG_RSRR 0x00002000
/* PIM related */
#define DEBUG_PIM_HELLO 0x00004000
#define DEBUG_PIM_REGISTER 0x00008000
#define DEBUG_PIM_JOIN_PRUNE 0x00010000
#define DEBUG_PIM_BOOTSTRAP 0x00020000
#define DEBUG_PIM_ASSERT 0x00040000
#define DEBUG_PIM_CAND_RP 0x00080000
#define DEBUG_PIM_MRT 0x00100000
#define DEBUG_PIM_TIMER 0x00200000
#define DEBUG_PIM_RPF 0x00400000
#define DEBUG_RPF DEBUG_PIM_RPF
#define DEBUG_PIM_DETAIL 0x00800000
#define DEBUG_PIM ( DEBUG_PIM_HELLO | DEBUG_PIM_REGISTER | \
#define DEBUG_PIM_HELLO 0x00004000
#define DEBUG_PIM_REGISTER 0x00008000
#define DEBUG_PIM_JOIN_PRUNE 0x00010000
#define DEBUG_PIM_BOOTSTRAP 0x00020000
#define DEBUG_PIM_ASSERT 0x00040000
#define DEBUG_PIM_CAND_RP 0x00080000
#define DEBUG_PIM_MRT 0x00100000
#define DEBUG_PIM_TIMER 0x00200000
#define DEBUG_PIM_RPF 0x00400000
#define DEBUG_RPF DEBUG_PIM_RPF
#define DEBUG_PIM_DETAIL 0x00800000
#define DEBUG_PIM ( DEBUG_PIM_HELLO | DEBUG_PIM_REGISTER | \
DEBUG_PIM_JOIN_PRUNE | DEBUG_PIM_BOOTSTRAP | \
DEBUG_PIM_ASSERT | DEBUG_PIM_CAND_RP | \
DEBUG_PIM_MRT | DEBUG_PIM_TIMER | \
DEBUG_PIM_RPF )
DEBUG_PIM_RPF )
#define DEBUG_MRT ( DEBUG_DVMRP_ROUTE | DEBUG_PIM_MRT )
#define DEBUG_NEIGHBORS ( DEBUG_DVMRP_PEER | DEBUG_PIM_HELLO )
#define DEBUG_TIMER ( DEBUG_MLD_TIMER | DEBUG_DVMRP_TIMER | \
#define DEBUG_MRT ( DEBUG_DVMRP_ROUTE | DEBUG_PIM_MRT )
#define DEBUG_NEIGHBORS ( DEBUG_DVMRP_PEER | DEBUG_PIM_HELLO )
#define DEBUG_TIMER ( DEBUG_MLD_TIMER | DEBUG_DVMRP_TIMER | \
DEBUG_PIM_TIMER )
#define DEBUG_ASSERT ( DEBUG_PIM_ASSERT )
#define DEBUG_ASSERT ( DEBUG_PIM_ASSERT )
/* CONFIG related */
#define DEBUG_CONF 0x01000000
#define DEBUG_CONF 0x01000000
#define DEBUG_ALL 0xffffffff
#define DEBUG_SWITCH 0x80000000
#define DEBUG_ALL 0xffffffff
#define DEBUG_SWITCH 0x80000000
#define DEBUG_DEFAULT 0xffffffff/* default if "-d" given without value */
#define DEBUG_DEFAULT 0xffffffff/* default if "-d" given without value */
#if defined(YIPS_DEBUG)
#define YIPSDEBUG(lev,arg) if ((debug & (lev)) == (lev)) { arg; }
#define YIPSDEBUG(lev,arg) if ((debug & (lev)) == (lev)) { arg; }
#else
#define YIPSDEBUG(lev,arg)
#define YIPSDEBUG(lev,arg)
#endif /* defined(YIPS_DEBUG) */
extern char *packet_kind __P((u_int proto, u_int type,
@ -146,8 +145,9 @@ extern void fdump __P((int i));
extern void cdump __P((int i));
extern void dump_vifs __P((FILE *fp));
extern void dump_nbrs __P((FILE *fp));
extern void dump_mldqueriers __P((FILE *fp));
extern void dump_pim_mrt __P((FILE *fp));
extern int dump_rp_set __P((FILE *fp));
extern void dump_stat __P(());
extern void dump_stat __P((void));
#endif

View File

@ -25,8 +25,6 @@
* 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.
*
* $FreeBSD$
*/
/*
* Questions concerning this software should be directed to
@ -34,26 +32,27 @@
*
*/
/*
* This program has been derived from pim6dd.
* This program has been derived from pim6dd.
* The pim6dd program is covered by the license in the accompanying file
* named "LICENSE.pim6dd".
*/
/*
* This program has been derived from pimd.
* This program has been derived from pimd.
* The pimd program is covered by the license in the accompanying file
* named "LICENSE.pimd".
*
* $FreeBSD$
*/
#ifndef DEFS_H
#define DEFS_H
#define DEFS_H
#include <sys/types.h>
#define TRUE 1
#define FALSE 0
#define ELSE else /* To make emacs cc-mode happy */
#define ELSE else /* To make emacs cc-mode happy */
#define max( a , b ) ( ( a )<( b )?( b ):( a ) )
@ -64,12 +63,12 @@ int register_input_handler __P((int fd,ihfunc_t func));
/* CONFIGCONFIGCONFIGCONFIG */
#define HAVE_ROUTING_SOCKETS
#define HAVE_SA_LEN
#define RANDOM() random()
#define HAVE_ROUTING_SOCKETS
#define HAVE_SA_LEN
#define RANDOM() random()
#define PRINTF printf
#define ALL_MCAST_GROUPS_LENGTH 8
#define PRINTF printf
#define ALL_MCAST_GROUPS_LENGTH 8
typedef u_int u_int32;

View File

@ -25,8 +25,6 @@
* 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.
*
* $FreeBSD$
*/
/*
* Questions concerning this software should be directed to
@ -34,17 +32,20 @@
*
*/
/*
* This program has been derived from pim6dd.
* This program has been derived from pim6dd.
* The pim6dd program is covered by the license in the accompanying file
* named "LICENSE.pim6dd".
*/
/*
* This program has been derived from pimd.
* This program has been derived from pimd.
* The pimd program is covered by the license in the accompanying file
* named "LICENSE.pimd".
*
* $FreeBSD$
*/
#include <sys/types.h>
#include <sys/socket.h>
#include <stdio.h>
#include <netdb.h>
#include <string.h>
@ -186,30 +187,38 @@ inet6_match_prefix(sa1, sa2, mask)
return (1);
}
char *
inet6_fmt(struct in6_addr * addr)
char *
sa6_fmt(struct sockaddr_in6 *sa6)
{
static char ip6buf[8][MAXHOSTNAMELEN];
static int ip6round = 0;
char *cp;
struct sockaddr_in6 sa6;
int flags = NI_WITHSCOPEID;
char *cp;
ip6round = (ip6round + 1) & 7;
cp = ip6buf[ip6round];
if (numerichost)
flags |= NI_NUMERICHOST;
getnameinfo((struct sockaddr *)sa6, sa6->sin6_len, cp, MAXHOSTNAMELEN,
NULL, 0, flags);
return(cp);
}
char *
inet6_fmt(struct in6_addr * addr)
{
struct sockaddr_in6 sa6;
memset(&sa6, 0, sizeof(sa6));
sa6.sin6_len = sizeof(sa6);
sa6.sin6_family = AF_INET6;
sa6.sin6_addr = *addr;
sa6.sin6_scope_id = 0; /* XXX */
if (numerichost)
flags |= NI_NUMERICHOST;
getnameinfo((struct sockaddr *)&sa6, sa6.sin6_len, cp, MAXHOSTNAMELEN,
NULL, 0, flags);
return(cp);
return(sa6_fmt(&sa6));
}
char *

View File

@ -25,8 +25,6 @@
* 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.
*
* $FreeBSD$
*/
/*
* Questions concerning this software should be directed to
@ -34,26 +32,27 @@
*
*/
/*
* This program has been derived from pim6dd.
* This program has been derived from pim6dd.
* The pim6dd program is covered by the license in the accompanying file
* named "LICENSE.pim6dd".
*/
/*
* This program has been derived from pimd.
* This program has been derived from pimd.
* The pimd program is covered by the license in the accompanying file
* named "LICENSE.pimd".
*
* $FreeBSD$
*/
#ifndef INET6_H
#define INET6_H
#define INET6_H
#include "vif.h"
extern int numerichost;
extern int inet6_equal __P((struct sockaddr_in6 *sa1,
struct sockaddr_in6 *sa2));
struct sockaddr_in6 *sa2));
extern int inet6_lessthan __P((struct sockaddr_in6 *sa1,
struct sockaddr_in6 *sa2));
extern int inet6_localif_address __P((struct sockaddr_in6 *sa,
@ -66,9 +65,10 @@ extern int inet6_match_prefix __P((struct sockaddr_in6 *sa1,
extern int inet6_mask2plen __P((struct in6_addr *mask));
extern int inet6_uvif2scopeid __P((struct sockaddr_in6 *sa, struct uvif *v));
extern int inet6_valid_host __P((struct sockaddr_in6 *addr));
extern char *sa6_fmt __P((struct sockaddr_in6 *sa6));
extern char *inet6_fmt __P((struct in6_addr *addr));
extern char *ifindex2str __P((int ifindex));
extern char *net6name __P((struct in6_addr *prefix,
extern char *net6name __P((struct in6_addr *prefix,
struct in6_addr *mask));

View File

@ -29,8 +29,6 @@
*
* Other copyrights might apply to parts of this software and are so
* noted when applicable.
*
* $FreeBSD$
*/
/*
* Questions concerning this software should be directed to
@ -38,15 +36,16 @@
*
*/
/*
* This program has been derived from pim6dd.
* This program has been derived from pim6dd.
* The pim6dd program is covered by the license in the accompanying file
* named "LICENSE.pim6dd".
*/
/*
* This program has been derived from pimd.
* This program has been derived from pimd.
* The pimd program is covered by the license in the accompanying file
* named "LICENSE.pimd".
*
* $FreeBSD$
*/
#include <sys/time.h>
@ -69,16 +68,17 @@
#include "vif.h"
#include "mrt.h"
#include "debug.h"
#include "kern.h"
/*
/*
* Open/init the multicast routing in the kernel and sets the MRT_ASSERT
* flag in the kernel.
*
*/
void
void
k_init_pim(int socket)
{
int v = 1;
@ -110,12 +110,12 @@ k_stop_pim(socket)
}
/*
/*
* Set the socket receiving buffer. `bufsize` is the preferred size,
* `minsize` is the smallest acceptable size.
*/
*/
void
void
k_set_rcvbuf(int socket, int bufsize, int minsize)
{
int delta = bufsize / 2;
@ -125,7 +125,7 @@ k_set_rcvbuf(int socket, int bufsize, int minsize)
* Set the socket buffer. If we can't set it as large as we
* want, search around to try to find the highest acceptable
* value. The highest acceptable value being smaller than
* minsize is a fatal error.
* minsize is a fatal error.
*/
@ -157,12 +157,12 @@ k_set_rcvbuf(int socket, int bufsize, int minsize)
log(LOG_DEBUG,0,"Buffer reception size for socket %d : %d in %d iterations",socket, bufsize, iter);
}
/*
/*
* Set the default Hop Limit for the multicast packets outgoing from this
* socket.
*/
*/
void
void
k_set_hlim(int socket, int h)
{
int hlim = h;
@ -177,7 +177,7 @@ k_set_hlim(int socket, int h)
*/
void
void
k_set_loop(int socket, int flag)
{
u_int loop;
@ -190,10 +190,10 @@ k_set_loop(int socket, int flag)
/*
* Set the IPV6_MULTICAST_IF option on local interface which has the
* specified index.
*/
*/
void
void
k_set_if(int socket, u_int ifindex)
{
if (setsockopt(socket, IPPROTO_IPV6, IPV6_MULTICAST_IF,
@ -205,9 +205,9 @@ k_set_if(int socket, u_int ifindex)
/*
* Join a multicast grp group on local interface ifa.
*/
*/
void
void
k_join(int socket, struct in6_addr * grp, u_int ifindex)
{
struct ipv6_mreq mreq;
@ -223,9 +223,9 @@ k_join(int socket, struct in6_addr * grp, u_int ifindex)
/*
* Leave a multicats grp group on local interface ifa.
*/
*/
void
void
k_leave(int socket, struct in6_addr * grp, u_int ifindex)
{
struct ipv6_mreq mreq;
@ -239,11 +239,11 @@ k_leave(int socket, struct in6_addr * grp, u_int ifindex)
inet6_fmt(grp), ifindex2str(ifindex));
}
/*
/*
* Add a virtual interface in the kernel.
*/
void
void
k_add_vif(int socket, vifi_t vifi, struct uvif * v)
{
struct mif6ctl mc;
@ -266,7 +266,7 @@ k_add_vif(int socket, vifi_t vifi, struct uvif * v)
* Delete a virtual interface in the kernel.
*/
void
void
k_del_vif(int socket, vifi_t vifi)
{
if (setsockopt(socket, IPPROTO_IPV6, MRT6_DEL_MIF,
@ -276,9 +276,9 @@ k_del_vif(int socket, vifi_t vifi)
/*
* Delete all MFC entries for particular routing entry from the kernel.
*/
*/
int
int
k_del_mfc(int socket, struct sockaddr_in6 * source, struct sockaddr_in6 * group)
{
struct mf6cctl mc;
@ -290,7 +290,7 @@ k_del_mfc(int socket, struct sockaddr_in6 * source, struct sockaddr_in6 * group)
if (setsockopt(socket, IPPROTO_IPV6, MRT6_DEL_MFC, (char *) &mc, sizeof(mc)) < 0)
{
pim6dstat.kern_del_cache_fail++;
log(LOG_WARNING, errno, "setsockopt MRT6_DEL_MFC");
log(LOG_WARNING, errno, "setsockopt MRT6_DEL_MFC");
return FALSE;
}
@ -359,7 +359,7 @@ k_chg_mfc(socket, source, group, iif, oifs, rp_addr)
* XXX: TODO: currently not used, but keep just in case we need it later.
*/
int
int
k_get_vif_count(vifi, retval)
vifi_t vifi;
struct vif_count *retval;

View File

@ -25,8 +25,6 @@
* 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.
*
* $FreeBSD$
*/
/*
* Questions concerning this software should be directed to
@ -34,20 +32,21 @@
*
*/
/*
* This program has been derived from pim6dd.
* This program has been derived from pim6dd.
* The pim6dd program is covered by the license in the accompanying file
* named "LICENSE.pim6dd".
*/
/*
* This program has been derived from pimd.
* This program has been derived from pimd.
* The pimd program is covered by the license in the accompanying file
* named "LICENSE.pimd".
*
* $FreeBSD$
*/
#ifndef KERN_H
#define KERN_H
#ifndef KERN_H
#define KERN_H
#include "vif.h"
#include "mrt.h"
@ -59,12 +58,12 @@ extern void k_join __P((int socket, struct in6_addr *grp,
u_int ifindex));
extern void k_leave __P((int socket, struct in6_addr *grp,
u_int ifindex));
extern void k_init_pim __P(());
extern void k_stop_pim __P(());
extern void k_init_pim __P((int));
extern void k_stop_pim __P((int));
extern int k_del_mfc __P((int socket, struct sockaddr_in6 *source,
struct sockaddr_in6 *group));
extern int k_chg_mfc __P((int socket, struct sockaddr_in6 *source,
struct sockaddr_in6 *group, vifi_t iif,
struct sockaddr_in6 *group, vifi_t iif,
if_set *oifs, struct sockaddr_in6 *rp_addr));
extern void k_add_vif __P((int socket, vifi_t vifi, struct uvif *v));
extern void k_del_vif __P((int socket, vifi_t vifi));

View File

@ -29,8 +29,6 @@
*
* Other copyrights might apply to parts of this software and are so
* noted when applicable.
*
* $FreeBSD$
*/
/*
* Questions concerning this software should be directed to
@ -38,12 +36,12 @@
*
*/
/*
* This program has been derived from pim6dd.
* This program has been derived from pim6dd.
* The pim6dd program is covered by the license in the accompanying file
* named "LICENSE.pim6dd".
*/
/*
* This program has been derived from pimd.
* This program has been derived from pimd.
* The pimd program is covered by the license in the accompanying file
* named "LICENSE.pimd".
*
@ -56,6 +54,7 @@
* The mrouted program is COPYRIGHT 1989 by The Board of Trustees of
* Leland Stanford Junior University.
*
* $FreeBSD$
*/
#include <sys/param.h>
@ -85,7 +84,7 @@ char configfilename[256] = _PATH_PIM6D_CONF;
char versionstring[100];
char logfilename[256] = _PATH_PIM6D_LOGFILE;
/* TODO: not used
/* TODO: not used
static char genidfilename[] = _PATH_PIM6D_GENID;
*/
static char pidfilename[] = _PATH_PIM6D_PID;
@ -96,15 +95,15 @@ char *progname;
static int foreground = 0;
static int sighandled = 0;
#define GOT_SIGINT 0x01
#define GOT_SIGHUP 0x02
#define GOT_SIGUSR1 0x04
#define GOT_SIGUSR2 0x08
#define GOT_SIGALRM 0x10
#define GOT_SIGINFO 0x20
#define GOT_SIGINT 0x01
#define GOT_SIGHUP 0x02
#define GOT_SIGUSR1 0x04
#define GOT_SIGUSR2 0x08
#define GOT_SIGALRM 0x10
#define GOT_SIGINFO 0x20
#define NHANDLERS 3
#define NHANDLERS 3
static struct ihandler
{
@ -274,7 +273,7 @@ main(argc, argv)
{
no=1;
p++;
}
}
len = strlen(p);
for (i = 0, d = debugnames;
i < sizeof(debugnames) / sizeof(debugnames[0]);
@ -547,20 +546,20 @@ main(argc, argv)
}
if ((n = select(nfds, &rfds, NULL, NULL, timeout)) < 0)
{
if (errno != EINTR)
if (errno != EINTR)
log(LOG_WARNING, errno, "select failed");
continue;
}
/*
* Handle timeout queue.
*
*
* If select + packet processing took more than 1 second, or if there is
* a timeout pending, age the timeout queue.
*
*
* If not, collect usec in difftime to make sure that the time doesn't
* drift too badly.
*
*
* If the timeout handlers took more than 1 second, age the timeout
* queue again. XXX This introduces the potential for infinite
* loops!
@ -637,7 +636,7 @@ main(argc, argv)
* initial- ization. This repetition after a short interval is desirable for
* quickly building up topology and membership information in the presence of
* possible packet loss.
*
*
* 'virtual_time' advances at a rate that is only a crude approximation of real
* time, because it does not take into account any time spent processing, and
* because the timer intervals are sometimes shrunk by a random amount to
@ -677,9 +676,9 @@ cleanup()
* TODO: XXX (not in the spec): if I am the BSR, somehow inform the other
* routers I am going down and need to elect another BSR? (probably by
* sending a the Cand-RP-set with my_priority=LOWEST?)
*
*/
*
*/
k_stop_pim(mld6_socket);
}
@ -736,7 +735,7 @@ restart(i)
* reset all the entries
*/
/*
* TODO: delete?
* TODO: delete?
free_all_routes();
*/

View File

@ -57,8 +57,6 @@
*
* Other copyrights might apply to parts of this software and are so
* noted when applicable.
*
* $FreeBSD$
*/
/*
* Questions concerning this software should be directed to
@ -66,15 +64,16 @@
*
*/
/*
* This program has been derived from pim6dd.
* This program has been derived from pim6dd.
* The pim6dd program is covered by the license in the accompanying file
* named "LICENSE.pim6dd".
*/
/*
* This program has been derived from pimd.
* This program has been derived from pimd.
* The pimd program is covered by the license in the accompanying file
* named "LICENSE.pimd".
*
* $FreeBSD$
*/
#include <sys/types.h>
@ -118,11 +117,12 @@ static struct msghdr sndmh,
static struct iovec sndiov[2];
static struct iovec rcviov[2];
static struct sockaddr_in6 from;
static u_char rcvcmsgbuf[CMSG_SPACE(sizeof(struct in6_pktinfo)) +
CMSG_SPACE(sizeof(int))];
static u_char *rcvcmsgbuf = NULL;
static int rcvcmsglen;
#ifndef USE_RFC2292BIS
u_int8_t raopt[IP6OPT_RTALERT_LEN];
#endif
#endif
static char *sndcmsgbuf;
static int ctlbuflen = 0;
static u_short rtalert_code;
@ -131,9 +131,11 @@ static u_short rtalert_code;
static void mld6_read __P((int i, fd_set * fds));
static void accept_mld6 __P((int len));
static void make_mld6_msg __P((int, int, struct sockaddr_in6 *,
struct sockaddr_in6 *, struct in6_addr *, int, int, int, int));
#ifndef IP6OPT_ROUTER_ALERT /* XXX to be compatible older systems */
#define IP6OPT_ROUTER_ALERT IP6OPT_RTALERT
#define IP6OPT_ROUTER_ALERT IP6OPT_RTALERT
#endif
/*
@ -147,10 +149,15 @@ init_mld6()
rtalert_code = htons(IP6OPT_RTALERT_MLD);
if (!mld6_recv_buf && (mld6_recv_buf = malloc(RECV_BUF_SIZE)) == NULL)
log(LOG_ERR, 0, "malloca failed");
log(LOG_ERR, 0, "malloc failed");
if (!mld6_send_buf && (mld6_send_buf = malloc(RECV_BUF_SIZE)) == NULL)
log(LOG_ERR, 0, "malloca failed");
log(LOG_ERR, 0, "malloc failed");
rcvcmsglen = CMSG_SPACE(sizeof(struct in6_pktinfo)) +
CMSG_SPACE(sizeof(int));
if (rcvcmsgbuf == NULL && (rcvcmsgbuf = malloc(rcvcmsglen)) == NULL)
log(LOG_ERR, 0,"malloc failed");
IF_DEBUG(DEBUG_KERN)
log(LOG_DEBUG,0,"%d octets allocated for the emit/recept buffer mld6",RECV_BUF_SIZE);
@ -189,7 +196,7 @@ init_mld6()
if (setsockopt(mld6_socket, IPPROTO_IPV6, IPV6_PKTINFO, &on,
sizeof(on)) < 0)
log(LOG_ERR, errno, "setsockopt(IPV6_PKTINFO)");
#endif
#endif
on = 1;
/* specify to tell value of hoplimit field of received IP6 hdr */
@ -201,7 +208,7 @@ init_mld6()
if (setsockopt(mld6_socket, IPPROTO_IPV6, IPV6_HOPLIMIT, &on,
sizeof(on)) < 0)
log(LOG_ERR, errno, "setsockopt(IPV6_HOPLIMIT)");
#endif
#endif
/* initialize msghdr for receiving packets */
rcviov[0].iov_base = (caddr_t) mld6_recv_buf;
@ -211,7 +218,7 @@ init_mld6()
rcvmh.msg_iov = rcviov;
rcvmh.msg_iovlen = 1;
rcvmh.msg_control = (caddr_t) rcvcmsgbuf;
rcvmh.msg_controllen = sizeof(rcvcmsgbuf);
rcvmh.msg_controllen = rcvcmsglen;
/* initialize msghdr for sending packets */
sndiov[0].iov_base = (caddr_t)mld6_send_buf;
@ -223,7 +230,7 @@ init_mld6()
raopt[0] = IP6OPT_ROUTER_ALERT;
raopt[1] = IP6OPT_RTALERT_LEN - 2;
memcpy(&raopt[2], (caddr_t) & rtalert_code, sizeof(u_short));
#endif
#endif
/* register MLD message handler */
if (register_input_handler(mld6_socket, mld6_read) < 0)
@ -268,19 +275,6 @@ int recvlen;
int ifindex = 0;
struct sockaddr_in6 *src = (struct sockaddr_in6 *) rcvmh.msg_name;
/*
* If control length is zero, it must be an upcall from the kernel
* multicast forwarding engine.
* XXX: can we trust it?
*/
if (rcvmh.msg_controllen == 0) {
/* XXX: msg_controllen must be reset in this case. */
rcvmh.msg_controllen = sizeof(rcvcmsgbuf);
process_kernel_call();
return;
}
if (recvlen < sizeof(struct mld6_hdr))
{
log(LOG_WARNING, 0,
@ -289,6 +283,20 @@ int recvlen;
return;
}
mldh = (struct mld6_hdr *) rcvmh.msg_iov[0].iov_base;
/*
* Packets sent up from kernel to daemon have ICMPv6 type = 0.
* Note that we set filters on the mld6_socket, so we should never
* see a "normal" ICMPv6 packet with type 0 of ICMPv6 type.
*/
if (mldh->mld6_type == 0) {
/* XXX: msg_controllen must be reset in this case. */
rcvmh.msg_controllen = rcvcmsglen;
process_kernel_call();
return;
}
group = &mldh->mld6_addr;
/* extract optional information via Advanced API */
@ -418,7 +426,7 @@ make_mld6_msg(type, code, src, dst, group, ifindex, delay, datalen, alert)
datalen = sizeof(struct mld6_hdr);
break;
}
bzero(mhp, sizeof(*mhp));
mhp->mld6_type = type;
mhp->mld6_code = code;
@ -440,10 +448,11 @@ make_mld6_msg(type, code, src, dst, group, ifindex, delay, datalen, alert)
log(LOG_ERR, 0, "inet6_opt_append(0) failed");
if ((hbhlen = inet6_opt_finish(NULL, 0, hbhlen)) == -1)
log(LOG_ERR, 0, "inet6_opt_finish(0) failed");
ctllen += CMSG_SPACE(hbhlen);
#else /* old advanced API */
hbhlen = inet6_option_space(sizeof(raopt));
hbhlen = inet6_option_space(sizeof(raopt));
ctllen += hbhlen;
#endif
ctllen += CMSG_SPACE(hbhlen);
}
/* extend ancillary data space (if necessary) */
if (ctlbuflen < ctllen) {
@ -505,7 +514,7 @@ make_mld6_msg(type, code, src, dst, group, ifindex, delay, datalen, alert)
if (inet6_option_append(cmsgp, raopt, 4, 0))
log(LOG_ERR, 0, /* assert */
"make_mld6_msg: inet6_option_append failed");
#endif
#endif
cmsgp = CMSG_NXTHDR(&sndmh, cmsgp);
}
}
@ -525,7 +534,7 @@ send_mld6(type, code, src, dst, group, index, delay, datalen, alert)
{
int setloop = 0;
struct sockaddr_in6 *dstp;
make_mld6_msg(type, code, src, dst, group, index, delay, datalen, alert);
dstp = (struct sockaddr_in6 *)sndmh.msg_name;
if (IN6_ARE_ADDR_EQUAL(&dstp->sin6_addr, &allnodes_group.sin6_addr)) {
@ -546,7 +555,7 @@ send_mld6(type, code, src, dst, group, index, delay, datalen, alert)
k_set_loop(mld6_socket, FALSE);
return;
}
IF_DEBUG(DEBUG_PKT|debug_kind(IPPROTO_IGMP, type, 0))
log(LOG_DEBUG, 0, "SENT %s from %-15s to %s",
packet_kind(IPPROTO_ICMPV6, type, 0),

View File

@ -25,8 +25,6 @@
* 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.
*
* $FreeBSD$
*/
/*
* Questions concerning this software should be directed to
@ -34,47 +32,51 @@
*
*/
/*
* This program has been derived from pim6dd.
* This program has been derived from pim6dd.
* The pim6dd program is covered by the license in the accompanying file
* named "LICENSE.pim6dd".
*/
/*
* This program has been derived from pimd.
* This program has been derived from pimd.
* The pimd program is covered by the license in the accompanying file
* named "LICENSE.pimd".
*
* $FreeBSD$
*/
#ifndef MLD6_H
#define MLD6_H
#define MLD6_H
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <unistd.h>
#define RECV_BUF_SIZE 64*1024
#define SO_RECV_BUF_SIZE_MAX 256*1024
#define SO_RECV_BUF_SIZE_MIN 48*1024
#define MINHLIM 1
#define RECV_BUF_SIZE 64*1024
#define SO_RECV_BUF_SIZE_MAX 256*1024
#define SO_RECV_BUF_SIZE_MIN 48*1024
#define MINHLIM 1
/*
* Constans for Multicast Listener Discovery protocol for IPv6.
*/
#define MLD6_ROBUSTNESS_VARIABLE 2
#define MLD6_QUERY_INTERVAL 125 /* in seconds */
#define MLD6_QUERY_RESPONSE_INTERVAL 10000 /* in milliseconds */
#define MLD6_ROBUSTNESS_VARIABLE 2
#define MLD6_QUERY_INTERVAL 125 /* in seconds */
#define MLD6_QUERY_RESPONSE_INTERVAL 10000 /* in milliseconds */
#ifndef MLD6_TIMER_SCALE
#define MLD6_TIMER_SCALE 1000
#define MLD6_TIMER_SCALE 1000
#endif
#define MLD6_LISTENER_INTERVAL (MLD6_ROBUSTNESS_VARIABLE * \
#define MLD6_LISTENER_INTERVAL (MLD6_ROBUSTNESS_VARIABLE * \
MLD6_QUERY_INTERVAL + \
MLD6_QUERY_RESPONSE_INTERVAL / MLD6_TIMER_SCALE)
#define MLD6_LAST_LISTENER_QUERY_INTERVAL 1000 /* in milliseconds */
#define MLD6_LAST_LISTENER_QUERY_COUNT MLD6_ROBUSTNESS_VARIABLE
#define MLD6_LAST_LISTENER_QUERY_INTERVAL 1000 /* in milliseconds */
#define MLD6_LAST_LISTENER_QUERY_COUNT MLD6_ROBUSTNESS_VARIABLE
#define MLD6_OTHER_QUERIER_PRESENT_INTERVAL (MLD6_ROBUSTNESS_VARIABLE * \
MLD6_QUERY_INTERVAL + \
MLD6_QUERY_RESPONSE_INTERVAL / (2 * MLD6_TIMER_SCALE))
extern int mld6_socket;
extern char *mld6_recv_buf;
@ -82,7 +84,7 @@ extern struct sockaddr_in6 allrouters_group;
extern struct sockaddr_in6 allnodes_group;
extern char *mld6_send_buf;
void init_mld6 __P(());
void init_mld6 __P((void));
void send_mld6 __P((int type, int code, struct sockaddr_in6 *src,
struct sockaddr_in6 *dst, struct in6_addr *group,
int index, int delay, int datalen, int alert));

View File

@ -57,8 +57,6 @@
*
* Other copyrights might apply to parts of this software and are so
* noted when applicable.
*
* $FreeBSD$
*/
/*
* Questions concerning this software should be directed to
@ -66,12 +64,12 @@
*
*/
/*
* This program has been derived from pim6dd.
* This program has been derived from pim6dd.
* The pim6dd program is covered by the license in the accompanying file
* named "LICENSE.pim6dd".
*/
/*
* This program has been derived from pimd.
* This program has been derived from pimd.
* The pimd program is covered by the license in the accompanying file
* named "LICENSE.pimd".
*
@ -93,6 +91,7 @@
* The mrouted program is COPYRIGHT 1989 by The Board of Trustees of
* Leland Stanford Junior University.
*
* $FreeBSD$
*/
#include <sys/param.h>
@ -113,6 +112,8 @@
#include "callout.h"
#include "timer.h"
#include "mld6_proto.h"
extern struct in6_addr in6addr_any;
typedef struct
@ -130,7 +131,7 @@ static void DelVif __P((void *arg));
static int SetTimer __P((int mifi, struct listaddr * g));
static int DeleteTimer __P((int id));
static void SendQuery __P((void *arg));
static int SetQueryTimer
static int SetQueryTimer
__P((struct listaddr * g, int mifi, int to_expire,
int q_time));
@ -177,37 +178,34 @@ accept_listener_query(src, dst, group, tmo)
register struct uvif *v;
struct sockaddr_in6 group_sa = {sizeof(group_sa), AF_INET6};
/* Ignore my own membership query */
/* Ignore my own listener query */
if (local_address(src) != NO_VIF)
return;
if ((mifi = find_vif_direct(src)) == NO_VIF)
{
if ((mifi = find_vif_direct(src)) == NO_VIF) {
IF_DEBUG(DEBUG_MLD)
log(LOG_INFO, 0,
"accept_listener_query: can't find a mif");
return;
}
v = &uvifs[mifi];
v->uv_in_mld_query++;
IF_DEBUG(DEBUG_MLD)
log(LOG_DEBUG, 0,
"accepting multicast listener query: "
"accepting multicast listener query on %s: "
"src %s, dst %s, grp %s",
v->uv_name,
inet6_fmt(&src->sin6_addr), inet6_fmt(dst),
inet6_fmt(group));
v = &uvifs[mifi];
v->uv_in_mld_query++;
if (v->uv_querier == NULL || inet6_equal(&v->uv_querier->al_addr, src))
{
if (v->uv_querier == NULL || !inet6_equal(&v->uv_querier->al_addr, src)) {
/*
* This might be: - A query from a new querier, with a lower source
* address than the current querier (who might be me) - A query from
* a new router that just started up and doesn't know who the querier
* is. - A query from the current querier
* This might be:
* - A query from a new querier, with a lower source address than
* the current querier (who might be me).
* - A query from a new router that just started up and doesn't know
* who the querier is.
*/
if (inet6_lessthan(src, (v->uv_querier ? &v->uv_querier->al_addr
: &v->uv_linklocal->pa_addr)))
{
@ -218,22 +216,11 @@ accept_listener_query(src, dst, group, tmo)
v->uv_querier ?
inet6_fmt(&v->uv_querier->al_addr.sin6_addr) :
"me", mifi);
if (!v->uv_querier)
{
if (!v->uv_querier) { /* this should be impossible... */
v->uv_querier = (struct listaddr *)malloc(sizeof(struct listaddr));
v->uv_querier->al_next = (struct listaddr *) NULL;
v->uv_querier->al_timer = 0;
v->uv_querier->al_genid = 0;
v->uv_querier->al_pv = 0;
v->uv_querier->al_mv = 0;
v->uv_querier->al_old = 0;
v->uv_querier->al_index = 0;
v->uv_querier->al_timerid = 0;
v->uv_querier->al_query = 0;
v->uv_querier->al_flags = 0;
v->uv_flags &= ~VIFF_QUERIER;
memset(v->uv_querier, 0, sizeof(struct listaddr));
}
v->uv_flags &= ~VIFF_QUERIER;
v->uv_querier->al_addr = *src;
time(&v->uv_querier->al_ctime);
}
@ -243,7 +230,7 @@ accept_listener_query(src, dst, group, tmo)
* Reset the timer since we've received a query.
*/
if (v->uv_querier && inet6_equal(src, &v->uv_querier->al_addr))
v->uv_querier->al_timer = 0;
v->uv_querier->al_timer = MLD6_OTHER_QUERIER_PRESENT_INTERVAL;
/*
* If this is a Group-Specific query which we did not source, we must set
@ -369,7 +356,7 @@ accept_listener_report(src, dst, group)
{
IF_DEBUG(DEBUG_MLD)
log(LOG_DEBUG,0,
"The group don't exist , trying to add it");
"The group don't exist , trying to add it");
g = (struct listaddr *) malloc(sizeof(struct listaddr));
if (g == NULL)
@ -386,7 +373,7 @@ accept_listener_report(src, dst, group)
g->al_next = v->uv_groups;
v->uv_groups = g;
time(&g->al_ctime);
add_leaf(mifi, NULL, &group_sa);
}
}
@ -405,7 +392,7 @@ accept_listener_done(src, dst, group)
struct sockaddr_in6 group_sa = {sizeof(group_sa), AF_INET6};
/* Don't create routing entries for the LAN scoped addresses */
if (IN6_IS_ADDR_MC_NODELOCAL(group)) /* sanity? */
{
IF_DEBUG(DEBUG_MLD)
@ -521,7 +508,7 @@ DelVif(arg)
/* increment statistics */
v->uv_listener_timo++;
anp = &(v->uv_groups);
while ((a = *anp) != NULL)
{

View File

@ -25,8 +25,6 @@
* 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.
*
* $FreeBSD$
*/
/*
* Questions concerning this software should be directed to
@ -34,25 +32,26 @@
*
*/
/*
* This program has been derived from pim6dd.
* This program has been derived from pim6dd.
* The pim6dd program is covered by the license in the accompanying file
* named "LICENSE.pim6dd".
*/
/*
* This program has been derived from pimd.
* This program has been derived from pimd.
* The pimd program is covered by the license in the accompanying file
* named "LICENSE.pimd".
*
* $FreeBSD$
*/
#ifndef MLD6_PROTO_H
#define MLD6_PROTO_H
#define MLD6_PROTO_H
#include "vif.h"
extern void query_groups __P((struct uvif *v));
extern int check_grp_membership __P((struct uvif *v,
extern int check_grp_membership __P((struct uvif *v,
struct sockaddr_in6 *group));
extern void accept_listener_query __P((struct sockaddr_in6 *src,
struct in6_addr *dst,

View File

@ -29,8 +29,6 @@
*
* Other copyrights might apply to parts of this software and are so
* noted when applicable.
*
* $FreeBSD$
*/
/*
* Questions concerning this software should be directed to
@ -38,15 +36,16 @@
*
*/
/*
* This program has been derived from pim6dd.
* This program has been derived from pim6dd.
* The pim6dd program is covered by the license in the accompanying file
* named "LICENSE.pim6dd".
*/
/*
* This program has been derived from pimd.
* This program has been derived from pimd.
* The pimd program is covered by the license in the accompanying file
* named "LICENSE.pimd".
*
* $FreeBSD$
*/
#include <syslog.h>
@ -70,7 +69,7 @@ grpentry_t *grplist;
* Local functions definition
*/
static srcentry_t *create_srcentry __P((struct sockaddr_in6 *source));
static int search_srclist __P((struct sockaddr_in6 *source ,
static int search_srclist __P((struct sockaddr_in6 *source ,
srcentry_t ** sourceEntry));
static int search_srcmrtlink __P((srcentry_t * srcentry_ptr,
@ -705,7 +704,7 @@ search_grplist(group, groupEntry)
if (inet6_lessthan(&g->group, group))
continue;
if (inet6_equal(&g->group, group))
if (inet6_equal(&g->group, group))
{
*groupEntry = g;
return (TRUE);
@ -741,7 +740,7 @@ create_srcentry(source)
* Free the memory if there is error getting the iif and the next hop
* (upstream) router.
*/
if (set_incoming(srcentry_ptr, PIM_IIF_SOURCE) == FALSE)
{
free((char *) srcentry_ptr);
@ -815,7 +814,7 @@ create_grpentry(group)
/*
* Return TRUE if the entry is found and then *mrtPtr is set to point to that
* entry. Otherwise return FALSE and *mrtPtr points the the previous entry
* entry. Otherwise return FALSE and *mrtPtr points the previous entry
* (or NULL if first in the chain.
*/
static int
@ -835,7 +834,7 @@ search_srcmrtlink(srcentry_ptr, group, mrtPtr)
* The entries are ordered with the smaller group address first. The
* addresses are in network order.
*/
if (inet6_lessthan(&mrtentry_ptr->group->group, group))
continue;
if (inet6_equal(&mrtentry_ptr->group->group, group))
@ -852,7 +851,7 @@ search_srcmrtlink(srcentry_ptr, group, mrtPtr)
/*
* Return TRUE if the entry is found and then *mrtPtr is set to point to that
* entry. Otherwise return FALSE and *mrtPtr points the the previous entry
* entry. Otherwise return FALSE and *mrtPtr points the previous entry
* (or NULL if first in the chain.
*/
static int
@ -978,7 +977,7 @@ alloc_mrtentry(srcentry_ptr, grpentry_ptr)
mrtentry_ptr->pmbr_addr.sin6_addr = in6addr_any;
mrtentry_ptr->pmbr_addr.sin6_len = sizeof(struct sockaddr_in6);
mrtentry_ptr->pmbr_addr.sin6_family = AF_INET6;
#ifdef RSRR
mrtentry_ptr->rsrr_cache = (struct rsrr_cache *) NULL;
#endif /* RSRR */
@ -1081,6 +1080,12 @@ create_mrtentry(srcentry_ptr, grpentry_ptr, flags)
insert_grpmrtlink(r_new, r_grp_insert, grpentry_ptr);
insert_srcmrtlink(r_new, r_src_insert, srcentry_ptr);
r_new->flags |= MRTF_SG;
IF_DEBUG(DEBUG_MFC)
log(LOG_DEBUG, 0, "create SG entry, source %s, group %s",
inet6_fmt(&source->sin6_addr),
inet6_fmt(&group->sin6_addr));
return (r_new);
}

View File

@ -29,8 +29,6 @@
*
* Other copyrights might apply to parts of this software and are so
* noted when applicable.
*
* $FreeBSD$
*/
/*
* Questions concerning this software should be directed to
@ -38,20 +36,21 @@
*
*/
/*
* This program has been derived from pim6dd.
* This program has been derived from pim6dd.
* The pim6dd program is covered by the license in the accompanying file
* named "LICENSE.pim6dd".
*/
/*
* This program has been derived from pimd.
* This program has been derived from pimd.
* The pimd program is covered by the license in the accompanying file
* named "LICENSE.pimd".
*
* $FreeBSD$
*/
#ifndef MRT_H
#define MRT_H
#define MRT_H
#include <sys/param.h>
#include <sys/time.h>
@ -67,31 +66,31 @@
/* flags for the mrt entries */
#define MRTF_SPT 0x0001 /* iif toward source */
#define MRTF_WC 0x0002 /* (*,G) entry */
#define MRTF_RP 0x0004 /* iif toward RP */
#define MRTF_NEW 0x0008 /* new created routing entry */
#define MRTF_IIF_REGISTER 0x0020 /* ??? */
#define MRTF_REGISTER 0x0080 /* ??? */
#define MRTF_KERNEL_CACHE 0x0200 /* a mirror for the kernel cache */
#define MRTF_NULL_OIF 0x0400 /* null oif cache.. ??? */
#define MRTF_REG_SUPP 0x0800 /* register suppress ??? */
#define MRTF_ASSERTED 0x1000 /* upstream is not that of src ??? */
#define MRTF_SG 0x2000 /* (S,G) pure, not hanging off of (*,G)*/
#define MRTF_PMBR 0x4000 /* (*,*,RP) entry (for interop) */
#define MRTF_MFC_CLONE_SG 0x8000 /* clone (S,G) MFC from (*,G) or (*,*,RP) */
#define MRTF_SPT 0x0001 /* iif toward source */
#define MRTF_WC 0x0002 /* (*,G) entry */
#define MRTF_RP 0x0004 /* iif toward RP */
#define MRTF_NEW 0x0008 /* new created routing entry */
#define MRTF_IIF_REGISTER 0x0020 /* ??? */
#define MRTF_REGISTER 0x0080 /* ??? */
#define MRTF_KERNEL_CACHE 0x0200 /* a mirror for the kernel cache */
#define MRTF_NULL_OIF 0x0400 /* null oif cache.. ??? */
#define MRTF_REG_SUPP 0x0800 /* register suppress ??? */
#define MRTF_ASSERTED 0x1000 /* upstream is not that of src ??? */
#define MRTF_SG 0x2000 /* (S,G) pure, not hanging off of (*,G)*/
#define MRTF_PMBR 0x4000 /* (*,*,RP) entry (for interop) */
#define MRTF_MFC_CLONE_SG 0x8000 /* clone (S,G) MFC from (*,G) or (*,*,RP) */
#define CREATE TRUE
#define DONT_CREATE FALSE
#define CREATE TRUE
#define DONT_CREATE FALSE
#define MFC_MOVE_FORCE 0x1
#define MFC_UPDATE_FORCE 0x2
#define MFC_MOVE_FORCE 0x1
#define MFC_UPDATE_FORCE 0x2
/* Macro to duplicate oif info (oif bits, timers) */
#define VOIF_COPY(from , to ) \
#define VOIF_COPY(from , to ) \
do { \
IF_COPY(&from->joined_oifs , &to->joined_oifs); \
IF_COPY(&from->oifs ,&to->oifs ); \
@ -105,7 +104,7 @@
} while (0)
#define FREE_MRTENTRY(mrtentry_ptr) \
#define FREE_MRTENTRY(mrtentry_ptr) \
do { \
kernel_cache_t *prev; \
kernel_cache_t *next; \
@ -135,12 +134,12 @@ typedef struct build_jp_message {
u_int32 jp_message_size; /* Size of the Join/Prune message (in bytes) */
u_int16 holdtime; /* Join/Prune message holdtime field */
struct sockaddr_in6 curr_group; /* Current group address */
u_int8 curr_group_msklen; /* Current group masklen */
u_int8 curr_group_msklen; /* Current group masklen */
u_int8 *join_list; /* The working area for the join addresses */
u_int32 join_list_size; /* The size of the join_list (in bytes) */
u_int16 join_addr_number; /* Number of the join addresses in join_list */
u_int8 *prune_list; /* The working area for the prune addresses */
u_int32 prune_list_size; /* The size of the prune_list (in bytes) */
u_int32 prune_list_size; /* The size of the prune_list (in bytes) */
u_int16 prune_addr_number; /* Number of the prune addresses in prune_list*/
u_int8 *rp_list_join; /* The working area for RP join addresses */
u_int32 rp_list_join_size; /* The size of the rp_list_join (in bytes) */
@ -148,21 +147,21 @@ typedef struct build_jp_message {
u_int8 *rp_list_prune; /* The working area for RP prune addresses */
u_int32 rp_list_prune_size; /* The size of the rp_list_prune (in bytes) */
u_int16 rp_list_prune_number; /* Number of RP addresses in rp_list_prune */
u_int8 *num_groups_ptr; /* Pointer to number_of_groups in jp_message */
u_int8 *num_groups_ptr; /* Pointer to number_of_groups in jp_message */
} build_jp_message_t;
typedef struct pim_nbr_entry {
struct pim_nbr_entry *next; /* link to next neighbor */
struct pim_nbr_entry *prev; /* link to prev neighbor */
struct pim_nbr_entry *prev; /* link to prev neighbor */
struct sockaddr_in6 address; /* neighbor address */
vifi_t vifi; /* which interface */
u_int16 timer; /* for timing out neighbor */
vifi_t vifi; /* which interface */
u_int16 timer; /* for timing out neighbor */
build_jp_message_t *build_jp_message; /* A structure for fairly
* complicated Join/Prune
* message construction.
*/
} pim_nbr_entry_t;
typedef struct srcentry {
@ -173,8 +172,8 @@ typedef struct srcentry {
vifi_t incoming; /* incoming vif */
struct pim_nbr_entry *upstream; /* upstream router */
u_int32 metric; /* Unicast Routing Metric to the source */
u_int32 preference; /* The metric preference (for assers)*/
u_int16 timer; /* Entry timer??? Delete? */
u_int32 preference; /* The metric preference (for assers)*/
u_int16 timer; /* Entry timer??? Delete? */
struct cand_rp *cand_rp; /* Used if this is rpentry_t */
} srcentry_t;
typedef srcentry_t rpentry_t;
@ -204,13 +203,13 @@ typedef struct rp_grp_entry {
struct rp_grp_entry *rp_grp_prev; /* Prev entry for same RP */
struct rp_grp_entry *grp_rp_next; /* Next entry for same grp prefix */
struct rp_grp_entry *grp_rp_prev; /* Prev entry for same grp prefix */
struct grpentry *grplink; /* Link to all grps via this entry*/
struct grpentry *grplink; /* Link to all grps via this entry*/
u_int16 advholdtime; /* The advertised holdtime */
u_int16 holdtime; /* The RP holdtime (will be aged) */
u_int16 fragment_tag; /* The fragment tag from the
* received BSR message
*/
u_int8 priority; /* The RP priority */
grp_mask_t *group; /* Pointer to (group,mask) entry */
cand_rp_t *rp; /* Pointer to the RP */
@ -250,7 +249,7 @@ typedef struct mrtentry {
u_int32 metric; /* Routing Metric for this entry */
u_int32 preference; /* The metric preference value */
struct sockaddr_in6 pmbr_addr; /* The PMBR address (for interop) */
u_int16 *vif_timers; /* vifs timer list */
u_int16 *vif_timers; /* vifs timer list */
u_int16 *vif_deletion_delay; /* vifs deletion delay list */
u_int16 flags; /* The MRTF_* flags */
@ -277,7 +276,7 @@ typedef struct mrtentry {
struct sg_count {
u_quad_t pktcnt; /* Number of packets for (s,g) */
u_quad_t bytecnt; /* Number of bytes for (s,g) */
u_quad_t wrong_if; /* Number of packets received on wrong iif for (s,g) */
u_quad_t wrong_if; /* Number of packets received on wrong iif for (s,g) */
};
/*
@ -311,17 +310,17 @@ struct vif_count {
u_long ocount; /* Output packet count on vif */
u_long ibytes; /* Input byte count on vif */
u_long obytes; /* Output byte count on vif */
};
};
/* globals and functions exportations */
extern srcentry_t *srclist;
extern grpentry_t *grplist;
extern void init_pim6_mrt __P(());
extern void init_pim6_mrt __P((void));
extern mrtentry_t *find_route __P((struct sockaddr_in6 *source,
struct sockaddr_in6 *group,
u_int16 flags, char create));
u_int16 flags, char create));
extern grpentry_t *find_group __P((struct sockaddr_in6 *group));
extern srcentry_t *find_source __P((struct sockaddr_in6 *source));
extern void delete_mrtentry __P((mrtentry_t *mrtentry_ptr));

View File

@ -11,7 +11,7 @@
# 3. Neither the name of the project 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 PROJECT 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
@ -35,15 +35,15 @@
# documentation, and that any documentation, advertising materials,
# and other materials related to such distribution and use acknowledge
# that the software was developed by the University of Oregon.
# The name of the University of Oregon may not be used to endorse or
# promote products derived from this software without specific prior
# The name of the University of Oregon may not be used to endorse or
# promote products derived from this software without specific prior
# written permission.
#
# THE UNIVERSITY OF OREGON DOES NOT MAKE ANY REPRESENTATIONS
# ABOUT THE SUITABILITY OF THIS SOFTWARE FOR ANY PURPOSE. THIS SOFTWARE IS
# PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
# INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, TITLE, AND
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, TITLE, AND
# NON-INFRINGEMENT.
#
# IN NO EVENT SHALL UO, OR ANY OTHER CONTRIBUTOR BE LIABLE FOR ANY
@ -55,17 +55,17 @@
# noted when applicable.
#
#
# Questions concerning this software should be directed to
# Questions concerning this software should be directed to
# Kurt Windisch (kurtw@antc.uoregon.edu)
#
# $Id: Makefile,v 1.2 1999/09/13 01:23:22 jinmei Exp $
# $Id: Makefile,v 1.3 2000/02/25 06:35:42 itojun Exp $
# $FreeBSD$
#
#
#Part of this program has been derived from PIM sparse-mode pimd.
#The pimd program is covered by the license in the accompanying file
#named "LICENSE.pimd".
#
#
#The pimd program is COPYRIGHT 1998 by University of Southern California.
#
#Part of this program has been derived from mrouted.
@ -78,9 +78,8 @@
PROG= mtrace6
CFLAGS+=-Wall
CFLAGS+= -I$(.CURDIR)/..
CFLAGS+= -I$(.CURDIR)/.. -DHAVE_GETIFADDRS
MAN8= mtrace6.8
.include <bsd.prog.mk>

View File

@ -1,6 +1,6 @@
.\" Copyright (C) 1999 WIDE Project.
.\" All rights reserved.
.\"
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
@ -12,7 +12,7 @@
.\" 3. Neither the name of the project 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 PROJECT 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
@ -26,7 +26,7 @@
.\" SUCH DAMAGE.
.\"
.\" $Id: mtrace6.8,v 1.3 1999/09/12 17:03:18 jinmei Exp $
.\" $FreeBSD$
.\" $FreeBSD$
.\"
.Dd Sep 12, 1999
.Dt MTRACE6 8
@ -50,8 +50,7 @@ a receiver
.Sh DESCRIPTION
.Nm
utilizes a tracing feature implemented in multicast routers that is
accessed via an extension to the MLD protocol.
A trace query is
accessed via an extension to the MLD protocol. A trace query is
passed hop-by-hop along the reverse path from the
.Ar destination
to the
@ -63,7 +62,7 @@ along the path, and then the response is returned to the requestor.
.It Fl d Ar destination
Specifies the multicast receiver that the query wants to trace.
It is the host running
.Nm
.Nm mtrace6
by default.
.It Fl g Ar gateway
Send the trace query via unicast directly to the multicast router
@ -75,8 +74,7 @@ can also be a multicast address that the last hop router joins.
.It Fl h Ar hops
Set
.Ar hops
to the IPv6 hop limit field of query packets.
The default is 64.
to the IPv6 hop limit field of query packets. The default is 64.
.It Fl i Ar interface
Specifies the local interface (on a multi-homed host) for sending
the trace query and as the default for the receiver and the response
@ -85,8 +83,7 @@ destination.
Set to
.Ar maxhops
to the maximum number of hops that will be traced from the receiver
back toward the source.
The default is 127 hops.
back toward the source. The default is 127 hops.
.It Fl n
Print hop addresses numerically rather than symbolically and numerically
(saves a nameserver address-to-name lookup for each router found on
@ -94,20 +91,18 @@ the path).
.It Fl r Ar response_addr
Specify the host that the trace response sends to.
By default, the response will send to the host running
.Nm Ns .
.Nm mtrace6 .
.It Fl w Ar waittime
Set the time to wait for a trace response to
Set the time to wait for a trace response to
.Ar waittime
seconds.
The default is 3 seconds.
seconds. The default is 3 seconds.
.El
.Sh SEE ALSO
.Xr mtrace 8 ,
.Xr pim6dd 8 ,
.Xr pim6sd 8
.Xr pim6sd 8 ,
.Xr mtrace 8
.Sh BUGS
Multicast trace for IPv6 is experimental.
MLD types for query and
Multicast trace for IPv6 is experimental. MLD types for query and
response, and packet format are not officially defined.
.Pp
.Ar waittime
@ -116,7 +111,7 @@ specified by the
option is currently meaningless.
.Sh HISTORY
The
.Nm
.Nm mtrace6
command first appeared in WIDE/KAME IPv6 protocol stack kit.
.Pp
IPv6 and IPsec support based on the KAME Project (http://www.kame.net/) stack

View File

@ -1,7 +1,7 @@
/*
* Copyright (C) 1999 WIDE Project.
* All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@ -13,7 +13,7 @@
* 3. Neither the name of the project 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 PROJECT 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
@ -42,9 +42,8 @@
#include <netinet/in.h>
#include <netinet6/in6.h>
#include <netinet6/in6_var.h>
#include <netinet6/icmp6.h>
#include <netinet/icmp6.h>
#include <string.h>
#include <stdio.h>
@ -52,17 +51,39 @@
#include <stdlib.h>
#include <netdb.h>
#include <err.h>
#ifdef HAVE_GETIFADDRS
#include <ifaddrs.h>
#endif
#include "trace.h"
static void usage(), open_socket(), make_packet(), mtrace_loop(), show_result();
static char *gateway, *intface, *source, *group, *receiver, *destination;
static int mldsoc, hops = 64, maxhops = 127, waittime = 3, querylen, opt_n;
static struct sockaddr *gw_sock, *src_sock, *grp_sock, *dst_sock, *rcv_sock;
static struct sockaddr *gw_sock, *src_sock, *grp_sock, *dst_sock, *rcv_sock;
static char *querypacket;
static char frombuf[1024]; /* XXX: enough size? */
int main __P((int, char *[]));
static char *proto_type __P((u_int));
static char *pr_addr __P((struct sockaddr *, int));
static void setqid __P((int, char *));
static void mtrace_loop __P((void));
static char *str_rflags __P((int));
static void show_ip6_result __P((struct sockaddr_in6 *, int));
static void show_result __P((struct sockaddr *, int));
static void set_sockaddr __P((char *, struct addrinfo *, struct sockaddr *));
static int is_multicast __P((struct sockaddr *));
static char *all_routers_str __P((int));
static int ip6_validaddr __P((char *, struct sockaddr_in6 *));
static int get_my_sockaddr __P((int, struct sockaddr *));
static void set_hlim __P((int, struct sockaddr *, int));
static void set_join __P((int, char *, struct sockaddr *));
static void set_filter __P((int, int));
static void open_socket __P((void));
static void make_ip6_packet __P((void));
static void make_packet __P((void));
static void usage __P((void));
int
main(argc, argv)
int argc;
@ -126,6 +147,8 @@ main(argc, argv)
make_packet();
mtrace_loop();
exit(0);
/*NOTREACHED*/
}
static char *
@ -159,7 +182,7 @@ proto_type(type)
static char *
pr_addr(addr, numeric)
struct sockaddr_in6 *addr;
struct sockaddr *addr;
int numeric;
{
static char buf[MAXHOSTNAMELEN];
@ -169,8 +192,7 @@ pr_addr(addr, numeric)
flag |= NI_NUMERICHOST;
flag |= NI_WITHSCOPEID;
getnameinfo((struct sockaddr *)addr, addr->sin6_len, buf, sizeof(buf),
NULL, 0, flag);
getnameinfo(addr, addr->sa_len, buf, sizeof(buf), NULL, 0, flag);
return (buf);
}
@ -314,8 +336,8 @@ show_ip6_result(from6, datalen)
printf("%3d ", -i);/* index */
/* router address and incoming/outgoing interface */
printf("%s", pr_addr((struct sockaddr *)&sa_resp, opt_n));
printf("(%s/%ld->%ld) ",
pr_addr((struct sckaddr *)&sa_upstream),
printf("(%s/%d->%d) ",
pr_addr((struct sockaddr *)&sa_upstream, 1),
ntohl(rp->tr_inifid), ntohl(rp->tr_outifid));
/* multicast routing protocol type */
printf("%s ", proto_type(rp->tr_rproto));
@ -394,7 +416,7 @@ all_routers_str(family)
}
}
int
static int
ip6_validaddr(ifname, addr)
char *ifname;
struct sockaddr_in6 *addr;
@ -426,12 +448,39 @@ ip6_validaddr(ifname, addr)
return(1);
}
int
static int
get_my_sockaddr(family, addrp)
int family;
struct sockaddr *addrp;
{
#define IF_BUFSIZE 8192 /* XXX: adhoc...should be customizable? */
#ifdef HAVE_GETIFADDRS
struct ifaddrs *ifap, *ifa;
if (getifaddrs(&ifap) != 0) {
err(1, "getifaddrs");
/*NOTREACHED */
}
for (ifa = ifap; ifa; ifa = ifa->ifa_next) {
if (ifa->ifa_addr->sa_family == family) {
switch(family) {
case AF_INET6:
if (ip6_validaddr(ifa->ifa_name,
(struct sockaddr_in6 *)ifa->ifa_addr))
goto found;
}
}
}
freeifaddrs(ifap);
return (-1); /* not found */
found:
memcpy((void *)addrp, (void *)ifa->ifa_addr, ifa->ifa_addr->sa_len);
freeifaddrs(ifap);
return (0);
#else
#define IF_BUFSIZE 8192 /* XXX: adhoc...should be customizable? */
int i, s;
struct ifconf ifconf;
struct ifreq *ifrp;
@ -471,7 +520,8 @@ get_my_sockaddr(family, addrp)
found:
memcpy((void *)addrp, (void *)&ifrp->ifr_addr, ifrp->ifr_addr.sa_len);
return(0);
#undef IF_BUFSIZE
#undef IF_BUFSIZE
#endif
}
static void
@ -504,7 +554,7 @@ set_join(s, ifname, group)
{
struct ipv6_mreq mreq6;
u_int ifindex;
switch(group->sa_family) {
case AF_INET6:
if ((ifindex = if_nametoindex(ifname)) == 0)
@ -522,6 +572,7 @@ set_join(s, ifname, group)
static void
set_filter(s, family)
int s, family;
{
struct icmp6_filter filter6;
@ -595,7 +646,7 @@ open_socket()
#else
errx(1, "receive I/F is not specified for multicast"
"response(%s)", receiver);
#endif
#endif
}
}
else {
@ -655,7 +706,8 @@ make_packet()
static void
usage()
{
errx(1,
fprintf(stderr, "usage: mtrace6 %s\n",
"[-d destination] [-g gateway] [-h hops] [-i interface] "
"[-m maxhops] [-n] [-r response_addr] [-w waittime] source group");
exit(1);
}

View File

@ -29,8 +29,6 @@
*
* Other copyrights might apply to parts of this software and are so
* noted when applicable.
*
* $FreeBSD$
*/
/*
* Questions concerning this software should be directed to
@ -38,12 +36,12 @@
*
*/
/*
* This program has been derived from pim6dd.
* This program has been derived from pim6dd.
* The pim6dd program is covered by the license in the accompanying file
* named "LICENSE.pim6dd".
*/
/*
* This program has been derived from pimd.
* This program has been derived from pimd.
* The pimd program is covered by the license in the accompanying file
* named "LICENSE.pimd".
*
@ -56,13 +54,14 @@
* The mrouted program is COPYRIGHT 1989 by The Board of Trustees of
* Leland Stanford Junior University.
*
* $FreeBSD$
*/
#ifndef PATHNAMES_H
#define PATHNAMES_H
#define PATHNAMES_H
#define _PATH_PIM6D_CONF "/etc/pim6sd.conf"
#define _PATH_PIM6D_LOGFILE "/var/log/pim6sd.log"
#define _PATH_PIM6D_CONF "/etc/pim6sd.conf"
#define _PATH_PIM6D_LOGFILE "/var/log/pim6sd.log"
#if (defined(BSD) && (BSD >= 199103))
#define _PATH_PIM6D_PID "/var/run/pim6sd.pid"

View File

@ -53,8 +53,6 @@
* 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.
*
* $FreeBSD$
*/
/*
* Questions concerning this software should be directed to
@ -62,15 +60,16 @@
*
*/
/*
* This program has been derived from pim6dd.
* This program has been derived from pim6dd.
* The pim6dd program is covered by the license in the accompanying file
* named "LICENSE.pim6dd".
*/
/*
* This program has been derived from pimd.
* This program has been derived from pimd.
* The pimd program is covered by the license in the accompanying file
* named "LICENSE.pimd".
*
* $FreeBSD$
*/
#include <sys/param.h>
@ -106,11 +105,13 @@ static struct iovec sndiovpim[2];
static struct iovec rcviovpim[2];
static struct msghdr sndmhpim,
rcvmhpim;
static u_char sndcmsgbufpim[CMSG_SPACE(sizeof(struct in6_pktinfo))];
static u_char rcvcmsgbufpim[CMSG_SPACE(sizeof(struct in6_pktinfo))];
static u_char *sndcmsgbufpim = NULL;
static int sndcmsglen;
static u_char *rcvcmsgbufpim = NULL;
static int rcvcmsglen;
/*
/*
* Local function definitions.
*/
static void pim6_read __P((int f, fd_set *rfd));
@ -120,7 +121,8 @@ static int pim6_cksum __P((u_short *, struct in6_addr *,
void init_pim6()
void
init_pim6()
{
struct cmsghdr *cmsgp;
int on;
@ -162,7 +164,7 @@ void init_pim6()
if (setsockopt(pim6_socket, IPPROTO_IPV6, IPV6_PKTINFO, &on,
sizeof(on)) < 0)
log(LOG_ERR, errno, "setsockopt(IPV6_PKTINFO)");
#endif
#endif
/* initialize msghdr for receiving packets */
rcviovpim[0].iov_base = (caddr_t) pim6_recv_buf;
@ -171,21 +173,28 @@ void init_pim6()
rcvmhpim.msg_namelen = sizeof (from);
rcvmhpim.msg_iov = rcviovpim;
rcvmhpim.msg_iovlen = 1;
rcvcmsglen = CMSG_SPACE(sizeof(struct in6_pktinfo));
if (rcvcmsgbufpim == NULL &&
(rcvcmsgbufpim = malloc(rcvcmsglen)) == NULL)
log(LOG_ERR, 0, "malloc failed");
rcvmhpim.msg_control = (caddr_t ) rcvcmsgbufpim;
rcvmhpim.msg_controllen = sizeof (rcvcmsgbufpim);
rcvmhpim.msg_controllen = rcvcmsglen;
sndmhpim.msg_namelen=sizeof(struct sockaddr_in6);
sndmhpim.msg_iov=sndiovpim;
sndmhpim.msg_iovlen=1;
sndmhpim.msg_control=(caddr_t)sndcmsgbufpim;
sndmhpim.msg_controllen=sizeof(sndcmsgbufpim);
sndcmsglen = CMSG_SPACE(sizeof(struct in6_pktinfo));
if (sndcmsgbufpim == NULL &&
(sndcmsgbufpim = malloc(sndcmsglen)) == NULL)
log(LOG_ERR, 0, "malloc failed");
sndmhpim.msg_control = (caddr_t)sndcmsgbufpim;
sndmhpim.msg_controllen = sndcmsglen;
cmsgp=(struct cmsghdr *)sndcmsgbufpim;
cmsgp->cmsg_len=CMSG_SPACE(sizeof(struct in6_pktinfo));
cmsgp->cmsg_level=IPPROTO_IPV6;
cmsgp->cmsg_type=IPV6_PKTINFO;
cmsgp->cmsg_len = CMSG_LEN(sizeof(struct in6_pktinfo));
cmsgp->cmsg_level = IPPROTO_IPV6;
cmsgp->cmsg_type = IPV6_PKTINFO;
if ( register_input_handler(pim6_socket, pim6_read) <0)
if ( register_input_handler(pim6_socket, pim6_read) <0)
log(LOG_ERR,0,"Registering pim6 socket");
/* Initialize the building Join/Prune messages working area */
@ -238,12 +247,12 @@ pim6_read(f, rfd)
static void
accept_pim6(pimlen)
int pimlen;
{
{
register struct pim *pim;
struct sockaddr_in6 dst;
struct in6_pktinfo *pi=NULL;
struct sockaddr_in6 *src = (struct sockaddr_in6 *)rcvmhpim.msg_name;
struct cmsghdr *cm;
struct cmsghdr *cm;
int ifindex=0;
/* sanity check */
@ -273,15 +282,15 @@ accept_pim6(pimlen)
else
dst.sin6_scope_id = 0;
}
}
}
if(pi==NULL)
log(LOG_ERR,0,"pim6_socket : unable to get destination packet");
if(ifindex==0)
log(LOG_ERR,0,"pim6_socket : unable to get ifindex");
#define NOSUCHDEF
#define NOSUCHDEF
#ifdef NOSUCHDEF /* TODO: delete. Too noisy */
IF_DEBUG(DEBUG_PIM_DETAIL) {
IF_DEBUG(DEBUG_PIM) {
@ -291,10 +300,10 @@ accept_pim6(pimlen)
}
}
#endif /* NOSUCHDEF */
/* Check of PIM version is already done in the kernel */
/*
* TODO: check the dest. is ALL_PIM_ROUTERS (if multicast address)
* is it necessary?
@ -306,10 +315,10 @@ accept_pim6(pimlen)
receive_pim6_hello(src, (char *)(pim), pimlen);
break;
case PIM_REGISTER:
receive_pim6_register(src, &dst, (char *)(pim), pimlen);
receive_pim6_register(src, &dst, (char *)(pim), pimlen);
break;
case PIM_REGISTER_STOP:
receive_pim6_register_stop(src, &dst, (char *)(pim), pimlen);
receive_pim6_register_stop(src, &dst, (char *)(pim), pimlen);
break;
case PIM_JOIN_PRUNE:
receive_pim6_join_prune(src, &dst, (char *)(pim), pimlen);
@ -342,7 +351,7 @@ accept_pim6(pimlen)
inet6_fmt(&src->sin6_addr));
break;
}
}
}
void
send_pim6(char *buf, struct sockaddr_in6 *src,
@ -370,7 +379,7 @@ send_pim6(char *buf, struct sockaddr_in6 *src,
if(pim->pim_type == PIM_REGISTER)
{
sendlen = sizeof(struct pim)+sizeof(pim_register_t);
}
pim->pim_cksum = pim6_cksum((u_int16 *)pim,
@ -405,24 +414,26 @@ send_pim6(char *buf, struct sockaddr_in6 *src,
}
else
{
sndmhpim.msg_control=(caddr_t)sndcmsgbufpim;
sndmhpim.msg_controllen=sizeof(sndcmsgbufpim);
sndmhpim.msg_control = (caddr_t)sndcmsgbufpim;
sndmhpim.msg_controllen = sndcmsglen;
sndpktinfo->ipi6_ifindex=src->sin6_scope_id;
memcpy(&sndpktinfo->ipi6_addr, &src->sin6_addr,
sizeof(sndpktinfo->ipi6_addr));
}
if( sendmsg(pim6_socket, &sndmhpim, 0) <0 )
if (errno == ENETDOWN)
check_vif_state();
else
log(LOG_WARNING, errno, "sendmsg from %s to %s",
inet6_fmt(&src->sin6_addr),
inet6_fmt(&dst->sin6_addr));
if (sendmsg(pim6_socket, &sndmhpim, 0) < 0) {
if (errno == ENETDOWN)
check_vif_state();
else {
log(LOG_WARNING, errno, "sendmsg from %s to %s",
inet6_fmt(&src->sin6_addr),
inet6_fmt(&dst->sin6_addr));
}
}
if(setloop)
k_set_loop(pim6_socket, FALSE);
return;
return;
}
/* ============================== */
@ -434,37 +445,37 @@ send_pim6(char *buf, struct sockaddr_in6 *src,
* code and should be modified for each CPU to be as fast as possible.
*/
#define ADDCARRY(x) (x > 65535 ? x -= 65535 : x)
#define REDUCE {l_util.l = sum; sum = l_util.s[0] + l_util.s[1]; ADDCARRY(sum);}
static union {
u_short phs[4];
#define ADDCARRY(x) (x > 65535 ? x -= 65535 : x)
#define REDUCE {l_util.l = sum; sum = l_util.s[0] + l_util.s[1]; ADDCARRY(sum);}
static union {
u_short phs[4];
struct {
u_long ph_len;
u_long ph_len;
u_char ph_zero[3];
u_char ph_nxt;
} ph;
u_char ph_nxt;
} ph;
} uph;
/*
/*
* Our algorithm is simple, using a 32 bit accumulator (sum), we add
* sequential 16 bit words to it, and at the end, fold back all the
* sequential 16 bit words to it, and at the end, fold back all the
* carry bits from the top 16 bits into the lower 16 bits.
*/
*/
int pim6_cksum(u_short *addr, struct in6_addr *src ,struct in6_addr *dst , int len )
{
{
register int nleft = len;
register u_short *w;
register int sum = 0;
u_short answer = 0;
/*
* First create IP6 pseudo header and calculate a summary.
*/
*/
w = (u_short *)src;
uph.ph.ph_len = htonl(len);
uph.ph.ph_nxt = IPPROTO_PIM;
/* IPv6 source address */
sum += w[0];
/* XXX: necessary? */
@ -483,7 +494,7 @@ int pim6_cksum(u_short *addr, struct in6_addr *src ,struct in6_addr *dst , int l
/* Payload length and upper layer identifier */
sum += uph.phs[0]; sum += uph.phs[1];
sum += uph.phs[2]; sum += uph.phs[3];
/*
* Secondly calculate a summary of the first mbuf excluding offset.
*/
@ -492,16 +503,16 @@ int pim6_cksum(u_short *addr, struct in6_addr *src ,struct in6_addr *dst , int l
sum += *w++;
nleft -= 2;
}
/* mop up an odd byte, if necessary */
if (nleft == 1) {
*(u_char *)(&answer) = *(u_char *)w ;
sum += answer;
}
/* add back carry outs from top 16 bits to low 16 bits */
sum = (sum >> 16) + (sum & 0xffff); /* add hi 16 to low 16 */
sum += (sum >> 16); /* add carry */
answer = ~sum; /* truncate to 16 bits */
return(answer);
}
}

View File

@ -25,8 +25,6 @@
* 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.
*
* $FreeBSD$
*/
/*
* Questions concerning this software should be directed to
@ -34,20 +32,21 @@
*
*/
/*
* This program has been derived from pim6dd.
* This program has been derived from pim6dd.
* The pim6dd program is covered by the license in the accompanying file
* named "LICENSE.pim6dd".
*/
/*
* This program has been derived from pimd.
* This program has been derived from pimd.
* The pimd program is covered by the license in the accompanying file
* named "LICENSE.pimd".
*
* $FreeBSD$
*/
#ifndef PIM6_H
#define PIM6_H
#define PIM6_H
#include <sys/param.h>
#include <sys/types.h>
@ -61,9 +60,9 @@ extern struct sockaddr_in6 allpim6routers_group;
extern char *pim6_send_buf;
extern int pim6_socket;
void init_pim6();
void init_pim6 __P((void));
extern void send_pim6 __P((char *buf, struct sockaddr_in6 *src,
struct sockaddr_in6 *dst, int type,
struct sockaddr_in6 *dst, int type,
int datalen));

View File

@ -85,8 +85,6 @@
*
* Other copyrights might apply to parts of this software and are so
* noted when applicable.
*
* $FreeBSD$
*/
/*
* Questions concerning this software should be directed to
@ -94,15 +92,16 @@
*
*/
/*
* This program has been derived from pim6dd.
* This program has been derived from pim6dd.
* The pim6dd program is covered by the license in the accompanying file
* named "LICENSE.pim6dd".
*/
/*
* This program has been derived from pimd.
* This program has been derived from pimd.
* The pimd program is covered by the license in the accompanying file
* named "LICENSE.pimd".
*
* $FreeBSD$
*/
#include <sys/types.h>
@ -134,11 +133,11 @@
static int parse_pim6_hello __P((char *pktPtr , int datalen , struct sockaddr_in6 *src,
u_int16 *holdtime));
static int send_pim6_register_stop __P((struct sockaddr_in6 *reg_src , struct sockaddr_in6 *reg_dst ,
static int send_pim6_register_stop __P((struct sockaddr_in6 *reg_src , struct sockaddr_in6 *reg_dst ,
struct sockaddr_in6 *inner_source,
struct sockaddr_in6 *inner_grp));
static build_jp_message_t *get_jp6_working_buff __P(());
static build_jp_message_t *get_jp6_working_buff __P((void));
static void return_jp6_working_buff __P((pim_nbr_entry_t * pim_nbr));
static void pack_jp6_message __P((pim_nbr_entry_t * pim_nbr));
static void send_jp6_message __P((pim_nbr_entry_t * pim_nbr));
@ -215,9 +214,9 @@ receive_pim6_hello(src, pim_message, datalen)
* translate the addresses in host order.
*/
if (inet6_lessthan(src, &nbr->address))
if (inet6_lessthan(src, &nbr->address))
continue;
if (inet6_equal(src, &nbr->address))
if (inet6_equal(src, &nbr->address))
{
/* We already have an entry for this host */
@ -322,8 +321,6 @@ receive_pim6_hello(src, pim_message, datalen)
}
}
v->uv_flags &= ~VIFF_DR;
v->uv_flags &= ~VIFF_QUERIER;
}
}
@ -374,16 +371,13 @@ delete_pim6_nbr(nbr_delete)
}
else
{
if (inet6_greaterthan(&v->uv_linklocal->pa_addr,
&v->uv_pim_neighbors->address))
if (inet6_greaterthan(&v->uv_linklocal->pa_addr,
&v->uv_pim_neighbors->address))
/*
* The first address is the new potential remote DR address, but
* the local address is the winner.
*/
v->uv_flags |= VIFF_DR;
v->uv_flags |= VIFF_QUERIER;
}
/* Update the source entries */
@ -712,7 +706,7 @@ receive_pim6_register(reg_src, reg_dst, pim_message, datalen)
SET_TIMER(mrtentry_ptr->timer, pim_data_timeout); /* restart timer */
if (!(mrtentry_ptr->flags & MRTF_SPT))
{
{
/* The SPT bit is not set */
if (!nullRegisterBit)
@ -902,7 +896,7 @@ send_pim6_register(pkt)
char *buf;
ip6=(struct ip6_hdr *)pkt;
group.sin6_addr = ip6->ip6_dst;
source.sin6_addr = ip6->ip6_src;
@ -1017,7 +1011,7 @@ send_pim6_null_register(mrtentry_ptr)
dest = &mrtentry_ptr->group->rpaddr;
reg_source = max_global_address();
send_pim6(pim6_send_buf, reg_source , dest, PIM_REGISTER,
pktlen);
pim6dstat.out_pim6_register++; /* should be counted separately? */
@ -1091,15 +1085,15 @@ receive_pim6_register_stop(reg_src, reg_dst, pim_message, datalen)
inet6_fmt(&encod_unisrc.unicast_addr));
}
return FALSE;
}
}
v=&uvifs[mifi];
v=&uvifs[mifi];
group.sin6_scope_id = inet6_uvif2scopeid(&group, v);
source.sin6_scope_id = inet6_uvif2scopeid(&source,
v);
IF_DEBUG(DEBUG_PIM_REGISTER)
{
@ -1135,7 +1129,7 @@ receive_pim6_register_stop(reg_src, reg_dst, pim_message, datalen)
}
/* restart the Register-Suppression timer */
SET_TIMER(mrtentry_ptr->rs_timer, (0.5 * pim_register_suppression_timeout)
+ (RANDOM() % (pim_register_suppression_timeout + 1)));
/* Prune the register_vif from the outgoing list */
@ -1171,7 +1165,7 @@ send_pim6_register_stop(reg_src, reg_dst, inner_grp, inner_src)
send_pim6(pim6_send_buf, reg_src , reg_dst , PIM_REGISTER_STOP,
data_ptr-(u_int8 *) buf);
pim6dstat.out_pim6_register_stop++;
return (TRUE);
}
@ -1217,7 +1211,7 @@ join_or_prune(mrtentry_ptr, upstream_router)
{
/* I am not the DR for that subnet. */
return (PIM_ACTION_PRUNE);
}
}
if (IF_ISSET(mrtentry_ptr->incoming, &mrtentry_ptr->leaves))
/* I am the DR and have local leaves */
return (PIM_ACTION_JOIN);
@ -1288,7 +1282,7 @@ join_or_prune(mrtentry_ptr, upstream_router)
}
/* TODO: too long, simplify it! */
#define PIM6_JOIN_PRUNE_MINLEN (4 + PIM6_ENCODE_UNI_ADDR_LEN + 4)
#define PIM6_JOIN_PRUNE_MINLEN (4 + PIM6_ENCODE_UNI_ADDR_LEN + 4)
int
receive_pim6_join_prune(src, dst, pim_message, datalen)
@ -1440,13 +1434,13 @@ receive_pim6_join_prune(src, dst, pim_message, datalen)
GET_HOSTSHORT(num_j_srcs, data_ptr);
GET_HOSTSHORT(num_p_srcs, data_ptr);
if (encod_group.masklen > (sizeof(struct in6_addr) << 3))
continue;
continue;
MASKLEN_TO_MASK6(encod_group.masklen, g_mask);
group.sin6_addr = encod_group.mcast_addr;
group.sin6_scope_id = inet6_uvif2scopeid(&group, v);
if (!IN6_IS_ADDR_MULTICAST(&group.sin6_addr))
{
if (!IN6_IS_ADDR_MULTICAST(&group.sin6_addr))
{
data_ptr +=
(num_j_srcs + num_p_srcs) * sizeof(pim6_encod_src_addr_t);
continue; /* Ignore this group and jump to the next */
@ -1469,7 +1463,7 @@ receive_pim6_join_prune(src, dst, pim_message, datalen)
if (encod_src.masklen >
(sizeof(struct in6_addr) << 3))
continue;
s_flags = encod_src.flags;
MASKLEN_TO_MASK6(encod_src.masklen, s_mask);
@ -1523,7 +1517,7 @@ receive_pim6_join_prune(src, dst, pim_message, datalen)
source.sin6_addr = encod_src.src_addr;
source.sin6_scope_id = inet6_uvif2scopeid(&source,
v);
if (!inet6_valid_host(&source))
continue;
@ -1794,7 +1788,7 @@ receive_pim6_join_prune(src, dst, pim_message, datalen)
* Join and the ~(S,G) prune are in the same message, ~(S,G) has the
* priority. The spec doesn't say it, but I think the same is true for
* (*,*,RP) and ~(S,G) prunes.
*
*
* The code below do: (1) Check the whole message for (*,*,RP) Joins. (1.1)
* If found, clean all pruned_oifs for all (*,G) and all (S,G) for each
* RP in the list, but do not update the kernel cache. Then go back to
@ -1809,7 +1803,7 @@ receive_pim6_join_prune(src, dst, pim_message, datalen)
* (kernel). (3.3) After the Prune part is processed, process the Join
* part normally (by applying any changes to the kernel) (4) If there
* were (*,*,RP) Join/Prune, process them.
*
*
* If the Join/Prune list is too long, it may result in long processing
* overhead. The idea above is not to place any wrong info in the kernel,
* because it may result in short-time existing traffic forwarding on
@ -1823,7 +1817,7 @@ receive_pim6_join_prune(src, dst, pim_message, datalen)
num_groups_tmp = num_groups;
data_ptr_start = data_ptr;
star_star_rp_found = FALSE; /* Indicating whether we have (*,*,RP) join */
IF_DEBUG(DEBUG_PIM_JOIN_PRUNE)
log(LOG_DEBUG,0,"Number of groups to process : %d",num_groups_tmp);
@ -1908,13 +1902,13 @@ receive_pim6_join_prune(src, dst, pim_message, datalen)
GET_HOSTSHORT(num_p_srcs, data_ptr);
group.sin6_addr = encod_group.mcast_addr;
group.sin6_scope_id = inet6_uvif2scopeid(&group, v);
IF_DEBUG(DEBUG_PIM_JOIN_PRUNE)
{
log(LOG_DEBUG,0,"Group to process : %s",inet6_fmt(&encod_group.mcast_addr));
log(LOG_DEBUG,0,"Number of join : %d",num_j_srcs );
log(LOG_DEBUG,0,"Number of prune : %d",num_p_srcs );
}
}
if (!IN6_IS_ADDR_MULTICAST(&group.sin6_addr))
{
@ -1959,7 +1953,7 @@ receive_pim6_join_prune(src, dst, pim_message, datalen)
GET_ESADDR6(&encod_src, data_ptr);
source.sin6_addr=encod_src.src_addr;
source.sin6_scope_id = inet6_uvif2scopeid(&source,v);
if ((encod_src.flags & USADDR_RP_BIT)
&& (encod_src.flags & USADDR_WC_BIT))
{
@ -1969,7 +1963,7 @@ receive_pim6_join_prune(src, dst, pim_message, datalen)
* pruned_oifs for all (S,G) entries.
*/
if(!inet6_equal(&rpentry_ptr->address, &source))
if(!inet6_equal(&rpentry_ptr->address, &source))
{
ignore_group = TRUE;
IF_DEBUG(DEBUG_PIM_JOIN_PRUNE)
@ -2002,7 +1996,7 @@ receive_pim6_join_prune(src, dst, pim_message, datalen)
{
GET_ESADDR6(&encod_src, data_ptr);
source.sin6_addr = encod_src.src_addr;
source.sin6_scope_id = inet6_uvif2scopeid(&source, v);
source.sin6_scope_id = inet6_uvif2scopeid(&source, v);
if (!inet6_valid_host(&source))
continue;
@ -2136,7 +2130,7 @@ receive_pim6_join_prune(src, dst, pim_message, datalen)
* not match the local RP-map, then ignore the whole
* group, not only this particular (*,G) prune.
*/
if (!inet6_equal(&mrtentry_ptr->group->active_rp_grp->rp->rpentry->address, &source ))
if (!inet6_equal(&mrtentry_ptr->group->active_rp_grp->rp->rpentry->address, &source ))
continue; /* The RP address doesn't match. */
if (v->uv_flags & VIFF_POINT_TO_POINT)
{
@ -2460,7 +2454,7 @@ receive_pim6_join_prune(src, dst, pim_message, datalen)
* we have ~(S,G)RPbit Prune entry, we must include any (*,G) or (*,*,RP)
* Currently the whole table is scanned. In the future will have all routing
* entries linked in a chain with the corresponding upstream pim_nbr_entry.
*
*
* If pim_nbr is not NULL, then send to only this particular PIM neighbor,
*/
int
@ -3404,7 +3398,7 @@ compare_metrics(local_preference, local_metric, local_address,
/************************************************************************
* PIM_BOOTSTRAP
************************************************************************/
#define PIM6_BOOTSTRAP_MINLEN (PIM_MINLEN + PIM6_ENCODE_UNI_ADDR_LEN)
#define PIM6_BOOTSTRAP_MINLEN (PIM_MINLEN + PIM6_ENCODE_UNI_ADDR_LEN)
int
receive_pim6_bootstrap(src, dst, pim_message, datalen)
@ -3480,7 +3474,7 @@ receive_pim6_bootstrap(src, dst, pim_message, datalen)
GET_BYTE(new_bsr_priority, data_ptr);
GET_EUADDR6(&new_bsr_uni_addr, data_ptr);
/*
/*
* BSR address must be a global unicast address.
* [draft-ietf-pim-ipv6-01.txt sec 4.5]
*/
@ -3668,7 +3662,7 @@ receive_pim6_bootstrap(src, dst, pim_message, datalen)
}
max_data_ptr = (u_int8 *) pim_message + datalen;
/*
* TODO: XXX: this 24 is HARDCODING!!! Do a bunch of definitions and make
* it stylish!
@ -3696,6 +3690,15 @@ receive_pim6_bootstrap(src, dst, pim_message, datalen)
GET_BYTE(curr_frag_rp_count, data_ptr);
GET_HOSTSHORT(reserved_short, data_ptr);
MASKLEN_TO_MASK6(curr_group_addr.masklen, curr_group_mask);
if (IN6_IS_ADDR_MC_NODELOCAL(&curr_group_addr.mcast_addr) ||
IN6_IS_ADDR_MC_LINKLOCAL(&curr_group_addr.mcast_addr)) {
log(LOG_WARNING, 0,
"receive_pim6_bootstrap: "
"group prefix has a narraw scope: %s (ignored)",
inet6_fmt(&curr_group_addr.mcast_addr));
continue;
}
if (curr_rp_count == 0)
{
group_.sin6_addr = curr_group_addr.mcast_addr;
@ -3716,7 +3719,7 @@ receive_pim6_bootstrap(src, dst, pim_message, datalen)
if (data_ptr + PIM6_ENCODE_UNI_ADDR_LEN + sizeof(u_int32_t)
> max_data_ptr) {
log(LOG_NOTICE, 0,
"receive_pim6_bootstrap: Bootstrap from %s on %s "
"receive_pim6_bootstrap: Bootstrap from %s on %s "
"does not have enough length to contatin RP information",
inet6_fmt(&src->sin6_addr), v->uv_name);
@ -3752,7 +3755,7 @@ receive_pim6_bootstrap(src, dst, pim_message, datalen)
group_.sin6_len = sizeof(group_);
group_.sin6_family = AF_INET6;
group_.sin6_scope_id = inet6_uvif2scopeid(&group_,v);
add_rp_grp_entry(&cand_rp_list, &grp_mask_list,
&rpp_, curr_rp_priority,
curr_rp_holdtime, &group_,
@ -3772,7 +3775,7 @@ receive_pim6_bootstrap(src, dst, pim_message, datalen)
curr_group_addr.mcast_addr.s6_addr[i]
& curr_group_mask.s6_addr[i];
}
for (grp_mask_ptr = segmented_grp_mask_list;
grp_mask_ptr != (grp_mask_t *) NULL;
grp_mask_ptr = grp_mask_ptr->next)
@ -3783,7 +3786,7 @@ receive_pim6_bootstrap(src, dst, pim_message, datalen)
& grp_mask_ptr->group_mask.s6_addr[i];
}
if (inet6_lessthan(&prefix_h2, &prefix_h))
if (inet6_greaterthan(&prefix_h2, &prefix_h))
continue;
else
break;
@ -3867,7 +3870,7 @@ receive_pim6_bootstrap(src, dst, pim_message, datalen)
}
}
garbage_collect:
/*
* Garbage collection. Check all group prefixes and if the fragment_tag
@ -3948,7 +3951,7 @@ send_pim6_bootstrap()
* length of PIM header + prefix-cnt(1) + priority(1) + holdtime(2) +
* encoded unicast RP addr(18)
*/
#define PIM6_CAND_RP_ADV_MINLEN (PIM_MINLEN + PIM6_ENCODE_UNI_ADDR_LEN)
#define PIM6_CAND_RP_ADV_MINLEN (PIM_MINLEN + PIM6_ENCODE_UNI_ADDR_LEN)
/*
* If I am the Bootstrap router, process the advertisement, otherwise ignore
@ -3973,7 +3976,7 @@ receive_pim6_cand_rp_adv(src, dst, pim_message, datalen)
pim6dstat.in_pim6_cand_rp++;
/* if I am not the bootstrap RP, then do not accept the message */
if ((cand_bsr_flag != FALSE) &&
if ((cand_bsr_flag != FALSE) &&
!inet6_equal(&curr_bsr_address, &my_bsr_address))
{
log(LOG_NOTICE, 0,
@ -4045,7 +4048,7 @@ receive_pim6_cand_rp_adv(src, dst, pim_message, datalen)
return(FALSE);
}
datalen -= PIM6_ENCODE_GRP_ADDR_LEN;
GET_EGADDR6(&encod_grp_addr, data_ptr);
MASKLEN_TO_MASK6(encod_grp_addr.masklen, grp_mask);
group_.sin6_addr = encod_grp_addr.mcast_addr;
@ -4114,7 +4117,7 @@ send_pim6_cand_rp_adv()
}
data_ptr = (u_int8 *) (pim6_send_buf + sizeof(struct pim));
bcopy((char *)cand_rp_adv_message.buffer, (char *) data_ptr,
cand_rp_adv_message.message_size);

View File

@ -29,28 +29,27 @@
*
* Other copyrights might apply to parts of this software and are so
* noted when applicable.
*
* $FreeBSD$
*/
/* Questions concerning this software should be directed to
* Mickael Hoerdt (hoerdt@clarinet.u-strasbg.fr) LSIIT Strasbourg.
*
*/
/*
* This program has been derived from pim6dd.
* This program has been derived from pim6dd.
* The pim6dd program is covered by the license in the accompanying file
* named "LICENSE.pim6dd".
*/
/*
* This program has been derived from pimd.
* This program has been derived from pimd.
* The pimd program is covered by the license in the accompanying file
* named "LICENSE.pimd".
*
* $FreeBSD$
*/
#ifndef PIM6_PROTO_H
#define PIM6_PROTO_H
#define PIM6_PROTO_H
#include "defs.h"
#include "vif.h"
#include "mrt.h"
@ -75,29 +74,29 @@ extern int receive_pim6_register_stop __P((struct sockaddr_in6 *src, struct soc
extern int send_pim6_register __P((char *pkt));
extern int receive_pim6_join_prune __P((struct sockaddr_in6 *src, struct sockaddr_in6 *dst,
char *pim_message, int datalen));
extern int join_or_prune __P((mrtentry_t *mrtentry_ptr,
extern int join_or_prune __P((mrtentry_t *mrtentry_ptr,
pim_nbr_entry_t *upstream_router));
extern int receive_pim6_assert __P((struct sockaddr_in6 *src, struct sockaddr_in6 *dst,
char *pim_message, int datalen));
extern int send_pim6_assert __P((struct sockaddr_in6 *source, struct sockaddr_in6 *group,
vifi_t vifi,
mrtentry_t *mrtentry_ptr));
extern int send_periodic_pim6_join_prune __P((vifi_t vifi,
extern int send_periodic_pim6_join_prune __P((vifi_t vifi,
pim_nbr_entry_t *pim_nbr,
u_int16 holdtime));
extern int add_jp_entry __P((pim_nbr_entry_t *pim_nbr,
u_int16 holdtime, struct sockaddr_in6 *group,
u_int8 grp_msklen, struct sockaddr_in6 *source,
u_int8 grp_msklen, struct sockaddr_in6 *source,
u_int8 src_msklen,
u_int16 addr_flags,
u_int16 addr_flags,
u_int8 join_prune));
extern void pack_and_send_jp6_message __P((pim_nbr_entry_t *pim_nbr));
extern int receive_pim6_cand_rp_adv __P((struct sockaddr_in6 *src, struct sockaddr_in6 *dst,
char *pim_message, int datalen));
extern int receive_pim6_bootstrap __P((struct sockaddr_in6 *src, struct sockaddr_in6 *dst,
char *pim_message, int datalen));
extern int send_pim6_cand_rp_adv __P(());
extern void send_pim6_bootstrap __P(());
extern int send_pim6_cand_rp_adv __P((void));
extern void send_pim6_bootstrap __P((void));
#endif

View File

@ -1,6 +1,6 @@
.\" Copyright (C) 1999 WIDE Project.
.\" All rights reserved.
.\"
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
@ -12,7 +12,7 @@
.\" 3. Neither the name of the project 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 PROJECT 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
@ -25,8 +25,8 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" $Id: pim6sd.8,v 1.4 1999/12/16 05:38:06 jinmei Exp $
.\" $FreeBSD$
.\" $Id: pim6sd.8,v 1.6 2000/05/18 16:11:46 itojun Exp $
.\" $FreeBSD$
.\"
.Dd June 10, 1999
.Dt PIM6SD 8
@ -56,8 +56,7 @@ By default,
.Pa /etc/pim6sd.conf
is used.
.It Fl d
Specify debug levels.
If this option is specified without any arguments,
Specify debug levels. If this option is specified without any arguments,
all debug messages will be printed out.
A subset of the messages to be printed out can be specified
as arguments of the option.
@ -72,12 +71,11 @@ Valid debug levels are
and
.Ic asserts.
.It Fl f
Do not become daemon, run in foreground.
This option is for debugging
Do not become daemon, run in foreground. This option is for debugging
use.
.El
.Pp
.Nm Pim6sd
.Nm Pim6sd
automatically configures itself to forward on all multicast-capable
interfaces, i.e., interfaces that have the IFF_MULTICAST flag set (excluding
the "loopback interface").
@ -99,8 +97,7 @@ signal.
The information includes a list of PIM neighbors,
.Nm
internal multicast routing table, and
BSR and RP related information.
Also, the program dumps its internal
BSR and RP related information. Also, the program dumps its internal
statistics to a file when it receives a SIGINFO signal.
.Pp
When
@ -142,21 +139,21 @@ It is based on IPv4 PIM sparse-mode
.Nm pimd
developed at University of Southern California,
which has also been derived from
.Nm mrouted.
.Nm mrouted .
.Nm Mrouted
is COPYRIGHT 1989 by The Board of Trustees of
Leland Stanford Junior University.
.Pp
IPv6 and IPsec support based on the KAME Project (http://www.kame.net/) stack
was initially integrated into
.Fx 4.0
.\"
.Sh BUGS
.Nm Pim6sd
does not contain any unicast routing engine, so a unicast routing
daemon needs to run on the system.
daemon needs to run on the system.
.Pp
The kernel unicast routing table is periodically polled by
.Nm
in order to follow changes of existing unicast routes.
.\"
.Pp
IPv6 and IPsec support based on the KAME Project (http://www.kame.net/) stack
was initially integrated into
.Fx 4.0

View File

@ -1,6 +1,6 @@
.\" Copyright (C) 1999 WIDE Project.
.\" All rights reserved.
.\"
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
@ -12,7 +12,7 @@
.\" 3. Neither the name of the project 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 PROJECT 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
@ -25,8 +25,8 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" $Id: pim6sd.conf.5,v 1.7 1999/12/03 07:31:45 jinmei Exp $
.\" $FreeBSD$
.\" $Id: pim6sd.conf.5,v 1.9 2000/05/05 14:57:14 sumikawa Exp $
.\" $FreeBSD$
.\"
.Dd Oct 6, 1999
.Dt PIM6SD.CONF 5
@ -65,8 +65,7 @@ The following statements can be specified in the configuration file.
.Ar option...
.Ic ;
.Xc
Specify debug messages to be printed out.
Each
Specify debug messages to be printed out. Each
.Ar option
usually specifies a subset of the messages to be printed.
If an
@ -74,8 +73,7 @@ If an
begins with
.Ic no ,
it means that the set of the messages that are specified by the option
will not be printed.
For example,
will not be printed. For example,
.Ic `all nomld'
means that all the messages except MLD related ones will be printed.
Valid options are
@ -147,8 +145,7 @@ The default preference is 1024.
.It Ic default_source_metric Ar metric;
Specifies a default metric value when sending a PIM assert message.
It is recommended that preferences be set such that metrics are never
consulted.
However, default metrics may also be set and will default to
consulted. However, default metrics may also be set and will default to
1024.
.\"
.It Xo
@ -169,8 +166,7 @@ the holdtime will be
*
.Ar coef .
The default values of the period and the coefficient are 30 and 3.5,
respectively.
The default holdtime is 105 seconds as a result.
respectively. The default holdtime is 105 seconds as a result.
.\"
.It Xo
.Ic join_prune_period Ar period Ar coef;
@ -184,8 +180,7 @@ the holdtime will be
*
.Ar coef .
The default values of the period and the coefficient are 60 and 3.5,
respectively.
Consequently, the default holdtime is 210 seconds.
respectively. Consequently, the default holdtime is 210 seconds.
.\"
.It Xo
.Ic data_timeout Ar timer;
@ -261,6 +256,7 @@ specifies a group prefix that the RP will handle.
.Op Ar interface
.Op Ic time Ar time
.Op Ic priority Ar priority
.Op Ic masklen Ar masklen
.Ic ;
.Xc
Specifies to act as a candidate bootstrap router(BSR).
@ -282,6 +278,11 @@ Another optional parameter
.Ic priority
specifies the priority of the RP.
The default value is 0, which means the lowest priority.
Hash mask length can also be specified by the
.Ic masklen
parametr. Its value,
.Ar masklen ,
must be no less than 0 and no greater than 128.
.\"
.It Xo
.Ic switch_register_threshold Ic rate Ar rate Ic interval Ar interval;
@ -312,8 +313,8 @@ The default values are 50000 and 20, respectively.
# phyint ep0 preference 101;
phyint de0 disable;
#
#followings are for a candidate Rendezvous Point, which should usually
#be disabled.
# followings are for a candidate Rendezvous Point, which should usually
# be disabled.
cand_bootstrap_router;
cand_rp;
.Ed

View File

@ -1,7 +1,7 @@
# $FreeBSD$
#
#The timer granularity.
#More this value is small,more pim6sd will be accurate
#More this value is small,more pim6sd will be accurate
#default if not specified : 5
#BE SURE to have to same granularity on ALL routers,
#otherwise....
@ -37,7 +37,7 @@
#syntax : 'data_timeout <number>'.
# number is the time after which (S,G) state for a silent source will be deleted
# default if not specified : 210
# default if not specified : 210
#data_timeout 210;
@ -56,22 +56,22 @@
#probe_time 5;
#syntax : 'assert_timeout <number>'.
#this is the interval between the last time an Assert is received and the time at wich the
#this is the interval between the last time an Assert is received and the time at wich the
#assert is timeout
#default if not specified : 180
#assert_timeout 180;
#syntax : <cand_rp> <interface> <time> [time] <priority> [priority]
#and time can't be < 10
#you can just type cand_rp,
#and time can't be < 10
#you can just type cand_rp,
#samples :
#cand_rp;
#cand_rp de0;
#cand_rp ed0 priority 0 time 6;
#syntax : <group_prefix> <multicast address>/<prefix length>
#group_prefix ff06::15
#group_prefix ff06::15
#default if not specified : ff00::/8
#samples:
#group_prefix ff1e::15/128;

View File

@ -1,6 +1,6 @@
.\" Copyright (C) 1999 WIDE Project.
.\" All rights reserved.
.\"
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
@ -12,7 +12,7 @@
.\" 3. Neither the name of the project 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 PROJECT 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
@ -25,8 +25,8 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" $Id: pim6stat.1,v 1.3 1999/12/16 05:38:06 jinmei Exp $
.\" $FreeBSD$
.\" $Id: pim6stat.1,v 1.5 2000/05/05 14:57:14 sumikawa Exp $
.\" $FreeBSD$
.\"
.Dd July 28, 1999
.Dt PIM6STAT 1
@ -36,11 +36,10 @@
.Nd show PIM for IPv6 status
.Sh SYNOPSIS
.Nm
.Op Fl d
.Op Fl f dumpfile
.Op Fl p pidfile
.Op Fl s
.Op Fl w waitsec
.Op Fl ds
.Op Fl f Ar dumpfile
.Op Fl p Ar pidfile
.Op Fl w Ar waitsec
.Sh DESCRIPTION
.Nm Pim6stat
shows status or statistics of the PIM for IPv6 daemon currently running.

View File

@ -29,74 +29,73 @@
*
* Other copyrights might apply to parts of this software and are so
* noted when applicable.
*
* $FreeBSD$
*/
/* Questions concerning this software should be directed to
* Mickael Hoerdt (hoerdt@clarinet.u-strasbg.fr) LSIIT Strasbourg.
*
*/
/*
* This program has been derived from pim6dd.
* This program has been derived from pim6dd.
* The pim6dd program is covered by the license in the accompanying file
* named "LICENSE.pim6dd".
*/
/*
* This program has been derived from pimd.
* This program has been derived from pimd.
* The pimd program is covered by the license in the accompanying file
* named "LICENSE.pimd".
*
* $FreeBSD$
*/
#ifndef PIMD_H
#define PIMD_H
#define PIMD_H
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include "defs.h"
#define PIM_PROTOCOL_VERSION 2
#define PIM_PROTOCOL_VERSION 2
/* PIM protocol timers (in seconds) */
#define PIM_REGISTER_SUPPRESSION_TIMEOUT 60
#define PIM_REGISTER_PROBE_TIME 5 /* Used to send NULL_REGISTER */
#define PIM_DATA_TIMEOUT 210
#define PIM_REGISTER_SUPPRESSION_TIMEOUT 60
#define PIM_REGISTER_PROBE_TIME 5 /* Used to send NULL_REGISTER */
#define PIM_DATA_TIMEOUT 210
#define PIM_TIMER_HELLO_PERIOD 30
#define PIM_JOIN_PRUNE_PERIOD 60
#define PIM_TIMER_HELLO_PERIOD 30
#define PIM_JOIN_PRUNE_PERIOD 60
#define PIM_JOIN_PRUNE_HOLDTIME (3.5 * PIM_JOIN_PRUNE_PERIOD)
#define PIM_RANDOM_DELAY_JOIN_TIMEOUT 4.5
#define PIM_JOIN_PRUNE_HOLDTIME (3.5 * PIM_JOIN_PRUNE_PERIOD)
#define PIM_RANDOM_DELAY_JOIN_TIMEOUT 4.5
#define PIM_DEFAULT_CAND_RP_ADV_PERIOD 60
#define PIM_DEFAULT_BOOTSTRAP_PERIOD 60
#define PIM_DEFAULT_CAND_RP_ADV_PERIOD 60
#define PIM_DEFAULT_BOOTSTRAP_PERIOD 60
#define PIM_BOOTSTRAP_TIMEOUT (2.5 * PIM_DEFAULT_BOOTSTRAP_PERIOD + 10)
#define PIM_TIMER_HELLO_HOLDTIME (3.5 * PIM_TIMER_HELLO_PERIOD)
#define PIM_ASSERT_TIMEOUT 180
#define PIM_BOOTSTRAP_TIMEOUT (2.5 * PIM_DEFAULT_BOOTSTRAP_PERIOD + 10)
#define PIM_TIMER_HELLO_HOLDTIME (3.5 * PIM_TIMER_HELLO_PERIOD)
#define PIM_ASSERT_TIMEOUT 180
/* Misc definitions */
#define PIM_DEFAULT_CAND_RP_PRIORITY 0 /* 0 is the highest. Don't know
#define PIM_DEFAULT_CAND_RP_PRIORITY 0 /* 0 is the highest. Don't know
* why this is the default.
* See the PS version (Mar' 97),
* pp.22 bottom of the spec.
*/
#define PIM_DEFAULT_BSR_PRIORITY 0 /* 0 is the lowest */
#define RP_DEFAULT_IPV6_HASHMASKLEN 126 /* the default group msklen used
#define PIM_DEFAULT_BSR_PRIORITY 0 /* 0 is the lowest */
#define RP_DEFAULT_IPV6_HASHMASKLEN 126 /* the default group msklen used
* by the hash function to
* calculate the group-to-RP
* mapping
*/
#define SINGLE_SRC_MSK6LEN 128 /* the single source mask length */
#define SINGLE_GRP_MSK6LEN 128 /* the single group mask length */
#define SINGLE_SRC_MSK6LEN 128 /* the single source mask length */
#define SINGLE_GRP_MSK6LEN 128 /* the single group mask length */
/* TODO: change? */
#define PIM_GROUP_PREFIX_DEFAULT_MASKLEN 8 /* The default group masklen if
/* TODO: change? */
#define PIM_GROUP_PREFIX_DEFAULT_MASKLEN 8 /* The default group masklen if
* omitted in the config file.
*/
@ -109,15 +108,15 @@
/* TODO: XXX: probably no need for two different intervals.
*/
#define PIM_DEFAULT_REG_RATE 50000 /* max # of register bits/s */
#define PIM_DEFAULT_REG_RATE_INTERVAL 20 /* regrate probe interval */
#define PIM_DEFAULT_DATA_RATE 50000 /* max # of data bits/s */
#define PIM_DEFAULT_DATA_RATE_INTERVAL 20 /* datarate check interval */
#define PIM_DEFAULT_REG_RATE 50000 /* max # of register bits/s */
#define PIM_DEFAULT_REG_RATE_INTERVAL 20 /* regrate probe interval */
#define PIM_DEFAULT_DATA_RATE 50000 /* max # of data bits/s */
#define PIM_DEFAULT_DATA_RATE_INTERVAL 20 /* datarate check interval */
#define DATA_RATE_CHECK_INTERVAL 20 /* Data rate check interval */
#define REG_RATE_CHECK_INTERVAL 20 /* PIM Reg. rate check interval*/
#define DATA_RATE_CHECK_INTERVAL 20 /* Data rate check interval */
#define REG_RATE_CHECK_INTERVAL 20 /* PIM Reg. rate check interval*/
#define UCAST_ROUTING_CHECK_INTERVAL 20 /* Unfortunately, if the unicast
#define UCAST_ROUTING_CHECK_INTERVAL 20 /* Unfortunately, if the unicast
* routing changes, the kernel
* or any of the existing
* unicast routing daemons
@ -128,37 +127,37 @@
* Sigh.
*/
#define DEFAULT_PHY_RATE_LIMIT 0 /* default phyint rate limit */
#define DEFAULT_REG_RATE_LIMIT 0 /* default register_vif rate limit */
#define DEFAULT_PHY_RATE_LIMIT 0 /* default phyint rate limit */
#define DEFAULT_REG_RATE_LIMIT 0 /* default register_vif rate limit */
/**************************************************************************
* PIM Encoded-Unicast, Encoded-Group and Encoded-Source Address formats *
*************************************************************************/
/* Address families definition */
#define ADDRF_RESERVED 0
#define ADDRF_IPv4 1
#define ADDRF_IPv6 2
#define ADDRF_NSAP 3
#define ADDRF_HDLC 4
#define ADDRF_BBN1822 5
#define ADDRF_802 6
#define ADDRF_ETHERNET ADDRF_802
#define ADDRF_E163 7
#define ADDRF_E164 8
#define ADDRF_SMDS ADDRF_E164
#define ADDRF_ATM ADDRF_E164
#define ADDRF_F69 9
#define ADDRF_TELEX ADDRF_F69
#define ADDRF_X121 10
#define ADDRF_X25 ADDRF_X121
#define ADDRF_IPX 11
#define ADDRF_APPLETALK 12
#define ADDRF_DECNET_IV 13
#define ADDRF_BANYAN 14
#define ADDRF_E164_NSAP 15
#define ADDRF_RESERVED 0
#define ADDRF_IPv4 1
#define ADDRF_IPv6 2
#define ADDRF_NSAP 3
#define ADDRF_HDLC 4
#define ADDRF_BBN1822 5
#define ADDRF_802 6
#define ADDRF_ETHERNET ADDRF_802
#define ADDRF_E163 7
#define ADDRF_E164 8
#define ADDRF_SMDS ADDRF_E164
#define ADDRF_ATM ADDRF_E164
#define ADDRF_F69 9
#define ADDRF_TELEX ADDRF_F69
#define ADDRF_X121 10
#define ADDRF_X25 ADDRF_X121
#define ADDRF_IPX 11
#define ADDRF_APPLETALK 12
#define ADDRF_DECNET_IV 13
#define ADDRF_BANYAN 14
#define ADDRF_E164_NSAP 15
/* Addresses Encoding Type (specific for each Address Family */
#define ADDRT_IPv6 0
#define ADDRT_IPv6 0
/* Encoded-Unicast: 18 bytes long */
@ -169,10 +168,10 @@ typedef struct pim6_encod_uni_addr_ {
* misalignment for the unicast
* address when placed in the
* memory. Must read it byte-by-byte!
*/
*/
} pim6_encod_uni_addr_t;
/* XXX: sizeof(pim6_encod_uni_addr_t) does not work due to misalignment */
#define PIM6_ENCODE_UNI_ADDR_LEN 18
#define PIM6_ENCODE_UNI_ADDR_LEN 18
/* Encoded-Group */
typedef struct pim6_encod_grp_addr_ {
@ -183,7 +182,7 @@ typedef struct pim6_encod_grp_addr_ {
struct in6_addr mcast_addr;
} pim6_encod_grp_addr_t;
/* XXX: sizeof(pim6_encod_grp_addr_t) MAY NOT work due to an alignment problem */
#define PIM6_ENCODE_GRP_ADDR_LEN 20
#define PIM6_ENCODE_GRP_ADDR_LEN 20
/* Encoded-Source */
typedef struct pim6_encod_src_addr_ {
@ -194,11 +193,11 @@ typedef struct pim6_encod_src_addr_ {
struct in6_addr src_addr;
} pim6_encod_src_addr_t;
/* XXX: sizeof(pim6_encod_src_addr_t) MAY NOT work due to an alignment problem */
#define PIM6_ENCODE_SRC_ADDR_LEN 20
#define PIM6_ENCODE_SRC_ADDR_LEN 20
#define USADDR_RP_BIT 0x1
#define USADDR_WC_BIT 0x2
#define USADDR_S_BIT 0x4
#define USADDR_RP_BIT 0x1
#define USADDR_WC_BIT 0x2
#define USADDR_S_BIT 0x4
/**************************************************************************
* PIM Messages formats *
@ -237,49 +236,49 @@ typedef struct pim_jp_encod_grp_ {
} pim_jp_encod_grp_t;
#define PIM_ACTION_NOTHING 0
#define PIM_ACTION_JOIN 1
#define PIM_ACTION_PRUNE 2
#define PIM_ACTION_NOTHING 0
#define PIM_ACTION_JOIN 1
#define PIM_ACTION_PRUNE 2
#define PIM_IIF_SOURCE 1
#define PIM_IIF_RP 2
#define PIM_IIF_SOURCE 1
#define PIM_IIF_RP 2
#define PIM_ASSERT_RPT_BIT 0x80000000
#define PIM_ASSERT_RPT_BIT 0x80000000
/* PIM messages type */
#define PIM_HELLO 0
#define PIM_REGISTER_STOP 2
#define PIM_JOIN_PRUNE 3
#define PIM_BOOTSTRAP 4
#define PIM_ASSERT 5
#define PIM_GRAFT 6
#define PIM_GRAFT_ACK 7
#define PIM_CAND_RP_ADV 8
#define PIM_HELLO 0
#define PIM_REGISTER_STOP 2
#define PIM_JOIN_PRUNE 3
#define PIM_BOOTSTRAP 4
#define PIM_ASSERT 5
#define PIM_GRAFT 6
#define PIM_GRAFT_ACK 7
#define PIM_CAND_RP_ADV 8
#define PIM_V2_HELLO PIM_HELLO
#define PIM_V2_REGISTER PIM_REGISTER
#define PIM_V2_REGISTER_STOP PIM_REGISTER_STOP
#define PIM_V2_JOIN_PRUNE PIM_JOIN_PRUNE
#define PIM_V2_BOOTSTRAP PIM_BOOTSTRAP
#define PIM_V2_ASSERT PIM_ASSERT
#define PIM_V2_GRAFT PIM_GRAFT
#define PIM_V2_GRAFT_ACK PIM_GRAFT_ACK
#define PIM_V2_CAND_RP_ADV PIM_CAND_RP_ADV
#define PIM_V2_HELLO PIM_HELLO
#define PIM_V2_REGISTER PIM_REGISTER
#define PIM_V2_REGISTER_STOP PIM_REGISTER_STOP
#define PIM_V2_JOIN_PRUNE PIM_JOIN_PRUNE
#define PIM_V2_BOOTSTRAP PIM_BOOTSTRAP
#define PIM_V2_ASSERT PIM_ASSERT
#define PIM_V2_GRAFT PIM_GRAFT
#define PIM_V2_GRAFT_ACK PIM_GRAFT_ACK
#define PIM_V2_CAND_RP_ADV PIM_CAND_RP_ADV
/* Vartious options from PIM messages definitions */
/* PIM_HELLO definitions */
#define PIM_MESSAGE_HELLO_HOLDTIME 1
#define PIM_MESSAGE_HELLO_HOLDTIME_LENGTH 2
#define PIM_MESSAGE_HELLO_HOLDTIME_FOREVER 0xffff
#define PIM_MESSAGE_HELLO_HOLDTIME 1
#define PIM_MESSAGE_HELLO_HOLDTIME_LENGTH 2
#define PIM_MESSAGE_HELLO_HOLDTIME_FOREVER 0xffff
/* PIM_REGISTER definitions */
#define PIM_MESSAGE_REGISTER_BORDER_BIT 0x80000000
#define PIM_MESSAGE_REGISTER_NULL_REGISTER_BIT 0x40000000
#define PIM_MESSAGE_REGISTER_BORDER_BIT 0x80000000
#define PIM_MESSAGE_REGISTER_NULL_REGISTER_BIT 0x40000000
#define MASK_TO_MASKLEN6(mask , masklen) \
#define MASK_TO_MASKLEN6(mask , masklen) \
do { \
register u_int32 tmp_mask; \
register u_int8 tmp_masklen = sizeof((mask)) <<3; \
@ -293,9 +292,9 @@ do { \
break; \
} \
(masklen) =tmp_masklen; \
} while (0)
} while (0)
#define MASKLEN_TO_MASK6(masklen, mask6) \
#define MASKLEN_TO_MASK6(masklen, mask6) \
do {\
u_char maskarray[8] = \
{0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc, 0xfe, 0xff}; \
@ -325,10 +324,10 @@ do { \
* The same for all {PUT,GET}_{NET,HOST}{SHORT,LONG}
*/
#define GET_BYTE(val, cp) ((val) = *(cp)++)
#define PUT_BYTE(val, cp) (*(cp)++ = (u_int8)(val))
#define GET_BYTE(val, cp) ((val) = *(cp)++)
#define PUT_BYTE(val, cp) (*(cp)++ = (u_int8)(val))
#define GET_HOSTSHORT(val, cp) \
#define GET_HOSTSHORT(val, cp) \
do { \
register u_int16 Xv; \
Xv = (*(cp)++) << 8; \
@ -336,7 +335,7 @@ do { \
(val) = Xv; \
} while (0)
#define PUT_HOSTSHORT(val, cp) \
#define PUT_HOSTSHORT(val, cp) \
do { \
register u_int16 Xv; \
Xv = (u_int16)(val); \
@ -345,14 +344,14 @@ do { \
} while (0)
#if defined(BYTE_ORDER) && (BYTE_ORDER == LITTLE_ENDIAN)
#define GET_NETSHORT(val, cp) \
#define GET_NETSHORT(val, cp) \
do { \
register u_int16 Xv; \
Xv = *(cp)++; \
Xv |= (*(cp)++) << 8; \
(val) = Xv; \
} while (0)
#define PUT_NETSHORT(val, cp) \
#define PUT_NETSHORT(val, cp) \
do { \
register u_int16 Xv; \
Xv = (u_int16)(val); \
@ -360,11 +359,11 @@ do { \
*(cp)++ = (u_int8)(Xv >> 8); \
} while (0)
#else
#define GET_NETSHORT(val, cp) GET_HOSTSHORT(val, cp)
#define PUT_NETSHORT(val, cp) PUT_HOSTSHORT(val, cp)
#define GET_NETSHORT(val, cp) GET_HOSTSHORT(val, cp)
#define PUT_NETSHORT(val, cp) PUT_HOSTSHORT(val, cp)
#endif /* {GET,PUT}_NETSHORT */
#define GET_HOSTLONG(val, cp) \
#define GET_HOSTLONG(val, cp) \
do { \
register u_long Xv; \
Xv = (*(cp)++) << 24; \
@ -374,7 +373,7 @@ do { \
(val) = Xv; \
} while (0)
#define PUT_HOSTLONG(val, cp) \
#define PUT_HOSTLONG(val, cp) \
do { \
register u_int32 Xv; \
Xv = (u_int32)(val); \
@ -385,7 +384,7 @@ do { \
} while (0)
#if defined(BYTE_ORDER) && (BYTE_ORDER == LITTLE_ENDIAN)
#define GET_NETLONG(val, cp) \
#define GET_NETLONG(val, cp) \
do { \
register u_long Xv; \
Xv = *(cp)++; \
@ -395,7 +394,7 @@ do { \
(val) = Xv; \
} while (0)
#define PUT_NETLONG(val, cp) \
#define PUT_NETLONG(val, cp) \
do { \
register u_int32 Xv; \
Xv = (u_int32)(val); \
@ -405,11 +404,11 @@ do { \
*(cp)++ = (u_int8)(Xv >> 24); \
} while (0)
#else
#define GET_NETLONG(val, cp) GET_HOSTLONG(val, cp)
#define PUT_NETLONG(val, cp) PUT_HOSTLONG(val, cp)
#define GET_NETLONG(val, cp) GET_HOSTLONG(val, cp)
#define PUT_NETLONG(val, cp) PUT_HOSTLONG(val, cp)
#endif /* {GET,PUT}_HOSTLONG */
#define GET_ESADDR6(esa, cp) /* XXX: hard coding */ \
#define GET_ESADDR6(esa, cp) /* XXX: hard coding */ \
do { \
(esa)->addr_family = *(cp)++; \
(esa)->encod_type = *(cp)++; \
@ -419,7 +418,7 @@ do { \
(cp) += sizeof(struct in6_addr); \
} while(0)
#define PUT_ESADDR6(addr, masklen, flags, cp) \
#define PUT_ESADDR6(addr, masklen, flags, cp) \
do { \
int i; \
struct in6_addr maskaddr; \
@ -432,7 +431,7 @@ do { \
*(cp) = maskaddr.s6_addr[i] & (addr).s6_addr[i]; \
} while(0)
#define GET_EGADDR6(ega, cp) /* XXX: hard coding */ \
#define GET_EGADDR6(ega, cp) /* XXX: hard coding */ \
do { \
(ega)->addr_family = *(cp)++; \
(ega)->encod_type = *(cp)++; \
@ -442,7 +441,7 @@ do { \
(cp) += sizeof(struct in6_addr); \
} while(0)
#define PUT_EGADDR6(addr, masklen, reserved, cp) \
#define PUT_EGADDR6(addr, masklen, reserved, cp) \
do { \
int i; \
struct in6_addr maskaddr; \
@ -456,7 +455,7 @@ do { \
} while(0)
#define GET_EUADDR6(eua, cp) /* XXX hard conding */ \
#define GET_EUADDR6(eua, cp) /* XXX hard conding */ \
do { \
(eua)->addr_family = *(cp)++; \
(eua)->encod_type = *(cp)++; \
@ -464,7 +463,7 @@ do { \
(cp) += sizeof(struct in6_addr); \
} while(0)
#define PUT_EUADDR6(addr, cp) \
#define PUT_EUADDR6(addr, cp) \
do { \
*(cp)++ = ADDRF_IPv6; /* family */ \
*(cp)++ = ADDRT_IPv6; /* type */ \
@ -473,28 +472,28 @@ do { \
} while(0)
/* Used if no relaible unicast routing information available */
#define UCAST_DEFAULT_SOURCE_METRIC 1024
#define UCAST_DEFAULT_SOURCE_PREFERENCE 1024
#define UCAST_DEFAULT_SOURCE_METRIC 1024
#define UCAST_DEFAULT_SOURCE_PREFERENCE 1024
#define DEFAULT_LOCAL_PREF 101 /* assert pref par defaut */
#define DEFAULT_LOCAL_METRIC 1024 /* assert metrique par default */
#define DEFAULT_LOCAL_PREF 101 /* assert pref par defaut */
#define DEFAULT_LOCAL_METRIC 1024 /* assert metrique par default */
/*
/*
* TODO: recalculate the messages sizes, probably with regard to the MTU
* TODO: cleanup
*/
#define MAX_JP_MESSAGE_SIZE 8192
#define MAX_JP_MESSAGE_POOL_NUMBER 8
#define MAX_JOIN_LIST_SIZE 1500
#define MAX_PRUNE_LIST_SIZE 1500
#define MAX_JP_MESSAGE_SIZE 8192
#define MAX_JP_MESSAGE_POOL_NUMBER 8
#define MAX_JOIN_LIST_SIZE 1500
#define MAX_PRUNE_LIST_SIZE 1500
#define STAR_STAR_RP_MSK6LEN 8 /* Masklen for
#define STAR_STAR_RP_MSK6LEN 8 /* Masklen for
* ff00 ::
* to encode (*,*,RP)
*/
*/
/* interface independent statistics */
struct pim6dstat {

View File

@ -29,8 +29,6 @@
*
* Other copyrights might apply to parts of this software and are so
* noted when applicable.
*
* $FreeBSD$
*/
/*
* Questions concerning this software should be directed to
@ -38,15 +36,16 @@
*
*/
/*
* This program has been derived from pim6dd.
* This program has been derived from pim6dd.
* The pim6dd program is covered by the license in the accompanying file
* named "LICENSE.pim6dd".
*/
/*
* This program has been derived from pimd.
* This program has been derived from pimd.
* The pimd program is covered by the license in the accompanying file
* named "LICENSE.pimd".
*
* $FreeBSD$
*/
#include <sys/types.h>
@ -207,13 +206,13 @@ set_incoming(srcentry_ptr, srctype)
/*
* The upstream router must be a (PIM router) neighbor, otherwise we are
* in big trouble ;-).
* in big trouble ;-).
* Yes but the neighbors are link-local and the rp is global ipv6..
*/
/* WARNING WARNING WARNING WARNING */
/* If the router is directly connected to the RP and the RP is the BSR , the next hop is
* the globally reachable addresse of the RP : NOT link local neighbor but
* a ipv6 global neighbor...
* a ipv6 global neighbor...
* the upstream router is the globally reachable router...
*
*/
@ -846,7 +845,7 @@ delete_vif_from_mrt(vifi)
}
void
void
process_kernel_call()
{
register struct mrt6msg *im; /* igmpmsg control struct */
@ -993,7 +992,7 @@ process_cache_miss(im)
else
rp_addr = mrtentry_ptr->group->rpaddr;
mfc_source = source;
// TODO
// TODO
#ifdef KERNEL_MFC_WC_G
if (mrtentry_ptr->flags & (MRTF_WC | MRTF_PMBR))
if (!(mrtentry_ptr->flags & MRTF_MFC_CLONE_SG))

View File

@ -25,8 +25,6 @@
* 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.
*
* $FreeBSD$
*/
/*
* Questions concerning this software should be directed to
@ -34,20 +32,21 @@
*
*/
/*
* This program has been derived from pim6dd.
* This program has been derived from pim6dd.
* The pim6dd program is covered by the license in the accompanying file
* named "LICENSE.pim6dd".
*/
/*
* This program has been derived from pimd.
* This program has been derived from pimd.
* The pimd program is covered by the license in the accompanying file
* named "LICENSE.pimd".
*
* $FreeBSD$
*/
#ifndef ROUTE_H
#define ROUTE_H
#define ROUTE_H
#include "mrt.h"
@ -58,7 +57,7 @@ int change_interfaces( mrtentry_t *mrtentry_ptr,vifi_t new_iif,
if_set *new_joined_oifs,if_set *new_pruned_oifs,if_set *new_leaves_ , if_set *asserted ,
u_int16 flags);
extern void process_kernel_call __P(());
extern void process_kernel_call __P((void));
extern int set_incoming __P((srcentry_t *srcentry_ptr,
int srctype));
extern vifi_t get_iif __P((struct sockaddr_in6 *source));
@ -68,7 +67,7 @@ extern int add_sg_oif __P((mrtentry_t *mrtentry_ptr,
int update_holdtime));
extern void add_leaf __P((vifi_t vifi, struct sockaddr_in6 *source,
struct sockaddr_in6 *group));
extern void delete_leaf __P((vifi_t vifi, struct sockaddr_in6 *source,
extern void delete_leaf __P((vifi_t vifi, struct sockaddr_in6 *source,
struct sockaddr_in6 *group));
@ -77,7 +76,7 @@ extern void delete_leaf __P((vifi_t vifi, struct sockaddr_in6 *source,
extern pim_nbr_entry_t *find_pim6_nbr __P((struct sockaddr_in6 *source));
extern void calc_oifs __P((mrtentry_t *mrtentry_ptr,
if_set *oifs_ptr));
extern void process_kernel_call __P(());
extern void process_kernel_call __P((void));
extern int delete_vif_from_mrt __P((vifi_t vifi));
extern mrtentry_t *switch_shortest_path __P((struct sockaddr_in6 *source, struct sockaddr_in6 *group));

View File

@ -29,8 +29,6 @@
*
* Other copyrights might apply to parts of this software and are so
* noted when applicable.
*
* $FreeBSD$
*/
/*
* Questions concerning this software should be directed to
@ -38,12 +36,12 @@
*
*/
/*
* This program has been derived from pim6dd.
* This program has been derived from pim6dd.
* The pim6dd program is covered by the license in the accompanying file
* named "LICENSE.pim6dd".
*/
/*
* This program has been derived from pimd.
* This program has been derived from pimd.
* The pimd program is covered by the license in the accompanying file
* named "LICENSE.pimd".
*
@ -56,6 +54,7 @@
* The mrouted program is COPYRIGHT 1989 by The Board of Trustees of
* Leland Stanford Junior University.
*
* $FreeBSD$
*/
#include <sys/param.h>
@ -78,6 +77,7 @@
#include <syslog.h>
#include "vif.h"
#include "debug.h"
#include "routesock.h"
#ifdef HAVE_ROUTING_SOCKETS
union sockunion
@ -96,7 +96,7 @@ u_long rtm_inits;
/*
* Local functions definitions.
*/
static int getmsg
static int getmsg
__P((register struct rt_msghdr *, int,
struct rpfctl * rpfinfo));
@ -104,17 +104,17 @@ __P((register struct rt_msghdr *, int,
* TODO: check again!
*/
#ifdef IRIX
#define ROUNDUP(a) ((a) > 0 ? (1 + (((a) - 1) | (sizeof(__uint64_t) - 1))) \
#define ROUNDUP(a) ((a) > 0 ? (1 + (((a) - 1) | (sizeof(__uint64_t) - 1))) \
: sizeof(__uint64_t))
#else
#define ROUNDUP(a) ((a) > 0 ? (1 + (((a) - 1) | (sizeof(long) - 1))) \
#define ROUNDUP(a) ((a) > 0 ? (1 + (((a) - 1) | (sizeof(long) - 1))) \
: sizeof(long))
#endif /* IRIX */
#ifdef HAVE_SA_LEN
#define ADVANCE(x, n) (x += ROUNDUP((n)->sa_len))
#define ADVANCE(x, n) (x += ROUNDUP((n)->sa_len))
#else
#define ADVANCE(x, n) (x += ROUNDUP(4)) /* TODO: a hack!! */
#define ADVANCE(x, n) (x += ROUNDUP(4)) /* TODO: a hack!! */
#endif
/* Open and initialize the routing socket */
@ -175,12 +175,12 @@ k_req_incoming(source, rpfp)
/* TODO: a hack!!!! */
#ifdef HAVE_SA_LEN
#define NEXTADDR(w, u) \
#define NEXTADDR(w, u) \
if (rtm_addrs & (w)) { \
l = ROUNDUP(u.sa.sa_len); bcopy((char *)&(u), cp, l); cp += l;\
}
#else
#define NEXTADDR(w, u) \
#define NEXTADDR(w, u) \
if (rtm_addrs & (w)) { \
l = ROUNDUP(4); bcopy((char *)&(u), cp, l); cp += l;\
}
@ -221,7 +221,7 @@ k_req_incoming(source, rpfp)
errno = 0;
bzero((char *) &m_rtmsg, sizeof(m_rtmsg));
#define rtm m_rtmsg.m_rtm
#define rtm m_rtmsg.m_rtm
rtm.rtm_type = RTM_GET;
rtm.rtm_flags = flags;
rtm.rtm_version = RTM_VERSION;
@ -281,7 +281,7 @@ getmsg(rtm, msglen, rpfinfop)
struct sockaddr *dst = NULL,
*gate = NULL,
*mask = NULL;
struct sockaddr_dl *ifp = NULL;
register struct sockaddr *sa;
register char *cp;

View File

@ -25,8 +25,6 @@
* 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.
*
* $FreeBSD$
*/
/*
* Questions concerning this software should be directed to
@ -34,24 +32,25 @@
*
*/
/*
* This program has been derived from pim6dd.
* This program has been derived from pim6dd.
* The pim6dd program is covered by the license in the accompanying file
* named "LICENSE.pim6dd".
*/
/*
* This program has been derived from pimd.
* This program has been derived from pimd.
* The pimd program is covered by the license in the accompanying file
* named "LICENSE.pimd".
*
* $FreeBSD$
*/
#ifndef ROUTESOCK_H
#define ROUTESOCK_H
#define ROUTESOCK_H
void init_routesock();
int init_routesock __P((void));
extern int pid;
extern int k_req_incoming __P((struct sockaddr_in6 *source,
struct rpfctl *rpfp));
struct rpfctl *rpfp));
#endif

View File

@ -47,7 +47,7 @@
* ABOUT THE SUITABILITY OF THIS SOFTWARE FOR ANY PURPOSE. THIS SOFTWARE IS
* PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, TITLE, AND
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, TITLE, AND
* NON-INFRINGEMENT.
*
* IN NO EVENT SHALL USC, OR ANY OTHER CONTRIBUTOR BE LIABLE FOR ANY
@ -57,8 +57,6 @@
*
* Other copyrights might apply to parts of this software and are so
* noted when applicable.
*
* $FreeBSD$
*/
/*
* Questions concerning this software should be directed to
@ -66,15 +64,16 @@
*
*/
/*
* This program has been derived from pim6dd.
* This program has been derived from pim6dd.
* The pim6dd program is covered by the license in the accompanying file
* named "LICENSE.pim6dd".
*/
/*
* This program has been derived from pimd.
* This program has been derived from pimd.
* The pimd program is covered by the license in the accompanying file
* named "LICENSE.pimd".
*
* $FreeBSD$
*/
#include <stdlib.h>
@ -95,10 +94,10 @@
* compatibility ;)
*/
#define SEED1 1103515245
#define SEED2 12345
#define RP_HASH_VALUE(G, M, C) (((SEED1) * (((SEED1) * ((G) & (M)) + (SEED2)) ^ (C)) + (SEED2)) % 0x80000000)
#define RP_HASH_VALUE2(P, C) (((SEED1) * (((SEED1) * (P) + (SEED2)) ^ (C)) + (SEED2)) % 0x80000000)
#define SEED1 1103515245
#define SEED2 12345
#define RP_HASH_VALUE(G, M, C) (((SEED1) * (((SEED1) * ((G) & (M)) + (SEED2)) ^ (C)) + (SEED2)) % 0x80000000)
#define RP_HASH_VALUE2(P, C) (((SEED1) * (((SEED1) * (P) + (SEED2)) ^ (C)) + (SEED2)) % 0x80000000)
cand_rp_t *cand_rp_list;
grp_mask_t *grp_mask_list;
@ -120,7 +119,7 @@ u_int8 my_cand_rp_priority;
u_int16 my_cand_rp_holdtime;
u_int16 my_cand_rp_adv_period; /* The locally configured Cand-RP
* adv. period. */
u_int16 my_bsr_period; /* The locally configured BSR
u_int16 my_bsr_period; /* The locally configured BSR
period */
u_int16 pim_cand_rp_adv_timer;
u_int8 cand_rp_flag = FALSE; /* Candidate RP flag */
@ -204,9 +203,9 @@ bootstrap_initial_delay()
/*
* The bootstrap timer initial value (if Cand-BSR). It depends of the
* bootstrap router priority: higher priority has shorter value:
*
*
* Delay = 5 + 2*log_2(1 + bestPriority - myPriority) + AddrDelay;
*
*
* bestPriority = Max(storedPriority, myPriority); if (bestPriority ==
* myPriority) AddrDelay = log_2(bestAddr - myAddr)/16; else AddrDelay =
* 2 - (myAddr/2^31);
@ -241,8 +240,8 @@ bootstrap_initial_delay()
*/
/* Calculate log_2(Delay) */
// log_mask = sizeof(Delay) << 3;
// log_mask = (1 << (log_mask - 1));
/* Set the leftmost bit to `1`
// log_mask = (1 << (log_mask - 1));
/* Set the leftmost bit to `1`
*/
/* for (log_of_2 = (sizeof(Delay) << 3) - 1; log_of_2; log_of_2--)
@ -360,7 +359,7 @@ add_grp_mask(used_grp_mask_list, group_addr, group_mask, hash_mask)
prefix_h.sin6_addr.s6_addr[i] =
group_addr->sin6_addr.s6_addr[i] & group_mask.s6_addr[i];
/* The ordering is: smaller first */
/* The ordering is: bigger first */
for (grp_mask = *used_grp_mask_list; grp_mask != (grp_mask_t *) NULL;
grp_mask_prev = grp_mask, grp_mask = grp_mask->next)
{
@ -368,7 +367,7 @@ add_grp_mask(used_grp_mask_list, group_addr, group_mask, hash_mask)
prefix_h2.sin6_addr.s6_addr[i] =
(grp_mask->group_addr.sin6_addr.s6_addr[i] &
grp_mask->group_mask.s6_addr[i]);
if (inet6_lessthan(&prefix_h2, &prefix_h) )
if (inet6_greaterthan(&prefix_h2, &prefix_h) )
continue;
if (inet6_equal(&prefix_h2, &prefix_h))
return (grp_mask);
@ -721,14 +720,14 @@ delete_grp_mask(used_cand_rp_list, used_grp_mask_list, group_addr, group_mask)
grp_mask_ptr = grp_mask_ptr->next)
{
for (i = 0; i < sizeof(struct in6_addr); i++)
prefix_h2.sin6_addr.s6_addr[i] =
prefix_h2.sin6_addr.s6_addr[i] =
grp_mask_ptr->group_addr.sin6_addr.s6_addr[i]&grp_mask_ptr->group_mask.s6_addr[i];
if (inet6_lessthan(&prefix_h2, &prefix_h))
if (inet6_greaterthan(&prefix_h2, &prefix_h))
continue;
if (IN6_ARE_ADDR_EQUAL(&grp_mask_ptr->group_addr.sin6_addr,
&group_addr->sin6_addr) &&
IN6_ARE_ADDR_EQUAL(&grp_mask_ptr->group_mask, &group_mask))
IN6_ARE_ADDR_EQUAL(&grp_mask_ptr->group_mask, &group_mask))
break;
else
return; /* Not found */
@ -1017,31 +1016,29 @@ rp_grp_match(group)
struct sockaddr_in6 prefix_h;
struct sockaddr_in6 prefix_h2;
int i;
int i;
if (grp_mask_list == (grp_mask_t *) NULL)
return (rp_grp_entry_t *) NULL;
/* XXX :I compare on the adresses , inet6_equal use the scope too */
/* XXX: I compare on the adresses, inet6_equal use the scope too */
prefix_h.sin6_scope_id = prefix_h2.sin6_scope_id = 0;
for (grp_mask_ptr = grp_mask_list; grp_mask_ptr != (grp_mask_t *) NULL;
grp_mask_ptr = grp_mask_ptr->next)
{
for (i = 0; i < sizeof(struct in6_addr); i++)
prefix_h2.sin6_addr.s6_addr[i] =
prefix_h2.sin6_addr.s6_addr[i] =
(grp_mask_ptr->group_addr.sin6_addr.s6_addr[i] &
grp_mask_ptr->group_mask.s6_addr[i]);
for (i = 0; i < sizeof(struct in6_addr); i++)
prefix_h.sin6_addr.s6_addr[i] =
prefix_h.sin6_addr.s6_addr[i] =
(group->sin6_addr.s6_addr[i] &
grp_mask_ptr->group_mask.s6_addr[i]);
/* Search the grp_mask (group_prefix) list */
if ((inet6_greaterthan(&prefix_h, &prefix_h2)))
if (!inet6_equal(&prefix_h, &prefix_h2))
continue;
if ((inet6_lessthan(&prefix_h, &prefix_h2)))
break;
for (grp_rp_entry_ptr = grp_mask_ptr->grp_rp_next;
grp_rp_entry_ptr != (rp_grp_entry_t *) NULL;
@ -1190,7 +1187,7 @@ create_pim6_bootstrap_message(send_buff)
* mrtentry_ptr. Return TRUE or FALSE.
*/
int
int
check_mrtentry_rp(mrtentry_ptr, rp_addr)
mrtentry_t *mrtentry_ptr;
struct sockaddr_in6 *rp_addr;

View File

@ -25,8 +25,6 @@
* 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.
*
* $FreeBSD$
*/
/*
* Questions concerning this software should be directed to
@ -34,20 +32,21 @@
*
*/
/*
* This program has been derived from pim6dd.
* This program has been derived from pim6dd.
* The pim6dd program is covered by the license in the accompanying file
* named "LICENSE.pim6dd".
*/
/*
* This program has been derived from pimd.
* This program has been derived from pimd.
* The pimd program is covered by the license in the accompanying file
* named "LICENSE.pimd".
*
* $FreeBSD$
*/
#ifndef RP_H
#define RP_H
#define RP_H
#include "defs.h"
#include "mrt.h"
@ -55,7 +54,7 @@
extern cand_rp_t *cand_rp_list;
extern grp_mask_t *grp_mask_list;
extern cand_rp_t *segmented_cand_rp_list;
extern grp_mask_t *segmented_grp_mask_list;
extern grp_mask_t *segmented_grp_mask_list;
extern u_int8 cand_rp_flag;
extern u_int8 cand_bsr_flag;
@ -82,9 +81,9 @@ extern struct cand_rp_adv_message_ {
} cand_rp_adv_message;
extern void init_rp6_and_bsr6 __P(());
extern void init_rp6_and_bsr6 __P((void));
void delete_rp_list( cand_rp_t **used_cand_rp_list , grp_mask_t **used_grp_mask_list );
u_int16 bootstrap_initial_delay();
u_int16 bootstrap_initial_delay __P((void));
extern rpentry_t *rp_match __P((struct sockaddr_in6 *group));
extern rp_grp_entry_t *rp_grp_match __P((struct sockaddr_in6 *group));
extern int create_pim6_bootstrap_message __P((char *send_buff));
@ -101,8 +100,8 @@ extern rp_grp_entry_t *add_rp_grp_entry __P((cand_rp_t **used_cand_rp_list,
extern void delete_rp_grp_entry __P((cand_rp_t **used_cand_rp_list,
grp_mask_t **used_grp_mask_list,
rp_grp_entry_t *rp_grp_entry_delete));
extern void delete_grp_mask __P((cand_rp_t **used_cand_rp_list,
grp_mask_t **used_grp_mask_list,
extern void delete_grp_mask __P((cand_rp_t **used_cand_rp_list,
grp_mask_t **used_grp_mask_list,
struct sockaddr_in6 *group_addr,
struct in6_addr group_mask));
extern void delete_rp __P((cand_rp_t **used_cand_rp_list,
@ -110,7 +109,7 @@ extern void delete_rp __P((cand_rp_t **used_cand_rp_list,
struct sockaddr_in6 *rp_addr));
extern void delete_rp_list __P((cand_rp_t **used_cand_rp_list,
grp_mask_t **used_grp_mask_list));
extern rpentry_t *rp_match __P((struct sockaddr_in6 *group));
extern rpentry_t *rp_match __P((struct sockaddr_in6 *group));
extern rp_grp_entry_t *rp_grp_match __P((struct sockaddr_in6 *group));
extern rpentry_t *rp_find __P((struct sockaddr_in6 *rp_address));
extern int remap_grpentry __P((grpentry_t *grpentry_ptr));

View File

@ -29,8 +29,6 @@
*
* Other copyrights might apply to parts of this software and are so
* noted when applicable.
*
* $FreeBSD$
*/
/*
* Questions concerning this software should be directed to
@ -38,15 +36,16 @@
*
*/
/*
* This program has been derived from pim6dd.
* This program has been derived from pim6dd.
* The pim6dd program is covered by the license in the accompanying file
* named "LICENSE.pim6dd".
*/
/*
* This program has been derived from pimd.
* This program has been derived from pimd.
* The pimd program is covered by the license in the accompanying file
* named "LICENSE.pimd".
*
* $FreeBSD$
*/
#include <stdlib.h>
@ -59,6 +58,7 @@
#include "debug.h"
#include "rp.h"
#include "pim6_proto.h"
#include "mld6.h"
#include "mld6_proto.h"
#include "route.h"
#include "kern.h"
@ -160,7 +160,7 @@ init_timers()
srcentry_save.next = (srcentry_t *) NULL;
memset(&srcentry_save.address, 0, sizeof(struct sockaddr_in6));
srcentry_save.address.sin6_len = sizeof(struct sockaddr_in6);
srcentry_save.address.sin6_family= AF_INET6;
srcentry_save.address.sin6_family= AF_INET6;
srcentry_save.mrtlink = (mrtentry_t *) NULL;
srcentry_save.incoming = NO_VIF;
srcentry_save.upstream = (pim_nbr_entry_t *) NULL;
@ -173,7 +173,7 @@ init_timers()
rpentry_save.next = (rpentry_t *) NULL;
memset(&rpentry_save.address, 0, sizeof(struct sockaddr_in6));
rpentry_save.address.sin6_len = sizeof(struct sockaddr_in6);
rpentry_save.address.sin6_family= AF_INET6;
rpentry_save.address.sin6_family= AF_INET6;
rpentry_save.mrtlink = (mrtentry_t *) NULL;
rpentry_save.incoming = NO_VIF;
rpentry_save.upstream = (pim_nbr_entry_t *) NULL;
@ -214,8 +214,23 @@ age_vifs()
{
if (v->uv_flags & (VIFF_DISABLED | VIFF_DOWN | MIFF_REGISTER))
continue;
/* Timeout neighbors */
/* Timeout the MLD querier (unless we re the querier) */
if ((v->uv_flags & VIFF_QUERIER) == 0 &&
v->uv_querier) { /* this must be non-NULL, but check for safety. */
IF_TIMEOUT(v->uv_querier->al_timer) {
v->uv_querier_timo++; /* count statistics */
/* act as a querier by myself */
v->uv_flags |= VIFF_QUERIER;
v->uv_querier->al_addr = v->uv_linklocal->pa_addr;
v->uv_querier->al_timer = MLD6_OTHER_QUERIER_PRESENT_INTERVAL;
time(&v->uv_querier->al_ctime); /* reset timestamp */
query_groups(v);
}
}
/* Timeout neighbors */
for (curr_nbr = v->uv_pim_neighbors; curr_nbr != NULL;
curr_nbr = next_nbr)
{
@ -376,7 +391,7 @@ age_routes()
for (cand_rp_ptr = cand_rp_list; cand_rp_ptr != (cand_rp_t *) NULL;
cand_rp_ptr = cand_rp_ptr->next)
{
rpentry_ptr = cand_rp_ptr->rpentry;
/*
@ -464,7 +479,7 @@ age_routes()
* However, because the kernel cache/traffic info is of the
* form (S,G), it is easier if we are simply collecting (S,G)
* traffic all the time.
*
*
* For (*,*,RP) if the number of bytes received between the last
* check and now exceeds some precalculated value (based on
* interchecking period and datarate threshold AND if there
@ -476,7 +491,7 @@ age_routes()
* hence after a switch to the source-specific tree occurs, a
* source with low datarate, but periodically sending will
* keep the (S,G) states.
*
*
* If a source with kernel cache entry has been idle after the
* last time a check of the datarate for the whole routing
* table, then delete its kernel cache entry.
@ -706,7 +721,7 @@ age_routes()
&mrtentry_grp->oifs) == TRUE)
{
#ifdef KERNEL_MFC_WC_G
// TODO
// TODO
if (kernel_cache_ptr->source
== IN6ADDR_ANY_N)
{
@ -877,7 +892,7 @@ age_routes()
}
else
{
/* iif info found */
if ((srcentry_save.incoming !=
@ -956,7 +971,7 @@ age_routes()
if (!(mrtentry_srcs->flags & MRTF_RP))
continue;
/* Forwarder initiated switch */
did_switch_flag = FALSE;
@ -1031,7 +1046,7 @@ age_routes()
if (src_action != PIM_ACTION_NOTHING)
add_jp_entry(mrtentry_srcs->upstream,
pim_join_prune_holdtime,
pim_join_prune_holdtime,
&mrtentry_srcs->group->group,
SINGLE_GRP_MSK6LEN,
&mrtentry_srcs->source->address,

View File

@ -25,8 +25,6 @@
* 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.
*
* $FreeBSD$
*/
/*
* Questions concerning this software should be directed to
@ -34,47 +32,48 @@
*
*/
/*
* This program has been derived from pim6dd.
* This program has been derived from pim6dd.
* The pim6dd program is covered by the license in the accompanying file
* named "LICENSE.pim6dd".
*/
/*
* This program has been derived from pimd.
* This program has been derived from pimd.
* The pimd program is covered by the license in the accompanying file
* named "LICENSE.pimd".
*
* $FreeBSD$
*/
#ifndef TIMER_H
#define TIMER_H
#define TIMER_H
/* the default granularity if not specified in the config file */
#define DEFAULT_TIMER_INTERVAL 5
#define DEFAULT_TIMER_INTERVAL 5
/* For timeout. The timers count down */
#define SET_TIMER(timer, value) (timer) = (value)
#define RESET_TIMER(timer) (timer) = 0
#define COPY_TIMER(timer_1, timer_2) (timer_2) = (timer_1)
#define IF_TIMER_SET(timer) if ((timer) > 0)
#define IF_TIMER_NOT_SET(timer) if ((timer) <= 0)
#define FIRE_TIMER(timer) (timer) = 0
#define SET_TIMER(timer, value) (timer) = (value)
#define RESET_TIMER(timer) (timer) = 0
#define COPY_TIMER(timer_1, timer_2) (timer_2) = (timer_1)
#define IF_TIMER_SET(timer) if ((timer) > 0)
#define IF_TIMER_NOT_SET(timer) if ((timer) <= 0)
#define FIRE_TIMER(timer) (timer) = 0
#define IF_TIMER_NOT_SET(timer) if ((timer) <= 0)
#define IF_TIMER_NOT_SET(timer) if ((timer) <= 0)
#define IF_TIMEOUT(timer) \
#define IF_TIMEOUT(timer) \
if (!((timer) -= (MIN(timer, timer_interval))))
#define IF_NOT_TIMEOUT(timer) \
#define IF_NOT_TIMEOUT(timer) \
if ((timer) -= (MIN(timer, timer_interval)))
#define TIMEOUT(timer) \
#define TIMEOUT(timer) \
(!((timer) -= (MIN(timer, timer_interval))))
#define NOT_TIMEOUT(timer) \
#define NOT_TIMEOUT(timer) \
((timer) -= (MIN(timer, timer_interval)))
@ -92,11 +91,11 @@ extern u_int32 pim_register_suppression_timeout;
extern u_int32 pim_register_probe_time;
extern u_int32 pim_assert_timeout;
extern void init_timers __P(());
extern void init_timers __P(());
extern void age_vifs __P(());
extern void age_routes __P(());
extern void age_misc __P(());
extern void init_timers __P((void));
extern void init_timers __P((void));
extern void age_vifs __P((void));
extern void age_routes __P((void));
extern void age_misc __P((void));
#endif

View File

@ -1,7 +1,7 @@
/*
* Copyright (C) 1999 WIDE Project.
* All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@ -13,7 +13,7 @@
* 3. Neither the name of the project 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 PROJECT 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
@ -47,7 +47,7 @@
* ABOUT THE SUITABILITY OF THIS SOFTWARE FOR ANY PURPOSE. THIS SOFTWARE IS
* PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, TITLE, AND
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, TITLE, AND
* NON-INFRINGEMENT.
*
* IN NO EVENT SHALL USC, OR ANY OTHER CONTRIBUTOR BE LIABLE FOR ANY
@ -57,11 +57,9 @@
*
* Other copyrights might apply to parts of this software and are so
* noted when applicable.
*
* $FreeBSD$
*/
/*
* Questions concerning this software should be directed to
* Questions concerning this software should be directed to
* Pavlin Ivanov Radoslavov (pavlin@catarina.usc.edu)
*
* $Id: trace.c,v 1.7 1999/09/16 08:45:45 jinmei Exp $
@ -74,6 +72,7 @@
* The mrouted program is COPYRIGHT 1989 by The Board of Trustees of
* Leland Stanford Junior University.
*
* $FreeBSD$
*/
#include <sys/types.h>
@ -226,9 +225,9 @@ accept_mtrace(src, dst, group, ifindex, data, no, datalen)
} else
log(LOG_DEBUG, 0, "...no route");
}
/*
* Query type packet - check if rte exists
* Query type packet - check if rte exists
* Check if the query destination is a vif connected to me.
* and if so, whether I should start response back
*/
@ -262,7 +261,7 @@ accept_mtrace(src, dst, group, ifindex, data, no, datalen)
#endif
}
vifi = find_vif_direct(&dst_sa6);
if (vifi == NO_VIF) {
/*
* The traceroute destination is not on one of
@ -300,21 +299,21 @@ accept_mtrace(src, dst, group, ifindex, data, no, datalen)
"Wrong interface for packet");
errcode = TR_WRONG_IF;
}
}
}
/* Now that we've decided to send a response, save the qid */
oqid = qry->tr_qid;
IF_DEBUG(DEBUG_TRACE)
log(LOG_DEBUG, 0, "Sending traceroute response");
/* copy the packet to the sending buffer */
p = mld6_send_buf + sizeof(struct mld6_hdr);
bcopy(data, p, datalen);
p += datalen;
/*
* If there is no room to insert our reply, coopt the previous hop
* error indication to relay this fact.
@ -333,7 +332,7 @@ accept_mtrace(src, dst, group, ifindex, data, no, datalen)
bzero(resp, sizeof(struct tr6_resp));
datalen += (RLEN + sizeof(struct mld6_hdr));
resp->tr_qarr = htonl(((tp.tv_sec + JAN_1970) << 16) +
resp->tr_qarr = htonl(((tp.tv_sec + JAN_1970) << 16) +
((tp.tv_usec << 10) / 15625));
resp->tr_rproto = PROTO_PIM;
@ -551,7 +550,7 @@ accept_mtrace(src, dst, group, ifindex, data, no, datalen)
"reply" : "request on",
inet6_fmt(dst),
sa6 ? inet6_fmt(&sa6->sin6_addr) : "unspecified");
send_mld6(resptype, no, sa6, &resp_sa6, group, ifindex,
0, datalen, 0);
}

View File

@ -1,7 +1,7 @@
/*
* Copyright (C) 1999 WIDE Project.
* All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@ -13,7 +13,7 @@
* 3. Neither the name of the project 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 PROJECT 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
@ -47,7 +47,7 @@
* ABOUT THE SUITABILITY OF THIS SOFTWARE FOR ANY PURPOSE. THIS SOFTWARE IS
* PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, TITLE, AND
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, TITLE, AND
* NON-INFRINGEMENT.
*
* IN NO EVENT SHALL USC, OR ANY OTHER CONTRIBUTOR BE LIABLE FOR ANY
@ -57,11 +57,9 @@
*
* Other copyrights might apply to parts of this software and are so
* noted when applicable.
*
* $FreeBSD$
*/
/*
* Questions concerning this software should be directed to
* Questions concerning this software should be directed to
* Pavlin Ivanov Radoslavov (pavlin@catarina.usc.edu)
*
* $Id: trace.h,v 1.2 1999/09/09 15:47:11 jinmei Exp $
@ -74,10 +72,11 @@
* The mrouted program is COPYRIGHT 1989 by The Board of Trustees of
* Leland Stanford Junior University.
*
* $FreeBSD$
*/
#ifndef TRACE_H
#define TRACE_H
#define TRACE_H
/*
* The packet format for a traceroute request.
@ -99,8 +98,8 @@ struct tr6_query {
#endif /* BYTE_ORDER */
};
#define tr_rhlim q.rhlim
#define tr_qid q.qid
#define tr_rhlim q.rhlim
#define tr_qid q.qid
/*
* Traceroute response format. A traceroute response has a tr_query at the
@ -129,60 +128,60 @@ struct tr6_resp {
};
/* defs within mtrace */
#define QUERY 1
#define RESP 2
#define QLEN sizeof(struct tr6_query)
#define RLEN sizeof(struct tr6_resp)
#define QUERY 1
#define RESP 2
#define QLEN sizeof(struct tr6_query)
#define RLEN sizeof(struct tr6_resp)
/* fields for tr_inifid and tr_outifid */
#define TR_NO_VIF 0xffffffff/* interface can't be determined */
#define TR_NO_VIF 0xffffffff/* interface can't be determined */
/* fields for tr_rflags (forwarding error codes) */
#define TR_NO_ERR 0 /* No error */
#define TR_WRONG_IF 1 /* traceroute arrived on non-oif */
#define TR_PRUNED 2 /* router has sent a prune upstream */
#define TR_OPRUNED 3 /* stop forw. after request from next hop rtr*/
#define TR_SCOPED 4 /* group adm. scoped at this hop */
#define TR_NO_RTE 5 /* no route for the source */
#define TR_NO_LHR 6 /* not the last-hop router */
#define TR_NO_FWD 7 /* not forwarding for this (S,G). Reason = ? */
#define TR_RP 8 /* I am the RP/Core */
#define TR_IIF 9 /* request arrived on the iif */
#define TR_NO_MULTI 0x0a /* multicast disabled on that interface */
#define TR_NO_SPACE 0x81 /* no space to insert responce data block */
#define TR_OLD_ROUTER 0x82 /* previous hop does not support traceroute */
#define TR_ADMIN_PROHIB 0x83 /* traceroute adm. prohibited */
#define TR_NO_ERR 0 /* No error */
#define TR_WRONG_IF 1 /* traceroute arrived on non-oif */
#define TR_PRUNED 2 /* router has sent a prune upstream */
#define TR_OPRUNED 3 /* stop forw. after request from next hop rtr*/
#define TR_SCOPED 4 /* group adm. scoped at this hop */
#define TR_NO_RTE 5 /* no route for the source */
#define TR_NO_LHR 6 /* not the last-hop router */
#define TR_NO_FWD 7 /* not forwarding for this (S,G). Reason = ? */
#define TR_RP 8 /* I am the RP/Core */
#define TR_IIF 9 /* request arrived on the iif */
#define TR_NO_MULTI 0x0a /* multicast disabled on that interface */
#define TR_NO_SPACE 0x81 /* no space to insert responce data block */
#define TR_OLD_ROUTER 0x82 /* previous hop does not support traceroute */
#define TR_ADMIN_PROHIB 0x83 /* traceroute adm. prohibited */
/* fields for tr_flags */
#define TR_SUBNET_COUNT 0x80 /* pkt count for (S,G) is for source network */
#define TR_SUBNET_COUNT 0x80 /* pkt count for (S,G) is for source network */
/* fields for r_plen */
#define TR_GROUP_ONLY 0xff /* forwarding solely on group state */
#define TR_GROUP_ONLY 0xff /* forwarding solely on group state */
/* fields for packets count */
#define TR_CANT_COUNT 0xffffffff /* no count can be reported */
#define TR_CANT_COUNT 0xffffffff /* no count can be reported */
/* fields for tr_rproto (routing protocol) */
#define PROTO_DVMRP 1
#define PROTO_MOSPF 2
#define PROTO_PIM 3
#define PROTO_CBT 4
#define PROTO_PIM_SPECIAL 5
#define PROTO_PIM_STATIC 6
#define PROTO_DVMRP_STATIC 7
#define PROTO_DVMRP 1
#define PROTO_MOSPF 2
#define PROTO_PIM 3
#define PROTO_CBT 4
#define PROTO_PIM_SPECIAL 5
#define PROTO_PIM_STATIC 6
#define PROTO_DVMRP_STATIC 7
#define MASK_TO_VAL(x, i) { \
#define MASK_TO_VAL(x, i) { \
u_int32_t _x = ntohl(x); \
(i) = 1; \
while ((_x) <<= 1) \
(i)++; \
};
#define VAL_TO_MASK(x, i) { \
#define VAL_TO_MASK(x, i) { \
x = htonl(~((1 << (32 - (i))) - 1)); \
};
#define MASKLEN_TO_MASK6(masklen, mask6) \
#define MASKLEN_TO_MASK6(masklen, mask6) \
do {\
u_char maskarray[8] = \
{0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc, 0xfe, 0xff}; \
@ -198,13 +197,13 @@ struct tr6_resp {
/* obnoxious gcc gives an extraneous warning about this constant... */
#if defined(__STDC__) || defined(__GNUC__)
#define JAN_1970 2208988800UL /* 1970 - 1900 in seconds */
#define JAN_1970 2208988800UL /* 1970 - 1900 in seconds */
#else
#define JAN_1970 2208988800L /* 1970 - 1900 in seconds */
#define const /**/
#define JAN_1970 2208988800L /* 1970 - 1900 in seconds */
#define const /**/
#endif
#define NBR_VERS(n) (((n)->al_pv << 8) + (n)->al_mv)
#define NBR_VERS(n) (((n)->al_pv << 8) + (n)->al_mv)
void accept_mtrace __P((struct sockaddr_in6 *, struct in6_addr *,
struct in6_addr *, int, char *, u_int, int));

View File

@ -1,7 +1,7 @@
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
* All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@ -13,7 +13,7 @@
* 3. Neither the name of the project 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 PROJECT 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
@ -31,32 +31,32 @@
/* YIPS @(#)$Id: var.h,v 1.1 1999/10/29 09:04:54 jinmei Exp $ */
#if !defined(_VAR_H_)
#define _VAR_H_
#define _VAR_H_
#include <sys/socket.h>
#define MAX3(a,b,c) (a > b ? (a > c ? a : c) : (b > c ? b : c))
#define MAX3(a,b,c) (a > b ? (a > c ? a : c) : (b > c ? b : c))
#define CALLOC(size, cast) (cast)calloc(1, (size))
#define CALLOC(size, cast) (cast)calloc(1, (size))
#define ISSET(exp, bit) (((exp) & (bit)) == (bit))
#define ISSET(exp, bit) (((exp) & (bit)) == (bit))
#define ATOX(c) \
#define ATOX(c) \
(isdigit(c) ? (c - '0') : (isupper(c) ? (c - 'A' + 10) : (c - 'a' + 10) ))
#define LALIGN(a) \
#define LALIGN(a) \
((a) > 0 ? ((a) &~ (sizeof(long) - 1)) : sizeof(long))
#define RNDUP(a) \
#define RNDUP(a) \
((a) > 0 ? (1 + (((a) - 1) | (sizeof(long) - 1))) : sizeof(long))
#define BUFADDRSIZE 128
#define INET_NTOP(addr, buf) \
#define BUFADDRSIZE 128
#define INET_NTOP(addr, buf) \
inet_ntop(((struct sockaddr *)(addr))->sa_family, _INADDRBYSA(addr), buf, sizeof(buf))
#define GETNAMEINFO(x, y, z) \
#define GETNAMEINFO(x, y, z) \
getnameinfo((x), (x)->sa_len, (y), sizeof(y), (z), sizeof(z), \
NI_NUMERICHOST | NI_NUMERICSERV)
#define ARRAYSIZE(a) (sizeof(a)/sizeof(a[0]))
#define ARRAYSIZE(a) (sizeof(a)/sizeof(a[0]))
#endif /*!defined(_VAR_H_)*/

View File

@ -29,8 +29,6 @@
*
* Other copyrights might apply to parts of this software and are so
* noted when applicable.
*
* $FreeBSD$
*/
/*
* Questions concerning this software should be directed to
@ -38,12 +36,12 @@
*
*/
/*
* This program has been derived from pim6dd.
* This program has been derived from pim6dd.
* The pim6dd program is covered by the license in the accompanying file
* named "LICENSE.pim6dd".
*/
/*
* This program has been derived from pimd.
* This program has been derived from pimd.
* The pimd program is covered by the license in the accompanying file
* named "LICENSE.pimd".
*
@ -56,6 +54,7 @@
* The mrouted program is COPYRIGHT 1989 by The Board of Trustees of
* Leland Stanford Junior University.
*
* $FreeBSD$
*/
#include <sys/ioctl.h>
@ -87,13 +86,13 @@ int total_interfaces;
if_set if_nullset;
if_set if_result;
int init_reg_vif();
void start_all_vifs();
void start_vif( vifi_t vifi );
void stop_vif( vifi_t vivi );
int update_reg_vif( vifi_t register_vifi);
int init_reg_vif __P((void));
void start_all_vifs __P((void));
void start_vif __P((vifi_t vifi));
void stop_vif __P((vifi_t vivi));
int update_reg_vif __P((vifi_t register_vifi));
extern int cfparse(int, int);
extern int cfparse __P((int, int));
void init_vifs()
{
@ -173,7 +172,7 @@ void init_vifs()
enabled_vifs == 0 ? "no enabled vifs" : "only one enabled vif" );
memset(&if_nullset,0,sizeof(if_nullset));
k_init_pim(mld6_socket);
k_init_pim(mld6_socket);
IF_DEBUG(DEBUG_PIM_DETAIL)
log(LOG_DEBUG,0,"Pim kernel initialization done");
@ -224,7 +223,7 @@ int init_reg_vif()
return -1;
}
memcpy(v,&uvifs[i],sizeof(*v));
strncpy(v->uv_name,"register_mif0",IFNAMSIZ);
v->uv_flags = MIFF_REGISTER;
@ -240,7 +239,7 @@ int init_reg_vif()
numvifs++;
total_interfaces++;
return 0;
return 0;
}
void start_all_vifs()
@ -268,17 +267,17 @@ void start_all_vifs()
IF_DEBUG(DEBUG_IF)
{
if ( v-> uv_flags & VIFF_DISABLED)
log(LOG_DEBUG,0,"%s is DISABLED ; vif #%u out of service",v->uv_name,vifi);
log(LOG_DEBUG,0,"%s is DISABLED ; vif #%u out of service",v->uv_name,vifi);
else
log(LOG_DEBUG,0,"%s is DOWN ; vif #%u out of service",v->uv_name,vifi);
}
}
}
else
start_vif(vifi);
}
if ( action == MIFF_REGISTER)
break;
}
}
}
/*
@ -311,45 +310,46 @@ void start_vif (vifi_t vifi)
IF_DEBUG(DEBUG_IF)
log(LOG_DEBUG,0,"%s comes up ,vif #%u now in service",v->uv_name,vifi);
if(!(v->uv_flags & MIFF_REGISTER))
{
if (!(v->uv_flags & MIFF_REGISTER)) {
/*
* Join the PIM multicast group on the interface.
*/
k_join(mld6_socket, &allpim6routers_group.sin6_addr,
v->uv_ifindex);
/*
* Join the PIM multicast group on the interface.
*/
/*
* Join the ALL-ROUTERS multicast group on the interface.
* This allows mtrace requests to loop back if they are run
* on the multicast router.this allow receiving mld6 messages too.
*/
k_join(mld6_socket, &allrouters_group.sin6_addr, v->uv_ifindex);
k_join(mld6_socket,&allpim6routers_group.sin6_addr,v->uv_ifindex);
/*
* Join the ALL-ROUTERS multicast group on the interface.
* This allows mtrace requests to loop back if they are run
* on the multicast router.this allow receiving mld6 messages too.
*/
k_join(mld6_socket,&allrouters_group.sin6_addr,v->uv_ifindex);
/*
* Until neighbors are discovered, assume responsibility for sending
* periodic group membership queries to the subnet. Send the first
* query.
*/
v->uv_flags |= VIFF_QUERIER;
query_groups(v);
/*
* Send a probe via the new vif to look for neighbors.
*/
send_pim6_hello( v , pim_hello_holdtime );
/*
* Until neighbors are discovered, assume responsibility for sending
* periodic group membership queries to the subnet. Send the first
* query.
*/
v->uv_flags |= VIFF_QUERIER;
if (!v->uv_querier) {
v->uv_querier = (struct listaddr *)malloc(sizeof(struct listaddr));
memset(v->uv_querier, 0, sizeof(struct listaddr));
}
v->uv_querier->al_addr = v->uv_linklocal->pa_addr;
v->uv_querier->al_timer = MLD6_OTHER_QUERIER_PRESENT_INTERVAL;
time(&v->uv_querier->al_ctime); /* reset timestamp */
query_groups(v);
/*
* Send a probe via the new vif to look for neighbors.
*/
send_pim6_hello(v, pim_hello_holdtime);
}
}
/*
* Stop a vif (either physical interface, tunnel or
* register.) If we are running only PIM we don't have tunnels.
*/
*/
void stop_vif( vifi_t vifi )
@ -360,7 +360,7 @@ void stop_vif( vifi_t vifi )
register pim_nbr_entry_t *next;
struct vif_acl *acl;
/*
* TODO: make sure that the kernel viftable is
* consistent with the daemon table
@ -411,7 +411,7 @@ void stop_vif( vifi_t vifi )
v->uv_pim_neighbors=NULL;
}
/* TODO: currently not used */
/* The Access Control List (list with the scoped addresses) */
@ -497,7 +497,7 @@ max_global_address()
&p->pa_addr) &&
!IN6_IS_ADDR_LINKLOCAL(&p->pa_addr.sin6_addr) &&
!IN6_IS_ADDR_SITELOCAL(&p->pa_addr.sin6_addr))
pmax=p;
pmax=p;
}
}
}
@ -522,7 +522,7 @@ uv_global(vifi)
}
/*
* Check if the interface exists in the mif table. If true
* Check if the interface exists in the mif table. If true
* return the highest address of the interface else return NULL.
*/
struct sockaddr_in6 *
@ -562,12 +562,12 @@ local_iface(char *ifname)
return NULL;
}
/*
/*
* See if any interfaces have changed from up state to down, or vice versa,
* including any non-multicast-capable interfaces that are in use as local
* tunnel end-points. Ignore interfaces that have been administratively
* disabled.
*/
*/
void
check_vif_state()
{
@ -596,7 +596,7 @@ check_vif_state()
continue;
strncpy( ifr.ifr_name , v->uv_name , IFNAMSIZ );
/* get the interface flags */
if( ioctl( udp_socket , SIOCGIFFLAGS , (char *)&ifr )<0 )
log(LOG_ERR, errno,
@ -675,12 +675,12 @@ find_vif_direct(src)
vifi_t vifi;
register struct uvif *v;
register struct phaddr *p;
for (vifi = 0, v = uvifs; vifi < numvifs; ++vifi, ++v)
for (vifi = 0, v = uvifs; vifi < numvifs; ++vifi, ++v)
{
if (v->uv_flags & (VIFF_DISABLED | VIFF_DOWN | VIFF_TUNNEL|MIFF_REGISTER))
continue;
for (p = v->uv_addrs; p; p = p->pa_next)
for (p = v->uv_addrs; p; p = p->pa_next)
{
if (inet6_equal(src, &p->pa_addr))
return(NO_VIF);
@ -706,40 +706,40 @@ local_address(src)
register struct phaddr *p;
for (vifi = 0, v = uvifs; vifi < numvifs; ++vifi, ++v) {
if (v->uv_flags & (VIFF_DISABLED | VIFF_DOWN | MIFF_REGISTER))
continue;
for (p = v->uv_addrs; p; p = p->pa_next) {
if (inet6_equal(src, &p->pa_addr))
return(vifi);
}
if (v->uv_flags & (VIFF_DISABLED | VIFF_DOWN | MIFF_REGISTER))
continue;
for (p = v->uv_addrs; p; p = p->pa_next) {
if (inet6_equal(src, &p->pa_addr))
return(vifi);
}
}
/* Returning NO_VIF means not a local address */
return (NO_VIF);
}
/*
/*
* If the source is directly connected, or is local address,
* find the vif number for the corresponding physical interface
* (tunnels excluded).
* Return the vif number or NO_VIF if not found.
*/
*/
vifi_t
find_vif_direct_local(src)
struct sockaddr_in6 *src;
{
{
vifi_t vifi;
register struct uvif *v;
register struct uvif *v;
register struct phaddr *p;
for (vifi = 0, v = uvifs; vifi < numvifs; ++vifi, ++v) {
if (v->uv_flags & (VIFF_DISABLED | VIFF_DOWN | VIFF_TUNNEL |MIFF_REGISTER))
continue;
for (p = v->uv_addrs; p; p = p->pa_next) {
if (inet6_equal(src, &p->pa_addr) ||
inet6_match_prefix(src, &p->pa_prefix, &p->pa_subnetmask))
inet6_match_prefix(src, &p->pa_prefix, &p->pa_subnetmask))
return(vifi);
}
}
@ -755,7 +755,7 @@ vif_forwarder(if_set *p1 , if_set *p2)
{
if (p1->ifs_bits[idx] & p2->ifs_bits[idx])
return(TRUE);
}
/* (p1 & p2) is empty. We're not the forwarder */
@ -792,15 +792,15 @@ vif_xor(if_set *p1 , if_set *p2, if_set *result)
return(result);
}
/*
/*
* stop all vifs
*/
*/
void
stop_all_vifs()
{
vifi_t vifi;
struct uvif *v;
for (vifi = 0, v=uvifs; vifi < numvifs; ++vifi, ++v) {
if (!(v->uv_flags & VIFF_DOWN)) {
stop_vif(vifi);

View File

@ -29,8 +29,6 @@
*
* Other copyrights might apply to parts of this software and are so
* noted when applicable.
*
* $FreeBSD$
*/
/*
* Questions concerning this software should be directed to
@ -38,12 +36,12 @@
*
*/
/*
* This program has been derived from pim6dd.
* This program has been derived from pim6dd.
* The pim6dd program is covered by the license in the accompanying file
* named "LICENSE.pim6dd".
*/
/*
* This program has been derived from pimd.
* This program has been derived from pimd.
* The pimd program is covered by the license in the accompanying file
* named "LICENSE.pimd".
*
@ -56,10 +54,11 @@
* The mrouted program is COPYRIGHT 1989 by The Board of Trustees of
* Leland Stanford Junior University.
*
* $FreeBSD$
*/
#ifndef VIF_H
#define VIF_H
#define VIF_H
#include <sys/param.h>
#include <sys/time.h>
@ -76,41 +75,41 @@ extern int total_interfaces;
extern int udp_socket;
extern struct uvif uvifs[];
extern vifi_t numvifs;
extern int vifs_down;
extern int vifs_down;
extern int phys_vif;
extern vifi_t reg_vif_num;
#define NO_VIF ((vifi_t)MAXVIFS) /* An invalid vif index */
#define DEFAULT_METRIC 1
#define VIFF_DOWN 0x000100
#define VIFF_DISABLED 0x000200
#define VIFF_QUERIER 0x000400
#define VIFF_REXMIT_PRUNES 0x004000
#define VIFF_DR 0x040000
#define VIFF_NONBRS 0x080000
#define VIFF_PIM_NBR 0x200000
#define VIFF_POINT_TO_POINT 0x400000
#define NBRTYPE u_long
#define NBRBITS sizeof(NBRTYPE) *8
#define NO_VIF ((vifi_t)MAXVIFS) /* An invalid vif index */
#define DEFAULT_METRIC 1
#define VIFF_DOWN 0x000100
#define VIFF_DISABLED 0x000200
#define VIFF_QUERIER 0x000400
#define VIFF_REXMIT_PRUNES 0x004000
#define VIFF_DR 0x040000
#define VIFF_NONBRS 0x080000
#define VIFF_PIM_NBR 0x200000
#define VIFF_POINT_TO_POINT 0x400000
#define NBRTYPE u_long
#define NBRBITS sizeof(NBRTYPE) *8
extern if_set if_nullset;
#define IF_ISEMPTY(p) (memcmp((p), &if_nullset, sizeof(if_nullset)) == 0)
#define IF_SAME(p1, p2) (memcmp((p1),(p2),sizeof(*(p1))) == 0)
#define IF_CLR_MASK(p, mask) \
#define IF_ISEMPTY(p) (memcmp((p), &if_nullset, sizeof(if_nullset)) == 0)
#define IF_SAME(p1, p2) (memcmp((p1),(p2),sizeof(*(p1))) == 0)
#define IF_CLR_MASK(p, mask) \
{\
int idx;\
for (idx = 0; idx < sizeof(*(p))/sizeof(fd_mask); idx++) {\
(p)->ifs_bits[idx] &= ~((mask)->ifs_bits[idx]);\
}\
}
#define IF_MERGE(p1, p2, result) \
#define IF_MERGE(p1, p2, result) \
{\
int idx;\
for (idx = 0; idx < sizeof(*(p1))/sizeof(fd_mask); idx++) {\
(result)->ifs_bits[idx] = (p1)->ifs_bits[idx]|(p2)->ifs_bits[idx]; \
}\
}
}
typedef struct {
NBRTYPE hi;
@ -122,12 +121,12 @@ struct vf_element {
struct sockaddr_in6 *vfe_addr;
struct in6_addr vfe_mask;
int vfe_flags;
#define VFRF_EXACT 0x0001
#define VFRF_EXACT 0x0001
};
#define VFT_ACCEPT 1
#define VFT_DENY 2
#define VFF_BIDIR 1
#define VFT_ACCEPT 1
#define VFT_DENY 2
#define VFF_BIDIR 1
struct vif_filter {
int vf_type;
@ -143,9 +142,9 @@ struct listaddr {
union {
u_int32 alu_genid; /* generation id for neighbor */
struct sockaddr_in6 alu_reporter; /* a host which reported membership */
} al_alu;
} al_alu;
u_char al_pv; /* router protocol version */
u_char al_mv; /* router mrouted version */
u_char al_mv; /* router mrouted version */
u_char al_old; /* time since heard old report */
u_char al_index; /* neighbor index */
u_long al_timerid; /* timer for group membership */
@ -153,15 +152,15 @@ struct listaddr {
u_int16 al_flags; /* flags related to this neighbor */
};
#define al_genid al_alu.alu_genid
#define al_reporter al_alu.alu_reporter
#define al_genid al_alu.alu_genid
#define al_reporter al_alu.alu_reporter
/*
* User level Virtual Interface structure
* User level Virtual Interface structure
*
* A "virtual interface" is either a physical, multicast-capable interface
* (called a "phyint"), a virtual point-to-point link (called a "tunnel")
* or a "register vif" used by PIM. The register vif is used by the
* or a "register vif" used by PIM. The register vif is used by the
* Designated Router (DR) to send encapsulated data packets to the
* Rendevous Point (RP) for a particular group. The data packets are
* encapsulated in PIM messages (IPPROTO_PIM = 103) and then unicast to
@ -169,34 +168,34 @@ struct listaddr {
* (Note: all addresses, subnet numbers and masks are kept in NETWORK order.)
*/
struct uvif {
u_int uv_flags;
u_int uv_flags;
u_char uv_metric; /* VIFF_ flags defined below */
u_char uv_admetric; /* advertised cost of this vif */
u_int uv_rate_limit; /* rate limit on this vif */
struct phaddr *uv_linklocal; /* link-local address of this vif */
struct sockaddr_in6 uv_rmt_addr;/* remote end-point addr (tunnels only) */
struct sockaddr_in6 uv_dst_addr;/* destination for PIM messages */
struct sockaddr_in6 uv_prefix; /* prefix (phyints only) */
struct in6_addr uv_subnetmask; /* subnet mask (phyints only) */
struct sockaddr_in6 uv_rmt_addr;/* remote end-point addr (tunnels only) */
struct sockaddr_in6 uv_dst_addr;/* destination for PIM messages */
struct sockaddr_in6 uv_prefix; /* prefix (phyints only) */
struct in6_addr uv_subnetmask; /* subnet mask (phyints only) */
char uv_name[IFNAMSIZ]; /* interface name */
char uv_name[IFNAMSIZ]; /* interface name */
u_int uv_ifindex; /* index of the interface */
u_int uv_siteid; /* index of the site on the interface */
struct listaddr *uv_groups; /* list of local groups (phyints only) */
struct lisaddr *uv_dvmrp_neighbors;
nbrbitmap_t uv_nbrmap; /* bitmap of active neighboring routers */
struct listaddr *uv_querier; /* MLD querier on vif */
struct listaddr *uv_querier; /* MLD querier on vif */
int uv_prune_lifetime; /* Prune lifetime or 0 for default */
struct vif_acl *uv_acl; /* access control list of groups */
struct vif_acl *uv_acl; /* access control list of groups */
int uv_leaftimer; /* time until this vif is considrd leaf */
struct phaddr *uv_addrs; /* Additional addresses on this vif */
struct vif_filter *uvfilter; /* Route filters on this vif */
u_int16 uv_pim_hello_timer; /* timer for sending PIM hello msgs */
u_int16 uv_gq_timer; /* Group Query timer */
u_int16 uv_jp_timer; /* Join/Prune timer */
int uv_local_pref; /* default local preference for assert */
u_int16 uv_jp_timer; /* Join/Prune timer */
int uv_local_pref; /* default local preference for assert */
int uv_local_metric; /* default local metric for assert */
struct pim_nbr_entry *uv_pim_neighbors; /* list of PIM nbr routers */
@ -227,6 +226,7 @@ struct uvif {
/* occurrences of timeouts */
u_quad_t uv_pim6_nbr_timo;
u_quad_t uv_listener_timo;
u_quad_t uv_querier_timo;
u_quad_t uv_outif_timo; /* outgoing interfaces timers */
};
@ -239,7 +239,7 @@ struct phaddr {
/* The Access Control List (list with scoped addresses) member */
#define VIFF_NOLISTENER 0x800000 /* no listener on the link */
#define VIFF_NOLISTENER 0x800000 /* no listener on the link */
struct vif_acl {
struct vif_acl *acl_next;
@ -247,7 +247,7 @@ struct vif_acl {
struct in6_addr acl_mask;
};
/*
/*
* Used to get the RPF neighbor and IIF info
* for a given source from the unicast routing table.
*/
@ -256,22 +256,22 @@ struct rpfctl {
struct sockaddr_in6 source; /* the source for which we want iif and rpfnbr */
struct sockaddr_in6 rpfneighbor;/* next hop towards the source */
vifi_t iif; /* the incoming interface to reach the next hop */
};
};
extern void init_vifs __P(());
extern void stop_all_vifs __P(());
extern void check_vif_state __P(());
struct sockaddr_in6 * max_global_address();
struct sockaddr_in6 * uv_global __P(());
extern void init_vifs __P((void));
extern void stop_all_vifs __P((void));
extern void check_vif_state __P((void));
struct sockaddr_in6 * max_global_address __P((void));
struct sockaddr_in6 * uv_global __P((vifi_t));
extern vifi_t local_address __P((struct sockaddr_in6 *src));
struct sockaddr_in6 * local_iface( char *ifname );
struct sockaddr_in6 * local_iface __P((char *ifname));
extern vifi_t find_vif_direct __P((struct sockaddr_in6 *src));
extern vifi_t find_vif_direct_local __P((struct sockaddr_in6 *src));
extern int vif_forwarder __P((if_set *p1 ,if_set *p2));
extern if_set *vif_and __P((if_set *p1, if_set *p2, if_set *result));
extern if_set *vif_and __P((if_set *p1, if_set *p2, if_set *result));
extern if_set *vif_xor __P((if_set *p1, if_set *p2, if_set *result));
extern struct uvif *find_vif __P((char *ifname));
#endif

View File

@ -1,7 +1,7 @@
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
* All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@ -13,7 +13,7 @@
* 3. Neither the name of the project 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 PROJECT 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
@ -45,5 +45,5 @@ extern void vfree(vchar_t *);
extern vchar_t *vdup(vchar_t *);
extern int pvdump(vchar_t *);
#define VREALLOC(ptr, size) ((ptr) = vrealloc((ptr), (size)))
#define VREALLOC(ptr, size) ((ptr) = vrealloc((ptr), (size)))