55 static void JsonDNP3LogLinkControl(JsonBuilder *js, uint8_t lc)
64 static void JsonDNP3LogIin(JsonBuilder *js, uint16_t iin)
67 jb_open_array(js,
"indicators");
80 static void JsonDNP3LogApplicationControl(JsonBuilder *js, uint8_t ac)
94 static void JsonDNP3LogObjectItems(JsonBuilder *js,
DNP3Object *
object)
101 jb_set_uint(js,
"prefix", item->
prefix);
102 jb_set_uint(js,
"index", item->
index);
104 jb_set_uint(js,
"size", item->
size);
118 static void JsonDNP3LogObjects(JsonBuilder *js, DNP3ObjectList *objects)
124 jb_set_uint(js,
"group", object->
group);
125 jb_set_uint(js,
"variation", object->
variation);
126 jb_set_uint(js,
"qualifier", object->
qualifier);
127 jb_set_uint(js,
"prefix_code", object->
prefix_code);
128 jb_set_uint(js,
"range_code", object->
range_code);
129 jb_set_uint(js,
"start", object->
start);
130 jb_set_uint(js,
"stop", object->
stop);
131 jb_set_uint(js,
"count", object->
count);
134 jb_open_array(js,
"points");
135 JsonDNP3LogObjectItems(js,
object);
143 static void JsonDNP3LogRequest(JsonBuilder *js,
DNP3Transaction *dnp3tx)
147 jb_open_object(js,
"control");
148 JsonDNP3LogLinkControl(js, dnp3tx->
lh.control);
154 jb_open_object(js,
"application");
156 jb_open_object(js,
"control");
157 JsonDNP3LogApplicationControl(js, dnp3tx->
ah.control);
160 jb_set_uint(js,
"function_code", dnp3tx->
ah.function_code);
163 jb_open_array(js,
"objects");
164 JsonDNP3LogObjects(js, &dnp3tx->
objects);
168 jb_set_bool(js,
"complete", dnp3tx->
complete);
174 static void JsonDNP3LogResponse(JsonBuilder *js,
DNP3Transaction *dnp3tx)
182 jb_open_object(js,
"control");
183 JsonDNP3LogLinkControl(js, dnp3tx->
lh.control);
189 jb_open_object(js,
"application");
191 jb_open_object(js,
"control");
192 JsonDNP3LogApplicationControl(js, dnp3tx->
ah.control);
195 jb_set_uint(js,
"function_code", dnp3tx->
ah.function_code);
198 jb_open_array(js,
"objects");
199 JsonDNP3LogObjects(js, &dnp3tx->
objects);
203 jb_set_bool(js,
"complete", dnp3tx->
complete);
208 jb_open_object(js,
"iin");
209 JsonDNP3LogIin(js, (uint16_t)(dnp3tx->
iin.iin1 << 8 | dnp3tx->
iin.iin2));
217 jb_open_object(js,
"dnp3");
219 jb_open_object(js,
"request");
220 JsonDNP3LogRequest(js, tx);
225 jb_open_object(js,
"response");
226 JsonDNP3LogResponse(js, tx);
234 static int JsonDNP3LoggerToServer(
ThreadVars *
tv,
void *thread_data,
235 const Packet *p,
Flow *f,
void *state,
void *vtx, uint64_t tx_id)
246 jb_open_object(js,
"dnp3");
247 JsonDNP3LogRequest(js, tx);
255 static int JsonDNP3LoggerToClient(
ThreadVars *
tv,
void *thread_data,
256 const Packet *p,
Flow *f,
void *state,
void *vtx, uint64_t tx_id)
267 jb_open_object(js,
"dnp3");
268 JsonDNP3LogResponse(js, tx);
277 void *vtx, uint64_t tx_id)
282 JsonDNP3LoggerToServer(
tv, thread_data, p, f, state, vtx, tx_id);
284 JsonDNP3LoggerToClient(
tv, thread_data, p, f, state, vtx, tx_id);
289 static void OutputDNP3LogDeInitCtxSub(
OutputCtx *output_ctx)
291 SCLogDebug(
"cleaning up sub output_ctx %p", output_ctx);
303 if (
unlikely(dnp3log_ctx == NULL)) {
306 dnp3log_ctx->
eve_ctx = json_ctx;
313 output_ctx->
data = dnp3log_ctx;
314 output_ctx->
DeInit = OutputDNP3LogDeInitCtxSub;
316 SCLogInfo(
"DNP3 log sub-module initialized.");
320 result.
ctx = output_ctx;
326 static TmEcode JsonDNP3LogThreadInit(
ThreadVars *t,
const void *initdata,
void **data)
333 if (initdata == NULL) {
334 SCLogDebug(
"Error getting context for DNP3. \"initdata\" is NULL.");
340 if (thread->
ctx == NULL) {
344 *data = (
void *)thread;
356 if (thread == NULL) {
367 OutputDNP3LogInitSub,
ALPROTO_DNP3, JsonDNP3Logger, JsonDNP3LogThreadInit,
368 JsonDNP3LogThreadDeinit);