forked from arkime/arkime
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmoloch.h
665 lines (543 loc) · 24.8 KB
/
moloch.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
/******************************************************************************/
/* moloch.h -- General Moloch include file
*
* Copyright 2012-2014 AOL Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this Software except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <netinet/in.h>
#include <netinet/ip.h>
#include <netinet/tcp.h>
#include <netinet/udp.h>
#include "http_parser.h"
#include "dll.h"
#include "hash.h"
#include "bsb.h"
#include "nids.h"
#include "glib.h"
#define UNUSED(x) x __attribute((unused))
#define MOLOCH_API_VERSION 10
/******************************************************************************/
/*
* Base Hash Table Types
*/
typedef struct moloch_int {
struct moloch_int *i_next, *i_prev;
uint32_t i_hash;
short i_bucket;
} MolochInt_t;
typedef struct {
struct moloch_int *i_next, *i_prev;
int i_count;
} MolochIntHead_t;
typedef HASH_VAR(s_, MolochIntHash_t, MolochIntHead_t, 1);
typedef HASH_VAR(s_, MolochIntHashStd_t, MolochIntHead_t, 13);
typedef struct moloch_string {
struct moloch_string *s_next, *s_prev;
char *str;
uint32_t s_hash;
int uw;
short s_bucket;
short len:15;
short utf8:1;
} MolochString_t;
typedef struct {
struct moloch_string *s_next, *s_prev;
int s_count;
} MolochStringHead_t;
typedef HASH_VAR(s_, MolochStringHash_t, MolochStringHead_t, 1);
typedef HASH_VAR(s_, MolochStringHashStd_t, MolochStringHead_t, 13);
/******************************************************************************/
/*
* TRIE
*/
typedef struct moloch_trie_node {
void *data;
struct moloch_trie_node **children;
char value, first, last;
} MolochTrieNode_t;
typedef struct moloch_trie {
int size;
MolochTrieNode_t root;
} MolochTrie_t;
/******************************************************************************/
/*
* Certs Info
*/
typedef struct {
MolochStringHead_t commonName; //2.5.4.3
char *orgName; // 2.5.4.10
char orgUtf8;
} MolochCertInfo_t;
typedef struct moloch_tlsinfo{
struct moloch_tlsinfo *t_next, *t_prev;
uint32_t t_hash;
MolochCertInfo_t issuer;
MolochCertInfo_t subject;
MolochStringHead_t alt;
unsigned char *serialNumber;
short serialNumberLen;
short t_bucket;
} MolochCertsInfo_t;
typedef struct {
struct moloch_tlsinfo *t_next, *t_prev;
int t_count;
} MolochCertsInfoHead_t;
typedef HASH_VAR(s_, MolochCertsInfoHash_t, MolochCertsInfoHead_t, 1);
typedef HASH_VAR(s_, MolochCertsInfoHashStd_t, MolochCertsInfoHead_t, 5);
/******************************************************************************/
/*
* Information about the various fields that we capture
*/
#define MOLOCH_FIELD_TYPE_INT 0
#define MOLOCH_FIELD_TYPE_INT_ARRAY 1
#define MOLOCH_FIELD_TYPE_INT_HASH 2
#define MOLOCH_FIELD_TYPE_STR 3
#define MOLOCH_FIELD_TYPE_STR_ARRAY 4
#define MOLOCH_FIELD_TYPE_STR_HASH 5
#define MOLOCH_FIELD_TYPE_IP 6
#define MOLOCH_FIELD_TYPE_IP_HASH 7
#define MOLOCH_FIELD_TYPE_CERTSINFO 8
/* These are ones you should set */
/* Field should be set on all linked sessions */
#define MOLOCH_FIELD_FLAG_LINKED_SESSIONS 0x0001
/* Create a XXX-cnt field with unique count */
#define MOLOCH_FIELD_FLAG_COUNT 0x0002
/* Force the field to be utf8 */
#define MOLOCH_FIELD_FLAG_FORCE_UTF8 0x0004
/* Don't create in fields db table */
#define MOLOCH_FIELD_FLAG_NODB 0x0008
/* Don't create in capture list */
#define MOLOCH_FIELD_FLAG_FAKE 0x0010
/* These are ones you shouldn't set, for old cruf before we were smarter */
/* XXXcnt - dont use */
#define MOLOCH_FIELD_FLAG_CNT 0x1000
/* XXXscnt - dont use */
#define MOLOCH_FIELD_FLAG_SCNT 0x2000
/* prepend ip stuff - dont use*/
#define MOLOCH_FIELD_FLAG_IPPRE 0x4000
typedef struct moloch_field_info {
struct moloch_field_info *f_next, *f_prev;
char *dbFieldMem;
char *dbField;
uint32_t f_hash;
uint32_t f_bucket;
uint32_t f_count;
int dbFieldLen;
int dbGroupNum;
char *dbGroup;
int dbGroupLen;
char *expression;
char *group;
int pos;
uint16_t type;
uint16_t flags;
} MolochFieldInfo_t;
typedef struct {
union {
char *str;
GPtrArray *sarray;
MolochStringHashStd_t *shash;
int i;
GArray *iarray;
MolochIntHashStd_t *ihash;
MolochCertsInfoHashStd_t *cihash;
};
uint32_t jsonSize;
} MolochField_t;
/******************************************************************************/
/*
* Configuration Information
*/
enum MolochRotate { MOLOCH_ROTATE_HOURLY, MOLOCH_ROTATE_DAILY, MOLOCH_ROTATE_WEEKLY, MOLOCH_ROTATE_MONTHLY };
#define MOLOCH_WRITE_NORMAL 0x00
#define MOLOCH_WRITE_DIRECT 0x01
#define MOLOCH_WRITE_MMAP 0x02
#define MOLOCH_WRITE_THREAD 0x04
typedef struct moloch_config {
gboolean exiting;
char *configFile;
char *nodeName;
char *hostName;
char *pcapReadFile;
char *pcapReadDir;
gchar **extraTags;
gboolean debug;
gboolean dryRun;
gboolean noSPI;
gboolean fakePcap;
gboolean copyPcap;
gboolean pcapRecursive;
gboolean tests;
int pagesize;
enum MolochRotate rotate;
int writeMethod;
HASH_VAR(s_, dontSaveTags, MolochStringHead_t, 11);
MolochFieldInfo_t *fields[100];
int maxField;
int numPlugins;
char *nodeClass;
char *elasticsearch;
char *interface;
int pcapDirPos;
char **pcapDir;
char *bpf;
char *yara;
char *emailYara;
char *geoipFile;
char *geoipASNFile;
char *rirFile;
char *dropUser;
char *dropGroup;
char **pluginsDir;
char **parsersDir;
char **plugins;
char **smtpIpHeaders;
uint32_t maxFileSizeG;
uint64_t maxFileSizeB;
uint32_t maxFileTimeM;
uint32_t minFreeSpaceG;
uint32_t icmpTimeout;
uint32_t udpTimeout;
uint32_t tcpTimeout;
uint32_t tcpSaveTimeout;
uint32_t maxStreams;
uint32_t maxPackets;
uint32_t dbBulkSize;
uint32_t dbFlushTimeout;
uint32_t maxESConns;
uint32_t maxESRequests;
uint32_t logEveryXPackets;
uint32_t packetsPerPoll;
uint32_t pcapBufferSize;
uint32_t pcapWriteSize;
uint32_t maxWriteBuffers;
uint32_t maxFreeOutputBuffers;
char logUnknownProtocols;
char logESRequests;
char logFileCreation;
char parseSMTP;
char parseSMB;
char parseQSValue;
char compressES;
char antiSynDrop;
} MolochConfig_t;
typedef struct {
char *country;
char *asn;
char *rir;
int numtags;
int tags[10];
} MolochIpInfo_t;
/******************************************************************************/
/*
* SPI Data Storage
*/
struct moloch_session;
typedef int (* MolochParserFunc) (struct moloch_session *session, void *uw, const unsigned char *data, int remaining);
typedef void (* MolochParserFreeFunc) (struct moloch_session *session, void *uw);
typedef void (* MolochParserSaveFunc) (struct moloch_session *session, void *uw, int final);
typedef struct {
MolochParserFunc parserFunc;
void *uw;
MolochParserFreeFunc parserFreeFunc;
MolochParserSaveFunc parserSaveFunc;
} MolochParserInfo_t;
typedef struct moloch_session {
struct moloch_session *tcp_next, *tcp_prev;
struct moloch_session *q_next, *q_prev;
struct moloch_session *h_next, *h_prev;
int h_bucket;
uint32_t h_hash;
MolochField_t **fields;
void **pluginData;
MolochParserInfo_t *parserInfo;
GArray *filePosArray;
GArray *fileNumArray;
char *rootId;
struct timeval firstPacket;
struct timeval lastPacket;
char firstBytes[2][8];
uint64_t bytes[2];
uint64_t databytes[2];
uint32_t lastFileNum;
uint32_t lastSave;
uint32_t addr1;
uint32_t addr2;
uint32_t packets[2];
uint16_t port1;
uint16_t port2;
uint16_t offsets[2];
uint16_t outstandingQueries;
uint16_t segments;
uint8_t consumed[2];
uint8_t protocol;
uint8_t firstBytesLen[2];
uint8_t ip_tos;
uint8_t tcp_flags;
uint8_t parserLen;
uint8_t parserNum;
uint16_t haveNidsTcp:1;
uint16_t needSave:1;
uint16_t dontSave:1;
uint16_t which:1;
} MolochSession_t;
typedef struct moloch_session_head {
struct moloch_session *tcp_next, *tcp_prev;
struct moloch_session *q_next, *q_prev;
struct moloch_session *h_next, *h_prev;
int h_bucket;
int tcp_count;
int q_count;
int h_count;
} MolochSessionHead_t;
#define MOLOCH_TYPE_ALLOC(type) (type *)(g_slice_alloc(sizeof(type)))
#define MOLOCH_TYPE_ALLOC0(type) (type *)(g_slice_alloc0(sizeof(type)))
#define MOLOCH_TYPE_FREE(type,mem) g_slice_free1(sizeof(type),mem)
void *moloch_size_alloc(int size, int zero);
int moloch_size_free(void *mem);
#define MOLOCH_SIZE_ALLOC(name, s) moloch_size_alloc(s, 0)
#define MOLOCH_SIZE_ALLOC0(name, s) moloch_size_alloc(s, 1)
#define MOLOCH_SIZE_FREE(name, mem) moloch_size_free(mem)
/******************************************************************************/
/*
* Callback function definitions
*/
typedef int (*MolochWatchFd_func)(gint fd, GIOCondition cond, gpointer data);
typedef void (*MolochResponse_cb)(unsigned char *data, int len, gpointer uw);
typedef void (*MolochTag_cb)(void *uw, int tagType, const char *tagName, uint32_t tagValue);
typedef void (*MolochSeqNum_cb)(uint32_t seq, gpointer uw);
/******************************************************************************/
#define LOG(...) do { \
time_t _t = time(NULL); \
printf("%15.15s %s:%d %s(): ",\
ctime(&_t)+4, __FILE__,\
__LINE__, __FUNCTION__); \
printf(__VA_ARGS__); \
printf("\n"); \
} while(0) /* no trailing ; */
/******************************************************************************/
/*
* main.c
*/
#define MOLOCH_GIO_READ_COND (G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL)
#define MOLOCH_GIO_WRITE_COND (G_IO_OUT | G_IO_HUP | G_IO_ERR | G_IO_NVAL)
gint moloch_watch_fd(gint fd, GIOCondition cond, MolochWatchFd_func func, gpointer data);
unsigned char *moloch_js0n_get(unsigned char *data, uint32_t len, char *key, uint32_t *olen);
char *moloch_js0n_get_str(unsigned char *data, uint32_t len, char *key);
gboolean moloch_string_add(void *hash, char *string, gboolean copy);
uint32_t moloch_string_hash(const void *key);
uint32_t moloch_string_hash_len(const void *key, int len);
int moloch_string_cmp(const void *keyv, const void *elementv);
int moloch_string_ncmp(const void *keyv, const void *elementv);
uint32_t moloch_int_hash(const void *key);
int moloch_int_cmp(const void *keyv, const void *elementv);
const char *moloch_memstr(const char *haystack, int haysize, const char *needle, int needlesize);
const char *moloch_memcasestr(const char *haystack, int haysize, const char *needle, int needlesize);
void moloch_quit();
/******************************************************************************/
/*
* config.c
*/
void moloch_config_init();
void moloch_config_load_local_ips();
void moloch_config_add_header(MolochStringHashStd_t *hash, char *key, int pos);
void moloch_config_load_header(char *section, char *group, char *helpBase, char *expBase, char *dbBase, MolochStringHashStd_t *hash, int flags);
void moloch_config_exit();
gchar *moloch_config_str(GKeyFile *keyfile, char *key, char *d);
gchar **moloch_config_str_list(GKeyFile *keyfile, char *key, char *d);
uint32_t moloch_config_int(GKeyFile *keyfile, char *key, uint32_t d, uint32_t min, uint32_t max);
char moloch_config_boolean(GKeyFile *keyfile, char *key, char d);
/******************************************************************************/
/*
* db.c
*/
void moloch_db_init();
int moloch_db_tags_loading();
char *moloch_db_create_file(time_t firstPacket, char *name, uint64_t size, uint32_t *id);
void moloch_db_save_session(MolochSession_t *session, int final);
void moloch_db_get_tag(void *uw, int tagtype, const char *tag, MolochTag_cb func);
uint32_t moloch_db_peek_tag(const char *tagname);
void moloch_db_add_local_ip(char *str, MolochIpInfo_t *ii);
void moloch_db_add_field(char *group, char *kind, char *expression, char *friendlyName, char *dbField, char *help, va_list ap);
MolochIpInfo_t *moloch_db_get_local_ip(MolochSession_t *session, uint32_t ip);
void moloch_db_exit();
/******************************************************************************/
/*
* parsers.c
*/
void moloch_parsers_init();
void moloch_parsers_initial_tag(MolochSession_t *session);
unsigned char *moloch_parsers_asn_get_tlv(BSB *bsb, int *apc, int *atag, int *alen);
char *moloch_parsers_asn_decode_oid(unsigned char *oid, int len);
void moloch_parsers_classify_tcp(MolochSession_t *session, const unsigned char *data, int remaining);
void moloch_parsers_classify_udp(MolochSession_t *session, const unsigned char *data, int remaining);
void moloch_parsers_exit();
void moloch_parsers_magic_tag(MolochSession_t *session, int field, const char *base, const char *data, int len);
typedef void (* MolochClassifyFunc) (MolochSession_t *session, const unsigned char *data, int remaining);
void moloch_parsers_unregister(MolochSession_t *session, void *uw);
void moloch_parsers_register2(MolochSession_t *session, MolochParserFunc func, void *uw, MolochParserFreeFunc ffunc, MolochParserSaveFunc sfunc);
#define moloch_parsers_register(session, func, uw, ffunc) moloch_parsers_register2(session, func, uw, ffunc, NULL)
void moloch_parsers_classifier_register_tcp_internal(const char *name, int offset, unsigned char *match, int matchlen, MolochClassifyFunc func, size_t sessionsize, int apiversion);
#define moloch_parsers_classifier_register_tcp(name, offset, match, matchlen, func) moloch_parsers_classifier_register_tcp_internal(name, offset, match, matchlen, func, sizeof(MolochSession_t), MOLOCH_API_VERSION)
void moloch_parsers_classifier_register_udp_internal(const char *name, int offset, unsigned char *match, int matchlen, MolochClassifyFunc func, size_t sessionsize, int apiversion);
#define moloch_parsers_classifier_register_udp(name, offset, match, matchlen, func) moloch_parsers_classifier_register_udp_internal(name, offset, match, matchlen, func, sizeof(MolochSession_t), MOLOCH_API_VERSION)
void moloch_print_hex_string(unsigned char* data, unsigned int length);
/******************************************************************************/
/*
* http.c
*/
#define MOLOCH_HTTP_BUFFER_SIZE 10000
void moloch_http_init();
unsigned char *moloch_http_send_sync(void *serverV, char *method, char *key, uint32_t key_len, char *data, uint32_t data_len, size_t *return_len);
gboolean moloch_http_send(void *serverV, char *method, char *key, uint32_t key_len, char *data, uint32_t data_len, gboolean dropable, MolochResponse_cb func, gpointer uw);
gboolean moloch_http_set(void *server, char *key, int key_len, char *data, uint32_t data_len, MolochResponse_cb func, gpointer uw);
unsigned char *moloch_http_get(void *server, char *key, int key_len, size_t *mlen);
#define moloch_http_get_buffer(s) MOLOCH_SIZE_ALLOC(buffer, s)
void moloch_http_exit();
int moloch_http_queue_length(void *server);
void *moloch_http_create_server(char *hostname, int defaultPort, int maxConns, int maxOutstandingRequests, int compress);
void moloch_http_free_server(void *serverV);
/******************************************************************************/
/*
* nids.c
*/
void moloch_nids_root_init();
void moloch_nids_init();
void moloch_nids_add_protocol(MolochSession_t *session, const char *protocol);
gboolean moloch_nids_has_protocol(MolochSession_t *session, const char *protocol);
void moloch_nids_add_tag(MolochSession_t *session, const char *tag);
void moloch_nids_add_tag_type(MolochSession_t *session, int field, const char *tag);
gboolean moloch_nids_has_tag(MolochSession_t *session, const char *tag);
uint32_t moloch_nids_dropped_packets();
uint32_t moloch_nids_monitoring_sessions();
uint32_t moloch_nids_disk_queue();
void moloch_nids_exit();
void moloch_nids_incr_outstanding(MolochSession_t *session);
void moloch_nids_decr_outstanding(MolochSession_t *session);
/******************************************************************************/
/*
* plugins.c
*/
typedef void (* MolochPluginInitFunc) ();
typedef void (* MolochPluginIpFunc) (MolochSession_t *session, struct ip *packet, int len);
typedef void (* MolochPluginUdpFunc) (MolochSession_t *session, struct udphdr *udphdr, unsigned char *data, int len);
typedef void (* MolochPluginTcpFunc) (MolochSession_t *session, struct tcp_stream *a_tcp);
typedef void (* MolochPluginSaveFunc) (MolochSession_t *session, int final);
typedef void (* MolochPluginNewFunc) (MolochSession_t *session);
typedef void (* MolochPluginExitFunc) ();
typedef void (* MolochPluginReloadFunc) ();
typedef void (* MolochPluginHttpDataFunc) (MolochSession_t *session, http_parser *hp, const char *at, size_t length);
typedef void (* MolochPluginHttpFunc) (MolochSession_t *session, http_parser *hp);
typedef void (* MolochPluginSMTPHeaderFunc) (MolochSession_t *session, const char *field, size_t field_len, const char *value, size_t value_len);
typedef void (* MolochPluginSMTPFunc) (MolochSession_t *session);
#define MOLOCH_PLUGIN_SAVE 0x00000001
#define MOLOCH_PLUGIN_IP 0x00000002
#define MOLOCH_PLUGIN_UDP 0x00000004
#define MOLOCH_PLUGIN_TCP 0x00000008
#define MOLOCH_PLUGIN_EXIT 0x00000010
#define MOLOCH_PLUGIN_NEW 0x00000020
#define MOLOCH_PLUGIN_RELOAD 0x00000040
#define MOLOCH_PLUGIN_PRE_SAVE 0x00000100
#define MOLOCH_PLUGIN_HP_OMB 0x00001000
#define MOLOCH_PLUGIN_HP_OU 0x00002000
#define MOLOCH_PLUGIN_HP_OHF 0x00004000
#define MOLOCH_PLUGIN_HP_OHV 0x00008000
#define MOLOCH_PLUGIN_HP_OHC 0x00010000
#define MOLOCH_PLUGIN_HP_OB 0x00020000
#define MOLOCH_PLUGIN_HP_OMC 0x00040000
#define MOLOCH_PLUGIN_SMTP_OH 0x00100000
#define MOLOCH_PLUGIN_SMTP_OHC 0x00200000
void moloch_plugins_init();
void moloch_plugins_reload();
int moloch_plugins_register_internal(const char *name, gboolean storeData, size_t sessionsize, int apiversion);
#define moloch_plugins_register(name, storeData) moloch_plugins_register_internal(name, storeData, sizeof(MolochSession_t), MOLOCH_API_VERSION)
void moloch_plugins_set_cb(const char * name,
MolochPluginIpFunc ipFunc,
MolochPluginUdpFunc udpFunc,
MolochPluginTcpFunc tcpFunc,
MolochPluginSaveFunc preSaveFunc,
MolochPluginSaveFunc saveFunc,
MolochPluginNewFunc newFunc,
MolochPluginExitFunc exitFunc,
MolochPluginExitFunc reloadFunc);
void moloch_plugins_set_http_cb(const char * name,
MolochPluginHttpFunc on_message_begin,
MolochPluginHttpDataFunc on_url,
MolochPluginHttpDataFunc on_header_field,
MolochPluginHttpDataFunc on_header_value,
MolochPluginHttpFunc on_headers_complete,
MolochPluginHttpDataFunc on_body,
MolochPluginHttpFunc on_message_complete);
void moloch_plugins_set_smtp_cb(const char * name,
MolochPluginSMTPHeaderFunc on_header,
MolochPluginSMTPFunc on_header_complete);
void moloch_plugins_cb_pre_save(MolochSession_t *session, int final);
void moloch_plugins_cb_save(MolochSession_t *session, int final);
void moloch_plugins_cb_new(MolochSession_t *session);
void moloch_plugins_cb_ip(MolochSession_t *session, struct ip *packet, int len);
void moloch_plugins_cb_udp(MolochSession_t *session, struct udphdr *udphdr, unsigned char *data, int len);
void moloch_plugins_cb_tcp(MolochSession_t *session, struct tcp_stream *a_tcp);
void moloch_plugins_cb_hp_omb(MolochSession_t *session, http_parser *parser);
void moloch_plugins_cb_hp_ou(MolochSession_t *session, http_parser *parser, const char *at, size_t length);
void moloch_plugins_cb_hp_ohf(MolochSession_t *session, http_parser *parser, const char *at, size_t length);
void moloch_plugins_cb_hp_ohv(MolochSession_t *session, http_parser *parser, const char *at, size_t length);
void moloch_plugins_cb_hp_ohc(MolochSession_t *session, http_parser *parser);
void moloch_plugins_cb_hp_ob(MolochSession_t *session, http_parser *parser, const char *at, size_t length);
void moloch_plugins_cb_hp_omc(MolochSession_t *session, http_parser *parser);
void moloch_plugins_cb_smtp_oh(MolochSession_t *session, const char *field, size_t field_len, const char *value, size_t value_len);
void moloch_plugins_cb_smtp_ohc(MolochSession_t *session);
void moloch_plugins_exit();
/******************************************************************************/
/*
* yara.c
*/
void moloch_yara_init();
void moloch_yara_execute(MolochSession_t *session, unsigned char *data, int len, int first);
void moloch_yara_email_execute(MolochSession_t *session, unsigned char *data, int len, int first);
void moloch_yara_exit();
/******************************************************************************/
/*
* field.c
*/
void moloch_field_init();
void moloch_field_define_json(unsigned char *expression, int expression_len, unsigned char *data, int data_len);
int moloch_field_define(char *group, char *kind, char *expression, char *friendlyName, char *dbField, char *help, int type, int flags, ...);
int moloch_field_by_db(char *dbField);
int moloch_field_by_exp(char *exp);
gboolean moloch_field_string_add(int pos, MolochSession_t *session, const char *string, int len, gboolean copy);
gboolean moloch_field_int_add(int pos, MolochSession_t *session, int i);
gboolean moloch_field_certsinfo_add(int pos, MolochSession_t *session, MolochCertsInfo_t *info, int len);
int moloch_field_count(int pos, MolochSession_t *session);
void moloch_field_certsinfo_free (MolochCertsInfo_t *certs);
void moloch_field_free(MolochSession_t *session);
void moloch_field_exit();
/******************************************************************************/
/*
* trie.c
*/
void moloch_trie_init(MolochTrie_t *trie);
MolochTrieNode_t *moloch_trie_add_node(MolochTrieNode_t *node, const char key);
void moloch_trie_add_forward(MolochTrie_t *trie, const char *key, const int len, void *data);
void moloch_trie_add_reverse(MolochTrie_t *trie, const char *key, const int len, void *data);
void *moloch_trie_get_forward(MolochTrie_t *trie, const char *key, const int len);
void *moloch_trie_get_reverse(MolochTrie_t *trie, const char *key, const int len);
void *moloch_trie_best_forward(MolochTrie_t *trie, const char *key, const int len);
void *moloch_trie_best_reverse(MolochTrie_t *trie, const char *key, const int len);
void *moloch_trie_del_forward(MolochTrie_t *trie, const char *key, const int len);
void *moloch_trie_del_reverse(MolochTrie_t *trie, const char *key, const int len);
/******************************************************************************/
/*
* js0n.c
*/
int js0n(unsigned char *js, unsigned int len, unsigned int *out);