Sync with latest KAME.

Obtained from:	KAME
This commit is contained in:
kris 2000-07-05 11:12:53 +00:00
parent 4bf2ee2817
commit 66c44f6a43
7 changed files with 343 additions and 143 deletions

View File

@ -17,13 +17,9 @@ PROG= rrenumd
SRCS= rrenumd.c parser.y lexer.l SRCS= rrenumd.c parser.y lexer.l
YFLAGS+= -d YFLAGS+= -d
CC= gcc
CFLAGS+= -DINET6 -DIPSEC -I${.OBJDIR} CFLAGS+= -DINET6 -DIPSEC -I${.OBJDIR}
LDADD+= -lipsec -lcompat LDADD+= -lipsec -lcompat -ll -ly
DPADD+= ${LIBIPSEC} ${LIBCOMPAT} DPADD+= ${LIBIPSEC} ${LIBCOMPAT} ${LIBL} ${LIBY}
LDADD+= -ll -ly
DPADD+= ${LIBL} ${LIBY}
MAN5= rrenumd.conf.5 MAN5= rrenumd.conf.5
MAN8= rrenumd.8 MAN8= rrenumd.8

View File

@ -1,3 +1,5 @@
/* $KAME$ */
/* /*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
* All rights reserved. * All rights reserved.
@ -37,16 +39,21 @@
#include <string.h> #include <string.h>
#include <net/if.h> #include <net/if.h>
#if defined(__FreeBSD__) && __FreeBSD__ >= 3
#include <net/if_var.h> #include <net/if_var.h>
#endif /* __FreeBSD__ >= 3 */
#include <netinet/in.h> #include <netinet/in.h>
#include <netinet/in_var.h> #include <netinet/in_var.h>
#include <netinet/icmp6.h> #include <netinet/icmp6.h>
#include <arpa/inet.h>
#include "y.tab.h" #include "y.tab.h"
int lineno = 1; int lineno = 1;
#define LINEBUF_SIZE 1000 #define LINEBUF_SIZE 1000
char linebuf[LINEBUF_SIZE]; char linebuf[LINEBUF_SIZE];
%} %}
@ -209,6 +216,15 @@ off {
yylval.cs.len = yyleng; yylval.cs.len = yyleng;
return NAME; return NAME;
} }
{ipv4addr} {
memset(&yylval.addr4, 0, sizeof(struct in_addr));
if (inet_pton(AF_INET, yytext,
&yylval.addr4) == 1) {
return IPV4ADDR;
} else {
return ERROR;
}
}
{ipv6addr} { {ipv6addr} {
memset(&yylval.addr6, 0, sizeof(struct in6_addr)); memset(&yylval.addr6, 0, sizeof(struct in6_addr));
if (inet_pton(AF_INET6, yytext, if (inet_pton(AF_INET6, yytext,

View File

@ -1,3 +1,5 @@
/* $KAME$ */
/* /*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
* All rights reserved. * All rights reserved.
@ -36,7 +38,9 @@
#include <sys/uio.h> #include <sys/uio.h>
#include <net/if.h> #include <net/if.h>
#if defined(__FreeBSD__) && __FreeBSD__ >= 3
#include <net/if_var.h> #include <net/if_var.h>
#endif /* __FreeBSD__ >= 3 */
#include <netinet/in.h> #include <netinet/in.h>
#include <netinet/in_var.h> #include <netinet/in_var.h>
@ -48,40 +52,40 @@
#include "rrenumd.h" #include "rrenumd.h"
struct config_is_set { struct config_is_set {
u_short cis_dest : 1; u_short cis_dest : 1;
} cis; } cis;
struct dst_list *dl_head; struct dst_list *dl_head;
struct payload_list *pl_head, ple_cur; struct payload_list *pl_head, ple_cur;
u_int retry; u_int retry;
char errbuf[LINE_MAX]; char errbuf[LINE_MAX];
extern int lineno; extern int lineno;
extern void yyerror __P((const char *s)); extern void yyerror __P((const char *s));
static struct payload_list * pllist_lookup __P((int seqnum)); static struct payload_list * pllist_lookup __P((int seqnum));
static void pllist_enqueue __P((struct payload_list *pl_entry)); static void pllist_enqueue __P((struct payload_list *pl_entry));
#define MAX_RETRYNUM 10 /* upper limit of retry in this rrenumd program */ #define MAX_RETRYNUM 10 /* upper limit of retry in this rrenumd program */
#define MAX_SEQNUM 256 /* upper limit of seqnum in this rrenumd program */ #define MAX_SEQNUM 256 /* upper limit of seqnum in this rrenumd program */
#define NOSPEC -1 #define NOSPEC -1
%} %}
%union { %union {
u_long num; u_long num;
struct { struct {
char *cp; char *cp;
int len; int len;
} cs; } cs;
struct in_addr addr4; struct in_addr addr4;
struct in6_addr addr6; struct in6_addr addr6;
struct { struct {
struct in6_addr addr; struct in6_addr addr;
u_char plen; u_char plen;
} prefix; } prefix;
struct dst_list *dl; struct dst_list *dl;
struct payload_list *pl; struct payload_list *pl;
struct sockaddr *sa; struct sockaddr *sa;
} }
%token <num> ADD CHANGE SETGLOBAL %token <num> ADD CHANGE SETGLOBAL
@ -103,7 +107,7 @@ static void pllist_enqueue __P((struct payload_list *pl_entry));
%type <num> lifetime days hours minutes seconds %type <num> lifetime days hours minutes seconds
%type <num> decstring %type <num> decstring
%type <num> raf_onlink raf_auto raf_decrvalid raf_decrprefd flag %type <num> raf_onlink raf_auto raf_decrvalid raf_decrprefd flag
%type <dl> dest_addrs dest_addr sin6 %type <dl> dest_addrs dest_addr sin sin6
%type <pl> rrenum_statement %type <pl> rrenum_statement
%type <cs> ifname %type <cs> ifname
%type <prefix> prefixval %type <prefix> prefixval
@ -158,7 +162,11 @@ dest_addrs:
; ;
dest_addr : dest_addr :
sin6 sin
{
with_v4dest = 1;
}
| sin6
{ {
with_v6dest = 1; with_v6dest = 1;
} }
@ -179,7 +187,7 @@ dest_addr :
memset(&hints, 0, sizeof(hints)); memset(&hints, 0, sizeof(hints));
hints.ai_flags = AI_CANONNAME; hints.ai_flags = AI_CANONNAME;
hints.ai_family = AF_INET6; hints.ai_family = AF_UNSPEC;
hints.ai_socktype = SOCK_RAW; hints.ai_socktype = SOCK_RAW;
hints.ai_protocol = 0; hints.ai_protocol = 0;
error = getaddrinfo($1.cp, 0, &hints, &res); error = getaddrinfo($1.cp, 0, &hints, &res);
@ -200,6 +208,24 @@ dest_addr :
} }
; ;
sin:
IPV4ADDR
{
struct sockaddr_in *sin;
sin = (struct sockaddr_in *)malloc(sizeof(*sin));
memset(sin, 0, sizeof(*sin));
sin->sin_len = sizeof(*sin);
sin->sin_family = AF_INET;
sin->sin_addr = $1;
$$ = (struct dst_list *)
malloc(sizeof(struct dst_list));
memset($$, 0, sizeof(struct dst_list));
$$->dl_dst = (struct sockaddr *)sin;
}
;
sin6: sin6:
IPV6ADDR IPV6ADDR
{ {
@ -427,39 +453,43 @@ use_prefix_values:
rpu->rpu_vltime = $2; rpu->rpu_vltime = $2;
rpu->rpu_pltime = $3; rpu->rpu_pltime = $3;
if ($4 == NOSPEC) if ($4 == NOSPEC) {
rpu->rpu_ramask &= rpu->rpu_ramask &=
~ICMP6_RR_PCOUSE_RAFLAGS_ONLINK; ~ICMP6_RR_PCOUSE_RAFLAGS_ONLINK;
else { } else {
rpu->rpu_ramask |= rpu->rpu_ramask |=
ICMP6_RR_PCOUSE_RAFLAGS_ONLINK; ICMP6_RR_PCOUSE_RAFLAGS_ONLINK;
if ($4 == ON) if ($4 == ON) {
rpu->rpu_raflags |= rpu->rpu_raflags |=
ICMP6_RR_PCOUSE_RAFLAGS_ONLINK; ICMP6_RR_PCOUSE_RAFLAGS_ONLINK;
else } else {
rpu->rpu_raflags &= rpu->rpu_raflags &=
~ICMP6_RR_PCOUSE_RAFLAGS_ONLINK; ~ICMP6_RR_PCOUSE_RAFLAGS_ONLINK;
}
} }
if ($5 == NOSPEC) if ($5 == NOSPEC) {
rpu->rpu_ramask &= rpu->rpu_ramask &=
ICMP6_RR_PCOUSE_RAFLAGS_AUTO; ICMP6_RR_PCOUSE_RAFLAGS_AUTO;
else { } else {
rpu->rpu_ramask |= rpu->rpu_ramask |=
ICMP6_RR_PCOUSE_RAFLAGS_AUTO; ICMP6_RR_PCOUSE_RAFLAGS_AUTO;
if ($5 == ON) if ($5 == ON) {
rpu->rpu_raflags |= rpu->rpu_raflags |=
ICMP6_RR_PCOUSE_RAFLAGS_AUTO; ICMP6_RR_PCOUSE_RAFLAGS_AUTO;
else } else {
rpu->rpu_raflags &= rpu->rpu_raflags &=
~ICMP6_RR_PCOUSE_RAFLAGS_AUTO; ~ICMP6_RR_PCOUSE_RAFLAGS_AUTO;
}
} }
rpu->rpu_flags = 0; rpu->rpu_flags = 0;
if ($6 == ON) if ($6 == ON) {
rpu->rpu_flags |= rpu->rpu_flags |=
ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME; ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME;
if ($7 == ON) }
if ($7 == ON) {
rpu->rpu_flags |= rpu->rpu_flags |=
ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME; ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME;
}
} }
; ;

View File

@ -1,3 +1,5 @@
.\" $KAME$
.\"
.\" Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. .\" Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
.\" All rights reserved. .\" All rights reserved.
.\" .\"
@ -25,12 +27,11 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE. .\" SUCH DAMAGE.
.\" .\"
.\" $Id: rrenumd.8,v 1.1.1.1 1999/08/08 23:31:38 itojun Exp $
.\" $FreeBSD$ .\" $FreeBSD$
.\" .\"
.Dd Sep 7, 1998 .Dd Sep 7, 1998
.Dt RRENUMD 8 .Dt RRENUMD 8
.Os KAME .Os
.Sh NAME .Sh NAME
.Nm rrenumd .Nm rrenumd
.Nd router renumbering daemon .Nd router renumbering daemon
@ -39,7 +40,6 @@
.Oo .Oo
.Fl c Ar conf_file | Fl s .Fl c Ar conf_file | Fl s
.Oc .Oc
.Op Fl P Ar policy
.Op Fl df .Op Fl df
.Sh DESCRIPTION .Sh DESCRIPTION
.Nm Rrenumd .Nm Rrenumd
@ -72,13 +72,6 @@ Do not become daemon.
.It Fl s .It Fl s
Script mode. Script mode.
Configuration information is obtained from standard input. Configuration information is obtained from standard input.
.It Fl P Ar policy
.Ar policy
specifies IPsec policy for the rrenumd session.
For details please refer to
.Xr ipsec 4
and
.Xr ipsec_set_policy 3 .
.It Fl c Ar conf_file .It Fl c Ar conf_file
Specify a configuration file where configuration information is kept. Specify a configuration file where configuration information is kept.
.Sh RETURN VALUES .Sh RETURN VALUES

View File

@ -1,3 +1,5 @@
/* $KAME$ */
/* /*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
* All rights reserved. * All rights reserved.
@ -44,11 +46,14 @@
#include <netinet/ip6.h> #include <netinet/ip6.h>
#include <netinet/icmp6.h> #include <netinet/icmp6.h>
#include <arpa/inet.h>
#ifdef IPSEC #ifdef IPSEC
#include <netinet6/ipsec.h> #include <netinet6/ipsec.h>
#endif #endif
#include <stdio.h> #include <stdio.h>
#include <err.h>
#include <errno.h> #include <errno.h>
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h> #include <unistd.h>
@ -56,36 +61,39 @@
#include "rrenumd.h" #include "rrenumd.h"
#define LL_ALLROUTERS "ff02::2" #define LL_ALLROUTERS "ff02::2"
#define SL_ALLROUTERS "ff05::2" #define SL_ALLROUTERS "ff05::2"
#ifndef IN6_IS_SCOPE_LINKLOCAL #ifndef IN6_IS_SCOPE_LINKLOCAL
#define IN6_IS_SCOPE_LINKLOCAL(a) \ #define IN6_IS_SCOPE_LINKLOCAL(a) \
((IN6_IS_ADDR_LINKLOCAL(a)) || \ ((IN6_IS_ADDR_LINKLOCAL(a)) || \
(IN6_IS_ADDR_MC_LINKLOCAL(a))) (IN6_IS_ADDR_MC_LINKLOCAL(a)))
#endif /* IN6_IS_SCOPE_LINKLOCAL */ #endif /* IN6_IS_SCOPE_LINKLOCAL */
struct flags { struct flags {
u_long debug : 1; u_long debug : 1;
u_long fg : 1; u_long fg : 1;
#ifdef IPSEC #ifdef IPSEC
#ifdef IPSEC_POLICY_IPSEC #ifdef IPSEC_POLICY_IPSEC
u_long policy : 1; u_long policy : 1;
#else /* IPSEC_POLICY_IPSEC */
u_long auth : 1;
u_long encrypt : 1;
#endif /* IPSEC_POLICY_IPSEC */ #endif /* IPSEC_POLICY_IPSEC */
#endif /*IPSEC*/ #endif /*IPSEC*/
}; };
struct msghdr sndmhdr; struct msghdr sndmhdr;
struct msghdr rcvmhdr; struct msghdr rcvmhdr;
struct sockaddr_in6 from; struct sockaddr_in6 from;
struct sockaddr_in6 sin6_ll_allrouters; struct sockaddr_in6 sin6_ll_allrouters;
int s6; int s4, s6;
int with_v6dest; int with_v4dest, with_v6dest;
struct in6_addr prefix; /* ADHOC */ struct in6_addr prefix; /* ADHOC */
int prefixlen = 64; /* ADHOC */ int prefixlen = 64; /* ADHOC */
extern int parse(FILE **fp); extern int parse(FILE **fp);
/* Print usage. Don't call this after daemonized. */ /* Print usage. Don't call this after daemonized. */
static void static void
@ -95,6 +103,8 @@ show_usage()
#ifdef IPSEC #ifdef IPSEC
#ifdef IPSEC_POLICY_IPSEC #ifdef IPSEC_POLICY_IPSEC
"] [-P policy" "] [-P policy"
#else /* IPSEC_POLICY_IPSEC */
"AE"
#endif /* IPSEC_POLICY_IPSEC */ #endif /* IPSEC_POLICY_IPSEC */
#endif /* IPSEC */ #endif /* IPSEC */
"]\n"); "]\n");
@ -111,15 +121,44 @@ init_sin6(struct sockaddr_in6 *sin6, const char *addr_ascii)
; /* XXX do something */ ; /* XXX do something */
} }
#if 0 /* XXX: not necessary ?? */
void
join_multi(const char *addrname)
{
struct ipv6_mreq mreq;
if (inet_pton(AF_INET6, addrname, &mreq.ipv6mr_multiaddr.s6_addr)
!= 1) {
syslog(LOG_ERR, "<%s> inet_pton failed(library bug?)",
__FUNCTION__);
exit(1);
}
/* ADHOC: currently join only one */
{
if ((mreq.ipv6mr_interface = if_nametoindex(ifname)) == 0) {
syslog(LOG_ERR, "<%s> ifname %s should be invalid: %s",
__FUNCTION__, ifname, strerror(errno));
exit(1);
}
if (setsockopt(s, IPPROTO_IPV6, IPV6_JOIN_GROUP,
&mreq,
sizeof(mreq)) < 0) {
syslog(LOG_ERR, "<%s> IPV6_JOIN_GROUP on %s: %s",
__FUNCTION__, ifname, strerror(errno));
exit(1);
}
}
}
#endif
void void
init_globals() init_globals()
{ {
static struct iovec rcviov; static struct iovec rcviov;
static u_char rprdata[4500]; /* maximal MTU of connected links */ static u_char rprdata[4500]; /* maximal MTU of connected links */
static u_char rcvcmsgbuf[CMSG_SPACE(sizeof(struct in6_pktinfo)) + static u_char *rcvcmsgbuf = NULL;
CMSG_SPACE(sizeof(int))]; static u_char *sndcmsgbuf = NULL;
static u_char sndcmsgbuf[CMSG_SPACE(sizeof(struct in6_pktinfo)) + int sndcmsglen, rcvcmsglen;
CMSG_SPACE(sizeof(int))];
/* init ll_allrouters */ /* init ll_allrouters */
init_sin6(&sin6_ll_allrouters, LL_ALLROUTERS); init_sin6(&sin6_ll_allrouters, LL_ALLROUTERS);
@ -130,14 +169,28 @@ init_globals()
rcvmhdr.msg_namelen = sizeof(struct sockaddr_in6); rcvmhdr.msg_namelen = sizeof(struct sockaddr_in6);
rcvmhdr.msg_iov = &rcviov; rcvmhdr.msg_iov = &rcviov;
rcvmhdr.msg_iovlen = 1; rcvmhdr.msg_iovlen = 1;
rcvcmsglen = CMSG_SPACE(sizeof(struct in6_pktinfo)) +
CMSG_SPACE(sizeof(int));
if (rcvcmsgbuf == NULL &&
(rcvcmsgbuf = (u_char *)malloc(rcvcmsglen)) == NULL) {
syslog(LOG_ERR, "<%s>: malloc failed", __FUNCTION__);
exit(1);
}
rcvmhdr.msg_control = (caddr_t)rcvcmsgbuf; rcvmhdr.msg_control = (caddr_t)rcvcmsgbuf;
rcvmhdr.msg_controllen = sizeof(rcvcmsgbuf); rcvmhdr.msg_controllen = rcvcmsglen;
/* initialize msghdr for sending packets */ /* initialize msghdr for sending packets */
sndmhdr.msg_namelen = sizeof(struct sockaddr_in6); sndmhdr.msg_namelen = sizeof(struct sockaddr_in6);
sndmhdr.msg_iovlen = 1; sndmhdr.msg_iovlen = 1;
sndcmsglen = CMSG_SPACE(sizeof(struct in6_pktinfo)) +
CMSG_SPACE(sizeof(int));
if (sndcmsgbuf == NULL &&
(sndcmsgbuf = (u_char *)malloc(sndcmsglen)) == NULL) {
syslog(LOG_ERR, "<%s>: malloc failed", __FUNCTION__);
exit(1);
}
sndmhdr.msg_control = (caddr_t)sndcmsgbuf; sndmhdr.msg_control = (caddr_t)sndcmsgbuf;
sndmhdr.msg_controllen = sizeof(sndcmsgbuf); sndmhdr.msg_controllen = sndcmsglen;
} }
void void
@ -191,7 +244,12 @@ sock6_open(struct flags *flags
) )
{ {
struct icmp6_filter filt; struct icmp6_filter filt;
int on, optval; int on;
#ifdef IPSEC
#ifndef IPSEC_POLICY_IPSEC
int optval;
#endif
#endif
if (with_v6dest == 0) if (with_v6dest == 0)
return; return;
@ -202,7 +260,13 @@ sock6_open(struct flags *flags
exit(1); exit(1);
} }
/* join all routers multicast addresses, not necessary? */ /*
* join all routers multicast addresses.
*/
#if 0 /* XXX: not necessary ?? */
join_multi(LL_ALLROUTERS);
join_multi(SL_ALLROUTERS);
#endif
/* set icmpv6 filter */ /* set icmpv6 filter */
ICMP6_FILTER_SETBLOCKALL(&filt); ICMP6_FILTER_SETBLOCKALL(&filt);
@ -236,6 +300,91 @@ sock6_open(struct flags *flags
err(1, NULL); err(1, NULL);
free(buf); free(buf);
} }
#else /* IPSEC_POLICY_IPSEC */
if (flags->auth) {
optval = IPSEC_LEVEL_REQUIRE;
if (setsockopt(s6, IPPROTO_IPV6, IPV6_AUTH_TRANS_LEVEL,
&optval, sizeof(optval)) == -1) {
syslog(LOG_ERR, "<%s> IPV6_AUTH_TRANS_LEVEL: %s",
__FUNCTION__, strerror(errno));
exit(1);
}
}
if (flags->encrypt) {
optval = IPSEC_LEVEL_REQUIRE;
if (setsockopt(s6, IPPROTO_IPV6, IPV6_ESP_TRANS_LEVEL,
&optval, sizeof(optval)) == -1) {
syslog(LOG_ERR, "<%s> IPV6_ESP_TRANS_LEVEL: %s",
__FUNCTION__, strerror(errno));
exit(1);
}
}
#endif /* IPSEC_POLICY_IPSEC */
#endif /* IPSEC */
return;
}
void
sock4_open(struct flags *flags
#ifdef IPSEC_POLICY_IPSEC
, char *policy
#endif /* IPSEC_POLICY_IPSEC */
)
{
#ifdef IPSEC
#ifndef IPSEC_POLICY_IPSEC
int optval;
#endif
#endif
if (with_v4dest == 0)
return;
if ((s4 = socket(AF_INET, SOCK_RAW, IPPROTO_ICMPV6)) < 0) {
syslog(LOG_ERR, "<%s> socket(v4): %s", __FUNCTION__,
strerror(errno));
exit(1);
}
#if 0 /* XXX: not necessary ?? */
/*
* join all routers multicast addresses.
*/
some_join_function();
#endif
#ifdef IPSEC
#ifdef IPSEC_POLICY_IPSEC
if (flags->policy) {
char *buf;
buf = ipsec_set_policy(policy, strlen(policy));
if (buf == NULL)
errx(1, ipsec_strerror());
/* XXX should handle in/out bound policy. */
if (setsockopt(s4, IPPROTO_IP, IP_IPSEC_POLICY,
buf, ipsec_get_policylen(buf)) < 0)
err(1, NULL);
free(buf);
}
#else /* IPSEC_POLICY_IPSEC */
if (flags->auth) {
optval = IPSEC_LEVEL_REQUIRE;
if (setsockopt(s4, IPPROTO_IP, IP_AUTH_TRANS_LEVEL,
&optval, sizeof(optval)) == -1) {
syslog(LOG_ERR, "<%s> IP_AUTH_TRANS_LEVEL: %s",
__FUNCTION__, strerror(errno));
exit(1);
}
}
if (flags->encrypt) {
optval = IPSEC_LEVEL_REQUIRE;
if (setsockopt(s4, IPPROTO_IP, IP_ESP_TRANS_LEVEL,
&optval, sizeof(optval)) == -1) {
syslog(LOG_ERR, "<%s> IP_ESP_TRANS_LEVEL: %s",
__FUNCTION__, strerror(errno));
exit(1);
}
}
#endif /* IPSEC_POLICY_IPSEC */ #endif /* IPSEC_POLICY_IPSEC */
#endif /* IPSEC */ #endif /* IPSEC */
@ -248,7 +397,6 @@ rrenum_output(struct payload_list *pl, struct dst_list *dl)
int i, msglen = 0; int i, msglen = 0;
struct cmsghdr *cm; struct cmsghdr *cm;
struct in6_pktinfo *pi; struct in6_pktinfo *pi;
struct icmp6_router_renum *rr;
struct sockaddr_in6 *sin6 = NULL; struct sockaddr_in6 *sin6 = NULL;
sndmhdr.msg_name = (caddr_t)dl->dl_dst; sndmhdr.msg_name = (caddr_t)dl->dl_dst;
@ -267,7 +415,7 @@ rrenum_output(struct payload_list *pl, struct dst_list *dl)
pi = (struct in6_pktinfo *)CMSG_DATA(cm); pi = (struct in6_pktinfo *)CMSG_DATA(cm);
memset(&pi->ipi6_addr, 0, sizeof(pi->ipi6_addr)); /*XXX*/ memset(&pi->ipi6_addr, 0, sizeof(pi->ipi6_addr)); /*XXX*/
pi->ipi6_ifindex = sin6->sin6_scope_id; pi->ipi6_ifindex = sin6->sin6_scope_id;
msglen += CMSG_SPACE(sizeof(struct in6_pktinfo)); msglen += CMSG_LEN(sizeof(struct in6_pktinfo));
/* specify the hop limit of the packet if dest is link local */ /* specify the hop limit of the packet if dest is link local */
/* not defined by router-renum-05.txt, but maybe its OK */ /* not defined by router-renum-05.txt, but maybe its OK */
@ -276,14 +424,14 @@ rrenum_output(struct payload_list *pl, struct dst_list *dl)
cm->cmsg_type = IPV6_HOPLIMIT; cm->cmsg_type = IPV6_HOPLIMIT;
cm->cmsg_len = CMSG_LEN(sizeof(int)); cm->cmsg_len = CMSG_LEN(sizeof(int));
memcpy(CMSG_DATA(cm), &hoplimit, sizeof(int)); memcpy(CMSG_DATA(cm), &hoplimit, sizeof(int));
msglen += CMSG_SPACE(sizeof(int)); msglen += CMSG_LEN(sizeof(int));
} }
sndmhdr.msg_controllen = msglen; sndmhdr.msg_controllen = msglen;
if (sndmhdr.msg_controllen == 0) if (sndmhdr.msg_controllen == 0)
sndmhdr.msg_control = 0; sndmhdr.msg_control = 0;
sndmhdr.msg_iov = &pl->pl_sndiov; sndmhdr.msg_iov = &pl->pl_sndiov;
i = sendmsg(s6, &sndmhdr, 0); i = sendmsg(dl->dl_dst->sa_family == AF_INET ? s4 : s6, &sndmhdr, 0);
if (i < 0 || i != sndmhdr.msg_iov->iov_len) if (i < 0 || i != sndmhdr.msg_iov->iov_len)
syslog(LOG_ERR, "<%s> sendmsg: %s", __FUNCTION__, syslog(LOG_ERR, "<%s> sendmsg: %s", __FUNCTION__,
@ -322,12 +470,19 @@ rrenum_input(int s)
strerror(errno)); strerror(errno));
return; return;
} }
if (s == s4)
i -= sizeof(struct ip);
if (i < sizeof(struct icmp6_router_renum)) { if (i < sizeof(struct icmp6_router_renum)) {
syslog(LOG_ERR, "<%s> packet size(%d) is too short", syslog(LOG_ERR, "<%s> packet size(%d) is too short",
__FUNCTION__, i); __FUNCTION__, i);
return; return;
} }
rr = (struct icmp6_router_renum *)rcvmhdr.msg_iov->iov_base; if (s == s4) {
struct ip *ip = (struct ip *)rcvmhdr.msg_iov->iov_base;
rr = (struct icmp6_router_renum *)(ip + 1);
} else /* s == s6 */
rr = (struct icmp6_router_renum *)rcvmhdr.msg_iov->iov_base;
switch(rr->rr_code) { switch(rr->rr_code) {
case ICMP6_ROUTER_RENUMBERING_COMMAND: case ICMP6_ROUTER_RENUMBERING_COMMAND:
@ -337,7 +492,7 @@ rrenum_input(int s)
/* TODO: receiving result message */ /* TODO: receiving result message */
break; break;
default: default:
syslog(LOG_ERR, "<%s> received unknown code %d" syslog(LOG_ERR, "<%s> received unknown code %d",
__FUNCTION__, rr->rr_code); __FUNCTION__, rr->rr_code);
break; break;
} }
@ -346,7 +501,6 @@ rrenum_input(int s)
int int
main(int argc, char *argv[]) main(int argc, char *argv[])
{ {
char *cfile = NULL;
FILE *fp = stdin; FILE *fp = stdin;
fd_set fdset; fd_set fdset;
struct timeval timeout; struct timeval timeout;
@ -358,13 +512,15 @@ main(int argc, char *argv[])
#endif #endif
memset(&flags, 0, sizeof(flags)); memset(&flags, 0, sizeof(flags));
openlog(*argv, LOG_PID, LOG_DAEMON); openlog("rrenumd", LOG_PID, LOG_DAEMON);
/* get options */ /* get options */
while ((ch = getopt(argc, argv, "c:sdf" while ((ch = getopt(argc, argv, "c:sdf"
#ifdef IPSEC #ifdef IPSEC
#ifdef IPSEC_POLICY_IPSEC #ifdef IPSEC_POLICY_IPSEC
"P:" "P"
#else /* IPSEC_POLICY_IPSEC */
"AE"
#endif /* IPSEC_POLICY_IPSEC */ #endif /* IPSEC_POLICY_IPSEC */
#endif /* IPSEC */ #endif /* IPSEC */
)) != -1){ )) != -1){
@ -392,6 +548,13 @@ main(int argc, char *argv[])
flags.policy = 1; flags.policy = 1;
policy = strdup(optarg); policy = strdup(optarg);
break; break;
#else /* IPSEC_POLICY_IPSEC */
case 'A':
flags.auth = 1;
break;
case 'E':
flags.encrypt = 1;
break;
#endif /* IPSEC_POLICY_IPSEC */ #endif /* IPSEC_POLICY_IPSEC */
#endif /*IPSEC*/ #endif /*IPSEC*/
default: default:
@ -415,6 +578,11 @@ main(int argc, char *argv[])
sock6_open(&flags sock6_open(&flags
#ifdef IPSEC_POLICY_IPSEC #ifdef IPSEC_POLICY_IPSEC
, policy , policy
#endif /* IPSEC_POLICY_IPSEC */
);
sock4_open(&flags
#ifdef IPSEC_POLICY_IPSEC
, policy
#endif /* IPSEC_POLICY_IPSEC */ #endif /* IPSEC_POLICY_IPSEC */
); );
@ -427,6 +595,11 @@ main(int argc, char *argv[])
if (s6 > maxfd) if (s6 > maxfd)
maxfd = s6; maxfd = s6;
} }
if (with_v4dest) {
FD_SET(s4, &fdset);
if (s4 > maxfd)
maxfd = s4;
}
/* ADHOC: timeout each 30seconds */ /* ADHOC: timeout each 30seconds */
memset(&timeout, 0, sizeof(timeout)); memset(&timeout, 0, sizeof(timeout));
@ -454,6 +627,8 @@ main(int argc, char *argv[])
send_counter = retry + 1; send_counter = retry + 1;
} }
} }
if (FD_ISSET(s4, &select_fd))
rrenum_input(s4);
if (FD_ISSET(s6, &select_fd)) if (FD_ISSET(s6, &select_fd))
rrenum_input(s6); rrenum_input(s6);
} }

View File

@ -1,3 +1,5 @@
.\" $KAME$
.\"
.\" Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. .\" Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
.\" All rights reserved. .\" All rights reserved.
.\" .\"
@ -25,7 +27,6 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE. .\" SUCH DAMAGE.
.\" .\"
.\" $Id: rrenumd.conf.5,v 1.1.1.1 1999/08/08 23:31:39 itojun Exp $
.\" $FreeBSD$ .\" $FreeBSD$
.\" .\"
.Dd Nov 5, 1998 .Dd Nov 5, 1998
@ -61,15 +62,15 @@ square brackets (`[' and `]') are used to show optional
keywords and parameters. keywords and parameters.
The vertical bar (`|') is used to indicate The vertical bar (`|') is used to indicate
between a choice of optional parameters. between a choice of optional parameters.
Curly braces (`{' and Parentheses (`(' and
`}') are used to group keywords and parameters when necessary. `)') are used to group keywords and parameters when necessary.
.\" .\"
.Sh Interface specification .Sh Interface specification
There are some statements that may or have to specify interface. There are some statements that may or have to specify interface.
Interfaces are specified in the form of "name unit", such as Interfaces are specified in the form of "name unit", such as
.Ar lo0 .Ar lo0
and and
.Ar ep1 . .Ar ep1.
.\" .\"
.Sh Configuration Statements .Sh Configuration Statements
.Bl -tag -width Ds .Bl -tag -width Ds
@ -83,8 +84,7 @@ then debugging is enabled,
If If
.Ic off .Ic off
is specified, is specified,
then debugging is disabled. then debugging is disabled. It is disabled by default.
It is disabled by default.
.\" .\"
.It Ic dest Ar dest-list Op Ar retrycmd ; .It Ic dest Ar dest-list Op Ar retrycmd ;
Specifies destinations to which router renumbering messages should be Specifies destinations to which router renumbering messages should be
@ -164,7 +164,7 @@ copied to the starting part of prefixes to be added on
.Cm add|change|setglobal .Cm add|change|setglobal
command, as decimal bit number. command, as decimal bit number.
.It Cm keeplen Ar keeplen-val .It Cm keeplen Ar keeplen-val
Specify the medium part of Specify the midium part of
.Ar use-prefix-val .Ar use-prefix-val
just next to the starting part specified by just next to the starting part specified by
.Ar use-prefix-len .Ar use-prefix-len
@ -181,8 +181,7 @@ Valid value for
.Ar time .Ar time
is decimal seconds number or special format as "d00h00m00s00", is decimal seconds number or special format as "d00h00m00s00",
where 00 can take any decimal number, and "d" means days, "h" means hours, where 00 can take any decimal number, and "d" means days, "h" means hours,
"m" means minutes, "s" means seconds. "m" means minutes, "s" means seconds. And alternatively, special keyword
And alternatively, special keyword
"infinity" can be also be specified. "infinity" can be also be specified.
.It Cm pltime Ar pltime-val .It Cm pltime Ar pltime-val
Assign an Assign an
@ -194,48 +193,38 @@ is same as for
.Ar vltime-val . .Ar vltime-val .
.It Cm raf_onlink Cm on|off .It Cm raf_onlink Cm on|off
Let the prefix to be added to have on-link or off-link nature Let the prefix to be added to have on-link or off-link nature
for the assigned interface. for the assigned interface. If
If
.Cm on .Cm on
is specified, the prefix have on-link nature. is specified, the prefix have on-link nature. (e.g. the prefix
(e.g. the prefix
belong to the link) If belong to the link) If
.Cm off .Cm off
is specified, the prefix have off-link nature. is specified, the prefix have off-link nature. (e.g. the
(e.g. the
prefix does not belong to the link) prefix does not belong to the link)
.It Cm raf_auto Cm on|off .It Cm raf_auto Cm on|off
Enable or disable the autonomous address auto configuration Enable or disable the autonomous address auto configuration
for the prefix to be added. for the prefix to be added. If
If
.Cm on .Cm on
is specified, autonomous address auto configuration is is specified, autonomous address auto configuration is
enabled. enabled. If
If
.Cm off .Cm off
is specified, it is disabled. is specified, it is disabled.
.It Cm rrf_decrprefd Cm on|off .It Cm rrf_decrprefd Cm on|off
Enable or disable the decrementation of the pltime. Enable or disable the decrementation of the pltime. If
If
.Cm on .Cm on
is specified, decrementation of the pltime is enabled. is specified, decrementation of the pltime is enabled. If
If
.Cm off .Cm off
is specified, decrementation of the pltime is disabled. is specified, decrementation of the pltime is disabled.
.It Cm rrf_decrvalid Cm on|off .It Cm rrf_decrvalid Cm on|off
Enable or disable the decrementation of the vltime. Enable or disable the decrementation of the vltime. If
If
.Cm on .Cm on
is specified, decrementation of the vltime is enabled. is specified, decrementation of the vltime is enabled. If
If
.Cm off .Cm off
is specified, decrementation of the vltime is disabled. is specified, decrementation of the vltime is disabled.
.El .El
.\" .\"
.It seqnum Ar seqnum-val { Ar rrenum-cmd } ; .It seqnum Ar seqnum-val { Ar rrenum-cmd } ;
Specifies contents of sending router renumbering message with some Specifies contents of sending router renumbering message with some
specific seqnum. specific seqnum. Multiple of this statement can be specified if they
Multiple of this statement can be specified if they
have different have different
.Ar seqnum-val .Ar seqnum-val
each other. each other.
@ -246,11 +235,10 @@ has just same syntax with above add|change|setglobal statement.
.Sh EXAMPLE .Sh EXAMPLE
For each configuration file example shown below, we suppose For each configuration file example shown below, we suppose
every IPv6 subnet has its own prefix beginning with every IPv6 subnet has its own prefix beginning with
fec0:0:0::/48 and with its own subnet number. fec0:0:0::/48 and with its own subnet number. (in this case,
(in this case,
subnet number is 7th and 8th octet value of the prefix) subnet number is 7th and 8th octet value of the prefix)
.Pp .Pp
If you want to assign prefixes beginning with fec0:1:1::/48 If you want to assigne prefixes beginning with fec0:1:1::/48
to each subnet, then following configuration will be enough, to each subnet, then following configuration will be enough,
if each of your routers supports IPv6 multicast forwarding. if each of your routers supports IPv6 multicast forwarding.
The subnet number of the existing fec0:0:0::/48 prefix and the The subnet number of the existing fec0:0:0::/48 prefix and the
@ -278,11 +266,10 @@ add match-prefix fec0:0:0:: /48 use-prefix fec0:1:1:: /48 keeplen 16;
If you are going to do renumbering, then following procedure will be natural. If you are going to do renumbering, then following procedure will be natural.
.Bl -enum -offset indent .Bl -enum -offset indent
.It .It
Assign new prefix. Assigne new prefix.
.It .It
Set old prefix lifetimes to some appropriate transition Set old prefix lifetimes to some appropriate transition
period. period. In the followng example we use 1 week for valid
In the followng example we use 1 week for valid
lifetime, and 0 for preferred lifetime. lifetime, and 0 for preferred lifetime.
Also, enable old prefix lifetime expiration. Also, enable old prefix lifetime expiration.
(By default, it is static and does not expire) (By default, it is static and does not expire)
@ -334,7 +321,7 @@ command is almost same with
command except that it deletes all pre-defined IPv6 global address. command except that it deletes all pre-defined IPv6 global address.
.Sh SEE ALSO .Sh SEE ALSO
.Xr rrenumd 8 , .Xr rrenumd 8
.Xr prefix 8 .Xr prefix 8
.Sh HISTORY .Sh HISTORY
The The

View File

@ -1,3 +1,5 @@
/* $KAME$ */
/* /*
* Copyright (C) 1998 WIDE Project. * Copyright (C) 1998 WIDE Project.
* All rights reserved. * All rights reserved.
@ -34,24 +36,25 @@
*/ */
struct dst_list { struct dst_list {
struct dst_list *dl_next; struct dst_list * dl_next;
struct sockaddr *dl_dst; struct sockaddr * dl_dst;
}; };
extern struct dst_list *dl_head; extern struct dst_list *dl_head;
struct payload_list { struct payload_list {
struct payload_list *pl_next; struct payload_list * pl_next;
struct iovec pl_sndiov; struct iovec pl_sndiov;
struct icmp6_router_renum pl_irr; struct icmp6_router_renum
struct rr_pco_match pl_rpm; pl_irr;
struct rr_pco_match pl_rpm;
/* currently, support only 1 rr_pco_use field per packet */ /* currently, support only 1 rr_pco_use field per packet */
struct rr_pco_use pl_rpu; struct rr_pco_use pl_rpu;
}; };
extern struct payload_list *pl_head; extern struct payload_list *pl_head;
extern u_int retry; extern u_int retry;
extern int with_v4dest, with_v6dest; extern int with_v4dest, with_v6dest;
#define DEF_VLTIME 2592000 #define DEF_VLTIME 2592000
#define DEF_PLTIME 604800 #define DEF_PLTIME 604800