/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include <locale.h>
#include <errno.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <strings.h>
#include <string.h>
#include <stropts.h>
#include <fcntl.h>
#include <libdliptun.h>
static void usage(void);
/* booleans corresponding to command line flags */
/*
* printkstatus()
*
* Queries the kernel for the current 6to4 Relay Router value, prints
* a status message based on the value and exits this command.
* INADDR_ANY is used to denote that Relay Router communication support is
* disabled within the kernel.
*/
static void
printkstatus(void)
{
if (status != DLADM_STATUS_OK) {
"6to4 relay status: %s\n"),
return;
}
(void) printf("6to4relay: ");
"support is disabled.\n"));
} else {
"support is enabled.\n"));
"Router = "));
(void) printf("%s\n",
}
}
/*
* modifyroute(cmd, in_gw)
*
* Modifies a default IPv6 route with DST = ::, GATEWAY = in_gw, NETMASK = ::
* and flags = <GATEWAY, STATIC>.
* This route is to be propagated through the 6to4 site so that 6to4 hosts
* can send packets to native IPv6 hosts behind a remote 6to4 Relay Router.
*/
static void
{
static int rtmseq;
int rtsock;
int rlen;
static struct {
} rt_msg;
/* Open a routing socket for passing route commands */
return;
}
/* DST */
sizeof (in6_addr_t));
/* GATEWAY */
sizeof (in6_addr_t));
/* NETMASK */
sizeof (in6_addr_t));
/* Send the routing message */
if (rlen < 0) {
gettext("6to4relay: write to routing socket: %s\n"),
} else {
"routing socket got only %d for rlen\n"), rlen);
}
}
}
static void
usage(void)
{
gettext("usage:\n"
"\t6to4relay\n"
"\t6to4relay -e [-a <addr>]\n"
"\t6to4relay -d\n"
"\t6to4relay -h\n"));
}
int
{
int ch;
#if !defined(TEXT_DOMAIN)
#endif
(void) textdomain(TEXT_DOMAIN);
return (EXIT_FAILURE);
}
/* If no args are specified, print the current status. */
if (argc < 2) {
printkstatus();
return (EXIT_SUCCESS);
}
switch (ch) {
case 'e':
break;
case 'd':
break;
case 'a':
break;
case 'h':
usage();
return (EXIT_SUCCESS);
default:
usage();
return (EXIT_FAILURE);
}
}
/*
* If -a is specified, -e must also be specified. Also, the
* combination of -e and -d is illegal. Fail on either case.
*/
usage();
return (EXIT_FAILURE);
}
/*
* Enable Relay Router communication support in the kernel.
*/
if (eflag) {
/*
* if -a was not specified, the well-known anycast will
* be used.
*/
if (!aflag) {
"address (%s) is not a valid IPv4 dotted-decimal "
"string.\n"), relay_arg);
return (EXIT_FAILURE);
}
if (status != DLADM_STATUS_OK) {
"unable to obtain current 6to4 relay address: %s"),
return (EXIT_FAILURE);
}
return (EXIT_SUCCESS);
if (status != DLADM_STATUS_OK) {
"unable to set the 6to4 relay router address: "
return (EXIT_FAILURE);
}
/* remove old default IPv6 route */
}
}
/*
* Disable Relay Router communication support in kernel.
*/
if (dflag) {
/*
* get Relay Router address from the kernel and delete
* default IPv6 route that was added for it.
*/
if (status != DLADM_STATUS_OK) {
"unable to obtain current 6to4 relay address: %s"),
return (EXIT_FAILURE);
}
return (EXIT_SUCCESS);
/*
* INADDR_ANY (0.0.0.0) is used by the kernel to disable Relay
* Router communication support.
*/
if (status != DLADM_STATUS_OK) {
"unable to disable tunneling to 6to4 relay router: "
return (EXIT_FAILURE);
}
}
return (EXIT_SUCCESS);
}