00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef __SNORT_H__
00022 #define __SNORT_H__
00023
00024 #ifdef HAVE_CONFIG_H
00025 #include "config.h"
00026 #endif
00027
00028 #include <sys/types.h>
00029 #include <pcap.h>
00030 #include <stdio.h>
00031
00032 #include "decode.h"
00033 #include "perf.h"
00034
00035 #ifdef GIDS
00036 #include "inline.h"
00037 #endif
00038
00039 extern SFPERF sfPerf;
00040
00041
00042 #define SNORT_20
00043
00044
00045
00046
00047
00048 #ifndef WIN32
00049 #define PRINT_INTERFACE(i) i
00050 #else
00051 #define PRINT_INTERFACE(i) print_interface(i)
00052 #endif
00053
00054
00055 #define BUILD "28"
00056
00057 #define STD_BUF 1024
00058
00059 #define RF_ANY_SIP 0x01
00060 #define RF_ANY_DIP 0x02
00061 #define RF_ANY_SP 0x04
00062 #define RF_ANY_DP 0x10
00063 #define RF_ANY_FLAGS 0x20
00064
00065 #define MAX_PIDFILE_SUFFIX 11
00066
00067 #ifndef _PATH_VARRUN
00068 extern char _PATH_VARRUN[STD_BUF];
00069 #endif
00070
00071 #ifndef WIN32
00072 #define DEFAULT_LOG_DIR "/var/log/snort"
00073 #define DEFAULT_DAEMON_ALERT_FILE "alert"
00074 #else
00075 #define DEFAULT_LOG_DIR "log"
00076 #define DEFAULT_DAEMON_ALERT_FILE "log/alert.ids"
00077 #endif
00078
00079
00080
00081
00082 #ifndef SNIFFUSER
00083 #define SNIFFUSER 0
00084 #endif
00085
00086
00087 #ifdef ACCESSPERMS
00088 #define FILEACCESSBITS ACCESSPERMS
00089 #else
00090 #ifdef S_IAMB
00091 #define FILEACCESSBITS S_IAMB
00092 #else
00093 #define FILEACCESSBITS 0x1FF
00094 #endif
00095 #endif
00096
00097 #define TIMEBUF_SIZE 26
00098
00099
00100 #define ASSURE_ALL 0
00101 #define ASSURE_EST 1
00102
00103 #define DO_IP_CHECKSUMS 0x00000001
00104 #define DO_TCP_CHECKSUMS 0x00000002
00105 #define DO_UDP_CHECKSUMS 0x00000004
00106 #define DO_ICMP_CHECKSUMS 0x00000008
00107
00108 #define LOG_UNIFIED 0x00000001
00109 #define LOG_TCPDUMP 0x00000002
00110
00111 #define SIGNAL_SNORT_ROTATE_STATS 28
00112
00113
00114
00115 #define MODE_PACKET_DUMP 1
00116 #define MODE_PACKET_LOG 2
00117 #define MODE_IDS 3
00118 #define MODE_TEST 4
00119
00120 extern u_int8_t runMode;
00121
00122 typedef struct _Configuration
00123 {
00124 char *logging_directory;
00125
00126 } Configuration;
00127
00128 typedef struct _Capabilities
00129 {
00130 u_int8_t stateful_inspection;
00131
00132 } Capabilities;
00133
00134 typedef struct _runtime_config
00135 {
00136 Configuration configuration;
00137 Capabilities capabilities;
00138 } runtime_config;
00139
00140 #define LOG_ASCII 1
00141 #define LOG_PCAP 2
00142 #define LOG_NONE 3
00143
00144 #define ALERT_FULL 1
00145 #define ALERT_FAST 2
00146 #define ALERT_NONE 3
00147 #define ALERT_UNSOCK 4
00148 #define ALERT_STDOUT 5
00149 #define ALERT_CMG 6
00150 #define ALERT_SYSLOG 8
00151
00152 #define MAX_IFS 1
00153
00154
00155 typedef struct _progvars
00156 {
00157 int stateful;
00158 int line_buffer_flag;
00159 int checksums_mode;
00160 int assurance_mode;
00161 int max_pattern;
00162 int test_mode_flag;
00163 int alert_interface_flag;
00164 int verbose_bytedump_flag;
00165 int obfuscation_flag;
00166 int log_cmd_override;
00167 int alert_cmd_override;
00168 int char_data_flag;
00169 int data_flag;
00170 int verbose_flag;
00171 int readmode_flag;
00172 int show2hdr_flag;
00173 int showwifimgmt_flag;
00174 int inline_flag;
00175 #ifdef GIDS
00176 #ifndef IPFW
00177 char layer2_resets;
00178 u_char enet_src[6];
00179 #endif
00180 #ifdef IPFW
00181 int divert_port;
00182 int ipfw_reinject_rule;
00183 #endif
00184 #endif
00185 #ifdef WIN32
00186 int syslog_remote_flag;
00187 char syslog_server[STD_BUF];
00188 int syslog_server_port;
00189 #ifdef ENABLE_WIN32_SERVICE
00190 int terminate_service_flag;
00191 int pause_service_flag;
00192 #endif
00193 #endif
00194 int promisc_flag;
00195 int rules_order_flag;
00196 int track_flag;
00197 int daemon_flag;
00198 int quiet_flag;
00199 int pkt_cnt;
00200 int pkt_snaplen;
00201 u_long homenet;
00202 u_long netmask;
00203 u_int32_t obfuscation_net;
00204 u_int32_t obfuscation_mask;
00205 int alert_mode;
00206 int log_plugin_active;
00207 int alert_plugin_active;
00208 u_int32_t log_bitmap;
00209 char pid_filename[STD_BUF];
00210 char *config_file;
00211 char *config_dir;
00212 char *log_dir;
00213 char readfile[STD_BUF];
00214 char pid_path[STD_BUF];
00215 char *interface;
00216 char *pcap_cmd;
00217 char *alert_filename;
00218 char *binLogFile;
00219 int use_utc;
00220 int include_year;
00221 char *chroot_dir;
00222 u_int8_t min_ttl;
00223 u_int8_t log_mode;
00224 int num_rule_types;
00225 char pidfile_suffix[MAX_PIDFILE_SUFFIX+1];
00226 DecoderFlags decoder_flags;
00227 char ignore_ports[0x10000];
00228 int rotate_perf_file;
00229 u_int32_t event_log_id;
00230
00231 int done_processing;
00232 } PV;
00233
00234
00235 typedef struct _PacketCount
00236 {
00237 u_long total;
00238
00239 u_long other;
00240 u_long tcp;
00241 u_long udp;
00242 u_long icmp;
00243 u_long arp;
00244 u_long eapol;
00245 u_long ipv6;
00246 u_long ipx;
00247 u_long ethloopback;
00248 u_long discards;
00249 u_long alert_pkts;
00250 u_long log_pkts;
00251 u_long pass_pkts;
00252
00253 u_long frags;
00254 u_long frag_trackers;
00255 u_long rebuilt_frags;
00256 u_long frag_incomp;
00257 u_long frag_timeout;
00258 u_long rebuild_element;
00259 u_long frag_mem_faults;
00260
00261 u_long tcp_stream_pkts;
00262 u_long rebuilt_tcp;
00263 u_long tcp_streams;
00264 u_long rebuilt_segs;
00265 u_long str_mem_faults;
00266
00267
00268 u_long wifi_mgmt;
00269 u_long wifi_data;
00270 u_long wifi_control;
00271 u_long assoc_req;
00272 u_long assoc_resp;
00273 u_long reassoc_req;
00274 u_long reassoc_resp;
00275 u_long probe_req;
00276 u_long probe_resp;
00277 u_long beacon;
00278 u_long atim;
00279 u_long dissassoc;
00280 u_long auth;
00281 u_long deauth;
00282 u_long ps_poll;
00283 u_long rts;
00284 u_long cts;
00285 u_long ack;
00286 u_long cf_end;
00287 u_long cf_end_cf_ack;
00288 u_long data;
00289 u_long data_cf_ack;
00290 u_long data_cf_poll;
00291 u_long data_cf_ack_cf_poll;
00292 u_long cf_ack;
00293 u_long cf_poll;
00294 u_long cf_ack_cf_poll;
00295 } PacketCount;
00296
00297
00298 extern PV pv;
00299 extern int datalink;
00300 extern char *progname;
00301 extern char **progargs;
00302 extern char *username;
00303 extern char *groupname;
00304 extern unsigned long userid;
00305 extern unsigned long groupid;
00306 extern struct passwd *pw;
00307 extern struct group *gr;
00308 extern char *pcap_cmd;
00309 extern char *pktidx;
00310 extern pcap_t *pd;
00311
00312
00313 extern FILE *alert;
00314 extern FILE *binlog_ptr;
00315 extern int flow;
00316 extern int thiszone;
00317 extern PacketCount pc;
00318 extern u_long netmasks[33];
00319 extern struct pcap_pkthdr *g_pkthdr;
00320 extern u_char *g_pkt;
00321 extern u_long g_caplen;
00322 extern char *protocol_names[256];
00323 extern u_int snaplen;
00324
00325
00326 typedef void (*grinder_t)(Packet *, struct pcap_pkthdr *, u_char *);
00327
00328 extern grinder_t grinder;
00329
00330
00331 extern runtime_config snort_runtime;
00332
00333
00334 int SnortMain(int argc, char *argv[]);
00335 int ParseCmdLine(int, char**);
00336 void *InterfaceThread(void *);
00337 int OpenPcap();
00338 void DefineIfaceVar(char *,u_char *, u_char *);
00339 int SetPktProcessor();
00340 void CleanExit(int);
00341 void PcapProcessPacket(char *, struct pcap_pkthdr *, u_char *);
00342 void ProcessPacket(char *, struct pcap_pkthdr *, u_char *, void *);
00343 int ShowUsage(char *);
00344 void SigCantHupHandler(int signal);
00345
00346
00347 #endif