File: ZMQPublisher.h

package info (click to toggle)
ntopng 5.2.1%2Bdfsg1-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 121,832 kB
  • sloc: javascript: 143,431; cpp: 71,175; ansic: 11,108; sh: 4,687; makefile: 911; python: 587; sql: 512; pascal: 234; perl: 118; ruby: 52; exp: 4
file content (50 lines) | stat: -rw-r--r-- 1,408 bytes parent folder | download
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
/*
 *
 * (C) 2019-22 - ntop.org
 *
 *  http://www.ntop.org/
 *
 * This code is proprietary code subject to the terms and conditions
 * defined in LICENSE file which is part of this source code package.
 *
 */

#include "ntop_includes.h"

/**
 * @file ZMQExporter.h
 *
 * @brief      ZMQPublisher class implementation.
 * @details    ZMQPublisher exports flows in JSON format using a ZMQ socket.
 */

#ifndef _ZMQ_PUBLISHER_H_
#define _ZMQ_PUBLISHER_H_

#define DEFAULT_ZMQ_TCP_KEEPALIVE            1  /* Keepalive ON */
#define DEFAULT_ZMQ_TCP_KEEPALIVE_IDLE       30 /* Keepalive after 30 seconds */
#define DEFAULT_ZMQ_TCP_KEEPALIVE_CNT        3  /* Keepalive send 3 probes */
#define DEFAULT_ZMQ_TCP_KEEPALIVE_INTVL      3  /* Keepalive probes sent every 3 seconds */

class ZMQPublisher {
 private:
  void *context; /**< ZMQ context */
  void *flow_publisher; /**< ZMQ publisher socket */
  char *encryption_key; /**< Encryption key */

#if ZMQ_VERSION >= ZMQ_MAKE_VERSION(4,1,0)
  int setEncryptionKey(const char *server_public_key);
#endif
  void xor_encdec(u_char *data, int data_len, u_char *key);
  bool sendMessage(const char * topic, char * str);

 public:
  ZMQPublisher(char *endpoint, const char *_encryption_key = NULL, const char *server_public_key = NULL);
  ~ZMQPublisher();

  inline bool sendIPSMessage(char *msg) { return(sendMessage("ips", msg)); }
};

#endif /* _ZMQ_PUBLISHER_H_ */