Imported Upstream version 2.4.3
[platform/upstream/audit.git] / src / ausearch-avc.h
1 /*
2 * ausearch-avc.h - Header file for ausearch-string.c
3 * Copyright (c) 2006,2008 Red Hat Inc., Durham, North Carolina.
4 * All Rights Reserved.
5 *
6 * This software may be freely redistributed and/or modified under the
7 * terms of the GNU General Public License as published by the Free
8 * Software Foundation; either version 2, or (at your option) any
9 * later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; see the file COPYING. If not, write to the
18 * Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 *
20 * Authors:
21 *   Steve Grubb <sgrubb@redhat.com>
22 */
23
24 #ifndef AU_AVC_HEADER
25 #define AU_AVC_HEADER
26
27 #include "config.h"
28 #include <sys/types.h>
29 #include "libaudit.h"
30
31 typedef enum { AVC_UNSET, AVC_DENIED, AVC_GRANTED } avc_t;
32
33 /* This is the node of the linked list. message & item are the only elements
34  * at this time. Any data elements that are per item goes here. */
35 typedef struct _anode{
36   char *scontext;       // se linux subject context
37   char *tcontext;       // se linux object context
38   avc_t avc_result;     // se linux avc denied/granted
39   char *avc_perm;       // se linux avc permission mentioned
40   char *avc_class;      // se linux class mentioned
41   struct _anode* next;  // Next string node pointer
42 } anode;
43
44 /* This is the linked list head. Only data elements that are 1 per
45  * event goes here. */
46 typedef struct {
47   anode *head;          // List head
48   anode *cur;           // Pointer to current node
49   unsigned int cnt;     // How many items in this list
50 } alist;
51
52 void alist_create(alist *l);
53 static inline void alist_first(alist *l) { l->cur = l->head; }
54 anode *alist_next(alist *l);
55 static inline anode *alist_get_cur(alist *l) { return l->cur; }
56 void alist_append(alist *l, anode *node);
57 void anode_init(anode *an);
58 void anode_clear(anode *an);
59 void alist_clear(alist* l);
60
61 /* See if any subj exists in list */
62 int alist_find_subj(alist *l);
63 anode *alist_next_subj(alist *l);
64 /* See if any obj exists in list */
65 int alist_find_obj(alist *l);
66 anode *alist_next_obj(alist *l);
67 /* See if any avc exists in list */
68 int alist_find_avc(alist *l);
69 anode *alist_next_avc(alist *l);
70
71 #endif
72