merge from main

This commit is contained in:
Oscar Zhao 2023-04-03 04:17:38 -04:00
commit 0799db0cd6
47 changed files with 7620 additions and 198 deletions

51
.gitignore vendored
View File

@ -38,32 +38,25 @@ ipch/
# ignore emacs backup saves
*~
# ignore bin test directory
bin/
*.log
ref_trace_decoder/build/win/rctdl_c_api_lib/Release/*
ref_trace_decoder/build/win/rctdl_c_api_lib/x64/Release/*
ref_trace_decoder/build/win/ref_trace_decode_lib/Release/*
ref_trace_decoder/build/win/ref_trace_decode_lib/x64/Release/*
ref_trace_decoder/tests/build/win/simple_pkt_print_c_api/Release/*
ref_trace_decoder/tests/build/win/simple_pkt_print_c_api/x64/Release/*
*.lastbuildstate
*.manifest
*.cache
ref_trace_decoder/docs/html/*
ref_trace_decoder/tests/build/win/simple_pkt_print_c_api/Debug-dll/*
ref_trace_decoder/tests/build/win/simple_pkt_print_c_api/x64/Debug-dll/*
ref_trace_decoder/tests/build/win/trc_pkt_lister/Debug-dll/*
ref_trace_decoder/tests/build/win/trc_pkt_lister/Release-dll/*
ref_trace_decoder/tests/build/win/trc_pkt_lister/x64/Debug-dll/*
ref_trace_decoder/tests/build/win/trc_pkt_lister/x64/Release-dll/*
*.bak
*.orig
decoder/docs/html/*
*.orig
*.VC.db
*.VC.VC.opendb
*.iobj
*.ipdb
decoder/tests/results*
_.tinderbox.*
_.universe-toolchain
_.amd64.*
_.arm.*
_.arm64.*
_.i386.*
_.powerpc.*
_.riscv.*
GPATH
GRTAGS
GTAGS
ID
cscope.files
cscope.in.out
cscope.out
cscope.po.out
compile_commands.json
compile_commands.events.json
tags
.cache
.clangd
.ccls-cache

View File

@ -14,10 +14,10 @@ above), please navigate to https://github.com/the-tcpdump-group/libpcap/issues
and check if the problem has already been reported. If it has not, please open
a new issue and provide the following details:
* libpcap version (e.g. from tcpdump --version)
* libpcap version (e.g. from `tcpdump --version`)
* operating system name and version and any other details that may be relevant
(uname -a, compiler name and version, CPU type etc.)
* configure flags if any were used
(`uname -a`, compiler name and version, CPU type etc.)
* `configure` or `cmake` flags if any were used
* statement of the problem
* steps to reproduce

View File

@ -1,22 +1,17 @@
To report a security issue please send an e-mail to security@tcpdump.org.
# LIBPCAP 1.x.y by [The Tcpdump Group](https://www.tcpdump.org)
**To report a security issue please send an e-mail to security@tcpdump.org.**
To report bugs and other problems, contribute patches, request a
feature, provide generic feedback etc please see the file
[CONTRIBUTING](CONTRIBUTING.md) in the libpcap source tree root.
feature, provide generic feedback etc please see the
[guidelines for contributing](CONTRIBUTING.md).
The directory doc/ has README files about specific operating systems and
options.
LIBPCAP 1.x.y
Now maintained by "The Tcpdump Group"
https://www.tcpdump.org
The [documentation directory](doc/) has README files about specific
operating systems and options.
Anonymous Git is available via:
https://github.com/the-tcpdump-group/libpcap.git
formerly from Lawrence Berkeley National Laboratory
Network Research Group <libpcap@ee.lbl.gov>
ftp://ftp.ee.lbl.gov/old/libpcap-0.4a7.tar.Z
https://github.com/the-tcpdump-group/libpcap.git
This directory contains source code for libpcap, a system-independent
interface for user-level packet capture. libpcap provides a portable
@ -28,7 +23,14 @@ require this functionality, we've created this system-independent API
to ease in porting and to alleviate the need for several
system-dependent packet capture modules in each application.
For some platforms there are README.{system} files that discuss issues
```text
formerly from Lawrence Berkeley National Laboratory
Network Research Group <libpcap@ee.lbl.gov>
ftp://ftp.ee.lbl.gov/old/libpcap-0.4a7.tar.Z
```
### Support for particular platforms and BPF
For some platforms there are `README.{system}` files that discuss issues
with the OS's interface for packet capture on those platforms, such as
how to enable support for that interface in the OS, if it's not built in
by default.
@ -36,22 +38,10 @@ by default.
The libpcap interface supports a filtering mechanism based on the
architecture in the BSD packet filter. BPF is described in the 1993
Winter Usenix paper ``The BSD Packet Filter: A New Architecture for
User-level Packet Capture''. A compressed PostScript version can be
found at
ftp://ftp.ee.lbl.gov/papers/bpf-usenix93.ps.Z
or
https://www.tcpdump.org/papers/bpf-usenix93.ps.Z
and a gzipped version can be found at
https://www.tcpdump.org/papers/bpf-usenix93.ps.gz
A PDF version can be found at
https://www.tcpdump.org/papers/bpf-usenix93.pdf
User-level Packet Capture''
([compressed PostScript](https://www.tcpdump.org/papers/bpf-usenix93.ps.Z),
[gzipped PostScript](https://www.tcpdump.org/papers/bpf-usenix93.ps.gz),
[PDF](https://www.tcpdump.org/papers/bpf-usenix93.pdf)).
Although most packet capture interfaces support in-kernel filtering,
libpcap utilizes in-kernel filtering only for the BPF interface.
@ -62,32 +52,25 @@ would translate BPF filters into a filter program that is compatible
with the underlying kernel subsystem, but this is not yet implemented.
BPF is standard in 4.4BSD, BSD/OS, NetBSD, FreeBSD, OpenBSD, DragonFly
BSD, and macOS; an older, modified and undocumented version is standard
in AIX. {DEC OSF/1, Digital UNIX, Tru64 UNIX} uses the packetfilter
interface but has been extended to accept BPF filters (which libpcap
utilizes). Also, you can add BPF filter support to Ultrix using the
kernel source and/or object patches available in:
https://www.tcpdump.org/other/bpfext42.tar.Z
BSD, macOS, and Solaris 11; an older, modified and undocumented version
is standard in AIX. {DEC OSF/1, Digital UNIX, Tru64 UNIX} uses the
packetfilter interface but has been extended to accept BPF filters
(which libpcap utilizes).
Linux has a number of BPF based systems, and libpcap does not support
any of the eBPF mechanisms as yet, although it supports many of the
memory mapped receive mechanisms.
See the [README.linux](doc/README.linux.md) file for more information.
See the [Linux-specific README](doc/README.linux) for more information.
Note to Linux distributions and *BSD systems that include libpcap:
### Note to Linux distributions and *BSD systems that include libpcap:
There's now a rule to make a shared library, which should work on Linux
and *BSD, among other platforms.
It sets the soname of the library to "libpcap.so.1"; this is what it
should be, *NOT* libpcap.so.1.x or libpcap.so.1.x.y or something such as
It sets the soname of the library to `libpcap.so.1`; this is what it
should be, **NOT** `libpcap.so.1.x` or `libpcap.so.1.x.y` or something such as
that.
We've been maintaining binary compatibility between libpcap releases for
quite a while; there's no reason to tie a binary linked with libpcap to
a particular release of libpcap.
Current versions can be found at https://www.tcpdump.org.
- The TCPdump group

217
contrib/libpcap/charconv.c Normal file
View File

@ -0,0 +1,217 @@
/* -*- Mode: c; tab-width: 8; indent-tabs-mode: 1; c-basic-offset: 8; -*- */
/*
* Copyright (c) 1993, 1994, 1995, 1996, 1997
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the Computer Systems
* Engineering Group at Lawrence Berkeley Laboratory.
* 4. Neither the name of the University nor of the Laboratory may be used
* to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#ifdef _WIN32
#include <stdio.h>
#include <errno.h>
#include <pcap/pcap.h> /* Needed for PCAP_ERRBUF_SIZE */
#include "charconv.h"
wchar_t *
cp_to_utf_16le(UINT codepage, const char *cp_string, DWORD flags)
{
int utf16le_len;
wchar_t *utf16le_string;
/*
* Map from the specified code page to UTF-16LE.
* First, find out how big a buffer we'll need.
*/
utf16le_len = MultiByteToWideChar(codepage, flags, cp_string, -1,
NULL, 0);
if (utf16le_len == 0) {
/*
* Error. Fail with EINVAL.
*/
errno = EINVAL;
return (NULL);
}
/*
* Now attempt to allocate a buffer for that.
*/
utf16le_string = malloc(utf16le_len * sizeof (wchar_t));
if (utf16le_string == NULL) {
/*
* Not enough memory; assume errno has been
* set, and fail.
*/
return (NULL);
}
/*
* Now convert.
*/
utf16le_len = MultiByteToWideChar(codepage, flags, cp_string, -1,
utf16le_string, utf16le_len);
if (utf16le_len == 0) {
/*
* Error. Fail with EINVAL.
* XXX - should this ever happen, given that
* we already ran the string through
* MultiByteToWideChar() to find out how big
* a buffer we needed?
*/
free(utf16le_string);
errno = EINVAL;
return (NULL);
}
return (utf16le_string);
}
char *
utf_16le_to_cp(UINT codepage, const wchar_t *utf16le_string)
{
int cp_len;
char *cp_string;
/*
* Map from UTF-16LE to the specified code page.
* First, find out how big a buffer we'll need.
* We convert composite characters to precomposed characters,
* as that's what Windows expects.
*/
cp_len = WideCharToMultiByte(codepage, WC_COMPOSITECHECK,
utf16le_string, -1, NULL, 0, NULL, NULL);
if (cp_len == 0) {
/*
* Error. Fail with EINVAL.
*/
errno = EINVAL;
return (NULL);
}
/*
* Now attempt to allocate a buffer for that.
*/
cp_string = malloc(cp_len * sizeof (char));
if (cp_string == NULL) {
/*
* Not enough memory; assume errno has been
* set, and fail.
*/
return (NULL);
}
/*
* Now convert.
*/
cp_len = WideCharToMultiByte(codepage, WC_COMPOSITECHECK,
utf16le_string, -1, cp_string, cp_len, NULL, NULL);
if (cp_len == 0) {
/*
* Error. Fail with EINVAL.
* XXX - should this ever happen, given that
* we already ran the string through
* WideCharToMultiByte() to find out how big
* a buffer we needed?
*/
free(cp_string);
errno = EINVAL;
return (NULL);
}
return (cp_string);
}
/*
* Convert an error message string from UTF-8 to the local code page, as
* best we can.
*
* The buffer is assumed to be PCAP_ERRBUF_SIZE bytes long; we truncate
* if it doesn't fit.
*/
void
utf_8_to_acp_truncated(char *errbuf)
{
wchar_t *utf_16_errbuf;
int retval;
DWORD err;
/*
* Do this by converting to UTF-16LE and then to the local
* code page. That means we get to use Microsoft's
* conversion routines, rather than having to understand
* all the code pages ourselves, *and* that this routine
* can convert in place.
*/
/*
* Map from UTF-8 to UTF-16LE.
* First, find out how big a buffer we'll need.
* Convert any invalid characters to REPLACEMENT CHARACTER.
*/
utf_16_errbuf = cp_to_utf_16le(CP_UTF8, errbuf, 0);
if (utf_16_errbuf == NULL) {
/*
* Error. Give up.
*/
snprintf(errbuf, PCAP_ERRBUF_SIZE,
"Can't convert error string to the local code page");
return;
}
/*
* Now, convert that to the local code page.
* Use the current thread's code page. For unconvertable
* characters, let it pick the "best fit" character.
*
* XXX - we'd like some way to do what utf_16le_to_utf_8_truncated()
* does if the buffer isn't big enough, but we don't want to have
* to handle all local code pages ourselves; doing so requires
* knowledge of all those code pages, including knowledge of how
* characters are formed in thoe code pages so that we can avoid
* cutting a multi-byte character into pieces.
*
* Converting to an un-truncated string using Windows APIs, and
* then copying to the buffer, still requires knowledge of how
* characters are formed in the target code page.
*/
retval = WideCharToMultiByte(CP_THREAD_ACP, 0, utf_16_errbuf, -1,
errbuf, PCAP_ERRBUF_SIZE, NULL, NULL);
if (retval == 0) {
err = GetLastError();
free(utf_16_errbuf);
if (err == ERROR_INSUFFICIENT_BUFFER)
snprintf(errbuf, PCAP_ERRBUF_SIZE,
"The error string, in the local code page, didn't fit in the buffer");
else
snprintf(errbuf, PCAP_ERRBUF_SIZE,
"Can't convert error string to the local code page");
return;
}
free(utf_16_errbuf);
}
#endif

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,36 @@
/*
* Copyright (c) 1999 - 2005 NetGroup, Politecnico di Torino (Italy)
* Copyright (c) 2005 - 2010 CACE Technologies, Davis (California)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the Politecnico di Torino, CACE Technologies
* nor the names of its contributors may be used to endorse or promote
* products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
pcap_t *airpcap_create(const char *, char *, int *);
int airpcap_findalldevs(pcap_if_list_t *devlistp, char *errbuf);
int device_is_airpcap(const char *device, char *ebuf);

1086
contrib/libpcap/pcap-dpdk.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,28 @@
/*
* Copyright (C) 2018 jingle YANG. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS''AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
pcap_t *pcap_dpdk_create(const char *, char *, int *);
int pcap_dpdk_findalldevs(pcap_if_list_t *devlistp, char *errbuf);

View File

@ -0,0 +1,305 @@
/*
* Copyright 2006-2010, Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
* Axel Dörfler, axeld@pinc-software.de
* James Woodcock
*/
#include "config.h"
#include "pcap-int.h"
#include <OS.h>
#include <sys/socket.h>
#include <sys/sockio.h>
#include <net/if.h>
#include <net/if_dl.h>
#include <net/if_types.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/*
* Private data for capturing on Haiku sockets.
*/
struct pcap_haiku {
struct pcap_stat stat;
char *device; /* device name */
};
bool
prepare_request(struct ifreq& request, const char* name)
{
if (strlen(name) >= IF_NAMESIZE)
return false;
strcpy(request.ifr_name, name);
return true;
}
static int
pcap_read_haiku(pcap_t* handle, int maxPackets _U_, pcap_handler callback,
u_char* userdata)
{
// Receive a single packet
u_char* buffer = (u_char*)handle->buffer + handle->offset;
struct sockaddr_dl from;
ssize_t bytesReceived;
do {
if (handle->break_loop) {
// Clear the break loop flag, and return -2 to indicate our
// reasoning
handle->break_loop = 0;
return -2;
}
socklen_t fromLength = sizeof(from);
bytesReceived = recvfrom(handle->fd, buffer, handle->bufsize, MSG_TRUNC,
(struct sockaddr*)&from, &fromLength);
} while (bytesReceived < 0 && errno == B_INTERRUPTED);
if (bytesReceived < 0) {
if (errno == B_WOULD_BLOCK) {
// there is no packet for us
return 0;
}
snprintf(handle->errbuf, sizeof(handle->errbuf),
"recvfrom: %s", strerror(errno));
return -1;
}
int32 captureLength = bytesReceived;
if (captureLength > handle->snapshot)
captureLength = handle->snapshot;
// run the packet filter
if (handle->fcode.bf_insns) {
if (pcap_filter(handle->fcode.bf_insns, buffer, bytesReceived,
captureLength) == 0) {
// packet got rejected
return 0;
}
}
// fill in pcap_header
pcap_pkthdr header;
header.caplen = captureLength;
header.len = bytesReceived;
header.ts.tv_usec = system_time() % 1000000;
header.ts.tv_sec = system_time() / 1000000;
// TODO: get timing from packet!!!
/* Call the user supplied callback function */
callback(userdata, &header, buffer);
return 1;
}
static int
pcap_inject_haiku(pcap_t *handle, const void *buffer, int size)
{
// we don't support injecting packets yet
// TODO: use the AF_LINK protocol (we need another socket for this) to
// inject the packets
strlcpy(handle->errbuf, "Sending packets isn't supported yet",
PCAP_ERRBUF_SIZE);
return -1;
}
static int
pcap_stats_haiku(pcap_t *handle, struct pcap_stat *stats)
{
struct pcap_haiku* handlep = (struct pcap_haiku*)handle->priv;
ifreq request;
int socket = ::socket(AF_INET, SOCK_DGRAM, 0);
if (socket < 0) {
return -1;
}
prepare_request(request, handlep->device);
if (ioctl(socket, SIOCGIFSTATS, &request, sizeof(struct ifreq)) < 0) {
snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "pcap_stats: %s",
strerror(errno));
close(socket);
return -1;
}
close(socket);
handlep->stat.ps_recv += request.ifr_stats.receive.packets;
handlep->stat.ps_drop += request.ifr_stats.receive.dropped;
*stats = handlep->stat;
return 0;
}
static int
pcap_activate_haiku(pcap_t *handle)
{
struct pcap_haiku* handlep = (struct pcap_haiku*)handle->priv;
const char* device = handle->opt.device;
handle->read_op = pcap_read_haiku;
handle->setfilter_op = install_bpf_program; /* no kernel filtering */
handle->inject_op = pcap_inject_haiku;
handle->stats_op = pcap_stats_haiku;
// use default hooks where possible
handle->getnonblock_op = pcap_getnonblock_fd;
handle->setnonblock_op = pcap_setnonblock_fd;
/*
* Turn a negative snapshot value (invalid), a snapshot value of
* 0 (unspecified), or a value bigger than the normal maximum
* value, into the maximum allowed value.
*
* If some application really *needs* a bigger snapshot
* length, we should just increase MAXIMUM_SNAPLEN.
*/
if (handle->snapshot <= 0 || handle->snapshot > MAXIMUM_SNAPLEN)
handle->snapshot = MAXIMUM_SNAPLEN;
handlep->device = strdup(device);
if (handlep->device == NULL) {
pcap_fmt_errmsg_for_errno(handle->errbuf, PCAP_ERRBUF_SIZE,
errno, "strdup");
return PCAP_ERROR;
}
handle->bufsize = 65536;
// TODO: should be determined by interface MTU
// allocate buffer for monitoring the device
handle->buffer = (u_char*)malloc(handle->bufsize);
if (handle->buffer == NULL) {
pcap_fmt_errmsg_for_errno(handle->errbuf, PCAP_ERRBUF_SIZE,
errno, "buffer malloc");
return PCAP_ERROR;
}
handle->offset = 0;
handle->linktype = DLT_EN10MB;
// TODO: check interface type!
return 0;
}
// #pragma mark - pcap API
extern "C" pcap_t *
pcap_create_interface(const char *device, char *errorBuffer)
{
// TODO: handle promiscuous mode!
// we need a socket to talk to the networking stack
int socket = ::socket(AF_INET, SOCK_DGRAM, 0);
if (socket < 0) {
snprintf(errorBuffer, PCAP_ERRBUF_SIZE,
"The networking stack doesn't seem to be available.\n");
return NULL;
}
struct ifreq request;
if (!prepare_request(request, device)) {
snprintf(errorBuffer, PCAP_ERRBUF_SIZE,
"Interface name \"%s\" is too long.", device);
close(socket);
return NULL;
}
// check if the interface exist
if (ioctl(socket, SIOCGIFINDEX, &request, sizeof(request)) < 0) {
snprintf(errorBuffer, PCAP_ERRBUF_SIZE,
"Interface \"%s\" does not exist.\n", device);
close(socket);
return NULL;
}
close(socket);
// no longer needed after this point
// get link level interface for this interface
socket = ::socket(AF_LINK, SOCK_DGRAM, 0);
if (socket < 0) {
snprintf(errorBuffer, PCAP_ERRBUF_SIZE, "No link level: %s\n",
strerror(errno));
return NULL;
}
// start monitoring
if (ioctl(socket, SIOCSPACKETCAP, &request, sizeof(struct ifreq)) < 0) {
snprintf(errorBuffer, PCAP_ERRBUF_SIZE, "Cannot start monitoring: %s\n",
strerror(errno));
close(socket);
return NULL;
}
struct wrapper_struct { pcap_t __common; struct pcap_haiku __private; };
pcap_t* handle = pcap_create_common(errorBuffer,
sizeof (struct wrapper_struct),
offsetof (struct wrapper_struct, __private));
if (handle == NULL) {
snprintf(errorBuffer, PCAP_ERRBUF_SIZE, "malloc: %s", strerror(errno));
close(socket);
return NULL;
}
handle->selectable_fd = socket;
handle->fd = socket;
handle->activate_op = pcap_activate_haiku;
return handle;
}
static int
can_be_bound(const char *name _U_)
{
return 1;
}
static int
get_if_flags(const char *name, bpf_u_int32 *flags, char *errbuf)
{
/* TODO */
if (*flags & PCAP_IF_LOOPBACK) {
/*
* Loopback devices aren't wireless, and "connected"/
* "disconnected" doesn't apply to them.
*/
*flags |= PCAP_IF_CONNECTION_STATUS_NOT_APPLICABLE;
return (0);
}
return (0);
}
extern "C" int
pcap_platform_finddevs(pcap_if_list_t* _allDevices, char* errorBuffer)
{
return pcap_findalldevs_interfaces(_allDevices, errorBuffer, can_be_bound,
get_if_flags);
}
/*
* Libpcap version string.
*/
extern "C" const char *
pcap_lib_version(void)
{
return (PCAP_VERSION_STRING);
}

View File

@ -0,0 +1,130 @@
/*
* Copyright (c) 1993, 1994, 1995, 1996, 1997
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that: (1) source code distributions
* retain the above copyright notice and this paragraph in its entirety, (2)
* distributions including binary code include the above copyright notice and
* this paragraph in its entirety in the documentation or other materials
* provided with the distribution, and (3) all advertising materials mentioning
* features or use of this software display the following acknowledgement:
* ``This product includes software developed by the University of California,
* Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
* the University nor the names of its contributors may be used to endorse
* or promote products derived from this software without specific prior
* written permission.
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* pcap-usb-linux-common.c - common code for everything that needs to
* deal with Linux USB captures.
*/
#include "pcap/pcap.h"
#include "pcap/usb.h"
#include "pcap-usb-linux-common.h"
/*
* Compute, from the data provided by the Linux USB memory-mapped capture
* mechanism, the amount of packet data that would have been provided
* had the capture mechanism not chopped off any data at the end, if, in
* fact, it did so.
*
* Set the "unsliced length" field of the packet header to that value.
*/
void
fix_linux_usb_mmapped_length(struct pcap_pkthdr *pkth, const u_char *bp)
{
const pcap_usb_header_mmapped *hdr;
u_int bytes_left;
/*
* All callers of this routine must ensure that pkth->caplen is
* >= sizeof (pcap_usb_header_mmapped).
*/
bytes_left = pkth->caplen;
bytes_left -= sizeof (pcap_usb_header_mmapped);
hdr = (const pcap_usb_header_mmapped *) bp;
if (!hdr->data_flag && hdr->transfer_type == URB_ISOCHRONOUS &&
hdr->event_type == URB_COMPLETE &&
(hdr->endpoint_number & URB_TRANSFER_IN) &&
pkth->len == sizeof(pcap_usb_header_mmapped) +
(hdr->ndesc * sizeof (usb_isodesc)) + hdr->urb_len) {
usb_isodesc *descs;
u_int pre_truncation_data_len, pre_truncation_len;
descs = (usb_isodesc *) (bp + sizeof(pcap_usb_header_mmapped));
/*
* We have data (yes, data_flag is 0 if we *do* have data),
* and this is a "this is complete" incoming isochronous
* transfer event, and the length was calculated based
* on the URB length.
*
* That's not correct, because the data isn't contiguous,
* and the isochronous descriptos show how it's scattered.
*
* Find the end of the last chunk of data in the buffer
* referred to by the isochronous descriptors; that indicates
* how far into the buffer the data would have gone.
*
* Make sure we don't run past the end of the captured data
* while processing the isochronous descriptors.
*/
pre_truncation_data_len = 0;
for (uint32_t desc = 0;
desc < hdr->ndesc && bytes_left >= sizeof (usb_isodesc);
desc++, bytes_left -= sizeof (usb_isodesc)) {
u_int desc_end;
if (descs[desc].len != 0) {
desc_end = descs[desc].offset + descs[desc].len;
if (desc_end > pre_truncation_data_len)
pre_truncation_data_len = desc_end;
}
}
/*
* Now calculate the total length based on that data
* length.
*/
pre_truncation_len = sizeof(pcap_usb_header_mmapped) +
(hdr->ndesc * sizeof (usb_isodesc)) +
pre_truncation_data_len;
/*
* If that's greater than or equal to the captured length,
* use that as the length.
*/
if (pre_truncation_len >= pkth->caplen)
pkth->len = pre_truncation_len;
/*
* If the captured length is greater than the length,
* use the captured length.
*
* For completion events for incoming isochronous transfers,
* it's based on data_len, which is calculated the same way
* we calculated pre_truncation_data_len above, except that
* it has access to all the isochronous descriptors, not
* just the ones that the kernel were able to provide us or,
* for a capture file, that weren't sliced off by a snapshot
* length.
*
* However, it might have been reduced by the USB capture
* mechanism arbitrarily limiting the amount of data it
* provides to userland, or by the libpcap capture code
* limiting it to being no more than the snapshot, so
* we don't want to just use it all the time; we only
* do so to try to get a better estimate of the actual
* length - and to make sure the on-the-network length
* is always >= the captured length.
*/
if (pkth->caplen > pkth->len)
pkth->len = pkth->caplen;
}
}

View File

@ -0,0 +1,26 @@
/*
* Copyright (c) 1993, 1994, 1995, 1996, 1997
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that: (1) source code distributions
* retain the above copyright notice and this paragraph in its entirety, (2)
* distributions including binary code include the above copyright notice and
* this paragraph in its entirety in the documentation or other materials
* provided with the distribution, and (3) all advertising materials mentioning
* features or use of this software display the following acknowledgement:
* ``This product includes software developed by the University of California,
* Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
* the University nor the names of its contributors may be used to endorse
* or promote products derived from this software without specific prior
* written permission.
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* pcap-usb-linux-common.h - common code for everything that needs to
* deal with Linux USB captures.
*/
extern void fix_linux_usb_mmapped_length(struct pcap_pkthdr *pkth,
const u_char *bp);

474
contrib/libpcap/pcap-util.c Normal file
View File

@ -0,0 +1,474 @@
/*
* Copyright (c) 1993, 1994, 1995, 1996, 1997
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that: (1) source code distributions
* retain the above copyright notice and this paragraph in its entirety, (2)
* distributions including binary code include the above copyright notice and
* this paragraph in its entirety in the documentation or other materials
* provided with the distribution, and (3) all advertising materials mentioning
* features or use of this software display the following acknowledgement:
* ``This product includes software developed by the University of California,
* Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
* the University nor the names of its contributors may be used to endorse
* or promote products derived from this software without specific prior
* written permission.
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* pcap-common.c - common code for pcap and pcapng files
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <pcap-types.h>
#include "pcap-int.h"
#include "extract.h"
#include "pcap-usb-linux-common.h"
#include "pcap-util.h"
#include "pflog.h"
#include "pcap/can_socketcan.h"
#include "pcap/sll.h"
#include "pcap/usb.h"
#include "pcap/nflog.h"
/*
* Most versions of the DLT_PFLOG pseudo-header have UID and PID fields
* that are saved in host byte order.
*
* When reading a DLT_PFLOG packet, we need to convert those fields from
* the byte order of the host that wrote the file to this host's byte
* order.
*/
static void
swap_pflog_header(const struct pcap_pkthdr *hdr, u_char *buf)
{
u_int caplen = hdr->caplen;
u_int length = hdr->len;
u_int pfloghdr_length;
struct pfloghdr *pflhdr = (struct pfloghdr *)buf;
if (caplen < (u_int) (offsetof(struct pfloghdr, uid) + sizeof pflhdr->uid) ||
length < (u_int) (offsetof(struct pfloghdr, uid) + sizeof pflhdr->uid)) {
/* Not enough data to have the uid field */
return;
}
pfloghdr_length = pflhdr->length;
if (pfloghdr_length < (u_int) (offsetof(struct pfloghdr, uid) + sizeof pflhdr->uid)) {
/* Header doesn't include uid field */
return;
}
pflhdr->uid = SWAPLONG(pflhdr->uid);
if (caplen < (u_int) (offsetof(struct pfloghdr, pid) + sizeof pflhdr->pid) ||
length < (u_int) (offsetof(struct pfloghdr, pid) + sizeof pflhdr->pid)) {
/* Not enough data to have the pid field */
return;
}
if (pfloghdr_length < (u_int) (offsetof(struct pfloghdr, pid) + sizeof pflhdr->pid)) {
/* Header doesn't include pid field */
return;
}
pflhdr->pid = SWAPLONG(pflhdr->pid);
if (caplen < (u_int) (offsetof(struct pfloghdr, rule_uid) + sizeof pflhdr->rule_uid) ||
length < (u_int) (offsetof(struct pfloghdr, rule_uid) + sizeof pflhdr->rule_uid)) {
/* Not enough data to have the rule_uid field */
return;
}
if (pfloghdr_length < (u_int) (offsetof(struct pfloghdr, rule_uid) + sizeof pflhdr->rule_uid)) {
/* Header doesn't include rule_uid field */
return;
}
pflhdr->rule_uid = SWAPLONG(pflhdr->rule_uid);
if (caplen < (u_int) (offsetof(struct pfloghdr, rule_pid) + sizeof pflhdr->rule_pid) ||
length < (u_int) (offsetof(struct pfloghdr, rule_pid) + sizeof pflhdr->rule_pid)) {
/* Not enough data to have the rule_pid field */
return;
}
if (pfloghdr_length < (u_int) (offsetof(struct pfloghdr, rule_pid) + sizeof pflhdr->rule_pid)) {
/* Header doesn't include rule_pid field */
return;
}
pflhdr->rule_pid = SWAPLONG(pflhdr->rule_pid);
}
/*
* DLT_LINUX_SLL packets with a protocol type of LINUX_SLL_P_CAN or
* LINUX_SLL_P_CANFD have SocketCAN headers in front of the payload,
* with the CAN ID being in host byte order.
*
* When reading a DLT_LINUX_SLL packet, we need to check for those
* packets and convert the CAN ID from the byte order of the host that
* wrote the file to this host's byte order.
*/
static void
swap_linux_sll_header(const struct pcap_pkthdr *hdr, u_char *buf)
{
u_int caplen = hdr->caplen;
u_int length = hdr->len;
struct sll_header *shdr = (struct sll_header *)buf;
uint16_t protocol;
pcap_can_socketcan_hdr *chdr;
if (caplen < (u_int) sizeof(struct sll_header) ||
length < (u_int) sizeof(struct sll_header)) {
/* Not enough data to have the protocol field */
return;
}
protocol = EXTRACT_BE_U_2(&shdr->sll_protocol);
if (protocol != LINUX_SLL_P_CAN && protocol != LINUX_SLL_P_CANFD)
return;
/*
* SocketCAN packet; fix up the packet's header.
*/
chdr = (pcap_can_socketcan_hdr *)(buf + sizeof(struct sll_header));
if (caplen < (u_int) sizeof(struct sll_header) + sizeof(chdr->can_id) ||
length < (u_int) sizeof(struct sll_header) + sizeof(chdr->can_id)) {
/* Not enough data to have the CAN ID */
return;
}
chdr->can_id = SWAPLONG(chdr->can_id);
}
/*
* The same applies for DLT_LINUX_SLL2.
*/
static void
swap_linux_sll2_header(const struct pcap_pkthdr *hdr, u_char *buf)
{
u_int caplen = hdr->caplen;
u_int length = hdr->len;
struct sll2_header *shdr = (struct sll2_header *)buf;
uint16_t protocol;
pcap_can_socketcan_hdr *chdr;
if (caplen < (u_int) sizeof(struct sll2_header) ||
length < (u_int) sizeof(struct sll2_header)) {
/* Not enough data to have the protocol field */
return;
}
protocol = EXTRACT_BE_U_2(&shdr->sll2_protocol);
if (protocol != LINUX_SLL_P_CAN && protocol != LINUX_SLL_P_CANFD)
return;
/*
* SocketCAN packet; fix up the packet's header.
*/
chdr = (pcap_can_socketcan_hdr *)(buf + sizeof(struct sll2_header));
if (caplen < (u_int) sizeof(struct sll2_header) + sizeof(chdr->can_id) ||
length < (u_int) sizeof(struct sll2_header) + sizeof(chdr->can_id)) {
/* Not enough data to have the CAN ID */
return;
}
chdr->can_id = SWAPLONG(chdr->can_id);
}
/*
* The DLT_USB_LINUX and DLT_USB_LINUX_MMAPPED headers are in host
* byte order when capturing (it's supplied directly from a
* memory-mapped buffer shared by the kernel).
*
* When reading a DLT_USB_LINUX or DLT_USB_LINUX_MMAPPED packet, we
* need to convert it from the byte order of the host that wrote the
* file to this host's byte order.
*/
static void
swap_linux_usb_header(const struct pcap_pkthdr *hdr, u_char *buf,
int header_len_64_bytes)
{
pcap_usb_header_mmapped *uhdr = (pcap_usb_header_mmapped *)buf;
bpf_u_int32 offset = 0;
/*
* "offset" is the offset *past* the field we're swapping;
* we skip the field *before* checking to make sure
* the captured data length includes the entire field.
*/
/*
* The URB id is a totally opaque value; do we really need to
* convert it to the reading host's byte order???
*/
offset += 8; /* skip past id */
if (hdr->caplen < offset)
return;
uhdr->id = SWAPLL(uhdr->id);
offset += 4; /* skip past various 1-byte fields */
offset += 2; /* skip past bus_id */
if (hdr->caplen < offset)
return;
uhdr->bus_id = SWAPSHORT(uhdr->bus_id);
offset += 2; /* skip past various 1-byte fields */
offset += 8; /* skip past ts_sec */
if (hdr->caplen < offset)
return;
uhdr->ts_sec = SWAPLL(uhdr->ts_sec);
offset += 4; /* skip past ts_usec */
if (hdr->caplen < offset)
return;
uhdr->ts_usec = SWAPLONG(uhdr->ts_usec);
offset += 4; /* skip past status */
if (hdr->caplen < offset)
return;
uhdr->status = SWAPLONG(uhdr->status);
offset += 4; /* skip past urb_len */
if (hdr->caplen < offset)
return;
uhdr->urb_len = SWAPLONG(uhdr->urb_len);
offset += 4; /* skip past data_len */
if (hdr->caplen < offset)
return;
uhdr->data_len = SWAPLONG(uhdr->data_len);
if (uhdr->transfer_type == URB_ISOCHRONOUS) {
offset += 4; /* skip past s.iso.error_count */
if (hdr->caplen < offset)
return;
uhdr->s.iso.error_count = SWAPLONG(uhdr->s.iso.error_count);
offset += 4; /* skip past s.iso.numdesc */
if (hdr->caplen < offset)
return;
uhdr->s.iso.numdesc = SWAPLONG(uhdr->s.iso.numdesc);
} else
offset += 8; /* skip USB setup header */
/*
* With the old header, there are no isochronous descriptors
* after the header.
*
* With the new header, the actual number of descriptors in
* the header is not s.iso.numdesc, it's ndesc - only the
* first N descriptors, for some value of N, are put into
* the header, and ndesc is set to the actual number copied.
* In addition, if s.iso.numdesc is negative, no descriptors
* are captured, and ndesc is set to 0.
*/
if (header_len_64_bytes) {
/*
* This is either the "version 1" header, with
* 16 bytes of additional fields at the end, or
* a "version 0" header from a memory-mapped
* capture, with 16 bytes of zeroed-out padding
* at the end. Byte swap them as if this were
* a "version 1" header.
*/
offset += 4; /* skip past interval */
if (hdr->caplen < offset)
return;
uhdr->interval = SWAPLONG(uhdr->interval);
offset += 4; /* skip past start_frame */
if (hdr->caplen < offset)
return;
uhdr->start_frame = SWAPLONG(uhdr->start_frame);
offset += 4; /* skip past xfer_flags */
if (hdr->caplen < offset)
return;
uhdr->xfer_flags = SWAPLONG(uhdr->xfer_flags);
offset += 4; /* skip past ndesc */
if (hdr->caplen < offset)
return;
uhdr->ndesc = SWAPLONG(uhdr->ndesc);
if (uhdr->transfer_type == URB_ISOCHRONOUS) {
/* swap the values in struct linux_usb_isodesc */
usb_isodesc *pisodesc;
uint32_t i;
pisodesc = (usb_isodesc *)(void *)(buf+offset);
for (i = 0; i < uhdr->ndesc; i++) {
offset += 4; /* skip past status */
if (hdr->caplen < offset)
return;
pisodesc->status = SWAPLONG(pisodesc->status);
offset += 4; /* skip past offset */
if (hdr->caplen < offset)
return;
pisodesc->offset = SWAPLONG(pisodesc->offset);
offset += 4; /* skip past len */
if (hdr->caplen < offset)
return;
pisodesc->len = SWAPLONG(pisodesc->len);
offset += 4; /* skip past padding */
pisodesc++;
}
}
}
}
/*
* The DLT_NFLOG "packets" have a mixture of big-endian and host-byte-order
* data. They begin with a fixed-length header with big-endian fields,
* followed by a set of TLVs, where the type and length are in host
* byte order but the values are either big-endian or are a raw byte
* sequence that's the same regardless of the host's byte order.
*
* When reading a DLT_NFLOG packet, we need to convert the type and
* length values from the byte order of the host that wrote the file
* to the byte order of this host.
*/
static void
swap_nflog_header(const struct pcap_pkthdr *hdr, u_char *buf)
{
u_char *p = buf;
nflog_hdr_t *nfhdr = (nflog_hdr_t *)buf;
nflog_tlv_t *tlv;
u_int caplen = hdr->caplen;
u_int length = hdr->len;
uint16_t size;
if (caplen < (u_int) sizeof(nflog_hdr_t) ||
length < (u_int) sizeof(nflog_hdr_t)) {
/* Not enough data to have any TLVs. */
return;
}
if (nfhdr->nflog_version != 0) {
/* Unknown NFLOG version */
return;
}
length -= sizeof(nflog_hdr_t);
caplen -= sizeof(nflog_hdr_t);
p += sizeof(nflog_hdr_t);
while (caplen >= sizeof(nflog_tlv_t)) {
tlv = (nflog_tlv_t *) p;
/* Swap the type and length. */
tlv->tlv_type = SWAPSHORT(tlv->tlv_type);
tlv->tlv_length = SWAPSHORT(tlv->tlv_length);
/* Get the length of the TLV. */
size = tlv->tlv_length;
if (size % 4 != 0)
size += 4 - size % 4;
/* Is the TLV's length less than the minimum? */
if (size < sizeof(nflog_tlv_t)) {
/* Yes. Give up now. */
return;
}
/* Do we have enough data for the full TLV? */
if (caplen < size || length < size) {
/* No. */
return;
}
/* Skip over the TLV. */
length -= size;
caplen -= size;
p += size;
}
}
static void
swap_pseudo_headers(int linktype, struct pcap_pkthdr *hdr, u_char *data)
{
/*
* Convert pseudo-headers from the byte order of
* the host on which the file was saved to our
* byte order, as necessary.
*/
switch (linktype) {
case DLT_PFLOG:
swap_pflog_header(hdr, data);
break;
case DLT_LINUX_SLL:
swap_linux_sll_header(hdr, data);
break;
case DLT_LINUX_SLL2:
swap_linux_sll2_header(hdr, data);
break;
case DLT_USB_LINUX:
swap_linux_usb_header(hdr, data, 0);
break;
case DLT_USB_LINUX_MMAPPED:
swap_linux_usb_header(hdr, data, 1);
break;
case DLT_NFLOG:
swap_nflog_header(hdr, data);
break;
}
}
void
pcap_post_process(int linktype, int swapped, struct pcap_pkthdr *hdr,
u_char *data)
{
if (swapped)
swap_pseudo_headers(linktype, hdr, data);
fixup_pcap_pkthdr(linktype, hdr, data);
}
void
fixup_pcap_pkthdr(int linktype, struct pcap_pkthdr *hdr, const u_char *data)
{
const pcap_usb_header_mmapped *usb_hdr;
usb_hdr = (const pcap_usb_header_mmapped *) data;
if (linktype == DLT_USB_LINUX_MMAPPED &&
hdr->caplen >= sizeof (pcap_usb_header_mmapped)) {
/*
* In older versions of libpcap, in memory-mapped captures,
* the "on-the-bus length" for completion events for
* incoming isochronous transfers was miscalculated; it
* needed to be calculated based on the* offsets and lengths
* in the descriptors, not on the raw URB length, but it
* wasn't.
*
* If this packet contains transferred data (yes, data_flag
* is 0 if we *do* have data), and the total on-the-network
* length is equal to the value calculated from the raw URB
* length, then it might be one of those transfers.
*
* We only do this if we have the full USB pseudo-header.
*/
if (!usb_hdr->data_flag &&
hdr->len == sizeof(pcap_usb_header_mmapped) +
(usb_hdr->ndesc * sizeof (usb_isodesc)) + usb_hdr->urb_len) {
/*
* It might need fixing; fix it if it's a completion
* event for an incoming isochronous transfer.
*/
fix_linux_usb_mmapped_length(hdr, data);
}
}
}

View File

@ -0,0 +1,55 @@
/*
* Copyright (c) 1993, 1994, 1995, 1996, 1997
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that: (1) source code distributions
* retain the above copyright notice and this paragraph in its entirety, (2)
* distributions including binary code include the above copyright notice and
* this paragraph in its entirety in the documentation or other materials
* provided with the distribution, and (3) all advertising materials mentioning
* features or use of this software display the following acknowledgement:
* ``This product includes software developed by the University of California,
* Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
* the University nor the names of its contributors may be used to endorse
* or promote products derived from this software without specific prior
* written permission.
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* pcap-util.h - common code for various files
*/
/*
* We use the "receiver-makes-right" approach to byte order;
* because time is at a premium when we are writing the file.
* In other words, the pcap_file_header and pcap_pkthdr,
* records are written in host byte order.
* Note that the bytes of packet data are written out in the order in
* which they were received, so multi-byte fields in packets are not
* written in host byte order, they're written in whatever order the
* sending machine put them in.
*
* We also use this for fixing up packet data headers from a remote
* capture, where the server may have a different byte order from the
* client.
*
* ntoh[ls] aren't sufficient because we might need to swap on a big-endian
* machine (if the file was written in little-end order).
*/
#define SWAPLONG(y) \
(((((u_int)(y))&0xff)<<24) | \
((((u_int)(y))&0xff00)<<8) | \
((((u_int)(y))&0xff0000)>>8) | \
((((u_int)(y))>>24)&0xff))
#define SWAPSHORT(y) \
((u_short)(((((u_int)(y))&0xff)<<8) | \
((((u_int)(y))&0xff00)>>8)))
extern void pcap_post_process(int linktype, int swapped,
struct pcap_pkthdr *hdr, u_char *data);
extern void fixup_pcap_pkthdr(int linktype, struct pcap_pkthdr *hdr,
const u_char *data);

View File

@ -80,7 +80,9 @@
#define lib_pcap_bpf_h
#include <pcap/funcattrs.h>
#if defined(__FreeBSD__)
#include <pcap/dlt.h>
#endif
#ifdef __cplusplus
extern "C" {
@ -282,6 +284,9 @@ struct bpf_insn {
PCAP_AVAILABLE_0_4
PCAP_API u_int bpf_filter(const struct bpf_insn *, const u_char *, u_int, u_int);
PCAP_AVAILABLE_0_4
PCAP_API u_int bpf_filter(const struct bpf_insn *, const u_char *, u_int, u_int);
PCAP_AVAILABLE_0_6
PCAP_API int bpf_validate(const struct bpf_insn *f, int len);

View File

@ -0,0 +1,99 @@
.\" Copyright (c) 1994, 1996, 1997
.\" The Regents of the University of California. All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that: (1) source code distributions
.\" retain the above copyright notice and this paragraph in its entirety, (2)
.\" distributions including binary code include the above copyright notice and
.\" this paragraph in its entirety in the documentation or other materials
.\" provided with the distribution, and (3) all advertising materials mentioning
.\" features or use of this software display the following acknowledgement:
.\" ``This product includes software developed by the University of California,
.\" Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
.\" the University nor the names of its contributors may be used to endorse
.\" or promote products derived from this software without specific prior
.\" written permission.
.\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
.\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
.\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
.\"
.TH PCAP_INIT 3PCAP "4 May 2022"
.SH NAME
pcap_init \- initialize the library
.SH SYNOPSIS
.nf
.ft B
#include <pcap/pcap.h>
.ft
.LP
.nf
.ft B
char errbuf[PCAP_ERRBUF_SIZE];
.ft
.LP
.ft B
int pcap_init(unsigned int opts, char *errbuf);
.ft
.fi
.SH DESCRIPTION
.BR pcap_init ()
is used to initialize the Packet Capture library.
.I opts
specifies options for the library;
currently, the options are:
.TP
.B PCAP_CHAR_ENC_LOCAL
Treat all strings supplied as arguments, and return all strings to the
caller, as being in the local character encoding.
.TP
.B PCAP_CHAR_ENC_UTF_8
Treat all strings supplied as arguments, and return all strings to the
caller, as being in UTF-8.
.PP
On UNIX-like systems, the local character encoding is assumed to be
UTF-8, so no character encoding transformations are done.
.PP
On Windows, the local character encoding is the local ANSI code page.
.PP
If
.BR pcap_init ()
is not called, strings are treated as being in the local ANSI code page
on Windows,
.BR pcap_lookupdev (3PCAP)
will succeed if there is a device on which to capture, and
.BR pcap_create (3PCAP)
makes an attempt to check whether the string passed as an argument is a
UTF-16LE string - note that this attempt is unsafe, as it may run past
the end of the string - to handle
.BR pcap_lookupdev ()
returning a UTF-16LE string. Programs that don't call
.BR pcap_init ()
should, on Windows, call
.BR pcap_wsockinit ()
to initialize Winsock; this is not necessary if
.BR pcap_init ()
is called, as
.BR pcap_init ()
will initialize Winsock itself on Windows.
.SH RETURN VALUE
.BR pcap_init ()
returns
.B 0
on success and
.B PCAP_ERROR
on failure.
If
.B PCAP_ERROR
is returned,
.I errbuf
is filled in with an appropriate error message.
.I errbuf
is assumed to be able to hold at least
.B PCAP_ERRBUF_SIZE
chars.
.SH BACKWARD COMPATIBILITY
This function became available in libpcap release 1.9.0. In previous
releases, on Windows, all strings supplied as arguments, and all strings
returned to the caller, are in the local character encoding.
.SH SEE ALSO
.BR pcap (3PCAP)

157
contrib/libpcap/pflog.h Normal file
View File

@ -0,0 +1,157 @@
/*
* Copyright (c) 1982, 1986, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/*
* pflog headers, at least as they exist now.
*/
#define PFLOG_IFNAMSIZ 16
#define PFLOG_RULESET_NAME_SIZE 16
/*
* Direction values.
*/
#define PF_INOUT 0
#define PF_IN 1
#define PF_OUT 2
#if defined(__OpenBSD__)
#define PF_FWD 3
#endif
/*
* Reason values.
*/
#define PFRES_MATCH 0
#define PFRES_BADOFF 1
#define PFRES_FRAG 2
#define PFRES_SHORT 3
#define PFRES_NORM 4
#define PFRES_MEMORY 5
#define PFRES_TS 6
#define PFRES_CONGEST 7
#define PFRES_IPOPTIONS 8
#define PFRES_PROTCKSUM 9
#define PFRES_BADSTATE 10
#define PFRES_STATEINS 11
#define PFRES_MAXSTATES 12
#define PFRES_SRCLIMIT 13
#define PFRES_SYNPROXY 14
#if defined(__FreeBSD__)
#define PFRES_MAPFAILED 15
#elif defined(__NetBSD__)
#define PFRES_STATELOCKED 15
#elif defined(__OpenBSD__)
#define PFRES_TRANSLATE 15
#define PFRES_NOROUTE 16
#elif defined(__APPLE__)
#define PFRES_DUMMYNET 15
#endif
/*
* Action values.
*/
#define PF_PASS 0
#define PF_DROP 1
#define PF_SCRUB 2
#define PF_NOSCRUB 3
#define PF_NAT 4
#define PF_NONAT 5
#define PF_BINAT 6
#define PF_NOBINAT 7
#define PF_RDR 8
#define PF_NORDR 9
#define PF_SYNPROXY_DROP 10
#if defined(__FreeBSD__)
#define PF_DEFER 11
#elif defined(__OpenBSD__)
#define PF_DEFER 11
#define PF_MATCH 12
#define PF_DIVERT 13
#define PF_RT 14
#define PF_AFRT 15
#elif defined(__APPLE__)
#define PF_DUMMYNET 11
#define PF_NODUMMYNET 12
#define PF_NAT64 13
#define PF_NONAT64 14
#endif
struct pf_addr {
union {
struct in_addr v4;
struct in6_addr v6;
uint8_t addr8[16];
uint16_t addr16[8];
uint32_t addr32[4];
} pfa; /* 128-bit address */
#define v4 pfa.v4
#define v6 pfa.v6
#define addr8 pfa.addr8
#define addr16 pfa.addr16
#define addr32 pfa.addr32
};
struct pfloghdr {
uint8_t length;
uint8_t af;
uint8_t action;
uint8_t reason;
char ifname[PFLOG_IFNAMSIZ];
char ruleset[PFLOG_RULESET_NAME_SIZE];
uint32_t rulenr;
uint32_t subrulenr;
uint32_t uid;
int32_t pid;
uint32_t rule_uid;
int32_t rule_pid;
uint8_t dir;
#if defined(__OpenBSD__)
uint8_t rewritten;
uint8_t naf;
uint8_t pad[1];
#else
uint8_t pad[3];
#endif
#if defined(__FreeBSD__)
uint32_t ridentifier;
uint8_t reserve;
uint8_t pad2[3];
#elif defined(__OpenBSD__)
struct pf_addr saddr;
struct pf_addr daddr;
uint16_t sport;
uint16_t dport;
#endif
};

239
contrib/libpcap/sslutils.c Normal file
View File

@ -0,0 +1,239 @@
/*
* Copyright (c) 2002 - 2003
* NetGroup, Politecnico di Torino (Italy)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the Politecnico di Torino nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#ifdef HAVE_OPENSSL
#include <stdlib.h>
#include "portability.h"
#include "sslutils.h"
static const char *ssl_keyfile = ""; //!< file containing the private key in PEM format
static const char *ssl_certfile = ""; //!< file containing the server's certificate in PEM format
static const char *ssl_rootfile = ""; //!< file containing the list of CAs trusted by the client
// TODO: a way to set ssl_rootfile from the command line, or an envvar?
// TODO: lock?
static SSL_CTX *ctx;
void ssl_set_certfile(const char *certfile)
{
ssl_certfile = certfile;
}
void ssl_set_keyfile(const char *keyfile)
{
ssl_keyfile = keyfile;
}
int ssl_init_once(int is_server, int enable_compression, char *errbuf, size_t errbuflen)
{
static int inited = 0;
if (inited) return 0;
SSL_library_init();
SSL_load_error_strings();
OpenSSL_add_ssl_algorithms();
if (enable_compression)
SSL_COMP_get_compression_methods();
SSL_METHOD const *meth =
is_server ? SSLv23_server_method() : SSLv23_client_method();
ctx = SSL_CTX_new(meth);
if (! ctx)
{
snprintf(errbuf, errbuflen, "Cannot get a new SSL context: %s", ERR_error_string(ERR_get_error(), NULL));
goto die;
}
SSL_CTX_set_mode(ctx, SSL_MODE_AUTO_RETRY);
if (is_server)
{
char const *certfile = ssl_certfile[0] ? ssl_certfile : "cert.pem";
if (1 != SSL_CTX_use_certificate_file(ctx, certfile, SSL_FILETYPE_PEM))
{
snprintf(errbuf, errbuflen, "Cannot read certificate file %s: %s", certfile, ERR_error_string(ERR_get_error(), NULL));
goto die;
}
char const *keyfile = ssl_keyfile[0] ? ssl_keyfile : "key.pem";
if (1 != SSL_CTX_use_PrivateKey_file(ctx, keyfile, SSL_FILETYPE_PEM))
{
snprintf(errbuf, errbuflen, "Cannot read private key file %s: %s", keyfile, ERR_error_string(ERR_get_error(), NULL));
goto die;
}
}
else
{
if (ssl_rootfile[0])
{
if (! SSL_CTX_load_verify_locations(ctx, ssl_rootfile, 0))
{
snprintf(errbuf, errbuflen, "Cannot read CA list from %s", ssl_rootfile);
goto die;
}
}
else
{
SSL_CTX_set_verify(ctx, SSL_VERIFY_NONE, NULL);
}
}
#if 0
if (! RAND_load_file(RANDOM, 1024*1024))
{
snprintf(errbuf, errbuflen, "Cannot init random");
goto die;
}
if (is_server)
{
SSL_CTX_set_session_id_context(ctx, (void *)&s_server_session_id_context, sizeof(s_server_session_id_context));
}
#endif
inited = 1;
return 0;
die:
return -1;
}
SSL *ssl_promotion(int is_server, SOCKET s, char *errbuf, size_t errbuflen)
{
if (ssl_init_once(is_server, 1, errbuf, errbuflen) < 0) {
return NULL;
}
SSL *ssl = SSL_new(ctx); // TODO: also a DTLS context
SSL_set_fd(ssl, (int)s);
if (is_server) {
if (SSL_accept(ssl) <= 0) {
snprintf(errbuf, errbuflen, "SSL_accept(): %s",
ERR_error_string(ERR_get_error(), NULL));
return NULL;
}
} else {
if (SSL_connect(ssl) <= 0) {
snprintf(errbuf, errbuflen, "SSL_connect(): %s",
ERR_error_string(ERR_get_error(), NULL));
return NULL;
}
}
return ssl;
}
// Finish using an SSL handle; shut down the connection and free the
// handle.
void ssl_finish(SSL *ssl)
{
//
// We won't be using this again, so we can just send the
// shutdown alert and free up the handle, and have our
// caller close the socket.
//
// XXX - presumably, if the connection is shut down on
// our side, either our peer won't have a problem sending
// their shutdown alert or will not treat such a problem
// as an error. If this causes errors to be reported,
// fix that as appropriate.
//
SSL_shutdown(ssl);
SSL_free(ssl);
}
// Same return value as sock_send:
// 0 on OK, -1 on error but closed connection (-2).
int ssl_send(SSL *ssl, char const *buffer, int size, char *errbuf, size_t errbuflen)
{
int status = SSL_write(ssl, buffer, size);
if (status > 0)
{
// "SSL_write() will only return with success, when the complete contents (...) has been written."
return 0;
}
else
{
int ssl_err = SSL_get_error(ssl, status); // TODO: does it pop the error?
if (ssl_err == SSL_ERROR_ZERO_RETURN)
{
return -2;
}
else if (ssl_err == SSL_ERROR_SYSCALL)
{
#ifndef _WIN32
if (errno == ECONNRESET || errno == EPIPE) return -2;
#endif
}
snprintf(errbuf, errbuflen, "SSL_write(): %s",
ERR_error_string(ERR_get_error(), NULL));
return -1;
}
}
// Returns the number of bytes read, or -1 on syserror, or -2 on SSL error.
int ssl_recv(SSL *ssl, char *buffer, int size, char *errbuf, size_t errbuflen)
{
int status = SSL_read(ssl, buffer, size);
if (status <= 0)
{
int ssl_err = SSL_get_error(ssl, status);
if (ssl_err == SSL_ERROR_ZERO_RETURN)
{
return 0;
}
else if (ssl_err == SSL_ERROR_SYSCALL)
{
return -1;
}
else
{
// Should not happen
snprintf(errbuf, errbuflen, "SSL_read(): %s",
ERR_error_string(ERR_get_error(), NULL));
return -2;
}
}
else
{
return status;
}
}
#endif // HAVE_OPENSSL

View File

@ -0,0 +1,66 @@
/*
* Copyright (c) 2002 - 2003
* NetGroup, Politecnico di Torino (Italy)
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the Politecnico di Torino nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
#ifndef __SSLUTILS_H__
#define __SSLUTILS_H__
#ifdef HAVE_OPENSSL
#include "pcap/socket.h" // for SOCKET
#include <openssl/ssl.h>
#include <openssl/err.h>
/*
* Utility functions
*/
void ssl_set_certfile(const char *certfile);
void ssl_set_keyfile(const char *keyfile);
int ssl_init_once(int is_server, int enable_compression, char *errbuf, size_t errbuflen);
SSL *ssl_promotion(int is_server, SOCKET s, char *errbuf, size_t errbuflen);
void ssl_finish(SSL *ssl);
int ssl_send(SSL *, char const *buffer, int size, char *errbuf, size_t errbuflen);
int ssl_recv(SSL *, char *buffer, int size, char *errbuf, size_t errbuflen);
// The SSL parameters are used
#define _U_NOSSL_
#else // HAVE_OPENSSL
// This saves us from a lot of ifdefs:
#define SSL void const
// The SSL parameters are unused
#define _U_NOSSL_ _U_
#endif // HAVE_OPENSSL
#endif // __SSLUTILS_H__

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,47 @@
/*
* \file ete_decoder.h
* \brief OpenCSD : Top level header file for ETE decoder.
*
* \copyright Copyright (c) 2019, ARM Limited. All Rights Reserved.
*/
/*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef ARM_ETE_DECODER_H_INCLUDED
#define ARM_ETE_DECODER_H_INCLUDED
// ETE actually uses extended ETMv4 packet processor and decode
// ETE specifics limited to configuration
//
#include "trc_cmp_cfg_ete.h"
#include "trc_pkt_types_ete.h"
#endif // ARM_ETE_DECODER_H_INCLUDED
/* End of File ete_decoder.h */

View File

@ -0,0 +1,81 @@
/*
* \file trc_cmp_cfg_ete.h
* \brief OpenCSD : ETE configuration
*
* \copyright Copyright (c) 2019, ARM Limited. All Rights Reserved.
*/
/*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef ARM_TRC_CMP_CFG_ETE_H_INCLUDED
#define ARM_TRC_CMP_CFG_ETE_H_INCLUDED
#include "trc_pkt_types_ete.h"
#include "opencsd/etmv4/trc_cmp_cfg_etmv4.h"
/** @addtogroup ocsd_protocol_cfg
@{*/
/** @name ETE configuration
@{*/
/*!
* @class ETEConfig
* @brief Interpreter class for ETE config structure
*
* ETE trace and config are a superset of ETMv4 trace and config - hence
* use the EtmV4Config class as a base.
*/
class ETEConfig : public EtmV4Config
{
public:
ETEConfig();
ETEConfig(const ocsd_ete_cfg *cfg_regs);
~ETEConfig();
//! copy assignment operator for base structure into class.
ETEConfig & operator=(const ocsd_ete_cfg *p_cfg);
//! cast operator returning struct const reference
operator const ocsd_ete_cfg &() const { return m_ete_cfg; };
//! cast operator returning struct const pointer
operator const ocsd_ete_cfg *() const { return &m_ete_cfg; };
private:
void copyV4(); // copy relevent config to underlying structure.
ocsd_ete_cfg m_ete_cfg;
};
/** @}*/
/** @}*/
#endif // ARM_TRC_CMP_CFG_ETE_H_INCLUDED
/* End of File trc_cmp_cfg_ete.h */

View File

@ -0,0 +1,58 @@
/*
* \file trc_dcd_mngr_ete.h
* \brief OpenCSD : ETE decoder creation.
*
* \copyright Copyright (c) 2019, ARM Limited. All Rights Reserved.
*/
/*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef ARM_TRC_DCD_MNGR_ETE_H_INCLUDED
#define ARM_TRC_DCD_MNGR_ETE_H_INCLUDED
#include "common/ocsd_dcd_mngr.h"
#include "trc_cmp_cfg_ete.h"
#include "opencsd/etmv4/trc_pkt_decode_etmv4i.h"
#include "opencsd/etmv4/trc_pkt_proc_etmv4.h"
class DecoderMngrETE : public DecodeMngrFullDcdExCfg< EtmV4ITrcPacket,
ocsd_etmv4_i_pkt_type,
EtmV4Config,
ETEConfig,
ocsd_ete_cfg,
TrcPktProcEtmV4I,
TrcPktDecodeEtmV4I>
{
public:
DecoderMngrETE(const std::string &name) : DecodeMngrFullDcdExCfg(name, OCSD_PROTOCOL_ETE) {};
virtual ~DecoderMngrETE() {};
};
#endif // ARM_TRC_DCD_MNGR_ETE_H_INCLUDED
/* End of File trc_dcd_mngr_ete.h */

View File

@ -0,0 +1,66 @@
/*
* \file trc_pkt_types_ete.h
* \brief OpenCSD : ETE types
*
* \copyright Copyright (c) 2019, ARM Limited. All Rights Reserved.
*/
/*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef ARM_TRC_PKT_TYPES_ETE_H_INCLUDED
#define ARM_TRC_PKT_TYPES_ETE_H_INCLUDED
#include "opencsd/trc_pkt_types.h"
#include "opencsd/etmv4/trc_pkt_types_etmv4.h"
/** @addtogroup trc_pkts
@{*/
/** @name ETE config Types
@{*/
typedef struct _ocsd_ete_cfg
{
uint32_t reg_idr0; /**< ID0 register */
uint32_t reg_idr1; /**< ID1 register */
uint32_t reg_idr2; /**< ID2 register */
uint32_t reg_idr8; /**< ID8 - maxspec */
uint32_t reg_devarch; /**< DevArch register */
uint32_t reg_configr; /**< Config Register */
uint32_t reg_traceidr; /**< Trace Stream ID register */
ocsd_arch_version_t arch_ver; /**< Architecture version */
ocsd_core_profile_t core_prof; /**< Core Profile */
} ocsd_ete_cfg;
/** @}*/
/** @}*/
#endif // ARM_TRC_PKT_TYPES_ETE_H_INCLUDED
/* End of File trc_pkt_types_ete.h */

View File

@ -0,0 +1,98 @@
/*
* \file trc_cmp_cfg_ete.cpp
* \brief OpenCSD : ETE config class
*
* \copyright Copyright (c) 2019, ARM Limited. All Rights Reserved.
*/
/*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "opencsd/ete/trc_cmp_cfg_ete.h"
ETEConfig::ETEConfig() : EtmV4Config()
{
m_ete_cfg.reg_idr0 = 0x28000EA1;
m_ete_cfg.reg_idr1 = 0x4100FFF3;
m_ete_cfg.reg_idr2 = 0x00000488;
m_ete_cfg.reg_idr8 = 0;
m_ete_cfg.reg_configr = 0xC1;
m_ete_cfg.reg_traceidr = 0;
m_ete_cfg.arch_ver = ARCH_AA64;
m_ete_cfg.core_prof = profile_CortexA;
m_ete_cfg.reg_devarch = 0x47705A13;
copyV4();
}
ETEConfig::ETEConfig(const ocsd_ete_cfg *cfg_regs) : EtmV4Config()
{
m_ete_cfg = *cfg_regs;
copyV4();
}
ETEConfig::~ETEConfig()
{
}
//! copy assignment operator for base structure into class.
ETEConfig & ETEConfig::operator=(const ocsd_ete_cfg *p_cfg)
{
m_ete_cfg = *p_cfg;
copyV4();
return *this;
}
//! cast operator returning struct const reference
//operator const ocsd_ete_cfg &() const { return m_ete_cfg; };
//! cast operator returning struct const pointer
//operator const ocsd_ete_cfg *() const { return &m_ete_cfg; };
// ete superset of etmv4 - move info to underlying structure.
void ETEConfig::copyV4()
{
// copy over 1:1 regs
m_cfg.reg_idr0 = m_ete_cfg.reg_idr0;
m_cfg.reg_idr1 = m_ete_cfg.reg_idr1;
m_cfg.reg_idr2 = m_ete_cfg.reg_idr2;
m_cfg.reg_idr8 = m_ete_cfg.reg_idr8;
m_cfg.reg_idr9 = 0;
m_cfg.reg_idr10 = 0;
m_cfg.reg_idr11 = 0;
m_cfg.reg_idr12 = 0;
m_cfg.reg_idr13 = 0;
m_cfg.reg_configr = m_ete_cfg.reg_configr;
m_cfg.reg_traceidr = m_ete_cfg.reg_traceidr;
m_cfg.core_prof = m_ete_cfg.core_prof;
m_cfg.arch_ver = m_ete_cfg.arch_ver;
// override major / minor version as part of devarch
m_MajVer = (uint8_t)((m_ete_cfg.reg_devarch & 0xF000) >> 12);
m_MinVer = (uint8_t)((m_ete_cfg.reg_devarch & 0xF0000) >> 16);
}
/* End of File trc_cmp_cfg_ete.cpp */

View File

@ -18,7 +18,7 @@ To email small changes, please run a POSIX shell command like
'diff -u old/europe new/europe >myfix.patch', and attach
'myfix.patch' to the email.
For more-elaborate or possibly-controversial changes,
For more-elaborate or possibly controversial changes,
such as renaming, adding or removing zones, please read
"Theory and pragmatics of the tz code and data"
<https://www.iana.org/time-zones/repository/theory.html>.

View File

@ -35,22 +35,14 @@ DATAFORM= main
LOCALTIME= Factory
# The POSIXRULES macro controls interpretation of nonstandard and obsolete
# POSIX-like TZ settings like TZ='EET-2EEST' that lack DST transition rules.
# Such a setting uses the rules in a template file to determine
# "spring forward" and "fall back" days and times; the environment
# variable itself specifies UT offsets of standard and daylight saving time.
#
# The POSIXRULES macro controls interpretation of POSIX-like TZ
# settings like TZ='EET-2EEST' that lack DST transition rules.
# If POSIXRULES is '-', no template is installed; this is the default.
#
# Any other value for POSIXRULES is obsolete and should not be relied on, as:
# * It does not work correctly in popular implementations such as GNU/Linux.
# * It does not work even in tzcode, except for historical timestamps
# that precede the last explicit transition in the POSIXRULES file.
# Hence it typically does not work for current and future timestamps.
# In short, software should avoid ruleless settings like TZ='EET-2EEST'
# and so should not depend on the value of POSIXRULES.
#
# If, despite the above, you want a template for handling these settings,
# you can change the line below (after finding the timezone you want in the
# one of the $(TDATA) source files, or adding it to a source file).
@ -63,7 +55,7 @@ LOCALTIME= Factory
POSIXRULES= -
# Also see TZDEFRULESTRING below, which takes effect only
# if the time zone files cannot be accessed.
# if POSIXRULES is '-' or if the template file cannot be accessed.
# Installation locations.
@ -211,7 +203,7 @@ LDLIBS=
# -DHAVE_DECL_ENVIRON if <unistd.h> declares 'environ'
# -DHAVE_DECL_TIMEGM=0 if <time.h> does not declare timegm
# -DHAVE_DIRECT_H if mkdir needs <direct.h> (MS-Windows)
# -DHAVE_GENERIC=0 if _Generic does not work*
# -DHAVE__GENERIC=0 if _Generic does not work*
# -DHAVE_GETRANDOM if getrandom works (e.g., GNU/Linux),
# -DHAVE_GETRANDOM=0 to avoid using getrandom
# -DHAVE_GETTEXT if gettext works (e.g., GNU/Linux, FreeBSD, Solaris),
@ -220,7 +212,7 @@ LDLIBS=
# -DHAVE_INCOMPATIBLE_CTIME_R if your system's time.h declares
# ctime_r and asctime_r incompatibly with the POSIX standard
# (Solaris when _POSIX_PTHREAD_SEMANTICS is not defined).
# -DHAVE_INTTYPES_H=0 if <inttypes.h> does not work*
# -DHAVE_INTTYPES_H=0 if <inttypes.h> does not work*+
# -DHAVE_LINK=0 if your system lacks a link function
# -DHAVE_LOCALTIME_R=0 if your system lacks a localtime_r function
# -DHAVE_LOCALTIME_RZ=0 if you do not want zdump to use localtime_rz
@ -229,22 +221,24 @@ LDLIBS=
# -DHAVE_POSIX_DECLS=0 if your system's include files do not declare
# functions like 'link' or variables like 'tzname' required by POSIX
# -DHAVE_SETENV=0 if your system lacks the setenv function
# -DHAVE_SNPRINTF=0 if your system lacks the snprintf function
# -DHAVE_SNPRINTF=0 if your system lacks the snprintf function+
# -DHAVE_STDCKDINT_H=0 if neither <stdckdint.h> nor substitutes like
# __builtin_add_overflow work*
# -DHAVE_STDINT_H=0 if <stdint.h> does not work*
# -DHAVE_STDINT_H=0 if <stdint.h> does not work*+
# -DHAVE_STRFTIME_L if <time.h> declares locale_t and strftime_l
# -DHAVE_STRDUP=0 if your system lacks the strdup function
# -DHAVE_STRTOLL=0 if your system lacks the strtoll function
# -DHAVE_STRTOLL=0 if your system lacks the strtoll function+
# -DHAVE_SYMLINK=0 if your system lacks the symlink function
# -DHAVE_SYS_STAT_H=0 if <sys/stat.h> does not work*
# -DHAVE_TZSET=0 if your system lacks a tzset function
# -DHAVE_UNISTD_H=0 if <unistd.h> does not work*
# -DHAVE_UTMPX_H=0 if <utmpx.h> does not work*
# -Dlocale_t=XXX if your system uses XXX instead of locale_t
# -DPORT_TO_C89 if tzcode should also run on C89 platforms+
# -DRESERVE_STD_EXT_IDS if your platform reserves standard identifiers
# with external linkage, e.g., applications cannot define 'localtime'.
# -Dssize_t=long on hosts like MS-Windows that lack ssize_t
# -DSUPPORT_C89 if the tzcode library should support C89 callers+
# -DSUPPRESS_TZDIR to not prepend TZDIR to file names; this has
# security implications and is not recommended for general use
# -DTHREAD_SAFE to make localtime.c thread-safe, as POSIX requires;
@ -256,7 +250,13 @@ LDLIBS=
# -DTZ_DOMAINDIR=\"/path\" to use "/path" for gettext directory;
# the default is system-supplied, typically "/usr/lib/locale"
# -DTZDEFRULESTRING=\",date/time,date/time\" to default to the specified
# DST transitions if the time zone files cannot be accessed
# DST transitions for POSIX-style TZ strings lacking them,
# in the usual case where POSIXRULES is '-'. If not specified,
# TZDEFRULESTRING defaults to US rules for future DST transitions.
# This mishandles some past timestamps, as US DST rules have changed.
# It also mishandles settings like TZ='EET-2EEST' for eastern Europe,
# as Europe and US DST rules differ.
# -DTZNAME_MAXIMUM=N to limit time zone abbreviations to N bytes (default 255)
# -DUNINIT_TRAP if reading uninitialized storage can cause problems
# other than simply getting garbage data
# -DUSE_LTZ=0 to build zdump with the system time zone library
@ -273,6 +273,8 @@ LDLIBS=
# $(GCC_DEBUG_FLAGS) if you are using recent GCC and want lots of checking
#
# * Options marked "*" can be omitted if your compiler is C23 compatible.
# * Options marked "+" are obsolescent and are planned to be removed
# once the code assumes C99 or later.
#
# Select instrumentation via "make GCC_INSTRUMENT='whatever'".
GCC_INSTRUMENT = \
@ -363,7 +365,7 @@ GCC_DEBUG_FLAGS = -DGCC_LINT -g3 -O3 -fno-common \
# -DNETBSD_INSPIRED=0
# to the end of the "CFLAGS=" line. Otherwise, the functions
# "localtime_rz", "mktime_z", "tzalloc", and "tzfree" are added to the
# time library, and if STD_INSPIRED is also defined the functions
# time library, and if STD_INSPIRED is also defined to nonzero the functions
# "posix2time_z" and "time2posix_z" are added as well.
# The functions ending in "_z" (or "_rz") are like their unsuffixed
# (or suffixed-by-"_r") counterparts, except with an extra first
@ -455,16 +457,13 @@ SAFE_CHARSET3= 'abcdefghijklmnopqrstuvwxyz{|}~'
SAFE_CHARSET= $(SAFE_CHARSET1)$(SAFE_CHARSET2)$(SAFE_CHARSET3)
SAFE_CHAR= '[]'$(SAFE_CHARSET)'-]'
# These characters are Latin-1, and so are likely to be displayable
# even in editors with limited character sets.
UNUSUAL_OK_LATIN_1 = «°±»½¾×
# This IPA symbol is represented in Unicode as the composition of
# U+0075 and U+032F, and U+032F is not considered alphabetic by some
# grep implementations that do not grok composition.
UNUSUAL_OK_IPA =
# These non-alphabetic, non-ASCII printable characters are Latin-1,
# and so are likely displayable even in editors like XEmacs 21
# that have limited display capabilities.
UNUSUAL_OK_LATIN_1 = ¡¢£¤¥¦§¨©«¬®¯°±²³´¶·¸¹»¼½¾¿×÷
# Non-ASCII non-letters that OK_CHAR allows, as these characters are
# useful in commentary.
UNUSUAL_OK_CHARSET= $(UNUSUAL_OK_LATIN_1)$(UNUSUAL_OK_IPA)
UNUSUAL_OK_CHARSET= $(UNUSUAL_OK_LATIN_1)
# Put this in a bracket expression to match spaces.
s = [:space:]
@ -833,7 +832,7 @@ check_slashed_abbrs: $(TDATA_TO_CHECK)
CHECK_CC_LIST = { n = split($$1,a,/,/); for (i=2; i<=n; i++) print a[1], a[i]; }
check_sorted: backward backzone iso3166.tab zone.tab zone1970.tab
check_sorted: backward backzone
$(AWK) '/^Link/ {printf "%.5d %s\n", g, $$3} !/./ {g++}' \
backward | LC_ALL=C sort -cu
$(AWK) '/^Zone/ {print $$2}' backzone | LC_ALL=C sort -cu

View File

@ -1,5 +1,116 @@
News for the tz database
Release 2023c - 2023-03-28 12:42:14 -0700
Changes to past and future timestamps
Model Lebanon's DST chaos by reverting data to tzdb 2023a.
(Thanks to Rany Hany for the heads-up.)
Release 2023b - 2023-03-23 19:50:38 -0700
Changes to future timestamps
This year Lebanon springs forward April 20/21 not March 25/26.
(Thanks to Saadallah Itani.) [This was reverted in 2023c.]
Release 2023a - 2023-03-22 12:39:33 -0700
Briefly:
Egypt now uses DST again, from April through October.
This year Morocco springs forward April 23, not April 30.
Palestine delays the start of DST this year.
Much of Greenland still uses DST from 2024 on.
America/Yellowknife now links to America/Edmonton.
tzselect can now use current time to help infer timezone.
The code now defaults to C99 or later.
Fix use of C23 attributes.
Changes to future timestamps
Starting in 2023, Egypt will observe DST from April's last Friday
through October's last Thursday. (Thanks to Ahmad ElDardiry.)
Assume the transition times are 00:00 and 24:00, respectively.
In 2023 Morocco's spring-forward transition after Ramadan
will occur April 23, not April 30. (Thanks to Milamber.)
Adjust predictions for future years accordingly. This affects
predictions for 2023, 2031, 2038, and later years.
This year Palestine will delay its spring forward from
March 25 to April 29 due to Ramadan. (Thanks to Heba Hamad.)
Make guesses for future Ramadans too.
Much of Greenland, represented by America/Nuuk, will continue to
observe DST using European Union rules. When combined with
Greenland's decision not to change the clocks in fall 2023,
America/Nuuk therefore changes from -03/-02 to -02/-01 effective
2023-10-29 at 01:00 UTC. (Thanks to Thomas M. Steenholdt.)
This change from 2022g doesn't affect timestamps until 2024-03-30,
and doesn't affect tm_isdst until 2023-03-25.
Changes to past timestamps
America/Yellowknife has changed from a Zone to a backward
compatibility Link, as it no longer differs from America/Edmonton
since 1970. (Thanks to Almaz Mingaleev.) This affects some
pre-1948 timestamps. The old data are now in 'backzone'.
Changes to past time zone abbreviations
When observing Moscow time, Europe/Kirov and Europe/Volgograd now
use the abbreviations MSK/MSD instead of numeric abbreviations,
for consistency with other timezones observing Moscow time.
Changes to code
You can now tell tzselect local time, to simplify later choices.
Select the 'time' option in its first prompt.
You can now compile with -DTZNAME_MAXIMUM=N to limit time zone
abbreviations to N bytes (default 255). The reference runtime
library now rejects POSIX-style TZ strings that contain longer
abbreviations, treating them as UTC. Previously the limit was
platform dependent and abbreviations were silently truncated to
16 bytes even when the limit was greater than 16.
The code by default is now designed for C99 or later. To build in
a C89 environment, compile with -DPORT_TO_C89. To support C89
callers of the tzcode library, compile with -DSUPPORT_C89. The
two new macros are transitional aids planned to be removed in a
future version, when C99 or later will be required.
The code now builds again on pre-C99 platforms, if you compile
with -DPORT_TO_C89. This fixes a bug introduced in 2022f.
On C23-compatible platforms tzcode no longer uses syntax like
'static [[noreturn]] void usage(void);'. Instead, it uses
'[[noreturn]] static void usage(void);' as strict C23 requires.
(Problem reported by Houge Langley.)
The code's functions now constrain their arguments with the C
'restrict' keyword consistently with their documentation.
This may allow future optimizations.
zdump again builds standalone with ckdadd and without setenv,
fixing a bug introduced in 2022g. (Problem reported by panic.)
leapseconds.awk can now process a leap seconds file that never
expires; this might be useful if leap seconds are discontinued.
Changes to commentary
tz-link.html has a new section "Coordinating with governments and
distributors". (Thanks to Neil Fuller for some of the text.)
To improve tzselect diagnostics, zone1970.tab's comments column is
now limited to countries that have multiple timezones.
Note that leap seconds are planned to be discontinued by 2035.
Release 2022g - 2022-11-29 08:58:31 -0800
Briefly:
@ -596,7 +707,7 @@ Release 2021b - 2021-09-24 16:23:00 -0700
Starting with 2020a, zic -L truncated its output according to the
"Expires" directive or "#expires" comment in the leapseconds file.
The resulting TZif files omitted daylight saving transitions after
the leap second table expired, which led to far less-accurate
the leap second table expired, which led to far less accurate
predictions of times after the expiry. Although future timestamps
cannot be converted accurately in the presence of leap seconds, it
is more accurate to convert near-future timestamps with a few
@ -616,7 +727,7 @@ Release 2021b - 2021-09-24 16:23:00 -0700
zic -L LEAPFILE -r @LO no longer generates an invalid TZif file
that omits leap second information for the range LO..B when LO
falls between two leap seconds A and B. Instead, it generates a
TZif version 4 file that represents the previously-missing
TZif version 4 file that represents the previously missing
information.
The TZif reader now allows the leap second table to begin with a
@ -670,7 +781,7 @@ Release 2021b - 2021-09-24 16:23:00 -0700
Fix a bug with 'zic -r @X' when X is a negative leap second that
has a nonnegative correction. Without the fix, the output file
was truncated so that X appeared to be a positive leap second.
Fix a similar, even-less-likely bug when truncating at a positive
Fix a similar, even less likely bug when truncating at a positive
leap second that has a nonpositive correction.
zic -r now reports an error if given rolling leap seconds, as this
@ -691,7 +802,7 @@ Release 2021b - 2021-09-24 16:23:00 -0700
fixing a bug introduced in 2014g.
zdump -v now outputs timestamps at boundaries of what localtime
and gmtime can represent, instead of the less-useful timestamps
and gmtime can represent, instead of the less useful timestamps
one day after the minimum and one day before the maximum.
(Thanks to Arthur David Olson for prototype code, and to Manuela
Friedrich for debugging help.)
@ -2311,7 +2422,7 @@ Release 2016g - 2016-09-13 08:56:38 -0700
names internally.
zdump has a new -i option to generate transitions in a
more-compact but still human-readable format. This option is
smaller but still human-readable format. This option is
experimental, and the output format may change in future versions.
(Thanks to Jon Skeet for suggesting that an option was needed,
and thanks to Tim Parenti and Chris Rovick for further comments.)
@ -2333,7 +2444,7 @@ Release 2016g - 2016-09-13 08:56:38 -0700
release 2016g, the version number is now something like
'2016g-23-g50556e3-dirty' instead of the misleading '2016g'.
Tagged releases use the same version number format as before,
e.g., '2016g'. To support the more-accurate version number, its
e.g., '2016g'. To support the more accurate version number, its
specification has moved from a line in the Makefile to a new
source file 'version'.
@ -2964,7 +3075,7 @@ Release 2014i - 2014-10-21 22:04:57 -0700
Since Belarus is not changing its clocks even though Moscow is,
the time zone abbreviation in Europe/Minsk is changing from FET
to its more-traditional value MSK on 2014-10-26 at 01:00.
to its more traditional value MSK on 2014-10-26 at 01:00.
(Thanks to Alexander Bokovoy for the heads-up about Belarus.)
The new abbreviation IDT stands for the pre-1976 use of UT +08 in
@ -3056,7 +3167,7 @@ Release 2014h - 2014-09-25 18:59:03 -0700
Changes affecting build procedure
'make check' now checks better for properly-sorted data.
'make check' now checks better for properly sorted data.
Changes affecting documentation and commentary
@ -3557,7 +3668,7 @@ Release 2014a - 2014-03-07 23:30:29 -0800
Changes affecting past timestamps
Fiji ended DST on 2014-01-19 at 02:00, not the previously-scheduled 03:00.
Fiji ended DST on 2014-01-19 at 02:00, not the previously scheduled 03:00.
(Thanks to Steffen Thorsen.)
Ukraine switched from Moscow to Eastern European time on 1990-07-01
@ -3811,7 +3922,7 @@ Release 2013e - 2013-09-19 23:50:04 -0700
Allow POSIX-like TZ strings where the transition time's hour can
range from -167 through 167, instead of the POSIX-required 0
through 24. E.g., TZ='FJT-12FJST,M10.3.1/146,M1.3.4/75' for the
new Fiji rules. This is a more-compact way to represent
new Fiji rules. This is a more compact way to represent
far-future timestamps for America/Godthab, America/Santiago,
Antarctica/Palmer, Asia/Gaza, Asia/Hebron, Asia/Jerusalem,
Pacific/Easter, and Pacific/Fiji. Other zones are unaffected by
@ -3819,7 +3930,7 @@ Release 2013e - 2013-09-19 23:50:04 -0700
Allow POSIX-like TZ strings where daylight saving time is in
effect all year. E.g., TZ='WART4WARST,J1/0,J365/25' for Western
Argentina Summer Time all year. This supports a more-compact way
Argentina Summer Time all year. This supports a more compact way
to represent the 2013d data for America/Argentina/San_Luis.
Because of the change for San Luis noted above this change does not
affect the current data. (Thanks to Andrew Main (Zefram) for
@ -3908,13 +4019,13 @@ Release 2013e - 2013-09-19 23:50:04 -0700
zdump now outputs "UT" when referring to Universal Time, not "UTC".
"UTC" does not make sense for timestamps that predate the introduction
of UTC, whereas "UT", a more-generic term, does. (Thanks to Steve Allen
of UTC, whereas "UT", a more generic term, does. (Thanks to Steve Allen
for clarifying UT vs UTC.)
Data changes affecting behavior of tzselect and similar programs
Country code BQ is now called the more-common name "Caribbean Netherlands"
rather than the more-official "Bonaire, St Eustatius & Saba".
Country code BQ is now called the more common name "Caribbean Netherlands"
rather than the more official "Bonaire, St Eustatius & Saba".
Remove from zone.tab the names America/Montreal, America/Shiprock,
and Antarctica/South_Pole, as they are equivalent to existing
@ -4098,7 +4209,7 @@ Release 2013c - 2013-04-19 16:17:40 -0700
Macquarie Island is politically part of Australia, not Antarctica.
(Thanks to Tobias Conradi.)
Sort Macquarie more-consistently with other parts of Australia.
Sort Macquarie more consistently with other parts of Australia.
(Thanks to Tim Parenti.)
@ -5322,7 +5433,7 @@ Release data1998g - 1998-08-11 03:28:35 -0000
Release data1998f - 1998-07-20 13:50:00 -0000
[tzdata1998f.tar.gz is missing!]
Update the "leapseconds" file to include the newly-announced
Update the "leapseconds" file to include the newly announced
insertion at the end of 1998.

View File

@ -23,7 +23,7 @@
<li><a href="#stability">Interface stability</a></li>
<li><a href="#leapsec">Leap seconds</a></li>
<li><a href="#calendar">Calendrical issues</a></li>
<li><a href="#planets">Time and time zones on other planets</a></li>
<li><a href="#planets">Time and time zones off earth</a></li>
</ul>
</nav>
@ -443,11 +443,11 @@ in decreasing order of importance:
CAT/CAST Central Africa,
CET/CEST/CEMT Central European,
ChST Chamorro,
CST/CDT/CWT/CPT/CDDT Central [North America],
CST/CDT/CWT/CPT Central [North America],
CST/CDT China,
GMT/BST/IST/BDST Greenwich,
EAT East Africa,
EST/EDT/EWT/EPT/EDDT Eastern [North America],
EST/EDT/EWT/EPT Eastern [North America],
EET/EEST Eastern European,
GST/GDT Guam,
HST/HDT/HWT/HPT Hawaii,
@ -460,13 +460,13 @@ in decreasing order of importance:
MET/MEST Middle European (a backward-compatibility alias for
Central European),
MSK/MSD Moscow,
MST/MDT/MWT/MPT/MDDT Mountain,
MST/MDT/MWT/MPT Mountain,
NST/NDT/NWT/NPT/NDDT Newfoundland,
NST/NDT/NWT/NPT Nome,
NZMT/NZST New Zealand through 1945,
NZST/NZDT New Zealand 1946&ndash;present,
PKT/PKST Pakistan,
PST/PDT/PWT/PPT/PDDT Pacific,
PST/PDT/PWT/PPT Pacific,
PST/PDT Philippine,
SAST South Africa,
SST Samoa,
@ -494,7 +494,7 @@ in decreasing order of importance:
<p>
<small>These abbreviations are:
AMT Asunción, Athens;
BMT Baghdad, Bangkok, Batavia, Bermuda, Bern, Bogotá, Bridgetown,
BMT Baghdad, Bangkok, Batavia, Bermuda, Bern, Bogotá,
Brussels, Bucharest;
CMT Calamarca, Caracas, Chisinau, Colón, Córdoba;
DMT Dublin/Dunsink;
@ -506,12 +506,13 @@ in decreasing order of importance:
IMT Irkutsk, Istanbul;
JMT Jerusalem;
KMT Kaunas, Kyiv, Kingston;
LMT Lima, Lisbon, local, Luanda;
LMT Lima, Lisbon, local;
MMT Macassar, Madras, Malé, Managua, Minsk, Monrovia, Montevideo,
Moratuwa, Moscow;
PLMT Phù Liễn;
PMT Paramaribo, Paris, Perm, Pontianak, Prague;
PMMT Port Moresby;
PPMT Port-au-Prince;
QMT Quito;
RMT Rangoon, Riga, Rome;
SDMT Santo Domingo;
@ -519,8 +520,7 @@ in decreasing order of importance:
SMT Santiago, Simferopol, Singapore, Stanley;
TBMT Tbilisi;
TMT Tallinn, Tehran;
WMT Warsaw;
ZMT Zomba.</small>
WMT Warsaw.</small>
</p>
<p>
@ -791,7 +791,7 @@ href="https://www.dissentmagazine.org/blog/booked-a-global-history-of-time-vanes
with days starting at midnight.
Although <abbr>UT</abbr> equals <abbr>UTC</abbr> for modern
timestamps, <abbr>UTC</abbr> was not defined until 1960, so
commentary uses the more-general abbreviation <abbr>UT</abbr> for
commentary uses the more general abbreviation <abbr>UT</abbr> for
timestamps that might predate 1960.
Since <abbr>UT</abbr>, <abbr>UT1</abbr>, etc. disagree slightly,
and since pre-1972 <abbr>UTC</abbr> seconds varied in length,
@ -818,7 +818,8 @@ href="https://www.dissentmagazine.org/blog/booked-a-global-history-of-time-vanes
<li>
The relationship between POSIX time (that is, <abbr>UTC</abbr> but
ignoring <a href="https://en.wikipedia.org/wiki/Leap_second">leap
seconds</a>) and <abbr>UTC</abbr> is not agreed upon after 1972.
seconds</a>) and <abbr>UTC</abbr> is not agreed upon.
This affects time stamps during the leap second era (1972&ndash;2035).
Although the POSIX
clock officially stops during an inserted leap second, at least one
proposed standard has it jumping back a second instead; and in
@ -877,7 +878,7 @@ an older <code>zic</code>.
is error-prone in practice.
Also, POSIX <code>TZ</code> strings cannot deal with daylight
saving time rules not based on the Gregorian calendar (as in
Iran), or with situations where more than two time zone
Morocco), or with situations where more than two time zone
abbreviations or <abbr>UT</abbr> offsets are used in an area.
</p>
@ -913,8 +914,8 @@ an older <code>zic</code>.
<dt><var>date</var>[<code>/</code><var>time</var>]<code>,</code><var>date</var>[<code>/</code><var>time</var>]</dt><dd>
specifies the beginning and end of <abbr>DST</abbr>.
If this is absent, the system supplies its own ruleset
for <abbr>DST</abbr>, and its rules can differ from year to year;
typically <abbr>US</abbr> <abbr>DST</abbr> rules are used.
for <abbr>DST</abbr>, typically current <abbr>US</abbr>
<abbr>DST</abbr> rules.
</dd>
<dt><var>time</var></dt><dd>
takes the form
@ -974,10 +975,11 @@ an older <code>zic</code>.
Traditionally the current <abbr>US</abbr> <abbr>DST</abbr> rules
were used to interpret such values, but this meant that the
<abbr>US</abbr> <abbr>DST</abbr> rules were compiled into each
program that did time conversion. This meant that when
time conversion package, and when
<abbr>US</abbr> time conversion rules changed (as in the United
States in 1987), all programs that did time conversion had to be
recompiled to ensure proper results.
States in 1987 and again in 2007), all packages that
interpreted <code>TZ</code> values had to be updated
to ensure proper results.
</li>
<li>
The <code>TZ</code> environment variable is process-global, which
@ -1173,7 +1175,7 @@ The vestigial <abbr>API</abbr>s are:
</li>
<li>
The functions that are conditionally compiled
if <code>STD_INSPIRED</code> is defined should, at this point, be
if <code>STD_INSPIRED</code> is nonzero should, at this point, be
looked on primarily as food for thought.
They are not in any sense "standard compatible" &ndash; some are
not, in fact, specified in <em>any</em> standard.
@ -1240,7 +1242,7 @@ The <code><abbr>tz</abbr></code> code and data supply the following interfaces:
Interface changes in a release attempt to preserve compatibility with
recent releases.
For example, <code><abbr>tz</abbr></code> data files typically do not
rely on recently-added <code>zic</code> features, so that users can
rely on recently added <code>zic</code> features, so that users can
run older <code>zic</code> versions to process newer data files.
<a href="tz-link.html#download">Downloading
the <code><abbr>tz</abbr></code> database</a> describes how releases
@ -1268,6 +1270,18 @@ between now and the future time.
<section>
<h2 id="leapsec">Leap seconds</h2>
<p>
Leap seconds were introduced in 1972 to accommodate the
difference between atomic time and the less regular rotation of the earth.
Unfortunately they caused so many problems with civil
timekeeping that they
are <a href="https://www.bipm.org/en/cgpm-2022/resolution-4">planned
to be discontinued by 2035</a>, with some as-yet-undetermined
mechanism replacing them, perhaps after the year 2135.
Despite their impending obsolescence, a record of leap seconds is still
needed to resolve timestamps from 1972 through 2035.
</p>
<p>
The <code><abbr>tz</abbr></code> code and data can account for leap seconds,
thanks to code contributed by Bradley White.
@ -1282,12 +1296,12 @@ commonly used by
<a href="https://www.ntp.org"><abbr title="Network Time Protocol">NTP</abbr></a>
software that adjusts the kernel clock.
However, kernel-clock twiddling approximates UTC only roughly,
and systems needing more-precise UTC can use this package's leap
and systems needing more precise UTC can use this package's leap
second support directly.
</p>
<p>
The directly-supported mechanism assumes that <code>time_t</code>
The directly supported mechanism assumes that <code>time_t</code>
counts of seconds since the POSIX epoch normally include leap seconds,
as opposed to POSIX <code>time_t</code> counts which exclude leap seconds.
This modified timescale is converted to <abbr>UTC</abbr>
@ -1348,7 +1362,15 @@ They sometimes disagree.
</section>
<section>
<h2 id="planets">Time and time zones on other planets</h2>
<h2 id="planets">Time and time zones off Earth</h2>
<p>
The European Space Agency is <a
href='https://www.esa.int/Applications/Navigation/Telling_time_on_the_Moon'>considering</a>
the establishment of a reference timescale for the Moon, which has
days roughly equivalent to 29.5 Earth days, and where relativistic
effects cause clocks to tick slightly faster than on Earth.
</p>
<p>
Some people's work schedules have used
<a href="https://en.wikipedia.org/wiki/Timekeeping_on_Mars">Mars time</a>.

View File

@ -1 +1 @@
2022g
2023c

2684
contrib/xz/doxygen/Doxyfile Normal file

File diff suppressed because it is too large Load Diff

111
contrib/xz/doxygen/update-doxygen Executable file
View File

@ -0,0 +1,111 @@
#!/bin/sh
#
#############################################################################
#
# Updates the Doxygen generated documentation files in the source tree.
# If the doxygen command is not installed, it will exit with an error.
# This script can generate Doxygen documentation for all source files or for
# just liblzma API header files.
#
# It is recommended to use this script to update the Doxygen-generated HTML
# files since this will include the package version in the output and,
# in case of liblzma API docs, strip JavaScript files from the output.
#
#############################################################################
#
# Authors: Jia Tan
# Lasse Collin
#
# This file has been put into the public domain.
# You can do whatever you want with this file.
#
#############################################################################
set -e
if type doxygen > /dev/null 2>&1; then
:
else
echo "doxygen/update-doxygen: 'doxygen' command not found." >&2
echo "doxygen/update-doxygen: Skipping Doxygen docs generation." >&2
exit 1
fi
if test ! -f Doxyfile; then
cd `dirname "$0"` || exit 1
if test ! -f Doxyfile; then
echo "doxygen/update-doxygen: Cannot find Doxyfile" >&2
exit 1
fi
fi
# Get the package version so that it can be included in the generated docs.
PACKAGE_VERSION=`cd .. && sh build-aux/version.sh` || exit 1
# If no arguments are specified, default to generating liblzma API header
# documentation only.
case $1 in
'' | api)
# Remove old documentation before re-generating the new.
rm -rf ../doc/api
# Generate the HTML documentation by preparing the Doxyfile
# in stdin and piping the result to the doxygen command.
# With Doxygen, the last assignment of a value to a tag will
# override any earlier assignment. So, we can use this
# feature to override the tags that need to change between
# "api" and "internal" modes.
(
cat Doxyfile
echo "PROJECT_NUMBER = $PACKAGE_VERSION"
) | doxygen -
# As of Doxygen 1.8.0 - 1.9.6 and the Doxyfile options we use,
# the output is good without any JavaScript. Unfortunately
# Doxygen doesn't have an option to disable JavaScript usage
# completely so we strip it away with the hack below.
#
# Omitting the JavaScript code avoids some license hassle
# as jquery.js is fairly big, it contains more than jQuery
# itself, and doesn't include the actual license text (it
# only refers to the MIT license by name).
echo "Stripping JavaScript from Doxygen output..."
for F in ../doc/api/*.html
do
sed 's/<script [^>]*><\/script>//g
s/onclick="[^"]*"//g' \
"$F" > ../doc/api/tmp
mv -f ../doc/api/tmp "$F"
done
rm -f ../doc/api/*.js
;;
internal)
# The docs from internal aren't for distribution so
# the JavaScript files aren't an issue here.
rm -rf ../doc/internal
(
cat Doxyfile
echo "PROJECT_NUMBER = $PACKAGE_VERSION"
echo 'PROJECT_NAME = "XZ Utils"'
echo 'STRIP_FROM_PATH = ../src'
echo 'INPUT = ../src'
echo 'HTML_OUTPUT = internal'
echo 'EXTRACT_PRIVATE = YES'
echo 'EXTRACT_STATIC = YES'
echo 'EXTRACT_LOCAL_CLASSES = YES'
echo 'SEARCHENGINE = YES'
) | doxygen -
;;
*)
echo "doxygen/update-doxygen: Error: mode argument '$1'" \
"is not supported." >&2
echo "doxygen/update-doxygen: Supported modes:" >&2
echo "doxygen/update-doxygen: - 'api' (default):" \
"liblzma API docs into doc/api" >&2
echo "doxygen/update-doxygen: - 'internal':"\
"internal docs into doc/internal" >&2
exit 1
;;
esac

View File

@ -204,6 +204,10 @@ io_sandbox_enter(int src_fd)
STDIN_FILENO, cap_rights_clear(&rights)))
goto error;
if (src_fd != STDIN_FILENO && cap_rights_limit(
STDIN_FILENO, cap_rights_clear(&rights)))
goto error;
if (cap_rights_limit(STDOUT_FILENO, cap_rights_init(&rights,
CAP_EVENT, CAP_FCNTL, CAP_FSTAT, CAP_LOOKUP,
CAP_WRITE, CAP_SEEK)) < 0 && errno != ENOSYS)
@ -214,11 +218,11 @@ io_sandbox_enter(int src_fd)
goto error;
if (cap_rights_limit(user_abort_pipe[0], cap_rights_init(&rights,
CAP_EVENT)) < 0 && errno != ENOSYS)
CAP_EVENT)))
goto error;
if (cap_rights_limit(user_abort_pipe[1], cap_rights_init(&rights,
CAP_WRITE)) < 0 && errno != ENOSYS)
CAP_WRITE)))
goto error;
#elif defined(HAVE_PLEDGE)

View File

@ -2,6 +2,7 @@
[![C/C++ CI](https://github.com/openssh/openssh-portable/actions/workflows/c-cpp.yml/badge.svg)](https://github.com/openssh/openssh-portable/actions/workflows/c-cpp.yml)
[![Fuzzing Status](https://oss-fuzz-build-logs.storage.googleapis.com/badges/openssh.svg)](https://bugs.chromium.org/p/oss-fuzz/issues/list?sort=-opened&can=1&q=proj:openssh)
[![Coverity Status](https://scan.coverity.com/projects/21341/badge.svg)](https://scan.coverity.com/projects/openssh-portable)
OpenSSH is a complete implementation of the SSH protocol (version 2) for secure remote login, command execution and file transfer. It includes a client ``ssh`` and server ``sshd``, file transfer utilities ``scp`` and ``sftp`` as well as tools for key generation (``ssh-keygen``), run-time key storage (``ssh-agent``) and a number of supporting programs.

View File

@ -40,6 +40,7 @@
#define required_argument 1
#define optional_argument 2
#if 0
struct option {
/* name of long option */
const char *name;
@ -58,6 +59,8 @@ int getopt_long(int, char * const *, const char *,
const struct option *, int *);
int getopt_long_only(int, char * const *, const char *,
const struct option *, int *);
#endif
#ifndef _GETOPT_DEFINED_
#define _GETOPT_DEFINED_
int getopt(int, char * const *, const char *);

View File

@ -220,9 +220,7 @@
#define compare Fssh_compare
#define compare_gps Fssh_compare_gps
#define compat_banner Fssh_compat_banner
#define compat_cipher_proposal Fssh_compat_cipher_proposal
#define compat_kex_proposal Fssh_compat_kex_proposal
#define compat_pkalg_proposal Fssh_compat_pkalg_proposal
#define compression_alg_list Fssh_compression_alg_list
#define connect_next Fssh_connect_next
#define connect_to Fssh_connect_to
@ -361,6 +359,8 @@
#define kex_new Fssh_kex_new
#define kex_prop2buf Fssh_kex_prop2buf
#define kex_prop_free Fssh_kex_prop_free
#define kex_proposal_free_entries Fssh_kex_proposal_free_entries
#define kex_proposal_populate_entries Fssh_kex_proposal_populate_entries
#define kex_protocol_error Fssh_kex_protocol_error
#define kex_ready Fssh_kex_ready
#define kex_send_kexinit Fssh_kex_send_kexinit

View File

@ -105,7 +105,7 @@ AuthorizedKeysFile .ssh/authorized_keys
#PermitTunnel no
#ChrootDirectory none
#UseBlacklist no
#VersionAddendum FreeBSD-20230205
#VersionAddendum FreeBSD-20230316
# no default banner path
#Banner none

View File

@ -1927,7 +1927,7 @@ The default is
Optionally specifies additional text to append to the SSH protocol banner
sent by the server upon connection.
The default is
.Qq FreeBSD-20230205 .
.Qq FreeBSD-20230316 .
The value
.Cm none
may be used to disable this.

View File

@ -5,4 +5,4 @@
#define SSH_PORTABLE "p1"
#define SSH_RELEASE SSH_VERSION SSH_PORTABLE
#define SSH_VERSION_FREEBSD "FreeBSD-20230205"
#define SSH_VERSION_FREEBSD "FreeBSD-20230316"

View File

@ -379,7 +379,7 @@
#define PACKAGE_NAME "XZ Utils"
/* Define to the full name and version of this package. */
#define PACKAGE_STRING "XZ Utils 5.4.1"
#define PACKAGE_STRING "XZ Utils 5.4.2"
/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME "xz"
@ -388,7 +388,7 @@
#define PACKAGE_URL "https://tukaani.org/xz/"
/* Define to the version of this package. */
#define PACKAGE_VERSION "5.4.1"
#define PACKAGE_VERSION "5.4.2"
/* Define to necessary symbol if this constant uses a non-standard name on
your system. */
@ -549,7 +549,7 @@
/* Version number of package */
#define VERSION "5.4.1"
#define VERSION "5.4.2"
/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
significant byte first (like Motorola and SPARC, unlike Intel). */

View File

@ -20,6 +20,8 @@ SRCS= bpf_dump.c \
pcap-bpf.c \
pcap-common.c \
pcap-netmap.c \
pcap-usb-linux-common.c \
pcap-util.c \
pcap.c \
savefile.c \
scanner.l \
@ -28,8 +30,7 @@ SRCS= bpf_dump.c \
tokdefs.h
# Old compatibility headers
INCS= fmtutils.h \
pcap-bpf.h \
INCS= pcap-bpf.h \
pcap-namedb.h \
pcap-netmap.h \
pcap.h
@ -78,6 +79,7 @@ MAN= pcap.3 \
pcap_get_selectable_fd.3 \
pcap_get_tstamp_precision.3 \
pcap_geterr.3 \
pcap_init.3 \
pcap_inject.3 \
pcap_is_swapped.3 \
pcap_lib_version.3 \
@ -130,7 +132,7 @@ MLINKS= \
# Our man pages are a special copy from the distdir. See below.
CLEANFILES+=${MAN}
CLEANFILES+=tokdefs.h scanner.h
CLEANFILES+=grammar.y scanner.h tokdefs.h
YFLAGS+=-p pcap_
LFLAGS+=-Ppcap_ --header-file=${.OBJDIR}/scanner.h --nounput
@ -166,6 +168,9 @@ CFLAGS+=-I${PCAP_DISTDIR}
.PATH: ${PCAP_DISTDIR}
.PATH: ${PCAP_DISTDIR}/bpf/net
grammar.y: grammar.y.in
sed -e 's/@REENTRANT_PARSER@/%pure-parser/' < ${.ALLSRC} > ${.TARGET}
tokdefs.h: grammar.h .NOMETA
ln -sf ${.ALLSRC} ${.TARGET}

View File

@ -39,6 +39,7 @@ PACKAGE= ssh
SRCS+= bcrypt_pbkdf.c blowfish.c bsd-misc.c bsd-signal.c explicit_bzero.c \
fmt_scaled.c freezero.c glob.c \
libressl-api-compat.c \
mktemp.c \
openssl-compat.c port-net.c \
recallocarray.c strtonum.c timingsafe_bcmp.c vis.c xcrypt.c

View File

@ -52,7 +52,7 @@
*
* See
*
* http://www.tcpdump.org/linktypes.html
* https://www.tcpdump.org/linktypes.html
*
* for detailed descriptions of some of these link-layer header types.
*/
@ -106,6 +106,67 @@
#define DLT_PPP_BSDOS 16 /* BSD/OS Point-to-point Protocol */
#endif
/*
* NetBSD uses 15 for HIPPI.
*
* From a quick look at sys/net/if_hippi.h and sys/net/if_hippisubr.c
* in an older version of NetBSD , the header appears to be:
*
* a 1-byte ULP field (ULP-id)?
*
* a 1-byte flags field;
*
* a 2-byte "offsets" field;
*
* a 4-byte "D2 length" field (D2_Size?);
*
* a 4-byte "destination switch" field (or a 1-byte field
* containing the Forwarding Class, Double_Wide, and Message_Type
* sub fields, followed by a 3-byte Destination_Switch_Address
* field?, HIPPI-LE 3.4-style?);
*
* a 4-byte "source switch" field (or a 1-byte field containing the
* Destination_Address_type and Source_Address_Type fields, followed
* by a 3-byte Source_Switch_Address field, HIPPI-LE 3.4-style?);
*
* a 2-byte reserved field;
*
* a 6-byte destination address field;
*
* a 2-byte "local admin" field;
*
* a 6-byte source address field;
*
* followed by an 802.2 LLC header.
*
* This looks somewhat like something derived from the HIPPI-FP 4.4
* Header_Area, followed an HIPPI-FP 4.4 D1_Area containing a D1 data set
* with the header in HIPPI-LE 3.4 (ANSI X3.218-1993), followed by an
* HIPPI-FP 4.4 D2_Area (with no Offset) containing the 802.2 LLC header
* and payload? Or does the "offsets" field contain the D2_Offset,
* with that many bytes of offset before the payload?
*
* See http://wotug.org/parallel/standards/hippi/ for an archive of
* HIPPI specifications.
*
* RFC 2067 imposes some additional restrictions. It says that the
* Offset is always zero
*
* HIPPI is long-gone, and the source files found in an older version
* of NetBSD don't appear to be in the main CVS branch, so we may never
* see a capture with this link-layer type.
*/
#if defined(__NetBSD__)
#define DLT_HIPPI 15 /* HIPPI */
#endif
/*
* NetBSD uses 16 for DLT_HDLC; see below.
* BSD/OS uses it for PPP; see above.
* As far as I know, no other OS uses it for anything; don't use it
* for anything else.
*/
/*
* 17 was used for DLT_PFLOG in OpenBSD; it no longer is.
*
@ -138,7 +199,7 @@
#define DLT_PFSYNC 18
#endif
#define DLT_ATM_CLIP 19 /* Linux Classical-IP over ATM */
#define DLT_ATM_CLIP 19 /* Linux Classical IP over ATM */
/*
* Apparently Redback uses this for its SmartEdge 400/800. I hope
@ -221,7 +282,8 @@
* that the AF_ type in the link-layer header is in network byte order.
*
* DLT_LOOP is 12 in OpenBSD, but that's DLT_RAW in other OSes, so
* we don't use 12 for it in OSes other than OpenBSD.
* we don't use 12 for it in OSes other than OpenBSD; instead, we
* use the same value as LINKTYPE_LOOP.
*/
#ifdef __OpenBSD__
#define DLT_LOOP 12
@ -232,7 +294,7 @@
/*
* Encapsulated packets for IPsec; DLT_ENC is 13 in OpenBSD, but that's
* DLT_SLIP_BSDOS in NetBSD, so we don't use 13 for it in OSes other
* than OpenBSD.
* than OpenBSD; instead, we use the same value as LINKTYPE_ENC.
*/
#ifdef __OpenBSD__
#define DLT_ENC 13
@ -241,14 +303,24 @@
#endif
/*
* Values between 110 and 112 are reserved for use in capture file headers
* Values 110 and 111 are reserved for use in capture file headers
* as link-layer types corresponding to DLT_ types that might differ
* between platforms; don't use those values for new DLT_ types
* other than the corresponding DLT_ types.
*/
/*
* This is for Linux cooked sockets.
* NetBSD uses 16 for (Cisco) "HDLC framing". For other platforms,
* we define it to have the same value as LINKTYPE_NETBSD_HDLC.
*/
#if defined(__NetBSD__)
#define DLT_HDLC 16 /* Cisco HDLC */
#else
#define DLT_HDLC 112
#endif
/*
* Linux cooked sockets.
*/
#define DLT_LINUX_SLL 113
@ -467,7 +539,7 @@
#define DLT_DOCSIS 143
/*
* Linux-IrDA packets. Protocol defined at http://www.irda.org.
* Linux-IrDA packets. Protocol defined at https://www.irda.org.
* Those packets include IrLAP headers and above (IrLMP...), but
* don't include Phy framing (SOF/EOF/CRC & byte stuffing), because Phy
* framing can be handled by the hardware and depend on the bitrate.
@ -475,7 +547,7 @@
* interface (irdaX), but not on a raw serial port.
* Note the capture is done in "Linux-cooked" mode, so each packet include
* a fake packet header (struct sll_header). This is because IrDA packet
* decoding is dependant on the direction of the packet (incomming or
* decoding is dependent on the direction of the packet (incoming or
* outgoing).
* When/if other platform implement IrDA capture, we may revisit the
* issue and define a real DLT_IRDA...
@ -609,7 +681,7 @@
/*
* Link types requested by Gregor Maier <gregor@endace.com> of Endace
* Measurement Systems. They add an ERF header (see
* http://www.endace.com/support/EndaceRecordFormat.pdf) in front of
* https://www.endace.com/support/EndaceRecordFormat.pdf) in front of
* the link-layer header.
*/
#define DLT_ERF_ETH 175 /* Ethernet */
@ -653,7 +725,7 @@
* DLT_ requested by Gianluca Varenni <gianluca.varenni@cacetech.com>.
* Every frame contains a 32bit A429 label.
* More documentation on Arinc 429 can be found at
* http://www.condoreng.com/support/downloads/tutorials/ARINCTutorial.pdf
* https://web.archive.org/web/20040616233302/https://www.condoreng.com/support/downloads/tutorials/ARINCTutorial.pdf
*/
#define DLT_A429 184
@ -742,12 +814,17 @@
* nothing); requested by Mikko Saarnivala <mikko.saarnivala@sensinode.com>.
* For this one, we expect the FCS to be present at the end of the frame;
* if the frame has no FCS, DLT_IEEE802_15_4_NOFCS should be used.
*
* We keep the name DLT_IEEE802_15_4 as an alias for backwards
* compatibility, but, again, this should *only* be used for 802.15.4
* frames that include the FCS.
*/
#define DLT_IEEE802_15_4 195
#define DLT_IEEE802_15_4_WITHFCS 195
#define DLT_IEEE802_15_4 DLT_IEEE802_15_4_WITHFCS
/*
* Various link-layer types, with a pseudo-header, for SITA
* (http://www.sita.aero/); requested by Fulko Hew (fulko.hew@gmail.com).
* (https://www.sita.aero/); requested by Fulko Hew (fulko.hew@gmail.com).
*/
#define DLT_SITA 196
@ -766,10 +843,10 @@
#define DLT_RAIF1 198
/*
* IPMB packet for IPMI, beginning with the I2C slave address, followed
* by the netFn and LUN, etc.. Requested by Chanthy Toeung
* <chanthy.toeung@ca.kontron.com>.
*
* IPMB packet for IPMI, beginning with a 2-byte header, followed by
* the I2C slave address, followed by the netFn and LUN, etc..
* Requested by Chanthy Toeung <chanthy.toeung@ca.kontron.com>.
*
* XXX - this used to be called DLT_IPMB, back when we got the
* impression from the email thread requesting it that the packet
* had no extra 2-byte header. We've renamed it; if anybody used
@ -811,15 +888,37 @@
#define DLT_LAPD 203
/*
* Variants of various link-layer headers, with a one-byte direction
* pseudo-header prepended - zero means "received by this host",
* non-zero (any non-zero value) means "sent by this host" - as per
* Will Barker <w.barker@zen.co.uk>.
* PPP, with a one-byte direction pseudo-header prepended - zero means
* "received by this host", non-zero (any non-zero value) means "sent by
* this host" - as per Will Barker <w.barker@zen.co.uk>.
*
* Don't confuse this with DLT_PPP_WITH_DIRECTION, which is an old
* name for what is now called DLT_PPP_PPPD.
*/
#define DLT_PPP_WITH_DIR 204 /* PPP - don't confuse with DLT_PPP_WITH_DIRECTION */
#define DLT_C_HDLC_WITH_DIR 205 /* Cisco HDLC */
#define DLT_FRELAY_WITH_DIR 206 /* Frame Relay */
#define DLT_LAPB_WITH_DIR 207 /* LAPB */
#define DLT_PPP_WITH_DIR 204
/*
* Cisco HDLC, with a one-byte direction pseudo-header prepended - zero
* means "received by this host", non-zero (any non-zero value) means
* "sent by this host" - as per Will Barker <w.barker@zen.co.uk>.
*/
#define DLT_C_HDLC_WITH_DIR 205
/*
* Frame Relay, with a one-byte direction pseudo-header prepended - zero
* means "received by this host" (DCE -> DTE), non-zero (any non-zero
* value) means "sent by this host" (DTE -> DCE) - as per Will Barker
* <w.barker@zen.co.uk>.
*/
#define DLT_FRELAY_WITH_DIR 206
/*
* LAPB, with a one-byte direction pseudo-header prepended - zero means
* "received by this host" (DCE -> DTE), non-zero (any non-zero value)
* means "sent by this host" (DTE -> DCE)- as per Will Barker
* <w.barker@zen.co.uk>.
*/
#define DLT_LAPB_WITH_DIR 207
/*
* 208 is reserved for an as-yet-unspecified proprietary link-layer
@ -840,7 +939,7 @@
/*
* Media Oriented Systems Transport (MOST) bus for multimedia
* transport - http://www.mostcooperation.com/ - as requested
* transport - https://www.mostcooperation.com/ - as requested
* by Hannes Kaelber <hannes.kaelber@x2e.de>.
*/
#define DLT_MOST 211
@ -1026,16 +1125,16 @@
/*
* Raw D-Bus:
*
* http://www.freedesktop.org/wiki/Software/dbus
* https://www.freedesktop.org/wiki/Software/dbus
*
* messages:
*
* http://dbus.freedesktop.org/doc/dbus-specification.html#message-protocol-messages
* https://dbus.freedesktop.org/doc/dbus-specification.html#message-protocol-messages
*
* starting with the endianness flag, followed by the message type, etc.,
* but without the authentication handshake before the message sequence:
*
* http://dbus.freedesktop.org/doc/dbus-specification.html#auth-protocol
* https://dbus.freedesktop.org/doc/dbus-specification.html#auth-protocol
*
* Requested by Martin Vidner <martin@vidner.net>.
*/
@ -1053,7 +1152,7 @@
* DVB-CI (DVB Common Interface for communication between a PC Card
* module and a DVB receiver). See
*
* http://www.kaiser.cx/pcap-dvbci.html
* https://www.kaiser.cx/pcap-dvbci.html
*
* for the specification.
*
@ -1189,15 +1288,17 @@
#define DLT_BLUETOOTH_LE_LL 251
/*
* DLT type for upper-protocol layer PDU saves from wireshark.
* DLT type for upper-protocol layer PDU saves from Wireshark.
*
* the actual contents are determined by two TAGs stored with each
* packet:
* EXP_PDU_TAG_LINKTYPE the link type (LINKTYPE_ value) of the
* original packet.
* the actual contents are determined by two TAGs, one or more of
* which is stored with each packet:
*
* EXP_PDU_TAG_PROTO_NAME the name of the wireshark dissector
* that can make sense of the data stored.
* EXP_PDU_TAG_DISSECTOR_NAME the name of the Wireshark dissector
* that can make sense of the data stored.
*
* EXP_PDU_TAG_HEUR_DISSECTOR_NAME the name of the Wireshark heuristic
* dissector that can make sense of the
* data stored.
*/
#define DLT_WIRESHARK_UPPER_PDU 252
@ -1342,9 +1443,9 @@
/*
* per: Stefanha at gmail.com for
* http://lists.sandelman.ca/pipermail/tcpdump-workers/2017-May/000772.html
* https://lists.sandelman.ca/pipermail/tcpdump-workers/2017-May/000772.html
* and: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/uapi/linux/vsockmon.h
* for: http://qemu-project.org/Features/VirtioVsock
* for: https://qemu-project.org/Features/VirtioVsock
*/
#define DLT_VSOCK 271
@ -1356,7 +1457,7 @@
/*
* Excentis DOCSIS 3.1 RF sniffer (XRA-31)
* per: bruno.verstuyft at excentis.com
* http://www.xra31.com/xra-header
* https://www.xra31.com/xra-header
*/
#define DLT_DOCSIS31_XRA31 273
@ -1368,7 +1469,7 @@
/*
* DisplayPort AUX channel monitoring data as specified by VESA
* DisplayPort(DP) Standard preceeded by a pseudo-header.
* DisplayPort(DP) Standard preceded by a pseudo-header.
* per dirk.eibach at gdsys.cc
*/
#define DLT_DISPLAYPORT_AUX 275
@ -1378,6 +1479,83 @@
*/
#define DLT_LINUX_SLL2 276
/*
* Sercos Monitor, per Manuel Jacob <manuel.jacob at steinbeis-stg.de>
*/
#define DLT_SERCOS_MONITOR 277
/*
* OpenVizsla http://openvizsla.org is open source USB analyzer hardware.
* It consists of FPGA with attached USB phy and FTDI chip for streaming
* the data to the host PC.
*
* Current OpenVizsla data encapsulation format is described here:
* https://github.com/matwey/libopenvizsla/wiki/OpenVizsla-protocol-description
*
*/
#define DLT_OPENVIZSLA 278
/*
* The Elektrobit High Speed Capture and Replay (EBHSCR) protocol is produced
* by a PCIe Card for interfacing high speed automotive interfaces.
*
* The specification for this frame format can be found at:
* https://www.elektrobit.com/ebhscr
*
* for Guenter.Ebermann at elektrobit.com
*
*/
#define DLT_EBHSCR 279
/*
* The https://fd.io vpp graph dispatch tracer produces pcap trace files
* in the format documented here:
* https://fdio-vpp.readthedocs.io/en/latest/gettingstarted/developers/vnet.html#graph-dispatcher-pcap-tracing
*/
#define DLT_VPP_DISPATCH 280
/*
* Broadcom Ethernet switches (ROBO switch) 4 bytes proprietary tagging format.
*/
#define DLT_DSA_TAG_BRCM 281
#define DLT_DSA_TAG_BRCM_PREPEND 282
/*
* IEEE 802.15.4 with pseudo-header and optional meta-data TLVs, PHY payload
* exactly as it appears in the spec (no padding, no nothing), and FCS if
* specified by FCS Type TLV; requested by James Ko <jck@exegin.com>.
* Specification at https://github.com/jkcko/ieee802.15.4-tap
*/
#define DLT_IEEE802_15_4_TAP 283
/*
* Marvell (Ethertype) Distributed Switch Architecture proprietary tagging format.
*/
#define DLT_DSA_TAG_DSA 284
#define DLT_DSA_TAG_EDSA 285
/*
* Payload of lawful intercept packets using the ELEE protocol;
* https://socket.hr/draft-dfranusic-opsawg-elee-00.xml
* https://xml2rfc.tools.ietf.org/cgi-bin/xml2rfc.cgi?url=https://socket.hr/draft-dfranusic-opsawg-elee-00.xml&modeAsFormat=html/ascii
*/
#define DLT_ELEE 286
/*
* Serial frames transmitted between a host and a Z-Wave chip.
*/
#define DLT_Z_WAVE_SERIAL 287
/*
* USB 2.0, 1.1, and 1.0 packets as transmitted over the cable.
*/
#define DLT_USB_2_0 288
/*
* ATSC Link-Layer Protocol (A/330) packets.
*/
#define DLT_ATSC_ALP 289
/*
* In case the code that includes this file (directly or indirectly)
* has also included OS files that happen to define DLT_MATCHING_MAX,
@ -1388,7 +1566,7 @@
#ifdef DLT_MATCHING_MAX
#undef DLT_MATCHING_MAX
#endif
#define DLT_MATCHING_MAX 276 /* highest value in the "matching" range */
#define DLT_MATCHING_MAX 289 /* highest value in the "matching" range */
/*
* DLT and savefile link type values are split into a class and