/*
* 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 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* This module reads and writes the stable identifier values, DUID and IAID.
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <limits.h>
#include <fcntl.h>
#include <errno.h>
#include <libdlpi.h>
#include <dhcp_inittab.h>
struct iaid_ent {
};
/*
* read_stable_duid(): read the system's stable DUID, if any
*
* input: size_t *: pointer to a size_t to return the DUID length
* output: uchar_t *: the DUID buffer, or NULL on error (and errno is set)
* note: memory returned is from malloc; caller must free.
*/
uchar_t *
{
int fd;
return (NULL);
} else {
/*
* Make sure that errno always gets set when something
* goes wrong.
*/
if (retv >= 0)
}
}
return (duid);
}
/*
* write_stable_duid(): write the system's stable DUID.
*
* input: const uchar_t *: pointer to the DUID buffer
* size_t: length of the DUID
* output: int: 0 on success, -1 on error. errno is set on error.
*/
int
{
int fd;
return (-1);
} else {
if (retv >= 0)
return (-1);
}
}
/*
* make_stable_duid(): create a new DUID
*
* input: const char *: name of physical interface for reference
* size_t *: pointer to a size_t to return the DUID length
* output: uchar_t *: the DUID buffer, or NULL on error (and errno is set)
* note: memory returned is from malloc; caller must free.
*/
uchar_t *
{
int len;
/*
* Try to read the MAC layer address for the physical interface
* provided as a hint. If that works, we can use a DUID-LLT.
*/
dlpi_close(dh);
return (NULL);
}
dlpi_close(dh);
}
dlpi_close(dh);
/*
* If we weren't able to create a DUID based on the network interface
* in use, then generate one based on a UUID.
*/
}
}
/*
* read_stable_iaid(): read a link's stable IAID, if any
*
* input: const char *: interface name
* output: uint32_t: the IAID, or 0 if none
*/
{
int fd;
return (0);
}
}
return (0);
}
/*
* write_stable_iaid(): write out a link's stable IAID
*
* input: const char *: interface name
* output: uint32_t: the IAID, or 0 if none
*/
int
{
int fd;
return (0);
return (0);
} else {
return (-1);
}
}
}
return (0);
} else {
if (retv >= 0)
return (-1);
}
}
/*
* make_stable_iaid(): create a stable IAID for a link
*
* input: const char *: interface name
* uint32_t: the ifIndex for this link (as a "hint")
* output: uint32_t: the new IAID, never zero
*/
/* ARGSUSED */
{
int fd;
return (hint);
maxid = 0;
minunused = 1;
/*
* This logic is deliberately unoptimized. The reason is that it runs
* essentially just once per interface for the life of the system.
* Once the IAID is established, there's no reason to generate it
* again, and all we care about here is correctness. Also, IAIDs tend
* to get added in a logical sequence order, so the outer loop should
* not normally run more than twice.
*/
do {
minunused++;
}
hint = 0;
}
if (recheck)
} while (recheck);
if (hint != 0)
return (hint);
else if (maxid != UINT32_MAX)
return (maxid + 1);
else
return (minunused);
}