├── .gitignore ├── .travis.yml ├── build.sh ├── debian ├── asterisk.conf ├── changelog ├── compat ├── control ├── dirs ├── docs ├── dummyprogs │ └── fetch ├── install ├── links ├── lintian-overrides ├── menuselect.makeopts ├── postinst ├── postrm ├── prerm └── rules ├── direct-integration-patches ├── 10.9.0 │ ├── v1_selectable_option.patch │ ├── v2_regs_working_issues_remain.patch │ └── v3_latest_but_untested_checkpoint.patch └── README.md └── fix_pjproject_dependency.patch /.gitignore: -------------------------------------------------------------------------------- 1 | ._* 2 | asterisk-* 3 | range-asterisk_* 4 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: cpp 2 | compiler: gcc 3 | 4 | notifications: 5 | irc: 6 | channels: 7 | - "chat.freenode.net#openbts" 8 | template: 9 | - "%{repository} : %{message} : %{build_url}" 10 | on_success: change 11 | on_failure: always 12 | 13 | before_install: 14 | - sudo apt-get install -qq libssl-dev unixodbc-dev libsrtp0 libsrtp0-dev uuid-dev libjansson-dev libxml2-dev 15 | 16 | #install: 17 | # - sh bootstrap.sh 18 | 19 | script: 20 | - ./build.sh 21 | 22 | -------------------------------------------------------------------------------- /build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | VERSION=11.7.0 4 | 5 | sayAndDo () { 6 | echo $@ 7 | eval $@ 8 | if [ $? -ne 0 ] 9 | then 10 | echo "ERROR: command failed!" 11 | exit 1 12 | fi 13 | } 14 | 15 | installIfMissing () { 16 | dpkg -s $@ > /dev/null 17 | if [ $? -ne 0 ]; then 18 | echo " - oops, missing $@, installing" 19 | sudo apt-get install $@ 20 | else 21 | echo " - $@ ok" 22 | fi 23 | echo 24 | } 25 | 26 | if [ ! -f asterisk-$VERSION.tar.gz ] 27 | then 28 | sayAndDo wget http://downloads.asterisk.org/pub/telephony/asterisk/releases/asterisk-$VERSION.tar.gz 29 | fi 30 | 31 | if [ -d asterisk-$VERSION ] 32 | then 33 | sayAndDo rm -rf asterisk-$VERSION 34 | fi 35 | 36 | sayAndDo tar zxf asterisk-$VERSION.tar.gz 37 | sayAndDo mkdir asterisk-$VERSION/debian 38 | sayAndDo cp -R debian/* asterisk-$VERSION/debian/ 39 | sayAndDo cd asterisk-$VERSION 40 | sayAndDo patch -p0 < ../fix_pjproject_dependency.patch 41 | sayAndDo dpkg-buildpackage -us -uc 42 | 43 | -------------------------------------------------------------------------------- /debian/asterisk.conf: -------------------------------------------------------------------------------- 1 | # asterisk 2 | # 3 | # Upstart control file for the Asterisk PBX 4 | # 5 | # To install, rename this file to 'asterisk' and copy it to /etc/event.d/ 6 | # On Debian: copy to /etc/init/ 7 | # 8 | # To start asterisk manually: 9 | # sudo start asterisk 10 | # 11 | # To stop asterisk manually: 12 | # sudo stop asterisk 13 | # 14 | # Asterisk is started with an "interactive console", though redirected 15 | # to/from /dev/null . The concept of a main console is bad. OTOH, the main 16 | # process should not detach from the console if we work with upstart and 17 | # alike. 18 | # 19 | # The username 'asterisk' is currently hardwired here, and likewise the 20 | # varrundir. 21 | # 22 | 23 | description "Asterisk PBX" 24 | #version "1.6.3" 25 | 26 | start on runlevel [2345] 27 | stop on runlevel [!2345] 28 | 29 | pre-start script 30 | # Since Ubuntu clears /var/run on reboot, create this before we try to start 31 | if [ ! -d /var/run/asterisk ]; then 32 | mkdir -p asterisk /var/run/asterisk 33 | chown asterisk: /var/run/asterisk 34 | fi 35 | end script 36 | 37 | #console output 38 | respawn 39 | exec /usr/sbin/asterisk -U asterisk -g -f 40 | 41 | post-stop script 42 | # Might as well clean up after ourselves, too. 43 | rm -rf /var/run/asterisk 44 | end script 45 | -------------------------------------------------------------------------------- /debian/changelog: -------------------------------------------------------------------------------- 1 | range-asterisk (11.7.0.5) unstable; urgency=low 2 | 3 | * Test 4 | 5 | -- Michael Iedema Thu, 30 May 2013 00:11:00 -0700 6 | -------------------------------------------------------------------------------- /debian/compat: -------------------------------------------------------------------------------- 1 | 5 2 | -------------------------------------------------------------------------------- /debian/control: -------------------------------------------------------------------------------- 1 | Source: range-asterisk 2 | Section: comm 3 | Priority: optional 4 | Maintainer: Range Networks, Inc. 5 | Homepage: http://www.rangenetworks.com/ 6 | Build-Depends: build-essential, debhelper (>= 7), pkg-config, autoconf, libsqlite3-dev, unixodbc-dev, libssl-dev 7 | Standards-Version: 3.7.3 8 | 9 | Package: range-asterisk 10 | Provides: asterisk 11 | Section: comm 12 | Priority: optional 13 | Architecture: any 14 | Essential: no 15 | Depends: sqlite3, libc6, pkg-config, libsqliteodbc, unixodbc 16 | Description: Range Networks - Tested Version of Asterisk 17 | 18 | -------------------------------------------------------------------------------- /debian/dirs: -------------------------------------------------------------------------------- 1 | etc/asterisk 2 | 3 | usr/share/asterisk 4 | var/log/asterisk 5 | var/spool/asterisk 6 | var/lib/asterisk 7 | 8 | usr/share/asterisk/static-http 9 | usr/share/asterisk/agi-bin 10 | 11 | var/lib/asterisk/moh 12 | var/lib/asterisk/sounds/custom 13 | var/log/asterisk/cdr-csv 14 | var/log/asterisk/cdr-custom 15 | var/spool/asterisk/dictate 16 | var/spool/asterisk/meetme 17 | var/spool/asterisk/monitor 18 | var/spool/asterisk/system 19 | var/spool/asterisk/tmp 20 | var/spool/asterisk/voicemail 21 | var/spool/asterisk/outgoing 22 | -------------------------------------------------------------------------------- /debian/docs: -------------------------------------------------------------------------------- 1 | BUGS 2 | README 3 | CREDITS 4 | CHANGES 5 | menuselect.makeopts 6 | -------------------------------------------------------------------------------- /debian/dummyprogs/fetch: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # a dummy script that can serve as 'fetch' to pass for autoconf tests 4 | # but always returns false to make sure it is never used. 5 | # 6 | # Note: the configure script will look for wget first. If you actually 7 | # want to download sound tarballs or whatever at build time, make sure 8 | # you have wget installed, and this script should cause you no problems. 9 | 10 | exit 1 11 | -------------------------------------------------------------------------------- /debian/install: -------------------------------------------------------------------------------- 1 | usr/lib/asterisk 2 | usr/sbin 3 | usr/share/asterisk/firmware 4 | usr/share/asterisk/keys 5 | usr/share/asterisk/conf 6 | usr/share/asterisk/documentation 7 | -------------------------------------------------------------------------------- /debian/links: -------------------------------------------------------------------------------- 1 | usr/share/man/man8/asterisk.8 usr/share/man/man8/rasterisk.8 2 | usr/local/share/asterisk/sounds usr/share/asterisk/sounds/custom 3 | var/lib/asterisk/sounds/custom usr/share/asterisk/sounds/recordings 4 | -------------------------------------------------------------------------------- /debian/lintian-overrides: -------------------------------------------------------------------------------- 1 | range-asterisk: package-contains-empty-directory 2 | -------------------------------------------------------------------------------- /debian/menuselect.makeopts: -------------------------------------------------------------------------------- 1 | MENUSELECT_ADDONS=chan_mobile chan_ooh323 format_mp3 res_config_mysql app_mysql app_saycountpl cdr_mysql 2 | MENUSELECT_APPS=app_flash app_skel app_dahdiras app_fax app_ivrdemo app_jack app_meetme app_osplookup app_saycounted app_dahdibarge app_readfile app_setcallerid 3 | MENUSELECT_BRIDGES= 4 | MENUSELECT_CDR=cdr_pgsql cdr_radius cdr_tds cdr_sqlite 5 | MENUSELECT_CEL=cel_pgsql cel_radius cel_tds 6 | MENUSELECT_CHANNELS=chan_dahdi chan_motif chan_alsa chan_console chan_mgcp chan_misdn chan_nbs chan_oss chan_phone chan_skinny chan_unistim chan_vpb chan_gtalk chan_h323 chan_jingle 7 | MENUSELECT_CODECS=codec_dahdi codec_speex 8 | MENUSELECT_FORMATS=format_ogg_vorbis 9 | MENUSELECT_FUNCS=func_curl func_speex 10 | MENUSELECT_PBX=pbx_lua 11 | MENUSELECT_RES=res_calendar_caldav res_calendar_ews res_calendar_exchange res_calendar_icalendar res_config_curl res_config_sqlite res_curl res_format_attr_celt res_format_attr_h263 res_format_attr_h264 res_format_attr_silk res_http_post res_timing_dahdi res_xmpp res_config_ldap res_config_pgsql res_corosync res_fax_spandsp res_pktccops res_snmp res_timing_kqueue res_jabber 12 | MENUSELECT_TESTS=test_abstract_jb test_acl test_amihooks test_aoc test_app test_ast_format_str_reduce test_astobj2 test_astobj2_thrash test_config test_db test_devicestate test_dlinklists test_event test_expr test_format_api test_func_file test_gosub test_hashtab_thrash test_heap test_jitterbuf test_linkedlists test_locale test_logger test_netsock2 test_pbx test_poll test_sched test_security_events test_skel test_stringfields test_strings test_substitution test_time test_utils test_voicemail_api test_xml_escape 13 | MENUSELECT_CFLAGS=LOADABLE_MODULES 14 | MENUSELECT_OPTS_app_voicemail=FILE_STORAGE 15 | MENUSELECT_UTILS=astcanary astdb2sqlite3 astdb2bdb 16 | MENUSELECT_AGIS= 17 | MENUSELECT_EMBED= 18 | MENUSELECT_CORE_SOUNDS=CORE-SOUNDS-EN-GSM 19 | MENUSELECT_MOH=MOH-OPSOUND-GSM 20 | MENUSELECT_EXTRA_SOUNDS= 21 | MENUSELECT_BUILD_DEPS=chan_local app_voicemail app_confbridge res_monitor res_agi res_adsi res_smdi res_odbc res_crypto res_http_websocket res_ael_share G711_NEW_ALGORITHM 22 | MENUSELECT_DEPSFAILED=MENUSELECT_APPS=app_flash 23 | MENUSELECT_DEPSFAILED=MENUSELECT_APPS=app_dahdiras 24 | MENUSELECT_DEPSFAILED=MENUSELECT_APPS=app_jack 25 | MENUSELECT_DEPSFAILED=MENUSELECT_APPS=app_osplookup 26 | MENUSELECT_DEPSFAILED=MENUSELECT_CDR=cdr_pgsql 27 | MENUSELECT_DEPSFAILED=MENUSELECT_CDR=cdr_radius 28 | MENUSELECT_DEPSFAILED=MENUSELECT_CDR=cdr_tds 29 | MENUSELECT_DEPSFAILED=MENUSELECT_CEL=cel_pgsql 30 | MENUSELECT_DEPSFAILED=MENUSELECT_CEL=cel_radius 31 | MENUSELECT_DEPSFAILED=MENUSELECT_CEL=cel_tds 32 | MENUSELECT_DEPSFAILED=MENUSELECT_CHANNELS=chan_dahdi 33 | MENUSELECT_DEPSFAILED=MENUSELECT_CHANNELS=chan_motif 34 | MENUSELECT_DEPSFAILED=MENUSELECT_CHANNELS=chan_alsa 35 | MENUSELECT_DEPSFAILED=MENUSELECT_CHANNELS=chan_console 36 | MENUSELECT_DEPSFAILED=MENUSELECT_CHANNELS=chan_misdn 37 | MENUSELECT_DEPSFAILED=MENUSELECT_CHANNELS=chan_nbs 38 | MENUSELECT_DEPSFAILED=MENUSELECT_CODECS=codec_dahdi 39 | MENUSELECT_DEPSFAILED=MENUSELECT_CODECS=codec_speex 40 | MENUSELECT_DEPSFAILED=MENUSELECT_FORMATS=format_ogg_vorbis 41 | MENUSELECT_DEPSFAILED=MENUSELECT_FUNCS=func_curl 42 | MENUSELECT_DEPSFAILED=MENUSELECT_FUNCS=func_speex 43 | MENUSELECT_DEPSFAILED=MENUSELECT_PBX=pbx_lua 44 | MENUSELECT_DEPSFAILED=MENUSELECT_RES=res_calendar_caldav 45 | MENUSELECT_DEPSFAILED=MENUSELECT_RES=res_calendar_ews 46 | MENUSELECT_DEPSFAILED=MENUSELECT_RES=res_calendar_exchange 47 | MENUSELECT_DEPSFAILED=MENUSELECT_RES=res_calendar_icalendar 48 | MENUSELECT_DEPSFAILED=MENUSELECT_RES=res_config_curl 49 | MENUSELECT_DEPSFAILED=MENUSELECT_RES=res_curl 50 | MENUSELECT_DEPSFAILED=MENUSELECT_RES=res_http_post 51 | MENUSELECT_DEPSFAILED=MENUSELECT_RES=res_timing_dahdi 52 | MENUSELECT_DEPSFAILED=MENUSELECT_RES=res_xmpp 53 | MENUSELECT_DEPSFAILED=MENUSELECT_RES=res_config_ldap 54 | MENUSELECT_DEPSFAILED=MENUSELECT_RES=res_config_pgsql 55 | MENUSELECT_DEPSFAILED=MENUSELECT_RES=res_corosync 56 | MENUSELECT_DEPSFAILED=MENUSELECT_RES=res_fax_spandsp 57 | MENUSELECT_DEPSFAILED=MENUSELECT_RES=res_snmp 58 | MENUSELECT_DEPSFAILED=MENUSELECT_RES=res_timing_kqueue 59 | MENUSELECT_DEPSFAILED=MENUSELECT_TESTS=test_abstract_jb 60 | MENUSELECT_DEPSFAILED=MENUSELECT_TESTS=test_acl 61 | MENUSELECT_DEPSFAILED=MENUSELECT_TESTS=test_amihooks 62 | MENUSELECT_DEPSFAILED=MENUSELECT_TESTS=test_aoc 63 | MENUSELECT_DEPSFAILED=MENUSELECT_TESTS=test_app 64 | MENUSELECT_DEPSFAILED=MENUSELECT_TESTS=test_ast_format_str_reduce 65 | MENUSELECT_DEPSFAILED=MENUSELECT_TESTS=test_astobj2 66 | MENUSELECT_DEPSFAILED=MENUSELECT_TESTS=test_astobj2_thrash 67 | MENUSELECT_DEPSFAILED=MENUSELECT_TESTS=test_config 68 | MENUSELECT_DEPSFAILED=MENUSELECT_TESTS=test_db 69 | MENUSELECT_DEPSFAILED=MENUSELECT_TESTS=test_devicestate 70 | MENUSELECT_DEPSFAILED=MENUSELECT_TESTS=test_dlinklists 71 | MENUSELECT_DEPSFAILED=MENUSELECT_TESTS=test_event 72 | MENUSELECT_DEPSFAILED=MENUSELECT_TESTS=test_expr 73 | MENUSELECT_DEPSFAILED=MENUSELECT_TESTS=test_format_api 74 | MENUSELECT_DEPSFAILED=MENUSELECT_TESTS=test_func_file 75 | MENUSELECT_DEPSFAILED=MENUSELECT_TESTS=test_gosub 76 | MENUSELECT_DEPSFAILED=MENUSELECT_TESTS=test_hashtab_thrash 77 | MENUSELECT_DEPSFAILED=MENUSELECT_TESTS=test_heap 78 | MENUSELECT_DEPSFAILED=MENUSELECT_TESTS=test_jitterbuf 79 | MENUSELECT_DEPSFAILED=MENUSELECT_TESTS=test_linkedlists 80 | MENUSELECT_DEPSFAILED=MENUSELECT_TESTS=test_locale 81 | MENUSELECT_DEPSFAILED=MENUSELECT_TESTS=test_logger 82 | MENUSELECT_DEPSFAILED=MENUSELECT_TESTS=test_netsock2 83 | MENUSELECT_DEPSFAILED=MENUSELECT_TESTS=test_pbx 84 | MENUSELECT_DEPSFAILED=MENUSELECT_TESTS=test_poll 85 | MENUSELECT_DEPSFAILED=MENUSELECT_TESTS=test_sched 86 | MENUSELECT_DEPSFAILED=MENUSELECT_TESTS=test_security_events 87 | MENUSELECT_DEPSFAILED=MENUSELECT_TESTS=test_skel 88 | MENUSELECT_DEPSFAILED=MENUSELECT_TESTS=test_stringfields 89 | MENUSELECT_DEPSFAILED=MENUSELECT_TESTS=test_strings 90 | MENUSELECT_DEPSFAILED=MENUSELECT_TESTS=test_substitution 91 | MENUSELECT_DEPSFAILED=MENUSELECT_TESTS=test_time 92 | MENUSELECT_DEPSFAILED=MENUSELECT_TESTS=test_utils 93 | MENUSELECT_DEPSFAILED=MENUSELECT_TESTS=test_voicemail_api 94 | MENUSELECT_DEPSFAILED=MENUSELECT_TESTS=test_xml_escape 95 | -------------------------------------------------------------------------------- /debian/postinst: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | set -e 4 | 5 | # summary of how this script can be called: 6 | # * `configure' 7 | # * `abort-upgrade' 8 | # * `abort-remove' `in-favour' 9 | # 10 | # * `abort-deconfigure' `in-favour' 11 | # `removing' 12 | # 13 | 14 | case "$1" in 15 | configure) 16 | # add asterisk user 17 | if ! getent passwd asterisk > /dev/null ; then 18 | echo 'Adding system user for Asterisk' 1>&2 19 | adduser --system --group --quiet \ 20 | --home /var/lib/asterisk \ 21 | --no-create-home --disabled-login \ 22 | --gecos "Asterisk PBX daemon" \ 23 | asterisk 24 | fi 25 | 26 | # add asterisk to required groups 27 | for group in dialout audio www-data; do 28 | if groups asterisk | grep -w -q -v $group; then 29 | adduser asterisk $group 30 | fi 31 | done 32 | 33 | # chown asterisk on all $dirs and their subdirectories 34 | # do not harm the files, they should be empty on new installations 35 | # and we don't want to mess-up anything on old installations 36 | find /var/log/asterisk \ 37 | /var/lib/asterisk \ 38 | -type d | while read dir; do 39 | if ! dpkg-statoverride --list "$dir" > /dev/null ; then 40 | chown asterisk:www-data "$dir" 41 | fi 42 | done 43 | 44 | # this is not needed for new installations but is not such a bad idea 45 | # removing this will _break_ upgrades from versions < 1:1.4.10.1~dfsg-1 46 | # 47 | # we are doing the same for subdirectories, since we are not shipping 48 | # any and it's supposed to be user-modifiable 49 | if ! dpkg-statoverride --list "/etc/asterisk" > /dev/null ; then 50 | chown asterisk:www-data /etc/asterisk 51 | fi 52 | 53 | # spool holds some sensitive information (e.g. monitor, voicemail etc.) 54 | find /var/spool/asterisk -type d | while read dir; do 55 | if ! dpkg-statoverride --list "$dir" > /dev/null ; then 56 | chown asterisk:www-data "$dir" 57 | chmod 750 "$dir" 58 | fi 59 | done 60 | 61 | # Create /usr/local directory; policy 9.1.2 62 | if [ ! -e /usr/local/share/asterisk/sounds ]; then 63 | if mkdir -p /usr/local/share/asterisk/sounds 2>/dev/null ; then 64 | chown root:staff /usr/local/share/asterisk/sounds 65 | chmod 2775 /usr/local/share/asterisk/sounds 66 | fi 67 | fi 68 | 69 | ### this is done here in case asterisk-config was installed/upgraded first 70 | 71 | set +e # ignore errors temporarily 72 | 73 | # find the name of the package providing config; either asterisk-config 74 | # or a package providing asterisk-config-custom 75 | ASTERISK_CONFIG=`dpkg-query -W -f='${Package}\t${Provides}\n' | \ 76 | sed -nr 's/(.*)\tasterisk-config-custom|(asterisk-config)(\t.*)?/\1\2/p'` 77 | 78 | # find conffiles under /etc/asterisk belonging to asterisk-config 79 | # and chown them to user asterisk. 80 | dpkg-query -W -f='${Conffiles}\n' $ASTERISK_CONFIG 2>/dev/null | \ 81 | sed -nr -e 's; (/etc/asterisk/.*) [0-9a-f]*;\1;p' | \ 82 | while read conffile; do 83 | chown asterisk:www-data "$conffile" 2>/dev/null 84 | done 85 | 86 | # handle them in the end with a glob since it's way faster 87 | dpkg-statoverride --quiet --list '/etc/asterisk/*' | while read STAT; do 88 | chown `echo $STAT | cut -d' ' -f 1,2,4 | sed 's/ /:/'` \ 89 | 2>/dev/null 90 | done 91 | 92 | set -e 93 | ;; 94 | 95 | abort-upgrade|abort-remove|abort-deconfigure) 96 | ;; 97 | 98 | *) 99 | echo "postinst called with unknown argument \`$1'" >&2 100 | exit 1 101 | ;; 102 | esac 103 | 104 | # dh_installdeb will replace this with shell code automatically 105 | # generated by other debhelper scripts. 106 | 107 | #DEBHELPER# 108 | 109 | exit 0 110 | 111 | 112 | -------------------------------------------------------------------------------- /debian/postrm: -------------------------------------------------------------------------------- 1 | #! /bin/sh -e 2 | 3 | if [ "$1" = purge ]; then 4 | userdel -r asterisk 2>/dev/null || true 5 | rm -fR /var/log/asterisk 6 | 7 | fi 8 | 9 | #DEBHELPER# 10 | -------------------------------------------------------------------------------- /debian/prerm: -------------------------------------------------------------------------------- 1 | #! /bin/sh -e 2 | 3 | rmdir /usr/local/share/asterisk/sounds 2>/dev/null || true 4 | rmdir /usr/local/share/asterisk 2>/dev/null || true 5 | 6 | #DEBHELPER# 7 | -------------------------------------------------------------------------------- /debian/rules: -------------------------------------------------------------------------------- 1 | #!/usr/bin/make -f 2 | # Uncomment this to turn on verbose mode. 3 | #export DH_VERBOSE=1 4 | 5 | export DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE) 6 | export DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE) 7 | 8 | ifeq ($(DEB_BUILD_GNU_TYPE), $(DEB_HOST_GNU_TYPE)) 9 | confflags += --build $(DEB_HOST_GNU_TYPE) 10 | else 11 | confflags += --build $(DEB_BUILD_GNU_TYPE) --host $(DEB_HOST_GNU_TYPE) 12 | endif 13 | 14 | # We copy around a number of things in case we're linux: 15 | BUILD_OS=$(shell dpkg-architecture -qDEB_BUILD_ARCH_OS) 16 | 17 | export PROC := $(shell dpkg-architecture -qDEB_BUILD_GNU_CPU) 18 | 19 | CFLAGS = `dpkg-buildflags --get CFLAGS` 20 | LDFLAGS = `dpkg-buildflags --get LDFLAGS` 21 | CFLAGS += `dpkg-buildflags --get CPPFLAGS` 22 | 23 | # Necessary to pass hardening flags to menuselect. 24 | export CFLAGS LDFLAGS 25 | 26 | 27 | ifneq (,$(filter noopt,$(DEB_BUILD_OPTIONS))) 28 | BUILDFLAGS += OPTIMIZE=-O0 29 | else 30 | BUILDFLAGS += OPTIMIZE=-O2 31 | endif 32 | BUILDFLAGS += MAKECMDGOALS=dont-optimize 33 | 34 | # show full gcc arguments instead of [CC] and [LD] 35 | BUILDFLAGS += NOISY_BUILD=yes 36 | 37 | BUILDFLAGS += ASTDATADIR=/usr/share/asterisk ASTVARRUNDIR=/var/run/asterisk 38 | 39 | ifneq (,$(findstring debug,$(DEB_BUILD_OPTIONS))) 40 | ENABLE_DEBUG += --enable-dev-mode 41 | endif 42 | ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS))) 43 | INSTALL_PROGRAM += -s 44 | endif 45 | 46 | DEBVERSION:=$(shell dpkg-parsechangelog | sed -n -e 's/Version: //p') 47 | DEB_NOEPOCH_VERSION:=$(shell echo $(DEBVERSION) | cut -d':' -f 2) 48 | DEB_SRC_VERSION:=$(shell echo $(DEB_NOEPOCH_VERSION) | sed -e 's/-[^-]\+$$//') 49 | UPVERSION:=$(shell echo $(DEB_SRC_VERSION) | sed -e 's/[.~]dfsg//' -e 's/~\(\(rc\|beta\)[0-9]\)/-\1/') 50 | 51 | FILENAME := asterisk_$(DEB_SRC_VERSION).orig.tar.gz 52 | UPFILENAME := asterisk_$(UPVERSION).orig.tar.gz 53 | URL := http://downloads.asterisk.org/pub/telephony/asterisk/releases/asterisk-$(UPVERSION).tar.gz 54 | 55 | # make sure we have 'fetch' . We need to have either wget or fetch 56 | # on the system. However it is generally not a good idea to actually 57 | # get remote tarballs at build time. So if neither wget nor fetch 58 | # happen to be installed, the configure script will find a dummy 59 | # fetch script that always returns an error. 60 | FETCH_ENV = PATH=$$PATH:$(CURDIR)/debian/dummyprogs 61 | 62 | configure: configure.ac 63 | if [ ! -f configure_deborig ]; then mv configure configure_deborig; fi 64 | ./bootstrap.sh 65 | 66 | config.status: configure 67 | dh_testdir 68 | 69 | [ -f .version.debian_sav ] || cp -a .version .version.debian_sav 70 | echo $(DEB_NOEPOCH_VERSION) > .version 71 | 72 | if [ ! -r configure.debian_sav ]; then cp -a configure configure.debian_sav; fi 73 | 74 | chmod 755 $(CURDIR)/debian/dummyprogs/fetch 75 | 76 | $(FETCH_ENV) ./configure \ 77 | CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS) -z muldefs" \ 78 | --host=$(DEB_HOST_GNU_TYPE) \ 79 | --build=$(DEB_BUILD_GNU_TYPE) \ 80 | --prefix=/usr \ 81 | --mandir=\$${prefix}/share/man \ 82 | --infodir=\$${prefix}/share/info \ 83 | --with-gsm \ 84 | --without-imap \ 85 | --without-pwlib \ 86 | --disable-xmldoc \ 87 | ${ENABLE_DEBUG} 88 | 89 | # --with-cap \ 90 | 91 | build: build-arch build-indep 92 | 93 | build-arch: build-arch-stamp 94 | build-arch-stamp: config.status 95 | dh_testdir 96 | cp debian/menuselect.makeopts . 97 | $(MAKE) menuselect.makeopts 98 | @if [ "x${ENABLE_DEBUG}" != "x" ] ; then \ 99 | menuselect/menuselect --enable DONT_OPTIMIZE menuselect.makeopts ; \ 100 | menuselect/menuselect --enable DEBUG_THREADS menuselect.makeopts ; \ 101 | fi 102 | $(FETCH_ENV) $(MAKE) $(BUILDFLAGS) 103 | touch $@ 104 | 105 | build-indep: build-indep-stamp 106 | build-indep-stamp: config.status 107 | dh_testdir 108 | touch $@ 109 | 110 | SND_FILE=asterisk-core-sounds-en-gsm-1.4.20.tar.gz 111 | clean: 112 | dh_testdir 113 | dh_testroot 114 | 115 | # The clean target seems to be run before patches are applied. 116 | # A brute-force fix to keep the tarball from getting deleted: 117 | # (if it has not been stripped from upstream tarball) 118 | if [ -r sounds/$(SND_FILE) ]; then mv sounds/$($SND_FILE) debian/; fi 119 | GREP=grep AWK=awk $(MAKE) distclean 120 | if [ -r debian/$(SND_FILE) ]; then mv debian/$(SND_FILE) sounds/; fi 121 | -$(RM) -rf debian/build 122 | 123 | if [ -r configure.debian_sav ]; then mv configure.debian_sav configure; fi 124 | -test -d configs && chmod -x configs/*.sample 125 | -$(RM) -f build-arch-stamp build-indep-stamp install-arch install-indep 126 | -$(RM) -f config.status menuselect.makeopts 127 | 128 | [ ! -f .version.debian_sav ] || mv .version.debian_sav .version 129 | if [ -f configure_deborig ]; then mv configure_deborig configure; fi 130 | 131 | # these were generated while building 132 | -$(RM) -f doc/core-en_US.xml utils/poll.c 133 | 134 | dh_clean 135 | 136 | SUBPACKS_EXTRA = \ 137 | voicemail voicemail-odbcstorage voicemail-imapstorage \ 138 | ooh323 mysql mp3 139 | ifeq (linux,$(BUILD_OS)) 140 | SUBPACKS_EXTRA += dahdi mobile 141 | endif 142 | SUBPACKS_EXTRA_DIRS = $(SUBPACKS_EXTRA:%=$(CURDIR)/debian/asterisk-%) 143 | SUBPACKS_EXTRA_DIRS_MOD = $(SUBPACKS_EXTRA_DIRS:%=%/usr/lib/asterisk/modules) 144 | 145 | install: install-arch install-indep 146 | install-arch: build-arch 147 | dh_testdir 148 | dh_testroot 149 | dh_prep -s 150 | dh_installdirs -s 151 | 152 | $(FETCH_ENV) $(MAKE) $(BUILDFLAGS) DESTDIR=$(CURDIR)/debian/tmp install 153 | cp -a configs $(CURDIR)/debian/tmp/usr/share/asterisk/conf 154 | 155 | mkdir -p $(CURDIR)/debian/range-asterisk/etc/init 156 | cp $(CURDIR)/debian/asterisk.conf $(CURDIR)/debian/range-asterisk/etc/init/ 157 | 158 | dh_install -s --sourcedir=debian/tmp 159 | dh_lintian -s 160 | 161 | cp $(CURDIR)/debian/tmp/usr/lib/libasteriskssl* $(CURDIR)/debian/range-asterisk/usr/lib/ 162 | 163 | $(RM) -f $(CURDIR)/debian/range-asterisk/usr/sbin/aelparse 164 | $(RM) -f $(CURDIR)/debian/range-asterisk/usr/sbin/conf2ael 165 | $(RM) -f $(CURDIR)/debian/range-asterisk/usr/sbin/muted 166 | $(RM) -f $(CURDIR)/debian/range-asterisk/usr/sbin/streamplayer 167 | $(RM) -f $(CURDIR)/debian/range-asterisk/usr/sbin/stereorize 168 | $(RM) -f $(CURDIR)/debian/range-asterisk/usr/sbin/hashtest* 169 | $(RM) -f $(CURDIR)/debian/range-asterisk/usr/sbin/refcounter 170 | 171 | # extra_packs=`find $(SUBPACKS_EXTRA_DIRS_MOD) -name '*.so' -printf '%f\n'`\ 172 | # ; cd $(CURDIR)/debian/asterisk-modules/usr/lib/asterisk/modules \ 173 | # && rm -f $$extra_packs 174 | 175 | # Rename dh_install file for -imapstorage and -odbcstorage. 176 | # mv $(CURDIR)/debian/asterisk-voicemail-imapstorage/usr/lib/asterisk/modules/app_voicemail_imapstorage.so \ 177 | # $(CURDIR)/debian/asterisk-voicemail-imapstorage/usr/lib/asterisk/modules/app_voicemail.so 178 | # mv $(CURDIR)/debian/asterisk-voicemail-odbcstorage/usr/lib/asterisk/modules/app_voicemail_odbcstorage.so \ 179 | # $(CURDIR)/debian/asterisk-voicemail-odbcstorage/usr/lib/asterisk/modules/app_voicemail.so 180 | 181 | touch $@ 182 | 183 | install-indep: build-indep 184 | dh_testdir 185 | dh_testroot 186 | dh_prep -i 187 | dh_installdirs -i 188 | 189 | $(FETCH_ENV) $(MAKE) $(BUILDFLAGS) DESTDIR=$(CURDIR)/debian/tmp install samples 190 | dh_install -i --sourcedir=debian/tmp 191 | dh_lintian -i 192 | 193 | # create a simple config 194 | #echo "; please read the documentation regarding the Manager Interface (asterisk-doc package)" > \ 195 | # $(CURDIR)/debian/asterisk-config/etc/asterisk/manager.d/README.conf 196 | touch $@ 197 | 198 | binary: binary-indep binary-arch 199 | binary-indep: install-indep 200 | dh_testdir -i 201 | dh_testroot -i 202 | dh_installlogrotate -i 203 | dh_installdocs -i -XREADME.cygwin 204 | # dh_installexamples -i 205 | dh_installcron -i 206 | dh_installchangelogs ChangeLog -i 207 | dh_link -i 208 | dh_compress -i 209 | dh_fixperms -i 210 | # should follow dh_fixperms; asterisk configurations may contain 211 | # sensitive information, such as passwords 212 | # chmod o-rwx $(CURDIR)/debian/asterisk-config/etc/asterisk/* 213 | # chmod o+rx $(CURDIR)/debian/asterisk-config/etc/asterisk/manager.d 214 | dh_installdeb -i 215 | dh_gencontrol -i 216 | dh_md5sums -i 217 | dh_builddeb -i 218 | 219 | binary-arch: install-arch 220 | dh_testdir -a 221 | dh_testroot -a 222 | dh_installlogrotate -a 223 | dh_installdocs -a 224 | dh_installman utils/*.1 doc/*.8 contrib/scripts/*.8 225 | # dh_installexamples -a 226 | dh_installchangelogs ChangeLog -a 227 | # dh_installinit -a -- defaults 21 228 | # dh_strip -a --dbg-package=asterisk-dbg 229 | dh_link -a 230 | dh_compress -a 231 | dh_fixperms -a 232 | dh_installdeb -a 233 | # dh_shlibdeps -a 234 | dh_gencontrol -a 235 | dh_md5sums -a 236 | dh_builddeb -a 237 | 238 | print-version: 239 | @@echo "Debian version: $(DEBVERSION)" 240 | @@echo "Upstream version: $(UPVERSION)" 241 | 242 | TMP_TARBALL_TOP=../tarballs/asterisk-$(UPVERSION).tmp/asterisk-$(UPVERSION) 243 | get-orig-source: 244 | @@dh_testdir 245 | #@@[ -d ../tarballs/. ]||mkdir -p ../tarballs 246 | #@@echo Downloading $(FILENAME) from $(URL) ... 247 | #@@wget -nv -T10 -t3 -O ../tarballs/$(FILENAME) $(URL) 248 | @echo Downloading $(UPFILENAME) from $(URL) ... 249 | @wget -nv -T10 -t3 -O ../tarballs/$(UPFILENAME) $(URL) 250 | @echo Repacking as DFSG-free... 251 | @mkdir -p ../tarballs/asterisk-$(UPVERSION).tmp/ 252 | @cd ../tarballs/asterisk-$(UPVERSION).tmp ; \ 253 | tar xfz ../$(UPFILENAME) 254 | # in case the tarball is not clean: 255 | @rm -rf $(TMP_TARBALL_TOP)/AST.txt 256 | @rm -rf $(TMP_TARBALL_TOP)/AST.pdf 257 | @rm -f $(TMP_TARBALL_TOP)/codecs/ilbc/rfc3951.txt 258 | # While we're at it: remove some generated files that will become 259 | # invalid: 260 | @rm -rf $(TMP_TARBALL_TOP)/*/.makeopts 261 | @rm -rf $(TMP_TARBALL_TOP)/*/.*.makeopts 262 | @rm -rf $(TMP_TARBALL_TOP)/*/.moduleinfo 263 | @rm -rf $(TMP_TARBALL_TOP)/*/.*.moduleinfo 264 | # And some large sound files we already ship in a different package: 265 | @rm -rf $(TMP_TARBALL_TOP)/sounds/*.tar.gz 266 | @cd ../tarballs/asterisk-$(UPVERSION).tmp ; \ 267 | tar cf - * | gzip -9 >../$(FILENAME) 268 | @echo Cleaning up... 269 | @$(RM) -rf ../tarballs/asterisk-$(UPVERSION).tmp/ 270 | 271 | .PHONY: build build-arch build-indep clean binary-indep binary-arch binary install clean 272 | -------------------------------------------------------------------------------- /direct-integration-patches/10.9.0/v1_selectable_option.patch: -------------------------------------------------------------------------------- 1 | Index: channels/sip/include/sip.h 2 | =================================================================== 3 | --- channels/sip/include/sip.h (revision 424158) 4 | +++ channels/sip/include/sip.h (working copy) 5 | @@ -224,6 +224,7 @@ 6 | #define DEFAULT_SDPOWNER "root" /*!< Default SDP username field in (o=) header unless re-defined in sip.conf */ 7 | #define DEFAULT_ENGINE "asterisk" /*!< Default RTP engine to use for sessions */ 8 | #define DEFAULT_STORE_SIP_CAUSE FALSE /*!< Don't store HASH(SIP_CAUSE,) for channels by default */ 9 | +#define DEFAULT_DIGESTALGORITHM "md5" /*!< Default authentication digest algorithm */ 10 | #endif 11 | /*@}*/ 12 | 13 | @@ -1009,6 +1010,7 @@ 14 | AST_STRING_FIELD(authname); /*!< Who we use for authentication */ 15 | AST_STRING_FIELD(uri); /*!< Original requested URI */ 16 | AST_STRING_FIELD(okcontacturi); /*!< URI from the 200 OK on INVITE */ 17 | + AST_STRING_FIELD(digestalgorithm); /*!< Digest algorithm */ 18 | AST_STRING_FIELD(peersecret); /*!< Password */ 19 | AST_STRING_FIELD(peermd5secret); 20 | AST_STRING_FIELD(cid_num); /*!< Caller*ID number */ 21 | @@ -1222,6 +1224,7 @@ 22 | struct sip_peer { 23 | char name[80]; /*!< the unique name of this object */ 24 | AST_DECLARE_STRING_FIELDS( 25 | + AST_STRING_FIELD(digestalgorithm); /*!< Digest algorithm */ 26 | AST_STRING_FIELD(secret); /*!< Password for inbound auth */ 27 | AST_STRING_FIELD(md5secret); /*!< Password in MD5 */ 28 | AST_STRING_FIELD(description); /*!< Description of this peer */ 29 | @@ -1345,6 +1348,7 @@ 30 | AST_STRING_FIELD(username); /*!< Who we are registering as */ 31 | AST_STRING_FIELD(authuser); /*!< Who we *authenticate* as */ 32 | AST_STRING_FIELD(hostname); /*!< Domain or host we register to */ 33 | + AST_STRING_FIELD(digestalgorithm); /*!< Digest algorithm */ 34 | AST_STRING_FIELD(secret); /*!< Password in clear text */ 35 | AST_STRING_FIELD(md5secret); /*!< Password in md5 */ 36 | AST_STRING_FIELD(callback); /*!< Contact extension */ 37 | Index: channels/chan_sip.c 38 | =================================================================== 39 | --- channels/chan_sip.c (revision 424158) 40 | +++ channels/chan_sip.c (working copy) 41 | @@ -695,6 +695,7 @@ 42 | static struct ast_codec_pref default_prefs; /*!< Default codec prefs */ 43 | static unsigned int default_transports; /*!< Default Transports (enum sip_transport) that are acceptable */ 44 | static unsigned int default_primary_transport; /*!< Default primary Transport (enum sip_transport) for outbound connections to devices */ 45 | +static char default_digestalgorithm[80]; /*!< Digest algorithm */ 46 | /*@}*/ 47 | 48 | static struct sip_settings sip_cfg; /*!< SIP configuration data. 49 | @@ -5389,6 +5390,7 @@ 50 | ast_string_field_set(dialog, peername, peer->name); 51 | ast_string_field_set(dialog, authname, peer->username); 52 | ast_string_field_set(dialog, username, peer->username); 53 | + ast_string_field_set(dialog, digestalgorithm, peer->digestalgorithm); 54 | ast_string_field_set(dialog, peersecret, peer->secret); 55 | ast_string_field_set(dialog, peermd5secret, peer->md5secret); 56 | ast_string_field_set(dialog, mohsuggest, peer->mohsuggest); 57 | @@ -13816,6 +13818,9 @@ 58 | ast_set_flag(&p->flags[0], SIP_OUTGOING); /* Registration is outgoing call */ 59 | r->call = dialog_ref(p, "copying dialog into registry r->call"); /* Save pointer to SIP dialog */ 60 | p->registry = registry_addref(r, "transmit_register: addref to p->registry in transmit_register"); /* Add pointer to registry in packet */ 61 | + if (!ast_strlen_zero(r->digestalgorithm)) { 62 | + ast_string_field_set(p, digestalgorithm, r->digestalgorithm); 63 | + } 64 | if (!ast_strlen_zero(r->secret)) { /* Secret (password) */ 65 | ast_string_field_set(p, peersecret, r->secret); 66 | } 67 | @@ -14838,7 +14843,12 @@ 68 | static void set_nonce_randdata(struct sip_pvt *p, int forceupdate) 69 | { 70 | if (p->stalenonce || forceupdate || ast_strlen_zero(p->randdata)) { 71 | - ast_string_field_build(p, randdata, "%08lx", ast_random()); /* Create nonce for challenge */ 72 | + printf("digestalgorithm : %s", p->digestalgorithm); 73 | + if (!strncasecmp(p->digestalgorithm, "comp128v1", 9)) { 74 | + ast_string_field_build(p, randdata, "%032lx", ast_random()); /* Create nonce for challenge */ 75 | + } else { 76 | + ast_string_field_build(p, randdata, "%08lx", ast_random()); /* Create nonce for challenge */ 77 | + } 78 | p->stalenonce = 0; 79 | } 80 | } 81 | @@ -15382,6 +15392,7 @@ 82 | ast_log(LOG_ERROR, "Peer '%s' is trying to register, but not configured as host=dynamic\n", peer->name); 83 | res = AUTH_PEER_NOT_DYNAMIC; 84 | } else { 85 | + ast_string_field_set(p, digestalgorithm, peer->digestalgorithm); 86 | ast_copy_flags(&p->flags[0], &peer->flags[0], SIP_NAT_FORCE_RPORT); 87 | if (!(res = check_auth(p, req, peer->name, peer->secret, peer->md5secret, SIP_REGISTER, uri2, XMIT_UNRELIABLE, req->ignore))) { 88 | if (sip_cancel_destroy(p)) 89 | @@ -16545,6 +16556,7 @@ 90 | 91 | do_setnat(p); 92 | 93 | + ast_string_field_set(p, digestalgorithm, peer->digestalgorithm); 94 | ast_string_field_set(p, peersecret, peer->secret); 95 | ast_string_field_set(p, peermd5secret, peer->md5secret); 96 | ast_string_field_set(p, subscribecontext, peer->subscribecontext); 97 | @@ -16629,6 +16641,7 @@ 98 | if (!ast_strlen_zero(peer->mwi_from)) { 99 | ast_string_field_set(p, mwi_from, peer->mwi_from); 100 | } 101 | + ast_string_field_set(p, digestalgorithm, peer->digestalgorithm); 102 | ast_string_field_set(p, peersecret, peer->secret); 103 | ast_string_field_set(p, peermd5secret, peer->md5secret); 104 | ast_string_field_set(p, language, peer->language); 105 | @@ -18206,6 +18219,7 @@ 106 | if (realtimepeers) { /* Realtime is enabled */ 107 | ast_cli(fd, " Realtime peer: %s\n", peer->is_realtime ? "Yes, cached" : "No"); 108 | } 109 | + ast_cli(fd, " Digest Algo : %s\n", peer->digestalgorithm); 110 | ast_cli(fd, " Secret : %s\n", ast_strlen_zero(peer->secret)?"":""); 111 | ast_cli(fd, " MD5Secret : %s\n", ast_strlen_zero(peer->md5secret)?"":""); 112 | ast_cli(fd, " Remote Secret: %s\n", ast_strlen_zero(peer->remotesecret)?"":""); 113 | @@ -19347,6 +19361,7 @@ 114 | ast_cli(a->fd, " Theoretical Address: %s\n", ast_sockaddr_stringify(&cur->sa)); 115 | ast_cli(a->fd, " Received Address: %s\n", ast_sockaddr_stringify(&cur->recv)); 116 | ast_cli(a->fd, " SIP Transfer mode: %s\n", transfermode2str(cur->allowtransfer)); 117 | + ast_cli(a->fd, " Digest Algorithm: %s\n", cur->digestalgorithm); 118 | ast_cli(a->fd, " Force rport: %s\n", AST_CLI_YESNO(ast_test_flag(&cur->flags[0], SIP_NAT_FORCE_RPORT))); 119 | if (ast_sockaddr_isnull(&cur->redirip)) { 120 | ast_cli(a->fd, 121 | @@ -28236,6 +28251,7 @@ 122 | if (global_callcounter) 123 | peer->call_limit=INT_MAX; 124 | ast_string_field_set(peer, vmexten, default_vmexten); 125 | + ast_string_field_set(peer, digestalgorithm, default_digestalgorithm); 126 | ast_string_field_set(peer, secret, ""); 127 | ast_string_field_set(peer, description, ""); 128 | ast_string_field_set(peer, remotesecret, ""); 129 | @@ -28773,6 +28789,8 @@ 130 | ast_set2_flag(&peer->flags[2], !strcasecmp(v->value, "32"), SIP_PAGE3_SRTP_TAG_32); 131 | } else if (!strcasecmp(v->name, "snom_aoc_enabled")) { 132 | ast_set2_flag(&peer->flags[2], ast_true(v->value), SIP_PAGE3_SNOM_AOC); 133 | + } else if (!strcasecmp(v->name, "digestalgorithm")) { 134 | + ast_string_field_set(peer, digestalgorithm, v->value); 135 | } 136 | } 137 | 138 | @@ -29309,6 +29327,7 @@ 139 | authlimit = DEFAULT_AUTHLIMIT; 140 | authtimeout = DEFAULT_AUTHTIMEOUT; 141 | global_store_sip_cause = DEFAULT_STORE_SIP_CAUSE; 142 | + ast_copy_string(default_digestalgorithm, DEFAULT_DIGESTALGORITHM, sizeof(default_digestalgorithm)); 143 | 144 | sip_cfg.matchexternaddrlocally = DEFAULT_MATCHEXTERNADDRLOCALLY; 145 | 146 | @@ -29812,6 +29831,8 @@ 147 | ast_set2_flag(&global_flags[2], ast_true(v->value), SIP_PAGE3_SNOM_AOC); 148 | } else if (!strcasecmp(v->name, "parkinglot")) { 149 | ast_copy_string(default_parkinglot, v->value, sizeof(default_parkinglot)); 150 | + } else if (!strcasecmp(v->name, "digestalgorithm")) { 151 | + ast_copy_string(default_digestalgorithm, v->value, sizeof(default_digestalgorithm)); 152 | } 153 | } 154 | 155 | -------------------------------------------------------------------------------- /direct-integration-patches/10.9.0/v2_regs_working_issues_remain.patch: -------------------------------------------------------------------------------- 1 | Index: include/asterisk/utils.h 2 | =================================================================== 3 | --- include/asterisk/utils.h (revision 424158) 4 | +++ include/asterisk/utils.h (working copy) 5 | @@ -219,6 +219,8 @@ 6 | void ast_md5_hash(char *output, const char *input); 7 | /*! \brief Produces SHA1 hash based on input string */ 8 | void ast_sha1_hash(char *output, const char *input); 9 | +/*! \brief Produces SRES based on input Ki and RAND */ 10 | +void ast_comp128v1_hash(char *sres, const char *ki, const char *rand); 11 | 12 | int ast_base64encode_full(char *dst, const unsigned char *src, int srclen, int max, int linebreaks); 13 | 14 | Index: main/utils.c 15 | =================================================================== 16 | --- main/utils.c (revision 424158) 17 | +++ main/utils.c (working copy) 18 | @@ -274,6 +274,49 @@ 19 | ptr += sprintf(ptr, "%2.2x", Message_Digest[x]); 20 | } 21 | 22 | +/*! \brief Produces SRES based on input Ki and RAND */ 23 | +void ast_comp128v1_hash(char *sres, const char *ki, const char *rand) 24 | +{ 25 | + printf("ast_comp128v1_hash() - start\n"); 26 | + printf("ast_comp128v1_hash() - ki : %s\n", ki); 27 | + printf("ast_comp128v1_hash() - rand : %s\n", rand); 28 | + char *ptr; 29 | + char command[160]; 30 | + 31 | + snprintf(command, sizeof(command), "/OpenBTS/comp128 0x%s 0x%s", ki, rand); 32 | + printf("ast_comp128v1_hash() - after sprintf\n"); 33 | + printf("ast_comp128v1_hash() - command: %s\n", command); 34 | + 35 | + FILE* f = popen(command, "r"); 36 | + if (f == NULL) { 37 | + printf("ast_comp128v1_hash() - error: popen failed\n"); 38 | + return; 39 | + } 40 | + char sres2[26]; 41 | + char *str = fgets(sres2, 26, f); 42 | + if (str != NULL && strlen(str) == 25) str[24] = 0; 43 | + if (str == NULL || strlen(str) != 24) { 44 | + printf("ast_comp128v1_hash() - error: popen result failed\n"); 45 | + return; 46 | + } 47 | + int st = pclose(f); 48 | + if (st == -1) { 49 | + printf("ast_comp128v1_hash() - error: pclose failed\n"); 50 | + return; 51 | + } 52 | + // first 8 chars are SRES; rest are Kc 53 | +// *kc = sres2+8; 54 | + sres2[8] = 0; 55 | + 56 | + ptr = sres; 57 | + printf("ast_comp128v1_hash() - after ptr assign\n"); 58 | + sprintf(ptr, "%s", sres2); 59 | + printf("ast_comp128v1_hash() - after ptr copy from sres2, ptr : %s\n", ptr); 60 | + for ( ; *ptr; ++ptr) *ptr = tolower(*ptr); 61 | + printf("ast_comp128v1_hash() - after ptr tolower() : %s\n", ptr); 62 | + printf("ast_comp128v1_hash() - exit\n"); 63 | +} 64 | + 65 | /*! \brief decode BASE64 encoded text */ 66 | int ast_base64decode(unsigned char *dst, const char *src, int max) 67 | { 68 | Index: channels/sip/include/sip.h 69 | =================================================================== 70 | --- channels/sip/include/sip.h (revision 424158) 71 | +++ channels/sip/include/sip.h (working copy) 72 | @@ -224,6 +224,7 @@ 73 | #define DEFAULT_SDPOWNER "root" /*!< Default SDP username field in (o=) header unless re-defined in sip.conf */ 74 | #define DEFAULT_ENGINE "asterisk" /*!< Default RTP engine to use for sessions */ 75 | #define DEFAULT_STORE_SIP_CAUSE FALSE /*!< Don't store HASH(SIP_CAUSE,) for channels by default */ 76 | +#define DEFAULT_DIGESTALGORITHM "md5" /*!< Default authentication digest algorithm */ 77 | #endif 78 | /*@}*/ 79 | 80 | @@ -1009,6 +1010,7 @@ 81 | AST_STRING_FIELD(authname); /*!< Who we use for authentication */ 82 | AST_STRING_FIELD(uri); /*!< Original requested URI */ 83 | AST_STRING_FIELD(okcontacturi); /*!< URI from the 200 OK on INVITE */ 84 | + AST_STRING_FIELD(digestalgorithm); /*!< Digest algorithm */ 85 | AST_STRING_FIELD(peersecret); /*!< Password */ 86 | AST_STRING_FIELD(peermd5secret); 87 | AST_STRING_FIELD(cid_num); /*!< Caller*ID number */ 88 | @@ -1222,6 +1224,7 @@ 89 | struct sip_peer { 90 | char name[80]; /*!< the unique name of this object */ 91 | AST_DECLARE_STRING_FIELDS( 92 | + AST_STRING_FIELD(digestalgorithm); /*!< Digest algorithm */ 93 | AST_STRING_FIELD(secret); /*!< Password for inbound auth */ 94 | AST_STRING_FIELD(md5secret); /*!< Password in MD5 */ 95 | AST_STRING_FIELD(description); /*!< Description of this peer */ 96 | @@ -1345,6 +1348,7 @@ 97 | AST_STRING_FIELD(username); /*!< Who we are registering as */ 98 | AST_STRING_FIELD(authuser); /*!< Who we *authenticate* as */ 99 | AST_STRING_FIELD(hostname); /*!< Domain or host we register to */ 100 | + AST_STRING_FIELD(digestalgorithm); /*!< Digest algorithm */ 101 | AST_STRING_FIELD(secret); /*!< Password in clear text */ 102 | AST_STRING_FIELD(md5secret); /*!< Password in md5 */ 103 | AST_STRING_FIELD(callback); /*!< Contact extension */ 104 | Index: channels/chan_sip.c 105 | =================================================================== 106 | --- channels/chan_sip.c (revision 424158) 107 | +++ channels/chan_sip.c (working copy) 108 | @@ -695,6 +695,7 @@ 109 | static struct ast_codec_pref default_prefs; /*!< Default codec prefs */ 110 | static unsigned int default_transports; /*!< Default Transports (enum sip_transport) that are acceptable */ 111 | static unsigned int default_primary_transport; /*!< Default primary Transport (enum sip_transport) for outbound connections to devices */ 112 | +static char default_digestalgorithm[80]; /*!< Digest algorithm */ 113 | /*@}*/ 114 | 115 | static struct sip_settings sip_cfg; /*!< SIP configuration data. 116 | @@ -5389,6 +5390,7 @@ 117 | ast_string_field_set(dialog, peername, peer->name); 118 | ast_string_field_set(dialog, authname, peer->username); 119 | ast_string_field_set(dialog, username, peer->username); 120 | + ast_string_field_set(dialog, digestalgorithm, peer->digestalgorithm); 121 | ast_string_field_set(dialog, peersecret, peer->secret); 122 | ast_string_field_set(dialog, peermd5secret, peer->md5secret); 123 | ast_string_field_set(dialog, mohsuggest, peer->mohsuggest); 124 | @@ -13816,6 +13818,9 @@ 125 | ast_set_flag(&p->flags[0], SIP_OUTGOING); /* Registration is outgoing call */ 126 | r->call = dialog_ref(p, "copying dialog into registry r->call"); /* Save pointer to SIP dialog */ 127 | p->registry = registry_addref(r, "transmit_register: addref to p->registry in transmit_register"); /* Add pointer to registry in packet */ 128 | + if (!ast_strlen_zero(r->digestalgorithm)) { 129 | + ast_string_field_set(p, digestalgorithm, r->digestalgorithm); 130 | + } 131 | if (!ast_strlen_zero(r->secret)) { /* Secret (password) */ 132 | ast_string_field_set(p, peersecret, r->secret); 133 | } 134 | @@ -14838,7 +14843,12 @@ 135 | static void set_nonce_randdata(struct sip_pvt *p, int forceupdate) 136 | { 137 | if (p->stalenonce || forceupdate || ast_strlen_zero(p->randdata)) { 138 | - ast_string_field_build(p, randdata, "%08lx", ast_random()); /* Create nonce for challenge */ 139 | + printf("digestalgorithm : %s", p->digestalgorithm); 140 | + if (!strncasecmp(p->digestalgorithm, "comp128v1", 9)) { 141 | + ast_string_field_build(p, randdata, "%032lx", ast_random()); /* Create nonce for challenge */ 142 | + } else { 143 | + ast_string_field_build(p, randdata, "%08lx", ast_random()); /* Create nonce for challenge */ 144 | + } 145 | p->stalenonce = 0; 146 | } 147 | } 148 | @@ -14979,8 +14989,20 @@ 149 | } else { 150 | char a1[256]; 151 | 152 | - snprintf(a1, sizeof(a1), "%s:%s:%s", username, p->realm, secret); 153 | + if (!strncasecmp(p->digestalgorithm, "comp128v1", 9)) { 154 | + char sres[80]; 155 | + ast_comp128v1_hash(sres, secret, usednonce); 156 | + printf("secret = %s\n", secret); 157 | + printf("nonce = %s\n", usednonce); 158 | + printf("sres = %s\n", sres); 159 | + snprintf(a1, sizeof(a1), "%s:%s:%s", username, p->realm, sres); 160 | + } else { 161 | + snprintf(a1, sizeof(a1), "%s:%s:%s", username, p->realm, secret); 162 | + } 163 | + 164 | ast_md5_hash(a1_hash, a1); 165 | + printf("a1 = %s\n", a1); 166 | + printf("a1_hash = %s\n", a1_hash); 167 | } 168 | 169 | /* compute the expected response to compare with what we received */ 170 | @@ -14994,8 +15016,15 @@ 171 | ast_md5_hash(a2_hash, a2); 172 | snprintf(resp, sizeof(resp), "%s:%s:%s", a1_hash, usednonce, a2_hash); 173 | ast_md5_hash(resp_hash, resp); 174 | + printf("a2 = %s\n", a2); 175 | + printf("a2_hash = %s\n", a2_hash); 176 | + printf("resp = %s\n", resp); 177 | + printf("resp_hash = %s\n", resp_hash); 178 | } 179 | - 180 | + printf("keys[K_RESP].s = %s\n", keys[K_RESP].s); 181 | + printf("keys[K_URI].s = %s\n", keys[K_URI].s); 182 | + printf("keys[K_USER].s = %s\n", keys[K_USER].s); 183 | + printf("keys[K_NONCE].s = %s\n", keys[K_NONCE].s); 184 | good_response = keys[K_RESP].s && 185 | !strncasecmp(keys[K_RESP].s, resp_hash, strlen(resp_hash)); 186 | if (wrongnonce) { 187 | @@ -15382,6 +15411,7 @@ 188 | ast_log(LOG_ERROR, "Peer '%s' is trying to register, but not configured as host=dynamic\n", peer->name); 189 | res = AUTH_PEER_NOT_DYNAMIC; 190 | } else { 191 | + ast_string_field_set(p, digestalgorithm, peer->digestalgorithm); 192 | ast_copy_flags(&p->flags[0], &peer->flags[0], SIP_NAT_FORCE_RPORT); 193 | if (!(res = check_auth(p, req, peer->name, peer->secret, peer->md5secret, SIP_REGISTER, uri2, XMIT_UNRELIABLE, req->ignore))) { 194 | if (sip_cancel_destroy(p)) 195 | @@ -16545,6 +16575,7 @@ 196 | 197 | do_setnat(p); 198 | 199 | + ast_string_field_set(p, digestalgorithm, peer->digestalgorithm); 200 | ast_string_field_set(p, peersecret, peer->secret); 201 | ast_string_field_set(p, peermd5secret, peer->md5secret); 202 | ast_string_field_set(p, subscribecontext, peer->subscribecontext); 203 | @@ -16629,6 +16660,7 @@ 204 | if (!ast_strlen_zero(peer->mwi_from)) { 205 | ast_string_field_set(p, mwi_from, peer->mwi_from); 206 | } 207 | + ast_string_field_set(p, digestalgorithm, peer->digestalgorithm); 208 | ast_string_field_set(p, peersecret, peer->secret); 209 | ast_string_field_set(p, peermd5secret, peer->md5secret); 210 | ast_string_field_set(p, language, peer->language); 211 | @@ -18206,6 +18238,7 @@ 212 | if (realtimepeers) { /* Realtime is enabled */ 213 | ast_cli(fd, " Realtime peer: %s\n", peer->is_realtime ? "Yes, cached" : "No"); 214 | } 215 | + ast_cli(fd, " Digest Algo : %s\n", peer->digestalgorithm); 216 | ast_cli(fd, " Secret : %s\n", ast_strlen_zero(peer->secret)?"":""); 217 | ast_cli(fd, " MD5Secret : %s\n", ast_strlen_zero(peer->md5secret)?"":""); 218 | ast_cli(fd, " Remote Secret: %s\n", ast_strlen_zero(peer->remotesecret)?"":""); 219 | @@ -19347,6 +19380,7 @@ 220 | ast_cli(a->fd, " Theoretical Address: %s\n", ast_sockaddr_stringify(&cur->sa)); 221 | ast_cli(a->fd, " Received Address: %s\n", ast_sockaddr_stringify(&cur->recv)); 222 | ast_cli(a->fd, " SIP Transfer mode: %s\n", transfermode2str(cur->allowtransfer)); 223 | + ast_cli(a->fd, " Digest Algorithm: %s\n", cur->digestalgorithm); 224 | ast_cli(a->fd, " Force rport: %s\n", AST_CLI_YESNO(ast_test_flag(&cur->flags[0], SIP_NAT_FORCE_RPORT))); 225 | if (ast_sockaddr_isnull(&cur->redirip)) { 226 | ast_cli(a->fd, 227 | @@ -28236,6 +28270,7 @@ 228 | if (global_callcounter) 229 | peer->call_limit=INT_MAX; 230 | ast_string_field_set(peer, vmexten, default_vmexten); 231 | + ast_string_field_set(peer, digestalgorithm, default_digestalgorithm); 232 | ast_string_field_set(peer, secret, ""); 233 | ast_string_field_set(peer, description, ""); 234 | ast_string_field_set(peer, remotesecret, ""); 235 | @@ -28773,6 +28808,8 @@ 236 | ast_set2_flag(&peer->flags[2], !strcasecmp(v->value, "32"), SIP_PAGE3_SRTP_TAG_32); 237 | } else if (!strcasecmp(v->name, "snom_aoc_enabled")) { 238 | ast_set2_flag(&peer->flags[2], ast_true(v->value), SIP_PAGE3_SNOM_AOC); 239 | + } else if (!strcasecmp(v->name, "digestalgorithm")) { 240 | + ast_string_field_set(peer, digestalgorithm, v->value); 241 | } 242 | } 243 | 244 | @@ -29309,6 +29346,7 @@ 245 | authlimit = DEFAULT_AUTHLIMIT; 246 | authtimeout = DEFAULT_AUTHTIMEOUT; 247 | global_store_sip_cause = DEFAULT_STORE_SIP_CAUSE; 248 | + ast_copy_string(default_digestalgorithm, DEFAULT_DIGESTALGORITHM, sizeof(default_digestalgorithm)); 249 | 250 | sip_cfg.matchexternaddrlocally = DEFAULT_MATCHEXTERNADDRLOCALLY; 251 | 252 | @@ -29812,6 +29850,8 @@ 253 | ast_set2_flag(&global_flags[2], ast_true(v->value), SIP_PAGE3_SNOM_AOC); 254 | } else if (!strcasecmp(v->name, "parkinglot")) { 255 | ast_copy_string(default_parkinglot, v->value, sizeof(default_parkinglot)); 256 | + } else if (!strcasecmp(v->name, "digestalgorithm")) { 257 | + ast_copy_string(default_digestalgorithm, v->value, sizeof(default_digestalgorithm)); 258 | } 259 | } 260 | 261 | -------------------------------------------------------------------------------- /direct-integration-patches/10.9.0/v3_latest_but_untested_checkpoint.patch: -------------------------------------------------------------------------------- 1 | Index: channels/sip/include/sip.h 2 | =================================================================== 3 | --- channels/sip/include/sip.h (revision 424158) 4 | +++ channels/sip/include/sip.h (working copy) 5 | @@ -224,6 +224,7 @@ 6 | #define DEFAULT_SDPOWNER "root" /*!< Default SDP username field in (o=) header unless re-defined in sip.conf */ 7 | #define DEFAULT_ENGINE "asterisk" /*!< Default RTP engine to use for sessions */ 8 | #define DEFAULT_STORE_SIP_CAUSE FALSE /*!< Don't store HASH(SIP_CAUSE,) for channels by default */ 9 | +#define DEFAULT_DIGESTALGORITHM "md5" /*!< Default authentication digest algorithm */ 10 | #endif 11 | /*@}*/ 12 | 13 | @@ -1009,6 +1010,7 @@ 14 | AST_STRING_FIELD(authname); /*!< Who we use for authentication */ 15 | AST_STRING_FIELD(uri); /*!< Original requested URI */ 16 | AST_STRING_FIELD(okcontacturi); /*!< URI from the 200 OK on INVITE */ 17 | + AST_STRING_FIELD(digestalgorithm); /*!< Digest algorithm */ 18 | AST_STRING_FIELD(peersecret); /*!< Password */ 19 | AST_STRING_FIELD(peermd5secret); 20 | AST_STRING_FIELD(cid_num); /*!< Caller*ID number */ 21 | @@ -1222,6 +1224,7 @@ 22 | struct sip_peer { 23 | char name[80]; /*!< the unique name of this object */ 24 | AST_DECLARE_STRING_FIELDS( 25 | + AST_STRING_FIELD(digestalgorithm); /*!< Digest algorithm */ 26 | AST_STRING_FIELD(secret); /*!< Password for inbound auth */ 27 | AST_STRING_FIELD(md5secret); /*!< Password in MD5 */ 28 | AST_STRING_FIELD(description); /*!< Description of this peer */ 29 | @@ -1345,6 +1348,7 @@ 30 | AST_STRING_FIELD(username); /*!< Who we are registering as */ 31 | AST_STRING_FIELD(authuser); /*!< Who we *authenticate* as */ 32 | AST_STRING_FIELD(hostname); /*!< Domain or host we register to */ 33 | + AST_STRING_FIELD(digestalgorithm); /*!< Digest algorithm */ 34 | AST_STRING_FIELD(secret); /*!< Password in clear text */ 35 | AST_STRING_FIELD(md5secret); /*!< Password in md5 */ 36 | AST_STRING_FIELD(callback); /*!< Contact extension */ 37 | Index: channels/chan_sip.c 38 | =================================================================== 39 | --- channels/chan_sip.c (revision 424158) 40 | +++ channels/chan_sip.c (working copy) 41 | @@ -695,6 +695,7 @@ 42 | static struct ast_codec_pref default_prefs; /*!< Default codec prefs */ 43 | static unsigned int default_transports; /*!< Default Transports (enum sip_transport) that are acceptable */ 44 | static unsigned int default_primary_transport; /*!< Default primary Transport (enum sip_transport) for outbound connections to devices */ 45 | +static char default_digestalgorithm[80]; /*!< Digest algorithm */ 46 | /*@}*/ 47 | 48 | static struct sip_settings sip_cfg; /*!< SIP configuration data. 49 | @@ -5389,6 +5390,7 @@ 50 | ast_string_field_set(dialog, peername, peer->name); 51 | ast_string_field_set(dialog, authname, peer->username); 52 | ast_string_field_set(dialog, username, peer->username); 53 | + ast_string_field_set(dialog, digestalgorithm, peer->digestalgorithm); 54 | ast_string_field_set(dialog, peersecret, peer->secret); 55 | ast_string_field_set(dialog, peermd5secret, peer->md5secret); 56 | ast_string_field_set(dialog, mohsuggest, peer->mohsuggest); 57 | @@ -13816,6 +13818,9 @@ 58 | ast_set_flag(&p->flags[0], SIP_OUTGOING); /* Registration is outgoing call */ 59 | r->call = dialog_ref(p, "copying dialog into registry r->call"); /* Save pointer to SIP dialog */ 60 | p->registry = registry_addref(r, "transmit_register: addref to p->registry in transmit_register"); /* Add pointer to registry in packet */ 61 | + if (!ast_strlen_zero(r->digestalgorithm)) { 62 | + ast_string_field_set(p, digestalgorithm, r->digestalgorithm); 63 | + } 64 | if (!ast_strlen_zero(r->secret)) { /* Secret (password) */ 65 | ast_string_field_set(p, peersecret, r->secret); 66 | } 67 | @@ -14838,7 +14843,12 @@ 68 | static void set_nonce_randdata(struct sip_pvt *p, int forceupdate) 69 | { 70 | if (p->stalenonce || forceupdate || ast_strlen_zero(p->randdata)) { 71 | - ast_string_field_build(p, randdata, "%08lx", ast_random()); /* Create nonce for challenge */ 72 | + printf("digestalgorithm : %s", p->digestalgorithm); 73 | + if (!strncasecmp(p->digestalgorithm, "comp128v1", 9)) { 74 | + ast_string_field_build(p, randdata, "%032lx", ast_random()); /* Create nonce for challenge */ 75 | + } else { 76 | + ast_string_field_build(p, randdata, "%08lx", ast_random()); /* Create nonce for challenge */ 77 | + } 78 | p->stalenonce = 0; 79 | } 80 | } 81 | @@ -14979,8 +14989,20 @@ 82 | } else { 83 | char a1[256]; 84 | 85 | - snprintf(a1, sizeof(a1), "%s:%s:%s", username, p->realm, secret); 86 | + if (!strncasecmp(p->digestalgorithm, "comp128v1", 9)) { 87 | + char sres[80]; 88 | + ast_comp128v1_hash(sres, secret, usednonce); 89 | + printf("secret = %s\n", secret); 90 | + printf("nonce = %s\n", usednonce); 91 | + printf("sres = %s\n", sres); 92 | + snprintf(a1, sizeof(a1), "%s:%s:%s", username, p->realm, sres); 93 | + } else { 94 | + snprintf(a1, sizeof(a1), "%s:%s:%s", username, p->realm, secret); 95 | + } 96 | + 97 | ast_md5_hash(a1_hash, a1); 98 | + printf("a1 = %s\n", a1); 99 | + printf("a1_hash = %s\n", a1_hash); 100 | } 101 | 102 | /* compute the expected response to compare with what we received */ 103 | @@ -14994,8 +15016,15 @@ 104 | ast_md5_hash(a2_hash, a2); 105 | snprintf(resp, sizeof(resp), "%s:%s:%s", a1_hash, usednonce, a2_hash); 106 | ast_md5_hash(resp_hash, resp); 107 | + printf("a2 = %s\n", a2); 108 | + printf("a2_hash = %s\n", a2_hash); 109 | + printf("resp = %s\n", resp); 110 | + printf("resp_hash = %s\n", resp_hash); 111 | } 112 | - 113 | + printf("keys[K_RESP].s = %s\n", keys[K_RESP].s); 114 | + printf("keys[K_URI].s = %s\n", keys[K_URI].s); 115 | + printf("keys[K_USER].s = %s\n", keys[K_USER].s); 116 | + printf("keys[K_NONCE].s = %s\n", keys[K_NONCE].s); 117 | good_response = keys[K_RESP].s && 118 | !strncasecmp(keys[K_RESP].s, resp_hash, strlen(resp_hash)); 119 | if (wrongnonce) { 120 | @@ -15382,6 +15411,7 @@ 121 | ast_log(LOG_ERROR, "Peer '%s' is trying to register, but not configured as host=dynamic\n", peer->name); 122 | res = AUTH_PEER_NOT_DYNAMIC; 123 | } else { 124 | + ast_string_field_set(p, digestalgorithm, peer->digestalgorithm); 125 | ast_copy_flags(&p->flags[0], &peer->flags[0], SIP_NAT_FORCE_RPORT); 126 | if (!(res = check_auth(p, req, peer->name, peer->secret, peer->md5secret, SIP_REGISTER, uri2, XMIT_UNRELIABLE, req->ignore))) { 127 | if (sip_cancel_destroy(p)) 128 | @@ -16545,6 +16575,7 @@ 129 | 130 | do_setnat(p); 131 | 132 | + ast_string_field_set(p, digestalgorithm, peer->digestalgorithm); 133 | ast_string_field_set(p, peersecret, peer->secret); 134 | ast_string_field_set(p, peermd5secret, peer->md5secret); 135 | ast_string_field_set(p, subscribecontext, peer->subscribecontext); 136 | @@ -16629,6 +16660,7 @@ 137 | if (!ast_strlen_zero(peer->mwi_from)) { 138 | ast_string_field_set(p, mwi_from, peer->mwi_from); 139 | } 140 | + ast_string_field_set(p, digestalgorithm, peer->digestalgorithm); 141 | ast_string_field_set(p, peersecret, peer->secret); 142 | ast_string_field_set(p, peermd5secret, peer->md5secret); 143 | ast_string_field_set(p, language, peer->language); 144 | @@ -18206,6 +18238,7 @@ 145 | if (realtimepeers) { /* Realtime is enabled */ 146 | ast_cli(fd, " Realtime peer: %s\n", peer->is_realtime ? "Yes, cached" : "No"); 147 | } 148 | + ast_cli(fd, " Digest Algo : %s\n", peer->digestalgorithm); 149 | ast_cli(fd, " Secret : %s\n", ast_strlen_zero(peer->secret)?"":""); 150 | ast_cli(fd, " MD5Secret : %s\n", ast_strlen_zero(peer->md5secret)?"":""); 151 | ast_cli(fd, " Remote Secret: %s\n", ast_strlen_zero(peer->remotesecret)?"":""); 152 | @@ -19347,6 +19380,7 @@ 153 | ast_cli(a->fd, " Theoretical Address: %s\n", ast_sockaddr_stringify(&cur->sa)); 154 | ast_cli(a->fd, " Received Address: %s\n", ast_sockaddr_stringify(&cur->recv)); 155 | ast_cli(a->fd, " SIP Transfer mode: %s\n", transfermode2str(cur->allowtransfer)); 156 | + ast_cli(a->fd, " Digest Algorithm: %s\n", cur->digestalgorithm); 157 | ast_cli(a->fd, " Force rport: %s\n", AST_CLI_YESNO(ast_test_flag(&cur->flags[0], SIP_NAT_FORCE_RPORT))); 158 | if (ast_sockaddr_isnull(&cur->redirip)) { 159 | ast_cli(a->fd, 160 | @@ -28236,6 +28270,7 @@ 161 | if (global_callcounter) 162 | peer->call_limit=INT_MAX; 163 | ast_string_field_set(peer, vmexten, default_vmexten); 164 | + ast_string_field_set(peer, digestalgorithm, default_digestalgorithm); 165 | ast_string_field_set(peer, secret, ""); 166 | ast_string_field_set(peer, description, ""); 167 | ast_string_field_set(peer, remotesecret, ""); 168 | @@ -28773,6 +28808,8 @@ 169 | ast_set2_flag(&peer->flags[2], !strcasecmp(v->value, "32"), SIP_PAGE3_SRTP_TAG_32); 170 | } else if (!strcasecmp(v->name, "snom_aoc_enabled")) { 171 | ast_set2_flag(&peer->flags[2], ast_true(v->value), SIP_PAGE3_SNOM_AOC); 172 | + } else if (!strcasecmp(v->name, "digestalgorithm")) { 173 | + ast_string_field_set(peer, digestalgorithm, v->value); 174 | } 175 | } 176 | 177 | @@ -29309,6 +29346,7 @@ 178 | authlimit = DEFAULT_AUTHLIMIT; 179 | authtimeout = DEFAULT_AUTHTIMEOUT; 180 | global_store_sip_cause = DEFAULT_STORE_SIP_CAUSE; 181 | + ast_copy_string(default_digestalgorithm, DEFAULT_DIGESTALGORITHM, sizeof(default_digestalgorithm)); 182 | 183 | sip_cfg.matchexternaddrlocally = DEFAULT_MATCHEXTERNADDRLOCALLY; 184 | 185 | @@ -29812,6 +29850,8 @@ 186 | ast_set2_flag(&global_flags[2], ast_true(v->value), SIP_PAGE3_SNOM_AOC); 187 | } else if (!strcasecmp(v->name, "parkinglot")) { 188 | ast_copy_string(default_parkinglot, v->value, sizeof(default_parkinglot)); 189 | + } else if (!strcasecmp(v->name, "digestalgorithm")) { 190 | + ast_copy_string(default_digestalgorithm, v->value, sizeof(default_digestalgorithm)); 191 | } 192 | } 193 | 194 | Index: main/utils.c 195 | =================================================================== 196 | --- main/utils.c (revision 424158) 197 | +++ main/utils.c (working copy) 198 | @@ -274,6 +274,49 @@ 199 | ptr += sprintf(ptr, "%2.2x", Message_Digest[x]); 200 | } 201 | 202 | +/*! \brief Produces SRES based on input Ki and RAND */ 203 | +void ast_comp128v1_hash(char *sres, const char *ki, const char *rand) 204 | +{ 205 | + printf("ast_comp128v1_hash() - start\n"); 206 | + printf("ast_comp128v1_hash() - ki : %s\n", ki); 207 | + printf("ast_comp128v1_hash() - rand : %s\n", rand); 208 | + char *ptr; 209 | + char command[160]; 210 | + 211 | + snprintf(command, sizeof(command), "/OpenBTS/comp128 0x%s 0x%s", ki, rand); 212 | + printf("ast_comp128v1_hash() - after sprintf\n"); 213 | + printf("ast_comp128v1_hash() - command: %s\n", command); 214 | + 215 | + FILE* f = popen(command, "r"); 216 | + if (f == NULL) { 217 | + printf("ast_comp128v1_hash() - error: popen failed\n"); 218 | + return; 219 | + } 220 | + char sres2[26]; 221 | + char *str = fgets(sres2, 26, f); 222 | + if (str != NULL && strlen(str) == 25) str[24] = 0; 223 | + if (str == NULL || strlen(str) != 24) { 224 | + printf("ast_comp128v1_hash() - error: popen result failed\n"); 225 | + return; 226 | + } 227 | + int st = pclose(f); 228 | + if (st == -1) { 229 | + printf("ast_comp128v1_hash() - error: pclose failed\n"); 230 | + return; 231 | + } 232 | + // first 8 chars are SRES; rest are Kc 233 | +// *kc = sres2+8; 234 | + sres2[8] = 0; 235 | + 236 | + ptr = sres; 237 | + printf("ast_comp128v1_hash() - after ptr assign\n"); 238 | + sprintf(ptr, "%s", sres2); 239 | + printf("ast_comp128v1_hash() - after ptr copy from sres2, ptr : %s\n", ptr); 240 | + for ( ; *ptr; ++ptr) *ptr = tolower(*ptr); 241 | + printf("ast_comp128v1_hash() - after ptr tolower() : %s\n", ptr); 242 | + printf("ast_comp128v1_hash() - exit\n"); 243 | +} 244 | + 245 | /*! \brief decode BASE64 encoded text */ 246 | int ast_base64decode(unsigned char *dst, const char *src, int max) 247 | { 248 | Index: include/asterisk/utils.h 249 | =================================================================== 250 | --- include/asterisk/utils.h (revision 424158) 251 | +++ include/asterisk/utils.h (working copy) 252 | @@ -219,6 +219,8 @@ 253 | void ast_md5_hash(char *output, const char *input); 254 | /*! \brief Produces SHA1 hash based on input string */ 255 | void ast_sha1_hash(char *output, const char *input); 256 | +/*! \brief Produces SRES based on input Ki and RAND */ 257 | +void ast_comp128v1_hash(char *sres, const char *ki, const char *rand); 258 | 259 | int ast_base64encode_full(char *dst, const unsigned char *src, int srclen, int max, int linebreaks); 260 | 261 | -------------------------------------------------------------------------------- /direct-integration-patches/README.md: -------------------------------------------------------------------------------- 1 | These patches are in progress. Their purpose is to allow Asterisk to directly process OpenBTS' REGISTER traffic instead of relying on SIPAuthServe. 2 | -------------------------------------------------------------------------------- /fix_pjproject_dependency.patch: -------------------------------------------------------------------------------- 1 | --- res/res_rtp_asterisk.c.orig 2014-12-08 15:53:43.032358579 +0100 2 | +++ res/res_rtp_asterisk.c 2014-12-08 15:54:15.524358525 +0100 3 | @@ -47,6 +47,7 @@ 4 | #include 5 | #endif 6 | 7 | +#undef USE_PJPROJECT 8 | #ifdef USE_PJPROJECT 9 | /* Asterisk discourages the use of bzero in favor of memset, in fact if you try to use bzero it will tell you to use memset. As a result bzero has to be undefined 10 | * here since it is used internally by pjlib. The only other option would be to modify pjlib... which won't happen. */ 11 | --------------------------------------------------------------------------------