-
Notifications
You must be signed in to change notification settings - Fork 6
/
metadata_writer_zeromq.h
191 lines (171 loc) · 5.96 KB
/
metadata_writer_zeromq.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
/* Copyright (c) 2015, Celerway, Kristian Evensen <[email protected]>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#pragma once
#include <netinet/in.h>
#include "metadata_exporter.h"
#define MD_ZMQ_BIND_INTVL 1000
#define MD_ZMQ_DATA_VERSION 3
enum md_zmq_topics {
MD_ZMQ_TOPIC_SYSEVENT,
MD_ZMQ_TOPIC_SENSOR,
MD_ZMQ_TOPIC_MODEM,
MD_ZMQ_TOPIC_CONNECTIVITY,
MD_ZMQ_TOPIC_GPS,
MD_ZMQ_TOPIC_MODEM_STATE,
MD_ZMQ_TOPIC_MODEM_MODE,
MD_ZMQ_TOPIC_MODEM_SIGNAL,
MD_ZMQ_TOPIC_MODEM_LTE_BAND,
MD_ZMQ_TOPIC_MODEM_ISP_NAME,
MD_ZMQ_TOPIC_MODEM_UPDATE,
MD_ZMQ_TOPIC_MODEM_IP_ADDR,
MD_ZMQ_TOPIC_MODEM_LOC_CHANGE,
MD_ZMQ_TOPIC_MODEM_NW_MCCMNC_CHANGE,
MD_ZMQ_TOPIC_RADIO_CELL_LOCATION_GERAN,
MD_ZMQ_TOPIC_RADIO_GSM_RR_CELL_SEL_RESEL_PARAM,
MD_ZMQ_TOPIC_RADIO_GRR_CELL_RESEL,
MD_ZMQ_TOPIC_RADIO_GSM_RR_CIPHER_MODE,
MD_ZMQ_TOPIC_RADIO_GSM_RR_CHANNEL_CONF,
MD_ZMQ_TOPIC_RADIO_WCDMA_RRC_STATE,
MD_ZMQ_TOPIC_RADIO_WCDMA_CELL_ID,
__MD_ZMQ_TOPICS_MAX
};
#define MD_ZMQ_TOPICS_MAX (__MD_ZMQ_TOPICS_MAX - 1)
enum md_zmq_keys {
MD_ZMQ_KEY_SEQ,
MD_ZMQ_KEY_TSTAMP,
MD_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O_CIPHER_ALGORITHM,
MD_ZMQ_KEY_RADIO_AFTER_CHANNEL_CONFIG,
MD_ZMQ_KEY_RADIO_BEFORE_CHANNEL_CONFIG,
MD_ZMQ_KEY_RADIO_CHANNEL_MODE_1,
MD_ZMQ_KEY_RADIO_CHANNEL_MODE_2,
MD_ZMQ_KEY_MONROE_IIF_NAME,
__MD_ZMQ_KEYS_MAX
};
#define MD_ZMQ_KEYS_MAX (__MD_ZMQ_KEYS_MAX - 1)
enum md_project_ids {
MD_PROJECT_NNE = 0,
MD_PROJECT_MNR
};
extern const char *monroe_topics[MD_ZMQ_TOPICS_MAX + 1];
extern const char *monroe_keys[MD_ZMQ_KEYS_MAX + 1];
extern const char *nne_topics[MD_ZMQ_TOPICS_MAX + 1];
extern const char *nne_keys[MD_ZMQ_KEYS_MAX + 1];
struct backend_timeout_handle;
struct md_writer_zeromq {
MD_WRITER;
void *zmq_context;
void *zmq_publisher;
struct backend_timeout_handle *bind_timeout_handle;
const char **topics;
const char **keys;
uint8_t topics_limit;
uint8_t keys_limit;
uint8_t metadata_project;
uint8_t socket_bound;
//INET6_ADDRSTRLEN is 46 (max length of ipv6 + trailing 0), 5 is port, 6 is
//protocol (we right now only support TCP)
//todo: carrying this around is not so elegant
char zmq_addr[INET6_ADDRSTRLEN + 5 + 6];
};
void md_zeromq_writer_setup(struct md_exporter *mde, struct md_writer_zeromq* mwz);
void md_zeromq_writer_usage();