#include <smi.h>
#endif
+#ifdef HAVE_LIBCRYPTO
+#include <openssl/crypto.h>
+#endif
+
#ifdef HAVE_GETOPT_LONG
#include <getopt.h>
#else
*/
#define OPTION_NUMBER 128
#define OPTION_VERSION 129
+#define OPTION_TSTAMP_PRECISION 130
-static struct option longopts[] = {
+static const struct option longopts[] = {
#if defined(HAVE_PCAP_CREATE) || defined(WIN32)
{ "buffer-size", required_argument, NULL, 'B' },
#endif
{ "time-stamp-type", required_argument, NULL, 'j' },
{ "list-time-stamp-types", no_argument, NULL, 'J' },
#endif
+ { "time-stamp-precision", required_argument, NULL, OPTION_TSTAMP_PRECISION},
{ "dont-verify-checksums", no_argument, NULL, 'K' },
{ "list-data-link-types", no_argument, NULL, 'L' },
{ "no-optimize", no_argument, NULL, 'O' },
#ifdef HAVE_CAP_NG_H
int ret = capng_change_id(pw->pw_uid, pw->pw_gid, CAPNG_NO_FLAG);
if (ret < 0) {
- printf("error : ret %d\n", ret);
+ fprintf(stderr, "error : ret %d\n", ret);
+ }
+ else {
+ printf("dropped privs to %s\n", username);
}
/* We don't need CAP_SETUID and CAP_SETGID */
capng_update(CAPNG_DROP, CAPNG_EFFECTIVE, CAP_SETUID);
pcap_strerror(errno));
exit(1);
}
+ else {
+ printf("dropped privs to %s\n", username);
+ }
#endif /* HAVE_CAP_NG_H */
}
else {
return ret;
}
+static int
+tstamp_precision_from_string(const char *precision)
+{
+ if (strncmp(precision, "nano", strlen("nano")) == 0)
+ return PCAP_TSTAMP_PRECISION_NANO;
+
+ if (strncmp(precision, "micro", strlen("micro")) == 0)
+ return PCAP_TSTAMP_PRECISION_MICRO;
+
+ return -EINVAL;
+}
+
int
main(int argc, char **argv)
{
exit(0);
break;
+ case OPTION_TSTAMP_PRECISION:
+ gndo->ndo_tstamp_precision = tstamp_precision_from_string(optarg);
+ if (gndo->ndo_tstamp_precision < 0)
+ error("unsupported time stamp precision");
+ break;
+
default:
print_usage();
exit(1);
RFileName = VFileLine;
}
- pd = pcap_open_offline(RFileName, ebuf);
+ if (gndo->ndo_tstamp_precision == PCAP_TSTAMP_PRECISION_NANO)
+ pd = pcap_open_offline_with_tstamp_precision(RFileName, PCAP_TSTAMP_PRECISION_NANO, ebuf);
+ else
+ pd = pcap_open_offline_with_tstamp_precision(RFileName, PCAP_TSTAMP_PRECISION_MICRO, ebuf);
+
if (pd == NULL)
error("%s", ebuf);
dlt = pcap_datalink(pd);
if (Jflag)
show_tstamp_types_and_exit(device, pd);
#endif
+ if (gndo->ndo_tstamp_precision == PCAP_TSTAMP_PRECISION_NANO) {
+ status = pcap_set_tstamp_precision(pd, PCAP_TSTAMP_PRECISION_NANO);
+ if (status != 0)
+ error("%s: Can't set nanosecond time stamp precision: %s",
+ device, pcap_statustostr(status));
+ }
+
/*
* Is this an interface that supports monitor mode?
*/
}
#endif
+USES_APPLE_DEPRECATED_API
static void
print_version(void)
{
(void)fprintf(stderr, "libpcap version %s\n", pcap_version);
#endif /* WIN32 */
#endif /* HAVE_PCAP_LIB_VERSION */
+
+#if defined(HAVE_LIBCRYPTO) && defined(SSLEAY_VERSION)
+ (void)fprintf (stderr, "%s\n", SSLeay_version(SSLEAY_VERSION));
+#endif
+
+#if defined(HAVE_SMI_H)
+ (void)fprintf (stderr, "SMI-library: %s\n", smi_version_string);
+#endif
}
+USES_APPLE_RST
static void
print_usage(void)
"\t\t[ -Q in|out|inout ]\n");
#endif
(void)fprintf(stderr,
-"\t\t[ -r file ] [ -s snaplen ] [ -T type ] [ -V file ] [ -w file ]\n");
+"\t\t[ -r file ] [ -s snaplen ] [ -T type ] [ --version ] [ -V file ]\n");
(void)fprintf(stderr,
-"\t\t[ -W filecount ] [ -y datalinktype ] [ -z command ]\n");
+"\t\t[ -w file ] [ -W filecount ] [ -y datalinktype ] [ -z command ]\n");
(void)fprintf(stderr,
"\t\t[ -Z user ] [ expression ]\n");
}