fa9e4066f08beec538e775443c5be79dd423fcabahrens * CDDL HEADER START
fa9e4066f08beec538e775443c5be79dd423fcabahrens * The contents of this file are subject to the terms of the
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock * Common Development and Distribution License, Version 1.0 only
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock * (the "License"). You may not use this file except in compliance
fa9e4066f08beec538e775443c5be79dd423fcabahrens * with the License.
fa9e4066f08beec538e775443c5be79dd423fcabahrens * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
fa9e4066f08beec538e775443c5be79dd423fcabahrens * See the License for the specific language governing permissions
fa9e4066f08beec538e775443c5be79dd423fcabahrens * and limitations under the License.
fa9e4066f08beec538e775443c5be79dd423fcabahrens * When distributing Covered Code, include this CDDL HEADER in each
fa9e4066f08beec538e775443c5be79dd423fcabahrens * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
fa9e4066f08beec538e775443c5be79dd423fcabahrens * If applicable, add the following below this CDDL HEADER, with the
fa9e4066f08beec538e775443c5be79dd423fcabahrens * fields enclosed by brackets "[]" replaced with your own identifying
fa9e4066f08beec538e775443c5be79dd423fcabahrens * information: Portions Copyright [yyyy] [name of copyright owner]
fa9e4066f08beec538e775443c5be79dd423fcabahrens * CDDL HEADER END
79d728325e257b05859d2eef4a4dfbefdce05a76Matthew Ahrens * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
bc9014e6a81272073b9854d9f65dd59e18d18c35Justin Gibbs * Use is subject to license terms.
fa9e4066f08beec538e775443c5be79dd423fcabahrens#pragma ident "%Z%%M% %I% %E% SMI"
fa9e4066f08beec538e775443c5be79dd423fcabahrens * FMA Error injector
fa9e4066f08beec538e775443c5be79dd423fcabahrensextern "C" {
cdb0ab79ea1af7b8fc339a04d4bf7426dc77ec4emaybee * The injector allows for the declaration, definition, and injection of four
cdb0ab79ea1af7b8fc339a04d4bf7426dc77ec4emaybee * types of things - Events, FMRIs, Authorities, and lists. The first three
cdb0ab79ea1af7b8fc339a04d4bf7426dc77ec4emaybee * are essentially lists with extra membership requirements (FMRIs, for
cdb0ab79ea1af7b8fc339a04d4bf7426dc77ec4emaybee * example, must include a member called `scheme'). So while each has a
cdb0ab79ea1af7b8fc339a04d4bf7426dc77ec4emaybee * different function within the FMA framework, we can use a single struct to
cdb0ab79ea1af7b8fc339a04d4bf7426dc77ec4emaybee * store all three. The inj_itemtype_t enum is used to describe which of the
fa9e4066f08beec538e775443c5be79dd423fcabahrens * four types is being represented by a given object.
0a586cea3ceec7e5e50e7e54c745082a7a333ac2Mark Shellenbaum * The member name-value pairs of Events, FMRIs, and Authorities are typed.
fa9e4066f08beec538e775443c5be79dd423fcabahrens * Declarations
4b5c8e93cab28d3c65ba9d407fd8f46e3be1db1cMatthew Ahrens * Each declared item, be it an event, an fmri, or an authority, consists of
4b5c8e93cab28d3c65ba9d407fd8f46e3be1db1cMatthew Ahrens * an inj_decl_t and a string of inj_declmem_t's, one of the latter for each
4b5c8e93cab28d3c65ba9d407fd8f46e3be1db1cMatthew Ahrens * declared member.
c144956179190829a882ff695f7771ba19f65becEric Taylor#define DECL_F_AUTOENA 0x1 /* ENA member to be auto-generated for event */
fa9e4066f08beec538e775443c5be79dd423fcabahrens inj_list_t decl_members; /* List of declared members */
fa9e4066f08beec538e775443c5be79dd423fcabahrens inj_itemtype_t decl_type; /* Type of declared item */
99653d4ee642c6528e88224f12409a5f23060994eschrock uint_t decl_lineno; /* Line # of first member declared */
fa9e4066f08beec538e775443c5be79dd423fcabahrens#define DECLMEM_F_ARRAY 0x1 /* This member is an array of the given type */
fa9e4066f08beec538e775443c5be79dd423fcabahrens inj_list_t dlm_memlist; /* List of declared members */
fa9e4066f08beec538e775443c5be79dd423fcabahrens uint_t dlm_arrdim; /* If arr flag set, dim of array */
148434217c040ea38dc844384f6ba68d9b325906Matthew Ahrens inj_hash_t *_dlm_enumvals; /* If enum, hash of poss. values */
148434217c040ea38dc844384f6ba68d9b325906Matthew Ahrens inj_decl_t *_dlm_decl; /* If evt, etc., ptr to decl for same */
fa9e4066f08beec538e775443c5be79dd423fcabahrens * Definitions
fa9e4066f08beec538e775443c5be79dd423fcabahrens * Each defined item consists of an inj_defn_t and a string of inj_defnmem_t's,
fa9e4066f08beec538e775443c5be79dd423fcabahrens * one of the latter for each defined member. The inj_defn_t also contains a
fa9e4066f08beec538e775443c5be79dd423fcabahrens * pointer to the corresponding declaration, thus allowing for correctness
99653d4ee642c6528e88224f12409a5f23060994eschrock * checking.
fa9e4066f08beec538e775443c5be79dd423fcabahrens inj_list_t defn_members; /* List of defined members */
fa9e4066f08beec538e775443c5be79dd423fcabahrens inj_decl_t *defn_decl; /* Ptr to decl this defn instantiates */
99653d4ee642c6528e88224f12409a5f23060994eschrock uint_t defn_lineno; /* Line # of first member defined */
fa9e4066f08beec538e775443c5be79dd423fcabahrens nvlist_t *defn_nvl; /* Built from validated members */
0a586cea3ceec7e5e50e7e54c745082a7a333ac2Mark Shellenbaum * Embodiment of the information that we know about a given defined member at
fa9e4066f08beec538e775443c5be79dd423fcabahrens * the time of definition. These values are assigned before the individual
fa9e4066f08beec538e775443c5be79dd423fcabahrens * definition members are paired with their corresponding declarations, so we
79d728325e257b05859d2eef4a4dfbefdce05a76Matthew Ahrens * don't know whether a given IDENT is, for example, an enum or an fmri
fa9e4066f08beec538e775443c5be79dd423fcabahrens * reference. Without these values, we wouldn't be able to distinguish between
f7170741490edba9d1d9c697c177c887172bc741Will Andrews * a quoted string and an identifier, for example, and thus would have a harder
f7170741490edba9d1d9c697c177c887172bc741Will Andrews * time with syntactic validation.
fa9e4066f08beec538e775443c5be79dd423fcabahrens inj_list_t dfm_memlist; /* List of defined members */
c543ec060d1359f6c8a9507242521f344a2ac3efahrens inj_defnmemtype_t dfm_type; /* Type of this member, from parser */
c543ec060d1359f6c8a9507242521f344a2ac3efahrens uint_t dfm_lineno; /* Last line of this member's defn */
c543ec060d1359f6c8a9507242521f344a2ac3efahrens inj_list_t _dfm_list; /* Enum, evt, auth, arr, list vals */
c543ec060d1359f6c8a9507242521f344a2ac3efahrens * Operations performed by the injector (aside from declarations and
c543ec060d1359f6c8a9507242521f344a2ac3efahrens * definitions)
da03de9920a5a87150a121e9851479c6b3364d8aMark Maybee/* events and priorities list for the randomize command */
744947dc83c634d985ed3ad79ac9c5e28d1865fdTom Erickson * Operations themselves are structured as a tree of inj_cmd_t's. Each one has
744947dc83c634d985ed3ad79ac9c5e28d1865fdTom Erickson * a command type and type-specific command data. The "program" is run via
744947dc83c634d985ed3ad79ac9c5e28d1865fdTom Erickson * iteration through the tree, with the injector performing the operation
fa9e4066f08beec538e775443c5be79dd423fcabahrens * requested by a given node.
fa9e4066f08beec538e775443c5be79dd423fcabahrens inj_defn_t *_cmd_event; /* If send_event, evt to send */
fa9e4066f08beec538e775443c5be79dd423fcabahrens inj_randelem_t **_cmd_rand; /* List of evts & probs */
fa9e4066f08beec538e775443c5be79dd423fcabahrens struct inj_cmd *_cmd_subcmd; /* If repeat, cmd to be rpt'd */
86bb58aec7165f8a0303564575c65e5a2ad58bf1Alex Reece * We support retargetable event-delivery mechanisms. Each method implements
86bb58aec7165f8a0303564575c65e5a2ad58bf1Alex Reece * a copy of the following ops vector, thus allowing us to switch mechanisms
86bb58aec7165f8a0303564575c65e5a2ad58bf1Alex Reece * simply by switching the structure.
744947dc83c634d985ed3ad79ac9c5e28d1865fdTom Erickson void *(*mo_open)(const char *); /* Init mechanism */
744947dc83c634d985ed3ad79ac9c5e28d1865fdTom Erickson void (*mo_send)(void *, nvlist_t *); /* Send a single nvlist */
ea8dc4b6d2251b437950c0056bc626b311c73c27eschrock void (*mo_close)(void *); /* Shut down mechanism */
148434217c040ea38dc844384f6ba68d9b325906Matthew Ahrensextern inj_list_t *inj_program_read(const char *);
0a586cea3ceec7e5e50e7e54c745082a7a333ac2Mark Shellenbaumextern void inj_program_run(inj_list_t *, const inj_mode_ops_t *, void *);
744947dc83c634d985ed3ad79ac9c5e28d1865fdTom Erickson#endif /* _INJ_H */