blob: 332f387dc01dedd8fd26e729651e088835da434d [file] [log] [blame]
Dragan Dosen59bb97a2017-06-02 12:03:16 +02001/*
2 * Mod Defender for HAProxy
3 *
4 * Copyright 2017 HAProxy Technologies, Dragan Dosen <ddosen@haproxy.com>
5 *
6 * Based on "A Random IP reputation service acting as a Stream Processing Offload Agent"
7 * Copyright 2016 HAProxy Technologies, Christopher Faulet <cfaulet@haproxy.com>
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version
12 * 3 of the License, or (at your option) any later version.
13 *
14 */
15#ifndef __SPOA_H__
16#define __SPOA_H__
17
18#include <sys/time.h>
19
20#include <event2/util.h>
21#include <event2/event.h>
22#include <event2/event_struct.h>
23#include <event2/thread.h>
24
25#define LOG(worker, fmt, args...) \
26 do { \
27 struct timeval now; \
28 \
29 gettimeofday(&now, NULL); \
30 fprintf(stderr, "%ld.%06ld [%02d] " fmt "\n", \
31 now.tv_sec, now.tv_usec, (worker)->id, ##args); \
32 } while (0)
33
34struct worker {
35 pthread_t thread;
36 int id;
37 struct event_base *base;
38 struct event *monitor_event;
39
40 struct list engines;
41
42 unsigned int nbclients;
43 struct list clients;
44
45 struct list frames;
46};
47
48extern struct worker null_worker;
49
50#endif /* __SPOA_H__ */