Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
dabreadman committed Feb 5, 2025
2 parents 15fa536 + 2f8052e commit 3825a2b
Show file tree
Hide file tree
Showing 23 changed files with 326 additions and 179 deletions.
18 changes: 5 additions & 13 deletions capture/capture-pcap-util.c
Original file line number Diff line number Diff line change
Expand Up @@ -1124,7 +1124,6 @@ static GList*
get_pcap_timestamp_types(pcap_t *pch _U_, char **err_str _U_)
{
GList *list = NULL;
#ifdef HAVE_PCAP_SET_TSTAMP_TYPE
int *types;
int ntypes = pcap_list_tstamp_types(pch, &types);

Expand All @@ -1142,11 +1141,9 @@ get_pcap_timestamp_types(pcap_t *pch _U_, char **err_str _U_)
}

pcap_free_tstamp_types(types);
#endif
return list;
}

#ifdef HAVE_PCAP_SET_TSTAMP_PRECISION
/*
* Request high-resolution time stamps.
*
Expand Down Expand Up @@ -1174,6 +1171,11 @@ request_high_resolution_timestamp(pcap_t *pcap_h)
* call it. We have to, instead, use dlopen() to load
* libpcap, and dlsym() to find a pointer to pcap_set_tstamp_precision(),
* and if we find the pointer, call it.
*
* XXX - This shouldn't be needed anymore; we don't support running
* on any release older than macOS 11, and starting with macOS 11 the
* system libpcap is based on libpcap 1.5 or later and has
* pcap_set_tstamp_precision().
*/
static bool initialized = false;
static int (*p_pcap_set_tstamp_precision)(pcap_t *, int);
Expand Down Expand Up @@ -1243,8 +1245,6 @@ have_high_resolution_timestamp(pcap_t *pcap_h)
#endif /* __APPLE__ */
}

#endif /* HAVE_PCAP_SET_TSTAMP_PRECISION */

#ifdef HAVE_BONDING
static bool
is_linux_bonding_device(const char *ifname)
Expand Down Expand Up @@ -1503,7 +1503,6 @@ open_capture_device_pcap_create(
return NULL;
}

#ifdef HAVE_PCAP_SET_TSTAMP_PRECISION
/*
* Try to enable nanosecond-resolution capture; any code
* that can read pcapng files must be able to handle
Expand All @@ -1527,9 +1526,7 @@ open_capture_device_pcap_create(
pcap_close(pcap_h);
return NULL;
}
#endif /* HAVE_PCAP_SET_TSTAMP_PRECISION */

#ifdef HAVE_PCAP_SET_TSTAMP_TYPE
if (interface_opts->timestamp_type) {
status = pcap_set_tstamp_type(pcap_h, interface_opts->timestamp_type_id);
/*
Expand All @@ -1543,7 +1540,6 @@ open_capture_device_pcap_create(
return NULL;
}
}
#endif /* HAVE_PCAP_SET_TSTAMP_PRECISION */

ws_debug("buffersize %d.", interface_opts->buffer_size);
if (interface_opts->buffer_size != 0) {
Expand Down Expand Up @@ -1584,13 +1580,11 @@ open_capture_device_pcap_create(
sizeof *open_status_str);
break;

#ifdef HAVE_PCAP_ERROR_PROMISC_PERM_DENIED
case PCAP_ERROR_PROMISC_PERM_DENIED:
*open_status = CAP_DEVICE_OPEN_ERROR_PROMISC_PERM_DENIED;
(void) g_strlcpy(*open_status_str, pcap_geterr(pcap_h),
sizeof *open_status_str);
break;
#endif

case PCAP_ERROR_RFMON_NOTSUP:
*open_status = CAP_DEVICE_OPEN_ERROR_RFMON_NOTSUP;
Expand Down Expand Up @@ -1632,13 +1626,11 @@ open_capture_device_pcap_create(
sizeof *open_status_str);
break;

#ifdef HAVE_PCAP_WARNING_TSTAMP_TYPE_NOTSUP
case PCAP_WARNING_TSTAMP_TYPE_NOTSUP:
*open_status = CAP_DEVICE_OPEN_WARNING_TSTAMP_TYPE_NOTSUP;
(void) g_strlcpy(*open_status_str, pcap_geterr(pcap_h),
sizeof *open_status_str);
break;
#endif

case PCAP_WARNING:
*open_status = CAP_DEVICE_OPEN_WARNING_OTHER;
Expand Down
2 changes: 0 additions & 2 deletions capture/capture-pcap-util.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,11 @@ bool set_pcap_datalink(pcap_t *pcap_h, int datalink, char *name,
char *errmsg, size_t errmsg_len,
char *secondary_errmsg, size_t secondary_errmsg_len);

#ifdef HAVE_PCAP_SET_TSTAMP_PRECISION
/*
* Return true if the pcap_t in question is set up for high-precision
* time stamps, false otherwise.
*/
bool have_high_resolution_timestamp(pcap_t *pcap_h);
#endif /* HAVE_PCAP_SET_TSTAMP_PRECISION */

/*
* Capture device open status values.
Expand Down
6 changes: 0 additions & 6 deletions capture/capture-wpcap.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ static int (*p_pcap_set_buffer_size)(pcap_t *, int);
static int (*p_pcap_activate)(pcap_t *);
static const char *(*p_pcap_statustostr)(int);

#ifdef HAVE_PCAP_SET_TSTAMP_TYPE
static int (*p_pcap_set_tstamp_type)(pcap_t *, int);
static int (*p_pcap_set_tstamp_precision)(pcap_t *, int);
static int (*p_pcap_get_tstamp_precision)(pcap_t *);
Expand All @@ -109,7 +108,6 @@ static void (*p_pcap_free_tstamp_types)(int *);
static int (*p_pcap_tstamp_type_name_to_val)(const char *);
static const char * (*p_pcap_tstamp_type_val_to_name)(int);
static const char * (*p_pcap_tstamp_type_val_to_description)(int);
#endif

typedef struct {
const char *name;
Expand Down Expand Up @@ -177,7 +175,6 @@ load_wpcap(void)
SYM(pcap_can_set_rfmon, false),
SYM(pcap_set_rfmon, false),
SYM(pcap_statustostr, false),
#ifdef HAVE_PCAP_SET_TSTAMP_TYPE
SYM(pcap_set_tstamp_type, true),
SYM(pcap_set_tstamp_precision, true),
SYM(pcap_get_tstamp_precision, true),
Expand All @@ -186,7 +183,6 @@ load_wpcap(void)
SYM(pcap_tstamp_type_name_to_val, true),
SYM(pcap_tstamp_type_val_to_name, true),
SYM(pcap_tstamp_type_val_to_description, true),
#endif
{ NULL, NULL, false }
};

Expand Down Expand Up @@ -630,7 +626,6 @@ pcap_statustostr(int a)
return p_pcap_statustostr(a);
}

#ifdef HAVE_PCAP_SET_TSTAMP_TYPE
int
pcap_set_tstamp_type(pcap_t *a, int b) {
ws_assert(has_npcap);
Expand Down Expand Up @@ -703,7 +698,6 @@ pcap_tstamp_type_val_to_description(int a) {
}
return NULL;
}
#endif

int
pcap_datalink_name_to_val(const char *name)
Expand Down
29 changes: 11 additions & 18 deletions cmake/modules/FindPCAP.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,6 @@ endif()
#
# # libpcap 1.5.0 (2013-11-07)
# check_symbol_exists(PCAP_ERROR_PROMISC_PERM_DENIED "pcap/pcap.h" HAVE_PCAP_ERROR_PROMISC_PERM_DENIED)
# # libpcap 1.2.1 (2012-01-01)
# check_symbol_exists(PCAP_WARNING_TSTAMP_TYPE_NOTSUP "pcap/pcap.h" HAVE_PCAP_WARNING_TSTAMP_TYPE_NOTSUP)
#
# if (NOT HAVE_PCAP_ERROR_PROMISC_PERM_DENIED)
# set(${validator_result_var} FALSE PARENT_SCOPE)
Expand Down Expand Up @@ -234,19 +232,18 @@ if(PCAP_FOUND)
set(HAVE_PCAP_OPEN TRUE)
set(HAVE_PCAP_SETSAMPLING TRUE)
set(HAVE_PCAP_SET_TSTAMP_PRECISION TRUE)
set(HAVE_PCAP_SET_TSTAMP_TYPE TRUE)
else(WIN32)
#
# Make sure we have at least libpcap 1.0, because we require at
# least libpcap 1.0's APIs.
# Make sure we have at least libpcap 1.5, because we require at
# least libpcap 1.5's APIs.
#
# We check whether pcap_create is defined in the pcap header,
# using it as a proxy for all the 1.0 API's. if not, we fail.
# We check whether pcap_set_tstamp_precision is defined in the pcap header,
# using it as a proxy for all the 1.5 API's. if not, we fail.
#
check_function_exists( "pcap_create" HAVE_PCAP_CREATE )
if( NOT HAVE_PCAP_CREATE )
message(FATAL_ERROR "You need libpcap 1.0 or later")
endif( NOT HAVE_PCAP_CREATE )
check_function_exists( "pcap_set_tstamp_precision" HAVE_PCAP_SET_TSTAMP_PRECISION )
if( NOT HAVE_PCAP_SET_TSTAMP_PRECISION )
message(FATAL_ERROR "You need libpcap 1.5 or later")
endif()

#
# macOS Sonoma's libpcap includes stub versions of the remote-
Expand Down Expand Up @@ -320,19 +317,15 @@ if(PCAP_FOUND)
endif( HAVE_PCAP_OPEN )
endif()

# This function became available in libpcap release 1.5.1. (2013-12-04)
check_function_exists( "pcap_set_tstamp_precision" HAVE_PCAP_SET_TSTAMP_PRECISION )
# This function became available in libpcap release 1.2.1. (2012-01-01)
check_function_exists( "pcap_set_tstamp_type" HAVE_PCAP_SET_TSTAMP_TYPE )
# Remote pcap checks
if( HAVE_PCAP_OPEN )
set( HAVE_PCAP_REMOTE 1 )
endif()

# libpcap 1.5.0 (2013-11-07)
check_symbol_exists(PCAP_ERROR_PROMISC_PERM_DENIED "pcap/pcap.h" HAVE_PCAP_ERROR_PROMISC_PERM_DENIED)
# libpcap 1.2.1 (2012-01-01)
check_symbol_exists(PCAP_WARNING_TSTAMP_TYPE_NOTSUP "pcap/pcap.h" HAVE_PCAP_WARNING_TSTAMP_TYPE_NOTSUP)
if( NOT HAVE_PCAP_ERROR_PROMISC_PERM_DENIED )
message(FATAL_ERROR "You need libpcap 1.5 or later")
endif()

cmake_pop_check_state()
endif()
Expand Down
19 changes: 3 additions & 16 deletions cmakeconfig.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -236,18 +236,6 @@
/* Define to 1 if you have the `pcap_setsampling' function. */
#cmakedefine HAVE_PCAP_SETSAMPLING 1

/* Define to 1 if you have the `pcap_set_tstamp_precision' function. */
#cmakedefine HAVE_PCAP_SET_TSTAMP_PRECISION 1

/* Define to 1 if you have the `pcap_set_tstamp_type' function. */
#cmakedefine HAVE_PCAP_SET_TSTAMP_TYPE 1

/* Define to 1 if you have the `PCAP_ERROR_PROMISC_PERM_DENIED' symbol. */
#cmakedefine HAVE_PCAP_ERROR_PROMISC_PERM_DENIED 1

/* Define to 1 if you have the `PCAP_WARNING_TSTAMP_TYPE_NOTSUP' symbol. */
#cmakedefine HAVE_PCAP_WARNING_TSTAMP_TYPE_NOTSUP 1

/* Define to 1 if you have the <pwd.h> header file. */
#cmakedefine HAVE_PWD_H 1

Expand Down Expand Up @@ -438,10 +426,9 @@
* The Npcap SDK, as of SDK version 1.04, provides them, so this is
* only necessary for building with the WinPcap SDK.
*
* WinPcap isn't supported at runtime anymore, but it's possible to build
* with the WinPcap SDK and run with Npcap, so long as this is defined.
* That's what currently happens when cross-compiling with Fedora Linux,
* which includes a MinGW WinPcap package.
* Building against the WinPcap SDK isn't supported anymore, nor is running
* with the WinPcap DLL installed, so needing this is very unlikely, though
* libpcap 1.9.0 or later is not yet required.
*/
#ifdef HAVE_PCAP_REMOTE
#define HAVE_REMOTE
Expand Down
4 changes: 0 additions & 4 deletions dumpcap.c
Original file line number Diff line number Diff line change
Expand Up @@ -3155,10 +3155,8 @@ capture_loop_open_input(capture_options *capture_opts, loop_data *ld,
if (pcap_src->pcap_h != NULL) {
/* we've opened "iface" as a network device */

#ifdef HAVE_PCAP_SET_TSTAMP_PRECISION
/* Find out if we're getting nanosecond-precision time stamps */
pcap_src->ts_nsec = have_high_resolution_timestamp(pcap_src->pcap_h);
#endif

#if defined(HAVE_PCAP_SETSAMPLING)
if (interface_opts->sampling_method != CAPTURE_SAMP_NONE) {
Expand Down Expand Up @@ -5949,7 +5947,6 @@ main(int argc, char *argv[])
exit_main(status);
}

#ifdef HAVE_PCAP_SET_TSTAMP_TYPE
for (j = 0; j < global_capture_opts.ifaces->len; j++) {
interface_options *interface_opts;

Expand All @@ -5962,7 +5959,6 @@ main(int argc, char *argv[])
}
}
}
#endif

/* We're supposed to do a capture, or print the BPF code for a filter. */

Expand Down
2 changes: 2 additions & 0 deletions epan/dissectors/asn1/cms/packet-cms-template.c
Original file line number Diff line number Diff line change
Expand Up @@ -209,4 +209,6 @@ void proto_reg_handoff_cms(void) {
dissector_add_string("media_type", "application/vnd.de-dke-k461-ic1+xml; encap=cms-tr03109", content_info_handle);
dissector_add_string("media_type", "application/vnd.de-dke-k461-ic1+xml; encap=cms-tr03109-zlib", content_info_handle);
dissector_add_string("media_type", "application/hgp;encap=cms", content_info_handle);

dissector_add_string("rfc7468.preeb_label", "CMS", content_info_handle);
}
2 changes: 1 addition & 1 deletion epan/dissectors/asn1/its/packet-its-template.c
Original file line number Diff line number Diff line change
Expand Up @@ -1080,7 +1080,7 @@ void proto_register_its(void)
#define ITS_TIS_TPG_PROT_VER 1
#define ITS_CPM_PROT_VERv1 1
#define ITS_CPM_PROT_VER 2
#define ITS_VAM_PROT_VER 2
#define ITS_VAM_PROT_VER 3
#define ITS_IMZM_PROT_VER 2

void proto_reg_handoff_its(void)
Expand Down
33 changes: 28 additions & 5 deletions epan/dissectors/asn1/ngap/packet-ngap-template.c
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ static int ett_ngap_successfulPSCellChangeReportContainer;
#include "packet-ngap-ett.c"

static expert_field ei_ngap_number_pages_le15;
static expert_field ei_ngap_disable_nrppa_encapsulation;

enum{
INITIATING_MESSAGE,
Expand Down Expand Up @@ -566,6 +567,7 @@ static const enum_val_t ngap_lte_container_vals[] = {
/* Global variables */
static range_t *gbl_ngapSctpRange;
static bool ngap_dissect_container = true;
static bool ngap_disable_nrppa_encapsulation = false;
static int ngap_dissect_target_ng_ran_container_as = NGAP_NG_RAN_CONTAINER_AUTOMATIC;
static int ngap_dissect_lte_container_as = NGAP_LTE_CONTAINER_AUTOMATIC;

Expand Down Expand Up @@ -984,12 +986,18 @@ find_n2_info_content(char *json_data, jsmntok_t *token, const char *n2_info_cont
if (!str || strcmp(str, content_id))
return false;
str = json_get_string(json_data, n2_info_content_token, "ngapIeType");
if (str)
*subdissector = dissector_get_string_handle(ngap_n2_ie_type_dissector_table, str);
else if (json_get_double(json_data, n2_info_content_token, "ngapMessageType", &ngap_msg_type))
if (str) {
if (!strcmp(str, "NRPPA_PDU") && ngap_disable_nrppa_encapsulation) {
*subdissector = nrppa_handle;
} else {
*subdissector = dissector_get_string_handle(ngap_n2_ie_type_dissector_table, str);
}
} else if (json_get_double(json_data, n2_info_content_token,
"ngapMessageType", &ngap_msg_type)) {
*subdissector = ngap_handle;
else
} else {
*subdissector = NULL;
}
return true;
}

Expand Down Expand Up @@ -1100,6 +1108,11 @@ dissect_ngap_media_type(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, voi
if (subdissector != ngap_handle) {
ngap_item = proto_tree_add_item(tree, proto_ngap, tvb, 0, -1, ENC_NA);
ngap_tree = proto_item_add_subtree(ngap_item, ett_ngap);
if (ngap_disable_nrppa_encapsulation && subdissector == nrppa_handle) {
expert_add_info_format(pinfo, ngap_item,
&ei_ngap_disable_nrppa_encapsulation,
"Encapsulation of NRPPa in NGAP is disabled");
}
} else {
ngap_tree = tree;
}
Expand Down Expand Up @@ -1489,7 +1502,10 @@ void proto_register_ngap(void) {
};

static ei_register_info ei[] = {
{ &ei_ngap_number_pages_le15, { "ngap.number_pages_le15", PI_MALFORMED, PI_ERROR, "Number of pages should be <=15", EXPFILL }}
{ &ei_ngap_number_pages_le15, { "ngap.number_pages_le15", PI_MALFORMED, PI_ERROR, "Number of pages should be <=15", EXPFILL }},
{ &ei_ngap_disable_nrppa_encapsulation,
{ "ngap.disable_nrppa_encapsulation", PI_PROTOCOL, PI_CHAT, "Encapsulation of NRPPa in NGAP is disabled", EXPFILL }
}
};

module_t *ngap_module;
Expand Down Expand Up @@ -1524,6 +1540,13 @@ void proto_register_ngap(void) {
"Dissect TransparentContainer",
"Dissect TransparentContainers that are opaque to NGAP",
&ngap_dissect_container);
prefs_register_bool_preference(ngap_module, "disable_nrppa_encapsulation",
"Disable encapsulation of NRPPa in NGAP",
"The standard indicates that NRPPa PDU must "
"be encapsulated in ngap.NRPPa-PDU ASN1 type. "
"However, Huawei AMF use the NRPPa ASN1 type "
"directly.",
&ngap_disable_nrppa_encapsulation);
prefs_register_enum_preference(ngap_module, "dissect_target_ng_ran_container_as",
"Dissect target NG-RAN container as",
"Select whether target NG-RAN container should be decoded automatically"
Expand Down
Loading

0 comments on commit 3825a2b

Please sign in to comment.