2 * \author Edward Fjellskål <edward.fjellskaal@redpill-linpro.com>
3 * \author Kacper Wysocki <comotion@krutt.org>
6 //#include "../common.h"
7 //#include "log_sguil.h"
10 #include "../sys_func.h" // u_ntop
12 #include "log_stdout.h"
16 output_plugin
*log_output
[LOG_MAX
];
18 /* set up function pointers for logging */
19 int init_logging(int logtype
, const char *file
, int flags
)
21 output_plugin
*log_fun
;
25 log_fun
= init_log_file();
28 log_fun
= init_log_stdout();
31 //init_output_sguil(&log_fun, file, flags);
33 /* these types are coming !*/
39 fprintf(stderr
,"whoops! init_logging\n");
42 log_output
[n_outputs
++] = log_fun
;
44 return log_fun
->init(log_fun
, file
, flags
);
51 /* magic logging function - iterate over all loggers */
52 // note... this breaks anywhere non-GNU!
53 #define log_foo(func, all, count, ...) do { int _i; for(_i = 0; _i < (count) ; _i++) { output_plugin* _p = all[_i]; if(_p && _p -> func) _p -> func(_p, ##__VA_ARGS__); } }while(0)
58 log_foo(denit
, log_output
, n_outputs
);
61 void log_asset_arp (asset
*masset
)
64 //static char ip_addr_s[INET6_ADDRSTRLEN];
65 //inet_ntop(AF_INET, &masset->ip_addr.s6_addr32[0], ip_addr_s, INET_ADDRSTRLEN + 1 );
66 //dlog("[*] added mac address to asset: %s\n",ip_addr_s);
68 log_foo(arp
, log_output
, n_outputs
, masset
);
71 void log_asset_os (asset
*main
, os_asset
*os
)
74 static char ip_addr_s
[INET6_ADDRSTRLEN
];
75 u_ntop(main
->ip_addr
, main
->af
, ip_addr_s
);
76 //dlog("[%lu] Incoming asset, %s: %s:%u [%s]\n",
77 //os->last_seen, (char*)bdata(os->detection),ip_addr_s,ntohs(os->port),(char*)bdata(os->raw_fp));
79 log_foo(os
, log_output
, n_outputs
, main
, os
);
82 void log_asset_service (asset
*main
, serv_asset
*service
)
85 static char ip_addr_s
[INET6_ADDRSTRLEN
];
86 u_ntop(main
->ip_addr
, main
->af
, ip_addr_s
);
87 if (service
->role
== 1) {
88 fprintf(stderr
, "[*] new service: %s:%d %s\n",ip_addr_s
,ntohs(service
->port
),(char *)bdata(service
->application
));
90 fprintf(stderr
, "[*] new client: %s:%d %s\n",ip_addr_s
,ntohs(service
->port
),(char *)bdata(service
->application
));
93 log_foo(service
, log_output
, n_outputs
, main
, service
);