notify_params.c revision f6e214c7418f43af38bd8c3a557e3d0a1d311cfa
/*
* 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
*/
/*
*/
#include <libintl.h>
#include <libnvpair.h>
#include <libscf.h>
#include <libscf_priv.h>
#include <libuutil.h>
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
#include "notify_params.h"
static struct events {
const char *s;
int32_t c;
} smf_st_events[] = {
{ NULL, 0 }
};
static struct fma_tags {
const char *t;
const char *s;
} fma_tags[] = {
{ "problem-diagnosed", "list.suspect" },
{ "problem-updated", "list.updated" },
{ "problem-repaired", "list.repaired" },
{ "problem-resolved", "list.resolved" },
};
static char *fma_classes[] = {
"list.",
"ireport.",
};
/*
* get_fma_tag()
* return a pointer to the fma tag at the passed index. NULL if no entry exist
* for index
*/
const char *
{
return (NULL);
}
/*
* get_fma_class()
* return a pointer to the fma class at the passed index. NULL if no entry exist
* for index
*/
const char *
{
return (NULL);
}
/*
* is_fma_token()
* check if the parameter is an fma token by comparing with the
* fma_classes[] and the fma_tags[] arrays.
*/
int
is_fma_token(const char *t)
{
int i;
for (i = 0; fma_classes[i]; ++i)
return (1);
for (i = 0; fma_tags[i].t; ++i)
return (1);
return (0);
}
/*
* has_fma_tag()
* returns 1 if there is an fma tag for the passed class, 0 otherwise
*/
int
has_fma_tag(const char *c)
{
int i;
for (i = 0; fma_tags[i].s; ++i)
return (1);
return (0);
}
const char *
{
int i;
for (i = 0; fma_tags[i].t; ++i)
return (fma_tags[i].s);
return (tag);
}
const char *
{
int i;
for (i = 0; fma_tags[i].s; ++i)
return (fma_tags[i].t);
return (fma_event);
}
string_to_tset(const char *str)
{
int i;
for (i = 0; smf_st_events[i].s != NULL; ++i) {
return (smf_st_events[i].c);
}
return (0);
}
const char *
{
int i;
for (i = 0; smf_st_events[i].s != NULL; ++i) {
if (smf_st_events[i].c == t)
return (smf_st_events[i].s);
}
return (NULL);
}
void
safe_printf(const char *fmt, ...)
{
}
static uint32_t
{
uint32_t v;
return (0xFFFFFFFFU);
return (0xFFFFFFFFU);
else
return (v);
}
static void
nvpair_print(nvpair_t *p)
{
char **v;
uint_t n;
int i;
(void) nvpair_value_string_array(p, &v, &n);
for (i = 0; i < n; ++i) {
safe_printf(" %s", v[i]);
}
safe_printf("\n");
}
static void
{
boolean_t *a;
uint_t n;
int has_output = 0;
/* for each event e print all notification parameters */
/* We only want the NVLIST memebers */
continue;
uu_die("nvpair_value_nvlist");
if (!has_output)
else
" Event: %s (source: %s)\n"),
has_output = 1;
nvpair_name(tnvp));
else
*a ? "true" : "false");
continue;
}
safe_printf("\n");
}
}
void
{
char *fmri;
size_t n;
int i;
/*
* Check the nvl we got is from a version we understand
*/
¶ms, &n) != 0)
/* Sanity check. If we get here nvl is bad! */
/* this is an SMF state transition nvlist */
for (i = 0; i < n; ++i) {
if (nvlist_lookup_string(p,
SCF_NOTIFY_PARAMS_SOURCE_NAME, &fmri) != 0)
&tset) != 0)
uu_die("nvlist_lookup_int32");
}
} else {
/* this is FMA event nvlist */
return;
}
for (i = 0; i < n; ++i) {
if (nvlist_lookup_string(p,
SCF_NOTIFY_PARAMS_SOURCE_NAME, &fmri) != 0)
}
}
}