add support for pcap receive statistics (used by net-mgmt/darkstat)

This commit is contained in:
Luigi Rizzo 2012-05-03 17:08:40 +00:00
parent b9cd48d64c
commit fb38ae2030
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=234975
2 changed files with 10 additions and 3 deletions

View File

@ -20,3 +20,4 @@ BSD netmap
---------------------------------------------------
0.77 3.82 ports/trafshow (version 5)
0.94 7.7 net-mgmt/ipcad (ip accounting daemon)
0.9 5.0 net-mgmt/darkstat (ip accounting + graphing)

View File

@ -154,6 +154,8 @@ int pcap_setdirection(pcap_t *p, pcap_direction_t d);
char *pcap_lookupdev(char *errbuf);
int pcap_inject(pcap_t *p, const void *buf, size_t size);
int pcap_fileno(pcap_t *p);
const char *pcap_lib_version(void);
struct eproto {
const char *s;
@ -318,6 +320,11 @@ struct eproto eproto_db[] = {
};
const char *pcap_lib_version(void)
{
return pcap_version;
}
int
pcap_findalldevs(pcap_if_t **alldevsp, __unused char *errbuf)
{
@ -532,10 +539,8 @@ pcap_stats(pcap_t *p, struct pcap_stat *ps)
struct my_ring *me = p;
ND("");
me->st.ps_recv += 10;
*ps = me->st;
sprintf(me->msg, "stats not supported");
return -1;
return 0; /* accumulate from pcap_dispatch() */
};
char *
@ -670,6 +675,7 @@ pcap_dispatch(pcap_t *p, int cnt, pcap_handler callback, u_char *user)
got++;
}
}
me->st.ps_recv += got;
return got;
}