]> The Tcpdump Group git mirrors - libpcap/blobdiff - pcap-dag.c
Update config.{guess,sub}, timestamps 2023-01-01,2023-01-21
[libpcap] / pcap-dag.c
index ff006150ee51bf5f441422170d6f1dcec5e0be97..f261ead00df8a0c3bdcbe47206d03b180b883f94 100644 (file)
@@ -736,7 +736,7 @@ dag_inject(pcap_t *p, const void *buf _U_, int size _U_)
  *  API polling parameters.
  *
  *  snaplen is now also ignored, until we get per-stream slen support. Set
- *  slen with approprite DAG tool BEFORE pcap_activate().
+ *  slen with appropriate DAG tool BEFORE pcap_activate().
  *
  *  See also pcap(3).
  */
@@ -793,14 +793,23 @@ static int dag_activate(pcap_t* p)
                /*
                 * XXX - does this reliably set errno?
                 */
-               if (errno == ENOENT)
+               if (errno == ENOENT) {
+                       /*
+                        * There's nothing more to say, so clear
+                        * the error message.
+                        */
                        ret = PCAP_ERROR_NO_SUCH_DEVICE;
-               else if (errno == EPERM || errno == EACCES)
+                       p->errbuf[0] = '\0';
+               } else if (errno == EPERM || errno == EACCES) {
                        ret = PCAP_ERROR_PERM_DENIED;
-               else
+                       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);
+                       pcap_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE,
+                           errno, "dag_config_init %s", device);
+               }
                goto fail;
        }
 
@@ -950,7 +959,7 @@ static int dag_activate(pcap_t* p)
                 * Did the user request that they not be stripped?
                 */
                if ((s = getenv("ERF_DONT_STRIP_FCS")) != NULL) {
-                       /* Yes.  Note the number of bytes that will be
+                       /* Yes.  Note the number of 16-bit words that will be
                           supplied. */
                        p->linktype_ext = LT_FCS_DATALINK_EXT(pd->dag_fcs_bits/16);