- pcap_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE,
- errno, "dag_config_init %s", device);
+ /*
+ * 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);
+ }