#include <arpa/inet.h>
#include <fcntl.h>
#include <errno.h>
+#include <signal.h>
#ifndef SO_BUSY_POLL
#define SO_BUSY_POLL 46
int (*out_fn)(struct out_ctx *ctx, struct can_frame *cf);
};
+struct stats {
+ int store;
+ int send;
+} stats;
+
+void sigint(int v)
+{
+ printf("store:%d\nsend:%d\ntotal:%d\n",
+ stats.store, stats.send, stats.store + stats.send);
+ exit(0);
+}
+
enum in2out in_read(struct in_ctx *ctx, struct can_frame *cf)
{
int ret = read(ctx->s, cf, sizeof(*cf));
//struct sockaddr_ll *addr = (void*)hdr + TPACKET_ALIGN(ctx->hdrlen);
(void)ret;
struct can_frame *cf_mmap = (void*)hdr + hdr->tp_mac;
- //printf("ret:%d st:%#08x m:%d RX in frame %2d, CAN ID %#3x\n", ret, hdr->tp_status, hdr->tp_mac, ctx->current, cf_mmap->can_id);
*cf = *cf_mmap;
hdr->tp_status = 0;
ctx->current = (ctx->current + 1) % FRAME_NR;
if (optind+1 < argc)
devout = argv[optind+1];
+ signal(SIGINT, sigint);
gw();
return 0;