]> The Tcpdump Group git mirrors - libpcap/commitdiff
Improve dag_platform_finddevs range and efficiency.
authorStephen Donnelly <[email protected]>
Mon, 12 Oct 2009 20:49:57 +0000 (09:49 +1300)
committerStephen Donnelly <[email protected]>
Mon, 12 Oct 2009 20:49:57 +0000 (09:49 +1300)
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.

pcap-dag.c

index 938ec26dce45ddefc49d1d32961a020eb3c39a01..b5de0691b95a448993f36b12913abbf987ef8adf 100644 (file)
@@ -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;
+                                               }
                                        }
                                }                               
                        }