diff options
author | Jun-ichiro itojun Hagino <itojun@cvs.openbsd.org> | 2000-08-13 18:24:01 +0000 |
---|---|---|
committer | Jun-ichiro itojun Hagino <itojun@cvs.openbsd.org> | 2000-08-13 18:24:01 +0000 |
commit | 0f7613c03c4bd997808651e637c2f8e94a438a44 (patch) | |
tree | 6ee4bfd67bb9ad181b6fe43feb2c35138111c346 /usr.sbin/rtsold/rtsol.c | |
parent | cb11ffa4bd67f11ab1386d67ce4869a6224c0719 (diff) |
add "rtsol -a" (automatically lookup outgoign interface).
warn if net.inet6.ip6.forwarding == 1.
improve manpage.
use $KAME$ for KAME tags.
sync with kame.
Diffstat (limited to 'usr.sbin/rtsold/rtsol.c')
-rw-r--r-- | usr.sbin/rtsold/rtsol.c | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/usr.sbin/rtsold/rtsol.c b/usr.sbin/rtsold/rtsol.c index afd2e98785c..08b1b5382f1 100644 --- a/usr.sbin/rtsold/rtsol.c +++ b/usr.sbin/rtsold/rtsol.c @@ -1,4 +1,5 @@ -/* $OpenBSD: rtsol.c,v 1.4 2000/01/17 16:33:49 itojun Exp $ */ +/* $OpenBSD: rtsol.c,v 1.5 2000/08/13 18:24:00 itojun Exp $ */ +/* $KAME: rtsol.c,v 1.11 2000/08/13 06:14:59 itojun Exp $ */ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -33,6 +34,7 @@ #include <sys/socket.h> #include <sys/uio.h> #include <sys/time.h> +#include <sys/queue.h> #include <net/if.h> #include <net/route.h> @@ -73,11 +75,21 @@ sockopen() int on; struct icmp6_filter filt; static u_char answer[1500]; - static u_char rcvcmsgbuf[CMSG_SPACE(sizeof(struct in6_pktinfo)) + - CMSG_SPACE(sizeof(int))]; - static u_char sndcmsgbuf[CMSG_SPACE(sizeof(struct in6_pktinfo)) + - CMSG_SPACE(sizeof(int))]; + int rcvcmsglen, sndcmsglen; + static u_char *rcvcmsgbuf = NULL, *sndcmsgbuf = NULL; + sndcmsglen = rcvcmsglen = CMSG_SPACE(sizeof(struct in6_pktinfo)) + + CMSG_SPACE(sizeof(int)); + if (rcvcmsgbuf == NULL && (rcvcmsgbuf = malloc(rcvcmsglen)) == NULL) { + warnmsg(LOG_ERR, __FUNCTION__, + "malloc for receive msghdr failed"); + return(-1); + } + if (sndcmsgbuf == NULL && (sndcmsgbuf = malloc(sndcmsglen)) == NULL) { + warnmsg(LOG_ERR, __FUNCTION__, + "malloc for send msghdr failed"); + return(-1); + } memset(&sin6_allrouters, 0, sizeof(struct sockaddr_in6)); if (inet_pton(AF_INET6, ALLROUTER, &sin6_allrouters.sin6_addr.s6_addr) != 1) { @@ -145,14 +157,14 @@ sockopen() rcvmhdr.msg_iov = rcviov; rcvmhdr.msg_iovlen = 1; rcvmhdr.msg_control = (caddr_t) rcvcmsgbuf; - rcvmhdr.msg_controllen = sizeof(rcvcmsgbuf); + rcvmhdr.msg_controllen = rcvcmsglen; /* initialize msghdr for sending packets */ sndmhdr.msg_namelen = sizeof(struct sockaddr_in6); sndmhdr.msg_iov = sndiov; sndmhdr.msg_iovlen = 1; sndmhdr.msg_control = (caddr_t)sndcmsgbuf; - sndmhdr.msg_controllen = sizeof(sndcmsgbuf); + sndmhdr.msg_controllen = sndcmsglen; return(rssock); } |