case EAGAIN:
return (0);
}
- strlcpy(p->errbuf, pcap_strerror(errno),
- sizeof(p->errbuf));
+ pcap_fmt_errmsg_for_errno(p->errbuf,
+ sizeof(p->errbuf), errno, "getmsg");
return (-1);
}
cc = data.len;
#if defined(DLIOCRAW)
ret = write(p->fd, buf, size);
if (ret == -1) {
- pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "send: %s",
- pcap_strerror(errno));
+ pcap_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE,
+ errno, "send");
return (-1);
}
#elif defined(DL_HP_RAWDLS)
}
ret = dlrawdatareq(pd->send_fd, buf, size);
if (ret == -1) {
- pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "send: %s",
- pcap_strerror(errno));
+ pcap_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE,
+ errno, "send");
return (-1);
}
/*
status = PCAP_ERROR_PERM_DENIED;
else
status = PCAP_ERROR;
- pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
- "%s: %s", cp, pcap_strerror(errno));
+ pcap_fmt_errmsg_for_errno(errbuf, PCAP_ERRBUF_SIZE,
+ errno, "%s", cp);
return (status);
}
status = PCAP_ERROR_PERM_DENIED;
else
status = PCAP_ERROR;
- pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, "%s: %s", dname,
- pcap_strerror(errno));
+ pcap_fmt_errmsg_for_errno(errbuf, PCAP_ERRBUF_SIZE,
+ errno, "%s", dname);
return (status);
}
status = PCAP_ERROR_PERM_DENIED;
else
status = PCAP_ERROR;
- pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, "%s: %s",
- dname2, pcap_strerror(errno));
+ pcap_fmt_errmsg_for_errno(errbuf,
+ PCAP_ERRBUF_SIZE, errno, "%s", dname2);
}
return (status);
}
*/
if (strioctl(p->fd, A_PROMISCON_REQ, 0, NULL) < 0) {
status = PCAP_ERROR;
- pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
- "A_PROMISCON_REQ: %s", pcap_strerror(errno));
+ pcap_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE,
+ errno, "A_PROMISCON_REQ");
goto bad;
}
} else
*/
if (strioctl(p->fd, DLIOCRAW, 0, NULL) < 0) {
status = PCAP_ERROR;
- pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "DLIOCRAW: %s",
- pcap_strerror(errno));
+ pcap_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE,
+ errno, "DLIOCRAW");
goto bad;
}
#endif
*/
if (ioctl(p->fd, I_FLUSH, FLUSHR) != 0) {
status = PCAP_ERROR;
- pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE, "FLUSHR: %s",
- pcap_strerror(errno));
+ pcap_fmt_errmsg_for_errno(p->errbuf, PCAP_ERRBUF_SIZE,
+ errno, "FLUSHR");
goto bad;
}
}
if (strioctl(fd, A_GET_UNITS, sizeof(buf), (char *)&buf) < 0) {
- pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE, "A_GET_UNITS: %s",
- pcap_strerror(errno));
+ pcap_fmt_errmsg_for_errno(errbuf, PCAP_ERRBUF_SIZE,
+ errno, "A_GET_UNITS");
return (-1);
}
for (i = 0; i < buf.nunits; i++) {
flags = 0;
if (putmsg(fd, &ctl, (struct strbuf *) NULL, flags) < 0) {
- pcap_snprintf(ebuf, PCAP_ERRBUF_SIZE,
- "send_request: putmsg \"%s\": %s",
- what, pcap_strerror(errno));
+ pcap_fmt_errmsg_for_errno(ebuf, PCAP_ERRBUF_SIZE,
+ errno, "send_request: putmsg \"%s\"", what);
return (-1);
}
return (0);
flags = 0;
if (getmsg(fd, &ctl, (struct strbuf*)NULL, &flags) < 0) {
- pcap_snprintf(ebuf, PCAP_ERRBUF_SIZE, "recv_ack: %s getmsg: %s",
- what, pcap_strerror(errno));
+ pcap_fmt_errmsg_for_errno(ebuf, PCAP_ERRBUF_SIZE,
+ errno, "recv_ack: %s getmsg", what);
return (PCAP_ERROR);
}
case DL_SYSERR:
if (uerror != NULL)
*uerror = dlp->error_ack.dl_unix_errno;
- pcap_snprintf(ebuf, PCAP_ERRBUF_SIZE,
- "recv_ack: %s: UNIX error - %s",
- what, pcap_strerror(dlp->error_ack.dl_unix_errno));
+ pcap_fmt_errmsg_for_errno(ebuf, PCAP_ERRBUF_SIZE,
+ dlp->error_ack.dl_unix_errno,
+ "recv_ack: %s: UNIX error", what);
if (dlp->error_ack.dl_unix_errno == EPERM ||
dlp->error_ack.dl_unix_errno == EACCES)
return (PCAP_ERROR_PERM_DENIED);
*/
/* get the head first */
if (getmsg(fd, &ctl, (struct strbuf *)NULL, &flags) < 0) {
- pcap_snprintf(ebuf, PCAP_ERRBUF_SIZE,
- "get_dlpi_ppa: hpppa getmsg: %s", pcap_strerror(errno));
+ pcap_fmt_errmsg_for_errno(ebuf, PCAP_ERRBUF_SIZE,
+ errno, "get_dlpi_ppa: hpppa getmsg");
return (PCAP_ERROR);
}
if (ctl.len == -1) {
/* allocate buffer */
if ((ppa_data_buf = (char *)malloc(dlp->dl_length)) == NULL) {
- pcap_snprintf(ebuf, PCAP_ERRBUF_SIZE,
- "get_dlpi_ppa: hpppa malloc: %s", pcap_strerror(errno));
+ pcap_fmt_errmsg_for_errno(ebuf, PCAP_ERRBUF_SIZE,
+ errno, "get_dlpi_ppa: hpppa malloc");
return (PCAP_ERROR);
}
ctl.maxlen = dlp->dl_length;
ctl.buf = (char *)ppa_data_buf;
/* get the data */
if (getmsg(fd, &ctl, (struct strbuf *)NULL, &flags) < 0) {
- pcap_snprintf(ebuf, PCAP_ERRBUF_SIZE,
- "get_dlpi_ppa: hpppa getmsg: %s", pcap_strerror(errno));
+ pcap_fmt_errmsg_for_errno(ebuf, PCAP_ERRBUF_SIZE,
+ errno, "get_dlpi_ppa: hpppa getmsg");
free(ppa_data_buf);
return (PCAP_ERROR);
}
*/
pcap_snprintf(dname, sizeof(dname), "/dev/%s%u", device, unit);
if (stat(dname, &statbuf) < 0) {
- pcap_snprintf(ebuf, PCAP_ERRBUF_SIZE, "stat: %s: %s",
- dname, pcap_strerror(errno));
+ pcap_fmt_errmsg_for_errno(ebuf, PCAP_ERRBUF_SIZE,
+ errno, "stat: %s", dname);
return (PCAP_ERROR);
}
majdev = major(statbuf.st_rdev);
}
kd = open("/dev/kmem", O_RDONLY);
if (kd < 0) {
- pcap_snprintf(ebuf, PCAP_ERRBUF_SIZE, "kmem open: %s",
- pcap_strerror(errno));
+ pcap_fmt_errmsg_for_errno(ebuf, PCAP_ERRBUF_SIZE,
+ errno, "kmem open");
return (PCAP_ERROR);
}
if (dlpi_kread(kd, nl[NL_IFNET].n_value,
register int cc;
if (lseek(fd, addr, SEEK_SET) < 0) {
- pcap_snprintf(ebuf, PCAP_ERRBUF_SIZE, "lseek: %s",
- pcap_strerror(errno));
+ pcap_fmt_errmsg_for_errno(ebuf, PCAP_ERRBUF_SIZE,
+ errno, "lseek");
return (-1);
}
cc = read(fd, buf, len);
if (cc < 0) {
- pcap_snprintf(ebuf, PCAP_ERRBUF_SIZE, "read: %s",
- pcap_strerror(errno));
+ pcap_fmt_errmsg_for_errno(ebuf, PCAP_ERRBUF_SIZE,
+ errno, "read");
return (-1);
} else if (cc != len) {
pcap_snprintf(ebuf, PCAP_ERRBUF_SIZE, "short read (%d != %d)", cc,