+#ifdef HAVE_DAG_STREAMS_API
+ /* Open requested stream. Can fail if already locked or on error */
+ if (dag_attach_stream(handle->fd, handlep->dag_stream, 0, 0) < 0) {
+ pcap_snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "dag_attach_stream: %s", pcap_strerror(errno));
+ goto failclose;
+ }
+
+ /* Set up default poll parameters for stream
+ * Can be overridden by pcap_set_nonblock()
+ */
+ if (dag_get_stream_poll(handle->fd, handlep->dag_stream,
+ &mindata, &maxwait, &poll) < 0) {
+ pcap_snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "dag_get_stream_poll: %s", pcap_strerror(errno));
+ goto faildetach;
+ }
+
+ if (handle->opt.immediate) {
+ /* Call callback immediately.
+ * XXX - is this the right way to handle this?
+ */
+ mindata = 0;
+ } else {
+ /* Amount of data to collect in Bytes before calling callbacks.
+ * Important for efficiency, but can introduce latency
+ * at low packet rates if to_ms not set!
+ */
+ mindata = 65536;
+ }
+
+ /* Obey opt.timeout (was to_ms) if supplied. This is a good idea!
+ * Recommend 10-100ms. Calls will time out even if no data arrived.
+ */
+ maxwait.tv_sec = handle->opt.timeout/1000;
+ maxwait.tv_usec = (handle->opt.timeout%1000) * 1000;
+
+ if (dag_set_stream_poll(handle->fd, handlep->dag_stream,
+ mindata, &maxwait, &poll) < 0) {
+ pcap_snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "dag_set_stream_poll: %s", pcap_strerror(errno));
+ goto faildetach;
+ }
+
+#else
+ if((handlep->dag_mem_base = dag_mmap(handle->fd)) == MAP_FAILED) {
+ pcap_snprintf(handle->errbuf, PCAP_ERRBUF_SIZE,"dag_mmap %s: %s", device, pcap_strerror(errno));
+ goto failclose;
+ }
+
+#endif /* HAVE_DAG_STREAMS_API */
+
+ /* XXX Not calling dag_configure() to set slen; this is unsafe in
+ * multi-stream environments as the gpp config is global.
+ * Once the firmware provides 'per-stream slen' this can be supported
+ * again via the Config API without side-effects */
+#if 0