代码拉取完成,页面将自动刷新
#include "log.h"
const char *msg_type[] = {
"OFPT_FLOW_MOD_ADD",
"OFPT_STATS_REQUEST_FLOW",
"OFPT_STATS_REPLY_FLOW",
"OFPT_STATS_REQUEST_FLOW",
"OFPT_STATS_REPLY_PORT",
"OFPT_HELLO",
"OFPT_ECHO_REPLY",
"OFPT_ECHO_REQUEST",
"OFPT_ERROR",
"GENERIC_MSG",
"SNMP_MSG",
"PCAP_MSG",
"OFPT_PACKET_IN_MSG",
"PKTGEN_MSG"
};
FILE* logger;
/*
* Initializes the logging system of oflops.
* @param filename The file where the logging messages are stored.
*/
void
oflops_log_init(const char *filename) {
logger = fopen(filename, "w");
if(logger == NULL) {
perror_and_exit("failed to open log file", 1);
}
}
int
oflops_log(struct timeval ts, int type, char *details) {
fprintf(logger, "%lu.%06lu:%s:%s\n",(long unsigned int)ts.tv_sec,
(long unsigned int)ts.tv_usec, msg_type[type], details);
fflush(logger);
return 1;
}
/*
* Initializes the logging system of oflops.
* @param filename The file where the logging messages are stored.
*/
void
oflops_log_close() {
fclose(logger);
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。