Skip to content

Commit 1dc8a05

Browse files
Pranav Hegde (pranhegd)GitHub Enterprise
authored andcommitted
Merge pull request #502 from network-intelligence/global_config
Update stateful_pkt_proc initializer list
2 parents ca92ec6 + 8f090c0 commit 1dc8a05

File tree

1 file changed

+13
-15
lines changed

1 file changed

+13
-15
lines changed

src/libmerc/pkt_proc.h

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ struct stateful_pkt_proc {
106106
mercury_context m;
107107
classifier *c; // TODO: change to reference
108108
data_aggregator *ag;
109-
global_config global_vars;
109+
const global_config &global_vars;
110110
class traffic_selector &selector;
111111
quic_crypto_engine quic_crypto;
112112
struct tcp_reassembler *reassembler_ptr = nullptr;
@@ -119,7 +119,7 @@ struct stateful_pkt_proc {
119119
analysis{},
120120
mq{nullptr},
121121
m{mc},
122-
c{nullptr},
122+
c{mc->c},
123123
ag{nullptr},
124124
global_vars{mc->global_vars},
125125
selector{mc->selector},
@@ -137,11 +137,9 @@ struct stateful_pkt_proc {
137137

138138
// set config and classifier to (refer to) context m
139139
// analysis requires `do_analysis` & `resources` to be set
140-
if (m->c == nullptr && m->global_vars.do_analysis && m->global_vars.resources != nullptr) {
140+
if (c == nullptr && global_vars.do_analysis && global_vars.resources != nullptr) {
141141
throw std::runtime_error("error: classifier pointer is null");
142142
}
143-
this->c = m->c;
144-
this->global_vars = m->global_vars;
145143

146144
// setting protocol based configuration option to output the raw features
147145
set_raw_features(global_vars.raw_features);
@@ -289,26 +287,26 @@ struct stateful_pkt_proc {
289287

290288
bool dump_pkt ();
291289

292-
void set_raw_features(std::unordered_map<std::string, bool> &raw_features) {
293-
if (raw_features["all"] or raw_features["tls"]) {
290+
void set_raw_features(const std::unordered_map<std::string, bool> &raw_features) {
291+
if (raw_features.at("all") or raw_features.at("tls")) {
294292
tls_client_hello::set_raw_features(true);
295293
}
296-
297-
if (raw_features["all"] or raw_features["stun"]) {
294+
295+
if (raw_features.at("all") or raw_features.at("stun")) {
298296
stun::message::set_raw_features(true);
299297
}
300-
301-
if (raw_features["all"] or raw_features["bittorrent"]) {
298+
299+
if (raw_features.at("all") or raw_features.at("bittorrent")) {
302300
bittorrent_dht::set_raw_features(true);
303301
bittorrent_lsd::set_raw_features(true);
304302
bittorrent_handshake::set_raw_features(true);
305303
}
306-
307-
if (raw_features["all"] or raw_features["smb"]) {
304+
305+
if (raw_features.at("all") or raw_features.at("smb")) {
308306
smb2_packet::set_raw_features(true);
309307
}
310-
311-
if (raw_features["all"] or raw_features["ssdp"]) {
308+
309+
if (raw_features.at("all") or raw_features.at("ssdp")) {
312310
ssdp::set_raw_features(true);
313311
}
314312
}

0 commit comments

Comments
 (0)