- if((handle->fd = dag_open((char *)device)) < 0) {
- pcap_snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "dag_open %s: %s", device, pcap_strerror(errno));
+ if((pd->dag_ref = dag_config_init((char *)device)) == NULL) {
+ /*
+ * XXX - does this reliably set errno?
+ */
+ if (errno == ENOENT) {
+ /*
+ * There's nothing more to say, so clear
+ * the error message.
+ */
+ ret = PCAP_ERROR_NO_SUCH_DEVICE;
+ p->errbuf[0] = '\0';
+ } else if (errno == EPERM || errno == EACCES) {
+ ret = PCAP_ERROR_PERM_DENIED;
+ snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
+ "Attempt to open %s failed with %s - additional privileges may be required",
+ device, (errno == EPERM) ? "EPERM" : "EACCES");
+ } else {
+ ret = PCAP_ERROR;
+ pcap_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE,
+ errno, "dag_config_init %s", device);
+ }