blob: 726007fc48d4bc32d9ac77f9f618b6700894127f [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>
David Carlier80ebd302017-06-07 12:39:16 +010019#undef LIST_HEAD
Dragan Dosen59bb97a2017-06-02 12:03:16 +020020
21#include <event2/util.h>
22#include <event2/event.h>
23#include <event2/event_struct.h>
24#include <event2/thread.h>
25
26#define LOG(worker, fmt, args...) \
27 do { \
28 struct timeval now; \
29 \
30 gettimeofday(&now, NULL); \
31 fprintf(stderr, "%ld.%06ld [%02d] " fmt "\n", \
32 now.tv_sec, now.tv_usec, (worker)->id, ##args); \
33 } while (0)
34
35struct worker {
36 pthread_t thread;
37 int id;
38 struct event_base *base;
39 struct event *monitor_event;
40
41 struct list engines;
42
43 unsigned int nbclients;
44 struct list clients;
45
46 struct list frames;
47};
48
49extern struct worker null_worker;
50
51#endif /* __SPOA_H__ */