/*
* 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 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
#include <libdscp.h>
/*
* Define the file containing the configured DSCP interface name
*/
/*
* Forward declarations
*/
static int get_ifname(char *);
static int convert_ipv4(struct sockaddr_in *,
struct sockaddr_in6 *, int *);
/*
* dscpBind()
*
* Properly bind a socket to the local DSCP address.
* Optionally bind it to a specific port.
*/
int
{
int len;
int len6;
int error;
/* Check arguments */
return (DSCP_ERROR_INVALID);
}
/* Get the local DSCP address used to communicate with the SP */
return (error);
}
/*
* If the caller specified a port, then update the socket address
* to also specify the same port.
*/
if (port != 0) {
}
/*
* Bind the socket.
*
* EINVAL means it is already bound.
* EAFNOSUPPORT means try again using IPv6.
*/
return (DSCP_ERROR_ALREADY);
}
if (errno != EAFNOSUPPORT) {
return (DSCP_ERROR);
}
return (DSCP_ERROR);
}
return (DSCP_ERROR_ALREADY);
}
return (DSCP_ERROR);
}
}
return (DSCP_OK);
}
/*
* dscpSecure()
*
* Enable DSCP security mechanisms on a socket.
*
* DSCP uses the IPSec AH (Authentication Headers) protocol with
* the SHA-1 algorithm.
*/
/*ARGSUSED*/
int
{
/* Check arguments */
if (sockfd < 0) {
return (DSCP_ERROR_INVALID);
}
/*
* Construct a socket option argument that specifies the protocols
* and algorithms required for DSCP's use of IPSec.
*/
/*
* Set the socket option that enables IPSec usage upon the socket,
* using the socket option argument constructed above.
*/
sizeof (opt)) < 0) {
return (DSCP_ERROR);
}
return (DSCP_OK);
}
/*
* dscpAuth()
*
* Test whether a connection should be accepted or refused.
* The address of the connection request is compared against
* the remote address of the specified DSCP link.
*/
/*ARGSUSED*/
int
{
int dlen;
/* Check arguments */
return (DSCP_ERROR_INVALID);
}
/*
* Get the remote IP address associated with the SP.
*/
return (DSCP_ERROR_DB);
}
/*
* Convert the request's address to a 32-bit integer.
*
* This may require a conversion if the caller is
* using an IPv6 socket.
*/
case AF_INET:
/* LINTED E_BAD_PTR_CAST_ALIGN */
break;
case AF_INET6:
/* LINTED E_BAD_PTR_CAST_ALIGN */
return (DSCP_ERROR);
}
break;
default:
return (DSCP_ERROR);
}
/*
* Convert the SP's address to a 32-bit integer.
*/
/* LINTED E_BAD_PTR_CAST_ALIGN */
/*
* Compare the addresses. Reject if they don't match.
*/
return (DSCP_ERROR_REJECT);
}
return (DSCP_OK);
}
/*
* dscpAddr()
*
* Get the addresses associated with a specific DSCP link.
*/
/*ARGSUSED*/
int
{
int error;
int sockfd;
/* Check arguments */
return (DSCP_ERROR_INVALID);
}
/*
* Get the DSCP interface name.
*/
if (get_ifname(ifname) != 0) {
return (DSCP_ERROR_DB);
}
/*
* Open a socket.
*/
return (DSCP_ERROR_DB);
}
/*
* Get the interface flags.
*/
return (DSCP_ERROR_DB);
}
/*
* The interface must be a PPP link using IPv4.
*/
((flags & IFF_POINTOPOINT) == 0)) {
return (DSCP_ERROR_DB);
}
/*
* Get the local or remote address, depending upon 'which'.
*/
if (which == DSCP_ADDR_LOCAL) {
} else {
}
if (error < 0) {
return (DSCP_ERROR_DB);
}
/*
* Copy the sockaddr value back to the caller.
*/
*lenp = sizeof (struct sockaddr_in);
return (DSCP_OK);
}
/*
* dscpIdent()
*
* Determine the domain of origin associated with a sockaddr.
* (Map a sockaddr to a domain ID.)
*
* In the Solaris version, the remote socket address should always
* be the SP. A call to dscpAuth() is used to confirm this, and
* then DSCP_IDENT_SP is returned as a special domain ID.
*/
int
{
int error;
/* Check arguments */
return (DSCP_ERROR_INVALID);
}
/* Confirm that the address is the SP */
if (error == DSCP_ERROR_REJECT) {
return (DSCP_ERROR);
}
return (error);
}
*domainp = DSCP_IDENT_SP;
return (DSCP_OK);
}
/*
* get_ifname()
*
* Retrieve the interface name used by DSCP.
*
* Returns: 0 upon success, -1 upon failure.
*/
static int
{
int i;
int fd;
int len;
int size;
int count;
int end;
int begin;
/*
* Initialize the interface name.
*/
/*
* Test for a a valid configuration file.
*/
return (-1);
}
/*
* Open the configuration file and read its contents
*/
return (-1);
}
count = 0;
do {
if (i <= 0) {
return (-1);
}
count += i;
/*
* Analyze the interface name that was just read,
* and clean it up as necessary. The result should
* be a simple NULL terminated string such as "sppp0"
* with no extra whitespace or other characters.
*/
/* Detect the beginning of the interface name */
begin = i;
break;
}
}
/* Fail if no such beginning was found */
if (begin < 0) {
return (-1);
}
/* Detect the end of the interface name */
end = i;
break;
}
}
/* Compute the length of the name */
/* Remove leading whitespace */
if (begin > 0) {
}
/* Clear out any remaining garbage */
}
return (0);
}
/*
* convert_ipv6()
*
* Converts an IPv6 socket address into an equivalent IPv4
* address. The conversion is to a 32-bit integer because
* that is sufficient for how libdscp uses IPv4 addresses.
*
* The IPv4 address is additionally converted from network
* byte order to host byte order.
*
* Returns: 0 upon success, with 'addrp' updated.
* -1 upon failure, with 'addrp' undefined.
*/
static int
{
char *ipv4str;
/*
* Convert the IPv6 address into a string.
*/
return (-1);
}
/*
* Use the IPv6 string to construct an IPv4 string.
*/
ipv4str++;
} else {
return (-1);
}
/*
* Convert the IPv4 string into a 32-bit integer.
*/
return (-1);
}
return (0);
}
/*
* convert_ipv4()
*
* Convert an IPv4 socket address into an equivalent IPv6 address.
*
* Returns: 0 upon success, with 'addr6' and 'lenp' updated.
* -1 upon failure, with 'addr6' and 'lenp' undefined.
*/
static int
{
int len;
/*
* Convert the IPv4 socket address into a string.
*/
return (-1);
}
/*
* Use the IPv4 string to construct an IPv6 string.
*/
if (len >= INET6_ADDRSTRLEN) {
return (-1);
}
/*
* Convert the IPv6 string to an IPv6 socket address.
*/
return (-1);
}
*lenp = sizeof (struct sockaddr_in6);
return (0);
}