summaryrefslogtreecommitdiff
path: root/comms
diff options
context:
space:
mode:
authorjnemeth <jnemeth@pkgsrc.org>2021-06-13 07:47:18 +0000
committerjnemeth <jnemeth@pkgsrc.org>2021-06-13 07:47:18 +0000
commit90f1883839ffa8b75f9088ad371bacf2c6102233 (patch)
tree92e5ac075a693ac888dc996fd27651769fcfe4d5 /comms
parent8d38f5eec124c94d932859b6feb6bcdd7594767c (diff)
downloadpkgsrc-90f1883839ffa8b75f9088ad371bacf2c6102233.tar.gz
Import Asterisk 18.x as comms/asterisk18.
This is a long term support version. It is scheduled to go to security fixes only on October 20th, 2024, and EOL on October 20th, 2025. ------------------------------------------------------------------------------ --- Functionality changes from Asterisk 18.3.0 to Asterisk 18.4.0 ------------ ------------------------------------------------------------------------------ logger ------------------ * The dateformat option in logger.conf will now control the remote console (asterisk -r -T) timestamp format. Previously, dateformat only controlled the formatting of the timestamp going to log files and the main console (asterisk -c) but only for non-verbose messages. Internally, Asterisk does not send the logging timestamp with verbose messages to console clients. It's up to the Asterisk remote consoles to format verbose messages. Asterisk remote consoles previously did not load dateformat from logger.conf. Previously there was a non-configurable and hard-coded "%b %e %T" dateformat that would be used no matter what on all verbose console messages printed on remote consoles. Example: logger.conf dateformat=%F %T.%3q # asterisk -rvvv -T [2021-03-19 09:54:19.760-0400] Loading res_stasis_answer.so. [Mar 19 09:55:43] -- Goto (dialExten,s,1) Given the following example configuration in logger.conf, Asterisk log files and the console, will log verbose messages using the given timestamp. Now ensuring that all remote console messages are logged with the same dateformat as other log streams. --- [general] dateformat=%F %T.%3q [logfiles] console => notice,warning,error,verbose full => notice,warning,error,debug,verbose --- Now we have a globally-defined dateformat that will be used consistently across the Asterisk main console, remote consoles, and log files. Now we have consistent logging: # asterisk -rvvv -T [2021-03-19 09:54:19.760-0400] Loading res_stasis_answer.so. [2021-03-19 09:55:43.920-0400] -- Goto (dialExten,s,1) res_pjsip ------------------ * PJSIP transports can now be partially reloaded safely. This allows the local_net and external_* options to be updated without restarting Asterisk. * PJSIP endpoints can now be configured to skip authentication when handling OPTIONS requests by setting the allow_unauthenticated_options configuration property to 'yes.' ------------------------------------------------------------------------------ --- Functionality changes from Asterisk 18.2.2 to Asterisk 18.3.0 ------------ ------------------------------------------------------------------------------ app_mixmonitor ------------------ * app_mixmonitor now sends manager events MixMonitorStart, MixMonitorStop and MixMonitorMute when the channel monitoring is started, stopped and muted (or unmuted) respectively. chan_iax2 ------------------ * You can now specify a default "auth" method in the [general] section of iax.conf chan_pjsip, app_transfer ------------------ * Added TRANSFERSTATUSPROTOCOL variable. When transfer is performed, transfers can pass a protocol specific error code. Example, in SIP 3xx-6xx represent any SIP specific error received when performing a REFER. func_odbc ------------------ * Introduce an ARGC variable for func_odbc functions, along with a minargs per-function configuration option. minargs enables enforcing of minimum count of arguments to pass to func_odbc, so if you're unconditionally using ARG1 through ARG4 then this should be set to 4. func_odbc will generate an error in this case, so for example [FOO] minargs = 4 and ODBC_FOO(a,b,c) in dialplan will now error out instead of using a potentially leaked ARG4 from Gosub(). ARGC is needed if you're using optional argument, to verify whether or not an argument has been passed, else it's possible to use a leaked ARGn from Gosub (app_stack). So now you can safely do ${IF($[${ARGC}>3]?${ARGV}:default value)} kind of thing. res_srtp ------------------ * SRTP replay protection has been added to res_srtp and a new configuration option "srtpreplayprotection" has been added to the rtp.conf config file. For security reasons, the default setting is "yes". Buggy clients may not handle this correctly which could result in no, or one way, audio and Asterisk error messages like "replay check failed". ------------------------------------------------------------------------------ --- Functionality changes from Asterisk 18.1.0 to Asterisk 18.2.0 ------------ ------------------------------------------------------------------------------ Core ------------------ * The location where the media cache stores its temporary files is no longer hardcoded to /tmp but can now be configured separately via the astcachedir config variable in asterisk.conf. To retain backwards compatibility, the default location remains /tmp. app_voicemail ------------------ * The VoiceMail application can now be configured to send greetings and instructions via early media and only answering the channel when it is time for the caller to record their message. This behavior can be activated by passing the new 'e' option to VoiceMail. ------------------------------------------------------------------------------ --- Functionality changes from Asterisk 18.0.0 to Asterisk 18.1.0 ------------ ------------------------------------------------------------------------------ Core ------------------ * Added debug logging categories that allow a user to output debug information based on a specified category. This lets the user limit, and filter debug output to data relevant to a particular context, or topic. For instance the following categories are now available for debug logging purposes: dtls, dtls_packet, ice, rtcp, rtcp_packet, rtp, rtp_packet, stun, stun_packet These debug categories can be enable/disable via an Asterisk CLI command: core set debug category <category>[:<sublevel>] [category[:<sublevel] ...] core set debug category off [<category> [<category>] ...] If no sub-level is associated all debug statements for a given category are output. If a sub-level is given then only those statements assigned a value at or below the associated sub-level are output. app_confbridge ------------------ * app_confbridge now has the ability to force the estimated bitrate on an SFU bridge. To use it, set a bridge profile's remb_behavior to "force" and set remb_estimated_bitrate to a rate in bits per second. The remb_estimated_bitrate parameter is ignored if remb_behavior is something other than "force". ------------------------------------------------------------------------------ --- Functionality changes from Asterisk 17.0.0 to Asterisk 18.0.0 ------------ ------------------------------------------------------------------------------ chan_pjsip ------------------ * The PJSIP_SEND_SESSION_REFRESH dialplan function now issues a warning, and returns unsuccessful if it's used on a channel prior to answering. logger ------------------ * Added a new log formatter called "plain" that always prints file, function and line number if available (even for verbose messages) and never prints color control characters. Most suitable for file output but can be used for other channels as well. You use it in logger.conf like so: debug => [plain]debug console => [plain]error,warning,debug,notice,pjsip_history messages => [plain]warning,error,verbose ------------------------------------------------------------------------------ --- New functionality introduced in Asterisk 18.0.0 -------------------------- ------------------------------------------------------------------------------ Core ------------------ * The Streams API becomes the home for the core ACN capabilities. These include... * Parsing and formatting of codec negotation preferences. * Resolving pending streams and topologies with those configured using configured preferences. * Utility functions for creating string representations of streams, topologies, and negotiation preferences. For codec negotiation preferences: * Added ast_stream_codec_prefs_parse() which takes a string representation of codec negotiation preferences, which may come from a pjsip endpoint for example, and populates a ast_stream_codec_negotiation_prefs structure. * Added ast_stream_codec_prefs_to_str() which does the reverse. * Added many functions to parse individual parameter name and value strings to their respectrive enum values, and the reverse. For streams: * Added ast_stream_create_resolved() which takes a "live" stream and resolves it with a configured stream and the negotiation preferences to create a new stream. * Added ast_stream_to_str() which create a string representation of a stream suitable for debug or display purposes. For topology: * Added ast_stream_topology_create_resolved() which takes a "live" topology and resolves it, stream by stream, with a configured topology stream and the negotiation preferences to create a new topology. * Added ast_stream_topology_to_str() which create a string representation of a topology suitable for debug or display purposes. * Renamed ast_format_caps_from_topology() to ast_stream_topology_get_formats() to be more consistent with the existing ast_stream_get_formats(). Additional changes: * A new function ast_format_cap_append_names() appends the results to the ast_str buffer instead of replacing buffer contents. app_bridgeaddchan ------------------ * The BridgeAdd application now behaves more like the Bridge application. The application now sets the BRIDGERESULT channel variable to indicate what happened when the channel resumes in dialplan. This is instead of hanging up the channel on failure conditions. res_pjsip ------------------ * Two new options, incoming_call_offer_pref and outgoing_call_offer_pref have been added to res_pjsip endpoints that specify the preferred order of codecs to use between those received/sent in an SDP offer and those set in the endpoint configuration. ------------------------------------------------------------------------------ --- Functionality changes from Asterisk 17.0.0 to Asterisk 18.0.0 ------------ ------------------------------------------------------------------------------ AMI ------------------ * You can now specify an optional 'Content-Type' as an argument for the Asterisk SendText manager action. ARI ------------------ * A new parameter 'inhibitConnectedLineUpdates' is now available in the 'bridges.addChannel' call. This prevents the identity of the newly connected channel from being presented to other bridge members. ARI Channels ------------------ * The Channel resource has a new sub-resource "externalMedia". This allows an application to create a channel for the sole purpose of exchanging media with an external server. Once created, this channel could be placed into a bridge with existing channels to allow the external server to inject audio into the bridge or receive audio from the bridge. See https://wiki.asterisk.org/wiki/display/AST/External+Media+and+ARI for more information. Core ------------------ * H.265/HEVC is now a supported video codec and it can be used by specifying "h265" in the allow line. Please note however, that handling of the additional SDP parameters described in RFC 7798 section 7.2 is not yet supported. Features ------------------ * Adds support for AudioSocket, a very simple bidirectional audio streaming protocol. There are both channel and application interfaces. A description of the protocol can be found on the referenced wiki page. A short talk about the reasons and implementation can be found on YouTube at the link provided. ARI support has also been added via the existing "externalMedia" ARI functionality. The UUID is specified using the arbitrary "data" field. Wiki: https://wiki.asterisk.org/wiki/display/AST/AudioSocket YouTube: https://www.youtube.com/watch?v=tjduXbZZEgI Messaging ------------------ * In order to reduce the amount of AMI and ARI events generated, the global "Message/ast_msg_queue" channel can be set to suppress it's normal channel housekeeping events such as "Newexten", "VarSet", etc. This can greatly reduce load on the manager and ARI applications when the Digium Phone Module for Asterisk is in use. To enable, set "hide_messaging_ami_events" in asterisk.conf to "yes" In Asterisk versions <18, the default is "no" preserving existing behavior. Beginning with Asterisk 18, the option will default to "yes". STIR/SHAKEN ------------------ * STIR/SHAKEN support has been added to Asterisk. Configuration is done in stir_shaken.conf. There is a sample configuration file to help you get started (asterisk/configs/samples/stir_shaken.conf.sample). Once that's set up, you can enable STIR/SHAKEN on any endpoint by setting stir_shaken to yes on the endpoint configuration object. This will add an Identity header on outgoing INVITEs, and check for an Identity header on incoming INVITEs. This option has been added to Alembic as well. The information received on an incoming INVITE can be checked using the STIR_SHAKEN dialplan function. There are two variations: STIR_SHAKEN(count) STIR_SHAKEN(0, verify_result) The first variation will tell you how many STIR/SHAKEN results are on the channel. The second fetches information for a specific result. The first parameter is the index, followed by what information you want to retrieve. The available options are 'verify_result', 'identity', and 'attestation'. app_chanisavail ------------------ * The ChanIsAvail application now tolerates empty positions in the supplied device list. Dialplan can now be simplified by not having to check for empty positions in the device list. app_confbridge ------------------ * A new bridge profile option, maximum_sample_rate, has been added which sets a maximum sample rate that the bridge will be mixed at. This allows the bridge to move below the maximum sample rate as needed but caps it at the maximum. * A new option, "text_messaging", has been added to the user profile which allows control over whether text messaging is enabled or disabled for a user. If enabled (the default) text messages will be sent to the user. If disabled no text messages will be sent to the user. app_dial ------------------ * The Dial application now tolerates empty positions in the supplied destination list. Dialplan can now be simplified by not having to check for empty positions in the destination list. If there are no endpoints to dial then DIALSTATUS is set to CHANUNAVAIL. app_mixmonitor ------------------ * An option 'S' has been added to MixMonitor. If used in combination with the r() and/or t() options, if a frame is available to write to one of those files but not the other, a frame of silence if written to the file that does not have an audio frame. This should prevent the two files from "drifting" when mixed after the fact. * If the 'filename' argument to MixMonitor() ended with '.wav49,' Asterisk would silently convert the extension to '.WAV' when opening the file for writing. This caused the MIXMONITOR_FILENAME variable to reference the wrong file. The MIXMONITOR_FILENAME variable will now reflect the name of the file that Asterisk actually used instead of the filename that was passed to the application. app_page ------------------ * The Page application now tolerates empty positions in the supplied destination list. Dialplan can now be simplified by not having to check for empty positions in the destination list. app_voicemail ------------------ * A feature was added in Asterisk 13.27.0 and 16.4.0 that removed lock files from the Asterisk voicemail directory on startup. Some users that store their voicemails on network storage devices experienced slow startup times due to the relative expense of traversing the voicemail directory structure looking for orphaned lock files. This feature has now been removed. Users who require the lock files to be removed at startup should modify their startup scripts to do so before starting the asterisk process. chan_pjsip ------------------ * A new dialplan function, PJSIP_MOH_PASSTRHOUGH, has been added to chan_pjsip. This allows the behaviour of the moh_passthrough endpoint option to be read or changed in the dialplan. This allows control on a per-call basis. chan_rtp ------------------ * The UnicastRTP channel driver provided by chan_rtp now accepts "<hostname>:<port>" as an alternative to "<ip_address>:<port>" in the destination. The first AAAA (preferred) or A record resolved will be used as the destination. The lookup is synchronous so beware of possible dialplan delays if you specify a hostname. func_curl ------------------ * A new parameter, httpheader, has been added to CURLOPT function. This parameter allows to set custom http headers for subsequent calls of CURL function. Any setting of headers will replace the default curl headers (e.g. "Content-type: application/x-www-form-urlencoded") * A new option, followlocation, can now be enabled with the CURLOPT() dialplan function. Setting this will instruct cURL to follow 3xx redirects, which it does not by default. func_jitterbuffer ------------------ * The JITTERBUFFER dialplan function now has an option to enable video synchronization support. When enabled and used with a compatible channel driver (chan_sip, chan_pjsip) the video is buffered according to the size of the audio jitterbuffer and is synchronized to the audio. func_volume ------------------ * Accept decimal number as argument. http ------------------ * You can now disable the /httpstatus page served by Asterisk's built-in HTTP server by setting 'enable_status' to 'no' in http.conf. minmemfree ------------------ * The 'minmemfree' configuration option now counts memory allocated to the filesystem cache as "free" because it is memory that is available to the process. res_ari_channels ------------------ * When creating a channel in ARI using the create call you can now specify dialplan variables to be set as part of the same operation. res_musiconhold ------------------ * This fix allows a realtime moh class to be unregistered from the command line. This is useful when the contents of a directory referenced by a realtime moh class have changed. The realtime moh class is then reloaded on the next request and uses the new directory contents. * A new mode - playlist - has been added to res_musiconhold. This mode allows the user to specify the files (or URLs) to play explicitly by putting them directly in musiconhold.conf. res_pjsip ------------------ * Added a new PJSIP system setting called disable_rport. Default is no to keep support working as before. If it is false (default) it adds the 'rport' parameter in the outgoing request message. If it is true it does not add the 'rport' parameter in the outgoing request message. This is a system option, but working as a global option. res_pjsip_endpoint_identifier_ip ------------------ * In 'type = identify' sections, the addresses specified for the 'match' clause can now include a port number. For IP addresses, the port is provided by including a colon after the address, followed by the desired port number. If supplied, the netmask should follow the port number. To specify a port for IPv6 addresses, the address itself must be enclosed in brackets to be parsed correctly. res_pjsip_logger ------------------ * The PJSIP packet logger now has the following CLI commands: pjsip set logger pcap <filename> When used this will create a pcap file containing the incoming and outgoing SIP packets, in unencrypted form. pjsip set logger console <on / off> This allows you to toggle logging to console on and off. pjsip set logger host <IP/subnet mask> add This allows you to add an additional IP address or subnet mask to logging, allowing you to log multiple instead of just a single IP address or all traffic. The normal "pjsip set logger host" CLI command has also been expanded to allow subnet masks as well. res_pjsip_session ------------------ * When placing an outgoing call to a PJSIP endpoint the intent of any requested formats will now be respected. If only an audio format is requested (such as ulaw) but the underlying endpoint does not support the format the resulting SDP will still only contain an audio stream, and not any additional streams such as video. * Two new options, incoming_call_offer_pref and outgoing_call_offer_pref have been added to res_pjsip endpoints that specify the preferred order of codecs to use between those received/sent in an SDP offer and those set in the endpoint configuration. res_rtp_asterisk ------------------ * This change include a new cli command 'rtp show settings' The command display by general settings of rtp configuration. For this point is added the fields: rtpstart, rtpend, dtmftimeout, rtpchecksum, strictrtp, learning_min_sequential and icesupport. * The blacklist mechanism in res_rtp_asterisk for ICE and STUN was converted to an ACL mechanism. As such six new options are now available: ice_deny ice_permit ice_acl stun_deny stun_permit stun_acl These options have their obvious meanings as used elsewhere. Backwards compatibility was maintained by adding {stun,ice}_blacklist as aliases for {stun,ice}_deny. res_sorcery_memory_cache ------------------ * The SorceryMemoryCacheExpireObject AMI action and CLI command allow expiring of a specific object within the sorcery memory cache. This is done by removing the object from the cache with the expectation that the cache will then re-populate the object when it is next needed. For full backend caching this does not occur. The cache won't repopulate until an entire refresh is done resulting in the possibility that objects are missing until that time. The AMI action and CLI command will now not allow expiring of an object if the cache is configured as a full backend cache. Instead you must use either the SorceryMemoryCacheExpire or SorceryMemoryCachePopulate AMI actions or their associated CLI commands. taskprocessor.c ------------------ * Added two new CLI commands to reset stats for taskprocessors. You can reset stats for a single, specific taskprocessor ('core reset taskprocessor <taskprocessor>'), or you can reset all taskprocessors ('core reset taskprocessors'). These commands will reset the counter for the number of tasks processed as well as the max queue size. * Added "like" support for 'core show taskprocessors'. Now you can specify a specific set of taskprocessors (or just one) by adding the keyword "like" to the above command, followed by your search criteria.
Diffstat (limited to 'comms')
-rw-r--r--comms/asterisk18/files/smf/manifest.xml34
-rw-r--r--comms/asterisk18/patches/patch-Makefile134
-rw-r--r--comms/asterisk18/patches/patch-addons_chan__ooh323.c13
-rw-r--r--comms/asterisk18/patches/patch-apps_app__adsiprog.c22
-rw-r--r--comms/asterisk18/patches/patch-apps_app__chanspy.c13
-rw-r--r--comms/asterisk18/patches/patch-apps_app__directory.c13
-rw-r--r--comms/asterisk18/patches/patch-apps_app__dumpchan.c22
-rw-r--r--comms/asterisk18/patches/patch-apps_app__followme.c22
-rw-r--r--comms/asterisk18/patches/patch-apps_app__minivm.c13
-rw-r--r--comms/asterisk18/patches/patch-apps_app__queue.c132
-rw-r--r--comms/asterisk18/patches/patch-apps_app__sms.c102
-rw-r--r--comms/asterisk18/patches/patch-apps_app__voicemail.c76
-rw-r--r--comms/asterisk18/patches/patch-build__tools_mkpkgconfig19
-rw-r--r--comms/asterisk18/patches/patch-cdr_cdr__pgsql.c31
-rw-r--r--comms/asterisk18/patches/patch-cel_cel__pgsql.c13
-rw-r--r--comms/asterisk18/patches/patch-channels_chan__pjsip.c32
-rw-r--r--comms/asterisk18/patches/patch-channels_chan__sip.c40
-rw-r--r--comms/asterisk18/patches/patch-channels_pjsip_cli__commands.c33
-rw-r--r--comms/asterisk18/patches/patch-channels_pjsip_dialplan__functions.c32
-rw-r--r--comms/asterisk18/patches/patch-configure222
-rw-r--r--comms/asterisk18/patches/patch-configure.ac34
-rw-r--r--comms/asterisk18/patches/patch-contrib_scripts_vmail.cgi181
-rw-r--r--comms/asterisk18/patches/patch-funcs_func__cdr.c13
-rw-r--r--comms/asterisk18/patches/patch-funcs_func__channel.c13
-rw-r--r--comms/asterisk18/patches/patch-funcs_func__env.c49
-rw-r--r--comms/asterisk18/patches/patch-funcs_func__pjsip__aor.c22
-rw-r--r--comms/asterisk18/patches/patch-funcs_func__pjsip__contact.c22
-rw-r--r--comms/asterisk18/patches/patch-funcs_func__pjsip__endpoint.c23
-rw-r--r--comms/asterisk18/patches/patch-funcs_func__strings.c40
-rw-r--r--comms/asterisk18/patches/patch-include_asterisk_autoconfig.h.in27
-rw-r--r--comms/asterisk18/patches/patch-include_asterisk_lock.h31
-rw-r--r--comms/asterisk18/patches/patch-include_asterisk_sha1.h131
-rw-r--r--comms/asterisk18/patches/patch-include_asterisk_strings.h40
-rw-r--r--comms/asterisk18/patches/patch-main_Makefile38
-rw-r--r--comms/asterisk18/patches/patch-main_acl.c40
-rw-r--r--comms/asterisk18/patches/patch-main_app.c13
-rw-r--r--comms/asterisk18/patches/patch-main_ast__expr2.c16
-rw-r--r--comms/asterisk18/patches/patch-main_ast__expr2.y16
-rw-r--r--comms/asterisk18/patches/patch-main_asterisk.c40
-rw-r--r--comms/asterisk18/patches/patch-main_astmm.c13
-rw-r--r--comms/asterisk18/patches/patch-main_bridge__basic.c13
-rw-r--r--comms/asterisk18/patches/patch-main_callerid.c28
-rw-r--r--comms/asterisk18/patches/patch-main_cdr.c25
-rw-r--r--comms/asterisk18/patches/patch-main_cel.c13
-rw-r--r--comms/asterisk18/patches/patch-main_cli.c22
-rw-r--r--comms/asterisk18/patches/patch-main_conversions.c13
-rw-r--r--comms/asterisk18/patches/patch-main_dns__naptr.c40
-rw-r--r--comms/asterisk18/patches/patch-main_enum.c76
-rw-r--r--comms/asterisk18/patches/patch-main_features.c20
-rw-r--r--comms/asterisk18/patches/patch-main_http.c13
-rw-r--r--comms/asterisk18/patches/patch-main_indications.c13
-rw-r--r--comms/asterisk18/patches/patch-main_logger.c22
-rw-r--r--comms/asterisk18/patches/patch-main_manager.c83
-rw-r--r--comms/asterisk18/patches/patch-main_pbx.c13
-rw-r--r--comms/asterisk18/patches/patch-main_pbx__builtins.c33
-rw-r--r--comms/asterisk18/patches/patch-main_pbx__timing.c13
-rw-r--r--comms/asterisk18/patches/patch-main_sched.c27
-rw-r--r--comms/asterisk18/patches/patch-main_stdtime_localtime.c147
-rw-r--r--comms/asterisk18/patches/patch-main_tdd.c13
-rw-r--r--comms/asterisk18/patches/patch-main_test.c13
-rw-r--r--comms/asterisk18/patches/patch-main_utils.c60
-rw-r--r--comms/asterisk18/patches/patch-menuselect_menuselect.c22
-rw-r--r--comms/asterisk18/patches/patch-pbx_pbx__config.c22
-rw-r--r--comms/asterisk18/patches/patch-pbx_pbx__dundi.c40
-rw-r--r--comms/asterisk18/patches/patch-res_ael_pval.c41
-rw-r--r--comms/asterisk18/patches/patch-res_res__calendar.c37
-rw-r--r--comms/asterisk18/patches/patch-res_res__calendar__caldav.c13
-rw-r--r--comms/asterisk18/patches/patch-res_res__calendar__icalendar.c13
-rw-r--r--comms/asterisk18/patches/patch-res_res__hep__pjsip.c23
-rw-r--r--comms/asterisk18/patches/patch-res_res__limit.c13
-rw-r--r--comms/asterisk18/patches/patch-res_res__musiconhold.c13
-rw-r--r--comms/asterisk18/patches/patch-res_res__pjproject.c31
-rw-r--r--comms/asterisk18/patches/patch-res_res__xmpp.c13
-rw-r--r--comms/asterisk18/patches/patch-sounds_Makefile25
-rw-r--r--comms/asterisk18/patches/patch-tests_test__locale.c13
-rw-r--r--comms/asterisk18/patches/patch-tests_test__voicemail__api.c13
-rw-r--r--comms/asterisk18/patches/patch-utils_Makefile24
-rw-r--r--comms/asterisk18/patches/patch-utils_db1-ast_include_db.h13
-rw-r--r--comms/asterisk18/patches/patch-utils_extconf.c67
-rw-r--r--comms/asterisk18/patches/patch-utils_smsq.c13
80 files changed, 2969 insertions, 0 deletions
diff --git a/comms/asterisk18/files/smf/manifest.xml b/comms/asterisk18/files/smf/manifest.xml
new file mode 100644
index 00000000000..d68dff50919
--- /dev/null
+++ b/comms/asterisk18/files/smf/manifest.xml
@@ -0,0 +1,34 @@
+<?xml version="1.0"?>
+<!DOCTYPE service_bundle SYSTEM "/usr/share/lib/xml/dtd/service_bundle.dtd.1">
+<service_bundle type="manifest" name="export">
+ <service name="@SMF_PREFIX@/@SMF_NAME@" type="service" version="1">
+ <create_default_instance enabled="false" />
+ <single_instance />
+ <dependency name='network' grouping='require_all' restart_on='error' type='service'>
+ <service_fmri value='svc:/milestone/network:default' />
+ </dependency>
+ <dependency name='filesystem-local' grouping='require_all' restart_on='none' type='service'>
+ <service_fmri value='svc:/system/filesystem/local:default' />
+ </dependency>
+ <method_context>
+ <method_environment>
+ <envvar name="LD_PRELOAD_32" value="/usr/lib/extendedFILE.so.1" />
+ </method_environment>
+ </method_context>
+ <exec_method type="method" name="start" exec="@PREFIX@/sbin/asterisk" timeout_seconds="60" />
+ <exec_method type="method" name="stop" exec="@PREFIX@/sbin/asterisk -nr -x 'core stop gracefully' >/dev/null" timeout_seconds="60" />
+ <exec_method type="method" name="refresh" exec="@PREFIX@/sbin/asterisk -nr -x 'core reload' >/dev/null" timeout_seconds="60" />
+ <property_group name="startd" type="framework">
+ <propval name="duration" type="astring" value="contract" />
+ <propval name="ignore_error" type="astring" value="core,signal" />
+ </property_group>
+ <property_group name="application" type="application">
+ <propval name="config_file" type="astring" value="@PKG_SYSCONFDIR@/asterisk.conf" />
+ </property_group>
+ <template>
+ <common_name>
+ <loctext xml:lang="C">Asterisk PBX</loctext>
+ </common_name>
+ </template>
+ </service>
+</service_bundle>
diff --git a/comms/asterisk18/patches/patch-Makefile b/comms/asterisk18/patches/patch-Makefile
new file mode 100644
index 00000000000..86b864328dd
--- /dev/null
+++ b/comms/asterisk18/patches/patch-Makefile
@@ -0,0 +1,134 @@
+$NetBSD: patch-Makefile,v 1.1.1.1 2021/06/13 07:47:18 jnemeth Exp $
+
+--- Makefile.orig 2021-05-06 15:34:57.000000000 +0000
++++ Makefile
+@@ -143,7 +143,7 @@ DEBUG=-g3
+
+ # Asterisk.conf is located in ASTETCDIR or by using the -C flag
+ # when starting Asterisk
+-ASTCONFPATH=$(ASTETCDIR)/asterisk.conf
++ASTCONFPATH=$(ASTEXAMPLEDIR)/asterisk.conf
+ AGI_DIR=$(ASTDATADIR)/agi-bin
+
+ # If you use Apache, you may determine by a grep 'DocumentRoot' of your httpd.conf file
+@@ -215,12 +215,6 @@ ifeq ($(AST_DEVMODE),yes)
+ endif
+ endif
+
+-ifeq ($(OSARCH),NetBSD)
+- _ASTCFLAGS+=-isystem /usr/pkg/include
+-else ifneq ($(findstring BSD,$(OSARCH)),)
+- _ASTCFLAGS+=-isystem /usr/local/include
+-endif
+-
+ ifeq ($(OSARCH),FreeBSD)
+ # -V is understood by BSD Make, not by GNU make.
+ BSDVERSION=$(shell make -V OSVERSION -f /usr/share/mk/bsd.port.subdir.mk)
+@@ -435,7 +429,6 @@ dist-clean: distclean
+
+ distclean: $(SUBDIRS_DIST_CLEAN) _clean
+ @$(MAKE) -C menuselect dist-clean
+- @$(MAKE) -C sounds dist-clean
+ rm -f menuselect.makeopts makeopts menuselect-tree menuselect.makedeps
+ rm -f config.log config.status config.cache
+ rm -rf autom4te.cache
+@@ -493,7 +486,7 @@ doc/core-en_US.xml: makeopts .lastclean
+ MODULEINFO=$$($(AWK) -f build_tools/get_moduleinfo $$i) ; \
+ if [ -n "$$MODULEINFO" ] ; \
+ then \
+- echo "<module language=\"en_US\" name=\"`$(BASENAME) -s .c $$i`\">" >> $@ ; \
++ echo "<module language=\"en_US\" name=\"`$(BASENAME) $$i .c`\">" >> $@ ; \
+ echo "$$MODULEINFO" >> $@ ; \
+ echo "</module>" >> $@ ; \
+ fi ; \
+@@ -563,7 +556,7 @@ update:
+
+ NEWHEADERS=$(notdir $(wildcard include/asterisk/*.h))
+ OLDHEADERS=$(filter-out $(NEWHEADERS) $(notdir $(DESTDIR)$(ASTHEADERDIR)),$(notdir $(wildcard $(DESTDIR)$(ASTHEADERDIR)/*.h)))
+-INSTALLDIRS="$(ASTLIBDIR)" "$(ASTMODDIR)" "$(ASTSBINDIR)" "$(ASTCACHEDIR)" "$(ASTETCDIR)" "$(ASTVARRUNDIR)" \
++INSTALLDIRS="$(ASTLIBDIR)" "$(ASTMODDIR)" "$(ASTSBINDIR)" "$(ASTCACHEDIR)" "$(ASTEXAMPLEDIR)" "$(ASTVARRUNDIR)" \
+ "$(ASTSPOOLDIR)" "$(ASTSPOOLDIR)/dictate" "$(ASTSPOOLDIR)/meetme" \
+ "$(ASTSPOOLDIR)/monitor" "$(ASTSPOOLDIR)/system" "$(ASTSPOOLDIR)/tmp" \
+ "$(ASTSPOOLDIR)/voicemail" "$(ASTSPOOLDIR)/recording" \
+@@ -769,7 +762,7 @@ upgrade: bininstall
+ # (2) the extension to strip off
+ define INSTALL_CONFIGS
+ @for x in $(1)/*$(2); do \
+- dst="$(DESTDIR)$(ASTETCDIR)/`$(BASENAME) $$x $(2)`"; \
++ dst="$(DESTDIR)$(ASTEXAMPLEDIR)/`$(BASENAME) $$x $(2)`"; \
+ if [ -f "$${dst}" ]; then \
+ if [ "$(OVERWRITE)" = "y" ]; then \
+ if cmp -s "$${dst}" "$$x" ; then \
+@@ -799,9 +792,9 @@ define INSTALL_CONFIGS
+ -e 's|^astrundir.*$$|astrundir => $(ASTVARRUNDIR)|' \
+ -e 's|^astlogdir.*$$|astlogdir => $(ASTLOGDIR)|' \
+ -e 's|^astsbindir.*$$|astsbindir => $(ASTSBINDIR)|' \
+- "$(DESTDIR)$(ASTCONFPATH)" > "$(DESTDIR)$(ASTCONFPATH).tmp" ; \
+- $(INSTALL) -m 644 "$(DESTDIR)$(ASTCONFPATH).tmp" "$(DESTDIR)$(ASTCONFPATH)" ; \
+- rm -f "$(DESTDIR)$(ASTCONFPATH).tmp" ; \
++ "$(DESTDIR)$(ASTEXAMPLEDIR)/asterisk.conf" > "$(DESTDIR)$(ASTEXAMPLEDIR)/asterisk.conf.tmp" ; \
++ $(INSTALL) -m 644 "$(DESTDIR)$(ASTEXAMPLEDIR)/asterisk.conf.tmp" "$(DESTDIR)$(ASTEXAMPLEDIR)/asterisk.conf" ; \
++ rm -f "$(DESTDIR)$(ASTEXAMPLEDIR)/asterisk.conf.tmp" ; \
+ fi
+ endef
+
+@@ -826,15 +819,15 @@ install-configs:
+ # XXX why *.adsi is installed first ?
+ adsi:
+ @echo Installing adsi config files...
+- $(INSTALL) -d "$(DESTDIR)$(ASTETCDIR)"
++ $(INSTALL) -d "$(DESTDIR)$(ASTEXAMPLEDIR)"
+ @for x in configs/samples/*.adsi; do \
+- dst="$(DESTDIR)$(ASTETCDIR)/`$(BASENAME) $$x`" ; \
++ dst="$(DESTDIR)$(ASTEXAMPLEDIR)/`$(BASENAME) $$x`" ; \
+ if [ -f "$${dst}" ] ; then \
+ echo "Overwriting $$x" ; \
+ else \
+ echo "Installing $$x" ; \
+ fi ; \
+- $(INSTALL) -m 644 "$$x" "$(DESTDIR)$(ASTETCDIR)/`$(BASENAME) $$x`" ; \
++ $(INSTALL) -m 644 "$$x" "$(DESTDIR)$(ASTEXAMPLEDIR)/`$(BASENAME) $$x`" ; \
+ done
+
+ samples: adsi
+@@ -867,7 +860,7 @@ basic-pbx:
+ webvmail:
+ @[ -d "$(DESTDIR)$(HTTP_DOCSDIR)/" ] || ( printf "http docs directory not found.\nUpdate assignment of variable HTTP_DOCSDIR in Makefile!\n" && exit 1 )
+ @[ -d "$(DESTDIR)$(HTTP_CGIDIR)" ] || ( printf "cgi-bin directory not found.\nUpdate assignment of variable HTTP_CGIDIR in Makefile!\n" && exit 1 )
+- $(INSTALL) -m 4755 contrib/scripts/vmail.cgi "$(DESTDIR)$(HTTP_CGIDIR)/vmail.cgi"
++ $(INSTALL) contrib/scripts/vmail.cgi "$(DESTDIR)$(HTTP_CGIDIR)/vmail"
+ $(INSTALL) -d "$(DESTDIR)$(HTTP_DOCSDIR)/_asterisk"
+ for x in images/*.gif; do \
+ $(INSTALL) -m 644 $$x "$(DESTDIR)$(HTTP_DOCSDIR)/_asterisk/"; \
+@@ -917,11 +910,11 @@ endif
+ endif
+
+ install-logrotate:
+- if [ ! -d "$(DESTDIR)$(ASTETCDIR)/../logrotate.d" ]; then \
+- $(INSTALL) -d "$(DESTDIR)$(ASTETCDIR)/../logrotate.d" ; \
++ if [ ! -d "$(DESTDIR)$(ASTEXAMPLEDIR)/../logrotate.d" ]; then \
++ $(INSTALL) -d "$(DESTDIR)$(ASTEXAMPLEDIR)/../logrotate.d" ; \
+ fi
+ sed 's#__LOGDIR__#$(ASTLOGDIR)#g' < contrib/scripts/asterisk.logrotate | sed 's#__SBINDIR__#$(ASTSBINDIR)#g' > contrib/scripts/asterisk.logrotate.tmp
+- $(INSTALL) -m 0644 contrib/scripts/asterisk.logrotate.tmp "$(DESTDIR)$(ASTETCDIR)/../logrotate.d/asterisk"
++ $(INSTALL) -m 0644 contrib/scripts/asterisk.logrotate.tmp "$(DESTDIR)$(ASTEXAMPLEDIR)/../logrotate.d/asterisk"
+ rm -f contrib/scripts/asterisk.logrotate.tmp
+
+ config:
+@@ -1048,7 +1041,7 @@ uninstall-all: _uninstall uninstall-head
+ rm -rf "$(DESTDIR)$(ASTVARLIBDIR)"
+ rm -rf "$(DESTDIR)$(ASTDATADIR)"
+ rm -rf "$(DESTDIR)$(ASTSPOOLDIR)"
+- rm -rf "$(DESTDIR)$(ASTETCDIR)"
++ rm -rf "$(DESTDIR)$(ASTEXAMPLEDIR)"
+ rm -rf "$(DESTDIR)$(ASTLOGDIR)"
+
+ menuconfig: menuselect
+@@ -1138,6 +1131,7 @@ check-alembic: makeopts
+ .PHONY: install-configs
+ .PHONY: install-headers
+ .PHONY: menuselect
++.PHONY: menuselect.makeopts
+ .PHONY: main
+ .PHONY: sounds
+ .PHONY: clean
diff --git a/comms/asterisk18/patches/patch-addons_chan__ooh323.c b/comms/asterisk18/patches/patch-addons_chan__ooh323.c
new file mode 100644
index 00000000000..d3f3dc46bd4
--- /dev/null
+++ b/comms/asterisk18/patches/patch-addons_chan__ooh323.c
@@ -0,0 +1,13 @@
+$NetBSD: patch-addons_chan__ooh323.c,v 1.1.1.1 2021/06/13 07:47:18 jnemeth Exp $
+
+--- addons/chan_ooh323.c.orig 2018-05-01 20:12:26.000000000 +0000
++++ addons/chan_ooh323.c
+@@ -4035,7 +4035,7 @@ static void *do_monitor(void *data)
+ h323->lastrtprx + h323->rtptimeout < t) {
+ if (!ast_channel_trylock(h323->owner)) {
+ ast_softhangup_nolock(h323->owner, AST_SOFTHANGUP_DEV);
+- ast_log(LOG_NOTICE, "Disconnecting call '%s' for lack of RTP activity in %ld seconds\n", ast_channel_name(h323->owner), (long) (t - h323->lastrtprx));
++ ast_log(LOG_NOTICE, "Disconnecting call '%s' for lack of RTP activity in %jd seconds\n", ast_channel_name(h323->owner), (intmax_t) (t - h323->lastrtprx));
+ ast_channel_unlock(h323->owner);
+ }
+
diff --git a/comms/asterisk18/patches/patch-apps_app__adsiprog.c b/comms/asterisk18/patches/patch-apps_app__adsiprog.c
new file mode 100644
index 00000000000..ba970a34682
--- /dev/null
+++ b/comms/asterisk18/patches/patch-apps_app__adsiprog.c
@@ -0,0 +1,22 @@
+$NetBSD: patch-apps_app__adsiprog.c,v 1.1.1.1 2021/06/13 07:47:18 jnemeth Exp $
+
+--- apps/app_adsiprog.c.orig 2018-05-07 17:17:45.731153122 +0000
++++ apps/app_adsiprog.c
+@@ -215,7 +215,7 @@ static int process_token(void *out, char
+ /* Convert */
+ *((unsigned int *)out) = htonl(*((unsigned int *)out));
+ }
+- } else if ((strlen(src) > 2) && (src[0] == '0') && (tolower(src[1]) == 'x')) {
++ } else if ((strlen(src) > 2) && (src[0] == '0') && (tolower((unsigned char)src[1]) == 'x')) {
+ if (!(argtype & ARG_NUMBER))
+ return -1;
+ /* Hex value */
+@@ -225,7 +225,7 @@ static int process_token(void *out, char
+ /* Convert */
+ *((unsigned int *)out) = htonl(*((unsigned int *)out));
+ }
+- } else if ((!ast_strlen_zero(src) && isdigit(src[0]))) {
++ } else if ((!ast_strlen_zero(src) && isdigit((unsigned char)src[0]))) {
+ if (!(argtype & ARG_NUMBER))
+ return -1;
+ /* Hex value */
diff --git a/comms/asterisk18/patches/patch-apps_app__chanspy.c b/comms/asterisk18/patches/patch-apps_app__chanspy.c
new file mode 100644
index 00000000000..1db5ef7ff98
--- /dev/null
+++ b/comms/asterisk18/patches/patch-apps_app__chanspy.c
@@ -0,0 +1,13 @@
+$NetBSD: patch-apps_app__chanspy.c,v 1.1.1.1 2021/06/13 07:47:18 jnemeth Exp $
+
+--- apps/app_chanspy.c.orig 2018-05-07 17:20:13.916423247 +0000
++++ apps/app_chanspy.c
+@@ -1105,7 +1105,7 @@ static int common_exec(struct ast_channe
+ if ((ptr = strchr(peer_name, '/'))) {
+ *ptr++ = '\0';
+ for (s = peer_name; s < ptr; s++) {
+- *s = tolower(*s);
++ *s = tolower((unsigned char)*s);
+ }
+ if ((s = strchr(ptr, '-'))) {
+ *s = '\0';
diff --git a/comms/asterisk18/patches/patch-apps_app__directory.c b/comms/asterisk18/patches/patch-apps_app__directory.c
new file mode 100644
index 00000000000..0613944fff1
--- /dev/null
+++ b/comms/asterisk18/patches/patch-apps_app__directory.c
@@ -0,0 +1,13 @@
+$NetBSD: patch-apps_app__directory.c,v 1.1.1.1 2021/06/13 07:47:18 jnemeth Exp $
+
+--- apps/app_directory.c.orig 2018-05-07 17:19:54.317128994 +0000
++++ apps/app_directory.c
+@@ -194,7 +194,7 @@ static int compare(const char *text, con
+ }
+
+ while (*template) {
+- digit = toupper(*text++);
++ digit = toupper((unsigned char)*text++);
+ switch (digit) {
+ case 0:
+ return -1;
diff --git a/comms/asterisk18/patches/patch-apps_app__dumpchan.c b/comms/asterisk18/patches/patch-apps_app__dumpchan.c
new file mode 100644
index 00000000000..f16e0b9a9db
--- /dev/null
+++ b/comms/asterisk18/patches/patch-apps_app__dumpchan.c
@@ -0,0 +1,22 @@
+$NetBSD: patch-apps_app__dumpchan.c,v 1.1.1.1 2021/06/13 07:47:18 jnemeth Exp $
+
+--- apps/app_dumpchan.c.orig 2015-10-09 21:48:48.000000000 +0000
++++ apps/app_dumpchan.c
+@@ -117,7 +117,7 @@ static int serialize_showchan(struct ast
+ "1stFileDescriptor= %d\n"
+ "Framesin= %u %s\n"
+ "Framesout= %u %s\n"
+- "TimetoHangup= %ld\n"
++ "TimetoHangup= %jd\n"
+ "ElapsedTime= %dh%dm%ds\n"
+ "BridgeID= %s\n"
+ "Context= %s\n"
+@@ -155,7 +155,7 @@ static int serialize_showchan(struct ast
+ ast_channel_fd(c, 0),
+ ast_channel_fin(c) & ~DEBUGCHAN_FLAG, (ast_channel_fin(c) & DEBUGCHAN_FLAG) ? " (DEBUGGED)" : "",
+ ast_channel_fout(c) & ~DEBUGCHAN_FLAG, (ast_channel_fout(c) & DEBUGCHAN_FLAG) ? " (DEBUGGED)" : "",
+- (long)ast_channel_whentohangup(c)->tv_sec,
++ (intmax_t)ast_channel_whentohangup(c)->tv_sec,
+ hour,
+ min,
+ sec,
diff --git a/comms/asterisk18/patches/patch-apps_app__followme.c b/comms/asterisk18/patches/patch-apps_app__followme.c
new file mode 100644
index 00000000000..fba5127e213
--- /dev/null
+++ b/comms/asterisk18/patches/patch-apps_app__followme.c
@@ -0,0 +1,22 @@
+$NetBSD: patch-apps_app__followme.c,v 1.1.1.1 2021/06/13 07:47:18 jnemeth Exp $
+
+--- apps/app_followme.c.orig 2015-10-09 21:48:48.000000000 +0000
++++ apps/app_followme.c
+@@ -380,7 +380,7 @@ static struct number *create_followme_nu
+ *tmp = '\0';
+ ast_copy_string(cur->number, buf, sizeof(cur->number));
+ cur->order = numorder;
+- ast_debug(1, "Created a number, %s, order of , %d, with a timeout of %ld.\n", cur->number, cur->order, cur->timeout);
++ ast_debug(1, "Created a number, %s, order of , %d, with a timeout of %jd.\n", cur->number, cur->order, (intmax_t)cur->timeout);
+
+ return cur;
+ }
+@@ -1010,7 +1010,7 @@ static struct ast_channel *findmeexec(st
+ break;
+ }
+
+- ast_debug(2, "Number(s) %s timeout %ld\n", nm->number, nm->timeout);
++ ast_debug(2, "Number(s) %s timeout %jd\n", nm->number, (intmax_t)nm->timeout);
+
+ /*
+ * Put all active outgoing channels into autoservice.
diff --git a/comms/asterisk18/patches/patch-apps_app__minivm.c b/comms/asterisk18/patches/patch-apps_app__minivm.c
new file mode 100644
index 00000000000..a1440e1c70a
--- /dev/null
+++ b/comms/asterisk18/patches/patch-apps_app__minivm.c
@@ -0,0 +1,13 @@
+$NetBSD: patch-apps_app__minivm.c,v 1.1.1.1 2021/06/13 07:47:18 jnemeth Exp $
+
+--- apps/app_minivm.c.orig 2018-05-07 17:45:03.072823223 +0000
++++ apps/app_minivm.c
+@@ -1593,7 +1593,7 @@ static int invent_message(struct ast_cha
+
+ while (*i) {
+ ast_debug(2, "Numeric? Checking %c\n", *i);
+- if (!isdigit(*i)) {
++ if (!isdigit((unsigned char)*i)) {
+ numericusername = FALSE;
+ break;
+ }
diff --git a/comms/asterisk18/patches/patch-apps_app__queue.c b/comms/asterisk18/patches/patch-apps_app__queue.c
new file mode 100644
index 00000000000..3cb3e1aa7f6
--- /dev/null
+++ b/comms/asterisk18/patches/patch-apps_app__queue.c
@@ -0,0 +1,132 @@
+$NetBSD: patch-apps_app__queue.c,v 1.1.1.1 2021/06/13 07:47:18 jnemeth Exp $
+
+--- apps/app_queue.c.orig 2021-03-25 17:34:21.000000000 +0000
++++ apps/app_queue.c
+@@ -5909,8 +5909,8 @@ static void queue_agent_cb(void *userdat
+ } else if (ast_channel_agent_logoff_type() == stasis_message_type(msg)) {
+ ast_queue_log("NONE", agent_blob->snapshot->base->uniqueid,
+ ast_json_string_get(ast_json_object_get(agent_blob->blob, "agent")),
+- "AGENTLOGOFF", "%s|%ld", agent_blob->snapshot->base->name,
+- (long) ast_json_integer_get(ast_json_object_get(agent_blob->blob, "logintime")));
++ "AGENTLOGOFF", "%s|%jd", agent_blob->snapshot->base->name,
++ (intmax_t) ast_json_integer_get(ast_json_object_get(agent_blob->blob, "logintime")));
+ }
+ }
+
+@@ -7043,8 +7043,8 @@ static int try_calling(struct queue_ent
+ /* if setinterfacevar is defined, make member variables available to the channel */
+ /* use pbx_builtin_setvar to set a load of variables with one call */
+ if (qe->parent->setinterfacevar && interfacevar) {
+- ast_str_set(&interfacevar, 0, "MEMBERINTERFACE=%s,MEMBERNAME=%s,MEMBERCALLS=%d,MEMBERLASTCALL=%ld,MEMBERPENALTY=%d,MEMBERDYNAMIC=%d,MEMBERREALTIME=%d",
+- member->interface, member->membername, member->calls, (long)member->lastcall, member->penalty, member->dynamic, member->realtime);
++ ast_str_set(&interfacevar, 0, "MEMBERINTERFACE=%s,MEMBERNAME=%s,MEMBERCALLS=%d,MEMBERLASTCALL=%jd,MEMBERPENALTY=%d,MEMBERDYNAMIC=%d,MEMBERREALTIME=%d",
++ member->interface, member->membername, member->calls, (intmax_t)member->lastcall, member->penalty, member->dynamic, member->realtime);
+ pbx_builtin_setvar_multiple(qe->chan, ast_str_buffer(interfacevar));
+ pbx_builtin_setvar_multiple(peer, ast_str_buffer(interfacevar));
+ }
+@@ -7052,8 +7052,8 @@ static int try_calling(struct queue_ent
+ /* if setqueueentryvar is defined, make queue entry (i.e. the caller) variables available to the channel */
+ /* use pbx_builtin_setvar to set a load of variables with one call */
+ if (qe->parent->setqueueentryvar && interfacevar) {
+- ast_str_set(&interfacevar, 0, "QEHOLDTIME=%ld,QEORIGINALPOS=%d",
+- (long) (time(NULL) - qe->start), qe->opos);
++ ast_str_set(&interfacevar, 0, "QEHOLDTIME=%jd,QEORIGINALPOS=%d",
++ (intmax_t) (time(NULL) - qe->start), qe->opos);
+ pbx_builtin_setvar_multiple(qe->chan, ast_str_buffer(interfacevar));
+ pbx_builtin_setvar_multiple(peer, ast_str_buffer(interfacevar));
+ }
+@@ -8335,8 +8335,8 @@ static int queue_exec(struct ast_channel
+ }
+ }
+
+- ast_debug(1, "queue: %s, expires: %ld, priority: %d\n",
+- args.queuename, (long)qe.expire, prio);
++ ast_debug(1, "queue: %s, expires: %jd, priority: %d\n",
++ args.queuename, (intmax_t)qe.expire, prio);
+
+ qe.chan = chan;
+ qe.prio = prio;
+@@ -8402,8 +8402,8 @@ check_turns:
+ record_abandoned(&qe);
+ reason = QUEUE_TIMEOUT;
+ res = 0;
+- ast_queue_log(args.queuename, ast_channel_uniqueid(chan),"NONE", "EXITWITHTIMEOUT", "%d|%d|%ld",
+- qe.pos, qe.opos, (long) (time(NULL) - qe.start));
++ ast_queue_log(args.queuename, ast_channel_uniqueid(chan),"NONE", "EXITWITHTIMEOUT", "%d|%d|%jd",
++ qe.pos, qe.opos, (intmax_t) (time(NULL) - qe.start));
+ break;
+ }
+
+@@ -8473,7 +8473,7 @@ check_turns:
+ record_abandoned(&qe);
+ reason = QUEUE_TIMEOUT;
+ res = 0;
+- ast_queue_log(qe.parent->name, ast_channel_uniqueid(qe.chan),"NONE", "EXITWITHTIMEOUT", "%d|%d|%ld", qe.pos, qe.opos, (long) (time(NULL) - qe.start));
++ ast_queue_log(qe.parent->name, ast_channel_uniqueid(qe.chan),"NONE", "EXITWITHTIMEOUT", "%d|%d|%jd", qe.pos, qe.opos, (intmax_t) (time(NULL) - qe.start));
+ break;
+ }
+
+@@ -8514,7 +8514,7 @@ stop:
+ }
+ } else if (qe.valid_digits) {
+ ast_queue_log(args.queuename, ast_channel_uniqueid(chan), "NONE", "EXITWITHKEY",
+- "%s|%d|%d|%ld", qe.digits, qe.pos, qe.opos, (long) (time(NULL) - qe.start));
++ "%s|%d|%d|%jd", qe.digits, qe.pos, qe.opos, (intmax_t) (time(NULL) - qe.start));
+ }
+ }
+
+@@ -9871,7 +9871,7 @@ static int word_in_list(const char *list
+ const char *find, *end_find, *end_list;
+
+ /* strip whitespace from front */
+- while(isspace(*list)) {
++ while(isspace((unsigned char)*list)) {
+ list++;
+ }
+
+@@ -9880,11 +9880,11 @@ static int word_in_list(const char *list
+ if (find != list && *(find - 1) != ' ') {
+ list = find;
+ /* strip word from front */
+- while(!isspace(*list) && *list != '\0') {
++ while(!isspace((unsigned char)*list) && *list != '\0') {
+ list++;
+ }
+ /* strip whitespace from front */
+- while(isspace(*list)) {
++ while(isspace((unsigned char)*list)) {
+ list++;
+ }
+ continue;
+@@ -9897,11 +9897,11 @@ static int word_in_list(const char *list
+ if (end_find == end_list || *end_find != ' ') {
+ list = find;
+ /* strip word from front */
+- while(!isspace(*list) && *list != '\0') {
++ while(!isspace((unsigned char)*list) && *list != '\0') {
+ list++;
+ }
+ /* strip whitespace from front */
+- while(isspace(*list)) {
++ while(isspace((unsigned char)*list)) {
+ list++;
+ }
+ continue;
+@@ -10194,7 +10194,7 @@ static int manager_queues_status(struct
+ "CallerIDName: %s\r\n"
+ "ConnectedLineNum: %s\r\n"
+ "ConnectedLineName: %s\r\n"
+- "Wait: %ld\r\n"
++ "Wait: %jd\r\n"
+ "Priority: %d\r\n"
+ "%s"
+ "\r\n",
+@@ -10203,7 +10203,7 @@ static int manager_queues_status(struct
+ S_COR(ast_channel_caller(qe->chan)->id.name.valid, ast_channel_caller(qe->chan)->id.name.str, "unknown"),
+ S_COR(ast_channel_connected(qe->chan)->id.number.valid, ast_channel_connected(qe->chan)->id.number.str, "unknown"),
+ S_COR(ast_channel_connected(qe->chan)->id.name.valid, ast_channel_connected(qe->chan)->id.name.str, "unknown"),
+- (long) (now - qe->start), qe->prio, idText);
++ (intmax_t) (now - qe->start), qe->prio, idText);
+ ++q_items;
+ }
+ }
diff --git a/comms/asterisk18/patches/patch-apps_app__sms.c b/comms/asterisk18/patches/patch-apps_app__sms.c
new file mode 100644
index 00000000000..6f4d09e59a4
--- /dev/null
+++ b/comms/asterisk18/patches/patch-apps_app__sms.c
@@ -0,0 +1,102 @@
+$NetBSD: patch-apps_app__sms.c,v 1.1.1.1 2021/06/13 07:47:18 jnemeth Exp $
+
+--- apps/app_sms.c.orig 2018-05-01 20:12:26.000000000 +0000
++++ apps/app_sms.c
+@@ -291,7 +291,7 @@ static void numcpy(char *d, char *s)
+ *d++ = *s++;
+ }
+ while (*s) {
+- if (isdigit(*s)) {
++ if (isdigit((unsigned char)*s)) {
+ *d++ = *s;
+ }
+ s++;
+@@ -557,7 +557,7 @@ static void packdate(unsigned char *o, t
+ int z;
+
+ ast_localtime(&topack, &t, NULL);
+-#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined( __NetBSD__ ) || defined(__APPLE__) || defined(__CYGWIN__)
++#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined( __NetBSD__ ) || defined(__APPLE__) || defined(__CYGWIN__) || defined(__DragonFly__)
+ z = -t.tm_gmtoff / 60 / 15;
+ #else
+ z = timezone / 60 / 15;
+@@ -754,7 +754,7 @@ static unsigned char packaddress(unsigne
+ o[1] = 0x81;
+ }
+ for ( ; *i ; i++) {
+- if (!isdigit(*i)) { /* ignore non-digits */
++ if (!isdigit((unsigned char)*i)) { /* ignore non-digits */
+ continue;
+ }
+ if (o[0] & 1) {
+@@ -849,11 +849,11 @@ static void sms_readfile(sms_t * h, char
+ if (!*p || *p == ';') {
+ continue; /* blank line or comment, ignore */
+ }
+- while (isalnum(*p)) {
+- *p = tolower (*p);
++ while (isalnum((unsigned char)*p)) {
++ *p = tolower ((unsigned char)*p);
+ p++;
+ }
+- while (isspace (*p)) {
++ while (isspace ((unsigned char)*p)) {
+ *p++ = 0;
+ }
+ if (*p == '=') {
+@@ -869,7 +869,7 @@ static void sms_readfile(sms_t * h, char
+ ast_log(LOG_WARNING, "UD too long in %s\n", fn);
+ }
+ } else {
+- while (isspace (*p)) {
++ while (isspace ((unsigned char)*p)) {
+ p++;
+ }
+ if (!strcmp(line, "oa") && strlen(p) < sizeof(h->oa)) {
+@@ -917,11 +917,11 @@ static void sms_readfile(sms_t * h, char
+ if (!strcmp(line, "ud")) { /* user data */
+ int o = 0;
+ while (*p && o < SMSLEN) {
+- if (isxdigit(*p) && isxdigit(p[1]) && isxdigit(p[2]) && isxdigit(p[3])) {
++ if (isxdigit((unsigned char)*p) && isxdigit((unsigned char)p[1]) && isxdigit((unsigned char)p[2]) && isxdigit((unsigned char)p[3])) {
+ h->ud[o++] =
+- (((isalpha(*p) ? 9 : 0) + (*p & 0xF)) << 12) +
+- (((isalpha(p[1]) ? 9 : 0) + (p[1] & 0xF)) << 8) +
+- (((isalpha(p[2]) ? 9 : 0) + (p[2] & 0xF)) << 4) + ((isalpha(p[3]) ? 9 : 0) + (p[3] & 0xF));
++ (((isalpha((unsigned char)*p) ? 9 : 0) + (*p & 0xF)) << 12) +
++ (((isalpha((unsigned char)p[1]) ? 9 : 0) + (p[1] & 0xF)) << 8) +
++ (((isalpha((unsigned char)p[2]) ? 9 : 0) + (p[2] & 0xF)) << 4) + ((isalpha((unsigned char)p[3]) ? 9 : 0) + (p[3] & 0xF));
+ p += 4;
+ } else
+ break;
+@@ -934,8 +934,8 @@ static void sms_readfile(sms_t * h, char
+ } else if (!strcmp(line, "ud")) { /* user data */
+ int o = 0;
+ while (*p && o < SMSLEN) {
+- if (isxdigit(*p) && isxdigit(p[1])) {
+- h->ud[o++] = (((isalpha(*p) ? 9 : 0) + (*p & 0xF)) << 4) + ((isalpha(p[1]) ? 9 : 0) + (p[1] & 0xF));
++ if (isxdigit((unsigned char)*p) && isxdigit((unsigned char)p[1])) {
++ h->ud[o++] = (((isalpha((unsigned char)*p) ? 9 : 0) + (*p & 0xF)) << 4) + ((isalpha((unsigned char)p[1]) ? 9 : 0) + (p[1] & 0xF));
+ p += 2;
+ } else {
+ break;
+@@ -949,8 +949,8 @@ static void sms_readfile(sms_t * h, char
+ unsigned char o = 0;
+ h->udhi = 1;
+ while (*p && o < SMSLEN) {
+- if (isxdigit(*p) && isxdigit(p[1])) {
+- h->udh[o] = (((isalpha(*p) ? 9 : 0) + (*p & 0xF)) << 4) + ((isalpha(p[1]) ? 9 : 0) + (p[1] & 0xF));
++ if (isxdigit((unsigned char)*p) && isxdigit((unsigned char)p[1])) {
++ h->udh[o] = (((isalpha((unsigned char)*p) ? 9 : 0) + (*p & 0xF)) << 4) + ((isalpha((unsigned char)p[1]) ? 9 : 0) + (p[1] & 0xF));
+ o++;
+ p += 2;
+ } else {
+@@ -1928,7 +1928,7 @@ static int sms_exec(struct ast_channel *
+ ast_copy_string(h.queue, sms_args.queue, sizeof(h.queue));
+
+ for (p = h.queue; *p; p++) {
+- if (!isalnum(*p)) {
++ if (!isalnum((unsigned char)*p)) {
+ *p = '-'; /* make very safe for filenames */
+ }
+ }
diff --git a/comms/asterisk18/patches/patch-apps_app__voicemail.c b/comms/asterisk18/patches/patch-apps_app__voicemail.c
new file mode 100644
index 00000000000..1ca497a0b87
--- /dev/null
+++ b/comms/asterisk18/patches/patch-apps_app__voicemail.c
@@ -0,0 +1,76 @@
+$NetBSD: patch-apps_app__voicemail.c,v 1.1.1.1 2021/06/13 07:47:18 jnemeth Exp $
+
+--- apps/app_voicemail.c.orig 2018-05-01 20:12:26.000000000 +0000
++++ apps/app_voicemail.c
+@@ -5251,7 +5251,7 @@ static void make_email_file(FILE *p,
+ }
+ fprintf(p, "X-Asterisk-VM-Message-Type: %s" ENDL, msgnum > -1 ? "Message" : greeting_attachment);
+ fprintf(p, "X-Asterisk-VM-Orig-date: %s" ENDL, date);
+- fprintf(p, "X-Asterisk-VM-Orig-time: %ld" ENDL, (long) time(NULL));
++ fprintf(p, "X-Asterisk-VM-Orig-time: %jd" ENDL, (intmax_t) time(NULL));
+ fprintf(p, "X-Asterisk-VM-Message-ID: %s" ENDL, msg_id);
+ }
+ if (!ast_strlen_zero(cidnum)) {
+@@ -6202,7 +6202,7 @@ static void generate_msg_id(char *dst)
+ * but only in single system solutions.
+ */
+ unsigned int unique_counter = ast_atomic_fetchadd_int(&msg_id_incrementor, +1);
+- snprintf(dst, MSG_ID_LEN, "%ld-%08x", (long) time(NULL), unique_counter);
++ snprintf(dst, MSG_ID_LEN, "%jd-%08x", (intmax_t) time(NULL), unique_counter);
+ }
+
+ /*!
+@@ -6324,7 +6324,7 @@ static int msg_create_from_file(struct a
+ "callerchan=%s\n"
+ "callerid=%s\n"
+ "origdate=%s\n"
+- "origtime=%ld\n"
++ "origtime=%jd\n"
+ "category=%s\n"
+ "msg_id=%s\n"
+ "flag=\n" /* flags not supported in copy from file yet */
+@@ -6337,7 +6337,7 @@ static int msg_create_from_file(struct a
+ recdata->call_priority,
+ S_OR(recdata->call_callerchan, "Unknown"),
+ S_OR(recdata->call_callerid, "Unknown"),
+- date, (long) time(NULL),
++ date, (intmax_t) time(NULL),
+ S_OR(category, ""),
+ msg_id,
+ duration);
+@@ -6859,7 +6859,7 @@ static int leave_voicemail(struct ast_ch
+ /* Store information in real-time storage */
+ if (ast_check_realtime("voicemail_data")) {
+ snprintf(priority, sizeof(priority), "%d", ast_channel_priority(chan));
+- snprintf(origtime, sizeof(origtime), "%ld", (long) time(NULL));
++ snprintf(origtime, sizeof(origtime), "%jd", (intmax_t) time(NULL));
+ get_date(date, sizeof(date));
+ ast_callerid_merge(callerid, sizeof(callerid),
+ S_COR(ast_channel_caller(chan)->id.name.valid, ast_channel_caller(chan)->id.name.str, NULL),
+@@ -6903,7 +6903,7 @@ static int leave_voicemail(struct ast_ch
+ "callerchan=%s\n"
+ "callerid=%s\n"
+ "origdate=%s\n"
+- "origtime=%ld\n"
++ "origtime=%jd\n"
+ "category=%s\n"
+ "msg_id=%s\n",
+ ext,
+@@ -6915,7 +6915,7 @@ static int leave_voicemail(struct ast_ch
+ ast_channel_priority(chan),
+ ast_channel_name(chan),
+ callerid,
+- date, (long) time(NULL),
++ date, (intmax_t) time(NULL),
+ category ? category : "",
+ msg_id);
+ } else {
+@@ -11456,7 +11456,7 @@ static int vm_execmain(struct ast_channe
+ play_auto = 1;
+ if (!ast_strlen_zero(opts[OPT_ARG_PLAYFOLDER])) {
+ /* See if it is a folder name first */
+- if (isdigit(opts[OPT_ARG_PLAYFOLDER][0])) {
++ if (isdigit((unsigned char)opts[OPT_ARG_PLAYFOLDER][0])) {
+ if (sscanf(opts[OPT_ARG_PLAYFOLDER], "%30d", &play_folder) != 1) {
+ play_folder = -1;
+ }
diff --git a/comms/asterisk18/patches/patch-build__tools_mkpkgconfig b/comms/asterisk18/patches/patch-build__tools_mkpkgconfig
new file mode 100644
index 00000000000..df854931820
--- /dev/null
+++ b/comms/asterisk18/patches/patch-build__tools_mkpkgconfig
@@ -0,0 +1,19 @@
+$NetBSD: patch-build__tools_mkpkgconfig,v 1.1.1.1 2021/06/13 07:47:18 jnemeth Exp $
+
+--- build_tools/mkpkgconfig.orig 2015-10-09 21:48:48.000000000 +0000
++++ build_tools/mkpkgconfig
+@@ -22,11 +22,14 @@ else
+ fi
+
+ ## Clean out CFLAGS for the spec file.
++## pkgsrc -- the regex below isn't sed compatible, so always use perl
++EXTREGEX="perl -pe"
+ LOCAL_CFLAGS=`echo $CFLAGS | ${EXTREGEX} 's/-pipe\s*//g' | ${EXTREGEX} 's/-[Wmp]\S*\s*//g' | \
+ ${EXTREGEX} 's/\s+-I(include|\.\.\/include)\s+/ /g' | \
+ ${EXTREGEX} 's/-DINSTALL_PREFIX=\S* //g' | \
+ ${EXTREGEX} 's/-DASTERISK_VERSION=\S* //g' | \
+ ${EXTREGEX} 's/-DAST(ETCDIR|LIBDIR|VARLIBDIR|VARRUNDIR|SPOOLDIR|LOGDIR|CONFPATH|MODDIR|AGIDIR)=\S* //g' | \
++ ${EXTREGEX} "s;${WRKSRC};${PREFIX};g" | \
+ ${EXTREGEX} 's/^\s|\s$//g'`
+
+ cat <<EOF > "$PPATH/asterisk.pc"
diff --git a/comms/asterisk18/patches/patch-cdr_cdr__pgsql.c b/comms/asterisk18/patches/patch-cdr_cdr__pgsql.c
new file mode 100644
index 00000000000..1a68eb0d4cb
--- /dev/null
+++ b/comms/asterisk18/patches/patch-cdr_cdr__pgsql.c
@@ -0,0 +1,31 @@
+$NetBSD: patch-cdr_cdr__pgsql.c,v 1.1.1.1 2021/06/13 07:47:18 jnemeth Exp $
+
+--- cdr/cdr_pgsql.c.orig 2016-09-30 20:36:17.000000000 +0000
++++ cdr/cdr_pgsql.c
+@@ -270,7 +270,7 @@ static int pgsql_log(struct ast_cdr *cdr
+ if (strcmp(cur->name, "start") == 0 || strcmp(cur->name, "calldate") == 0) {
+ if (strncmp(cur->type, "int", 3) == 0) {
+ LENGTHEN_BUF2(13);
+- ast_str_append(&sql2, 0, "%s%ld", separator, (long) cdr->start.tv_sec);
++ ast_str_append(&sql2, 0, "%s%jd", separator, (intmax_t) cdr->start.tv_sec);
+ } else if (strncmp(cur->type, "float", 5) == 0) {
+ LENGTHEN_BUF2(31);
+ ast_str_append(&sql2, 0, "%s%f", separator, (double)cdr->start.tv_sec + (double)cdr->start.tv_usec / 1000000.0);
+@@ -284,7 +284,7 @@ static int pgsql_log(struct ast_cdr *cdr
+ } else if (strcmp(cur->name, "answer") == 0) {
+ if (strncmp(cur->type, "int", 3) == 0) {
+ LENGTHEN_BUF2(13);
+- ast_str_append(&sql2, 0, "%s%ld", separator, (long) cdr->answer.tv_sec);
++ ast_str_append(&sql2, 0, "%s%jd", separator, (intmax_t) cdr->answer.tv_sec);
+ } else if (strncmp(cur->type, "float", 5) == 0) {
+ LENGTHEN_BUF2(31);
+ ast_str_append(&sql2, 0, "%s%f", separator, (double)cdr->answer.tv_sec + (double)cdr->answer.tv_usec / 1000000.0);
+@@ -298,7 +298,7 @@ static int pgsql_log(struct ast_cdr *cdr
+ } else if (strcmp(cur->name, "end") == 0) {
+ if (strncmp(cur->type, "int", 3) == 0) {
+ LENGTHEN_BUF2(13);
+- ast_str_append(&sql2, 0, "%s%ld", separator, (long) cdr->end.tv_sec);
++ ast_str_append(&sql2, 0, "%s%jd", separator, (intmax_t) cdr->end.tv_sec);
+ } else if (strncmp(cur->type, "float", 5) == 0) {
+ LENGTHEN_BUF2(31);
+ ast_str_append(&sql2, 0, "%s%f", separator, (double)cdr->end.tv_sec + (double)cdr->end.tv_usec / 1000000.0);
diff --git a/comms/asterisk18/patches/patch-cel_cel__pgsql.c b/comms/asterisk18/patches/patch-cel_cel__pgsql.c
new file mode 100644
index 00000000000..304402c5273
--- /dev/null
+++ b/comms/asterisk18/patches/patch-cel_cel__pgsql.c
@@ -0,0 +1,13 @@
+$NetBSD: patch-cel_cel__pgsql.c,v 1.1.1.1 2021/06/13 07:47:18 jnemeth Exp $
+
+--- cel/cel_pgsql.c.orig 2015-10-09 21:48:48.000000000 +0000
++++ cel/cel_pgsql.c
+@@ -205,7 +205,7 @@ static void pgsql_log(struct ast_event *
+ if (strcmp(cur->name, "eventtime") == 0) {
+ if (strncmp(cur->type, "int", 3) == 0) {
+ LENGTHEN_BUF2(13);
+- ast_str_append(&sql2, 0, "%s%ld", SEP, (long) record.event_time.tv_sec);
++ ast_str_append(&sql2, 0, "%s%jd", SEP, (intmax_t) record.event_time.tv_sec);
+ } else if (strncmp(cur->type, "float", 5) == 0) {
+ LENGTHEN_BUF2(31);
+ ast_str_append(&sql2, 0, "%s%f",
diff --git a/comms/asterisk18/patches/patch-channels_chan__pjsip.c b/comms/asterisk18/patches/patch-channels_chan__pjsip.c
new file mode 100644
index 00000000000..18df6ed6424
--- /dev/null
+++ b/comms/asterisk18/patches/patch-channels_chan__pjsip.c
@@ -0,0 +1,32 @@
+$NetBSD: patch-channels_chan__pjsip.c,v 1.1.1.1 2021/06/13 07:47:18 jnemeth Exp $
+
+--- channels/chan_pjsip.c.orig 2019-09-05 13:09:20.000000000 +0000
++++ channels/chan_pjsip.c
+@@ -34,10 +34,6 @@
+
+ #include "asterisk.h"
+
+-#include <pjsip.h>
+-#include <pjsip_ua.h>
+-#include <pjlib.h>
+-
+ #include "asterisk/lock.h"
+ #include "asterisk/channel.h"
+ #include "asterisk/module.h"
+@@ -63,10 +59,14 @@
+ #include "asterisk/test.h"
+ #include "asterisk/message.h"
+
+-#include "asterisk/res_pjsip.h"
+-#include "asterisk/res_pjsip_session.h"
+ #include "asterisk/stream.h"
+
++#include <pjsip.h>
++#include <pjsip_ua.h>
++#include <pjlib.h>
++
++#include "asterisk/res_pjsip.h"
++#include "asterisk/res_pjsip_session.h"
+ #include "pjsip/include/chan_pjsip.h"
+ #include "pjsip/include/dialplan_functions.h"
+ #include "pjsip/include/cli_functions.h"
diff --git a/comms/asterisk18/patches/patch-channels_chan__sip.c b/comms/asterisk18/patches/patch-channels_chan__sip.c
new file mode 100644
index 00000000000..8d39b7cd654
--- /dev/null
+++ b/comms/asterisk18/patches/patch-channels_chan__sip.c
@@ -0,0 +1,40 @@
+$NetBSD: patch-channels_chan__sip.c,v 1.1.1.1 2021/06/13 07:47:18 jnemeth Exp $
+
+--- channels/chan_sip.c.orig 2018-05-01 20:12:26.000000000 +0000
++++ channels/chan_sip.c
+@@ -2411,7 +2411,7 @@ static int sip_is_token(const char *str)
+
+ is_token = 1;
+ do {
+- if (!isalnum(*str)
++ if (!isalnum((unsigned char)*str)
+ && !strchr("-.!%*_+`'~", *str)) {
+ /* The character is not allowed in a token. */
+ is_token = 0;
+@@ -11624,7 +11624,7 @@ static int process_sdp_a_image(const cha
+ * code reviews).
+ */
+ for (pos = attrib; *pos; ++pos) {
+- *pos = tolower(*pos);
++ *pos = tolower((unsigned char)*pos);
+ }
+
+ if ((sscanf(attrib, "t38faxmaxbuffer:%30u", &x) == 1)) {
+@@ -20014,7 +20014,7 @@ static int manager_show_registry(struct
+ "DomainPort: %d\r\n"
+ "Refresh: %d\r\n"
+ "State: %s\r\n"
+- "RegistrationTime: %ld\r\n"
++ "RegistrationTime: %jd\r\n"
+ "\r\n",
+ idtext,
+ iterator->hostname,
+@@ -20024,7 +20024,7 @@ static int manager_show_registry(struct
+ iterator->regdomainport ? iterator->regdomainport : STANDARD_SIP_PORT,
+ iterator->refresh,
+ regstate2str(iterator->regstate),
+- (long) iterator->regtime.tv_sec);
++ (intmax_t) iterator->regtime.tv_sec);
+
+ ao2_unlock(iterator);
+ ao2_t_ref(iterator, -1, "manager_show_registry iter");
diff --git a/comms/asterisk18/patches/patch-channels_pjsip_cli__commands.c b/comms/asterisk18/patches/patch-channels_pjsip_cli__commands.c
new file mode 100644
index 00000000000..51b74947ca4
--- /dev/null
+++ b/comms/asterisk18/patches/patch-channels_pjsip_cli__commands.c
@@ -0,0 +1,33 @@
+$NetBSD: patch-channels_pjsip_cli__commands.c,v 1.1.1.1 2021/06/13 07:47:18 jnemeth Exp $
+
+--- channels/pjsip/cli_commands.c.orig 2018-06-20 14:37:54.485779459 +0000
++++ channels/pjsip/cli_commands.c
+@@ -26,20 +26,21 @@
+
+ #include "asterisk.h"
+
++#include "asterisk/astobj2.h"
++#include "asterisk/channel.h"
++#include "asterisk/format.h"
++#include "asterisk/stasis.h"
++#include "asterisk/time.h"
++#include "include/cli_functions.h"
++
+ #include <pjsip.h>
+ #include <pjlib.h>
+ #include <pjsip_ua.h>
+
+-#include "asterisk/astobj2.h"
+-#include "asterisk/channel.h"
+-#include "asterisk/format.h"
++#include "include/chan_pjsip.h"
+ #include "asterisk/res_pjsip.h"
+ #include "asterisk/res_pjsip_session.h"
+ #include "asterisk/res_pjsip_cli.h"
+-#include "asterisk/stasis.h"
+-#include "asterisk/time.h"
+-#include "include/chan_pjsip.h"
+-#include "include/cli_functions.h"
+
+
+ static int cli_channel_iterate(void *endpoint, ao2_callback_fn callback, void *arg)
diff --git a/comms/asterisk18/patches/patch-channels_pjsip_dialplan__functions.c b/comms/asterisk18/patches/patch-channels_pjsip_dialplan__functions.c
new file mode 100644
index 00000000000..5ed13dae507
--- /dev/null
+++ b/comms/asterisk18/patches/patch-channels_pjsip_dialplan__functions.c
@@ -0,0 +1,32 @@
+$NetBSD: patch-channels_pjsip_dialplan__functions.c,v 1.1.1.1 2021/06/13 07:47:18 jnemeth Exp $
+
+--- channels/pjsip/dialplan_functions.c.orig 2018-06-20 14:39:31.934736437 +0000
++++ channels/pjsip/dialplan_functions.c
+@@ -450,10 +450,6 @@
+
+ #include "asterisk.h"
+
+-#include <pjsip.h>
+-#include <pjlib.h>
+-#include <pjsip_ua.h>
+-
+ #include "asterisk/astobj2.h"
+ #include "asterisk/module.h"
+ #include "asterisk/acl.h"
+@@ -463,10 +459,15 @@
+ #include "asterisk/format.h"
+ #include "asterisk/dsp.h"
+ #include "asterisk/pbx.h"
++#include "include/dialplan_functions.h"
++
++#include <pjsip.h>
++#include <pjlib.h>
++#include <pjsip_ua.h>
++
+ #include "asterisk/res_pjsip.h"
+ #include "asterisk/res_pjsip_session.h"
+ #include "include/chan_pjsip.h"
+-#include "include/dialplan_functions.h"
+
+ /*!
+ * \brief String representations of the T.38 state enum
diff --git a/comms/asterisk18/patches/patch-configure b/comms/asterisk18/patches/patch-configure
new file mode 100644
index 00000000000..35145349f1a
--- /dev/null
+++ b/comms/asterisk18/patches/patch-configure
@@ -0,0 +1,222 @@
+$NetBSD: patch-configure,v 1.1.1.1 2021/06/13 07:47:18 jnemeth Exp $
+
+--- configure.orig 2021-03-04 16:46:08.000000000 +0000
++++ configure
+@@ -8963,12 +8963,12 @@ else
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for clang -fblocks" >&5
+ $as_echo_n "checking for clang -fblocks... " >&6; }
+- if test "`echo 'int main(){return ^{return 42;}();}' | ${CC} -o /dev/null -fblocks -x c - 2>&1`" = ""; then
++ if test "`echo 'int main(){return ^{return 42;}();}' | ${CC} ${LDFLAGS} -o /dev/null -fblocks -x c - 2>&1`" = ""; then
+ AST_CLANG_BLOCKS_LIBS=""
+ AST_CLANG_BLOCKS="-Wno-unknown-warning-option -fblocks"
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+ $as_echo "yes" >&6; }
+- elif test "`echo 'int main(){return ^{return 42;}();}' | ${CC} -o /dev/null -fblocks -x c -lBlocksRuntime - 2>&1`" = ""; then
++ elif test "`echo 'int main(){return ^{return 42;}();}' | ${CC} ${LDFLAGS} -o /dev/null -fblocks -x c -lBlocksRuntime - 2>&1`" = ""; then
+ AST_CLANG_BLOCKS_LIBS="-lBlocksRuntime"
+ AST_CLANG_BLOCKS="-fblocks"
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+@@ -9065,7 +9065,7 @@ if test "${with_pjproject_bundled+set}"
+ fi
+
+
+-if test "${with_pjproject}" == "no" || test "${with_pjproject}" == "n" ; then
++if test "${with_pjproject}" = "no" || test "${with_pjproject}" = "n" ; then
+ PJPROJECT_BUNDLED=no
+ fi
+
+@@ -14727,7 +14727,7 @@ fi
+
+
+
+-if test "${PERMANENT_DLOPEN}" == "yes"; then
++if test "${PERMANENT_DLOPEN}" = "yes"; then
+
+ $as_echo "#define HAVE_PERMANENT_DLOPEN 1" >>confdefs.h
+
+@@ -14761,7 +14761,7 @@ fi
+ done
+
+
+-ac_fn_c_check_header_mongrel "$LINENO" "sys/poll.h" "ac_cv_header_sys_poll_h" "$ac_includes_default"
++ac_fn_c_check_header_mongrel "$LINENO" "poll.h" "ac_cv_header_sys_poll_h" "$ac_includes_default"
+ if test "x$ac_cv_header_sys_poll_h" = xyes; then :
+
+ else
+@@ -16776,7 +16776,7 @@ fi
+ done
+
+
+-for ac_func in asprintf atexit closefrom dup2 eaccess endpwent euidaccess ffsll ftruncate getcwd gethostbyname gethostname getloadavg gettimeofday glob ioperm inet_ntoa isascii memchr memmove memset mkdir mkdtemp munmap newlocale pipe2 ppoll putenv re_comp regcomp select setenv socket strcasecmp strcasestr strchr strcspn strdup strerror strlcat strlcpy strncasecmp strndup strnlen strrchr strsep strspn strstr strtod strtol strtold strtoq unsetenv uselocale utime vasprintf getpeereid sysctl swapctl malloc_trim
++for ac_func in asprintf atexit closefrom dup2 eaccess endpwent euidaccess ffsll ftruncate getcwd gethostbyname gethostname getloadavg gettimeofday glob ioperm inet_ntoa isascii memchr memmove memset mkdir mkdtemp munmap newlocale pipe2 ppoll putenv re_comp regcomp select setenv socket strcasecmp strcasestr strchr strcspn strdup strerror strftime_l strlcat strlcpy strncasecmp strndup strnlen strptime_l strrchr strsep strspn strstr strtod strtol strtold strtoq unsetenv uselocale utime vasprintf getpeereid sysctl swapctl malloc_trim
+ do :
+ as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
+ ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
+@@ -17011,7 +17011,7 @@ rm -f core conftest.err conftest.$ac_obj
+ LDFLAGS=${old_LDFLAGS}
+ rm -f conftest.dynamics
+
+-ac_fn_c_check_header_mongrel "$LINENO" "sys/poll.h" "ac_cv_header_sys_poll_h" "$ac_includes_default"
++ac_fn_c_check_header_mongrel "$LINENO" "poll.h" "ac_cv_header_sys_poll_h" "$ac_includes_default"
+ if test "x$ac_cv_header_sys_poll_h" = xyes; then :
+ HAS_POLL=1
+
+@@ -19289,6 +19289,148 @@ rm -f core conftest.err conftest.$ac_obj
+
+
+
++if test "${ac_cv_header_sys_atomic_h+set}" = set; then
++ { $as_echo "$as_me:$LINENO: checking for sys/atomic.h" >&5
++$as_echo_n "checking for sys/atomic.h... " >&6; }
++if test "${ac_cv_header_sys_atomic_h+set}" = set; then
++ $as_echo_n "(cached) " >&6
++fi
++{ $as_echo "$as_me:$LINENO: result: $ac_cv_header_sys_atomic_h" >&5
++$as_echo "$ac_cv_header_sys_atomic_h" >&6; }
++else
++ # Is the header compilable?
++{ $as_echo "$as_me:$LINENO: checking sys/atomic.h usability" >&5
++$as_echo_n "checking sys/atomic.h usability... " >&6; }
++cat >conftest.$ac_ext <<_ACEOF
++/* confdefs.h. */
++_ACEOF
++cat confdefs.h >>conftest.$ac_ext
++cat >>conftest.$ac_ext <<_ACEOF
++/* end confdefs.h. */
++$ac_includes_default
++#include <sys/atomic.h>
++_ACEOF
++rm -f conftest.$ac_objext
++if { (ac_try="$ac_compile"
++case "(($ac_try" in
++ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
++ *) ac_try_echo=$ac_try;;
++esac
++eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
++$as_echo "$ac_try_echo") >&5
++ (eval "$ac_compile") 2>conftest.er1
++ ac_status=$?
++ grep -v '^ *+' conftest.er1 >conftest.err
++ rm -f conftest.er1
++ cat conftest.err >&5
++ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); } && {
++ test -z "$ac_c_werror_flag" ||
++ test ! -s conftest.err
++ } && test -s conftest.$ac_objext; then
++ ac_header_compiler=yes
++else
++ $as_echo "$as_me: failed program was:" >&5
++sed 's/^/| /' conftest.$ac_ext >&5
++
++ ac_header_compiler=no
++fi
++
++rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
++{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
++$as_echo "$ac_header_compiler" >&6; }
++
++# Is the header present?
++{ $as_echo "$as_me:$LINENO: checking sys/atomic.h presence" >&5
++$as_echo_n "checking sys/atomic.h presence... " >&6; }
++cat >conftest.$ac_ext <<_ACEOF
++/* confdefs.h. */
++_ACEOF
++cat confdefs.h >>conftest.$ac_ext
++cat >>conftest.$ac_ext <<_ACEOF
++/* end confdefs.h. */
++#include <sys/atomic.h>
++_ACEOF
++if { (ac_try="$ac_cpp conftest.$ac_ext"
++case "(($ac_try" in
++ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
++ *) ac_try_echo=$ac_try;;
++esac
++eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
++$as_echo "$ac_try_echo") >&5
++ (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
++ ac_status=$?
++ grep -v '^ *+' conftest.er1 >conftest.err
++ rm -f conftest.er1
++ cat conftest.err >&5
++ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); } >/dev/null && {
++ test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
++ test ! -s conftest.err
++ }; then
++ ac_header_preproc=yes
++else
++ $as_echo "$as_me: failed program was:" >&5
++sed 's/^/| /' conftest.$ac_ext >&5
++
++ ac_header_preproc=no
++fi
++
++rm -f conftest.err conftest.$ac_ext
++{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
++$as_echo "$ac_header_preproc" >&6; }
++
++# So? What about this header?
++case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
++ yes:no: )
++ { $as_echo "$as_me:$LINENO: WARNING: sys/atomic.h: accepted by the compiler, rejected by the preprocessor!" >&5
++$as_echo "$as_me: WARNING: sys/atomic.h: accepted by the compiler, rejected by the preprocessor!" >&2;}
++ { $as_echo "$as_me:$LINENO: WARNING: sys/atomic.h: proceeding with the compiler's result" >&5
++$as_echo "$as_me: WARNING: sys/atomic.h: proceeding with the compiler's result" >&2;}
++ ac_header_preproc=yes
++ ;;
++ no:yes:* )
++ { $as_echo "$as_me:$LINENO: WARNING: sys/atomic.h: present but cannot be compiled" >&5
++$as_echo "$as_me: WARNING: sys/atomic.h: present but cannot be compiled" >&2;}
++ { $as_echo "$as_me:$LINENO: WARNING: sys/atomic.h: check for missing prerequisite headers?" >&5
++$as_echo "$as_me: WARNING: sys/atomic.h: check for missing prerequisite headers?" >&2;}
++ { $as_echo "$as_me:$LINENO: WARNING: sys/atomic.h: see the Autoconf documentation" >&5
++$as_echo "$as_me: WARNING: sys/atomic.h: see the Autoconf documentation" >&2;}
++ { $as_echo "$as_me:$LINENO: WARNING: sys/atomic.h: section \"Present But Cannot Be Compiled\"" >&5
++$as_echo "$as_me: WARNING: sys/atomic.h: section \"Present But Cannot Be Compiled\"" >&2;}
++ { $as_echo "$as_me:$LINENO: WARNING: sys/atomic.h: proceeding with the preprocessor's result" >&5
++$as_echo "$as_me: WARNING: sys/atomic.h: proceeding with the preprocessor's result" >&2;}
++ { $as_echo "$as_me:$LINENO: WARNING: sys/atomic.h: in the future, the compiler will take precedence" >&5
++$as_echo "$as_me: WARNING: sys/atomic.h: in the future, the compiler will take precedence" >&2;}
++ ( cat <<\_ASBOX
++## ------------------------------------------ ##
++## Report this to https://issues.asterisk.org ##
++## ------------------------------------------ ##
++_ASBOX
++ ) | sed "s/^/$as_me: WARNING: /" >&2
++ ;;
++esac
++{ $as_echo "$as_me:$LINENO: checking for sys/atomic.h" >&5
++$as_echo_n "checking for sys/atomic.h... " >&6; }
++if test "${ac_cv_header_sys_atomic_h+set}" = set; then
++ $as_echo_n "(cached) " >&6
++else
++ ac_cv_header_sys_atomic_h=$ac_header_preproc
++fi
++{ $as_echo "$as_me:$LINENO: result: $ac_cv_header_sys_atomic_h" >&5
++$as_echo "$ac_cv_header_sys_atomic_h" >&6; }
++
++fi
++if test "x$ac_cv_header_sys_atomic_h" = x""yes; then
++
++cat >>confdefs.h <<_ACEOF
++#define HAVE_SYS_ATOMIC_H 1
++_ACEOF
++
++fi
++
++
++
+ # The cast to long int works around a bug in the HP C Compiler
+ # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
+ # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
+@@ -20393,6 +20535,8 @@ $as_echo_n "checking for getifaddrs() su
+
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+ /* end confdefs.h. */
++ #include <sys/types.h>
++ #include <sys/socket.h>
+ #include <ifaddrs.h>
+ int
+ main ()
diff --git a/comms/asterisk18/patches/patch-configure.ac b/comms/asterisk18/patches/patch-configure.ac
new file mode 100644
index 00000000000..459bd777da5
--- /dev/null
+++ b/comms/asterisk18/patches/patch-configure.ac
@@ -0,0 +1,34 @@
+$NetBSD: patch-configure.ac,v 1.1.1.1 2021/06/13 07:47:18 jnemeth Exp $
+
+--- configure.ac.orig 2021-03-04 16:46:08.000000000 +0000
++++ configure.ac
+@@ -751,7 +751,7 @@ AC_CHECK_HEADERS([xlocale.h])
+
+ AC_CHECK_HEADERS([winsock.h winsock2.h])
+
+-AC_CHECK_HEADER([sys/poll.h],
++AC_CHECK_HEADER([poll.h],
+ [],
+ AC_DEFINE([AST_POLL_COMPAT], 1, [Define to 1 if internal poll should be used.]))
+
+@@ -803,7 +803,7 @@ AC_FUNC_STRNLEN
+ AC_FUNC_STRTOD
+ AC_FUNC_UTIME_NULL
+ AC_FUNC_VPRINTF
+-AC_CHECK_FUNCS([asprintf atexit closefrom dup2 eaccess endpwent euidaccess ffsll ftruncate getcwd gethostbyname gethostname getloadavg gettimeofday glob ioperm inet_ntoa isascii memchr memmove memset mkdir mkdtemp munmap newlocale pipe2 ppoll putenv re_comp regcomp select setenv socket strcasecmp strcasestr strchr strcspn strdup strerror strlcat strlcpy strncasecmp strndup strnlen strrchr strsep strspn strstr strtod strtol strtold strtoq unsetenv uselocale utime vasprintf getpeereid sysctl swapctl malloc_trim])
++AC_CHECK_FUNCS([asprintf atexit closefrom dup2 eaccess endpwent euidaccess ffsll ftruncate getcwd gethostbyname gethostname getloadavg gettimeofday glob ioperm inet_ntoa isascii memchr memmove memset mkdir mkdtemp munmap newlocale pipe2 ppoll putenv re_comp regcomp select setenv socket strcasecmp strcasestr strchr strcspn strdup strerror strftime_l strlcat strlcpy strncasecmp strndup strnlen strptime_l strrchr strsep strspn strstr strtod strtol strtold strtoq unsetenv uselocale utime vasprintf getpeereid sysctl swapctl malloc_trim])
+
+ AC_MSG_CHECKING(for htonll)
+ AC_LINK_IFELSE(
+@@ -872,9 +872,9 @@ AC_SUBST(PBX_DYNAMIC_LIST)
+ LDFLAGS=${old_LDFLAGS}
+ rm -f conftest.dynamics
+
+-AC_CHECK_HEADER([sys/poll.h],
++AC_CHECK_HEADER([poll.h],
+ [HAS_POLL=1]
+- AC_DEFINE([HAVE_SYS_POLL_H], 1, [Define to 1 if your system has working sys/poll.h]),
++ AC_DEFINE([HAVE_SYS_POLL_H], 1, [Define to 1 if your system has working poll.h]),
+ )
+
+ AC_ARG_ENABLE([internal-poll],
diff --git a/comms/asterisk18/patches/patch-contrib_scripts_vmail.cgi b/comms/asterisk18/patches/patch-contrib_scripts_vmail.cgi
new file mode 100644
index 00000000000..f8ef39fc106
--- /dev/null
+++ b/comms/asterisk18/patches/patch-contrib_scripts_vmail.cgi
@@ -0,0 +1,181 @@
+$NetBSD: patch-contrib_scripts_vmail.cgi,v 1.1.1.1 2021/06/13 07:47:18 jnemeth Exp $
+
+--- contrib/scripts/vmail.cgi.orig 2015-10-09 21:48:48.000000000 +0000
++++ contrib/scripts/vmail.cgi
+@@ -145,7 +145,7 @@ sub check_login($$)
+ $context = "default";
+ }
+ if (!$filename) {
+- $filename = "/etc/asterisk/voicemail.conf";
++ $filename = "@ASTETCDIR@/voicemail.conf";
+ }
+ # print header;
+ # print "Including <h2>$filename</h2> while in <h2>$category</h2>...\n";
+@@ -153,7 +153,7 @@ sub check_login($$)
+ while(<VMAIL>) {
+ chomp;
+ if (/include\s\"([^\"]+)\"$/) {
+- ($tmp, $category) = &check_login("/etc/asterisk/$1", $category);
++ ($tmp, $category) = &check_login("@ASTETCDIR@/$1", $category);
+ if (length($tmp)) {
+ # print "Got '$tmp'\n";
+ return ($tmp, $category);
+@@ -200,7 +200,7 @@ sub check_login_users {
+ my ($mbox, $context) = split(/\@/, param('mailbox'));
+ my $pass = param('password');
+ my ($found, $fullname) = (0, "");
+- open VMAIL, "</etc/asterisk/users.conf";
++ open VMAIL, "<@ASTETCDIR@/users.conf";
+ while (<VMAIL>) {
+ chomp;
+ if (m/\[(.*)\]/) {
+@@ -242,7 +242,7 @@ sub validmailbox($$$$)
+ $context = "default";
+ }
+ if (!$filename) {
+- $filename = "/etc/asterisk/voicemail.conf";
++ $filename = "@ASTETCDIR@/voicemail.conf";
+ }
+ if (!$category) {
+ $category = "general";
+@@ -251,7 +251,7 @@ sub validmailbox($$$$)
+ while (<VMAIL>) {
+ chomp;
+ if (/include\s\"([^\"]+)\"$/) {
+- ($tmp, $category) = &validmailbox($mbox, $context, "/etc/asterisk/$1");
++ ($tmp, $category) = &validmailbox($mbox, $context, "@ASTETCDIR@/$1");
+ if ($tmp) {
+ return ($tmp, $category);
+ }
+@@ -298,7 +298,7 @@ sub mailbox_options()
+ local $tmp2;
+ local $tmp;
+ if (!$filename) {
+- $filename = "/etc/asterisk/voicemail.conf";
++ $filename = "@ASTETCDIR@/voicemail.conf";
+ }
+ if (!$category) {
+ $category = "general";
+@@ -386,7 +386,7 @@ sub mailbox_list()
+ sub msgcount()
+ {
+ my ($context, $mailbox, $folder) = @_;
+- my $path = "/var/spool/asterisk/voicemail/$context/$mailbox/$folder";
++ my $path = "@ASTSPOOLDIR@/voicemail/$context/$mailbox/$folder";
+ if (opendir(DIR, $path)) {
+ my @msgs = grep(/^msg....\.txt$/, readdir(DIR));
+ closedir(DIR);
+@@ -410,7 +410,7 @@ sub msgcountstr()
+ sub messages()
+ {
+ my ($context, $mailbox, $folder) = @_;
+- my $path = "/var/spool/asterisk/voicemail/$context/$mailbox/$folder";
++ my $path = "@ASTSPOOLDIR@/voicemail/$context/$mailbox/$folder";
+ if (opendir(DIR, $path)) {
+ my @msgs = sort grep(/^msg....\.txt$/, readdir(DIR));
+ closedir(DIR);
+@@ -435,7 +435,7 @@ sub getfields()
+ {
+ my ($context, $mailbox, $folder, $msg) = @_;
+ my $fields;
+- if (open(MSG, "</var/spool/asterisk/voicemail/$context/$mailbox/$folder/msg${msg}.txt")) {
++ if (open(MSG, "<@ASTSPOOLDIR@/voicemail/$context/$mailbox/$folder/msg${msg}.txt")) {
+ while(<MSG>) {
+ s/\#.*$//g;
+ if (/^(\w+)\s*\=\s*(.*)$/) {
+@@ -560,7 +560,7 @@ _EOH
+ <input name="action" type=submit value="download">
+ </td></tr>
+ <tr><td colspan=2 align=center>
+-<embed width=400 height=40 src="vmail.cgi?action=audio&folder=$folder&mailbox=$mbox&context=$context&password=$passwd&msgid=$msgid&format=$format&dontcasheme=$$.$format" autostart=yes loop=false></embed>
++<embed width=400 height=40 src="vmail?action=audio&folder=$folder&mailbox=$mbox&context=$context&password=$passwd&msgid=$msgid&format=$format&dontcasheme=$$.$format" autostart=yes loop=false></embed>
+ </td></tr></table>
+ </td></tr>
+ </table>
+@@ -588,7 +588,7 @@ sub message_audio()
+ }
+ &untaint($format);
+
+- my $path = "/var/spool/asterisk/voicemail/$context/$mailbox/$folder/msg${msgid}.$format";
++ my $path = "@ASTSPOOLDIR@/voicemail/$context/$mailbox/$folder/msg${msgid}.$format";
+
+ $msgid =~ /^\d\d\d\d$/ || die("Msgid Liar ($msgid)!");
+ grep(/^${format}$/, keys %formats) || die("Format Liar ($format)!");
+@@ -809,11 +809,11 @@ sub message_rename()
+ die("Invalid old Message<BR>\n");
+ }
+
+- my $path = "/var/spool/asterisk/voicemail/$context/$mbox/$newfolder";
++ my $path = "@ASTSPOOLDIR@/voicemail/$context/$mbox/$newfolder";
+ $path =~ /^(.*)$/;
+ $path = $1;
+ mkdir $path, 0770;
+- $path = "/var/spool/asterisk/voicemail/$context/$mbox/$oldfolder";
++ $path = "@ASTSPOOLDIR@/voicemail/$context/$mbox/$oldfolder";
+ opendir(DIR, $path) || die("Unable to open directory\n");
+ my @files = grep /^msg${old}\.\w+$/, readdir(DIR);
+ closedir(DIR);
+@@ -823,7 +823,7 @@ sub message_rename()
+ $tmp = $1;
+ $oldfile = $path . "/$tmp";
+ $tmp =~ s/msg${old}/msg${new}/;
+- $newfile = "/var/spool/asterisk/voicemail/$context/$mbox/$newfolder/$tmp";
++ $newfile = "@ASTSPOOLDIR@/voicemail/$context/$mbox/$newfolder/$tmp";
+ # print "Renaming $oldfile to $newfile<BR>\n";
+ rename($oldfile, $newfile);
+ }
+@@ -884,15 +884,15 @@ sub message_copy()
+ die("Invalid old Message<BR>\n");
+ }
+
+- my $path = "/var/spool/asterisk/voicemail/$context/$newmbox";
++ my $path = "@ASTSPOOLDIR@/voicemail/$context/$newmbox";
+ $path =~ /^(.*)$/;
+ $path = $1;
+ mkdir $path, 0770;
+- $path = "/var/spool/asterisk/voicemail/$context/$newmbox/INBOX";
++ $path = "@ASTSPOOLDIR@/voicemail/$context/$newmbox/INBOX";
+ $path =~ /^(.*)$/;
+ $path = $1;
+ mkdir $path, 0770;
+- $path = "/var/spool/asterisk/voicemail/$context/$mbox/$oldfolder";
++ $path = "@ASTSPOOLDIR@/voicemail/$context/$mbox/$oldfolder";
+ opendir(DIR, $path) || die("Unable to open directory\n");
+ my @files = grep /^msg${old}\.\w+$/, readdir(DIR);
+ closedir(DIR);
+@@ -902,7 +902,7 @@ sub message_copy()
+ $tmp = $1;
+ $oldfile = $path . "/$tmp";
+ $tmp =~ s/msg${old}/msg${new}/;
+- $newfile = "/var/spool/asterisk/voicemail/$context/$newmbox/INBOX/$tmp";
++ $newfile = "@ASTSPOOLDIR@/voicemail/$context/$newmbox/INBOX/$tmp";
+ # print "Copying $oldfile to $newfile<BR>\n";
+ &file_copy($oldfile, $newfile);
+ }
+@@ -932,7 +932,7 @@ sub message_delete()
+ } else {
+ die("Invalid Message<BR>\n");
+ }
+- my $path = "/var/spool/asterisk/voicemail/$context/$mbox/$folder";
++ my $path = "@ASTSPOOLDIR@/voicemail/$context/$mbox/$folder";
+ opendir(DIR, $path) || die("Unable to open directory\n");
+ my @files = grep /^msg${msg}\.\w+$/, readdir(DIR);
+ closedir(DIR);
+@@ -968,7 +968,7 @@ sub message_forward()
+ my $txt;
+ $context = &untaint($context);
+ $newmbox = &untaint($newmbox);
+- my $path = "/var/spool/asterisk/voicemail/$context/$newmbox/INBOX";
++ my $path = "@ASTSPOOLDIR@/voicemail/$context/$newmbox/INBOX";
+ if ($msgs[0]) {
+ if (&lock_path($path) == 0) {
+ $msgcount = &msgcount($context, $newmbox, "INBOX");
+@@ -1018,7 +1018,7 @@ sub message_delete_or_move()
+ $context = &untaint($context);
+ $mbox = &untaint($mbox);
+ $folder = &untaint($folder);
+- $path = "/var/spool/asterisk/voicemail/$context/$mbox/$folder";
++ $path = "@ASTSPOOLDIR@/voicemail/$context/$mbox/$folder";
+ if ($msgs[0]) {
+ if (&lock_path($path) == 0) {
+ my $msgcount = &msgcount($context, $mbox, $folder);
diff --git a/comms/asterisk18/patches/patch-funcs_func__cdr.c b/comms/asterisk18/patches/patch-funcs_func__cdr.c
new file mode 100644
index 00000000000..239f99cc932
--- /dev/null
+++ b/comms/asterisk18/patches/patch-funcs_func__cdr.c
@@ -0,0 +1,13 @@
+$NetBSD: patch-funcs_func__cdr.c,v 1.1.1.1 2021/06/13 07:47:18 jnemeth Exp $
+
+--- funcs/func_cdr.c.orig 2018-05-07 17:23:06.705808560 +0000
++++ funcs/func_cdr.c
+@@ -547,7 +547,7 @@ static int cdr_write(struct ast_channel
+
+ ast_log(LOG_WARNING, "Using the %s function to set 'amaflags' is deprecated. Please use the CHANNEL function instead.\n",
+ cmd);
+- if (isdigit(*value)) {
++ if (isdigit((unsigned char)*value)) {
+ if (sscanf(value, "%30d", &amaflags) != 1) {
+ amaflags = AST_AMA_NONE;
+ }
diff --git a/comms/asterisk18/patches/patch-funcs_func__channel.c b/comms/asterisk18/patches/patch-funcs_func__channel.c
new file mode 100644
index 00000000000..f7198f14b7f
--- /dev/null
+++ b/comms/asterisk18/patches/patch-funcs_func__channel.c
@@ -0,0 +1,13 @@
+$NetBSD: patch-funcs_func__channel.c,v 1.1.1.1 2021/06/13 07:47:18 jnemeth Exp $
+
+--- funcs/func_channel.c.orig 2018-05-07 17:22:10.785599288 +0000
++++ funcs/func_channel.c
+@@ -492,7 +492,7 @@ static int func_channel_write_real(struc
+ } else if (!strcasecmp(data, "amaflags")) {
+ int amaflags;
+
+- if (isdigit(*value)) {
++ if (isdigit((unsigned char)*value)) {
+ if (sscanf(value, "%30d", &amaflags) != 1) {
+ amaflags = AST_AMA_NONE;
+ }
diff --git a/comms/asterisk18/patches/patch-funcs_func__env.c b/comms/asterisk18/patches/patch-funcs_func__env.c
new file mode 100644
index 00000000000..3451532b9e3
--- /dev/null
+++ b/comms/asterisk18/patches/patch-funcs_func__env.c
@@ -0,0 +1,49 @@
+$NetBSD: patch-funcs_func__env.c,v 1.1.1.1 2021/06/13 07:47:18 jnemeth Exp $
+
+--- funcs/func_env.c.orig 2019-09-05 13:09:20.000000000 +0000
++++ funcs/func_env.c
+@@ -408,11 +408,11 @@ static int file_count_line(struct ast_ch
+
+ AST_STANDARD_APP_ARGS(args, data);
+ if (args.argc > 1) {
+- if (tolower(args.format[0]) == 'd') {
++ if (tolower((unsigned char)args.format[0]) == 'd') {
+ newline_format = FF_DOS;
+- } else if (tolower(args.format[0]) == 'm') {
++ } else if (tolower((unsigned char)args.format[0]) == 'm') {
+ newline_format = FF_MAC;
+- } else if (tolower(args.format[0]) == 'u') {
++ } else if (tolower((unsigned char)args.format[0]) == 'u') {
+ newline_format = FF_UNIX;
+ }
+ }
+@@ -570,11 +570,11 @@ static int file_read(struct ast_channel
+
+ /* Line-based read */
+ if (args.argc == 5) {
+- if (tolower(args.fileformat[0]) == 'd') {
++ if (tolower((unsigned char)args.fileformat[0]) == 'd') {
+ format = FF_DOS;
+- } else if (tolower(args.fileformat[0]) == 'm') {
++ } else if (tolower((unsigned char)args.fileformat[0]) == 'm') {
+ format = FF_MAC;
+- } else if (tolower(args.fileformat[0]) == 'u') {
++ } else if (tolower((unsigned char)args.fileformat[0]) == 'u') {
+ format = FF_UNIX;
+ }
+ }
+@@ -935,11 +935,11 @@ static int file_write(struct ast_channel
+
+ /* Line mode */
+ if (args.argc == 5) {
+- if (tolower(args.format[0]) == 'u') {
++ if (tolower((unsigned char)args.format[0]) == 'u') {
+ newline_format = FF_UNIX;
+- } else if (tolower(args.format[0]) == 'm') {
++ } else if (tolower((unsigned char)args.format[0]) == 'm') {
+ newline_format = FF_MAC;
+- } else if (tolower(args.format[0]) == 'd') {
++ } else if (tolower((unsigned char)args.format[0]) == 'd') {
+ newline_format = FF_DOS;
+ }
+ }
diff --git a/comms/asterisk18/patches/patch-funcs_func__pjsip__aor.c b/comms/asterisk18/patches/patch-funcs_func__pjsip__aor.c
new file mode 100644
index 00000000000..9ef7a1b2f91
--- /dev/null
+++ b/comms/asterisk18/patches/patch-funcs_func__pjsip__aor.c
@@ -0,0 +1,22 @@
+$NetBSD: patch-funcs_func__pjsip__aor.c,v 1.1.1.1 2021/06/13 07:47:18 jnemeth Exp $
+
+--- funcs/func_pjsip_aor.c.orig 2018-06-20 14:41:48.304859278 +0000
++++ funcs/func_pjsip_aor.c
+@@ -34,13 +34,14 @@
+
+ #include "asterisk.h"
+
+-#include <pjsip.h>
+-#include <pjlib.h>
+-
+ #include "asterisk/app.h"
+ #include "asterisk/pbx.h"
+ #include "asterisk/module.h"
+ #include "asterisk/sorcery.h"
++
++#include <pjsip.h>
++#include <pjlib.h>
++
+ #include "asterisk/res_pjsip.h"
+
+ /*** DOCUMENTATION
diff --git a/comms/asterisk18/patches/patch-funcs_func__pjsip__contact.c b/comms/asterisk18/patches/patch-funcs_func__pjsip__contact.c
new file mode 100644
index 00000000000..7b11fd1744c
--- /dev/null
+++ b/comms/asterisk18/patches/patch-funcs_func__pjsip__contact.c
@@ -0,0 +1,22 @@
+$NetBSD: patch-funcs_func__pjsip__contact.c,v 1.1.1.1 2021/06/13 07:47:18 jnemeth Exp $
+
+--- funcs/func_pjsip_contact.c.orig 2018-06-20 14:41:26.963425573 +0000
++++ funcs/func_pjsip_contact.c
+@@ -34,13 +34,14 @@
+
+ #include "asterisk.h"
+
+-#include <pjsip.h>
+-#include <pjlib.h>
+-
+ #include "asterisk/app.h"
+ #include "asterisk/pbx.h"
+ #include "asterisk/module.h"
+ #include "asterisk/sorcery.h"
++
++#include <pjsip.h>
++#include <pjlib.h>
++
+ #include "asterisk/res_pjsip.h"
+
+ /*** DOCUMENTATION
diff --git a/comms/asterisk18/patches/patch-funcs_func__pjsip__endpoint.c b/comms/asterisk18/patches/patch-funcs_func__pjsip__endpoint.c
new file mode 100644
index 00000000000..184117197f1
--- /dev/null
+++ b/comms/asterisk18/patches/patch-funcs_func__pjsip__endpoint.c
@@ -0,0 +1,23 @@
+$NetBSD: patch-funcs_func__pjsip__endpoint.c,v 1.1.1.1 2021/06/13 07:47:18 jnemeth Exp $
+
+--- funcs/func_pjsip_endpoint.c.orig 2018-06-20 14:41:38.307201390 +0000
++++ funcs/func_pjsip_endpoint.c
+@@ -34,14 +34,15 @@
+
+ #include "asterisk.h"
+
+-#include <pjsip.h>
+-#include <pjlib.h>
+-
+ #include "asterisk/app.h"
+ #include "asterisk/pbx.h"
+ #include "asterisk/module.h"
+ #include "asterisk/channel.h"
+ #include "asterisk/sorcery.h"
++
++#include <pjsip.h>
++#include <pjlib.h>
++
+ #include "asterisk/res_pjsip.h"
+
+ /*** DOCUMENTATION
diff --git a/comms/asterisk18/patches/patch-funcs_func__strings.c b/comms/asterisk18/patches/patch-funcs_func__strings.c
new file mode 100644
index 00000000000..63e12083794
--- /dev/null
+++ b/comms/asterisk18/patches/patch-funcs_func__strings.c
@@ -0,0 +1,40 @@
+$NetBSD: patch-funcs_func__strings.c,v 1.1.1.1 2021/06/13 07:47:18 jnemeth Exp $
+
+--- funcs/func_strings.c.orig 2018-05-07 17:21:13.413282206 +0000
++++ funcs/func_strings.c
+@@ -1483,7 +1483,7 @@ static int string_toupper(struct ast_cha
+ {
+ char *bufptr = buf, *dataptr = data;
+
+- while ((bufptr < buf + buflen - 1) && (*bufptr++ = toupper(*dataptr++)));
++ while ((bufptr < buf + buflen - 1) && (*bufptr++ = toupper((unsigned char)*dataptr++)));
+
+ return 0;
+ }
+@@ -1496,7 +1496,7 @@ static int string_toupper2(struct ast_ch
+ ast_str_make_space(buf, buflen > 0 ? buflen : strlen(data) + 1);
+ }
+ bufptr = ast_str_buffer(*buf);
+- while ((bufptr < ast_str_buffer(*buf) + ast_str_size(*buf) - 1) && (*bufptr++ = toupper(*dataptr++)));
++ while ((bufptr < ast_str_buffer(*buf) + ast_str_size(*buf) - 1) && (*bufptr++ = toupper((unsigned char)*dataptr++)));
+ ast_str_update(*buf);
+
+ return 0;
+@@ -1512,7 +1512,7 @@ static int string_tolower(struct ast_cha
+ {
+ char *bufptr = buf, *dataptr = data;
+
+- while ((bufptr < buf + buflen - 1) && (*bufptr++ = tolower(*dataptr++)));
++ while ((bufptr < buf + buflen - 1) && (*bufptr++ = tolower((unsigned char)*dataptr++)));
+
+ return 0;
+ }
+@@ -1525,7 +1525,7 @@ static int string_tolower2(struct ast_ch
+ ast_str_make_space(buf, buflen > 0 ? buflen : strlen(data) + 1);
+ }
+ bufptr = ast_str_buffer(*buf);
+- while ((bufptr < ast_str_buffer(*buf) + ast_str_size(*buf) - 1) && (*bufptr++ = tolower(*dataptr++)));
++ while ((bufptr < ast_str_buffer(*buf) + ast_str_size(*buf) - 1) && (*bufptr++ = tolower((unsigned char)*dataptr++)));
+ ast_str_update(*buf);
+
+ return 0;
diff --git a/comms/asterisk18/patches/patch-include_asterisk_autoconfig.h.in b/comms/asterisk18/patches/patch-include_asterisk_autoconfig.h.in
new file mode 100644
index 00000000000..be5f440872c
--- /dev/null
+++ b/comms/asterisk18/patches/patch-include_asterisk_autoconfig.h.in
@@ -0,0 +1,27 @@
+$NetBSD: patch-include_asterisk_autoconfig.h.in,v 1.1.1.1 2021/06/13 07:47:18 jnemeth Exp $
+
+--- include/asterisk/autoconfig.h.in.orig 2016-10-25 19:27:49.000000000 +0000
++++ include/asterisk/autoconfig.h.in
+@@ -945,6 +945,12 @@
+ /* Define to 1 if you have the `strstr' function. */
+ #undef HAVE_STRSTR
+
++/* Define to 1 if you have the `strftime_l' function. */
++#undef HAVE_STRFTIME_L
++
++/* Define to 1 if you have the `strptime_l' function. */
++#undef HAVE_STRPTIME_L
++
+ /* Define to 1 if you have the `strtod' function. */
+ #undef HAVE_STRTOD
+
+@@ -1032,6 +1038,9 @@
+ /* Define if your system has the SYSTEMD libraries. */
+ #undef HAVE_SYSTEMD
+
++/* Define to 1 if sys/atomic.h atomic operations are supported. */
++#undef HAVE_SYS_ATOMIC_H
++
+ /* Define to 1 if you have the <sys/dir.h> header file, and it defines `DIR'.
+ */
+ #undef HAVE_SYS_DIR_H
diff --git a/comms/asterisk18/patches/patch-include_asterisk_lock.h b/comms/asterisk18/patches/patch-include_asterisk_lock.h
new file mode 100644
index 00000000000..dda74fb0594
--- /dev/null
+++ b/comms/asterisk18/patches/patch-include_asterisk_lock.h
@@ -0,0 +1,31 @@
+$NetBSD: patch-include_asterisk_lock.h,v 1.1.1.1 2021/06/13 07:47:18 jnemeth Exp $
+
+--- include/asterisk/lock.h.orig 2021-03-04 16:46:08.000000000 +0000
++++ include/asterisk/lock.h
+@@ -616,6 +616,17 @@ static void __attribute__((destructor))
+ */
+ #define SCOPED_CHANNELLOCK(varname, chan) SCOPED_LOCK(varname, (chan), ast_channel_lock, ast_channel_unlock)
+
++#undef pthread_mutex_lock
++#undef pthread_mutex_unlock
++#undef pthread_mutex_trylock
++#undef pthread_mutex_init
++#undef pthread_mutex_destroy
++#undef pthread_cond_init
++#undef pthread_cond_destroy
++#undef pthread_cond_signal
++#undef pthread_cond_broadcast
++#undef pthread_cond_wait
++#undef pthread_cond_timedwait
+ #ifndef __CYGWIN__ /* temporary disabled for cygwin */
+ #define pthread_mutex_t use_ast_mutex_t_instead_of_pthread_mutex_t
+ #define pthread_cond_t use_ast_cond_t_instead_of_pthread_cond_t
+@@ -636,7 +647,7 @@ static void __attribute__((destructor))
+
+ #define gethostbyname __gethostbyname__is__not__reentrant__use__ast_gethostbyname__instead__
+
+-#ifndef __linux__
++#if !defined(__linux__) && !defined(__DragonFly__)
+ #define pthread_create __use_ast_pthread_create_instead__
+ #endif
+
diff --git a/comms/asterisk18/patches/patch-include_asterisk_sha1.h b/comms/asterisk18/patches/patch-include_asterisk_sha1.h
new file mode 100644
index 00000000000..21653357077
--- /dev/null
+++ b/comms/asterisk18/patches/patch-include_asterisk_sha1.h
@@ -0,0 +1,131 @@
+$NetBSD: patch-include_asterisk_sha1.h,v 1.1.1.1 2021/06/13 07:47:18 jnemeth Exp $
+
+--- include/asterisk/sha1.h.orig 2016-09-09 16:14:37.000000000 +0000
++++ include/asterisk/sha1.h
+@@ -191,49 +191,6 @@ typedef struct SHA256Context SHA224Conte
+ typedef struct SHA512Context SHA384Context;
+
+ /*
+- * This structure holds context information for all SHA
+- * hashing operations.
+- */
+-typedef struct USHAContext {
+- int whichSha; /* which SHA is being used */
+- union {
+- SHA1Context sha1Context;
+- SHA224Context sha224Context; SHA256Context sha256Context;
+- SHA384Context sha384Context; SHA512Context sha512Context;
+- } ctx;
+-} USHAContext;
+-
+-/*
+- * This structure will hold context information for the HMAC
+- * keyed-hashing operation.
+- */
+-typedef struct HMACContext {
+- int whichSha; /* which SHA is being used */
+- int hashSize; /* hash size of SHA being used */
+- int blockSize; /* block size of SHA being used */
+- USHAContext shaContext; /* SHA context */
+- unsigned char k_opad[USHA_Max_Message_Block_Size];
+- /* outer padding - key XORd with opad */
+- int Computed; /* Is the MAC computed? */
+- int Corrupted; /* Cumulative corruption code */
+-
+-} HMACContext;
+-
+-/*
+- * This structure will hold context information for the HKDF
+- * extract-and-expand Key Derivation Functions.
+- */
+-typedef struct HKDFContext {
+- int whichSha; /* which SHA is being used */
+- HMACContext hmacContext;
+- int hashSize; /* hash size of SHA being used */
+- unsigned char prk[USHAMaxHashSize];
+- /* pseudo-random key - output of hkdfInput */
+- int Computed; /* Is the key material computed? */
+- int Corrupted; /* Cumulative corruption code */
+-} HKDFContext;
+-
+-/*
+ * Function Prototypes
+ */
+
+@@ -281,76 +238,6 @@ extern int SHA512FinalBits(SHA512Context
+ extern int SHA512Result(SHA512Context *,
+ uint8_t Message_Digest[SHA512HashSize]);
+
+-/* Unified SHA functions, chosen by whichSha */
+-extern int USHAReset(USHAContext *context, SHAversion whichSha);
+-extern int USHAInput(USHAContext *context,
+- const uint8_t *bytes, unsigned int bytecount);
+-extern int USHAFinalBits(USHAContext *context,
+- uint8_t bits, unsigned int bit_count);
+-extern int USHAResult(USHAContext *context,
+- uint8_t Message_Digest[USHAMaxHashSize]);
+-extern int USHABlockSize(enum SHAversion whichSha);
+-extern int USHAHashSize(enum SHAversion whichSha);
+-extern int USHAHashSizeBits(enum SHAversion whichSha);
+-extern const char *USHAHashName(enum SHAversion whichSha);
+-
+-/*
+- * HMAC Keyed-Hashing for Message Authentication, RFC 2104,
+- * for all SHAs.
+- * This interface allows a fixed-length text input to be used.
+- */
+-extern int hmac(SHAversion whichSha, /* which SHA algorithm to use */
+- const unsigned char *text, /* pointer to data stream */
+- int text_len, /* length of data stream */
+- const unsigned char *key, /* pointer to authentication key */
+- int key_len, /* length of authentication key */
+- uint8_t digest[USHAMaxHashSize]); /* caller digest to fill in */
+-
+-/*
+- * HMAC Keyed-Hashing for Message Authentication, RFC 2104,
+- * for all SHAs.
+- * This interface allows any length of text input to be used.
+- */
+-extern int hmacReset(HMACContext *context, enum SHAversion whichSha,
+- const unsigned char *key, int key_len);
+-extern int hmacInput(HMACContext *context, const unsigned char *text,
+- int text_len);
+-extern int hmacFinalBits(HMACContext *context, uint8_t bits,
+- unsigned int bit_count);
+-extern int hmacResult(HMACContext *context,
+- uint8_t digest[USHAMaxHashSize]);
+-
+-/*
+- * HKDF HMAC-based Extract-and-Expand Key Derivation Function,
+- * RFC 5869, for all SHAs.
+- */
+-extern int hkdf(SHAversion whichSha, const unsigned char *salt,
+- int salt_len, const unsigned char *ikm, int ikm_len,
+- const unsigned char *info, int info_len,
+- uint8_t okm[ ], int okm_len);
+-extern int hkdfExtract(SHAversion whichSha, const unsigned char *salt,
+- int salt_len, const unsigned char *ikm,
+- int ikm_len, uint8_t prk[USHAMaxHashSize]);
+-extern int hkdfExpand(SHAversion whichSha, const uint8_t prk[ ],
+- int prk_len, const unsigned char *info,
+- int info_len, uint8_t okm[ ], int okm_len);
+-
+-/*
+- * HKDF HMAC-based Extract-and-Expand Key Derivation Function,
+- * RFC 5869, for all SHAs.
+- * This interface allows any length of text input to be used.
+- */
+-extern int hkdfReset(HKDFContext *context, enum SHAversion whichSha,
+- const unsigned char *salt, int salt_len);
+-extern int hkdfInput(HKDFContext *context, const unsigned char *ikm,
+- int ikm_len);
+-extern int hkdfFinalBits(HKDFContext *context, uint8_t ikm_bits,
+- unsigned int ikm_bit_count);
+-extern int hkdfResult(HKDFContext *context,
+- uint8_t prk[USHAMaxHashSize],
+- const unsigned char *info, int info_len,
+- uint8_t okm[USHAMaxHashSize], int okm_len);
+-
+ /************************ sha-private.h ************************/
+ /***************** See RFC 6234 for details. *******************/
+ /*
diff --git a/comms/asterisk18/patches/patch-include_asterisk_strings.h b/comms/asterisk18/patches/patch-include_asterisk_strings.h
new file mode 100644
index 00000000000..0730059dca9
--- /dev/null
+++ b/comms/asterisk18/patches/patch-include_asterisk_strings.h
@@ -0,0 +1,40 @@
+$NetBSD: patch-include_asterisk_strings.h,v 1.1.1.1 2021/06/13 07:47:18 jnemeth Exp $
+
+--- include/asterisk/strings.h.orig 2018-05-01 20:12:26.000000000 +0000
++++ include/asterisk/strings.h
+@@ -1168,7 +1168,7 @@ char *ast_tech_to_upper(char *dev_str),
+ }
+
+ for (pos = dev_str; *pos && *pos != '/'; pos++) {
+- *pos = toupper(*pos);
++ *pos = toupper((unsigned char)*pos);
+ }
+ return dev_str;
+ }
+@@ -1244,7 +1244,7 @@ static force_inline int attribute_pure a
+ unsigned int hash = 5381;
+
+ while (*str) {
+- hash = hash * 33 ^ (unsigned char) tolower(*str++);
++ hash = hash * 33 ^ tolower((unsigned char)*str++);
+ }
+
+ return ast_str_hash_restrict(hash);
+@@ -1265,7 +1265,7 @@ static force_inline char *attribute_pure
+ }
+
+ for (; *str; ++str) {
+- *str = tolower(*str);
++ *str = tolower((unsigned char)*str);
+ }
+
+ return str_orig;
+@@ -1286,7 +1286,7 @@ static force_inline char *attribute_pure
+ }
+
+ for (; *str; ++str) {
+- *str = toupper(*str);
++ *str = toupper((unsigned char)*str);
+ }
+
+ return str_orig;
diff --git a/comms/asterisk18/patches/patch-main_Makefile b/comms/asterisk18/patches/patch-main_Makefile
new file mode 100644
index 00000000000..4b5ddcfb24c
--- /dev/null
+++ b/comms/asterisk18/patches/patch-main_Makefile
@@ -0,0 +1,38 @@
+$NetBSD: patch-main_Makefile,v 1.1.1.1 2021/06/13 07:47:18 jnemeth Exp $
+
+--- main/Makefile.orig 2021-03-04 16:46:08.000000000 +0000
++++ main/Makefile
+@@ -97,6 +97,10 @@ ifeq ($(OSARCH),OpenBSD)
+ AST_LIBS+=-lcrypto -lpthread -lm
+ endif
+
++ifeq ($(OSARCH),dragonfly)
++ AST_LIBS+=-lpthread
++endif
++
+ ifeq ($(OSARCH),SunOS)
+ AST_LIBS+=-lpthread -ldl -lrt -lnsl -lsocket -lresolv
+ ASTSSL_LIBS+=-L/opt/ssl/lib -L/usr/local/ssl/lib
+@@ -243,7 +247,7 @@ libasteriskpj.o: _ASTCFLAGS+=$(PJPROJECT
+ ifeq ($(PJPROJECT_BUNDLED),yes)
+
+ ASTPJ_SO_VERSION=2
+-ASTPJ_LDLIBS=-L. -lasteriskpj
++ASTPJ_LDLIBS=${COMPILER_RPATH_FLAG}${PREFIX}/lib/asterisk -L. -lasteriskpj
+
+ PJDIR=$(ASTTOPDIR)/$(PJPROJECT_DIR)/source
+ -include $(ASTTOPDIR)/$(PJPROJECT_DIR)/build.mak
+@@ -330,10 +334,10 @@ bininstall:
+ $(INSTALL) -m 755 $(MAIN_TGT) "$(DESTDIR)$(ASTSBINDIR)/"
+ ifeq ($(AST_ASTERISKSSL),yes)
+ ifeq ($(findstring darwin,$(OSARCH)),) # not Darwin
+- $(INSTALL) -m 755 $(ASTSSL_LIB).$(ASTSSL_SO_VERSION) "$(DESTDIR)$(ASTLIBDIR)/"
+- $(LN) -sf $(ASTSSL_LIB).$(ASTSSL_SO_VERSION) "$(DESTDIR)$(ASTLIBDIR)/$(ASTSSL_LIB)"
++ $(INSTALL) -m 755 $(ASTSSL_LIB).$(ASTSSL_SO_VERSION) "$(DESTDIR)$(PREFIX)/lib/"
++ $(LN) -sf $(ASTSSL_LIB).$(ASTSSL_SO_VERSION) "$(DESTDIR)$(PREFIX)/lib/$(ASTSSL_LIB)"
+ else # Darwin
+- $(INSTALL) -m 755 $(ASTSSL_LIB) "$(DESTDIR)$(ASTLIBDIR)/"
++ $(INSTALL) -m 755 $(ASTSSL_LIB) "$(DESTDIR)$(PREFIX)/lib/"
+ endif
+ endif
+ ifeq ($(PJPROJECT_BUNDLED),yes)
diff --git a/comms/asterisk18/patches/patch-main_acl.c b/comms/asterisk18/patches/patch-main_acl.c
new file mode 100644
index 00000000000..b5e5424d5d5
--- /dev/null
+++ b/comms/asterisk18/patches/patch-main_acl.c
@@ -0,0 +1,40 @@
+$NetBSD: patch-main_acl.c,v 1.1.1.1 2021/06/13 07:47:18 jnemeth Exp $
+
+--- main/acl.c.orig 2015-10-09 21:48:48.000000000 +0000
++++ main/acl.c
+@@ -127,7 +127,7 @@ static int get_local_address(struct ast_
+ char *buf = NULL;
+ int bufsz, x;
+ #endif /* SOLARIS */
+-#if defined(__OpenBSD__) || defined(__NetBSD__) || defined(__FreeBSD__) || defined(__linux__) || defined(__Darwin__) || defined(__GLIBC__)
++#if defined(__OpenBSD__) || defined(__NetBSD__) || defined(__FreeBSD__) || defined(__linux__) || defined(__Darwin__) || defined(__DragonFly__) || defined(__GLIBC__)
+ struct ifaddrs *ifap, *ifaphead;
+ int rtnerr;
+ const struct sockaddr_in *sin;
+@@ -136,7 +136,7 @@ static int get_local_address(struct ast_
+ int best_score = -100;
+ memset(&best_addr, 0, sizeof(best_addr));
+
+-#if defined(__OpenBSD__) || defined(__NetBSD__) || defined(__FreeBSD__) || defined(__linux__) || defined(__Darwin__) || defined(__GLIBC__)
++#if defined(__OpenBSD__) || defined(__NetBSD__) || defined(__FreeBSD__) || defined(__linux__) || defined(__Darwin__) || defined(__DragonFly__) || defined(__GLIBC__)
+ rtnerr = getifaddrs(&ifaphead);
+ if (rtnerr) {
+ perror(NULL);
+@@ -147,7 +147,7 @@ static int get_local_address(struct ast_
+ s = socket(AF_INET, SOCK_STREAM, 0);
+
+ if (s > 0) {
+-#if defined(__OpenBSD__) || defined(__NetBSD__) || defined(__FreeBSD__) || defined(__linux__) || defined(__Darwin__) || defined(__GLIBC__)
++#if defined(__OpenBSD__) || defined(__NetBSD__) || defined(__FreeBSD__) || defined(__linux__) || defined(__Darwin__) || defined(__DragonFly__) || defined(__GLIBC__)
+ for (ifap = ifaphead; ifap; ifap = ifap->ifa_next) {
+
+ if (ifap->ifa_addr && ifap->ifa_addr->sa_family == AF_INET) {
+@@ -206,7 +206,7 @@ static int get_local_address(struct ast_
+
+ close(s);
+ }
+-#if defined(__OpenBSD__) || defined(__NetBSD__) || defined(__FreeBSD__) || defined(__linux__) || defined(__Darwin__)
++#if defined(__OpenBSD__) || defined(__NetBSD__) || defined(__FreeBSD__) || defined(__linux__) || defined(__Darwin__) || defined(__DragonFly__)
+ freeifaddrs(ifaphead);
+ #endif /* BSD_OR_LINUX */
+
diff --git a/comms/asterisk18/patches/patch-main_app.c b/comms/asterisk18/patches/patch-main_app.c
new file mode 100644
index 00000000000..1160e50a59a
--- /dev/null
+++ b/comms/asterisk18/patches/patch-main_app.c
@@ -0,0 +1,13 @@
+$NetBSD: patch-main_app.c,v 1.1.1.1 2021/06/13 07:47:18 jnemeth Exp $
+
+--- main/app.c.orig 2018-05-07 17:23:29.870389813 +0000
++++ main/app.c
+@@ -3085,7 +3085,7 @@ int ast_app_parse_timelen(const char *ti
+ break;
+ case 'm':
+ case 'M':
+- if (toupper(u[1]) == 'S') {
++ if (toupper((unsigned char)u[1]) == 'S') {
+ unit = TIMELEN_MILLISECONDS;
+ if (u[2] != '\0') {
+ return -1;
diff --git a/comms/asterisk18/patches/patch-main_ast__expr2.c b/comms/asterisk18/patches/patch-main_ast__expr2.c
new file mode 100644
index 00000000000..7dbcd59e626
--- /dev/null
+++ b/comms/asterisk18/patches/patch-main_ast__expr2.c
@@ -0,0 +1,16 @@
+$NetBSD: patch-main_ast__expr2.c,v 1.1.1.1 2021/06/13 07:47:18 jnemeth Exp $
+
+--- main/ast_expr2.c.orig 2018-05-07 17:49:06.171631311 +0000
++++ main/ast_expr2.c
+@@ -2545,9 +2545,9 @@ make_str (const char *s)
+ return(NULL);
+ }
+
+- for (i = 0, isint = (isdigit(s[0]) || s[0] == '-' || s[0]=='.'); isint && i < strlen(s); i++)
++ for (i = 0, isint = (isdigit((unsigned char)s[0]) || s[0] == '-' || s[0]=='.'); isint && i < strlen(s); i++)
+ {
+- if (!isdigit(s[i]) && s[i] != '.') {
++ if (!isdigit((unsigned char)s[i]) && s[i] != '.') {
+ isint = 0;
+ break;
+ }
diff --git a/comms/asterisk18/patches/patch-main_ast__expr2.y b/comms/asterisk18/patches/patch-main_ast__expr2.y
new file mode 100644
index 00000000000..fbb2b96087b
--- /dev/null
+++ b/comms/asterisk18/patches/patch-main_ast__expr2.y
@@ -0,0 +1,16 @@
+$NetBSD: patch-main_ast__expr2.y,v 1.1.1.1 2021/06/13 07:47:18 jnemeth Exp $
+
+--- main/ast_expr2.y.orig 2018-05-07 17:23:43.934750158 +0000
++++ main/ast_expr2.y
+@@ -538,9 +538,9 @@ make_str (const char *s)
+ return(NULL);
+ }
+
+- for (i = 0, isint = (isdigit(s[0]) || s[0] == '-' || s[0]=='.'); isint && i < strlen(s); i++)
++ for (i = 0, isint = (isdigit((unsigned char)s[0]) || s[0] == '-' || s[0]=='.'); isint && i < strlen(s); i++)
+ {
+- if (!isdigit(s[i]) && s[i] != '.') {
++ if (!isdigit((unsigned char)s[i]) && s[i] != '.') {
+ isint = 0;
+ break;
+ }
diff --git a/comms/asterisk18/patches/patch-main_asterisk.c b/comms/asterisk18/patches/patch-main_asterisk.c
new file mode 100644
index 00000000000..2d44ea46374
--- /dev/null
+++ b/comms/asterisk18/patches/patch-main_asterisk.c
@@ -0,0 +1,40 @@
+$NetBSD: patch-main_asterisk.c,v 1.1.1.1 2021/06/13 07:47:18 jnemeth Exp $
+
+--- main/asterisk.c.orig 2019-09-05 13:09:20.000000000 +0000
++++ main/asterisk.c
+@@ -852,7 +852,7 @@ int64_t ast_mark(int i, int startstop)
+ #define DEFINE_PROFILE_MIN_MAX_VALUES min = 0; \
+ max = prof_data->entries;\
+ if (a->argc > 3) { /* specific entries */ \
+- if (isdigit(a->argv[3][0])) { \
++ if (isdigit((unsigned char)a->argv[3][0])) { \
+ min = atoi(a->argv[3]); \
+ if (a->argc == 5 && strcmp(a->argv[4], "-")) \
+ max = atoi(a->argv[4]); \
+@@ -2274,7 +2274,7 @@ static int remoteconsolehandler(const ch
+ if (!ast_all_zeros(s))
+ ast_el_add_history(s);
+
+- while (isspace(*s)) {
++ while (isspace((unsigned char)*s)) {
+ s++;
+ }
+
+@@ -2286,7 +2286,7 @@ static int remoteconsolehandler(const ch
+ ast_safe_system(getenv("SHELL") ? getenv("SHELL") : "/bin/sh");
+ ret = 1;
+ } else if ((strncasecmp(s, "quit", 4) == 0 || strncasecmp(s, "exit", 4) == 0) &&
+- (s[4] == '\0' || isspace(s[4]))) {
++ (s[4] == '\0' || isspace((unsigned char)s[4]))) {
+ quit_handler(0, SHUTDOWN_FAST, 0);
+ ret = 1;
+ }
+@@ -2949,7 +2949,7 @@ static char *cli_complete(EditLine *edit
+ ptr = (char *)lf->cursor;
+ if (ptr) {
+ while (ptr > lf->buffer) {
+- if (isspace(*ptr)) {
++ if (isspace((unsigned char)*ptr)) {
+ ptr++;
+ break;
+ }
diff --git a/comms/asterisk18/patches/patch-main_astmm.c b/comms/asterisk18/patches/patch-main_astmm.c
new file mode 100644
index 00000000000..647018349b6
--- /dev/null
+++ b/comms/asterisk18/patches/patch-main_astmm.c
@@ -0,0 +1,13 @@
+$NetBSD: patch-main_astmm.c,v 1.1.1.1 2021/06/13 07:47:18 jnemeth Exp $
+
+--- main/astmm.c.orig 2015-10-09 21:48:48.000000000 +0000
++++ main/astmm.c
+@@ -1487,7 +1487,7 @@ void __ast_mm_init_phase_2(void)
+
+ mmlog = fopen(filename, "a+");
+ if (mmlog) {
+- fprintf(mmlog, "%ld - New session\n", (long) time(NULL));
++ fprintf(mmlog, "%jd - New session\n", (intmax_t) time(NULL));
+ fflush(mmlog);
+ } else {
+ ast_log(LOG_ERROR, "Could not open malloc debug log file: %s\n", filename);
diff --git a/comms/asterisk18/patches/patch-main_bridge__basic.c b/comms/asterisk18/patches/patch-main_bridge__basic.c
new file mode 100644
index 00000000000..2fec3c063d4
--- /dev/null
+++ b/comms/asterisk18/patches/patch-main_bridge__basic.c
@@ -0,0 +1,13 @@
+$NetBSD: patch-main_bridge__basic.c,v 1.1.1.1 2021/06/13 07:47:18 jnemeth Exp $
+
+--- main/bridge_basic.c.orig 2018-05-07 17:25:08.340535041 +0000
++++ main/bridge_basic.c
+@@ -167,7 +167,7 @@ static int build_dtmf_features(struct as
+ size_t number_of_missing_features = 0;
+
+ for (feature = features; *feature; feature++) {
+- if (!isupper(*feature)) {
++ if (!isupper((unsigned char)*feature)) {
+ ast_log(LOG_ERROR, "Features string '%s' rejected because it contains non-uppercase feature.\n", features);
+ return -1;
+ }
diff --git a/comms/asterisk18/patches/patch-main_callerid.c b/comms/asterisk18/patches/patch-main_callerid.c
new file mode 100644
index 00000000000..abfb61b835e
--- /dev/null
+++ b/comms/asterisk18/patches/patch-main_callerid.c
@@ -0,0 +1,28 @@
+$NetBSD: patch-main_callerid.c,v 1.1.1.1 2021/06/13 07:47:18 jnemeth Exp $
+
+--- main/callerid.c.orig 2018-05-07 17:25:23.439816235 +0000
++++ main/callerid.c
+@@ -233,20 +233,20 @@ void callerid_get_dtmf(char *cidstring,
+ for (i = 1; i < strlen(cidstring); i++) {
+ if (cidstring[i] == 'C' || cidstring[i] == '#')
+ break;
+- if (isdigit(cidstring[i]))
++ if (isdigit((unsigned char)cidstring[i]))
+ number[i-1] = cidstring[i];
+ else
+ ast_debug(1, "Unknown CID digit '%c'\n",
+ cidstring[i]);
+ }
+ number[i-1] = 0;
+- } else if (isdigit(cidstring[0])) {
++ } else if (isdigit((unsigned char)cidstring[0])) {
+ /* It begins with a digit, so we parse it as a number and hope
+ * for the best */
+ ast_log(LOG_WARNING, "Couldn't detect start-character. CID "
+ "parsing might be unreliable\n");
+ for (i = 0; i < strlen(cidstring); i++) {
+- if (isdigit(cidstring[i]))
++ if (isdigit((unsigned char)cidstring[i]))
+ number[i] = cidstring[i];
+ else
+ break;
diff --git a/comms/asterisk18/patches/patch-main_cdr.c b/comms/asterisk18/patches/patch-main_cdr.c
new file mode 100644
index 00000000000..545e47a1e52
--- /dev/null
+++ b/comms/asterisk18/patches/patch-main_cdr.c
@@ -0,0 +1,25 @@
+$NetBSD: patch-main_cdr.c,v 1.1.1.1 2021/06/13 07:47:18 jnemeth Exp $
+
+--- main/cdr.c.orig 2015-10-09 21:48:48.000000000 +0000
++++ main/cdr.c
+@@ -2787,7 +2787,7 @@ static const char *cdr_format_var_intern
+ static void cdr_get_tv(struct timeval when, const char *fmt, char *buf, int bufsize)
+ {
+ if (fmt == NULL) { /* raw mode */
+- snprintf(buf, bufsize, "%ld.%06ld", (long)when.tv_sec, (long)when.tv_usec);
++ snprintf(buf, bufsize, "%jd.%06ld", (intmax_t)when.tv_sec, (long)when.tv_usec);
+ } else {
+ buf[0] = '\0';/* Ensure the buffer is initialized. */
+ if (when.tv_sec) {
+@@ -2833,9 +2833,9 @@ void ast_cdr_format_var(struct ast_cdr *
+ } else if (!strcasecmp(name, "end")) {
+ cdr_get_tv(cdr->end, raw ? NULL : fmt, workspace, workspacelen);
+ } else if (!strcasecmp(name, "duration")) {
+- snprintf(workspace, workspacelen, "%ld", cdr->end.tv_sec != 0 ? cdr->duration : (long)ast_tvdiff_ms(ast_tvnow(), cdr->start) / 1000);
++ snprintf(workspace, workspacelen, "%jd", cdr->end.tv_sec != 0 ? cdr->duration : (intmax_t)ast_tvdiff_ms(ast_tvnow(), cdr->start) / 1000);
+ } else if (!strcasecmp(name, "billsec")) {
+- snprintf(workspace, workspacelen, "%ld", (cdr->billsec || !ast_tvzero(cdr->end) || ast_tvzero(cdr->answer)) ? cdr->billsec : (long)ast_tvdiff_ms(ast_tvnow(), cdr->answer) / 1000);
++ snprintf(workspace, workspacelen, "%jd", (cdr->billsec || !ast_tvzero(cdr->end) || ast_tvzero(cdr->answer)) ? cdr->billsec : (intmax_t)ast_tvdiff_ms(ast_tvnow(), cdr->answer) / 1000);
+ } else if (!strcasecmp(name, "disposition")) {
+ if (raw) {
+ snprintf(workspace, workspacelen, "%ld", cdr->disposition);
diff --git a/comms/asterisk18/patches/patch-main_cel.c b/comms/asterisk18/patches/patch-main_cel.c
new file mode 100644
index 00000000000..a53fedf572c
--- /dev/null
+++ b/comms/asterisk18/patches/patch-main_cel.c
@@ -0,0 +1,13 @@
+$NetBSD: patch-main_cel.c,v 1.1.1.1 2021/06/13 07:47:18 jnemeth Exp $
+
+--- main/cel.c.orig 2015-10-09 21:48:48.000000000 +0000
++++ main/cel.c
+@@ -790,7 +790,7 @@ struct ast_channel *ast_cel_fabricate_ch
+ }
+
+ if (ast_strlen_zero(cfg->general->date_format)) {
+- snprintf(timebuf, sizeof(timebuf), "%ld.%06ld", (long) record.event_time.tv_sec,
++ snprintf(timebuf, sizeof(timebuf), "%jd.%06ld", (intmax_t) record.event_time.tv_sec,
+ (long) record.event_time.tv_usec);
+ } else {
+ struct ast_tm tm;
diff --git a/comms/asterisk18/patches/patch-main_cli.c b/comms/asterisk18/patches/patch-main_cli.c
new file mode 100644
index 00000000000..4a1eae894ed
--- /dev/null
+++ b/comms/asterisk18/patches/patch-main_cli.c
@@ -0,0 +1,22 @@
+$NetBSD: patch-main_cli.c,v 1.1.1.1 2021/06/13 07:47:18 jnemeth Exp $
+
+--- main/cli.c.orig 2018-05-07 17:26:06.732494913 +0000
++++ main/cli.c
+@@ -2440,7 +2440,7 @@ static char *parse_args(const char *s, i
+ cur = duplicate;
+
+ /* Remove leading spaces from the command */
+- while (isspace(*s)) {
++ while (isspace((unsigned char)*s)) {
+ cur++;
+ s++;
+ }
+@@ -2627,7 +2627,7 @@ struct ast_vector_string *ast_cli_comple
+ continue;
+ }
+
+- while (i < max_equal && toupper(prevstr[i]) == toupper(retstr[i])) {
++ while (i < max_equal && toupper((unsigned char)prevstr[i]) == toupper((unsigned char)retstr[i])) {
+ i++;
+ }
+
diff --git a/comms/asterisk18/patches/patch-main_conversions.c b/comms/asterisk18/patches/patch-main_conversions.c
new file mode 100644
index 00000000000..a8c9aab7b00
--- /dev/null
+++ b/comms/asterisk18/patches/patch-main_conversions.c
@@ -0,0 +1,13 @@
+$NetBSD: patch-main_conversions.c,v 1.1.1.1 2021/06/13 07:47:18 jnemeth Exp $
+
+--- main/conversions.c.orig 2021-03-04 16:46:08.000000000 +0000
++++ main/conversions.c
+@@ -37,7 +37,7 @@ static int str_is_negative(const char **
+ * Ignore any preceding white space. It's okay to move the pointer here
+ * since the converting function would do the same, i.e. skip white space.
+ */
+- while (isspace(**str)) ++*str;
++ while (isspace((unsigned char)**str)) ++*str;
+ return **str == '-';
+ }
+
diff --git a/comms/asterisk18/patches/patch-main_dns__naptr.c b/comms/asterisk18/patches/patch-main_dns__naptr.c
new file mode 100644
index 00000000000..e870126b774
--- /dev/null
+++ b/comms/asterisk18/patches/patch-main_dns__naptr.c
@@ -0,0 +1,40 @@
+$NetBSD: patch-main_dns__naptr.c,v 1.1.1.1 2021/06/13 07:47:18 jnemeth Exp $
+
+--- main/dns_naptr.c.orig 2018-05-07 17:26:59.602834230 +0000
++++ main/dns_naptr.c
+@@ -78,7 +78,7 @@ static enum flags_result interpret_flags
+ *flags == 'a' || *flags == 'A' ||
+ *flags == 'u' || *flags == 'U') {
+ return FLAGS_TERMINAL;
+- } else if (!isalnum(*flags)) {
++ } else if (!isalnum((unsigned char)*flags)) {
+ return FLAGS_INVALID;
+ } else {
+ return FLAGS_UNKNOWN;
+@@ -90,7 +90,7 @@ static enum flags_result interpret_flags
+ * S, A, U, and P flags together.
+ */
+ for (i = 0; i < flags_size; ++i) {
+- if (!isalnum(flags[i])) {
++ if (!isalnum((unsigned char)flags[i])) {
+ return FLAGS_INVALID;
+ } else if (flags[i] == 's' || flags[i] == 'S') {
+ if (known_flag_found && known_flag_found != 's') {
+@@ -146,7 +146,7 @@ static int services_invalid(const char *
+ uint8_t current_size = plus_pos ? plus_pos - current_pos : end_of_services - current_pos;
+ int i;
+
+- if (!isalpha(current_pos[0])) {
++ if (!isalpha((unsigned char)current_pos[0])) {
+ return -1;
+ }
+
+@@ -155,7 +155,7 @@ static int services_invalid(const char *
+ }
+
+ for (i = 1; i < current_size; ++i) {
+- if (!isalnum(current_pos[i])) {
++ if (!isalnum((unsigned char)current_pos[i])) {
+ return -1;
+ }
+ }
diff --git a/comms/asterisk18/patches/patch-main_enum.c b/comms/asterisk18/patches/patch-main_enum.c
new file mode 100644
index 00000000000..ac8a36ca5ba
--- /dev/null
+++ b/comms/asterisk18/patches/patch-main_enum.c
@@ -0,0 +1,76 @@
+$NetBSD: patch-main_enum.c,v 1.1.1.1 2021/06/13 07:47:18 jnemeth Exp $
+
+--- main/enum.c.orig 2021-03-04 16:46:08.000000000 +0000
++++ main/enum.c
+@@ -219,7 +219,7 @@ static int blr_txt(const char *cc, const
+ ast_mutex_unlock(&enumlock);
+
+ for (p2 = (char *) cc + strlen(cc) - 1; p2 >= cc; p2--) {
+- if (isdigit(*p2)) {
++ if (isdigit((unsigned char)*p2)) {
+ *p1++ = *p2;
+ *p1++ = '.';
+ }
+@@ -348,7 +348,7 @@ static int blr_ebl(const char *cc, const
+ ast_mutex_unlock(&enumlock);
+
+ for (p2 = (char *) cc + strlen(cc) - 1; p2 >= cc; p2--) {
+- if (isdigit(*p2)) {
++ if (isdigit((unsigned char)*p2)) {
+ *p1++ = *p2;
+ *p1++ = '.';
+ }
+@@ -458,7 +458,7 @@ static int parse_naptr(unsigned char *ds
+ naptrinput, flags, services, regexp, repl);
+
+
+- if (tolower(flags[0]) != 'u') {
++ if (tolower((unsigned char)flags[0]) != 'u') {
+ ast_log(LOG_WARNING, "NAPTR Flag must be 'U' or 'u'.\n");
+ return -1;
+ }
+@@ -551,7 +551,7 @@ static int parse_naptr(unsigned char *ds
+ * beginning and ending indexes of the substring to insert as the backreference.
+ * if no backreference is found, continue copying the subst into tempdst */
+ while (*subst && (d_len > 0)) {
+- if ((subst[0] == '\\') && isdigit(subst[1])) { /* is this character the beginning of a backreference */
++ if ((subst[0] == '\\') && isdigit((unsigned char)subst[1])) { /* is this character the beginning of a backreference */
+ matchindex = (int) (subst[1] - '0');
+ if (matchindex >= ARRAY_LEN(pmatch)) {
+ ast_log(LOG_WARNING, "Error during regex substitution. Invalid pmatch index.\n");
+@@ -573,7 +573,7 @@ static int parse_naptr(unsigned char *ds
+ ast_log(LOG_WARNING, "Error during regex substitution. Invalid backreference index.\n");
+ return -1;
+ }
+- } else if (isprint(*subst)) {
++ } else if (isprint((unsigned char)*subst)) {
+ *d++ = *subst++;
+ d_len--;
+ } else {
+@@ -830,7 +830,7 @@ int ast_get_enum(struct ast_channel *cha
+
+ p1 = middle + strlen(middle);
+ for (p2 = (char *) number + sdl - 1; p2 >= number; p2--) {
+- if (isdigit(*p2)) {
++ if (isdigit((unsigned char)*p2)) {
+ *p1++ = *p2;
+ *p1++ = '.';
+ }
+@@ -849,7 +849,7 @@ int ast_get_enum(struct ast_channel *cha
+ /* flip left into domain */
+ p1 = domain;
+ for (p2 = left + strlen(left); p2 >= left; p2--) {
+- if (isdigit(*p2)) {
++ if (isdigit((unsigned char)*p2)) {
+ *p1++ = *p2;
+ *p1++ = '.';
+ }
+@@ -973,7 +973,7 @@ static char *format_numeric_domain(const
+
+ if (buffer) {
+ while (src >= number) {
+- if (isdigit(*src)) {
++ if (isdigit((unsigned char)*src)) {
+ *dst++ = *src;
+ *dst++ = '.';
+ }
diff --git a/comms/asterisk18/patches/patch-main_features.c b/comms/asterisk18/patches/patch-main_features.c
new file mode 100644
index 00000000000..91a3dc70626
--- /dev/null
+++ b/comms/asterisk18/patches/patch-main_features.c
@@ -0,0 +1,20 @@
+$NetBSD: patch-main_features.c,v 1.1.1.1 2021/06/13 07:47:18 jnemeth Exp $
+
+--- main/features.c.orig 2018-05-07 17:28:38.342590540 +0000
++++ main/features.c
+@@ -387,13 +387,13 @@ static void set_bridge_features_on_confi
+ for (feature = features; *feature; feature++) {
+ struct ast_flags *party;
+
+- if (isupper(*feature)) {
++ if (isupper((unsigned char)*feature)) {
+ party = &config->features_caller;
+ } else {
+ party = &config->features_callee;
+ }
+
+- switch (tolower(*feature)) {
++ switch (tolower((unsigned char)*feature)) {
+ case 't' :
+ ast_set_flag(party, AST_FEATURE_REDIRECT);
+ break;
diff --git a/comms/asterisk18/patches/patch-main_http.c b/comms/asterisk18/patches/patch-main_http.c
new file mode 100644
index 00000000000..eb71d5fcdac
--- /dev/null
+++ b/comms/asterisk18/patches/patch-main_http.c
@@ -0,0 +1,13 @@
+$NetBSD: patch-main_http.c,v 1.1.1.1 2021/06/13 07:47:18 jnemeth Exp $
+
+--- main/http.c.orig 2015-10-09 21:48:48.000000000 +0000
++++ main/http.c
+@@ -304,7 +304,7 @@ static int static_callback(struct ast_tc
+ }
+
+ /* make "Etag:" http header value */
+- snprintf(etag, sizeof(etag), "\"%ld\"", (long)st.st_mtime);
++ snprintf(etag, sizeof(etag), "\"%jd\"", (intmax_t)st.st_mtime);
+
+ /* make "Last-Modified:" http header value */
+ tv.tv_sec = st.st_mtime;
diff --git a/comms/asterisk18/patches/patch-main_indications.c b/comms/asterisk18/patches/patch-main_indications.c
new file mode 100644
index 00000000000..143bed83e37
--- /dev/null
+++ b/comms/asterisk18/patches/patch-main_indications.c
@@ -0,0 +1,13 @@
+$NetBSD: patch-main_indications.c,v 1.1.1.1 2021/06/13 07:47:18 jnemeth Exp $
+
+--- main/indications.c.orig 2021-03-04 16:46:08.000000000 +0000
++++ main/indications.c
+@@ -908,7 +908,7 @@ static void store_tone_zone_ring_cadence
+
+ ring = ast_strip(ring);
+
+- if (!isdigit(ring[0]) || (value = atoi(ring)) == -1) {
++ if (!isdigit((unsigned char)ring[0]) || (value = atoi(ring)) == -1) {
+ ast_log(LOG_WARNING, "Invalid ringcadence given '%s'.\n", ring);
+ continue;
+ }
diff --git a/comms/asterisk18/patches/patch-main_logger.c b/comms/asterisk18/patches/patch-main_logger.c
new file mode 100644
index 00000000000..ca0eefa2c06
--- /dev/null
+++ b/comms/asterisk18/patches/patch-main_logger.c
@@ -0,0 +1,22 @@
+$NetBSD: patch-main_logger.c,v 1.1.1.1 2021/06/13 07:47:18 jnemeth Exp $
+
+--- main/logger.c.orig 2015-10-09 21:48:48.000000000 +0000
++++ main/logger.c
+@@ -674,7 +674,7 @@ void ast_queue_log(const char *queuename
+
+ if (qlog) {
+ va_start(ap, fmt);
+- qlog_len = snprintf(qlog_msg, sizeof(qlog_msg), "%ld|%s|%s|%s|%s|", (long)time(NULL), callid, queuename, agent, event);
++ qlog_len = snprintf(qlog_msg, sizeof(qlog_msg), "%jd|%s|%s|%s|%s|", (intmax_t)time(NULL), callid, queuename, agent, event);
+ vsnprintf(qlog_msg + qlog_len, sizeof(qlog_msg) - qlog_len, fmt, ap);
+ va_end(ap);
+ AST_RWLIST_RDLOCK(&logchannels);
+@@ -714,7 +714,7 @@ static int rotate_file(const char *filen
+ }
+ break;
+ case TIMESTAMP:
+- snprintf(new, sizeof(new), "%s.%ld", filename, (long)time(NULL));
++ snprintf(new, sizeof(new), "%s.%jd", filename, (intmax_t)time(NULL));
+ if (rename(filename, new)) {
+ fprintf(stderr, "Unable to rename file '%s' to '%s'\n", filename, new);
+ res = -1;
diff --git a/comms/asterisk18/patches/patch-main_manager.c b/comms/asterisk18/patches/patch-main_manager.c
new file mode 100644
index 00000000000..a582eef4386
--- /dev/null
+++ b/comms/asterisk18/patches/patch-main_manager.c
@@ -0,0 +1,83 @@
+$NetBSD: patch-main_manager.c,v 1.1.1.1 2021/06/13 07:47:18 jnemeth Exp $
+
+--- main/manager.c.orig 2018-05-01 20:12:26.000000000 +0000
++++ main/manager.c
+@@ -2639,7 +2639,7 @@ static char *handle_showmanconn(struct a
+ struct mansession_session *session;
+ time_t now = time(NULL);
+ #define HSMCONN_FORMAT1 " %-15.15s %-55.55s %-10.10s %-10.10s %-8.8s %-8.8s %-5.5s %-5.5s\n"
+-#define HSMCONN_FORMAT2 " %-15.15s %-55.55s %-10d %-10d %-8d %-8d %-5.5d %-5.5d\n"
++#define HSMCONN_FORMAT2 " %-15.15s %-55.55s %-10jd %-10jd %-8d %-8d %-5.5d %-5.5d\n"
+ int count = 0;
+ struct ao2_iterator i;
+
+@@ -2665,8 +2665,8 @@ static char *handle_showmanconn(struct a
+ ao2_lock(session);
+ ast_cli(a->fd, HSMCONN_FORMAT2, session->username,
+ ast_sockaddr_stringify_addr(&session->addr),
+- (int) (session->sessionstart),
+- (int) (now - session->sessionstart),
++ (intmax_t) (session->sessionstart),
++ (intmax_t) (now - session->sessionstart),
+ session->stream ? ast_iostream_get_fd(session->stream) : -1,
+ session->inuse,
+ session->readperm,
+@@ -3510,9 +3510,9 @@ static int action_ping(struct mansession
+ astman_append(
+ s,
+ "Ping: Pong\r\n"
+- "Timestamp: %ld.%06lu\r\n"
++ "Timestamp: %jd.%06lu\r\n"
+ "\r\n",
+- (long) now.tv_sec, (unsigned long) now.tv_usec);
++ (intmax_t) now.tv_sec, (unsigned long) now.tv_usec);
+ return 0;
+ }
+
+@@ -4621,7 +4621,7 @@ static void generate_status(struct manse
+ "DNID: %s\r\n"
+ "EffectiveConnectedLineNum: %s\r\n"
+ "EffectiveConnectedLineName: %s\r\n"
+- "TimeToHangup: %ld\r\n"
++ "TimeToHangup: %jd\r\n"
+ "BridgeID: %s\r\n"
+ "Application: %s\r\n"
+ "Data: %s\r\n"
+@@ -4641,7 +4641,7 @@ static void generate_status(struct manse
+ S_OR(ast_channel_dialed(chan)->number.str, ""),
+ S_COR(effective_id.number.valid, effective_id.number.str, "<unknown>"),
+ S_COR(effective_id.name.valid, effective_id.name.str, "<unknown>"),
+- (long)ast_channel_whentohangup(chan)->tv_sec,
++ (intmax_t)ast_channel_whentohangup(chan)->tv_sec,
+ bridge ? bridge->uniqueid : "",
+ ast_channel_appl(chan),
+ ast_channel_data(chan),
+@@ -6920,8 +6920,8 @@ static int __attribute__((format(printf,
+ if (timestampevents) {
+ now = ast_tvnow();
+ ast_str_append(&buf, 0,
+- "Timestamp: %ld.%06lu\r\n",
+- (long)now.tv_sec, (unsigned long) now.tv_usec);
++ "Timestamp: %jd.%06lu\r\n",
++ (intmax_t)now.tv_sec, (unsigned long) now.tv_usec);
+ }
+ if (manager_debug) {
+ static int seq;
+@@ -7433,7 +7433,7 @@ static void xml_copy_escape(struct ast_s
+ }
+ }
+
+- if ( (mode & 2) && !isalnum(*src)) {
++ if ( (mode & 2) && !isalnum((unsigned char)*src)) {
+ *dst++ = '_';
+ space--;
+ continue;
+@@ -7466,7 +7466,7 @@ static void xml_copy_escape(struct ast_s
+ break;
+
+ default:
+- *dst++ = mode ? tolower(*src) : *src;
++ *dst++ = mode ? tolower((unsigned char)*src) : *src;
+ space--;
+ }
+ }
diff --git a/comms/asterisk18/patches/patch-main_pbx.c b/comms/asterisk18/patches/patch-main_pbx.c
new file mode 100644
index 00000000000..884ca849cc5
--- /dev/null
+++ b/comms/asterisk18/patches/patch-main_pbx.c
@@ -0,0 +1,13 @@
+$NetBSD: patch-main_pbx.c,v 1.1.1.1 2021/06/13 07:47:18 jnemeth Exp $
+
+--- main/pbx.c.orig 2016-04-20 10:46:18.000000000 +0000
++++ main/pbx.c
+@@ -7973,7 +7973,7 @@ static int testtime_write(struct ast_cha
+ sscanf(remainder, "%79s", timezone);
+ tv = ast_mktime(&tm, S_OR(timezone, NULL));
+
+- snprintf(result, sizeof(result), "%ld", (long) tv.tv_sec);
++ snprintf(result, sizeof(result), "%jd", (intmax_t) tv.tv_sec);
+ pbx_builtin_setvar_helper(chan, "__TESTTIME", result);
+ return 0;
+ }
diff --git a/comms/asterisk18/patches/patch-main_pbx__builtins.c b/comms/asterisk18/patches/patch-main_pbx__builtins.c
new file mode 100644
index 00000000000..291844e1b56
--- /dev/null
+++ b/comms/asterisk18/patches/patch-main_pbx__builtins.c
@@ -0,0 +1,33 @@
+$NetBSD: patch-main_pbx__builtins.c,v 1.1.1.1 2021/06/13 07:47:18 jnemeth Exp $
+
+--- main/pbx_builtins.c.orig 2018-05-01 20:12:26.000000000 +0000
++++ main/pbx_builtins.c
+@@ -807,7 +807,7 @@ static int pbx_builtin_setamaflags(struc
+ }
+ /* Copy the AMA Flags as specified */
+ ast_channel_lock(chan);
+- if (isdigit(data[0])) {
++ if (isdigit((unsigned char)data[0])) {
+ int amaflags;
+ if (sscanf(data, "%30d", &amaflags) != 1) {
+ ast_log(AST_LOG_WARNING, "Unable to set AMA flags on channel %s\n", ast_channel_name(chan));
+@@ -877,7 +877,7 @@ static int pbx_builtin_gotoiftime(struct
+ struct ast_timing timing;
+ const char *ctime;
+ struct timeval tv = ast_tvnow();
+- long timesecs;
++ int64_t timesecs;
+
+ if (!chan) {
+ ast_log(LOG_WARNING, "GotoIfTime requires a channel on which to operate\n");
+@@ -892,8 +892,8 @@ static int pbx_builtin_gotoiftime(struct
+ ts = s = ast_strdupa(data);
+
+ ast_channel_lock(chan);
+- if ((ctime = pbx_builtin_getvar_helper(chan, "TESTTIME")) && sscanf(ctime, "%ld", &timesecs) == 1) {
+- tv.tv_sec = timesecs;
++ if ((ctime = pbx_builtin_getvar_helper(chan, "TESTTIME")) && sscanf(ctime, "%" SCNd64, &timesecs) == 1) {
++ tv.tv_sec = (time_t)timesecs;
+ } else if (ctime) {
+ ast_log(LOG_WARNING, "Using current time to evaluate\n");
+ /* Reset when unparseable */
diff --git a/comms/asterisk18/patches/patch-main_pbx__timing.c b/comms/asterisk18/patches/patch-main_pbx__timing.c
new file mode 100644
index 00000000000..c98e9827169
--- /dev/null
+++ b/comms/asterisk18/patches/patch-main_pbx__timing.c
@@ -0,0 +1,13 @@
+$NetBSD: patch-main_pbx__timing.c,v 1.1.1.1 2021/06/13 07:47:18 jnemeth Exp $
+
+--- main/pbx_timing.c.orig 2018-05-07 17:30:09.949079213 +0000
++++ main/pbx_timing.c
+@@ -137,7 +137,7 @@ static void get_timerange(struct ast_tim
+ }
+ *endpart++ = '\0';
+ /* why skip non digits? Mostly to skip spaces */
+- while (*endpart && !isdigit(*endpart)) {
++ while (*endpart && !isdigit((unsigned char)*endpart)) {
+ endpart++;
+ }
+ if (!*endpart) {
diff --git a/comms/asterisk18/patches/patch-main_sched.c b/comms/asterisk18/patches/patch-main_sched.c
new file mode 100644
index 00000000000..aee09e65ca6
--- /dev/null
+++ b/comms/asterisk18/patches/patch-main_sched.c
@@ -0,0 +1,27 @@
+$NetBSD: patch-main_sched.c,v 1.1.1.1 2021/06/13 07:47:18 jnemeth Exp $
+
+--- main/sched.c.orig 2018-05-01 20:12:26.000000000 +0000
++++ main/sched.c
+@@ -498,7 +498,7 @@ static int sched_settime(struct timeval
+ ast_assert(0);
+ }
+
+- /*ast_debug(1, "TV -> %lu,%lu\n", tv->tv_sec, tv->tv_usec);*/
++ /*ast_debug(1, "TV -> %jd,%lu\n", (intmax_t)tv->tv_sec, tv->tv_usec);*/
+ if (ast_tvzero(*t)) /* not supplied, default to now */
+ *t = now;
+ *t = ast_tvadd(*t, ast_samp2tv(when, 1000));
+@@ -732,11 +732,11 @@ void ast_sched_dump(struct ast_sched_con
+ struct timeval delta;
+ q = ast_heap_peek(con->sched_heap, x);
+ delta = ast_tvsub(q->when, when);
+- ast_log(LOG_DEBUG, "|%.4d | %-15p | %-15p | %.6ld : %.6ld |\n",
++ ast_log(LOG_DEBUG, "|%.4d | %-15p | %-15p | %.6jd : %.6ld |\n",
+ q->sched_id->id,
+ q->callback,
+ q->data,
+- (long)delta.tv_sec,
++ (intmax_t)delta.tv_sec,
+ (long int)delta.tv_usec);
+ }
+ ast_mutex_unlock(&con->lock);
diff --git a/comms/asterisk18/patches/patch-main_stdtime_localtime.c b/comms/asterisk18/patches/patch-main_stdtime_localtime.c
new file mode 100644
index 00000000000..187e6c7e56d
--- /dev/null
+++ b/comms/asterisk18/patches/patch-main_stdtime_localtime.c
@@ -0,0 +1,147 @@
+$NetBSD: patch-main_stdtime_localtime.c,v 1.1.1.1 2021/06/13 07:47:18 jnemeth Exp $
+
+--- main/stdtime/localtime.c.orig 2018-05-01 20:12:26.000000000 +0000
++++ main/stdtime/localtime.c
+@@ -65,6 +65,10 @@
+ #include <sys/stat.h>
+ #include <fcntl.h>
+ #endif
++#ifdef __sun
++#include <time.h>
++#include <xlocale.h>
++#endif
+
+ #include "private.h"
+ #include "tzfile.h"
+@@ -74,6 +78,7 @@
+ #include "asterisk/localtime.h"
+ #include "asterisk/strings.h"
+ #include "asterisk/linkedlists.h"
++#include "asterisk/autoconfig.h"
+ #include "asterisk/utils.h"
+ #include "asterisk/test.h"
+
+@@ -310,7 +315,7 @@ static struct state * sstate_alloc(void)
+ static void sstate_free(struct state *p);
+
+ static AST_LIST_HEAD_STATIC(zonelist, state);
+-#if defined(HAVE_NEWLOCALE) && defined(HAVE_USELOCALE)
++#if defined(HAVE_NEWLOCALE) && (defined(HAVE_USELOCALE) || HAVE_STRFTIME_L || HAVE_STRPTIME_L)
+ static AST_LIST_HEAD_STATIC(localelist, locale_entry);
+ #endif
+
+@@ -731,7 +736,7 @@ static void *notify_daemon(void *data)
+ if (st.st_mtime > cur->mtime[0] || lst.st_mtime > cur->mtime[1]) {
+ #ifdef TEST_FRAMEWORK
+ if (test) {
+- ast_test_status_update(test, "Removing cached TZ entry '%s' because underlying file changed. (%ld != %ld) or (%ld != %ld)\n", name, st.st_mtime, cur->mtime[0], lst.st_mtime, cur->mtime[1]);
++ ast_test_status_update(test, "Removing cached TZ entry '%s' because underlying file changed. (%jd != %jd) or (%jd != %jd)\n", name, (intmax_t)st.st_mtime, (intmax_t)cur->mtime[0], (intmax_t)lst.st_mtime, (intmax_t)cur->mtime[1]);
+ } else
+ #endif
+ {
+@@ -2362,7 +2367,8 @@ struct timeval ast_mktime(struct ast_tm
+ return time1(tmp, localsub, 0L, sp);
+ }
+
+-#if defined(HAVE_NEWLOCALE) && defined(HAVE_USELOCALE)
++#if defined(HAVE_NEWLOCALE) && (defined(HAVE_USELOCALE) || HAVE_STRFTIME_L || HAVE_STRPTIME_L)
++#if defined HAVE_USELOCALE
+ static struct locale_entry *find_by_locale(locale_t locale)
+ {
+ struct locale_entry *cur;
+@@ -2373,6 +2379,7 @@ static struct locale_entry *find_by_loca
+ }
+ return NULL;
+ }
++#endif
+
+ static struct locale_entry *find_by_name(const char *name)
+ {
+@@ -2385,6 +2392,23 @@ static struct locale_entry *find_by_name
+ return NULL;
+ }
+
++#if HAVE_STRFTIME_L || HAVE_STRPTIME_L
++static locale_t ast_getlocale(const char *locale)
++{
++ struct locale_entry *cur;
++
++ AST_LIST_LOCK(&localelist);
++ if ((cur = find_by_name(locale)) == NULL) {
++ cur->locale = newlocale(LC_ALL_MASK, locale, NULL);
++ strcpy(cur->name, locale); /* SAFE */
++ AST_LIST_INSERT_TAIL(&localelist, cur, list);
++ }
++ AST_LIST_UNLOCK(&localelist);
++ return cur->locale;
++}
++#endif
++
++#if !HAVE_STRFTIME_L || !HAVE_STRPTIME_L
+ static const char *store_by_locale(locale_t prevlocale)
+ {
+ struct locale_entry *cur;
+@@ -2442,6 +2466,7 @@ const char *ast_setlocale(const char *lo
+ AST_LIST_UNLOCK(&localelist);
+ return store_by_locale(prevlocale);
+ }
++#endif
+ #else
+ const char *ast_setlocale(const char *unused)
+ {
+@@ -2455,7 +2480,9 @@ int ast_strftime_locale(char *buf, size_
+ char *format = ast_calloc(1, fmtlen), *fptr = format, *newfmt;
+ int decimals = -1, i, res;
+ long fraction;
++#if !HAVE_STRFTIME_L
+ const char *prevlocale;
++#endif
+
+ buf[0] = '\0';/* Ensure the buffer is initialized. */
+ if (!format) {
+@@ -2510,6 +2537,14 @@ defcase: *fptr++ = *tmp;
+ }
+ *fptr = '\0';
+ #undef strftime
++#if HAVE_STRFTIME_L
++ if (locale) {
++ locale_t l = ast_getlocale(locale);
++ res = (int)strftime_l(buf, len, format, (struct tm *)tm, l);
++ } else {
++ res = (int)strftime(buf, len, format, (struct tm *)tm);
++ }
++#else
+ if (locale) {
+ prevlocale = ast_setlocale(locale);
+ }
+@@ -2517,6 +2552,7 @@ defcase: *fptr++ = *tmp;
+ if (locale) {
+ ast_setlocale(prevlocale);
+ }
++#endif
+ ast_free(format);
+ return res;
+ }
+@@ -2530,11 +2566,22 @@ char *ast_strptime_locale(const char *s,
+ {
+ struct tm tm2 = { 0, };
+ char *res;
++#if !HAVE_STRPTIME_L
+ const char *prevlocale;
++#endif
+
++#if HAVE_STRPTIME_L
++ if (locale) {
++ locale_t l = ast_getlocale(locale);
++ res = strptime_l(s, format, &tm2, l);
++ } else {
++ res = strptime(s, format, &tm2);
++ }
++#else
+ prevlocale = ast_setlocale(locale);
+ res = strptime(s, format, &tm2);
+ ast_setlocale(prevlocale);
++#endif
+ /* ast_time and tm are not the same size - tm is a subset of
+ * ast_time. Hence, the size of tm needs to be used for the
+ * memcpy
diff --git a/comms/asterisk18/patches/patch-main_tdd.c b/comms/asterisk18/patches/patch-main_tdd.c
new file mode 100644
index 00000000000..ec05fee894c
--- /dev/null
+++ b/comms/asterisk18/patches/patch-main_tdd.c
@@ -0,0 +1,13 @@
+$NetBSD: patch-main_tdd.c,v 1.1.1.1 2021/06/13 07:47:18 jnemeth Exp $
+
+--- main/tdd.c.orig 2018-05-07 17:30:59.571540797 +0000
++++ main/tdd.c
+@@ -313,7 +313,7 @@ int tdd_generate(struct tdd_state *tdd,
+ if ( (tdd->charnum++) % 72 == 0)
+ PUT_TDD(tdd->mode ? 27 /* FIGS */ : 31 /* LTRS */);
+
+- c = toupper(str[x]);
++ c = toupper((unsigned char)str[x]);
+ #if 0
+ printf("%c",c); fflush(stdout);
+ #endif
diff --git a/comms/asterisk18/patches/patch-main_test.c b/comms/asterisk18/patches/patch-main_test.c
new file mode 100644
index 00000000000..743c2aac5f4
--- /dev/null
+++ b/comms/asterisk18/patches/patch-main_test.c
@@ -0,0 +1,13 @@
+$NetBSD: patch-main_test.c,v 1.1.1.1 2021/06/13 07:47:18 jnemeth Exp $
+
+--- main/test.c.orig 2015-10-09 21:48:48.000000000 +0000
++++ main/test.c
+@@ -975,7 +975,7 @@ static char *test_cli_generate_results(s
+ if (!(buf = ast_str_create(256))) {
+ return NULL;
+ }
+- ast_str_set(&buf, 0, "%s/asterisk_test_results-%ld.%s", ast_config_AST_LOG_DIR, (long) time.tv_sec, type);
++ ast_str_set(&buf, 0, "%s/asterisk_test_results-%jd.%s", ast_config_AST_LOG_DIR, (intmax_t) time.tv_sec, type);
+
+ file = ast_str_buffer(buf);
+ }
diff --git a/comms/asterisk18/patches/patch-main_utils.c b/comms/asterisk18/patches/patch-main_utils.c
new file mode 100644
index 00000000000..261eb4e384a
--- /dev/null
+++ b/comms/asterisk18/patches/patch-main_utils.c
@@ -0,0 +1,60 @@
+$NetBSD: patch-main_utils.c,v 1.1.1.1 2021/06/13 07:47:18 jnemeth Exp $
+
+--- main/utils.c.orig 2018-05-01 20:12:26.000000000 +0000
++++ main/utils.c
+@@ -39,6 +39,10 @@
+ #elif defined(HAVE_SYS_THR_H)
+ #include <sys/thr.h>
+ #endif
++#if defined(HAVE_GETIFADDRS)
++#include <ifaddrs.h>
++#include <net/if_dl.h>
++#endif
+
+ #include "asterisk/network.h"
+ #include "asterisk/ast_version.h"
+@@ -204,7 +208,7 @@ struct hostent *ast_gethostbyname(const
+ while (s && *s) {
+ if (*s == '.')
+ dots++;
+- else if (!isdigit(*s))
++ else if (!isdigit((unsigned char)*s))
+ break;
+ s++;
+ }
+@@ -612,7 +616,7 @@ const char *ast_inet_ntoa(struct in_addr
+
+ static int dev_urandom_fd = -1;
+
+-#ifndef __linux__
++#if !defined(__linux__) && !defined(__DragonFly__)
+ #undef pthread_create /* For ast_pthread_create function only */
+ #endif /* !__linux__ */
+
+@@ -1820,13 +1824,13 @@ int ast_false(const char *s)
+ static struct timeval tvfix(struct timeval a)
+ {
+ if (a.tv_usec >= ONE_MILLION) {
+- ast_log(LOG_WARNING, "warning too large timestamp %ld.%ld\n",
+- (long)a.tv_sec, (long int) a.tv_usec);
++ ast_log(LOG_WARNING, "warning too large timestamp %jd.%ld\n",
++ (intmax_t)a.tv_sec, (long int) a.tv_usec);
+ a.tv_sec += a.tv_usec / ONE_MILLION;
+ a.tv_usec %= ONE_MILLION;
+ } else if (a.tv_usec < 0) {
+- ast_log(LOG_WARNING, "warning negative timestamp %ld.%ld\n",
+- (long)a.tv_sec, (long int) a.tv_usec);
++ ast_log(LOG_WARNING, "warning negative timestamp %jd.%ld\n",
++ (intmax_t)a.tv_sec, (long int) a.tv_usec);
+ a.tv_usec = 0;
+ }
+ return a;
+@@ -1986,7 +1990,7 @@ char *ast_to_camel_case_delim(const char
+
+ while (front) {
+ size = strlen(front);
+- *front = toupper(*front);
++ *front = toupper((unsigned char)*front);
+ ast_copy_string(buf, front, size + 1);
+ buf += size;
+ front = strtok_r(NULL, delim, &back);
diff --git a/comms/asterisk18/patches/patch-menuselect_menuselect.c b/comms/asterisk18/patches/patch-menuselect_menuselect.c
new file mode 100644
index 00000000000..45d209372ba
--- /dev/null
+++ b/comms/asterisk18/patches/patch-menuselect_menuselect.c
@@ -0,0 +1,22 @@
+$NetBSD: patch-menuselect_menuselect.c,v 1.1.1.1 2021/06/13 07:47:18 jnemeth Exp $
+
+--- menuselect/menuselect.c.orig 2018-05-07 17:13:49.312815875 +0000
++++ menuselect/menuselect.c
+@@ -1461,7 +1461,7 @@ static int generate_makedeps_file(void)
+ }
+
+ for (c = dep->name; *c; c++)
+- fputc(toupper(*c), f);
++ fputc(toupper((unsigned char)*c), f);
+ fputc(' ', f);
+ }
+ AST_LIST_TRAVERSE(&mem->uses, use, list) {
+@@ -1477,7 +1477,7 @@ static int generate_makedeps_file(void)
+ }
+
+ for (c = use->name; *c; c++)
+- fputc(toupper(*c), f);
++ fputc(toupper((unsigned char)*c), f);
+ fputc(' ', f);
+ }
+
diff --git a/comms/asterisk18/patches/patch-pbx_pbx__config.c b/comms/asterisk18/patches/patch-pbx_pbx__config.c
new file mode 100644
index 00000000000..f383ff9f91f
--- /dev/null
+++ b/comms/asterisk18/patches/patch-pbx_pbx__config.c
@@ -0,0 +1,22 @@
+$NetBSD: patch-pbx_pbx__config.c,v 1.1.1.1 2021/06/13 07:47:18 jnemeth Exp $
+
+--- pbx/pbx_config.c.orig 2018-05-07 17:17:05.322793470 +0000
++++ pbx/pbx_config.c
+@@ -237,7 +237,7 @@ static const char *skip_words(const char
+ {
+ int in_blank = 0;
+ for (;n && *p; p++) {
+- if (isblank(*p) /* XXX order is important */ && !in_blank) {
++ if (isblank((unsigned char)*p) /* XXX order is important */ && !in_blank) {
+ n--; /* one word is gone */
+ in_blank = 1;
+ } else if (/* !is_blank(*p), we know already, && */ in_blank) {
+@@ -447,7 +447,7 @@ static char *handle_cli_dialplan_remove_
+ if (!strcmp("hint", c))
+ removing_priority = PRIORITY_HINT;
+ else {
+- while (*c && isdigit(*c))
++ while (*c && isdigit((unsigned char)*c))
+ c++;
+ if (*c) { /* non-digit in string */
+ ast_cli(a->fd, "Invalid priority '%s'\n", a->argv[4]);
diff --git a/comms/asterisk18/patches/patch-pbx_pbx__dundi.c b/comms/asterisk18/patches/patch-pbx_pbx__dundi.c
new file mode 100644
index 00000000000..a2d769f1493
--- /dev/null
+++ b/comms/asterisk18/patches/patch-pbx_pbx__dundi.c
@@ -0,0 +1,40 @@
+$NetBSD: patch-pbx_pbx__dundi.c,v 1.1.1.1 2021/06/13 07:47:18 jnemeth Exp $
+
+--- pbx/pbx_dundi.c.orig 2015-10-09 21:48:48.000000000 +0000
++++ pbx/pbx_dundi.c
+@@ -47,7 +47,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revisi
+ #include <pthread.h>
+ #include <net/if.h>
+
+-#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__Darwin__)
++#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__Darwin__) || defined(__DragonFly__)
+ #include <net/if_dl.h>
+ #include <ifaddrs.h>
+ #include <signal.h>
+@@ -885,7 +885,7 @@ static int cache_save_hint(dundi_eid *ei
+
+ time(&timeout);
+ timeout += expiration;
+- snprintf(data, sizeof(data), "%ld|", (long)(timeout));
++ snprintf(data, sizeof(data), "%jd|", (intmax_t)(timeout));
+
+ ast_db_put("dundi/cache", key1, data);
+ ast_debug(1, "Caching hint at '%s'\n", key1);
+@@ -921,7 +921,7 @@ static int cache_save(dundi_eid *eidpeer
+ /* Build request string */
+ time(&timeout);
+ timeout += expiration;
+- snprintf(data, sizeof(data), "%ld|", (long)(timeout));
++ snprintf(data, sizeof(data), "%jd|", (intmax_t)(timeout));
+ for (x=start;x<req->respcount;x++) {
+ /* Skip anything with an illegal pipe in it */
+ if (strchr(req->dr[x].dest, '|'))
+@@ -2166,7 +2166,7 @@ static void check_password(void)
+
+ time(&now);
+ #if 0
+- printf("%ld/%ld\n", now, rotatetime);
++ printf("%jd/%jd\n", now, rotatetime);
+ #endif
+ if ((now - rotatetime) >= 0) {
+ /* Time to rotate keys */
diff --git a/comms/asterisk18/patches/patch-res_ael_pval.c b/comms/asterisk18/patches/patch-res_ael_pval.c
new file mode 100644
index 00000000000..e89e595dd3a
--- /dev/null
+++ b/comms/asterisk18/patches/patch-res_ael_pval.c
@@ -0,0 +1,41 @@
+$NetBSD: patch-res_ael_pval.c,v 1.1.1.1 2021/06/13 07:47:18 jnemeth Exp $
+
+--- res/ael/pval.c.orig 2018-05-07 17:37:44.116772314 +0000
++++ res/ael/pval.c
+@@ -855,7 +855,7 @@ static void check_timerange(pval *p)
+ }
+ *e = '\0';
+ e++;
+- while (*e && !isdigit(*e))
++ while (*e && !isdigit((unsigned char)*e))
+ e++;
+ if (!*e) {
+ ast_log(LOG_WARNING, "Warning: file %s, line %d-%d: The time range format (%s) is missing the end time!\n",
+@@ -3531,11 +3531,11 @@ static int gen_prios(struct ael_extensio
+ for_init->appargs = strdup(buf2);
+ } else {
+ strp2 = p->u1.for_init;
+- while (*strp2 && isspace(*strp2))
++ while (*strp2 && isspace((unsigned char)*strp2))
+ strp2++;
+ if (*strp2 == '&') { /* itsa macro call */
+ char *strp3 = strp2+1;
+- while (*strp3 && isspace(*strp3))
++ while (*strp3 && isspace((unsigned char)*strp3))
+ strp3++;
+ strcpy(buf2, strp3);
+ strp3 = strchr(buf2,'(');
+@@ -3581,11 +3581,11 @@ static int gen_prios(struct ael_extensio
+ for_inc->app = strdup("MSet");
+ } else {
+ strp2 = p->u3.for_inc;
+- while (*strp2 && isspace(*strp2))
++ while (*strp2 && isspace((unsigned char)*strp2))
+ strp2++;
+ if (*strp2 == '&') { /* itsa macro call */
+ char *strp3 = strp2+1;
+- while (*strp3 && isspace(*strp3))
++ while (*strp3 && isspace((unsigned char)*strp3))
+ strp3++;
+ strcpy(buf2, strp3);
+ strp3 = strchr(buf2,'(');
diff --git a/comms/asterisk18/patches/patch-res_res__calendar.c b/comms/asterisk18/patches/patch-res_res__calendar.c
new file mode 100644
index 00000000000..f6bc01f74bf
--- /dev/null
+++ b/comms/asterisk18/patches/patch-res_res__calendar.c
@@ -0,0 +1,37 @@
+$NetBSD: patch-res_res__calendar.c,v 1.1.1.1 2021/06/13 07:47:18 jnemeth Exp $
+
+--- res/res_calendar.c.orig 2015-10-09 21:48:48.000000000 +0000
++++ res/res_calendar.c
+@@ -1245,7 +1245,7 @@ static int calendar_query_exec(struct as
+ i = ao2_iterator_init(cal->events, 0);
+ while ((event = ao2_iterator_next(&i))) {
+ if (!(start > event->end || end < event->start)) {
+- ast_debug(10, "%s (%ld - %ld) overlapped with (%ld - %ld)\n", event->summary, (long) event->start, (long) event->end, (long) start, (long) end);
++ ast_debug(10, "%s (%jd - %jd) overlapped with (%jd - %jd)\n", event->summary, (intmax_t) event->start, (intmax_t) event->end, (intmax_t) start, (intmax_t) end);
+ if (add_event_to_list(events, event, start, end) < 0) {
+ event = ast_calendar_unref_event(event);
+ cal = unref_calendar(cal);
+@@ -1378,9 +1378,9 @@ static int calendar_query_result_exec(st
+ } else if (!strcasecmp(args.field, "uid")) {
+ ast_copy_string(buf, entry->event->uid, len);
+ } else if (!strcasecmp(args.field, "start")) {
+- snprintf(buf, len, "%ld", (long) entry->event->start);
++ snprintf(buf, len, "%jd", (intmax_t) entry->event->start);
+ } else if (!strcasecmp(args.field, "end")) {
+- snprintf(buf, len, "%ld", (long) entry->event->end);
++ snprintf(buf, len, "%jd", (intmax_t) entry->event->end);
+ } else if (!strcasecmp(args.field, "busystate")) {
+ snprintf(buf, len, "%u", entry->event->busy_state);
+ } else if (!strcasecmp(args.field, "attendees")) {
+@@ -1739,9 +1739,9 @@ static int calendar_event_read(struct as
+ } else if (!strcasecmp(data, "uid")) {
+ ast_copy_string(buf, event->uid, len);
+ } else if (!strcasecmp(data, "start")) {
+- snprintf(buf, len, "%ld", (long)event->start);
++ snprintf(buf, len, "%jd", (intmax_t)event->start);
+ } else if (!strcasecmp(data, "end")) {
+- snprintf(buf, len, "%ld", (long)event->end);
++ snprintf(buf, len, "%jd", (intmax_t)event->end);
+ } else if (!strcasecmp(data, "busystate")) {
+ snprintf(buf, len, "%u", event->busy_state);
+ } else if (!strcasecmp(data, "attendees")) {
diff --git a/comms/asterisk18/patches/patch-res_res__calendar__caldav.c b/comms/asterisk18/patches/patch-res_res__calendar__caldav.c
new file mode 100644
index 00000000000..e567642c8fa
--- /dev/null
+++ b/comms/asterisk18/patches/patch-res_res__calendar__caldav.c
@@ -0,0 +1,13 @@
+$NetBSD: patch-res_res__calendar__caldav.c,v 1.1.1.1 2021/06/13 07:47:18 jnemeth Exp $
+
+--- res/res_calendar_caldav.c.orig 2015-10-09 21:48:48.000000000 +0000
++++ res/res_calendar_caldav.c
+@@ -404,7 +404,7 @@ static void caldav_add_event(icalcompone
+ ast_string_field_set(event, uid, event->summary);
+ } else {
+ char tmp[100];
+- snprintf(tmp, sizeof(tmp), "%ld", event->start);
++ snprintf(tmp, sizeof(tmp), "%jd", (intmax_t)event->start);
+ ast_string_field_set(event, uid, tmp);
+ }
+ }
diff --git a/comms/asterisk18/patches/patch-res_res__calendar__icalendar.c b/comms/asterisk18/patches/patch-res_res__calendar__icalendar.c
new file mode 100644
index 00000000000..18d5eec7163
--- /dev/null
+++ b/comms/asterisk18/patches/patch-res_res__calendar__icalendar.c
@@ -0,0 +1,13 @@
+$NetBSD: patch-res_res__calendar__icalendar.c,v 1.1.1.1 2021/06/13 07:47:18 jnemeth Exp $
+
+--- res/res_calendar_icalendar.c.orig 2015-10-09 21:48:48.000000000 +0000
++++ res/res_calendar_icalendar.c
+@@ -246,7 +246,7 @@ static void icalendar_add_event(icalcomp
+ ast_string_field_set(event, uid, event->summary);
+ } else {
+ char tmp[100];
+- snprintf(tmp, sizeof(tmp), "%ld", event->start);
++ snprintf(tmp, sizeof(tmp), "%jd", (intmax_t)event->start);
+ ast_string_field_set(event, uid, tmp);
+ }
+ }
diff --git a/comms/asterisk18/patches/patch-res_res__hep__pjsip.c b/comms/asterisk18/patches/patch-res_res__hep__pjsip.c
new file mode 100644
index 00000000000..6aa6a338687
--- /dev/null
+++ b/comms/asterisk18/patches/patch-res_res__hep__pjsip.c
@@ -0,0 +1,23 @@
+$NetBSD: patch-res_res__hep__pjsip.c,v 1.1.1.1 2021/06/13 07:47:18 jnemeth Exp $
+
+--- res/res_hep_pjsip.c.orig 2018-06-20 15:24:25.999288749 +0000
++++ res/res_hep_pjsip.c
+@@ -34,6 +34,9 @@
+
+ #include "asterisk.h"
+
++#include "asterisk/module.h"
++#include "asterisk/netsock2.h"
++
+ #include <pjsip.h>
+ #include <pjsip_ua.h>
+ #include <pjlib.h>
+@@ -41,8 +44,6 @@
+ #include "asterisk/res_pjsip.h"
+ #include "asterisk/res_pjsip_session.h"
+ #include "asterisk/res_hep.h"
+-#include "asterisk/module.h"
+-#include "asterisk/netsock2.h"
+
+ static char *assign_uuid(const pj_str_t *call_id, const pj_str_t *local_tag, const pj_str_t *remote_tag)
+ {
diff --git a/comms/asterisk18/patches/patch-res_res__limit.c b/comms/asterisk18/patches/patch-res_res__limit.c
new file mode 100644
index 00000000000..1f2444db6ca
--- /dev/null
+++ b/comms/asterisk18/patches/patch-res_res__limit.c
@@ -0,0 +1,13 @@
+$NetBSD: patch-res_res__limit.c,v 1.1.1.1 2021/06/13 07:47:18 jnemeth Exp $
+
+--- res/res_limit.c.orig 2018-05-07 17:38:31.944908572 +0000
++++ res/res_limit.c
+@@ -191,7 +191,7 @@ static char *handle_cli_ulimit(struct as
+ else
+ snprintf(printlimit, sizeof(printlimit), "limited to %d", (int) rlimit.rlim_cur);
+ desc = str2desc(a->argv[1]);
+- ast_cli(a->fd, "%c%s (%s) is %s.\n", toupper(desc[0]), desc + 1, a->argv[1], printlimit);
++ ast_cli(a->fd, "%c%s (%s) is %s.\n", toupper((unsigned char)desc[0]), desc + 1, a->argv[1], printlimit);
+ } else
+ ast_cli(a->fd, "Could not retrieve resource limits for %s: %s\n", str2desc(a->argv[1]), strerror(errno));
+ return CLI_SUCCESS;
diff --git a/comms/asterisk18/patches/patch-res_res__musiconhold.c b/comms/asterisk18/patches/patch-res_res__musiconhold.c
new file mode 100644
index 00000000000..b62075bb748
--- /dev/null
+++ b/comms/asterisk18/patches/patch-res_res__musiconhold.c
@@ -0,0 +1,13 @@
+$NetBSD: patch-res_res__musiconhold.c,v 1.1.1.1 2021/06/13 07:47:18 jnemeth Exp $
+
+--- res/res_musiconhold.c.orig 2021-03-04 16:46:08.000000000 +0000
++++ res/res_musiconhold.c
+@@ -1153,7 +1153,7 @@ static void moh_parse_options(struct ast
+ } else if (!strcasecmp(var->name, "announcement")) {
+ ast_copy_string(mohclass->announcement, var->value, sizeof(mohclass->announcement));
+ ast_set_flag(mohclass, MOH_ANNOUNCEMENT);
+- } else if (!strcasecmp(var->name, "digit") && (isdigit(*var->value) || strchr("*#", *var->value))) {
++ } else if (!strcasecmp(var->name, "digit") && (isdigit((unsigned char)*var->value) || strchr("*#", *var->value))) {
+ mohclass->digit = *var->value;
+ } else if (!strcasecmp(var->name, "random")) {
+ static int deprecation_warning = 0;
diff --git a/comms/asterisk18/patches/patch-res_res__pjproject.c b/comms/asterisk18/patches/patch-res_res__pjproject.c
new file mode 100644
index 00000000000..bad7f81c792
--- /dev/null
+++ b/comms/asterisk18/patches/patch-res_res__pjproject.c
@@ -0,0 +1,31 @@
+$NetBSD: patch-res_res__pjproject.c,v 1.1.1.1 2021/06/13 07:47:18 jnemeth Exp $
+
+--- res/res_pjproject.c.orig 2019-09-05 13:09:20.000000000 +0000
++++ res/res_pjproject.c
+@@ -99,20 +99,22 @@
+ #include "asterisk.h"
+
+ #include <stdarg.h>
+-#include <pjlib.h>
+-#include <pjsip.h>
+-#include <pj/log.h>
+
+ #include "asterisk/options.h"
+ #include "asterisk/logger.h"
+ #include "asterisk/module.h"
+ #include "asterisk/cli.h"
+-#include "asterisk/res_pjproject.h"
+ #include "asterisk/vector.h"
+ #include "asterisk/sorcery.h"
+ #include "asterisk/test.h"
+ #include "asterisk/netsock2.h"
+
++#include <pjlib.h>
++#include <pjsip.h>
++#include <pj/log.h>
++
++#include "asterisk/res_pjproject.h"
++
+ static struct ast_sorcery *pjproject_sorcery;
+ static pj_log_func *log_cb_orig;
+ static unsigned decor_orig;
diff --git a/comms/asterisk18/patches/patch-res_res__xmpp.c b/comms/asterisk18/patches/patch-res_res__xmpp.c
new file mode 100644
index 00000000000..aeb5665f9ed
--- /dev/null
+++ b/comms/asterisk18/patches/patch-res_res__xmpp.c
@@ -0,0 +1,13 @@
+$NetBSD: patch-res_res__xmpp.c,v 1.1.1.1 2021/06/13 07:47:18 jnemeth Exp $
+
+--- res/res_xmpp.c.orig 2018-06-19 21:29:29.310245367 +0000
++++ res/res_xmpp.c
+@@ -3746,7 +3746,7 @@ static int xmpp_client_receive(struct as
+ /* if we stumble on the ending tag character,
+ we skip any whitespace that follows it*/
+ if (c == '>') {
+- while (isspace(buf[pos+1])) {
++ while (isspace((unsigned char)buf[pos+1])) {
+ pos++;
+ }
+ }
diff --git a/comms/asterisk18/patches/patch-sounds_Makefile b/comms/asterisk18/patches/patch-sounds_Makefile
new file mode 100644
index 00000000000..3539a296921
--- /dev/null
+++ b/comms/asterisk18/patches/patch-sounds_Makefile
@@ -0,0 +1,25 @@
+$NetBSD: patch-sounds_Makefile,v 1.1.1.1 2021/06/13 07:47:18 jnemeth Exp $
+
+--- sounds/Makefile.orig 2018-05-01 20:12:26.000000000 +0000
++++ sounds/Makefile
+@@ -124,20 +124,6 @@ endef # sound_format_lang_rule
+ all: $(CORE_SOUNDS) $(EXTRA_SOUNDS) $(MOH)
+
+ have_download:
+- @if test "$(DOWNLOAD)" = ":" ; then \
+- echo "**************************************************"; \
+- echo "*** ***"; \
+- echo "*** You must have either wget, curl, or fetch ***"; \
+- echo "*** to be able to automatically download and ***"; \
+- echo "*** install the requested sound packages. ***"; \
+- echo "*** ***"; \
+- echo "*** Please install one of these, or remove any ***"; \
+- echo "*** extra sound package selections in ***"; \
+- echo "*** menuselect before installing Asterisk. ***"; \
+- echo "*** ***"; \
+- echo "**************************************************"; \
+- exit 1; \
+- fi
+
+ $(eval $(call sound_format_lang_rule,$(SOUNDS_DIR),core-sounds,en,$(CORE_SOUNDS_VERSION)))
+
diff --git a/comms/asterisk18/patches/patch-tests_test__locale.c b/comms/asterisk18/patches/patch-tests_test__locale.c
new file mode 100644
index 00000000000..24373672c0a
--- /dev/null
+++ b/comms/asterisk18/patches/patch-tests_test__locale.c
@@ -0,0 +1,13 @@
+$NetBSD: patch-tests_test__locale.c,v 1.1.1.1 2021/06/13 07:47:18 jnemeth Exp $
+
+--- tests/test_locale.c.orig 2015-10-09 21:48:48.000000000 +0000
++++ tests/test_locale.c
+@@ -81,7 +81,7 @@ static char *handle_cli_test_locales(str
+
+ /* First we run a set of tests with the global locale, which isn't thread-safe. */
+ if (!(localedir = opendir(
+-#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined( __NetBSD__ ) || defined(__APPLE__)
++#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined( __NetBSD__ ) || defined(__APPLE__) || defined(__DragonFly__)
+ "/usr/share/locale"
+ #else /* Linux */
+ "/usr/lib/locale"
diff --git a/comms/asterisk18/patches/patch-tests_test__voicemail__api.c b/comms/asterisk18/patches/patch-tests_test__voicemail__api.c
new file mode 100644
index 00000000000..bb6fef61fba
--- /dev/null
+++ b/comms/asterisk18/patches/patch-tests_test__voicemail__api.c
@@ -0,0 +1,13 @@
+$NetBSD: patch-tests_test__voicemail__api.c,v 1.1.1.1 2021/06/13 07:47:18 jnemeth Exp $
+
+--- tests/test_voicemail_api.c.orig 2015-10-09 21:48:48.000000000 +0000
++++ tests/test_voicemail_api.c
+@@ -383,7 +383,7 @@ static struct ast_vm_msg_snapshot *test_
+ struct ast_vm_msg_snapshot *snapshot;
+
+ snprintf(msg_id_hash, sizeof(msg_id_hash), "%s%s%s", exten, context, callerid);
+- snprintf(msg_id_buf, sizeof(msg_id_buf), "%ld-%d", (long)time(NULL), ast_str_hash(msg_id_hash));
++ snprintf(msg_id_buf, sizeof(msg_id_buf), "%jd-%d", (intmax_t)time(NULL), ast_str_hash(msg_id_hash));
+
+ if ((snapshot = ast_calloc(1, sizeof(*snapshot)))) {
+ if (ast_string_field_init(snapshot, 128)) {
diff --git a/comms/asterisk18/patches/patch-utils_Makefile b/comms/asterisk18/patches/patch-utils_Makefile
new file mode 100644
index 00000000000..55ad3ec11e5
--- /dev/null
+++ b/comms/asterisk18/patches/patch-utils_Makefile
@@ -0,0 +1,24 @@
+$NetBSD: patch-utils_Makefile,v 1.1.1.1 2021/06/13 07:47:18 jnemeth Exp $
+
+--- utils/Makefile.orig 2018-05-01 20:12:26.000000000 +0000
++++ utils/Makefile
+@@ -41,6 +41,10 @@ ifeq ($(OSARCH),SunOS)
+ UTILS:=$(filter-out muted,$(UTILS))
+ endif
+
++ifeq ($(OSARCH),NetBSD)
++ UTILS:=$(filter-out muted,$(UTILS))
++endif
++
+ ifeq ($(OSARCH),OpenBSD)
+ UTILS:=$(filter-out muted,$(UTILS))
+ endif
+@@ -75,7 +79,7 @@ all: $(UTILS)
+ install:
+ for x in $(UTILS); do \
+ if [ "$$x" != "none" ]; then \
+- $(INSTALL) -m 755 $$x "$(DESTDIR)$(ASTSBINDIR)/$$x"; \
++ $(BSD_INSTALL_PROGRAM) $$x "$(DESTDIR)$(ASTSBINDIR)/$$x"; \
+ fi; \
+ done
+
diff --git a/comms/asterisk18/patches/patch-utils_db1-ast_include_db.h b/comms/asterisk18/patches/patch-utils_db1-ast_include_db.h
new file mode 100644
index 00000000000..151e1cc27bc
--- /dev/null
+++ b/comms/asterisk18/patches/patch-utils_db1-ast_include_db.h
@@ -0,0 +1,13 @@
+$NetBSD: patch-utils_db1-ast_include_db.h,v 1.1.1.1 2021/06/13 07:47:18 jnemeth Exp $
+
+--- utils/db1-ast/include/db.h.orig 2015-10-09 21:48:48.000000000 +0000
++++ utils/db1-ast/include/db.h
+@@ -55,7 +55,7 @@
+
+ #ifndef __BIT_TYPES_DEFINED__
+ #define __BIT_TYPES_DEFINED__
+-#if (!defined(__FreeBSD__) && !defined(__NetBSD__) && !defined(__APPLE__))
++#if (!defined(__FreeBSD__) && !defined(__NetBSD__) && !defined(__APPLE__) && !defined(__DragonFly__))
+ typedef __signed char int8_t;
+ typedef short int16_t;
+ typedef int int32_t;
diff --git a/comms/asterisk18/patches/patch-utils_extconf.c b/comms/asterisk18/patches/patch-utils_extconf.c
new file mode 100644
index 00000000000..eb79a318d87
--- /dev/null
+++ b/comms/asterisk18/patches/patch-utils_extconf.c
@@ -0,0 +1,67 @@
+$NetBSD: patch-utils_extconf.c,v 1.1.1.1 2021/06/13 07:47:18 jnemeth Exp $
+
+--- utils/extconf.c.orig 2015-10-09 21:48:48.000000000 +0000
++++ utils/extconf.c
+@@ -593,6 +593,10 @@ static void __attribute__((destructor))
+ #include "libkern/OSAtomic.h"
+ #endif
+
++#if defined(HAVE_SYS_ATOMIC_H)
++#include <sys/atomic.h>
++#endif
++
+ /*! \brief Atomically add v to *p and return * the previous value of *p.
+ * This can be used to handle reference counts, and the return value
+ * can be used to generate unique identifiers.
+@@ -606,12 +610,18 @@ AST_INLINE_API(int ast_atomic_fetchadd_i
+ #elif defined(HAVE_OSX_ATOMICS) && (SIZEOF_INT == 4)
+ AST_INLINE_API(int ast_atomic_fetchadd_int(volatile int *p, int v),
+ {
+- return OSAtomicAdd32(v, (int32_t *) p);
++ return OSAtomicAdd32(v, (int32_t *) p) - v;
+ })
+ #elif defined(HAVE_OSX_ATOMICS) && (SIZEOF_INT == 8)
+ AST_INLINE_API(int ast_atomic_fetchadd_int(volatile int *p, int v),
+ {
+- return OSAtomicAdd64(v, (int64_t *) p);
++ return OSAtomicAdd64(v, (int64_t *) p) - v;
++})
++#elif defined(HAVE_SYS_ATOMIC_H)
++AST_INLINE_API(int ast_atomic_fetchadd_int(volatile int *p, int v),
++{
++ return atomic_add_int_nv((unsigned int *)p, v) - v;
++})
+ #elif defined (__i386__) || defined(__x86_64__)
+ AST_INLINE_API(int ast_atomic_fetchadd_int(volatile int *p, int v),
+ {
+@@ -653,6 +663,12 @@ AST_INLINE_API(int ast_atomic_dec_and_te
+ AST_INLINE_API(int ast_atomic_dec_and_test(volatile int *p),
+ {
+ return OSAtomicAdd64( -1, (int64_t *) p) == 0;
++})
++#elif defined(HAVE_SYS_ATOMIC_H)
++AST_INLINE_API(int ast_atomic_dec_and_test(volatile int *p),
++{
++ return atomic_dec_uint_nv((unsigned int *)p) == 0;
++})
+ #else
+ AST_INLINE_API(int ast_atomic_dec_and_test(volatile int *p),
+ {
+@@ -2537,13 +2553,13 @@ static int ast_true(const char *s)
+ static struct timeval tvfix(struct timeval a)
+ {
+ if (a.tv_usec >= ONE_MILLION) {
+- ast_log(LOG_WARNING, "warning too large timestamp %ld.%ld\n",
+- (long)a.tv_sec, (long int) a.tv_usec);
++ ast_log(LOG_WARNING, "warning too large timestamp %jd.%ld\n",
++ (intmax_t)a.tv_sec, (long int) a.tv_usec);
+ a.tv_sec += a.tv_usec / ONE_MILLION;
+ a.tv_usec %= ONE_MILLION;
+ } else if (a.tv_usec < 0) {
+- ast_log(LOG_WARNING, "warning negative timestamp %ld.%ld\n",
+- (long)a.tv_sec, (long int) a.tv_usec);
++ ast_log(LOG_WARNING, "warning negative timestamp %jd.%ld\n",
++ (intmax_t)a.tv_sec, (long int) a.tv_usec);
+ a.tv_usec = 0;
+ }
+ return a;
diff --git a/comms/asterisk18/patches/patch-utils_smsq.c b/comms/asterisk18/patches/patch-utils_smsq.c
new file mode 100644
index 00000000000..141a91614a0
--- /dev/null
+++ b/comms/asterisk18/patches/patch-utils_smsq.c
@@ -0,0 +1,13 @@
+$NetBSD: patch-utils_smsq.c,v 1.1.1.1 2021/06/13 07:47:18 jnemeth Exp $
+
+--- utils/smsq.c.orig 2015-10-09 21:48:48.000000000 +0000
++++ utils/smsq.c
+@@ -687,7 +687,7 @@ main (int argc, const char *argv[])
+ snprintf (temp, sizeof(temp), "sms/.smsq-%d", (int)getpid ());
+ mkdir ("sms", 0777); /* ensure directory exists */
+ mkdir (dir, 0777); /* ensure directory exists */
+- snprintf (queuename, sizeof(queuename), "%s/%s.%ld-%d", dir, *queue ? queue : "0", (long)time (0), (int)getpid ());
++ snprintf (queuename, sizeof(queuename), "%s/%s.%jd-%d", dir, *queue ? queue : "0", (intmax_t)time (0), (int)getpid ());
+ f = fopen (temp, "w");
+ if (!f)
+ {