-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathngx_http_sflow_config.h
76 lines (64 loc) · 2.4 KB
/
ngx_http_sflow_config.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
/* -*- Mode: C; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
/* Copyright (c) 2002-2014 InMon Corp. Licensed under the terms of the InMon sFlow licence: */
/* http://www.inmon.com/technology/sflowlicense.txt */
#ifndef NGX_HTTP_SFLOW_CONFIG_H
#define NGX_HTTP_SFLOW_CONFIG_H 1
#include <ngx_config.h>
#include <ngx_core.h>
#include <ngx_http.h>
#include <nginx.h>
#include "ngx_http_sflow.h"
/*_________________---------------------------__________________
_________________ config parsing defs __________________
-----------------___________________________------------------
*/
#define SFWB_DEFAULT_CONFIGFILE "/etc/hsflowd.auto"
#define SFWB_SEPARATORS " \t\r\n="
#define SFWB_QUOTES "'\" \t\r\n"
/* SFWB_MAX LINE LEN must be enough to hold the whole list of targets */
#define SFWB_MAX_LINELEN 1024
#define SFWB_MAX_COLLECTORS 10
#define SFWB_CONFIG_CHECK_S 10
#define SFWB_CONFIG_POOL_SIZ 5000
/*_________________---------------------------__________________
_________________ structure definitions __________________
-----------------___________________________------------------
*/
typedef struct _SFWBCollector {
SFLAddress ipAddr;
uint32_t udpPort;
struct sockaddr_in6 sendSocketAddr;
uint16_t priority;
} SFWBCollector;
typedef struct _SFWBConfig {
int32_t error;
uint32_t sampling_n;
uint32_t polling_secs;
bool_t got_sampling_n_http;
bool_t got_polling_secs_http;
SFLAddress agentIP;
uint32_t num_collectors;
SFWBCollector collectors[SFWB_MAX_COLLECTORS];
uint32_t parent_ds_index;
// ngx_pool_t *pool;
} SFWBConfig;
typedef struct _SFWBConfigManager {
/* master config */
int32_t configCountDown;
char *configFile;
time_t configFile_modTime;
SFWBConfig *config;
SFWBConfig configs[2];
int configToggle;
int socket4;
int socket6;
} SFWBConfigManager;
bool_t sfwb_config_tick(SFWBConfigManager *sm, ngx_log_t *log);
void sfwb_config_send_packet(SFWBConfigManager *sm, u_char *pkt, uint32_t pktLen, ngx_log_t *log);
void sfwb_config_init(SFWBConfigManager *sm, ngx_log_t *log);
SFLAddress *sfwb_config_agentIP(SFWBConfigManager *sm);
uint32_t sfwb_config_polling_secs(SFWBConfigManager *sm);
uint32_t sfwb_config_sampling_n(SFWBConfigManager *sm);
uint32_t sfwb_config_parent_ds_index(SFWBConfigManager *sm);
bool_t sfwb_config_valid(SFWBConfigManager *sm);
#endif /* NGX_HTTP_SFLOW_CONFIG_H */