diff options
author | sfd <stephen.donnelly@emulex.com> | 2013-08-16 10:41:47 +1200 |
---|---|---|
committer | sfd <stephen.donnelly@emulex.com> | 2013-08-16 10:41:47 +1200 |
commit | 16fca258d1a4806877aca65394fc10c991df728d (patch) | |
tree | 7198259793ea37690681504c322a383edcf821c4 /pcap-dag.c | |
parent | 3413aa91cd425ce6f047a19dbd76677385dda013 (diff) | |
download | libpcap-16fca258d1a4806877aca65394fc10c991df728d.tar.gz |
Add stream support to dag_create()
DAG capture device names are of the format dagN or dagN:M where N
is the device number and M is the stream number. The former implies
stream 0.
Diffstat (limited to 'pcap-dag.c')
-rw-r--r-- | pcap-dag.c | 31 |
1 files changed, 25 insertions, 6 deletions
@@ -50,9 +50,12 @@ struct rtentry; /* declarations in <net/if.h> */ /* * DAG devices have names beginning with "dag", followed by a number - * from 0 to MAXDAG. + * from 0 to DAG_MAX_BOARDS, then optionally a colon and a stream number + * from 0 to DAG_STREAM_MAX. */ -#define MAXDAG 31 +#ifndef DAG_MAX_BOARDS +#define DAG_MAX_BOARDS 32 +#endif #define ATM_CELL_SIZE 52 #define ATM_HDR_SIZE 4 @@ -870,6 +873,9 @@ pcap_t *dag_create(const char *device, char *ebuf, int *is_ours) char *cpend; long devnum; pcap_t *p; +#ifdef HAVE_DAG_STREAMS_API + long stream = 0; +#endif /* Does this look like a DAG device? */ cp = strrchr(device, '/'); @@ -881,19 +887,32 @@ pcap_t *dag_create(const char *device, char *ebuf, int *is_ours) *is_ours = 0; return NULL; } - /* Yes - is "dag" followed by a number from 0 to MAXDAG? */ + /* Yes - is "dag" followed by a number from 0 to DAG_MAX_BOARDS-1 */ cp += 3; devnum = strtol(cp, &cpend, 10); +#ifdef HAVE_DAG_STREAMS_API + if (*cpend == ':') { + /* Followed by a stream number. */ + stream = strtol(++cpend, &cpend, 10); + } +#endif if (cpend == cp || *cpend != '\0') { /* Not followed by a number. */ *is_ours = 0; return NULL; } - if (devnum < 0 || devnum > MAXDAG) { + if (devnum < 0 || devnum >= DAG_MAX_BOARDS) { /* Followed by a non-valid number. */ *is_ours = 0; return NULL; } +#ifdef HAVE_DAG_STREAMS_API + if (stream <0 || stream >= DAG_STREAM_MAX) { + /* Followed by a non-valid stream number. */ + *is_ours = 0; + return NULL; + } +#endif /* OK, it's probably ours. */ *is_ours = 1; @@ -940,8 +959,8 @@ dag_findalldevs(pcap_if_t **devlistp, char *errbuf) int dagstream; int dagfd; - /* Try all the DAGs 0-MAXDAG */ - for (c = 0; c <= MAXDAG; c++) { + /* Try all the DAGs 0-DAG_MAX_BOARDS */ + for (c = 0; c < DAG_MAX_BOARDS; c++) { snprintf(name, 12, "dag%d", c); if (-1 == dag_parse_name(name, dagname, DAGNAME_BUFSIZE, &dagstream)) { |