inj.h revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (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 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _INJ_H
#define _INJ_H
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* FMA Error injector
*/
#include <stdio.h>
#include <libnvpair.h>
#include <inj_list.h>
#include <inj_hash.h>
#ifdef __cplusplus
extern "C" {
#endif
/*
* The injector allows for the declaration, definition, and injection of three
* types of things - Events, FMRIs, and Authorities. While each has a different
* function within the FMA framework, their internal composition is similar
* enough to allow for the use of a single struct to represent all three. The
* inj_itemtype_t enum is used to describe which of the three types is being
* represented by a given object.
*/
typedef enum inj_itemtype {
/*
* The member name-value pairs of Events, FMRIs, and Authorities are typed.
*/
typedef enum inj_memtype {
/*
* Declarations
*
* Each declared item, be it an event, an fmri, or an authority, consists of
* an inj_decl_t and a string of inj_declmem_t's, one of the latter for each
* declared member.
*/
typedef struct inj_decl {
const char *decl_name; /* Name of declared item */
} inj_decl_t;
typedef struct inj_declmem {
const char *dlm_name; /* Name of this member */
union {
} _dlm_u;
/*
* Definitions
*
* Each defined item consists of an inj_defn_t and a string of inj_defnmem_t's,
* one of the latter for each defined member. The inj_defn_t also contains a
* pointer to the corresponding declaration, thus allowing for correctness
* checking.
*/
typedef struct inj_defn {
const char *defn_name; /* Name of this definition */
} inj_defn_t;
/*
* Embodiment of the information that we know about a given defined member at
* the time of definition. These values are assigned before the individual
* definition members are paired with their corresponding declarations, so we
* don't know whether a given IDENT is, for example, an enum or an fmri
* reference. Without these values, we wouldn't be able to distinguish between
* a quoted string and an identifier, for example, and thus would have a harder
* time with syntactic validation.
*/
typedef enum inj_defnmemtype {
typedef struct inj_defnmem {
union {
const char *_dfm_str; /* String value of member */
} _dfm_u;
/*
* Operations performed by the injector (aside from declarations and
* definitions)
*/
/* events and priorities list for the randomize command */
typedef struct inj_randelem {
struct inj_randelem *re_next;
/*
* Operations themselves are structured as a tree of inj_cmd_t's. Each one has
* a command type and type-specific command data. The "program" is run via
* iteration through the tree, with the injector performing the operation
* requested by a given node.
*/
typedef enum inj_cmd_type {
typedef struct inj_cmd {
union {
} _cmd_u;
} inj_cmd_t;
/*
* We support retargetable event-delivery mechanisms. Each method implements
* a copy of the following ops vector, thus allowing us to switch mechanisms
* simply by switching the structure.
*/
typedef struct inj_mode_ops {
void *(*mo_open)(const char *); /* Init mechanism */
void (*mo_close)(void *); /* Shut down mechanism */
extern int verbose;
extern int quiet;
extern inj_list_t *inj_program_read(const char *);
extern void *inj_zalloc(size_t);
#ifdef __cplusplus
}
#endif
#endif /* _INJ_H */