1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License, Version 1.0 only 6 * (the "License"). You may not use this file except in compliance 7 * with the License. 8 * 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 * or http://www.opensolaris.org/os/licensing. 11 * See the License for the specific language governing permissions 12 * and limitations under the License. 13 * 14 * When distributing Covered Code, include this CDDL HEADER in each 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 * If applicable, add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your own identifying 18 * information: Portions Copyright [yyyy] [name of copyright owner] 19 * 20 * CDDL HEADER END 21 */ 22 /* 23 * Copyright 2004 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 */ 26 27 #pragma ident "%Z%%M% %I% %E% SMI" 28 29 #include <sys/fm/protocol.h> 30 31 #include <strings.h> 32 #include <libgen.h> 33 34 #include <fmd_log_impl.h> 35 #include <fmd_log.h> 36 37 /*ARGSUSED*/ 38 int 39 fmd_log_filter_class(fmd_log_t *lp, const fmd_log_record_t *rp, void *arg) 40 { 41 return (gmatch(rp->rec_class, arg)); 42 } 43 44 /*ARGSUSED*/ 45 int 46 fmd_log_filter_uuid(fmd_log_t *lp, const fmd_log_record_t *rp, void *arg) 47 { 48 char *uuid; 49 50 /* 51 * Note: the uuid filter matches *any* member whose name is 'uuid'. 52 * This permits us to match not only a list.suspect uuid but any 53 * other event that decides to embed uuids, too, using the same name. 54 */ 55 return (nvlist_lookup_string(rp->rec_nvl, 56 "uuid", &uuid) == 0 && strcmp(uuid, arg) == 0); 57 } 58 59 /*ARGSUSED*/ 60 int 61 fmd_log_filter_before(fmd_log_t *lp, const fmd_log_record_t *rp, void *arg) 62 { 63 uint64_t sec = ((struct timeval *)arg)->tv_sec; 64 uint64_t nsec = ((struct timeval *)arg)->tv_usec * (NANOSEC / MICROSEC); 65 return (rp->rec_sec == sec ? rp->rec_nsec <= nsec : rp->rec_sec <= sec); 66 } 67 68 /*ARGSUSED*/ 69 int 70 fmd_log_filter_after(fmd_log_t *lp, const fmd_log_record_t *rp, void *arg) 71 { 72 uint64_t sec = ((struct timeval *)arg)->tv_sec; 73 uint64_t nsec = ((struct timeval *)arg)->tv_usec * (NANOSEC / MICROSEC); 74 return (rp->rec_sec == sec ? rp->rec_nsec >= nsec : rp->rec_sec >= sec); 75 } 76