/*
* 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
*/
/*
*/
/*
* This file contains the code that creates ASR audit messages.
*/
#include <errno.h>
#include <inttypes.h>
#include <libscf.h>
#include <string.h>
#include <unistd.h>
#include "asr.h"
#include "asr_buf.h"
#include "asr_mem.h"
#include "asr_err.h"
#include "asr_nvl.h"
/* Default initial buffer sizes. They will grow if needed. */
/*
* Logs a topology error to the ASR log.
*/
static int
{
return (err);
}
/*
* The returned string must be freed when no longer needed.
* If there is an error NULL will be returned and asr_errno will be set.
*/
static char *
{
int err;
return (NULL);
goto finally;
}
(void) asr_set_errno(EASR_NOMEM);
}
return (ret_fmri);
}
/*
* Gets the FRU from a topo node as a string.
*/
static char *
{
int err;
return (NULL);
}
}
/*
* Gets the ASRU from a topo node as a string.
*/
static char *
{
int err;
return (NULL);
}
}
/*
* Gets the resouce from a topo node as a string.
*/
static char *
{
int err;
return (NULL);
}
}
/*
* Prints the additional-information element filled with data from the given
* topo node property.
* The name of the property is returned for further processing of the
* property.
*/
static int
{
int err = 0;
int i;
char *type;
return (ASR_FAILURE);
return (ASR_FAILURE);
else
return (ASR_FAILURE);
else
return (ASR_FAILURE);
switch (nvpair_type(nvp)) {
case DATA_TYPE_INT32:
{
break;
}
case DATA_TYPE_UINT32:
{
break;
}
case DATA_TYPE_INT64:
{
break;
}
case DATA_TYPE_UINT64:
{
break;
}
case DATA_TYPE_DOUBLE:
{
double val;
break;
}
case DATA_TYPE_STRING:
{
char *val;
break;
}
case DATA_TYPE_NVLIST:
{
char *fmri;
if (topo_fmri_nvl2str(
} else {
}
break;
}
case DATA_TYPE_INT32_ARRAY:
{
for (i = 0; i < nelem; i++)
break;
}
case DATA_TYPE_UINT32_ARRAY:
{
for (i = 0; i < nelem; i++)
break;
}
case DATA_TYPE_INT64_ARRAY:
{
for (i = 0; i < nelem; i++)
break;
}
case DATA_TYPE_UINT64_ARRAY:
{
for (i = 0; i < nelem; i++)
break;
}
case DATA_TYPE_STRING_ARRAY:
{
char **val;
for (i = 0; i < nelem; i++)
break;
}
default:
nvpair_type(nvp));
break;
}
return (err);
}
/*
* Prints additional information for an entire topo node group.
* Any properties that are part of the standard ASR audit message
* will be returned in the std name value list.
*/
static int
{
int err = 0;
return (ASR_FAILURE);
return (ASR_FAILURE);
return (ASR_FAILURE);
else
return (ASR_FAILURE);
return (ASR_FAILURE);
if (err != 0) {
return (ASR_FAILURE);
}
/*
* If this is a value we should skip then stop now.
*/
return (ASR_OK);
}
return (ASR_FAILURE);
}
break;
if ((err = add_topo_ai_prop(
break;
break;
asr_buf_data(val));
if (err == 0)
}
}
return (err);
}
/*
* Prints out additional information for a topology node.
*/
static int
{
int err = 0;
continue;
}
return (err);
}
/*
* Converts an FMRI string to an ASR name.
* The string will contain the FMRI data after the <authority>/
*/
char *
{
char *id;
break;
if (*id == '/')
id++;
return (id);
}
/*
* Contains the definition of a hardware component, inclusive of a path to this
* hardware component
* Adds name, id, serial, part, revision, path, state, status &
* additional-information
*/
static int
{
int err = 0;
char *name;
else
if (err && rollback_index) {
}
return (err);
}
/*
* Walks the topology. Used as a callback function to the topology walker.
*/
/* ARGSUSED */
static int
{
return (TOPO_WALK_NEXT);
}
/*
* Prints all the hardware-component ASR elements.
* Searches the FMA topology and creates a hardware-component for each
* topology node found.
*/
static int
{
}
static char *
{
return (value);
}
/*
* A description of a software package reminiscent of pkginfo
* Adds all values in an uncategorized element so all info can be sent.
* Newer verisons of message.xsd should include these new values.
*/
static int
{
int err = 0;
return (0);
"<component>"
"<uncategorized name='software-package'>"
"<software-package>\n");
"</software-package>"
"</uncategorized>"
"</component>\n");
if (err && rollback_index) {
}
return (err);
}
/*
* Reads a file containing pkginfo output and prints the results to the out
* buffer as ASR audit software-package elements.
*/
static int
{
int err = 0;
return (ASR_FAILURE);
return (ASR_FAILURE);
do {
break;
"info to audit event");
}
continue;
}
pkg = asr_nvl_alloc();
err = 1;
break;
}
}
;
*sep = '\0';
;
*sep = '\0';
} while (err == 0);
return (err);
}
static char *
{
return (NULL);
return (NULL);
}
return (asr_buf_free_struct(file));
}
/*
* Collects software package information and print it out as ASR
* software-package elements.
*/
static int
{
int err = 0;
(void) asr_error(EASR_SYSTEM,
return (ASR_FAILURE);
}
return (err);
}
/*
* Prints out a SCF service as an ASR software-module element containing
* name & description
* name=FMRI
* description = STATE STIME
*/
static int
{
int err = 0;
int rollback_index = 0;
}
}
if (err && rollback_index) {
}
return (err);
}
/*
* Collects all SCF services and prints them out as ASR software-module
* elements
*/
static int
{
int r;
char *fmri;
if (frmi_len < 0) {
err++;
goto finally;
}
}
if (r < 0)
break;
}
if (r < 0) {
err++;
}
return (err);
}
static int
{
int err = 0;
int line;
return (1);
return (ASR_FAILURE);
}
do {
return (err);
}
static int
{
int err;
return (ASR_FAILURE);
return (ASR_FAILURE);
}
return (ASR_FAILURE);
}
(void) asr_error(EASR_SYSTEM,
"Error (%d) calling audit payload command (%s)",
return (ASR_FAILURE);
}
return (err);
}
/*
* Collects software package information and print it out as ASR
* software-package elements.
*/
static int
{
int result = 0;
return (result);
}
return (result);
}
/*
* Creates an ASR audit message and places it in out_msg. The message must
* be released when finished using it.
* Returns non-zero, sets out_msg to NULL and sets asr_errno
* if there is an error.
*/
int
{
int err;
return (asr_set_errno(EASR_NOMEM));
}
}
}
}
if (err == 0) {
err = EASR_NOMEM;
} else {
}
return (err);
}