#include <rte_mbuf.h>
#include "log.h"
+#include "quit.h"
#include "display.h"
#include "defaults.h"
#include "etypes.h"
tsc_off = rte_rdtsc() + 2500000000;
}
+void plog_end(void)
+{
+ if (fp)
+ fclose(fp);
+ fp = NULL;
+}
+
int plog_set_lvl(int lvl)
{
if (lvl <= PROX_MAX_LOG_LVL) {
static int dump_pkt(char *dst, size_t dst_size, const struct rte_mbuf *mbuf)
{
- const struct ether_hdr *peth = rte_pktmbuf_mtod(mbuf, const struct ether_hdr *);
- const struct ipv4_hdr *dpip = (const struct ipv4_hdr *)(peth + 1);
+ const prox_rte_ether_hdr *peth = rte_pktmbuf_mtod(mbuf, const prox_rte_ether_hdr *);
+ const prox_rte_ipv4_hdr *dpip = (const prox_rte_ipv4_hdr *)(peth + 1);
const uint8_t *pkt_bytes = (const uint8_t *)peth;
const uint16_t len = rte_pktmbuf_pkt_len(mbuf);
size_t str_len = 0;
ret--;
ret += dump_pkt(buf + ret, sizeof(buf) - ret, mbuf);
}
+
+ if (lvl == PROX_LOG_PANIC)
+ PROX_PANIC(1, "%s", buf);
+
plog_buf(buf);
if (lvl == PROX_LOG_WARN) {
return ret;
}
+int plog_err_or_panic(int do_panic, const char *fmt, ...)
+{
+ va_list ap;
+ int ret;
+
+ va_start(ap, fmt);
+ if (do_panic) {
+ ret = vplog(PROX_LOG_PANIC, fmt, ap, NULL, 0);
+ va_end(ap);
+ return ret;
+ } else {
+ ret = vplog(PROX_LOG_ERR, fmt, ap, NULL, 0);
+ va_end(ap);
+ return ret;
+ }
+}
+
int plogx_err(const char *fmt, ...)
{
va_list ap;