~ubuntu-branches/ubuntu/utopic/suricata/utopic

« back to all changes in this revision

Viewing changes to src/suricata.c

  • Committer: Bazaar Package Importer
  • Author(s): Pierre Chifflier
  • Date: 2010-09-29 10:02:52 UTC
  • mfrom: (1.1.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20100929100252-2ak252422dwsqs7e
Tags: 1.0.2-1
New Upstream version 1.0.2 (Closes: #598389)

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
#include "threads.h"
35
35
#include "threadvars.h"
36
36
 
 
37
#include "util-atomic.h"
37
38
#include "util-spm.h"
38
39
#include "util-hash.h"
39
40
#include "util-hashlist.h"
106
107
#include "app-layer-htp.h"
107
108
#include "app-layer-ftp.h"
108
109
#include "app-layer-ssl.h"
 
110
#include "app-layer-ssh.h"
109
111
 
110
112
#include "util-radix-tree.h"
111
113
#include "util-host-os-info.h"
141
143
#include "tmqh-packetpool.h"
142
144
 
143
145
#include "util-ringbuffer.h"
 
146
#include "util-mem.h"
144
147
 
145
148
/*
146
149
 * we put this here, because we only use it here in main.
149
152
volatile sig_atomic_t sighup_count = 0;
150
153
volatile sig_atomic_t sigterm_count = 0;
151
154
 
 
155
/*
 
156
 * Flag to indicate if the engine is at the initialization
 
157
 * or already processing packets. 2 stages: SURICATA_INIT,
 
158
 * SURICATA_RUNTIME and SURICATA_FINALIZE
 
159
 */
 
160
SC_ATOMIC_DECLARE(unsigned int, engine_stage);
 
161
 
152
162
/* Max packets processed simultaniously. */
153
163
#define DEFAULT_MAX_PENDING_PACKETS 50
154
164
 
158
168
/** Run mode selected */
159
169
int run_mode = MODE_UNKNOWN;
160
170
 
 
171
/** Engine mode: inline (ENGINE_MODE_IPS) or just
 
172
  * detection mode (ENGINE_MODE_IDS by default) */
 
173
uint8_t engine_mode = ENGINE_MODE_IDS;
 
174
 
161
175
/** Maximum packets to simultaneously process. */
162
176
intmax_t max_pending_packets;
163
177
 
371
385
 
372
386
    sc_set_caps = FALSE;
373
387
 
 
388
    SC_ATOMIC_INIT(engine_stage);
 
389
 
374
390
    /* initialize the logging subsys */
375
391
    SCLogInitLogModule(NULL);
376
392
 
 
393
    /* By default use IDS mode, but if nfq or ipfw
 
394
     * are specified, IPS mode will overwrite this */
 
395
    SET_ENGINE_MODE_IDS(engine_mode);
 
396
 
377
397
#ifdef OS_WIN32
378
398
        /* service initialization */
379
399
        if (SCRunningAsService()) {
615
635
#ifdef NFQ
616
636
            if (run_mode == MODE_UNKNOWN) {
617
637
                run_mode = MODE_NFQ;
 
638
                SET_ENGINE_MODE_IPS(engine_mode);
618
639
            } else {
619
640
                SCLogError(SC_ERR_MULTIPLE_RUN_MODE, "more than one run mode "
620
641
                                                     "has been specified");
631
652
#ifdef IPFW
632
653
            if (run_mode == MODE_UNKNOWN) {
633
654
                run_mode = MODE_IPFW;
 
655
                SET_ENGINE_MODE_IPS(engine_mode);
634
656
            } else {
635
657
                SCLogError(SC_ERR_MULTIPLE_RUN_MODE, "more than one run mode "
636
658
                                                     "has been specified");
828
850
    RegisterDCERPCUDPParsers();
829
851
    RegisterFTPParsers();
830
852
    RegisterSSLParsers();
 
853
    RegisterSSHParsers();
831
854
    AppLayerParsersInitPostProcess();
832
855
 
833
856
#ifdef UNITTESTS
864
887
        DecodeVLANRegisterTests();
865
888
        HTPParserRegisterTests();
866
889
        TLSParserRegisterTests();
 
890
        SSHParserRegisterTests();
867
891
        SMBParserRegisterTests();
868
892
        DCERPCParserRegisterTests();
869
893
        DCERPCUDPParserRegisterTests();
1105
1129
        exit(EXIT_FAILURE);
1106
1130
    }
1107
1131
 
 
1132
    SC_ATOMIC_CAS(&engine_stage, SURICATA_INIT, SURICATA_RUNTIME);
 
1133
 
1108
1134
    /* Un-pause all the paused threads */
1109
1135
    TmThreadContinueThreads();
1110
1136
 
1163
1189
        usleep(100);
1164
1190
    }
1165
1191
 
 
1192
    /* Update the engine stage/status flag */
 
1193
    SC_ATOMIC_CAS(&engine_stage, SURICATA_RUNTIME, SURICATA_DEINIT);
 
1194
 
1166
1195
 
1167
1196
    FlowShutdown();
1168
1197
    FlowPrintQueueInfo();
1232
1261
                return 0;
1233
1262
        }
1234
1263
#endif /* OS_WIN32 */
 
1264
 
 
1265
    SC_ATOMIC_DESTROY(engine_stage);
1235
1266
    exit(EXIT_SUCCESS);
1236
1267
}