summaryrefslogtreecommitdiff
path: root/pcap-dag.c
diff options
context:
space:
mode:
authorStephen Donnelly <stephen.donnelly@endace.com>2009-10-13 09:49:57 +1300
committerStephen Donnelly <stephen.donnelly@endace.com>2009-10-13 09:49:57 +1300
commitad4052e8f4845eddebfd9be05f23e40bd2cbe924 (patch)
tree73d2d265a618b145b69ea3384db3c0de49c9a440 /pcap-dag.c
parente6b89d9420708a324c1e4bc3e6a2021709b3e875 (diff)
downloadlibpcap-ad4052e8f4845eddebfd9be05f23e40bd2cbe924.tar.gz
Improve dag_platform_finddevs range and efficiency.
Find dags 0-31 instead of 0-9. Find streams up to DAG_MAX_STREAMS (currently 64) not 16. Use rxstreams count to reduce number of test attaches required.
Diffstat (limited to 'pcap-dag.c')
-rw-r--r--pcap-dag.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/pcap-dag.c b/pcap-dag.c
index 938ec26d..b5de0691 100644
--- a/pcap-dag.c
+++ b/pcap-dag.c
@@ -879,8 +879,8 @@ dag_platform_finddevs(pcap_if_t **devlistp, char *errbuf)
int dagstream;
int dagfd;
- /* Try all the DAGs 0-9 */
- for (c = 0; c < 9; c++) {
+ /* Try all the DAGs 0-31 */
+ for (c = 0; c < 32; c++) {
snprintf(name, 12, "dag%d", c);
if (-1 == dag_parse_name(name, dagname, DAGNAME_BUFSIZE, &dagstream))
{
@@ -897,7 +897,7 @@ dag_platform_finddevs(pcap_if_t **devlistp, char *errbuf)
{
int stream, rxstreams;
rxstreams = dag_rx_get_stream_count(dagfd);
- for(stream=0;stream<16;stream+=2) {
+ for(stream=0;stream<DAG_STREAM_MAX;stream+=2) {
if (0 == dag_attach_stream(dagfd, stream, 0, 0)) {
dag_detach_stream(dagfd, stream);
@@ -908,6 +908,11 @@ dag_platform_finddevs(pcap_if_t **devlistp, char *errbuf)
*/
ret = -1;
}
+
+ rxstreams--;
+ if(rxstreams <= 0) {
+ break;
+ }
}
}
}