All Data Structures Files Functions Variables Enumerations Enumerator Macros Groups
bytecode_detect.h
1 /*
2  * Copyright (C) 2009 Sourcefire, Inc.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution.
13  *
14  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS AS IS'' AND
15  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17  * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
18  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24  * SUCH DAMAGE.
25  */
26 #ifndef BYTECODE_DETECT_H
27 #define BYTECODE_DETECT_H
28 /* mostly from m4/acinclude.m4 */
29 enum arch_list {
30  arch_unknown=0,
31  arch_i386,
32  arch_x86_64,
33  arch_ppc32,
34  arch_ppc64,
35  arch_arm,
36  arch_sparc,
37  arch_sparc64,
38  arch_mips,
39  arch_mips64,
40  arch_alpha,
41  arch_hppa1,
42  arch_hppa2,
43  arch_m68k,
44  arch_ANY = 0xf
45 };
46 
47 /* from ClamAV's configure.in */
48 enum os_kind_conf {
49  os_unknown=0,
50  os_aix,
51  os_beos,
52  os_bsd,
53  os_darwin,
54  os_gnu_hurd,
55  os_hpux,
56  os_interix,
57  os_irix,
58  os_kfreebsd_gnu,
59  os_linux,
60  os_os2,
61  os_osf,
62  os_qnx6,
63  os_solaris,
64  os_win32,
65  os_win64,
66  os_ANY = 0xff
67 };
68 
69 enum os_kind_llvm {
70  llvm_os_UnknownOS=0,
71  llvm_os_AuroraUX,
72  llvm_os_Cygwin,
73  llvm_os_Darwin,
74  llvm_os_DragonFly,
75  llvm_os_FreeBSD,
76  llvm_os_Linux,
77  llvm_os_Lv2,
78  llvm_os_MinGW32,
79  llvm_os_MinGW64,
80  llvm_os_NetBSD,
81  llvm_os_OpenBSD,
82  llvm_os_Psp,
83  llvm_os_Solaris,
84  llvm_os_Win32,
85  llvm_os_Haiku,
86  llvm_os_Minix,
87  llvm_os_ANY = 0xff
88 };
89 
90 /* the ones from clamconf */
91 enum compiler_list {
92  compiler_unknown = 0,
93  compiler_gnuc,
94  compiler_llvm,
95  compiler_clang,
96  compiler_intel,
97  compiler_msc,
98  compiler_sun,
99  compiler_other,
100  compiler_ANY = 0xf
101 };
102 
103 enum endian_list {
104  endian_little=0,
105  endian_big=1,
106  endian_ANY=0xf
107 };
108 
109 enum os_feature_bits {
110  feature_map_rwx = 0,
111  feature_selinux = 1,
112  feature_selinux_enforcing = 2,
113  feature_pax = 3,
114  feature_pax_mprotect = 4
115 };
116 
117 struct cli_environment {
118  uint32_t platform_id_a;
119  uint32_t platform_id_b;
120  uint32_t platform_id_c;
121  uint32_t c_version;
122  uint32_t cpp_version; /* LLVM only */
123  /* engine */
124  uint32_t functionality_level;
125  uint32_t dconf_level;
126  int8_t engine_version[65];
127  /* detailed runtime info */
128  int8_t triple[65];/* LLVM only */
129  int8_t cpu[65];/* LLVM only */
130  /* uname */
131  int8_t sysname[65];
132  int8_t release[65];
133  int8_t version[65];
134  int8_t machine[65];
135  /* build time */
136  uint8_t big_endian;
137  uint8_t sizeof_ptr;
138  uint8_t arch;
139  uint8_t os_category;/* from configure */
140  uint8_t os;/* from LLVM if available */
141  uint8_t compiler;
142  uint8_t has_jit_compiled;
143  uint8_t os_features;
144  uint8_t reserved0;
145 };
146 
147 #ifndef __CLAMBC__
148 #define MAKE_VERSION(a,b,c,d) ((a << 24) | (b << 16) | (c << 8) | d)
149 #define INIT_STRFIELD(field, value) do {\
150  strncpy((char*)(field), (value), sizeof(field)-1);\
151  (field)[sizeof(field)-1]=0;\
152 } while (0)
153 #endif
154 
155 #endif