mirror of https://github.com/hak5/openwrt-owl.git
parent
e3f2355a12
commit
a8780cfe23
|
@ -95,7 +95,16 @@ config BR2_PACKAGE_ASTERISK_PGSQL
|
|||
select BR2_PACKAGE_LIBPQ
|
||||
help
|
||||
PostgreSQL modules for Asterisk
|
||||
|
||||
|
||||
config BR2_PACKAGE_ASTERISK_SQLITE
|
||||
prompt "asterisk-sqlite................. SQLite modules"
|
||||
tristate
|
||||
default m if CONFIG_DEVEL
|
||||
depends BR2_PACKAGE_ASTERISK
|
||||
select BR2_PACKAGE_LIBSQLITE
|
||||
help
|
||||
SQLite modules for Asterisk
|
||||
|
||||
config BR2_PACKAGE_ASTERISK_SOUNDS
|
||||
prompt "asterisk-sounds................. Sound files"
|
||||
tristate
|
||||
|
@ -111,7 +120,7 @@ config BR2_PACKAGE_ASTERISK_VOICEMAIL
|
|||
depends BR2_PACKAGE_ASTERISK
|
||||
help
|
||||
Voicemail related modules for Asterisk
|
||||
|
||||
|
||||
config BR2_PACKAGE_ASTERISK_MINI
|
||||
prompt "asterisk-mini..................... Minimal open source PBX"
|
||||
tristate
|
||||
|
@ -137,6 +146,5 @@ config BR2_PACKAGE_ASTERISK_MINI
|
|||
- pbx_config
|
||||
- res_features
|
||||
- res_musiconhold
|
||||
|
||||
|
||||
endmenu
|
||||
|
|
|
@ -3,9 +3,9 @@
|
|||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=asterisk
|
||||
PKG_VERSION:=1.0.10
|
||||
PKG_VERSION:=1.2.1
|
||||
PKG_RELEASE:=1
|
||||
PKG_MD5SUM:=f60f4c4edc36fa61dc55a5385fd82e71
|
||||
PKG_MD5SUM:=04657086791e80f319c0d728af705001
|
||||
|
||||
PKG_SOURCE_URL:=http://ftp.digium.com/pub/asterisk/ ftp://ftp.digium.com/pub/asterisk/
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
||||
|
@ -19,6 +19,7 @@ $(eval $(call PKG_template,ASTERISK,asterisk,$(PKG_VERSION)-$(PKG_RELEASE),$(ARC
|
|||
$(eval $(call PKG_template,ASTERISK_MINI,asterisk-mini,$(PKG_VERSION)-$(PKG_RELEASE),$(ARCH)))
|
||||
$(eval $(call PKG_template,ASTERISK_MYSQL,asterisk-mysql,$(PKG_VERSION)-$(PKG_RELEASE),$(ARCH)))
|
||||
$(eval $(call PKG_template,ASTERISK_PGSQL,asterisk-pgsql,$(PKG_VERSION)-$(PKG_RELEASE),$(ARCH)))
|
||||
$(eval $(call PKG_template,ASTERISK_SQLITE,asterisk-sqlite,$(PKG_VERSION)-$(PKG_RELEASE),$(ARCH)))
|
||||
$(eval $(call PKG_template,ASTERISK_VOICEMAIL,asterisk-voicemail,$(PKG_VERSION)-$(PKG_RELEASE),$(ARCH)))
|
||||
$(eval $(call PKG_template,ASTERISK_SOUNDS,asterisk-sounds,$(PKG_VERSION)-$(PKG_RELEASE),$(ARCH)))
|
||||
$(eval $(call PKG_template,ASTERISK_CHAN_BLUETOOTH,asterisk-chan-bluetooth,$(PKG_VERSION)-$(PKG_RELEASE),$(ARCH)))
|
||||
|
@ -30,47 +31,53 @@ $(eval $(call PKG_template,ASTERISK_CODEC_SPEEX,asterisk-codec-speex,$(PKG_VERSI
|
|||
$(eval $(call PKG_template,ASTERISK_PBX_DUNDI,asterisk-pbx-dundi,$(PKG_VERSION)-$(PKG_RELEASE),$(ARCH)))
|
||||
$(eval $(call PKG_template,ASTERISK_RES_AGI,asterisk-res-agi,$(PKG_VERSION)-$(PKG_RELEASE),$(ARCH)))
|
||||
|
||||
ifneq ($(DEVELOPER),)
|
||||
APPS:=app_sql_mysql.so app_sql_postgres.so
|
||||
MODS:=cdr_mysql.so cdr_pgsql.so
|
||||
SPEEX:=codec_speex.so
|
||||
else
|
||||
APPS:=
|
||||
MODS:=
|
||||
EXTRA_CFLAGS := -I$(STAGING_DIR)/usr/include -I$(STAGING_DIR)/include
|
||||
EXTRA_LDFLAGS := -L$(STAGING_DIR)/usr/lib -L$(STAGING_DIR)/lib
|
||||
|
||||
ifneq ($(BR2_PACKAGE_ASTERISK_MYSQL),)
|
||||
APPS += app_sql_mysql.so
|
||||
MODS += cdr_mysql.so
|
||||
EXTRA_CFLAGS += -I$(STAGING_DIR)/usr/include/mysql
|
||||
EXTRA_LDFLAGS += -L$(STAGING_DIR)/usr/lib/mysql
|
||||
EXTRA_APP_MODULES += app_sql_mysql.so
|
||||
EXTRA_CDR_MODULES += cdr_mysql.so
|
||||
EXTRA_RES_MODULES += res_config_mysql.so
|
||||
endif
|
||||
ifneq ($(BR2_PACKAGE_ASTERISK_PGSQL),)
|
||||
APPS += app_sql_postgres.so
|
||||
MODS += cdr_pgsql.so
|
||||
EXTRA_APP_MODULES += app_sql_postgres.so
|
||||
EXTRA_CDR_MODULES += cdr_pgsql.so
|
||||
endif
|
||||
ifneq ($(BR2_PACKAGE_ASTERISK_SQLITE),)
|
||||
EXTRA_CDR_MODULES += cdr_sqlite.so
|
||||
endif
|
||||
ifneq ($(BR2_PACKAGE_ASTERISK_CODEC_SPEEX),)
|
||||
SPEEX:=codec_speex.so
|
||||
endif
|
||||
EXTRA_CFLAGS += -I$(STAGING_DIR)/usr/include/speex
|
||||
EXTRA_CODEC_MODULES += codec_speex.so
|
||||
endif
|
||||
|
||||
$(PKG_BUILD_DIR)/.configured:
|
||||
touch $@
|
||||
|
||||
$(PKG_BUILD_DIR)/.built:
|
||||
$(MAKE) -C "$(PKG_BUILD_DIR)/channels" \
|
||||
CC="$(HOSTCC)" \
|
||||
gentone
|
||||
$(MAKE) -C "$(PKG_BUILD_DIR)" \
|
||||
CC_FOR_BUILD="$(HOSTCC)" \
|
||||
CROSS_ARCH="Linux" \
|
||||
CROSS_COMPILE="$(TARGET_CROSS)" \
|
||||
CROSS_COMPILE_BIN="/void/" \
|
||||
CROSS_COMPILE_TARGET="/void/" \
|
||||
$(TARGET_CONFIGURE_OPTS) \
|
||||
HOST_CC="$(HOSTCC)" \
|
||||
OPTIMIZE="$(TARGET_CFLAGS)" \
|
||||
PROC="$(ARCH)" \
|
||||
CFLAGS_EXTRA="-I$(STAGING_DIR)/usr/include -I$(STAGING_DIR)/usr/include/speex" \
|
||||
LDFLAGS_EXTRA="-L$(STAGING_DIR)/usr/lib -L$(STAGING_DIR)/usr/lib/mysql" \
|
||||
CRYPTO_LIBS="-L$(STAGING_DIR)/usr/lib -Wl,-Bstatic -lssl -lcrypto -Wl,-Bdynamic" \
|
||||
EXTRA_APPS="$(APPS)" \
|
||||
EXTRA_MODS="$(MODS)" \
|
||||
MODSPEEX="$(SPEEX)"
|
||||
$(MAKE) -C $(PKG_BUILD_DIR) \
|
||||
DEBUG="" \
|
||||
OPTIONS="-DLOW_MEMORY -Dlinux" \
|
||||
NOCRYPTO="yes" \
|
||||
EXTRA_CFLAGS="$(EXTRA_CFLAGS)" \
|
||||
EXTRA_LDFLAGS="$(EXTRA_LDFLAGS)" \
|
||||
EXTRA_APP_MODULES="$(EXTRA_APP_MODULES)" \
|
||||
EXTRA_CDR_MODULES="$(EXTRA_CDR_MODULES)" \
|
||||
EXTRA_CODEC_MODULES="$(EXTRA_CODEC_MODULES)" \
|
||||
EXTRA_RES_MODULES="$(EXTRA_RES_MODULES)" \
|
||||
DESTDIR="$(PKG_INSTALL_DIR)" \
|
||||
install samples
|
||||
ASTVARLIBDIR="/usr/lib/asterisk" \
|
||||
all install samples
|
||||
rm -f $(PKG_INSTALL_DIR)/etc/asterisk/*.old
|
||||
touch $@
|
||||
|
||||
|
@ -164,6 +171,12 @@ $(IPKG_ASTERISK_PGSQL):
|
|||
$(RSTRIP) $(IDIR_ASTERISK_PGSQL)
|
||||
$(IPKG_BUILD) $(IDIR_ASTERISK_PGSQL) $(PACKAGE_DIR)
|
||||
|
||||
$(IPKG_ASTERISK_SQLITE):
|
||||
install -d -m0755 $(IDIR_ASTERISK_SQLITE)/usr/lib/asterisk/modules
|
||||
install -m0755 $(PKG_BUILD_DIR)/cdr/cdr_sqlite.so $(IDIR_ASTERISK_SQLITE)/usr/lib/asterisk/modules/
|
||||
$(RSTRIP) $(IDIR_ASTERISK_SQLITE)
|
||||
$(IPKG_BUILD) $(IDIR_ASTERISK_SQLITE) $(PACKAGE_DIR)
|
||||
|
||||
$(IPKG_ASTERISK_SOUNDS):
|
||||
install -d -m0755 $(IDIR_ASTERISK_SOUNDS)/usr/lib/asterisk/sounds
|
||||
cp -fpR $(PKG_BUILD_DIR)/sounds/* $(IDIR_ASTERISK_SOUNDS)/usr/lib/asterisk/sounds/
|
||||
|
|
|
@ -7,12 +7,29 @@
|
|||
[modules]
|
||||
autoload=yes
|
||||
;
|
||||
; Any modules that need to be loaded before the Asterisk core has been
|
||||
; initialized (just after the logger has been initialized) can be loaded
|
||||
; using 'preload'. This will frequently be needed if you wish to map all
|
||||
; module configuration files into Realtime storage, since the Realtime
|
||||
; driver will need to be loaded before the modules using those configuration
|
||||
; files are initialized.
|
||||
;
|
||||
; An example of loading ODBC support would be:
|
||||
;preload => res_odbc.so
|
||||
;preload => res_config_odbc.so
|
||||
;
|
||||
noload => res_config_mysql.so ;
|
||||
;
|
||||
; load => res_features.so ; Call Parking Resource
|
||||
noload => res_indications.so ; Indications Configuration
|
||||
noload => res_monitor.so ; Call Monitoring Resource
|
||||
; load => res_musiconhold.so ; Music On Hold Resource
|
||||
noload => cdr_csv.so ; Comma Separated Values CDR Backend
|
||||
noload => cdr_custom.so ; Customizable Comma Separated Values CDR Backend
|
||||
noload => cdr_manager.so ; Asterisk Call Manager CDR Backend
|
||||
noload => cdr_mysql.so ; MySQL CDR Backend
|
||||
noload => cdr_pgsql.so ; PostgreSQL CDR Backend
|
||||
noload => cdr_sqlite.so ; SQLite CDR Backend
|
||||
noload => chan_agent.so ; Agent Proxy Channel
|
||||
; load => chan_iax2.so ; Inter Asterisk eXchange (Ver 2)
|
||||
; load => chan_local.so ; Local Proxy Channel
|
||||
|
@ -21,8 +38,11 @@ noload => codec_a_mu.so ; A-law and Mulaw direct Coder/Decoder
|
|||
noload => codec_adpcm.so ; Adaptive Differential PCM Coder/Decoder
|
||||
noload => codec_alaw.so ; A-law Coder/Decoder
|
||||
noload => codec_g726.so ; ITU G.726-32kbps G726 Transcoder
|
||||
; load => codec_gsm.so ; GSM/PCM16 (signed linear) Codec Translat
|
||||
; load => codec_gsm.so ; GSM/PCM16 (signed linear) Codec Translation
|
||||
; load => codec_ulaw.so ; Mu-law Coder/Decoder
|
||||
noload => codec_speex.so ; Speex/PCM16 (signed linear) Codec Translator
|
||||
noload => format_au.so ; Sun Microsystems AU format (signed linear)
|
||||
noload => format_g723.so ; G.723.1 Simple Timestamp File Format
|
||||
noload => format_g726.so ; Raw G.726 (16/24/32/40kbps) data
|
||||
noload => format_g729.so ; Raw G729 data
|
||||
; load => format_gsm.so ; Raw GSM data
|
||||
|
@ -34,21 +54,26 @@ noload => format_sln.so ; Raw Signed Linear Audio support (SLN)
|
|||
noload => format_vox.so ; Dialogic VOX (ADPCM) File Format
|
||||
; load => format_wav.so ; Microsoft WAV format (8000hz Signed Line
|
||||
; load => format_wav_gsm.so ; Microsoft WAV format (Proprietary GSM)
|
||||
noload => app_alarmreceiver.so ; Alarm Receiver for Asterisk
|
||||
noload => app_alarmreceiver.so ; Alarm Receiver Application
|
||||
noload => app_authenticate.so ; Authentication Application
|
||||
noload => app_cdr.so ; Make sure asterisk doesn't save CDR for
|
||||
noload => app_cdr.so ; Make sure asterisk doesn't save CDR
|
||||
noload => app_chanisavail.so ; Check if channel is available
|
||||
noload => app_chanspy.so ; Listen in on any channel
|
||||
noload => app_controlplayback.so ; Control Playback Application
|
||||
noload => app_cut.so ; Cuts up variables
|
||||
noload => app_db.so ; Database access functions for Asterisk e
|
||||
noload => app_db.so ; Database access functions
|
||||
; load => app_dial.so ; Dialing Application
|
||||
noload => app_dictate.so ; Virtual Dictation Machine Application
|
||||
noload => app_directory.so ; Extension Directory
|
||||
noload => app_disa.so ; DISA (Direct Inward System Access) Appli
|
||||
noload => app_directed_pickup.so ; Directed Call Pickup Support
|
||||
noload => app_disa.so ; DISA (Direct Inward System Access) Application
|
||||
noload => app_dumpchan.so ; Dump channel variables Application
|
||||
; load => app_echo.so ; Simple Echo Application
|
||||
noload => app_enumlookup.so ; ENUM Lookup
|
||||
noload => app_eval.so ; Reevaluates strings
|
||||
noload => app_exec.so ; Executes applications
|
||||
noload => app_forkcdr.so ; Fork The CDR into 2 seperate entities.
|
||||
noload => app_externalivr.so ; External IVR application interface
|
||||
noload => app_forkcdr.so ; Fork The CDR into 2 seperate entities
|
||||
noload => app_getcpeid.so ; Get ADSI CPE ID
|
||||
noload => app_groupcount.so ; Group Management Routines
|
||||
noload => app_ices.so ; Encode and Stream via icecast and ices
|
||||
|
@ -56,14 +81,18 @@ noload => app_image.so ; Image Transmission Application
|
|||
noload => app_lookupblacklist.so ; Look up Caller*ID name/number from black
|
||||
noload => app_lookupcidname.so ; Look up CallerID Name from local databas
|
||||
; load => app_macro.so ; Extension Macros
|
||||
; load => app_milliwatt.so ; Digital Milliwatt (mu-law) Test Applicat
|
||||
noload => app_math.so ; A simple math Application
|
||||
noload => app_md5.so ; MD5 checksum Application
|
||||
; load => app_milliwatt.so ; Digital Milliwatt (mu-law) Test Application
|
||||
noload => app_mixmonitor.so ; Record a call and mix the audio during the recording
|
||||
noload => app_parkandannounce.so ; Call Parking and Announce Application
|
||||
; load => app_playback.so ; Trivial Playback Application
|
||||
noload => app_privacy.so ; Require phone number to be entered, if n
|
||||
noload => app_qcall.so ; Call from Queue
|
||||
noload => app_queue.so ; True Call Queueing
|
||||
noload => app_random.so ; Random goto
|
||||
noload => app_read.so ; Read Variable Application
|
||||
noload => app_readfile.so ; Read in a file
|
||||
noload => app_realtime.so ; Realtime Data Lookup/Rewrite
|
||||
noload => app_record.so ; Trivial Record Application
|
||||
; load => app_sayunixtime.so ; Say time
|
||||
noload => app_senddtmf.so ; Send DTMF digits Application
|
||||
|
@ -72,10 +101,13 @@ noload => app_setcallerid.so ; Set CallerID Application
|
|||
noload => app_setcdruserfield.so ; CDR user field apps
|
||||
noload => app_setcidname.so ; Set CallerID Name
|
||||
noload => app_setcidnum.so ; Set CallerID Number
|
||||
noload => app_setrndis.so ; Set RDNIS Number
|
||||
noload => app_settransfercapability.so ; Set ISDN Transfer Capability
|
||||
noload => app_sms.so ; SMS/PSTN handler
|
||||
noload => app_softhangup.so ; Hangs up the requested channel
|
||||
noload => app_striplsd.so ; Strip trailing digits
|
||||
noload => app_substring.so ; (Deprecated) Save substring digits in a
|
||||
noload => app_sql_mysql.so ; Simple MySQL Interface
|
||||
noload => app_sql_postgres.so ; Simple PostgreSQL Interface
|
||||
noload => app_stack.so ; Stack Routines
|
||||
noload => app_system.so ; Generic System() application
|
||||
noload => app_talkdetect.so ; Playback with Talk Detection
|
||||
noload => app_test.so ; Interface Test Application
|
||||
|
@ -85,9 +117,18 @@ noload => app_url.so ; Send URL Applications
|
|||
noload => app_userevent.so ; Custom User Event Application
|
||||
; load => app_verbose.so ; Send verbose output
|
||||
noload => app_waitforring.so ; Waits until first ring after time
|
||||
noload => app_waitforsilence.so ; Wait For Silence Application
|
||||
noload => app_while.so ; While Loops and Conditional Execution
|
||||
noload => pbx_ael.so ; Asterisk Extension Language Compiler
|
||||
; load => pbx_config.so ; Text Extension Configuration
|
||||
noload => pbx_functions.so ; Builtin dialplan functions
|
||||
noload => pbx_loopback.so ; Loopback Switch
|
||||
noload => pbx_realtime.so ; Realtime Switch
|
||||
noload => pbx_spool.so ; Outgoing Spool Support
|
||||
noload => pbx_wilcalu.so ; Wil Cal U (Auto Dialer)
|
||||
noload => func_callerid.so ; Caller ID related dialplan functions
|
||||
noload => func_enum.so ; ENUM Functions
|
||||
noload => func_uri.so ; URI encoding / decoding functions
|
||||
|
||||
;
|
||||
; Module names listed in "global" section will have symbols globally
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
Package: asterisk-sqlite
|
||||
Priority: optional
|
||||
Section: net
|
||||
Description: SQLite modules for Asterisk
|
||||
Depends: asterisk, libsqlite2
|
|
@ -2,6 +2,7 @@
|
|||
/etc/asterisk/agents.conf
|
||||
/etc/asterisk/alarmreceiver.conf
|
||||
/etc/asterisk/cdr_manager.conf
|
||||
/etc/asterisk/codecs.conf
|
||||
/etc/asterisk/enum.conf
|
||||
/etc/asterisk/extconfig.conf
|
||||
/etc/asterisk/extensions.conf
|
||||
|
|
|
@ -1,22 +0,0 @@
|
|||
diff -ruN asterisk-1.0.7-old/apps/Makefile asterisk-1.0.7-new/apps/Makefile
|
||||
--- asterisk-1.0.7-old/apps/Makefile 2004-09-24 23:32:56.000000000 +0200
|
||||
+++ asterisk-1.0.7-new/apps/Makefile 2005-03-19 17:38:06.000000000 +0100
|
||||
@@ -35,13 +35,14 @@
|
||||
APPS+=app_intercom.so
|
||||
endif
|
||||
|
||||
-#APPS+=app_sql_postgres.so
|
||||
+# add extra apps
|
||||
+APPS+=$(EXTRA_APPS)
|
||||
#APPS+=app_sql_odbc.so
|
||||
#APPS+=app_rpt.so
|
||||
|
||||
-APPS+=$(shell if [ -f /usr/include/linux/zaptel.h ]; then echo "app_zapras.so app_meetme.so app_flash.so app_zapbarge.so app_zapscan.so" ; fi)
|
||||
-APPS+=$(shell if [ -f /usr/local/include/zaptel.h ]; then echo "app_zapras.so app_meetme.so app_flash.so app_zapbarge.so app_zapscan.so" ; fi)
|
||||
-APPS+=$(shell if [ -f /usr/include/osp/osp.h ]; then echo "app_osplookup.so" ; fi)
|
||||
+#APPS+=$(shell if [ -f /usr/include/linux/zaptel.h ]; then echo "app_zapras.so app_meetme.so app_flash.so app_zapbarge.so app_zapscan.so" ; fi)
|
||||
+#APPS+=$(shell if [ -f /usr/local/include/zaptel.h ]; then echo "app_zapras.so app_meetme.so app_flash.so app_zapbarge.so app_zapscan.so" ; fi)
|
||||
+#APPS+=$(shell if [ -f /usr/include/osp/osp.h ]; then echo "app_osplookup.so" ; fi)
|
||||
|
||||
CFLAGS+=-fPIC
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
diff -ruN asterisk-1.0.7-old/cdr/Makefile asterisk-1.0.7-new/cdr/Makefile
|
||||
--- asterisk-1.0.7-old/cdr/Makefile 2004-08-31 18:33:00.000000000 +0200
|
||||
+++ asterisk-1.0.7-new/cdr/Makefile 2005-03-19 17:38:06.000000000 +0100
|
||||
@@ -12,7 +12,7 @@
|
||||
#
|
||||
|
||||
#ADD cdr_pgsql.so to MODS= to include PostgreSQL support: REQUIRES PostgreSQL libs
|
||||
-MODS=cdr_csv.so cdr_manager.so
|
||||
+MODS=cdr_csv.so cdr_manager.so $(EXTRA_MODS)
|
||||
|
||||
|
||||
CFLAGS+=-fPIC
|
|
@ -1,33 +0,0 @@
|
|||
diff -ruN asterisk-1.0.7-old/channels/h323/Makefile asterisk-1.0.7-new/channels/h323/Makefile
|
||||
--- asterisk-1.0.7-old/channels/h323/Makefile 2004-11-15 03:35:35.000000000 +0100
|
||||
+++ asterisk-1.0.7-new/channels/h323/Makefile 2005-03-19 17:38:06.000000000 +0100
|
||||
@@ -22,9 +22,11 @@
|
||||
OSARCH=$(shell uname -s)
|
||||
ifneq (${OSARCH},FreeBSD)
|
||||
ifneq (${OSARCH},NetBSD)
|
||||
+ifneq ($(PROC),mipsel)
|
||||
CFLAGS += -march=$(shell uname -m)
|
||||
endif
|
||||
endif
|
||||
+endif
|
||||
CFLAGS += -DPBYTE_ORDER=PLITTLE_ENDIAN
|
||||
|
||||
ifeq (${OSARCH},Linux)
|
||||
@@ -47,7 +49,7 @@
|
||||
|
||||
# Pre Janus release directives
|
||||
CFLAGS += -DNDEBUG -DDO_CRASH -DDEBUG_THREADS
|
||||
-CFLAGS += -pipe -Wall -fPIC
|
||||
+CFLAGS += -pipe -Wall -fPIC $(OPTIMIZE)
|
||||
ifeq (${OSARCH},Linux)
|
||||
CFLAGS += -DP_LINUX
|
||||
LIBS+=-lpthread
|
||||
@@ -74,7 +76,7 @@
|
||||
|
||||
|
||||
libchanh323.a: ast_h323.o
|
||||
- ar cr libchanh323.a ast_h323.o
|
||||
+ $(AR) cr libchanh323.a ast_h323.o
|
||||
|
||||
ast_h323.o: ast_h323.cpp
|
||||
$(CXX) -g -c -fno-rtti -o $@ $(CFLAGS) $<
|
|
@ -1,61 +0,0 @@
|
|||
diff -ruN asterisk-1.0.7-old/channels/Makefile asterisk-1.0.7-new/channels/Makefile
|
||||
--- asterisk-1.0.7-old/channels/Makefile 2004-08-31 18:33:00.000000000 +0200
|
||||
+++ asterisk-1.0.7-new/channels/Makefile 2005-03-19 17:38:06.000000000 +0100
|
||||
@@ -71,25 +71,25 @@
|
||||
CHANNEL_LIBS+=chan_oss.so
|
||||
endif
|
||||
|
||||
-CHANNEL_LIBS+=$(shell [ -f /usr/include/linux/ixjuser.h ] && echo chan_phone.so)
|
||||
-CHANNEL_LIBS+=$(shell [ -f /usr/local/include/ixjuser.h ] && echo chan_phone.so)
|
||||
-CHANNEL_LIBS+=$(shell [ -f h323/libchanh323.a ] && echo chan_h323.so)
|
||||
-
|
||||
-CFLAGS+=-Wno-missing-prototypes -Wno-missing-declarations
|
||||
-CFLAGS+=$(shell [ ! -f /usr/include/linux/if_wanpipe.h ] && echo " -DOLD_SANGOMA_API")
|
||||
-CHANNEL_LIBS+=$(shell [ -f /usr/include/alsa/asoundlib.h ] && echo "chan_alsa.so")
|
||||
-CFLAGS+=$(shell [ -f /usr/lib/libpri.so.1 ] && echo " -DZAPATA_PRI")
|
||||
-CFLAGS+=$(shell [ -f /usr/lib/libmfcr2.so.1 ] && echo " -DZAPATA_R2")
|
||||
-CFLAGS+=$(shell [ -f alsa-monitor.h ] && echo " -DALSA_MONITOR")
|
||||
-ZAPPRI=$(shell [ -f /usr/lib/libpri.so.1 ] && echo "-lpri")
|
||||
-ZAPR2=$(shell [ -f /usr/lib/libmfcr2.so.1 ] && echo "-lmfcr2")
|
||||
-CFLAGS+=$(shell [ -f /usr/include/linux/zaptel.h ] && echo "-DIAX_TRUNKING")
|
||||
-CFLAGS+=$(shell [ -f /usr/local/include/zaptel.h ] && echo "-DIAX_TRUNKING")
|
||||
-CHANNEL_LIBS+=$(shell [ -f /usr/include/vpbapi.h ] && echo "chan_vpb.so" )
|
||||
-CFLAGS+=$(shell [ -f /usr/include/vpbapi.h ] && echo " -DLINUX")
|
||||
+#CHANNEL_LIBS+=$(shell [ -f /usr/include/linux/ixjuser.h ] && echo chan_phone.so)
|
||||
+#CHANNEL_LIBS+=$(shell [ -f /usr/local/include/ixjuser.h ] && echo chan_phone.so)
|
||||
+#CHANNEL_LIBS+=$(shell [ -f h323/libchanh323.a ] && echo chan_h323.so)
|
||||
+
|
||||
+#CFLAGS+=-Wno-missing-prototypes -Wno-missing-declarations
|
||||
+#CFLAGS+=$(shell [ ! -f /usr/include/linux/if_wanpipe.h ] && echo " -DOLD_SANGOMA_API")
|
||||
+#CHANNEL_LIBS+=$(shell [ -f /usr/include/alsa/asoundlib.h ] && echo "chan_alsa.so")
|
||||
+#CFLAGS+=$(shell [ -f /usr/lib/libpri.so.1 ] && echo " -DZAPATA_PRI")
|
||||
+#CFLAGS+=$(shell [ -f /usr/lib/libmfcr2.so.1 ] && echo " -DZAPATA_R2")
|
||||
+#CFLAGS+=$(shell [ -f alsa-monitor.h ] && echo " -DALSA_MONITOR")
|
||||
+#ZAPPRI=$(shell [ -f /usr/lib/libpri.so.1 ] && echo "-lpri")
|
||||
+#ZAPR2=$(shell [ -f /usr/lib/libmfcr2.so.1 ] && echo "-lmfcr2")
|
||||
+#CFLAGS+=$(shell [ -f /usr/include/linux/zaptel.h ] && echo "-DIAX_TRUNKING")
|
||||
+#CFLAGS+=$(shell [ -f /usr/local/include/zaptel.h ] && echo "-DIAX_TRUNKING")
|
||||
+#CHANNEL_LIBS+=$(shell [ -f /usr/include/vpbapi.h ] && echo "chan_vpb.so" )
|
||||
+#CFLAGS+=$(shell [ -f /usr/include/vpbapi.h ] && echo " -DLINUX")
|
||||
|
||||
-ALSA_SRC=chan_alsa.c
|
||||
-ALSA_SRC+=$(shell [ -f alsa-monitor.h ] && echo "alsa-monitor.h")
|
||||
+#ALSA_SRC=chan_alsa.c
|
||||
+#ALSA_SRC+=$(shell [ -f alsa-monitor.h ] && echo "alsa-monitor.h")
|
||||
|
||||
CFLAGS+=-DCRYPTO
|
||||
CFLAGS+=-fPIC
|
||||
@@ -106,10 +106,10 @@
|
||||
|
||||
ZAPDIR=/usr/lib
|
||||
|
||||
-CHANNEL_LIBS+=$(shell [ -f /usr/include/linux/zaptel.h ] && echo "chan_zap.so")
|
||||
-CHANNEL_LIBS+=$(shell [ -f /usr/local/include/zaptel.h ] && echo "chan_zap.so")
|
||||
+#CHANNEL_LIBS+=$(shell [ -f /usr/include/linux/zaptel.h ] && echo "chan_zap.so")
|
||||
+#CHANNEL_LIBS+=$(shell [ -f /usr/local/include/zaptel.h ] && echo "chan_zap.so")
|
||||
|
||||
-CHANNEL_LIBS+=$(shell [ -f /usr/include/nbs.h ] && echo "chan_nbs.so" )
|
||||
+#CHANNEL_LIBS+=$(shell [ -f /usr/include/nbs.h ] && echo "chan_nbs.so" )
|
||||
|
||||
ifndef OPENH323DIR
|
||||
OPENH323DIR=$(HOME)/openh323
|
|
@ -1,21 +0,0 @@
|
|||
diff -ruN asterisk-1.0.7-old/codecs/ilbc/Makefile asterisk-1.0.7-new/codecs/ilbc/Makefile
|
||||
--- asterisk-1.0.7-old/codecs/ilbc/Makefile 2004-08-29 19:40:58.000000000 +0200
|
||||
+++ asterisk-1.0.7-new/codecs/ilbc/Makefile 2005-03-19 17:38:06.000000000 +0100
|
||||
@@ -1,5 +1,5 @@
|
||||
ARCH=$(PROC)
|
||||
-CFLAGS+=-Wall -fPIC -O3 -funroll-loops -fomit-frame-pointer
|
||||
+CFLAGS+=-Wall -fPIC $(OPTIMIZE)
|
||||
LIB=libilbc.a
|
||||
|
||||
OBJS= anaFilter.o iCBSearch.o packing.o \
|
||||
@@ -12,8 +12,8 @@
|
||||
|
||||
|
||||
$(LIB): $(OBJS)
|
||||
- ar cr $(LIB) $(OBJS)
|
||||
- ranlib $(LIB)
|
||||
+ $(AR) cr $(LIB) $(OBJS)
|
||||
+ $(RANLIB) $(LIB)
|
||||
|
||||
clean:
|
||||
rm -f $(LIB) *.o
|
|
@ -1,69 +0,0 @@
|
|||
diff -ruN asterisk-1.0.7-old/codecs/Makefile asterisk-1.0.7-new/codecs/Makefile
|
||||
--- asterisk-1.0.7-old/codecs/Makefile 2005-03-17 15:43:51.000000000 +0100
|
||||
+++ asterisk-1.0.7-new/codecs/Makefile 2005-03-22 23:26:20.000000000 +0100
|
||||
@@ -17,21 +17,21 @@
|
||||
# g723.1b)
|
||||
#
|
||||
#MODG723=codec_g723_1.so codec_g723_1b.so
|
||||
-MODG723=$(shell [ -f g723.1/coder.c ] && echo "codec_g723_1.so")
|
||||
-MODG723+=$(shell [ -f g723.1b/coder2.c ] && echo "codec_g723_1b.so")
|
||||
-MODSPEEX=$(shell [ -f /usr/include/speex.h ] || [ -f /usr/include/speex/speex.h ] || [ -f /usr/local/include/speex.h ] || [ -f /usr/local/include/speex/speex.h ] && echo "codec_speex.so")
|
||||
+#MODG723=$(shell [ -f g723.1/coder.c ] && echo "codec_g723_1.so")
|
||||
+#MODG723+=$(shell [ -f g723.1b/coder2.c ] && echo "codec_g723_1b.so")
|
||||
+#MODSPEEX=$(shell [ -f /usr/include/speex.h ] || [ -f /usr/include/speex/speex.h ] || [ -f /usr/local/include/speex.h ] || [ -f /usr/local/include/speex/speex.h ] && echo "codec_speex.so")
|
||||
MODILBC=$(shell [ -f ilbc/iLBC_decode.h ] && echo "codec_ilbc.so")
|
||||
CFLAGS+=-fPIC
|
||||
-CFLAGS+=$(shell [ -f /usr/local/include/speex.h ] && echo "-I/usr/local/include")
|
||||
-CFLAGS+=$(shell [ -f /usr/local/include/speex/speex.h ] && echo "-I/usr/local/include/speex")
|
||||
-CFLAGS+=$(shell [ -f /usr/include/speex/speex.h ] && echo "-I/usr/include/speex")
|
||||
+#CFLAGS+=$(shell [ -f /usr/local/include/speex.h ] && echo "-I/usr/local/include")
|
||||
+#CFLAGS+=$(shell [ -f /usr/local/include/speex/speex.h ] && echo "-I/usr/local/include/speex")
|
||||
+#CFLAGS+=$(shell [ -f /usr/include/speex/speex.h ] && echo "-I/usr/include/speex")
|
||||
|
||||
LIBG723=g723.1/libg723.a
|
||||
LIBG723B=g723.1b/libg723b.a
|
||||
LIBGSM=gsm/lib/libgsm.a
|
||||
LIBGSMT=gsm/lib/libgsm.a
|
||||
LIBLPC10=lpc10/liblpc10.a
|
||||
-LIBSPEEX=$(shell [ -f /usr/local/lib/libspeex.a ] && echo "-L/usr/local/lib")
|
||||
+LIBSPEEX=$(LDFLAGS_EXTRA)
|
||||
LIBSPEEX+=-lspeex -lm
|
||||
LIBILBC=ilbc/libilbc.a
|
||||
|
||||
@@ -43,26 +43,26 @@
|
||||
|
||||
clean:
|
||||
rm -f *.so *.o .depend
|
||||
- ! [ -d g723.1 ] || $(MAKE) -C g723.1 clean
|
||||
- ! [ -d g723.1b ] || $(MAKE) -C g723.1b clean
|
||||
- $(MAKE) -C gsm clean
|
||||
- $(MAKE) -C lpc10 clean
|
||||
- $(MAKE) -C ilbc clean
|
||||
+ ! [ -d g723.1 ] || $(MAKE) PROC=$(PROC) -C g723.1 clean
|
||||
+ ! [ -d g723.1b ] || $(MAKE) PROC=$(PROC) -C g723.1b clean
|
||||
+ $(MAKE) PROC=$(PROC) -C gsm clean
|
||||
+ $(MAKE) PROC=$(PROC) -C lpc10 clean
|
||||
+ $(MAKE) PROC=$(PROC) -C ilbc clean
|
||||
|
||||
$(LIBG723):
|
||||
- $(MAKE) -C g723.1 all
|
||||
+ $(MAKE) PROC=$(PROC) -C g723.1 all
|
||||
|
||||
gsm/lib/libgsm.a:
|
||||
- $(MAKE) -C gsm lib/libgsm.a
|
||||
+ $(MAKE) PROC=$(PROC) -C gsm lib/libgsm.a
|
||||
|
||||
$(LIBG723B):
|
||||
- $(MAKE) -C g723.1b all
|
||||
+ $(MAKE) PROC=$(PROC) -C g723.1b all
|
||||
|
||||
$(LIBLPC10):
|
||||
- $(MAKE) -C lpc10 all
|
||||
+ $(MAKE) PROC=$(PROC) -C lpc10 all
|
||||
|
||||
$(LIBILBC):
|
||||
- $(MAKE) -C ilbc all
|
||||
+ $(MAKE) PROC=$(PROC) -C ilbc all
|
||||
|
||||
codec_ilbc.so: codec_ilbc.o $(LIBILBC)
|
||||
$(CC) $(SOLINK) -o $@ $< $(LIBILBC)
|
|
@ -1,16 +0,0 @@
|
|||
diff -ruN asterisk-1.0.7-old/res/Makefile asterisk-1.0.7-new/res/Makefile
|
||||
--- asterisk-1.0.7-old/res/Makefile 2004-07-17 22:58:01.000000000 +0200
|
||||
+++ asterisk-1.0.7-new/res/Makefile 2005-03-19 17:58:17.000000000 +0100
|
||||
@@ -13,9 +13,9 @@
|
||||
|
||||
MODS=res_adsi.so res_features.so res_crypto.so res_musiconhold.so res_indications.so res_monitor.so \
|
||||
res_agi.so
|
||||
-MODS+=$(shell if [ -f "/usr/include/odbcinst.h" ]; then echo "res_odbc.so res_config_odbc.so"; fi)
|
||||
-MODS+=$(shell if [ -f "/usr/local/include/odbcinst.h" ]; then echo "res_odbc.so res_config_odbc.so"; fi)
|
||||
-MODS+=$(shell if [ -f "/usr/include/osp/osp.h" ]; then echo "res_osp.so"; fi)
|
||||
+#MODS+=$(shell if [ -f "/usr/include/odbcinst.h" ]; then echo "res_odbc.so res_config_odbc.so"; fi)
|
||||
+#MODS+=$(shell if [ -f "/usr/local/include/odbcinst.h" ]; then echo "res_odbc.so res_config_odbc.so"; fi)
|
||||
+#MODS+=$(shell if [ -f "/usr/include/osp/osp.h" ]; then echo "res_osp.so"; fi)
|
||||
|
||||
CRYPTO_LIBS=-lssl -lcrypto
|
||||
|
|
@ -1,121 +0,0 @@
|
|||
diff -ruN asterisk-1.0.7-old/Makefile asterisk-1.0.7-new/Makefile
|
||||
--- asterisk-1.0.7-old/Makefile 2005-03-10 09:15:05.000000000 +0100
|
||||
+++ asterisk-1.0.7-new/Makefile 2005-03-19 17:38:06.000000000 +0100
|
||||
@@ -63,10 +63,10 @@
|
||||
#K6OPT = -DK6OPT
|
||||
|
||||
#Tell gcc to optimize the asterisk's code
|
||||
-OPTIMIZE+=-O6
|
||||
+#OPTIMIZE+=-O6
|
||||
|
||||
#Include debug symbols in the executables (-g) and profiling info (-pg)
|
||||
-DEBUG=-g #-pg
|
||||
+#DEBUG=-g #-pg
|
||||
|
||||
# If you are running a radio application, define RADIO_RELAX so that the DTMF
|
||||
# will be received more reliably
|
||||
@@ -74,7 +74,7 @@
|
||||
|
||||
# If you don't have a lot of memory (e.g. embedded Asterisk), uncomment the
|
||||
# following to reduce the size of certain static buffers
|
||||
-#OPTIONS += -DLOW_MEMORY
|
||||
+OPTIONS += -DLOW_MEMORY
|
||||
|
||||
# Optional debugging parameters
|
||||
DEBUG_THREADS = #-DDEBUG_THREADS #-DDO_CRASH
|
||||
@@ -112,7 +112,7 @@
|
||||
BUSYDETECT+= #-DBUSYDETECT_COMPARE_TONE_AND_SILENCE
|
||||
|
||||
ASTLIBDIR=$(INSTALL_PREFIX)/usr/lib/asterisk
|
||||
-ASTVARLIBDIR=$(INSTALL_PREFIX)/var/lib/asterisk
|
||||
+ASTVARLIBDIR=$(INSTALL_PREFIX)/usr/lib/asterisk
|
||||
ASTETCDIR=$(INSTALL_PREFIX)/etc/asterisk
|
||||
ASTSPOOLDIR=$(INSTALL_PREFIX)/var/spool/asterisk
|
||||
ASTLOGDIR=$(INSTALL_PREFIX)/var/log/asterisk
|
||||
@@ -128,7 +128,7 @@
|
||||
|
||||
INCLUDE=-Iinclude -I../include
|
||||
CFLAGS=-pipe -Wall -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations $(DEBUG) $(INCLUDE) -D_REENTRANT -D_GNU_SOURCE #-DMAKE_VALGRIND_HAPPY
|
||||
-CFLAGS+=$(OPTIMIZE)
|
||||
+CFLAGS+=$(OPTIMIZE) $(CFLAGS_EXTRA)
|
||||
|
||||
ifneq ($(PROC),ultrasparc)
|
||||
CFLAGS+=$(shell if $(CC) -march=$(PROC) -S -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-march=$(PROC)"; fi)
|
||||
@@ -187,7 +187,7 @@
|
||||
CFLAGS+=# -fomit-frame-pointer
|
||||
SUBDIRS=res channels pbx apps codecs formats agi cdr astman stdtime
|
||||
ifeq (${OSARCH},Linux)
|
||||
-LIBS=-ldl -lpthread
|
||||
+LIBS=$(LDFLAGS_EXTRA) -ldl -lpthread
|
||||
endif
|
||||
LIBS+=-lncurses -lm
|
||||
ifeq (${OSARCH},Linux)
|
||||
@@ -205,7 +205,7 @@
|
||||
ifeq (${OSARCH},OpenBSD)
|
||||
LIBS=-lcrypto -lpthread -lm -lncurses
|
||||
endif
|
||||
-LIBS+=-lssl
|
||||
+LIBS+=-Wl,-Bstatic -lssl -Wl,-Bdynamic
|
||||
OBJS=io.o sched.o logger.o frame.o loader.o config.o channel.o \
|
||||
translate.o file.o say.o pbx.o cli.o md5.o term.o \
|
||||
ulaw.o alaw.o callerid.o fskmodem.o image.o app.o \
|
||||
@@ -240,12 +240,12 @@
|
||||
cd editline && unset CFLAGS LIBS && ./configure ; \
|
||||
|
||||
editline/libedit.a: FORCE
|
||||
- cd editline && unset CFLAGS LIBS && test -f config.h || ./configure
|
||||
- $(MAKE) -C editline libedit.a
|
||||
+ cd editline && unset CFLAGS LIBS && test -f config.h || CFLAGS="$(OPTIMIZE) $(CFLAGS_EXTRA)" LDFLAGS="$(LDFLAGS_EXTRA)" ./configure
|
||||
+ $(MAKE) PROC=$(PROC) CFLAGS="$(OPTIMIZE)" -C editline libedit.a
|
||||
|
||||
db1-ast/libdb1.a: FORCE
|
||||
@if [ -d db1-ast ]; then \
|
||||
- $(MAKE) -C db1-ast libdb1.a ; \
|
||||
+ $(MAKE) PROC=$(PROC) OORG="$(OPTIMIZE)" -C db1-ast libdb1.a ; \
|
||||
else \
|
||||
echo "You need to do a cvs update -d not just cvs update"; \
|
||||
exit 1; \
|
||||
@@ -289,7 +289,7 @@
|
||||
|
||||
stdtime/libtime.a: FORCE
|
||||
@if [ -d stdtime ]; then \
|
||||
- $(MAKE) -C stdtime libtime.a ; \
|
||||
+ $(MAKE) PROC=$(PROC) -C stdtime libtime.a ; \
|
||||
else \
|
||||
echo "You need to do a cvs update -d not just cvs update"; \
|
||||
exit 1; \
|
||||
@@ -381,7 +381,7 @@
|
||||
if [ ! -f $(DESTDIR)$(ASTSBINDIR)/safe_asterisk ]; then \
|
||||
install -m 755 contrib/scripts/safe_asterisk $(DESTDIR)$(ASTSBINDIR)/ ;\
|
||||
fi
|
||||
- for x in $(SUBDIRS); do $(MAKE) -C $$x install || exit 1 ; done
|
||||
+ for x in $(SUBDIRS); do $(MAKE) PROC=$(PROC) -C $$x install || exit 1 ; done
|
||||
install -d $(DESTDIR)$(ASTHEADERDIR)
|
||||
install -m 644 include/asterisk/*.h $(DESTDIR)$(ASTHEADERDIR)
|
||||
rm -f $(DESTDIR)$(ASTVARLIBDIR)/sounds/vm
|
||||
@@ -519,8 +519,8 @@
|
||||
__rpm: _version
|
||||
rm -rf /tmp/asterisk ; \
|
||||
mkdir -p /tmp/asterisk/redhat/RPMS/i386 ; \
|
||||
- $(MAKE) DESTDIR=/tmp/asterisk install ; \
|
||||
- $(MAKE) DESTDIR=/tmp/asterisk samples ; \
|
||||
+ $(MAKE) PROC=$(PROC) DESTDIR=/tmp/asterisk install ; \
|
||||
+ $(MAKE) PROC=$(PROC) DESTDIR=/tmp/asterisk samples ; \
|
||||
mkdir -p /tmp/asterisk/etc/rc.d/init.d ; \
|
||||
cp -f redhat/asterisk /tmp/asterisk/etc/rc.d/init.d/ ; \
|
||||
sed "s/^Version:.*/Version: $(RPMVERSION)/g" redhat/asterisk.spec > asterisk.spec ; \
|
||||
@@ -544,12 +544,12 @@
|
||||
fi
|
||||
|
||||
dont-optimize:
|
||||
- $(MAKE) OPTIMIZE= K6OPT= install
|
||||
+ $(MAKE) PROC=$(PROC) OPTIMIZE= K6OPT= install
|
||||
|
||||
valgrind: dont-optimize
|
||||
|
||||
depend: .depend
|
||||
- for x in $(SUBDIRS); do $(MAKE) -C $$x depend || exit 1 ; done
|
||||
+ for x in $(SUBDIRS); do $(MAKE) PROC=$(PROC) -C $$x depend || exit 1 ; done
|
||||
|
||||
.depend:
|
||||
@if ! which mpg123 &>/dev/null ; then \
|
|
@ -1,12 +0,0 @@
|
|||
diff -ruN asterisk-1.0.7-old/asterisk.h asterisk-1.0.7-new/asterisk.h
|
||||
--- asterisk-1.0.7-old/asterisk.h 2004-09-07 17:02:53.000000000 +0200
|
||||
+++ asterisk-1.0.7-new/asterisk.h 2005-05-17 09:56:13.000000000 +0200
|
||||
@@ -27,7 +27,7 @@
|
||||
#define AST_LOG_DIR ASTLOGDIR
|
||||
#define AST_AGI_DIR ASTAGIDIR
|
||||
#define AST_KEY_DIR ASTVARLIBDIR "/keys"
|
||||
-#define AST_DB ASTVARLIBDIR "/astdb"
|
||||
+#define AST_DB ASTSPOOLDIR "/astdb"
|
||||
#define AST_TMP_DIR ASTSPOOLDIR "/tmp"
|
||||
|
||||
#define AST_CONFIG_FILE ASTCONFPATH
|
|
@ -1,12 +0,0 @@
|
|||
diff -urN asterisk-1.0.7-old/res/Makefile asterisk-1.0.7-new/res/Makefile
|
||||
--- asterisk-1.0.7-old/res/Makefile 2005-04-25 20:53:11.000000000 +0200
|
||||
+++ asterisk-1.0.7-new/res/Makefile 2005-04-25 20:53:26.000000000 +0200
|
||||
@@ -11,7 +11,7 @@
|
||||
# the GNU General Public License
|
||||
#
|
||||
|
||||
-MODS=res_adsi.so res_features.so res_crypto.so res_musiconhold.so res_indications.so res_monitor.so \
|
||||
+MODS=res_adsi.so res_features.so res_musiconhold.so res_indications.so res_monitor.so \
|
||||
res_agi.so
|
||||
#MODS+=$(shell if [ -f "/usr/include/odbcinst.h" ]; then echo "res_odbc.so res_config_odbc.so"; fi)
|
||||
#MODS+=$(shell if [ -f "/usr/local/include/odbcinst.h" ]; then echo "res_odbc.so res_config_odbc.so"; fi)
|
|
@ -1,12 +0,0 @@
|
|||
diff -urN asterisk-1.0.7-old/astman/Makefile asterisk-1.0.7-new/astman/Makefile
|
||||
--- asterisk-1.0.7-old/astman/Makefile 2004-06-26 21:25:39.000000000 +0200
|
||||
+++ asterisk-1.0.7-new/astman/Makefile 2005-04-29 15:54:53.000000000 +0200
|
||||
@@ -8,7 +8,7 @@
|
||||
CFLAGS+=-I/usr/local/include -L/usr/local/lib
|
||||
endif
|
||||
|
||||
-TARGET=$(shell if [ -f /usr/include/newt.h ]; then echo "astman"; else if [ -f /usr/local/include/newt.h ]; then echo "astman"; else echo "none" ; fi ; fi)
|
||||
+TARGET=none
|
||||
all: depend $(TARGET)
|
||||
|
||||
install:
|
|
@ -1,20 +0,0 @@
|
|||
diff -ruN asterisk-1.0.7-old/pbx/Makefile asterisk-1.0.7-new/pbx/Makefile
|
||||
--- asterisk-1.0.7-old/pbx/Makefile 2003-10-26 19:50:49.000000000 +0100
|
||||
+++ asterisk-1.0.7-new/pbx/Makefile 2005-07-04 15:42:52.000000000 +0200
|
||||
@@ -16,13 +16,13 @@
|
||||
PBX_LIBS=pbx_config.so pbx_wilcalu.so pbx_spool.so # pbx_gtkconsole.so pbx_kdeconsole.so
|
||||
|
||||
# Add GTK console if appropriate
|
||||
-PBX_LIBS+=$(shell gtk-config --cflags >/dev/null 2>/dev/null && echo "pbx_gtkconsole.so")
|
||||
+#PBX_LIBS+=$(shell gtk-config --cflags >/dev/null 2>/dev/null && echo "pbx_gtkconsole.so")
|
||||
# Add KDE Console if appropriate
|
||||
#PBX_LIBS+=$(shell [ "$$QTDIR" != "" ] && echo "pbx_kdeconsole.so")
|
||||
|
||||
|
||||
-GTK_FLAGS=`gtk-config --cflags gthread`
|
||||
-GTK_LIBS=`gtk-config --libs gthread`
|
||||
+#GTK_FLAGS=`gtk-config --cflags gthread`
|
||||
+#GTK_LIBS=`gtk-config --libs gthread`
|
||||
#CXX=egcs
|
||||
MOC=$(QTDIR)/bin/moc
|
||||
KDE_FLAGS=-I$(KDEDIR)/include -I$(KDEDIR)/include/kde -I$(QTDIR)/include
|
File diff suppressed because it is too large
Load Diff
|
@ -1,11 +0,0 @@
|
|||
diff -ruN asterisk-1.0.7-old/rtp.c asterisk-1.0.7-new/rtp.c
|
||||
--- asterisk-1.0.7-old/rtp.c 2005-01-19 03:33:54.000000000 +0100
|
||||
+++ asterisk-1.0.7-new/rtp.c 2005-05-16 19:40:02.000000000 +0200
|
||||
@@ -1048,6 +1048,7 @@
|
||||
rtpheader[3] |= htonl((800));
|
||||
/* Set the End bit for the last 3 */
|
||||
rtpheader[3] |= htonl((1 << 23));
|
||||
+ rtpheader[1] = htonl(++(rtp->lastts)); /* added for Sipura SPA-3000 compat. */
|
||||
} else if ( x < 5) {
|
||||
rtpheader[0] = htonl((2 << 30) | (payload << 16) | (rtp->seqno++));
|
||||
}
|
|
@ -1,80 +0,0 @@
|
|||
diff -ruN asterisk-1.0.9-old/codecs/gsm/Makefile asterisk-1.0.9-new/codecs/gsm/Makefile
|
||||
--- asterisk-1.0.9-old/codecs/gsm/Makefile 2005-06-21 16:27:28.000000000 +0200
|
||||
+++ asterisk-1.0.9-new/codecs/gsm/Makefile 2005-07-11 13:36:12.000000000 +0200
|
||||
@@ -40,12 +40,12 @@
|
||||
ifneq (${OSARCH},Darwin)
|
||||
ifneq (${PROC},x86_64)
|
||||
ifneq (${PROC},ultrasparc)
|
||||
-ifneq ($(shell uname -m),ppc)
|
||||
-ifneq ($(shell uname -m),alpha)
|
||||
-ifneq ($(shell uname -m),armv4l)
|
||||
+ifneq (${PROC},alpha)
|
||||
+ifneq (${PROC},armv4l)
|
||||
ifneq (${PROC},sparc64)
|
||||
ifneq (${PROC},ppc)
|
||||
ifneq (${PROC},ppc64)
|
||||
+ifneq (${PROC},mipsel)
|
||||
OPTIMIZE+=-march=$(PROC)
|
||||
endif
|
||||
endif
|
||||
@@ -84,7 +84,7 @@
|
||||
# CCFLAGS = -c -O
|
||||
|
||||
CC ?= gcc
|
||||
-CCFLAGS += -c -DNeedFunctionPrototypes=1 -funroll-loops -fPIC $(OPTIMIZE) -fomit-frame-pointer
|
||||
+CCFLAGS += -c -DNeedFunctionPrototypes=1 -fPIC $(OPTIMIZE)
|
||||
|
||||
LD = $(CC)
|
||||
|
||||
@@ -219,11 +219,12 @@
|
||||
$(SRC)/short_term.c \
|
||||
$(SRC)/table.c
|
||||
ifeq (${OSARCH},Linux)
|
||||
-ifneq ($(shell uname -m),x86_64)
|
||||
-ifneq ($(shell uname -m),ppc)
|
||||
-ifneq ($(shell uname -m),alpha)
|
||||
-ifneq ($(shell uname -m),armv4l)
|
||||
-ifneq ($(shell uname -m),sparc64)
|
||||
+ifneq (${PROC},x86_64)
|
||||
+ifneq (${PROC},ppc)
|
||||
+ifneq (${PROC},alpha)
|
||||
+ifneq (${PROC},armv4l)
|
||||
+ifneq (${PROC},sparc64)
|
||||
+ifneq ($(PROC),mipsel)
|
||||
GSM_SOURCES+= $(SRC)/k6opt.s
|
||||
endif
|
||||
endif
|
||||
@@ -231,6 +232,7 @@
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
+endif
|
||||
|
||||
TOAST_SOURCES = $(SRC)/toast.c \
|
||||
$(SRC)/toast_lin.c \
|
||||
@@ -277,11 +279,12 @@
|
||||
$(SRC)/table.o
|
||||
|
||||
ifeq (${OSARCH},Linux)
|
||||
-ifneq ($(shell uname -m), x86_64)
|
||||
-ifneq ($(shell uname -m), ppc)
|
||||
-ifneq ($(shell uname -m), alpha)
|
||||
-ifneq ($(shell uname -m), armv4l)
|
||||
-ifneq ($(shell uname -m), sparc64)
|
||||
+ifneq (${PROC}, x86_64)
|
||||
+ifneq (${PROC}, ppc)
|
||||
+ifneq (${PROC}, alpha)
|
||||
+ifneq (${PROC}, armv4l)
|
||||
+ifneq (${PROC}, sparc64)
|
||||
+ifneq ($(PROC), mipsel)
|
||||
GSM_OBJECTS+= $(SRC)/k6opt.o
|
||||
endif
|
||||
endif
|
||||
@@ -289,6 +292,7 @@
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
+endif
|
||||
|
||||
TOAST_OBJECTS = $(SRC)/toast.o \
|
||||
$(SRC)/toast_lin.o \
|
|
@ -19,7 +19,7 @@ diff -ruN asterisk-1.0.9-old/channels/Makefile asterisk-1.0.9-new/channels/Makef
|
|||
$(CC) $(SOLINK) -o $@ $< h323/libchanh323.a $(CHANH323LIB) -L$(PWLIBDIR)/lib $(PTLIB) -L$(OPENH323DIR)/lib $(H323LIB) -L/usr/lib -lcrypto -lssl -lexpat
|
||||
|
||||
+chan_bluetooth.so: chan_bluetooth.o
|
||||
+ $(CC) $(SOLINK) -o $@ $< $(LDFLAGS_EXTRA) -lbluetooth
|
||||
+ $(CC) $(SOLINK) -o $@ $< $(EXTRA_LDFLAGS) -lbluetooth
|
||||
+
|
||||
|
||||
#chan_modem.so : chan_modem.o
|
||||
|
@ -164,7 +164,7 @@ diff -ruN asterisk-1.0.9-old/channels/chan_bluetooth.c asterisk-1.0.9-new/channe
|
|||
+#define BLT_CONFIG_FILE "bluetooth.conf"
|
||||
+#define BLT_RDBUFF_MAX 1024
|
||||
+#define BLT_DEFAULT_HCI_DEV 0
|
||||
+#define BLT_SVN_REVISION "$Rev: 38 $"
|
||||
+#define BLT_SVN_REVISION "$Rev$"
|
||||
+
|
||||
+/* ---------------------------------- */
|
||||
+
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
diff -ruN asterisk-1.2.0-old/apps/Makefile asterisk-1.2.0-new/apps/Makefile
|
||||
--- asterisk-1.2.0-old/apps/Makefile 2005-11-11 01:32:45.000000000 +0100
|
||||
+++ asterisk-1.2.0-new/apps/Makefile 2005-12-04 19:26:20.000000000 +0100
|
||||
@@ -83,6 +83,9 @@
|
||||
#CFLAGS+=-DEXTENDED_ODBC_STORAGE
|
||||
# See doc/README.odbcstorage for more information
|
||||
|
||||
+CFLAGS += $(EXTRA_CFLAGS)
|
||||
+APPS += $(EXTRA_APP_MODULES)
|
||||
+
|
||||
all: $(APPS)
|
||||
|
||||
clean:
|
||||
@@ -102,14 +105,17 @@
|
||||
app_curl.so: app_curl.o
|
||||
$(CC) $(SOLINK) -o $@ ${CYGSOLINK} $< ${CYGSOLIB} $(CURLLIBS)
|
||||
|
||||
+app_sql_mysql.so: app_sql_mysql.o
|
||||
+ $(CC) $(SOLINK) -o $@ ${CYGSOLINK} $< ${CYGSOLIB} $(EXTRA_LDFLAGS) -lmysqlclient
|
||||
+
|
||||
app_sql_postgres.o: app_sql_postgres.c
|
||||
- $(CC) -pipe -I/usr/local/pgsql/include $(CFLAGS) -c -o app_sql_postgres.o app_sql_postgres.c
|
||||
+ $(CC) -pipe $(CFLAGS) -c -o app_sql_postgres.o app_sql_postgres.c
|
||||
|
||||
app_sql_postgres.so: app_sql_postgres.o
|
||||
- $(CC) $(SOLINK) -o $@ ${CYGSOLINK} $< ${CYGSOLIB} -L/usr/local/pgsql/lib -lpq
|
||||
+ $(CC) $(SOLINK) -o $@ ${CYGSOLINK} $< ${CYGSOLIB} $(EXTRA_LDFLAGS) -lpq
|
||||
|
||||
app_sql_odbc.so: app_sql_odbc.o
|
||||
- $(CC) $(SOLINK) -o $@ ${CYGSOLINK} $< ${CYGSOLIB} -lodbc
|
||||
+ $(CC) $(SOLINK) -o $@ ${CYGSOLINK} $< ${CYGSOLIB} $(EXTRA_LDFLAGS) -lodbc
|
||||
|
||||
look: look.c
|
||||
$(CC) -pipe -O6 -g look.c -o look -lncurses
|
|
@ -0,0 +1,37 @@
|
|||
diff -ruN asterisk-1.2.0-old/cdr/Makefile asterisk-1.2.0-new/cdr/Makefile
|
||||
--- asterisk-1.2.0-old/cdr/Makefile 2005-11-14 01:45:07.000000000 +0100
|
||||
+++ asterisk-1.2.0-new/cdr/Makefile 2005-12-04 22:22:43.000000000 +0100
|
||||
@@ -107,6 +107,9 @@
|
||||
MODS+=cdr_sqlite.so
|
||||
endif
|
||||
|
||||
+CFLAGS += $(EXTRA_CFLAGS)
|
||||
+MODS += $(EXTRA_CDR_MODULES)
|
||||
+
|
||||
all: depend $(MODS)
|
||||
|
||||
install: all
|
||||
@@ -123,16 +126,19 @@
|
||||
endif
|
||||
|
||||
cdr_odbc.so: cdr_odbc.o
|
||||
- $(CC) $(SOLINK) -o $@ ${CYGSOLINK} $< ${CYGSOLIB} -lodbc $(MLFLAGS)
|
||||
+ $(CC) $(SOLINK) -o $@ ${CYGSOLINK} $< ${CYGSOLIB} $(EXTRA_LDFLAGS) -lodbc $(MLFLAGS)
|
||||
|
||||
cdr_tds.so: cdr_tds.o
|
||||
- $(CC) $(SOLINK) -o $@ ${CYGSOLINK} $< ${CYGSOLIB} -ltds $(MLFLAGS)
|
||||
+ $(CC) $(SOLINK) -o $@ ${CYGSOLINK} $< ${CYGSOLIB} $(EXTRA_LDFLAGS) -ltds $(MLFLAGS)
|
||||
+
|
||||
+cdr_mysql.so: cdr_pgsql.o
|
||||
+ $(CC) $(SOLINK) -o $@ ${CYGSOLINK} $< ${CYGSOLIB} $(EXTRA_LDFLAGS) -lmysqlclient -lz $(MLFLAGS)
|
||||
|
||||
cdr_pgsql.so: cdr_pgsql.o
|
||||
- $(CC) $(SOLINK) -o $@ ${CYGSOLINK} $< ${CYGSOLIB} -lpq -lz $(MLFLAGS)
|
||||
+ $(CC) $(SOLINK) -o $@ ${CYGSOLINK} $< ${CYGSOLIB} $(EXTRA_LDFLAGS) -lpq -lz $(MLFLAGS)
|
||||
|
||||
cdr_sqlite.so: cdr_sqlite.o
|
||||
- $(CC) $(SOLINK) -o $@ ${CYGSOLINK} $< ${CYGSOLIB} -lsqlite $(MLFLAGS)
|
||||
+ $(CC) $(SOLINK) -o $@ ${CYGSOLINK} $< ${CYGSOLIB} $(EXTRA_LDFLAGS) -lsqlite $(MLFLAGS)
|
||||
|
||||
depend: .depend
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
diff -ruN asterisk-1.2.0-old/channels/Makefile asterisk-1.2.0-new/channels/Makefile
|
||||
--- asterisk-1.2.0-old/channels/Makefile 2005-12-04 04:48:40.000000000 +0100
|
||||
+++ asterisk-1.2.0-new/channels/Makefile 2005-12-04 23:30:19.000000000 +0100
|
||||
@@ -155,6 +155,9 @@
|
||||
|
||||
#CFLAGS+=$(shell [ -f $(ZAPDIR)/libzap.a ] && echo "-I$(ZAPDIR)")
|
||||
|
||||
+CFLAGS += $(EXTRA_CFLAGS)
|
||||
+CHANNEL_LIBS += $(EXTRA_CHAN_MODULES)
|
||||
+
|
||||
all: depend $(CHANNEL_LIBS)
|
||||
|
||||
clean:
|
||||
@@ -162,7 +165,7 @@
|
||||
rm -f busy.h ringtone.h gentone gentone-ulaw
|
||||
|
||||
%.so : %.o
|
||||
- $(CC) $(SOLINK) -o $@ ${CYGSOLINK} $< ${CYGSOLIB} ${LIBS}
|
||||
+ $(CC) $(SOLINK) -o $@ ${CYGSOLINK} $< ${CYGSOLIB}
|
||||
|
||||
ifneq ($(wildcard .depend),)
|
||||
include .depend
|
|
@ -0,0 +1,35 @@
|
|||
diff -ruN asterisk-1.2.0-old/codecs/gsm/Makefile asterisk-1.2.0-new/codecs/gsm/Makefile
|
||||
--- asterisk-1.2.0-old/codecs/gsm/Makefile 2005-11-08 04:31:45.000000000 +0100
|
||||
+++ asterisk-1.2.0-new/codecs/gsm/Makefile 2005-12-04 13:31:50.000000000 +0100
|
||||
@@ -236,6 +236,7 @@
|
||||
ifneq ($(shell uname -m),armv4l)
|
||||
ifneq ($(shell uname -m),sparc64)
|
||||
ifneq (${PROC},arm)
|
||||
+ifneq (${PROC},mipsel)
|
||||
GSM_SOURCES+= $(SRC)/k6opt.s
|
||||
endif
|
||||
endif
|
||||
@@ -245,6 +246,7 @@
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
+endif
|
||||
|
||||
TOAST_SOURCES = $(SRC)/toast.c \
|
||||
$(SRC)/toast_lin.c \
|
||||
@@ -297,6 +299,7 @@
|
||||
ifneq ($(shell uname -m), alpha)
|
||||
ifneq ($(shell uname -m), sparc64)
|
||||
ifneq ($(shell uname -m), armv4l)
|
||||
+ifneq (${PROC}, mipsel)
|
||||
GSM_OBJECTS+= $(SRC)/k6opt.o
|
||||
endif
|
||||
endif
|
||||
@@ -305,6 +308,7 @@
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
+endif
|
||||
|
||||
TOAST_OBJECTS = $(SRC)/toast.o \
|
||||
$(SRC)/toast_lin.o \
|
|
@ -0,0 +1,13 @@
|
|||
diff -ruN asterisk-1.2.0-old/codecs/Makefile asterisk-1.2.0-new/codecs/Makefile
|
||||
--- asterisk-1.2.0-old/codecs/Makefile 2005-11-08 05:13:18.000000000 +0100
|
||||
+++ asterisk-1.2.0-new/codecs/Makefile 2005-12-04 19:24:53.000000000 +0100
|
||||
@@ -72,6 +72,9 @@
|
||||
codec_adpcm.so codec_ulaw.so codec_alaw.so codec_a_mu.so \
|
||||
codec_g726.so
|
||||
|
||||
+CFLAGS += $(EXTRA_CFLAGS)
|
||||
+CODECS += $(EXTRA_CODEC_MODULES)
|
||||
+
|
||||
all: depend $(CODECS)
|
||||
|
||||
clean:
|
|
@ -0,0 +1,22 @@
|
|||
diff -ruN asterisk-1.2.0-old/pbx/Makefile asterisk-1.2.0-new/pbx/Makefile
|
||||
--- asterisk-1.2.0-old/pbx/Makefile 2005-11-01 22:53:30.000000000 +0100
|
||||
+++ asterisk-1.2.0-new/pbx/Makefile 2005-12-04 19:23:48.000000000 +0100
|
||||
@@ -38,6 +38,9 @@
|
||||
|
||||
KDE_CONSOLE_OBJS=pbx_kdeconsole_main.o pbx_kdeconsole.o
|
||||
|
||||
+CFLAGS += $(EXTRA_CFLAGS)
|
||||
+PBX_LIBS += $(EXTRA_PBX_MODULES)
|
||||
+
|
||||
all: depend $(PBX_LIBS)
|
||||
|
||||
clean:
|
||||
@@ -59,7 +62,7 @@
|
||||
$(CC) $(SOLINK) -o $@ $(KDE_CONSOLE_OBJS) $(KDE_LIBS)
|
||||
|
||||
pbx_dundi.so: dundi-parser.o pbx_dundi.o
|
||||
- $(CC) $(SOLINK) -o $@ ${CYGSOLINK} pbx_dundi.o dundi-parser.o -lz ${CYGSOLIB}
|
||||
+ $(CC) $(SOLINK) -o $@ ${CYGSOLINK} pbx_dundi.o dundi-parser.o $(EXTRA_LDFLAGS) -lz ${CYGSOLIB}
|
||||
|
||||
%.moc : %.h
|
||||
$(MOC) $< -o $@
|
|
@ -0,0 +1,26 @@
|
|||
diff -ruN asterisk-1.2.0-old/res/Makefile asterisk-1.2.0-new/res/Makefile
|
||||
--- asterisk-1.2.0-old/res/Makefile 2005-11-16 21:49:44.000000000 +0100
|
||||
+++ asterisk-1.2.0-new/res/Makefile 2005-12-04 19:18:15.000000000 +0100
|
||||
@@ -69,6 +69,9 @@
|
||||
CFLAGS+=-DOPENSSL_NO_KRB5 -fPIC
|
||||
endif
|
||||
|
||||
+CFLAGS += $(EXTRA_CFLAGS)
|
||||
+MODS += $(EXTRA_RES_MODULES)
|
||||
+
|
||||
all: depend $(MODS)
|
||||
|
||||
install: all
|
||||
@@ -112,6 +112,12 @@
|
||||
res_config_odbc.so: res_config_odbc.o
|
||||
$(CC) $(SOLINK) -o $@ ${CYGSOLINK} $< ${CYGSOLIB} ${CYG_RES_CONFIG_ODBC_LIB}
|
||||
|
||||
+res_config_mysql.so: res_config_mysql.o
|
||||
+ $(CC) $(SOLINK) -o $@ ${CYGSOLINK} $< ${CYGSOLIB} $(EXTRA_LDFLAGS) -lmysqlclient -lz
|
||||
+
|
||||
+res_sqlite.so: res_sqlite.o
|
||||
+ $(CC) $(SOLINK) -o $@ ${CYGSOLINK} $< ${CYGSOLIB} $(EXTRA_LDFLAGS) -lsqlite
|
||||
+
|
||||
ifneq ($(wildcard .depend),)
|
||||
include .depend
|
||||
endif
|
|
@ -0,0 +1,54 @@
|
|||
diff -ruN asterisk-1.2.0-old/Makefile asterisk-1.2.0-new/Makefile
|
||||
--- asterisk-1.2.0-old/Makefile 2005-11-16 21:23:53.000000000 +0100
|
||||
+++ asterisk-1.2.0-new/Makefile 2005-12-04 23:01:16.000000000 +0100
|
||||
@@ -341,16 +339,6 @@
|
||||
netsock.o slinfactory.o ast_expr2.o ast_expr2f.o \
|
||||
cryptostub.o
|
||||
|
||||
-ifeq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/include/sys/poll.h),)
|
||||
- OBJS+= poll.o
|
||||
- ASTCFLAGS+=-DPOLLCOMPAT
|
||||
-endif
|
||||
-
|
||||
-ifeq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/include/dlfcn.h),)
|
||||
- OBJS+= dlfcn.o
|
||||
- ASTCFLAGS+=-DDLFCNCOMPAT
|
||||
-endif
|
||||
-
|
||||
ifeq ($(OSARCH),Linux)
|
||||
LIBS+=-ldl -lpthread -lncurses -lm -lresolv #-lnjamd
|
||||
else
|
||||
@@ -401,7 +389,9 @@
|
||||
HAVEDOT=no
|
||||
endif
|
||||
|
||||
+ifneq ($(NOCRYPTO),yes)
|
||||
LIBS+=-lssl
|
||||
+endif
|
||||
|
||||
INSTALL=install
|
||||
|
||||
@@ -430,12 +420,12 @@
|
||||
cd editline && unset CFLAGS LIBS && ./configure ; \
|
||||
|
||||
editline/libedit.a: FORCE
|
||||
- cd editline && unset CFLAGS LIBS && test -f config.h || ./configure
|
||||
+ cd editline && unset CFLAGS LIBS && test -f config.h || CFLAGS="$(OPTIMIZE) $(EXTRA_CFLAGS)" LDFLAGS="$(EXTRA_LDFLAGS)" ./configure
|
||||
$(MAKE) -C editline libedit.a
|
||||
|
||||
db1-ast/libdb1.a: FORCE
|
||||
@if [ -d db1-ast ]; then \
|
||||
- $(MAKE) -C db1-ast libdb1.a ; \
|
||||
+ $(MAKE) OORG="$(OPTIMIZE)" -C db1-ast libdb1.a ; \
|
||||
else \
|
||||
echo "You need to do a cvs update -d not just cvs update"; \
|
||||
exit 1; \
|
||||
@@ -513,7 +503,7 @@
|
||||
fi
|
||||
rm -f include/asterisk/build.h.tmp
|
||||
$(CC) -c -o buildinfo.o $(CFLAGS) buildinfo.c
|
||||
- $(CC) $(DEBUG) $(ASTOBJ) $(ASTLINK) $(OBJS) buildinfo.o $(LIBEDIT) db1-ast/libdb1.a stdtime/libtime.a $(LIBS)
|
||||
+ $(CC) $(DEBUG) $(ASTOBJ) $(ASTLINK) $(OBJS) buildinfo.o $(LIBEDIT) db1-ast/libdb1.a stdtime/libtime.a $(EXTRA_LDFLAGS) $(LIBS)
|
||||
|
||||
muted: muted.o
|
||||
$(CC) $(AUDIO_LIBS) -o muted muted.o
|
|
@ -0,0 +1,449 @@
|
|||
diff -ruN asterisk-1.2.0-old/apps/app_sql_mysql.c asterisk-1.2.0-new/apps/app_sql_mysql.c
|
||||
--- asterisk-1.2.0-old/apps/app_sql_mysql.c 1970-01-01 01:00:00.000000000 +0100
|
||||
+++ asterisk-1.2.0-new/apps/app_sql_mysql.c 2005-06-07 18:36:28.000000000 +0200
|
||||
@@ -0,0 +1,445 @@
|
||||
+/*
|
||||
+ * Asterisk -- A telephony toolkit for Linux.
|
||||
+ *
|
||||
+ * Connect to MySQL
|
||||
+ *
|
||||
+ * Copyright (C) 2004, Constantine Filin and Christos Ricudis
|
||||
+ *
|
||||
+ * Christos Ricudis <ricudis@itc.auth.gr>
|
||||
+ * Constantine Filin <cf@intermedia.net>
|
||||
+ *
|
||||
+ * This program is free software, distributed under the terms of
|
||||
+ * the GNU General Public License
|
||||
+ */
|
||||
+
|
||||
+#include <stdlib.h>
|
||||
+#include <unistd.h>
|
||||
+#include <string.h>
|
||||
+#include <stdlib.h>
|
||||
+#include <sys/types.h>
|
||||
+#include <stdio.h>
|
||||
+#include <unistd.h>
|
||||
+
|
||||
+#include <mysql.h>
|
||||
+
|
||||
+#include <asterisk/file.h>
|
||||
+#include <asterisk/logger.h>
|
||||
+#include <asterisk/channel.h>
|
||||
+#include <asterisk/pbx.h>
|
||||
+#include <asterisk/module.h>
|
||||
+#include <asterisk/linkedlists.h>
|
||||
+#include <asterisk/chanvars.h>
|
||||
+#include <asterisk/lock.h>
|
||||
+
|
||||
+#define EXTRA_LOG 0
|
||||
+
|
||||
+static char *tdesc = "Simple Mysql Interface";
|
||||
+
|
||||
+static char *app = "MYSQL";
|
||||
+
|
||||
+static char *synopsis = "Do several mySQLy things";
|
||||
+
|
||||
+static char *descrip =
|
||||
+"MYSQL(): Do several mySQLy things\n"
|
||||
+"Syntax:\n"
|
||||
+" MYSQL(Connect connid dhhost dbuser dbpass dbname)\n"
|
||||
+" Connects to a database. Arguments contain standard MySQL parameters\n"
|
||||
+" passed to function mysql_real_connect. Connection identifer returned\n"
|
||||
+" in ${var}\n"
|
||||
+" MYSQL(Query resultid ${connid} query-string)\n"
|
||||
+" Executes standard MySQL query contained in query-string using established\n"
|
||||
+" connection identified by ${connection_identifier}. Result of query is\n"
|
||||
+" is stored in ${var}.\n"
|
||||
+" MYSQL(Fetch fetchid ${resultid} var1 var2 ... varN)\n"
|
||||
+" Fetches a single row from a result set contained in ${result_identifier}.\n"
|
||||
+" Assigns returned fields to ${var1} ... ${varn}. ${fetchid} is set TRUE\n"
|
||||
+" if additional rows exist in result set.\n"
|
||||
+" MYSQL(Clear ${resultid})\n"
|
||||
+" Frees memory and datastructures associated with result set.\n"
|
||||
+" MYSQL(Disconnect ${connid})\n"
|
||||
+" Disconnects from named connection to MySQL.\n"
|
||||
+" On exit, always returns 0. Sets MYSQL_STATUS to 0 on success and -1 on error.\n";
|
||||
+
|
||||
+/*
|
||||
+EXAMPLES OF USE :
|
||||
+
|
||||
+exten => s,2,MYSQL(Connect connid localhost asterisk mypass credit)
|
||||
+exten => s,3,MYSQL(Query resultid ${connid} SELECT username,credit FROM credit WHERE callerid=${CALLERIDNUM})
|
||||
+exten => s,4,MYSQL(Fetch fetchid ${resultid} datavar1 datavar2)
|
||||
+exten => s,5,GotoIf(${fetchid}?6:8)
|
||||
+exten => s,6,Festival("User ${datavar1} currently has credit balance of ${datavar2} dollars.")
|
||||
+exten => s,7,Goto(s,4)
|
||||
+exten => s,8,MYSQL(Clear ${resultid})
|
||||
+exten => s,9,MYSQL(Disconnect ${connid})
|
||||
+*/
|
||||
+
|
||||
+STANDARD_LOCAL_USER;
|
||||
+LOCAL_USER_DECL;
|
||||
+
|
||||
+AST_MUTEX_DEFINE_STATIC(_mysql_mutex);
|
||||
+
|
||||
+#define AST_MYSQL_ID_DUMMY 0
|
||||
+#define AST_MYSQL_ID_CONNID 1
|
||||
+#define AST_MYSQL_ID_RESID 2
|
||||
+#define AST_MYSQL_ID_FETCHID 3
|
||||
+
|
||||
+struct ast_MYSQL_id {
|
||||
+ int identifier_type; /* 0=dummy, 1=connid, 2=resultid */
|
||||
+ int identifier;
|
||||
+ void *data;
|
||||
+ AST_LIST_ENTRY(ast_MYSQL_id) entries;
|
||||
+} *ast_MYSQL_id;
|
||||
+
|
||||
+AST_LIST_HEAD(MYSQLidshead,ast_MYSQL_id) _mysql_ids_head;
|
||||
+
|
||||
+/* helpful procs */
|
||||
+static void *find_identifier(int identifier,int identifier_type) {
|
||||
+ struct MYSQLidshead *headp;
|
||||
+ struct ast_MYSQL_id *i;
|
||||
+ void *res=NULL;
|
||||
+ int found=0;
|
||||
+
|
||||
+ headp=&_mysql_ids_head;
|
||||
+
|
||||
+ if (AST_LIST_LOCK(headp)) {
|
||||
+ ast_log(LOG_WARNING,"Unable to lock identifiers list\n");
|
||||
+ } else {
|
||||
+ AST_LIST_TRAVERSE(headp,i,entries) {
|
||||
+ if ((i->identifier==identifier) && (i->identifier_type==identifier_type)) {
|
||||
+ found=1;
|
||||
+ res=i->data;
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+ if (!found) {
|
||||
+ ast_log(LOG_WARNING,"Identifier %d, identifier_type %d not found in identifier list\n",identifier,identifier_type);
|
||||
+ }
|
||||
+ AST_LIST_UNLOCK(headp);
|
||||
+ }
|
||||
+
|
||||
+ return res;
|
||||
+}
|
||||
+
|
||||
+static int add_identifier(int identifier_type,void *data) {
|
||||
+ struct ast_MYSQL_id *i,*j;
|
||||
+ struct MYSQLidshead *headp;
|
||||
+ int maxidentifier=0;
|
||||
+
|
||||
+ headp=&_mysql_ids_head;
|
||||
+ i=NULL;
|
||||
+ j=NULL;
|
||||
+
|
||||
+ if (AST_LIST_LOCK(headp)) {
|
||||
+ ast_log(LOG_WARNING,"Unable to lock identifiers list\n");
|
||||
+ return(-1);
|
||||
+ } else {
|
||||
+ i=malloc(sizeof(struct ast_MYSQL_id));
|
||||
+ AST_LIST_TRAVERSE(headp,j,entries) {
|
||||
+ if (j->identifier>maxidentifier) {
|
||||
+ maxidentifier=j->identifier;
|
||||
+ }
|
||||
+ }
|
||||
+ i->identifier=maxidentifier+1;
|
||||
+ i->identifier_type=identifier_type;
|
||||
+ i->data=data;
|
||||
+ AST_LIST_INSERT_HEAD(headp,i,entries);
|
||||
+ AST_LIST_UNLOCK(headp);
|
||||
+ }
|
||||
+ return i->identifier;
|
||||
+}
|
||||
+
|
||||
+static int del_identifier(int identifier,int identifier_type) {
|
||||
+ struct ast_MYSQL_id *i;
|
||||
+ struct MYSQLidshead *headp;
|
||||
+ int found=0;
|
||||
+
|
||||
+ headp=&_mysql_ids_head;
|
||||
+
|
||||
+ if (AST_LIST_LOCK(headp)) {
|
||||
+ ast_log(LOG_WARNING,"Unable to lock identifiers list\n");
|
||||
+ } else {
|
||||
+ AST_LIST_TRAVERSE(headp,i,entries) {
|
||||
+ if ((i->identifier==identifier) &&
|
||||
+ (i->identifier_type==identifier_type)) {
|
||||
+ AST_LIST_REMOVE(headp,i,entries);
|
||||
+ free(i);
|
||||
+ found=1;
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+ AST_LIST_UNLOCK(headp);
|
||||
+ }
|
||||
+
|
||||
+ if (found==0) {
|
||||
+ ast_log(LOG_WARNING,"Could not find identifier %d, identifier_type %d in list to delete\n",identifier,identifier_type);
|
||||
+ return(-1);
|
||||
+ } else {
|
||||
+ return(0);
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+static int set_asterisk_int(struct ast_channel *chan, char *varname, int id) {
|
||||
+ if( id>=0 ) {
|
||||
+ char s[100] = "";
|
||||
+ snprintf(s, sizeof(s)-1, "%d", id);
|
||||
+#if EXTRA_LOG
|
||||
+ ast_log(LOG_WARNING,"MYSQL: setting var '%s' to value '%s'\n",varname,s);
|
||||
+#endif
|
||||
+ pbx_builtin_setvar_helper(chan,varname,s);
|
||||
+ }
|
||||
+ return id;
|
||||
+}
|
||||
+
|
||||
+static int add_identifier_and_set_asterisk_int(struct ast_channel *chan, char *varname, int identifier_type, void *data) {
|
||||
+ return set_asterisk_int(chan,varname,add_identifier(identifier_type,data));
|
||||
+}
|
||||
+
|
||||
+static int safe_scan_int( char** data, char* delim, int def ) {
|
||||
+ char* end;
|
||||
+ int res = def;
|
||||
+ char* s = strsep(data,delim);
|
||||
+ if( s ) {
|
||||
+ res = strtol(s,&end,10);
|
||||
+ if (*end) res = def; /* not an integer */
|
||||
+ }
|
||||
+ return res;
|
||||
+}
|
||||
+
|
||||
+/* MYSQL operations */
|
||||
+static int aMYSQL_connect(struct ast_channel *chan, char *data) {
|
||||
+
|
||||
+ MYSQL *mysql;
|
||||
+
|
||||
+ char *connid_var;
|
||||
+ char *dbhost;
|
||||
+ char *dbuser;
|
||||
+ char *dbpass;
|
||||
+ char *dbname;
|
||||
+
|
||||
+ strsep(&data," "); // eat the first token, we already know it :P
|
||||
+
|
||||
+ connid_var=strsep(&data," ");
|
||||
+ dbhost=strsep(&data," ");
|
||||
+ dbuser=strsep(&data," ");
|
||||
+ dbpass=strsep(&data," ");
|
||||
+ dbname=strsep(&data,"\n");
|
||||
+
|
||||
+ if( connid_var && dbhost && dbuser && dbpass && dbname ) {
|
||||
+ mysql = mysql_init(NULL);
|
||||
+ if (mysql) {
|
||||
+ if (mysql_real_connect(mysql,dbhost,dbuser,dbpass,dbname,0,NULL,0)) {
|
||||
+ add_identifier_and_set_asterisk_int(chan,connid_var,AST_MYSQL_ID_CONNID,mysql);
|
||||
+ return 0;
|
||||
+ }
|
||||
+ else {
|
||||
+ ast_log(LOG_WARNING,"mysql_real_connect(mysql,%s,%s,dbpass,%s,...) failed\n",dbhost,dbuser,dbname);
|
||||
+ }
|
||||
+ }
|
||||
+ else {
|
||||
+ ast_log(LOG_WARNING,"myslq_init returned NULL\n");
|
||||
+ }
|
||||
+ }
|
||||
+ else {
|
||||
+ ast_log(LOG_WARNING,"MYSQL(connect is missing some arguments\n");
|
||||
+ }
|
||||
+
|
||||
+ return -1;
|
||||
+}
|
||||
+
|
||||
+static int aMYSQL_query(struct ast_channel *chan, char *data) {
|
||||
+
|
||||
+ MYSQL *mysql;
|
||||
+ MYSQL_RES *mysqlres;
|
||||
+
|
||||
+ char *resultid_var;
|
||||
+ int connid;
|
||||
+ char *querystring;
|
||||
+
|
||||
+ strsep(&data," "); // eat the first token, we already know it :P
|
||||
+
|
||||
+ resultid_var = strsep(&data," ");
|
||||
+ connid = safe_scan_int(&data," ",-1);
|
||||
+ querystring = strsep(&data,"\n");
|
||||
+
|
||||
+ if (resultid_var && (connid>=0) && querystring) {
|
||||
+ if ((mysql=find_identifier(connid,AST_MYSQL_ID_CONNID))!=NULL) {
|
||||
+ mysql_query(mysql,querystring);
|
||||
+ if ((mysqlres=mysql_use_result(mysql))!=NULL) {
|
||||
+ add_identifier_and_set_asterisk_int(chan,resultid_var,AST_MYSQL_ID_RESID,mysqlres);
|
||||
+ return 0;
|
||||
+ }
|
||||
+ else if( mysql_field_count(mysql)==0 ) {
|
||||
+ return 0; // See http://dev.mysql.com/doc/mysql/en/mysql_field_count.html
|
||||
+ }
|
||||
+ else {
|
||||
+ ast_log(LOG_WARNING,"aMYSQL_query: mysql_store_result() failed on query %s\n",querystring);
|
||||
+ }
|
||||
+ }
|
||||
+ else {
|
||||
+ ast_log(LOG_WARNING,"aMYSQL_query: Invalid connection identifier %d passed in aMYSQL_query\n",connid);
|
||||
+ }
|
||||
+ }
|
||||
+ else {
|
||||
+ ast_log(LOG_WARNING,"aMYSQL_query: missing some arguments\n");
|
||||
+ }
|
||||
+
|
||||
+ return -1;
|
||||
+}
|
||||
+
|
||||
+
|
||||
+static int aMYSQL_fetch(struct ast_channel *chan, char *data) {
|
||||
+
|
||||
+ MYSQL_RES *mysqlres;
|
||||
+ MYSQL_ROW mysqlrow;
|
||||
+
|
||||
+ char *fetchid_var,*s5,*s6;
|
||||
+ int resultid,numFields,j;
|
||||
+
|
||||
+ strsep(&data," "); // eat the first token, we already know it :P
|
||||
+
|
||||
+ fetchid_var = strsep(&data," ");
|
||||
+ resultid = safe_scan_int(&data," ",-1);
|
||||
+
|
||||
+ if (fetchid_var && (resultid>=0) ) {
|
||||
+ if ((mysqlres=find_identifier(resultid,AST_MYSQL_ID_RESID))!=NULL) {
|
||||
+ /* Grab the next row */
|
||||
+ if ((mysqlrow=mysql_fetch_row(mysqlres))!=NULL) {
|
||||
+ numFields=mysql_num_fields(mysqlres);
|
||||
+ for (j=0;j<numFields;j++) {
|
||||
+ s5=strsep(&data," ");
|
||||
+ if (s5==NULL) {
|
||||
+ ast_log(LOG_WARNING,"ast_MYSQL_fetch: More fields (%d) than variables (%d)\n",numFields,j);
|
||||
+ break;
|
||||
+ }
|
||||
+ s6=mysqlrow[j];
|
||||
+ pbx_builtin_setvar_helper(chan,s5, s6 ? s6 : "NULL");
|
||||
+ }
|
||||
+#ifdef EXTRA_LOG
|
||||
+ ast_log(LOG_WARNING,"ast_MYSQL_fetch: numFields=%d\n",numFields);
|
||||
+#endif
|
||||
+ set_asterisk_int(chan,fetchid_var,1); // try more rows
|
||||
+ } else {
|
||||
+#if EXTRA_LOG
|
||||
+ ast_log(LOG_WARNING,"ast_MYSQL_fetch : EOF\n");
|
||||
+#endif
|
||||
+ set_asterisk_int(chan,fetchid_var,0); // no more rows
|
||||
+ }
|
||||
+ return 0;
|
||||
+ }
|
||||
+ else {
|
||||
+ ast_log(LOG_WARNING,"aMYSQL_fetch: Invalid result identifier %d passed\n",resultid);
|
||||
+ }
|
||||
+ }
|
||||
+ else {
|
||||
+ ast_log(LOG_WARNING,"aMYSQL_fetch: missing some arguments\n");
|
||||
+ }
|
||||
+
|
||||
+ return -1;
|
||||
+}
|
||||
+
|
||||
+static int aMYSQL_clear(struct ast_channel *chan, char *data) {
|
||||
+
|
||||
+ MYSQL_RES *mysqlres;
|
||||
+
|
||||
+ int id;
|
||||
+ strsep(&data," "); // eat the first token, we already know it :P
|
||||
+ id = safe_scan_int(&data," \n",-1);
|
||||
+ if ((mysqlres=find_identifier(id,AST_MYSQL_ID_RESID))==NULL) {
|
||||
+ ast_log(LOG_WARNING,"Invalid result identifier %d passed in aMYSQL_clear\n",id);
|
||||
+ } else {
|
||||
+ mysql_free_result(mysqlres);
|
||||
+ del_identifier(id,AST_MYSQL_ID_RESID);
|
||||
+ }
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static int aMYSQL_disconnect(struct ast_channel *chan, char *data) {
|
||||
+
|
||||
+ MYSQL *mysql;
|
||||
+ int id;
|
||||
+ strsep(&data," "); // eat the first token, we already know it :P
|
||||
+
|
||||
+ id = safe_scan_int(&data," \n",-1);
|
||||
+ if ((mysql=find_identifier(id,AST_MYSQL_ID_CONNID))==NULL) {
|
||||
+ ast_log(LOG_WARNING,"Invalid connection identifier %d passed in aMYSQL_disconnect\n",id);
|
||||
+ } else {
|
||||
+ mysql_close(mysql);
|
||||
+ del_identifier(id,AST_MYSQL_ID_CONNID);
|
||||
+ }
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static int MYSQL_exec(struct ast_channel *chan, void *data)
|
||||
+{
|
||||
+ struct localuser *u;
|
||||
+ int result;
|
||||
+ char sresult[10];
|
||||
+
|
||||
+#if EXTRA_LOG
|
||||
+ fprintf(stderr,"MYSQL_exec: data=%s\n",(char*)data);
|
||||
+#endif
|
||||
+
|
||||
+ if (!data) {
|
||||
+ ast_log(LOG_WARNING, "APP_MYSQL requires an argument (see manual)\n");
|
||||
+ return -1;
|
||||
+ }
|
||||
+
|
||||
+ LOCAL_USER_ADD(u);
|
||||
+ result=0;
|
||||
+
|
||||
+ ast_mutex_lock(&_mysql_mutex);
|
||||
+
|
||||
+ if (strncasecmp("connect",data,strlen("connect"))==0) {
|
||||
+ result=aMYSQL_connect(chan,ast_strdupa(data));
|
||||
+ } else if (strncasecmp("query",data,strlen("query"))==0) {
|
||||
+ result=aMYSQL_query(chan,ast_strdupa(data));
|
||||
+ } else if (strncasecmp("fetch",data,strlen("fetch"))==0) {
|
||||
+ result=aMYSQL_fetch(chan,ast_strdupa(data));
|
||||
+ } else if (strncasecmp("clear",data,strlen("clear"))==0) {
|
||||
+ result=aMYSQL_clear(chan,ast_strdupa(data));
|
||||
+ } else if (strncasecmp("disconnect",data,strlen("disconnect"))==0) {
|
||||
+ result=aMYSQL_disconnect(chan,ast_strdupa(data));
|
||||
+ } else {
|
||||
+ ast_log(LOG_WARNING, "Unknown argument to MYSQL application : %s\n",(char *)data);
|
||||
+ result=-1;
|
||||
+ }
|
||||
+
|
||||
+ ast_mutex_unlock(&_mysql_mutex);
|
||||
+
|
||||
+ LOCAL_USER_REMOVE(u);
|
||||
+ snprintf(sresult, sizeof(sresult), "%d", result);
|
||||
+ pbx_builtin_setvar_helper(chan, "MYSQL_STATUS", sresult);
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+int unload_module(void)
|
||||
+{
|
||||
+ STANDARD_HANGUP_LOCALUSERS;
|
||||
+ return ast_unregister_application(app);
|
||||
+}
|
||||
+
|
||||
+int load_module(void)
|
||||
+{
|
||||
+ struct MYSQLidshead *headp = &_mysql_ids_head;
|
||||
+ AST_LIST_HEAD_INIT(headp);
|
||||
+ return ast_register_application(app, MYSQL_exec, synopsis, descrip);
|
||||
+}
|
||||
+
|
||||
+char *description(void)
|
||||
+{
|
||||
+ return tdesc;
|
||||
+}
|
||||
+
|
||||
+int usecount(void)
|
||||
+{
|
||||
+ int res;
|
||||
+ STANDARD_USECOUNT(res);
|
||||
+ return res;
|
||||
+}
|
||||
+
|
||||
+char *key()
|
||||
+{
|
||||
+ return ASTERISK_GPL_KEY;
|
||||
+}
|
|
@ -0,0 +1,522 @@
|
|||
diff -ruN asterisk-1.2.0-old/configs/cdr_mysql.conf.sample asterisk-1.2.0-new/configs/cdr_mysql.conf.sample
|
||||
--- asterisk-1.2.0-old/configs/cdr_mysql.conf.sample 1970-01-01 01:00:00.000000000 +0100
|
||||
+++ asterisk-1.2.0-new/configs/cdr_mysql.conf.sample 2005-01-21 02:43:20.000000000 +0100
|
||||
@@ -0,0 +1,21 @@
|
||||
+;
|
||||
+; Note - if the database server is hosted on the same machine as the
|
||||
+; asterisk server, you can achieve a local Unix socket connection by
|
||||
+; setting hostname=localhost
|
||||
+;
|
||||
+; port and sock are both optional parameters. If hostname is specified
|
||||
+; and is not "localhost", then cdr_mysql will attempt to connect to the
|
||||
+; port specified or use the default port. If hostname is not specified
|
||||
+; or if hostname is "localhost", then cdr_mysql will attempt to connect
|
||||
+; to the socket file specified by sock or otherwise use the default socket
|
||||
+; file.
|
||||
+;
|
||||
+;[global]
|
||||
+;hostname=database.host.name
|
||||
+;dbname=asteriskcdrdb
|
||||
+;table=cdr
|
||||
+;password=password
|
||||
+;user=asteriskcdruser
|
||||
+;port=3306
|
||||
+;sock=/tmp/mysql.sock
|
||||
+;userfield=1
|
||||
diff -ruN asterisk-1.2.0-old/cdr/cdr_mysql.c asterisk-1.2.0-new/cdr/cdr_mysql.c
|
||||
--- asterisk-1.2.0-old/cdr/cdr_mysql.c 1970-01-01 01:00:00.000000000 +0100
|
||||
+++ asterisk-1.2.0-new/cdr/cdr_mysql.c 2005-12-04 20:10:59.000000000 +0100
|
||||
@@ -0,0 +1,493 @@
|
||||
+/*
|
||||
+ * Asterisk -- A telephony toolkit for Linux.
|
||||
+ *
|
||||
+ * MySQL CDR logger
|
||||
+ *
|
||||
+ * James Sharp <jsharp@psychoses.org>
|
||||
+ *
|
||||
+ * Modified August 2003
|
||||
+ * Tilghman Lesher <asterisk__cdr__cdr_mysql__200308@the-tilghman.com>
|
||||
+ *
|
||||
+ * Modified August 6, 2005
|
||||
+ * Joseph Benden <joe@thrallingpenguin.com>
|
||||
+ * Added mysql connection timeout parameter
|
||||
+ * Added an automatic reconnect as to not lose a cdr record
|
||||
+ * Cleaned up the original code to match the coding guidelines
|
||||
+ *
|
||||
+ * This program is free software, distributed under the terms of
|
||||
+ * the GNU General Public License.
|
||||
+ *
|
||||
+ */
|
||||
+
|
||||
+#include <sys/types.h>
|
||||
+
|
||||
+#include <stdio.h>
|
||||
+#include <string.h>
|
||||
+
|
||||
+#include <stdlib.h>
|
||||
+#include <unistd.h>
|
||||
+#include <time.h>
|
||||
+
|
||||
+#include <mysql.h>
|
||||
+#include <errmsg.h>
|
||||
+
|
||||
+#include <sys/stat.h>
|
||||
+#include <sys/types.h>
|
||||
+#include <errno.h>
|
||||
+
|
||||
+#include <asterisk/config.h>
|
||||
+#include <asterisk/options.h>
|
||||
+#include <asterisk/channel.h>
|
||||
+#include <asterisk/cdr.h>
|
||||
+#include <asterisk/module.h>
|
||||
+#include <asterisk/logger.h>
|
||||
+#include <asterisk/cli.h>
|
||||
+
|
||||
+#define DATE_FORMAT "%Y-%m-%d %T"
|
||||
+
|
||||
+static char *desc = "MySQL CDR Backend";
|
||||
+static char *name = "mysql";
|
||||
+static char *config = "cdr_mysql.conf";
|
||||
+static char *hostname = NULL, *dbname = NULL, *dbuser = NULL, *password = NULL, *dbsock = NULL, *dbtable = NULL;
|
||||
+static int hostname_alloc = 0, dbname_alloc = 0, dbuser_alloc = 0, password_alloc = 0, dbsock_alloc = 0, dbtable_alloc = 0;
|
||||
+static int dbport = 0;
|
||||
+static int connected = 0;
|
||||
+static time_t connect_time = 0;
|
||||
+static int records = 0;
|
||||
+static int totalrecords = 0;
|
||||
+static int userfield = 0;
|
||||
+static unsigned int timeout = 0;
|
||||
+
|
||||
+AST_MUTEX_DEFINE_STATIC(mysql_lock);
|
||||
+
|
||||
+static MYSQL mysql;
|
||||
+
|
||||
+static char cdr_mysql_status_help[] =
|
||||
+"Usage: cdr mysql status\n"
|
||||
+" Shows current connection status for cdr_mysql\n";
|
||||
+
|
||||
+static int handle_cdr_mysql_status(int fd, int argc, char *argv[])
|
||||
+{
|
||||
+ if (connected) {
|
||||
+ char status[256], status2[100] = "";
|
||||
+ int ctime = time(NULL) - connect_time;
|
||||
+ if (dbport)
|
||||
+ snprintf(status, 255, "Connected to %s@%s, port %d", dbname, hostname, dbport);
|
||||
+ else if (dbsock)
|
||||
+ snprintf(status, 255, "Connected to %s on socket file %s", dbname, dbsock);
|
||||
+ else
|
||||
+ snprintf(status, 255, "Connected to %s@%s", dbname, hostname);
|
||||
+
|
||||
+ if (dbuser && *dbuser)
|
||||
+ snprintf(status2, 99, " with username %s", dbuser);
|
||||
+ if (dbtable && *dbtable)
|
||||
+ snprintf(status2, 99, " using table %s", dbtable);
|
||||
+ if (ctime > 31536000) {
|
||||
+ ast_cli(fd, "%s%s for %d years, %d days, %d hours, %d minutes, %d seconds.\n", status, status2, ctime / 31536000, (ctime % 31536000) / 86400, (ctime % 86400) / 3600, (ctime % 3600) / 60, ctime % 60);
|
||||
+ } else if (ctime > 86400) {
|
||||
+ ast_cli(fd, "%s%s for %d days, %d hours, %d minutes, %d seconds.\n", status, status2, ctime / 86400, (ctime % 86400) / 3600, (ctime % 3600) / 60, ctime % 60);
|
||||
+ } else if (ctime > 3600) {
|
||||
+ ast_cli(fd, "%s%s for %d hours, %d minutes, %d seconds.\n", status, status2, ctime / 3600, (ctime % 3600) / 60, ctime % 60);
|
||||
+ } else if (ctime > 60) {
|
||||
+ ast_cli(fd, "%s%s for %d minutes, %d seconds.\n", status, status2, ctime / 60, ctime % 60);
|
||||
+ } else {
|
||||
+ ast_cli(fd, "%s%s for %d seconds.\n", status, status2, ctime);
|
||||
+ }
|
||||
+ if (records == totalrecords)
|
||||
+ ast_cli(fd, " Wrote %d records since last restart.\n", totalrecords);
|
||||
+ else
|
||||
+ ast_cli(fd, " Wrote %d records since last restart and %d records since last reconnect.\n", totalrecords, records);
|
||||
+ return RESULT_SUCCESS;
|
||||
+ } else {
|
||||
+ ast_cli(fd, "Not currently connected to a MySQL server.\n");
|
||||
+ return RESULT_FAILURE;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+static struct ast_cli_entry cdr_mysql_status_cli =
|
||||
+ { { "cdr", "mysql", "status", NULL },
|
||||
+ handle_cdr_mysql_status, "Show connection status of cdr_mysql",
|
||||
+ cdr_mysql_status_help, NULL };
|
||||
+
|
||||
+static int mysql_log(struct ast_cdr *cdr)
|
||||
+{
|
||||
+ struct tm tm;
|
||||
+ struct timeval tv;
|
||||
+ struct localuser *u;
|
||||
+ char *userfielddata = NULL;
|
||||
+ char sqlcmd[2048], timestr[128];
|
||||
+ char *clid=NULL, *dcontext=NULL, *channel=NULL, *dstchannel=NULL, *lastapp=NULL, *lastdata=NULL;
|
||||
+ int retries = 5;
|
||||
+#ifdef MYSQL_LOGUNIQUEID
|
||||
+ char *uniqueid = NULL;
|
||||
+#endif
|
||||
+
|
||||
+ ast_mutex_lock(&mysql_lock);
|
||||
+
|
||||
+ memset(sqlcmd, 0, 2048);
|
||||
+
|
||||
+ localtime_r(&cdr->start.tv_sec, &tm);
|
||||
+ strftime(timestr, 128, DATE_FORMAT, &tm);
|
||||
+
|
||||
+db_reconnect:
|
||||
+ if ((!connected) && (hostname || dbsock) && dbuser && password && dbname && dbtable ) {
|
||||
+ /* Attempt to connect */
|
||||
+ mysql_init(&mysql);
|
||||
+ /* Add option to quickly timeout the connection */
|
||||
+ if (timeout && mysql_options(&mysql, MYSQL_OPT_CONNECT_TIMEOUT, (char *)&timeout)!=0) {
|
||||
+ ast_log(LOG_ERROR, "cdr_mysql: mysql_options returned (%d) %s\n", mysql_errno(&mysql), mysql_error(&mysql));
|
||||
+ }
|
||||
+ if (mysql_real_connect(&mysql, hostname, dbuser, password, dbname, dbport, dbsock, 0)) {
|
||||
+ connected = 1;
|
||||
+ connect_time = time(NULL);
|
||||
+ records = 0;
|
||||
+ } else {
|
||||
+ ast_log(LOG_ERROR, "cdr_mysql: cannot connect to database server %s.\n", hostname);
|
||||
+ connected = 0;
|
||||
+ }
|
||||
+ } else {
|
||||
+ /* Long connection - ping the server */
|
||||
+ int error;
|
||||
+ if ((error = mysql_ping(&mysql))) {
|
||||
+ connected = 0;
|
||||
+ records = 0;
|
||||
+ switch (error) {
|
||||
+ case CR_SERVER_GONE_ERROR:
|
||||
+ case CR_SERVER_LOST:
|
||||
+ ast_log(LOG_ERROR, "cdr_mysql: Server has gone away. Attempting to reconnect.\n");
|
||||
+ break;
|
||||
+ default:
|
||||
+ ast_log(LOG_ERROR, "cdr_mysql: Unknown connection error: (%d) %s\n", mysql_errno(&mysql), mysql_error(&mysql));
|
||||
+ }
|
||||
+ retries--;
|
||||
+ if (retries)
|
||||
+ goto db_reconnect;
|
||||
+ else
|
||||
+ ast_log(LOG_ERROR, "cdr_mysql: Retried to connect fives times, giving up.\n");
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ /* Maximum space needed would be if all characters needed to be escaped, plus a trailing NULL */
|
||||
+ /* WARNING: This code previously used mysql_real_escape_string, but the use of said function
|
||||
+ requires an active connection to a database. If we are not connected, then this function
|
||||
+ cannot be used. This is a problem since we need to store off the SQL statement into our
|
||||
+ spool file for later restoration.
|
||||
+ So the question is, what's the best way to handle this? This works for now.
|
||||
+ */
|
||||
+ if ((clid = alloca(strlen(cdr->clid) * 2 + 1)) != NULL)
|
||||
+ mysql_escape_string(clid, cdr->clid, strlen(cdr->clid));
|
||||
+ if ((dcontext = alloca(strlen(cdr->dcontext) * 2 + 1)) != NULL)
|
||||
+ mysql_escape_string(dcontext, cdr->dcontext, strlen(cdr->dcontext));
|
||||
+ if ((channel = alloca(strlen(cdr->channel) * 2 + 1)) != NULL)
|
||||
+ mysql_escape_string(channel, cdr->channel, strlen(cdr->channel));
|
||||
+ if ((dstchannel = alloca(strlen(cdr->dstchannel) * 2 + 1)) != NULL)
|
||||
+ mysql_escape_string(dstchannel, cdr->dstchannel, strlen(cdr->dstchannel));
|
||||
+ if ((lastapp = alloca(strlen(cdr->lastapp) * 2 + 1)) != NULL)
|
||||
+ mysql_escape_string(lastapp, cdr->lastapp, strlen(cdr->lastapp));
|
||||
+ if ((lastdata = alloca(strlen(cdr->lastdata) * 2 + 1)) != NULL)
|
||||
+ mysql_escape_string(lastdata, cdr->lastdata, strlen(cdr->lastdata));
|
||||
+#ifdef MYSQL_LOGUNIQUEID
|
||||
+ if ((uniqueid = alloca(strlen(cdr->uniqueid) * 2 + 1)) != NULL)
|
||||
+ mysql_escape_string(uniqueid, cdr->uniqueid, strlen(cdr->uniqueid));
|
||||
+#endif
|
||||
+ if (userfield && ((userfielddata = alloca(strlen(cdr->userfield) * 2 + 1)) != NULL))
|
||||
+ mysql_escape_string(userfielddata, cdr->userfield, strlen(cdr->userfield));
|
||||
+
|
||||
+ /* Check for all alloca failures above at once */
|
||||
+#ifdef MYSQL_LOGUNIQUEID
|
||||
+ if ((!clid) || (!dcontext) || (!channel) || (!dstchannel) || (!lastapp) || (!lastdata) || (!uniqueid)) {
|
||||
+#else
|
||||
+ if ((!clid) || (!dcontext) || (!channel) || (!dstchannel) || (!lastapp) || (!lastdata)) {
|
||||
+#endif
|
||||
+ ast_log(LOG_ERROR, "cdr_mysql: Out of memory error (insert fails)\n");
|
||||
+ ast_mutex_unlock(&mysql_lock);
|
||||
+ return -1;
|
||||
+ }
|
||||
+
|
||||
+ ast_log(LOG_DEBUG, "cdr_mysql: inserting a CDR record.\n");
|
||||
+
|
||||
+ if (userfield && userfielddata) {
|
||||
+#ifdef MYSQL_LOGUNIQUEID
|
||||
+ sprintf(sqlcmd, "INSERT INTO %s (calldate,clid,src,dst,dcontext,channel,dstchannel,lastapp,lastdata,duration,billsec,disposition,amaflags,accountcode,uniqueid,userfield) VALUES ('%s','%s','%s','%s','%s', '%s','%s','%s','%s',%i,%i,'%s',%i,'%s','%s','%s')", dbtable, timestr, clid, cdr->src, cdr->dst, dcontext, channel, dstchannel, lastapp, lastdata, cdr->duration, cdr->billsec, ast_cdr_disp2str(cdr->disposition), cdr->amaflags, cdr->accountcode, uniqueid, userfielddata);
|
||||
+#else
|
||||
+ sprintf(sqlcmd, "INSERT INTO %s (calldate,clid,src,dst,dcontext,channel,dstchannel,lastapp,lastdata,duration,billsec,disposition,amaflags,accountcode,userfield) VALUES ('%s','%s','%s','%s','%s', '%s','%s','%s','%s',%i,%i,'%s',%i,'%s','%s')", dbtable, timestr, clid, cdr->src, cdr->dst, dcontext,channel, dstchannel, lastapp, lastdata, cdr->duration, cdr->billsec, ast_cdr_disp2str(cdr->disposition), cdr->amaflags, cdr->accountcode, userfielddata);
|
||||
+#endif
|
||||
+ } else {
|
||||
+#ifdef MYSQL_LOGUNIQUEID
|
||||
+ sprintf(sqlcmd, "INSERT INTO %s (calldate,clid,src,dst,dcontext,channel,dstchannel,lastapp,lastdata,duration,billsec,disposition,amaflags,accountcode,uniqueid) VALUES ('%s','%s','%s','%s','%s', '%s','%s','%s','%s',%i,%i,'%s',%i,'%s','%s')", dbtable, timestr, clid, cdr->src, cdr->dst, dcontext,channel, dstchannel, lastapp, lastdata, cdr->duration, cdr->billsec, ast_cdr_disp2str(cdr->disposition), cdr->amaflags, cdr->accountcode, uniqueid);
|
||||
+#else
|
||||
+ sprintf(sqlcmd, "INSERT INTO %s (calldate,clid,src,dst,dcontext,channel,dstchannel,lastapp,lastdata,duration,billsec,disposition,amaflags,accountcode) VALUES ('%s','%s','%s','%s','%s', '%s','%s','%s','%s',%i,%i,'%s',%i,'%s')", dbtable, timestr, clid, cdr->src, cdr->dst, dcontext, channel, dstchannel, lastapp, lastdata, cdr->duration, cdr->billsec, ast_cdr_disp2str(cdr->disposition), cdr->amaflags, cdr->accountcode);
|
||||
+#endif
|
||||
+ }
|
||||
+
|
||||
+ ast_log(LOG_DEBUG, "cdr_mysql: SQL command as follows: %s\n", sqlcmd);
|
||||
+
|
||||
+ if (connected) {
|
||||
+ if (mysql_real_query(&mysql, sqlcmd, strlen(sqlcmd))) {
|
||||
+ ast_log(LOG_ERROR, "mysql_cdr: Failed to insert into database: (%d) %s", mysql_errno(&mysql), mysql_error(&mysql));
|
||||
+ connected = 0;
|
||||
+ } else {
|
||||
+ records++;
|
||||
+ totalrecords++;
|
||||
+ }
|
||||
+ }
|
||||
+ ast_mutex_unlock(&mysql_lock);
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+char *description(void)
|
||||
+{
|
||||
+ return desc;
|
||||
+}
|
||||
+
|
||||
+static int my_unload_module(void)
|
||||
+{
|
||||
+ ast_cli_unregister(&cdr_mysql_status_cli);
|
||||
+ if (connected) {
|
||||
+ mysql_close(&mysql);
|
||||
+ connected = 0;
|
||||
+ records = 0;
|
||||
+ }
|
||||
+ if (hostname && hostname_alloc) {
|
||||
+ free(hostname);
|
||||
+ hostname = NULL;
|
||||
+ hostname_alloc = 0;
|
||||
+ }
|
||||
+ if (dbname && dbname_alloc) {
|
||||
+ free(dbname);
|
||||
+ dbname = NULL;
|
||||
+ dbname_alloc = 0;
|
||||
+ }
|
||||
+ if (dbuser && dbuser_alloc) {
|
||||
+ free(dbuser);
|
||||
+ dbuser = NULL;
|
||||
+ dbuser_alloc = 0;
|
||||
+ }
|
||||
+ if (dbsock && dbsock_alloc) {
|
||||
+ free(dbsock);
|
||||
+ dbsock = NULL;
|
||||
+ dbsock_alloc = 0;
|
||||
+ }
|
||||
+ if (dbtable && dbtable_alloc) {
|
||||
+ free(dbtable);
|
||||
+ dbtable = NULL;
|
||||
+ dbtable_alloc = 0;
|
||||
+ }
|
||||
+ if (password && password_alloc) {
|
||||
+ free(password);
|
||||
+ password = NULL;
|
||||
+ password_alloc = 0;
|
||||
+ }
|
||||
+ dbport = 0;
|
||||
+ ast_cdr_unregister(name);
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static int my_load_module(void)
|
||||
+{
|
||||
+ int res;
|
||||
+ struct ast_config *cfg;
|
||||
+ struct ast_variable *var;
|
||||
+ char *tmp;
|
||||
+
|
||||
+ cfg = ast_config_load(config);
|
||||
+ if (!cfg) {
|
||||
+ ast_log(LOG_WARNING, "Unable to load config for mysql CDR's: %s\n", config);
|
||||
+ return 0;
|
||||
+ }
|
||||
+
|
||||
+ var = ast_variable_browse(cfg, "global");
|
||||
+ if (!var) {
|
||||
+ /* nothing configured */
|
||||
+ return 0;
|
||||
+ }
|
||||
+
|
||||
+ tmp = ast_variable_retrieve(cfg, "global", "hostname");
|
||||
+ if (tmp) {
|
||||
+ hostname = malloc(strlen(tmp) + 1);
|
||||
+ if (hostname != NULL) {
|
||||
+ hostname_alloc = 1;
|
||||
+ strcpy(hostname, tmp);
|
||||
+ } else {
|
||||
+ ast_log(LOG_ERROR, "Out of memory error.\n");
|
||||
+ return -1;
|
||||
+ }
|
||||
+ } else {
|
||||
+ ast_log(LOG_WARNING, "MySQL server hostname not specified. Assuming localhost\n");
|
||||
+ hostname = "localhost";
|
||||
+ }
|
||||
+
|
||||
+ tmp = ast_variable_retrieve(cfg, "global", "dbname");
|
||||
+ if (tmp) {
|
||||
+ dbname = malloc(strlen(tmp) + 1);
|
||||
+ if (dbname != NULL) {
|
||||
+ dbname_alloc = 1;
|
||||
+ strcpy(dbname, tmp);
|
||||
+ } else {
|
||||
+ ast_log(LOG_ERROR, "Out of memory error.\n");
|
||||
+ return -1;
|
||||
+ }
|
||||
+ } else {
|
||||
+ ast_log(LOG_WARNING, "MySQL database not specified. Assuming asteriskcdrdb\n");
|
||||
+ dbname = "asteriskcdrdb";
|
||||
+ }
|
||||
+
|
||||
+ tmp = ast_variable_retrieve(cfg, "global", "user");
|
||||
+ if (tmp) {
|
||||
+ dbuser = malloc(strlen(tmp) + 1);
|
||||
+ if (dbuser != NULL) {
|
||||
+ dbuser_alloc = 1;
|
||||
+ strcpy(dbuser, tmp);
|
||||
+ } else {
|
||||
+ ast_log(LOG_ERROR, "Out of memory error.\n");
|
||||
+ return -1;
|
||||
+ }
|
||||
+ } else {
|
||||
+ ast_log(LOG_WARNING, "MySQL database user not specified. Assuming root\n");
|
||||
+ dbuser = "root";
|
||||
+ }
|
||||
+
|
||||
+ tmp = ast_variable_retrieve(cfg, "global", "sock");
|
||||
+ if (tmp) {
|
||||
+ dbsock = malloc(strlen(tmp) + 1);
|
||||
+ if (dbsock != NULL) {
|
||||
+ dbsock_alloc = 1;
|
||||
+ strcpy(dbsock, tmp);
|
||||
+ } else {
|
||||
+ ast_log(LOG_ERROR, "Out of memory error.\n");
|
||||
+ return -1;
|
||||
+ }
|
||||
+ } else {
|
||||
+ ast_log(LOG_WARNING, "MySQL database sock file not specified. Using default\n");
|
||||
+ dbsock = NULL;
|
||||
+ }
|
||||
+
|
||||
+ tmp = ast_variable_retrieve(cfg, "global", "table");
|
||||
+ if (tmp) {
|
||||
+ dbtable = malloc(strlen(tmp) + 1);
|
||||
+ if (dbtable != NULL) {
|
||||
+ dbtable_alloc = 1;
|
||||
+ strcpy(dbtable, tmp);
|
||||
+ } else {
|
||||
+ ast_log(LOG_ERROR, "Out of memory error.\n");
|
||||
+ return -1;
|
||||
+ }
|
||||
+ } else {
|
||||
+ ast_log(LOG_NOTICE, "MySQL database table not specified. Assuming \"cdr\"\n");
|
||||
+ dbtable = "cdr";
|
||||
+ }
|
||||
+
|
||||
+ tmp = ast_variable_retrieve(cfg, "global", "password");
|
||||
+ if (tmp) {
|
||||
+ password = malloc(strlen(tmp) + 1);
|
||||
+ if (password != NULL) {
|
||||
+ password_alloc = 1;
|
||||
+ strcpy(password, tmp);
|
||||
+ } else {
|
||||
+ ast_log(LOG_ERROR, "Out of memory error.\n");
|
||||
+ return -1;
|
||||
+ }
|
||||
+ } else {
|
||||
+ ast_log(LOG_WARNING, "MySQL database password not specified. Assuming blank\n");
|
||||
+ password = "";
|
||||
+ }
|
||||
+
|
||||
+ tmp = ast_variable_retrieve(cfg, "global", "port");
|
||||
+ if (tmp) {
|
||||
+ if (sscanf(tmp, "%d", &dbport) < 1) {
|
||||
+ ast_log(LOG_WARNING, "Invalid MySQL port number. Using default\n");
|
||||
+ dbport = 0;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ tmp = ast_variable_retrieve(cfg, "global", "timeout");
|
||||
+ if (tmp) {
|
||||
+ if (sscanf(tmp,"%d", &timeout) < 1) {
|
||||
+ ast_log(LOG_WARNING, "Invalid MySQL timeout number. Using default\n");
|
||||
+ timeout = 0;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ tmp = ast_variable_retrieve(cfg, "global", "userfield");
|
||||
+ if (tmp) {
|
||||
+ if (sscanf(tmp, "%d", &userfield) < 1) {
|
||||
+ ast_log(LOG_WARNING, "Invalid MySQL configurtation file\n");
|
||||
+ userfield = 0;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ ast_config_destroy(cfg);
|
||||
+
|
||||
+ ast_log(LOG_DEBUG, "cdr_mysql: got hostname of %s\n", hostname);
|
||||
+ ast_log(LOG_DEBUG, "cdr_mysql: got port of %d\n", dbport);
|
||||
+ ast_log(LOG_DEBUG, "cdr_mysql: got a timeout of %d\n", timeout);
|
||||
+ if (dbsock)
|
||||
+ ast_log(LOG_DEBUG, "cdr_mysql: got sock file of %s\n", dbsock);
|
||||
+ ast_log(LOG_DEBUG, "cdr_mysql: got user of %s\n", dbuser);
|
||||
+ ast_log(LOG_DEBUG, "cdr_mysql: got dbname of %s\n", dbname);
|
||||
+ ast_log(LOG_DEBUG, "cdr_mysql: got password of %s\n", password);
|
||||
+
|
||||
+ mysql_init(&mysql);
|
||||
+
|
||||
+ if (timeout && mysql_options(&mysql, MYSQL_OPT_CONNECT_TIMEOUT, (char *)&timeout)!=0) {
|
||||
+ ast_log(LOG_ERROR, "cdr_mysql: mysql_options returned (%d) %s\n", mysql_errno(&mysql), mysql_error(&mysql));
|
||||
+ }
|
||||
+
|
||||
+ if (!mysql_real_connect(&mysql, hostname, dbuser, password, dbname, dbport, dbsock, 0)) {
|
||||
+ ast_log(LOG_ERROR, "Failed to connect to mysql database %s on %s.\n", dbname, hostname);
|
||||
+ connected = 0;
|
||||
+ records = 0;
|
||||
+ } else {
|
||||
+ ast_log(LOG_DEBUG, "Successfully connected to MySQL database.\n");
|
||||
+ connected = 1;
|
||||
+ records = 0;
|
||||
+ connect_time = time(NULL);
|
||||
+ }
|
||||
+
|
||||
+ res = ast_cdr_register(name, desc, mysql_log);
|
||||
+ if (res) {
|
||||
+ ast_log(LOG_ERROR, "Unable to register MySQL CDR handling\n");
|
||||
+ } else {
|
||||
+ res = ast_cli_register(&cdr_mysql_status_cli);
|
||||
+ }
|
||||
+
|
||||
+ return res;
|
||||
+}
|
||||
+
|
||||
+int load_module(void)
|
||||
+{
|
||||
+ return my_load_module();
|
||||
+}
|
||||
+
|
||||
+int unload_module(void)
|
||||
+{
|
||||
+ return my_unload_module();
|
||||
+}
|
||||
+
|
||||
+int reload(void)
|
||||
+{
|
||||
+ int ret;
|
||||
+
|
||||
+ ast_mutex_lock(&mysql_lock);
|
||||
+ my_unload_module();
|
||||
+ ret = my_load_module();
|
||||
+ ast_mutex_unlock(&mysql_lock);
|
||||
+
|
||||
+ return ret;
|
||||
+}
|
||||
+
|
||||
+int usecount(void)
|
||||
+{
|
||||
+ /* Simplistic use count */
|
||||
+ if (ast_mutex_trylock(&mysql_lock)) {
|
||||
+ return 1;
|
||||
+ } else {
|
||||
+ ast_mutex_unlock(&mysql_lock);
|
||||
+ return 0;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+char *key()
|
||||
+{
|
||||
+ return ASTERISK_GPL_KEY;
|
||||
+}
|
|
@ -0,0 +1,11 @@
|
|||
diff -ruN asterisk-1.2.0-old/channels/chan_bluetooth.c asterisk-1.2.0-new/channels/chan_bluetooth.c
|
||||
--- asterisk-1.2.0-old/channels/chan_bluetooth.c 2005-12-04 04:48:40.000000000 +0100
|
||||
+++ asterisk-1.2.0-new/channels/chan_bluetooth.c 2005-12-04 23:07:19.000000000 +0100
|
||||
@@ -104,6 +104,7 @@
|
||||
#include <asterisk/options.h>
|
||||
#include <asterisk/cli.h>
|
||||
#include <asterisk/callerid.h>
|
||||
+#include <asterisk/version.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/signal.h>
|
||||
#include <sys/time.h>
|
|
@ -0,0 +1,13 @@
|
|||
diff -ruN asterisk-1.2.0-old/include/asterisk/compat.h asterisk-1.2.0-new/include/asterisk/compat.h
|
||||
--- asterisk-1.2.0-old/include/asterisk/compat.h 2005-11-08 05:13:19.000000000 +0100
|
||||
+++ asterisk-1.2.0-new/include/asterisk/compat.h 2005-12-04 05:32:31.000000000 +0100
|
||||
@@ -75,7 +75,9 @@
|
||||
#define HAVE_STRTOQ
|
||||
|
||||
#ifdef _BSD_SOURCE
|
||||
+#ifndef __UCLIBC__
|
||||
#define HAVE_GETLOADAVG
|
||||
+#endif /* __UCLIBC__ */
|
||||
#endif
|
||||
|
||||
#ifdef __linux__
|
|
@ -0,0 +1,698 @@
|
|||
diff -ruN asterisk-1.2.0-old/configs/res_mysql.conf.sample asterisk-1.2.0-new/configs/res_mysql.conf.sample
|
||||
--- asterisk-1.2.0-old/configs/res_mysql.conf.sample 1970-01-01 01:00:00.000000000 +0100
|
||||
+++ asterisk-1.2.0-new/configs/res_mysql.conf.sample 2004-12-03 15:33:44.000000000 +0100
|
||||
@@ -0,0 +1,15 @@
|
||||
+;
|
||||
+; Sample configuration for res_config_mysql.c
|
||||
+;
|
||||
+; The value of dbhost may be either a hostname or an IP address.
|
||||
+; If dbhost is commented out or the string "localhost", a connection
|
||||
+; to the local host is assumed and dbsock is used instead of TCP/IP
|
||||
+; to connect to the server.
|
||||
+;
|
||||
+[general]
|
||||
+;dbhost = 127.0.0.1
|
||||
+;dbname = asterisk
|
||||
+;dbuser = myuser
|
||||
+;dbpass = mypass
|
||||
+;dbport = 3306
|
||||
+;dbsock = /tmp/mysql.sock
|
||||
diff -ruN asterisk-1.2.0-old/res/res_config_mysql.c asterisk-1.2.0-new/res/res_config_mysql.c
|
||||
--- asterisk-1.2.0-old/res/res_config_mysql.c 1970-01-01 01:00:00.000000000 +0100
|
||||
+++ asterisk-1.2.0-new/res/res_config_mysql.c 2005-10-13 21:43:54.000000000 +0200
|
||||
@@ -0,0 +1,675 @@
|
||||
+/*
|
||||
+ * Asterisk -- A telephony toolkit for Linux.
|
||||
+ *
|
||||
+ * Copyright (C) 1999-2005, Digium, Inc.
|
||||
+ *
|
||||
+ * Mark Spencer <markster@digium.com> - Asterisk Author
|
||||
+ * Matthew Boehm <mboehm@cytelcom.com> - MySQL RealTime Driver Author
|
||||
+ *
|
||||
+ * res_config_mysql.c <mysql plugin for RealTime configuration engine>
|
||||
+ *
|
||||
+ * v2.0 - (10-07-05) - mutex_lock fixes (bug #4973, comment #0034602)
|
||||
+ *
|
||||
+ * v1.9 - (08-19-05) - Added support to correctly honor the family database specified
|
||||
+ * in extconfig.conf (bug #4973)
|
||||
+ *
|
||||
+ * v1.8 - (04-21-05) - Modified return values of update_mysql to better indicate
|
||||
+ * what really happened.
|
||||
+ *
|
||||
+ * v1.7 - (01-28-05) - Fixed non-initialization of ast_category struct
|
||||
+ * in realtime_multi_mysql function which caused segfault.
|
||||
+ *
|
||||
+ * v1.6 - (00-00-00) - Skipped to bring comments into sync with version number in CVS.
|
||||
+ *
|
||||
+ * v1.5.1 - (01-26-05) - Added better(?) locking stuff
|
||||
+ *
|
||||
+ * v1.5 - (01-26-05) - Brought up to date with new config.h changes (bug #3406)
|
||||
+ * - Added in extra locking provided by georg (bug #3248)
|
||||
+ *
|
||||
+ * v1.4 - (12-02-04) - Added realtime_multi_mysql function
|
||||
+ * This function will return an ast_config with categories,
|
||||
+ * unlike standard realtime_mysql which only returns
|
||||
+ * a linked list of ast_variables
|
||||
+ *
|
||||
+ * v1.3 - (12-01-04) - Added support other operators
|
||||
+ * Ex: =, !=, LIKE, NOT LIKE, RLIKE, etc...
|
||||
+ *
|
||||
+ * v1.2 - (11-DD-04) - Added reload. Updated load and unload.
|
||||
+ * Code beautification (doc/CODING-GUIDELINES)
|
||||
+ */
|
||||
+
|
||||
+#include <asterisk/channel.h>
|
||||
+#include <asterisk/logger.h>
|
||||
+#include <asterisk/config.h>
|
||||
+#include <asterisk/module.h>
|
||||
+#include <asterisk/lock.h>
|
||||
+#include <asterisk/options.h>
|
||||
+#include <asterisk/cli.h>
|
||||
+#include <asterisk/utils.h>
|
||||
+#include <stdlib.h>
|
||||
+#include <string.h>
|
||||
+#include <mysql.h>
|
||||
+#include <mysql_version.h>
|
||||
+#include <errmsg.h>
|
||||
+
|
||||
+static char *res_config_mysql_desc = "MySQL RealTime Configuration Driver";
|
||||
+
|
||||
+AST_MUTEX_DEFINE_STATIC(mysql_lock);
|
||||
+#define RES_CONFIG_MYSQL_CONF "res_mysql.conf"
|
||||
+MYSQL mysql;
|
||||
+static char dbhost[50];
|
||||
+static char dbuser[50];
|
||||
+static char dbpass[50];
|
||||
+static char dbname[50];
|
||||
+static char dbsock[50];
|
||||
+static int dbport;
|
||||
+static int connected;
|
||||
+static time_t connect_time;
|
||||
+
|
||||
+static int parse_config(void);
|
||||
+static int mysql_reconnect(const char *database);
|
||||
+static int realtime_mysql_status(int fd, int argc, char **argv);
|
||||
+
|
||||
+STANDARD_LOCAL_USER;
|
||||
+
|
||||
+LOCAL_USER_DECL;
|
||||
+
|
||||
+static char cli_realtime_mysql_status_usage[] =
|
||||
+"Usage: realtime mysql status\n"
|
||||
+" Shows connection information for the MySQL RealTime driver\n";
|
||||
+
|
||||
+static struct ast_cli_entry cli_realtime_mysql_status = {
|
||||
+ { "realtime", "mysql", "status", NULL }, realtime_mysql_status,
|
||||
+ "Shows connection information for the MySQL RealTime driver", cli_realtime_mysql_status_usage, NULL };
|
||||
+
|
||||
+static struct ast_variable *realtime_mysql(const char *database, const char *table, va_list ap)
|
||||
+{
|
||||
+ MYSQL_RES *result;
|
||||
+ MYSQL_ROW row;
|
||||
+ MYSQL_FIELD *fields;
|
||||
+ int numFields, i;
|
||||
+ char sql[256];
|
||||
+ char *stringp;
|
||||
+ char *chunk;
|
||||
+ char *op;
|
||||
+ const char *newparam, *newval;
|
||||
+ struct ast_variable *var=NULL, *prev=NULL;
|
||||
+
|
||||
+ if(!table) {
|
||||
+ ast_log(LOG_WARNING, "MySQL RealTime: No table specified.\n");
|
||||
+ return NULL;
|
||||
+ }
|
||||
+
|
||||
+ /* Get the first parameter and first value in our list of passed paramater/value pairs */
|
||||
+ newparam = va_arg(ap, const char *);
|
||||
+ newval = va_arg(ap, const char *);
|
||||
+ if(!newparam || !newval) {
|
||||
+ ast_log(LOG_WARNING, "MySQL RealTime: Realtime retrieval requires at least 1 parameter and 1 value to search on.\n");
|
||||
+ mysql_close(&mysql);
|
||||
+ return NULL;
|
||||
+ }
|
||||
+
|
||||
+ /* Create the first part of the query using the first parameter/value pairs we just extracted
|
||||
+ If there is only 1 set, then we have our query. Otherwise, loop thru the list and concat */
|
||||
+
|
||||
+ if(!strchr(newparam, ' ')) op = " ="; else op = "";
|
||||
+
|
||||
+ snprintf(sql, sizeof(sql), "SELECT * FROM %s WHERE %s%s '%s'", table, newparam, op, newval);
|
||||
+ while((newparam = va_arg(ap, const char *))) {
|
||||
+ newval = va_arg(ap, const char *);
|
||||
+ if(!strchr(newparam, ' ')) op = " ="; else op = "";
|
||||
+ snprintf(sql + strlen(sql), sizeof(sql) - strlen(sql), " AND %s%s '%s'", newparam, op, newval);
|
||||
+ }
|
||||
+ va_end(ap);
|
||||
+
|
||||
+ ast_log(LOG_DEBUG, "MySQL RealTime: Retrieve SQL: %s\n", sql);
|
||||
+
|
||||
+ /* We now have our complete statement; Lets connect to the server and execute it. */
|
||||
+ ast_mutex_lock(&mysql_lock);
|
||||
+ if(!mysql_reconnect(database)) {
|
||||
+ ast_mutex_unlock(&mysql_lock);
|
||||
+ return NULL;
|
||||
+ }
|
||||
+
|
||||
+ if(mysql_real_query(&mysql, sql, strlen(sql))) {
|
||||
+ ast_log(LOG_WARNING, "MySQL RealTime: Failed to query database. Check debug for more info.\n");
|
||||
+ ast_log(LOG_DEBUG, "MySQL RealTime: Query: %s\n", sql);
|
||||
+ ast_log(LOG_DEBUG, "MySQL RealTime: Query Failed because: %s\n", mysql_error(&mysql));
|
||||
+ ast_mutex_unlock(&mysql_lock);
|
||||
+ return NULL;
|
||||
+ }
|
||||
+
|
||||
+ if((result = mysql_store_result(&mysql))) {
|
||||
+ numFields = mysql_num_fields(result);
|
||||
+ fields = mysql_fetch_fields(result);
|
||||
+
|
||||
+ while((row = mysql_fetch_row(result))) {
|
||||
+ for(i = 0; i < numFields; i++) {
|
||||
+ stringp = row[i];
|
||||
+ while(stringp) {
|
||||
+ chunk = strsep(&stringp, ";");
|
||||
+ if(chunk && !ast_strlen_zero(ast_strip(chunk))) {
|
||||
+ if(prev) {
|
||||
+ prev->next = ast_variable_new(fields[i].name, chunk);
|
||||
+ if (prev->next) {
|
||||
+ prev = prev->next;
|
||||
+ }
|
||||
+ } else {
|
||||
+ prev = var = ast_variable_new(fields[i].name, chunk);
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ } else {
|
||||
+ ast_log(LOG_WARNING, "MySQL RealTime: Could not find any rows in table %s.\n", table);
|
||||
+ }
|
||||
+
|
||||
+ ast_mutex_unlock(&mysql_lock);
|
||||
+ mysql_free_result(result);
|
||||
+
|
||||
+ return var;
|
||||
+}
|
||||
+
|
||||
+static struct ast_config *realtime_multi_mysql(const char *database, const char *table, va_list ap)
|
||||
+{
|
||||
+ MYSQL_RES *result;
|
||||
+ MYSQL_ROW row;
|
||||
+ MYSQL_FIELD *fields;
|
||||
+ int numFields, i;
|
||||
+ char sql[256];
|
||||
+ const char *initfield = NULL;
|
||||
+ char *stringp;
|
||||
+ char *chunk;
|
||||
+ char *op;
|
||||
+ const char *newparam, *newval;
|
||||
+ struct ast_realloca ra;
|
||||
+ struct ast_variable *var=NULL;
|
||||
+ struct ast_config *cfg = NULL;
|
||||
+ struct ast_category *cat = NULL;
|
||||
+
|
||||
+ if(!table) {
|
||||
+ ast_log(LOG_WARNING, "MySQL RealTime: No table specified.\n");
|
||||
+ return NULL;
|
||||
+ }
|
||||
+
|
||||
+ memset(&ra, 0, sizeof(ra));
|
||||
+
|
||||
+ cfg = ast_config_new();
|
||||
+ if (!cfg) {
|
||||
+ /* If I can't alloc memory at this point, why bother doing anything else? */
|
||||
+ ast_log(LOG_WARNING, "Out of memory!\n");
|
||||
+ return NULL;
|
||||
+ }
|
||||
+
|
||||
+ /* Get the first parameter and first value in our list of passed paramater/value pairs */
|
||||
+ newparam = va_arg(ap, const char *);
|
||||
+ newval = va_arg(ap, const char *);
|
||||
+ if(!newparam || !newval) {
|
||||
+ ast_log(LOG_WARNING, "MySQL RealTime: Realtime retrieval requires at least 1 parameter and 1 value to search on.\n");
|
||||
+ mysql_close(&mysql);
|
||||
+ return NULL;
|
||||
+ }
|
||||
+
|
||||
+ initfield = ast_strdupa(newparam);
|
||||
+ if(initfield && (op = strchr(initfield, ' '))) {
|
||||
+ *op = '\0';
|
||||
+ }
|
||||
+
|
||||
+ /* Create the first part of the query using the first parameter/value pairs we just extracted
|
||||
+ If there is only 1 set, then we have our query. Otherwise, loop thru the list and concat */
|
||||
+
|
||||
+ if(!strchr(newparam, ' ')) op = " ="; else op = "";
|
||||
+
|
||||
+ snprintf(sql, sizeof(sql), "SELECT * FROM %s WHERE %s%s '%s'", table, newparam, op, newval);
|
||||
+ while((newparam = va_arg(ap, const char *))) {
|
||||
+ newval = va_arg(ap, const char *);
|
||||
+ if(!strchr(newparam, ' ')) op = " ="; else op = "";
|
||||
+ snprintf(sql + strlen(sql), sizeof(sql) - strlen(sql), " AND %s%s '%s'", newparam, op, newval);
|
||||
+ }
|
||||
+
|
||||
+ if(initfield) {
|
||||
+ snprintf(sql + strlen(sql), sizeof(sql) - strlen(sql), " ORDER BY %s", initfield);
|
||||
+ }
|
||||
+
|
||||
+ va_end(ap);
|
||||
+
|
||||
+ ast_log(LOG_DEBUG, "MySQL RealTime: Retrieve SQL: %s\n", sql);
|
||||
+
|
||||
+ /* We now have our complete statement; Lets connect to the server and execute it. */
|
||||
+ ast_mutex_lock(&mysql_lock);
|
||||
+ if(!mysql_reconnect(database)) {
|
||||
+ ast_mutex_unlock(&mysql_lock);
|
||||
+ return NULL;
|
||||
+ }
|
||||
+
|
||||
+ if(mysql_real_query(&mysql, sql, strlen(sql))) {
|
||||
+ ast_log(LOG_WARNING, "MySQL RealTime: Failed to query database. Check debug for more info.\n");
|
||||
+ ast_log(LOG_DEBUG, "MySQL RealTime: Query: %s\n", sql);
|
||||
+ ast_log(LOG_DEBUG, "MySQL RealTime: Query Failed because: %s\n", mysql_error(&mysql));
|
||||
+ ast_mutex_unlock(&mysql_lock);
|
||||
+ return NULL;
|
||||
+ }
|
||||
+
|
||||
+ if((result = mysql_store_result(&mysql))) {
|
||||
+ numFields = mysql_num_fields(result);
|
||||
+ fields = mysql_fetch_fields(result);
|
||||
+
|
||||
+ while((row = mysql_fetch_row(result))) {
|
||||
+ var = NULL;
|
||||
+ cat = ast_category_new("");
|
||||
+ if(!cat) {
|
||||
+ ast_log(LOG_WARNING, "Out of memory!\n");
|
||||
+ continue;
|
||||
+ }
|
||||
+ for(i = 0; i < numFields; i++) {
|
||||
+ stringp = row[i];
|
||||
+ while(stringp) {
|
||||
+ chunk = strsep(&stringp, ";");
|
||||
+ if(chunk && !ast_strlen_zero(ast_strip(chunk))) {
|
||||
+ if(initfield && !strcmp(initfield, fields[i].name)) {
|
||||
+ ast_category_rename(cat, chunk);
|
||||
+ }
|
||||
+ var = ast_variable_new(fields[i].name, chunk);
|
||||
+ ast_variable_append(cat, var);
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ ast_category_append(cfg, cat);
|
||||
+ }
|
||||
+ } else {
|
||||
+ ast_log(LOG_WARNING, "MySQL RealTime: Could not find any rows in table %s.\n", table);
|
||||
+ }
|
||||
+
|
||||
+ ast_mutex_unlock(&mysql_lock);
|
||||
+ mysql_free_result(result);
|
||||
+
|
||||
+ return cfg;
|
||||
+}
|
||||
+
|
||||
+static int update_mysql(const char *database, const char *table, const char *keyfield, const char *lookup, va_list ap)
|
||||
+{
|
||||
+ my_ulonglong numrows;
|
||||
+ char sql[256];
|
||||
+ const char *newparam, *newval;
|
||||
+
|
||||
+ if(!table) {
|
||||
+ ast_log(LOG_WARNING, "MySQL RealTime: No table specified.\n");
|
||||
+ return -1;
|
||||
+ }
|
||||
+
|
||||
+ /* Get the first parameter and first value in our list of passed paramater/value pairs */
|
||||
+ newparam = va_arg(ap, const char *);
|
||||
+ newval = va_arg(ap, const char *);
|
||||
+ if(!newparam || !newval) {
|
||||
+ ast_log(LOG_WARNING, "MySQL RealTime: Realtime retrieval requires at least 1 parameter and 1 value to search on.\n");
|
||||
+ mysql_close(&mysql);
|
||||
+ return -1;
|
||||
+ }
|
||||
+
|
||||
+ /* Create the first part of the query using the first parameter/value pairs we just extracted
|
||||
+ If there is only 1 set, then we have our query. Otherwise, loop thru the list and concat */
|
||||
+
|
||||
+ snprintf(sql, sizeof(sql), "UPDATE %s SET %s = '%s'", table, newparam, newval);
|
||||
+ while((newparam = va_arg(ap, const char *))) {
|
||||
+ newval = va_arg(ap, const char *);
|
||||
+ snprintf(sql + strlen(sql), sizeof(sql) - strlen(sql), ", %s = '%s'", newparam, newval);
|
||||
+ }
|
||||
+ va_end(ap);
|
||||
+ snprintf(sql + strlen(sql), sizeof(sql) - strlen(sql), " WHERE %s = '%s'", keyfield, lookup);
|
||||
+
|
||||
+ ast_log(LOG_DEBUG,"MySQL RealTime: Update SQL: %s\n", sql);
|
||||
+
|
||||
+ /* We now have our complete statement; Lets connect to the server and execute it. */
|
||||
+ ast_mutex_lock(&mysql_lock);
|
||||
+ if(!mysql_reconnect(database)) {
|
||||
+ ast_mutex_unlock(&mysql_lock);
|
||||
+ return -1;
|
||||
+ }
|
||||
+
|
||||
+ if(mysql_real_query(&mysql, sql, strlen(sql))) {
|
||||
+ ast_log(LOG_WARNING, "MySQL RealTime: Failed to query database. Check debug for more info.\n");
|
||||
+ ast_log(LOG_DEBUG, "MySQL RealTime: Query: %s\n", sql);
|
||||
+ ast_log(LOG_DEBUG, "MySQL RealTime: Query Failed because: %s\n", mysql_error(&mysql));
|
||||
+ ast_mutex_unlock(&mysql_lock);
|
||||
+ return -1;
|
||||
+ }
|
||||
+
|
||||
+ numrows = mysql_affected_rows(&mysql);
|
||||
+ ast_mutex_unlock(&mysql_lock);
|
||||
+
|
||||
+ ast_log(LOG_DEBUG,"MySQL RealTime: Updated %llu rows on table: %s\n", numrows, table);
|
||||
+
|
||||
+ /* From http://dev.mysql.com/doc/mysql/en/mysql-affected-rows.html
|
||||
+ * An integer greater than zero indicates the number of rows affected
|
||||
+ * Zero indicates that no records were updated
|
||||
+ * -1 indicates that the query returned an error (although, if the query failed, it should have been caught above.)
|
||||
+ */
|
||||
+
|
||||
+ if(numrows >= 0)
|
||||
+ return (int)numrows;
|
||||
+
|
||||
+ return -1;
|
||||
+}
|
||||
+
|
||||
+static struct ast_config *config_mysql(const char *database, const char *table, const char *file, struct ast_config *cfg)
|
||||
+{
|
||||
+ MYSQL_RES *result;
|
||||
+ MYSQL_ROW row;
|
||||
+ my_ulonglong num_rows;
|
||||
+ struct ast_config *new;
|
||||
+ struct ast_variable *cur_v, *new_v;
|
||||
+ struct ast_category *cur_cat, *new_cat;
|
||||
+ char sql[250] = "";
|
||||
+ char last[80] = "";
|
||||
+ int cat_started = 0;
|
||||
+ int var_started = 0;
|
||||
+ int last_cat_metric = 0;
|
||||
+
|
||||
+ last[0] = '\0';
|
||||
+
|
||||
+ if(!file || !strcmp(file, RES_CONFIG_MYSQL_CONF)) {
|
||||
+ ast_log(LOG_WARNING, "MySQL RealTime: Cannot configure myself.\n");
|
||||
+ return NULL;
|
||||
+ }
|
||||
+
|
||||
+ snprintf(sql, sizeof(sql), "SELECT category, var_name, var_val, cat_metric FROM %s WHERE filename='%s' and commented=0 ORDER BY filename, cat_metric desc, var_metric asc, category, var_name, var_val, id", table, file);
|
||||
+
|
||||
+ ast_log(LOG_DEBUG, "MySQL RealTime: Static SQL: %s\n", sql);
|
||||
+
|
||||
+ /* We now have our complete statement; Lets connect to the server and execute it. */
|
||||
+ ast_mutex_lock(&mysql_lock);
|
||||
+ if(!mysql_reconnect(database)) {
|
||||
+ ast_mutex_unlock(&mysql_lock);
|
||||
+ return NULL;
|
||||
+ }
|
||||
+
|
||||
+ if(mysql_real_query(&mysql, sql, strlen(sql))) {
|
||||
+ ast_log(LOG_WARNING, "MySQL RealTime: Failed to query database. Check debug for more info.\n");
|
||||
+ ast_log(LOG_DEBUG, "MySQL RealTime: Query: %s\n", sql);
|
||||
+ ast_log(LOG_DEBUG, "MySQL RealTime: Query Failed because: %s\n", mysql_error(&mysql));
|
||||
+ ast_mutex_unlock(&mysql_lock);
|
||||
+ return NULL;
|
||||
+ }
|
||||
+
|
||||
+ if((result = mysql_store_result(&mysql))) {
|
||||
+ num_rows = mysql_num_rows(result);
|
||||
+ ast_log(LOG_DEBUG, "MySQL RealTime: Found %llu rows.\n", num_rows);
|
||||
+
|
||||
+ /* There might exist a better way to access the column names other than counting,
|
||||
+ but I believe that would require another loop that we don't need. */
|
||||
+
|
||||
+ while((row = mysql_fetch_row(result))) {
|
||||
+ if(!strcmp(row[1], "#include")) {
|
||||
+ if (!ast_config_internal_load(row[2], cfg)) {
|
||||
+ mysql_free_result(result);
|
||||
+ ast_mutex_unlock(&mysql_lock);
|
||||
+ return NULL;
|
||||
+ }
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ if(strcmp(last, row[0]) || last_cat_metric != atoi(row[3])) {
|
||||
+ cur_cat = ast_category_new(row[0]);
|
||||
+ if (!cur_cat) {
|
||||
+ ast_log(LOG_WARNING, "Out of memory!\n");
|
||||
+ break;
|
||||
+ }
|
||||
+ strcpy(last, row[0]);
|
||||
+ last_cat_metric = atoi(row[3]);
|
||||
+ ast_category_append(cfg, cur_cat);
|
||||
+ }
|
||||
+ new_v = ast_variable_new(row[1], row[2]);
|
||||
+ ast_variable_append(cur_cat, new_v);
|
||||
+ }
|
||||
+ } else {
|
||||
+ ast_log(LOG_WARNING, "MySQL RealTime: Could not find config '%s' in database.\n", file);
|
||||
+ }
|
||||
+
|
||||
+ mysql_free_result(result);
|
||||
+ ast_mutex_unlock(&mysql_lock);
|
||||
+
|
||||
+ return cfg;
|
||||
+}
|
||||
+
|
||||
+static struct ast_config_engine mysql_engine = {
|
||||
+ .name = "mysql",
|
||||
+ .load_func = config_mysql,
|
||||
+ .realtime_func = realtime_mysql,
|
||||
+ .realtime_multi_func = realtime_multi_mysql,
|
||||
+ .update_func = update_mysql
|
||||
+};
|
||||
+
|
||||
+int load_module (void)
|
||||
+{
|
||||
+ parse_config();
|
||||
+
|
||||
+ ast_mutex_lock(&mysql_lock);
|
||||
+
|
||||
+ if(!mysql_reconnect(NULL)) {
|
||||
+ ast_log(LOG_WARNING, "MySQL RealTime: Couldn't establish connection. Check debug.\n");
|
||||
+ ast_log(LOG_DEBUG, "MySQL RealTime: Cannot Connect: %s\n", mysql_error(&mysql));
|
||||
+ }
|
||||
+
|
||||
+ ast_config_engine_register(&mysql_engine);
|
||||
+ if(option_verbose) {
|
||||
+ ast_verbose("MySQL RealTime driver loaded.\n");
|
||||
+ }
|
||||
+ ast_cli_register(&cli_realtime_mysql_status);
|
||||
+
|
||||
+ ast_mutex_unlock(&mysql_lock);
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+int unload_module (void)
|
||||
+{
|
||||
+ /* Aquire control before doing anything to the module itself. */
|
||||
+ ast_mutex_lock(&mysql_lock);
|
||||
+
|
||||
+ mysql_close(&mysql);
|
||||
+ ast_cli_unregister(&cli_realtime_mysql_status);
|
||||
+ ast_config_engine_deregister(&mysql_engine);
|
||||
+ if(option_verbose) {
|
||||
+ ast_verbose("MySQL RealTime unloaded.\n");
|
||||
+ }
|
||||
+
|
||||
+ STANDARD_HANGUP_LOCALUSERS;
|
||||
+
|
||||
+ /* Unlock so something else can destroy the lock. */
|
||||
+ ast_mutex_unlock(&mysql_lock);
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+int reload (void)
|
||||
+{
|
||||
+ /* Aquire control before doing anything to the module itself. */
|
||||
+ ast_mutex_lock(&mysql_lock);
|
||||
+
|
||||
+ mysql_close(&mysql);
|
||||
+ connected = 0;
|
||||
+ parse_config();
|
||||
+
|
||||
+ if(!mysql_reconnect(NULL)) {
|
||||
+ ast_log(LOG_WARNING, "MySQL RealTime: Couldn't establish connection. Check debug.\n");
|
||||
+ ast_log(LOG_DEBUG, "MySQL RealTime: Cannot Connect: %s\n", mysql_error(&mysql));
|
||||
+ }
|
||||
+
|
||||
+ ast_verbose(VERBOSE_PREFIX_2 "MySQL RealTime reloaded.\n");
|
||||
+
|
||||
+ /* Done reloading. Release lock so others can now use driver. */
|
||||
+ ast_mutex_unlock(&mysql_lock);
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+int parse_config (void)
|
||||
+{
|
||||
+ struct ast_config *config;
|
||||
+ char *s;
|
||||
+
|
||||
+ config = ast_config_load(RES_CONFIG_MYSQL_CONF);
|
||||
+
|
||||
+ if(config) {
|
||||
+ if(!(s=ast_variable_retrieve(config, "general", "dbuser"))) {
|
||||
+ ast_log(LOG_WARNING, "MySQL RealTime: No database user found, using 'asterisk' as default.\n");
|
||||
+ strncpy(dbuser, "asterisk", sizeof(dbuser) - 1);
|
||||
+ } else {
|
||||
+ strncpy(dbuser, s, sizeof(dbuser) - 1);
|
||||
+ }
|
||||
+
|
||||
+ if(!(s=ast_variable_retrieve(config, "general", "dbpass"))) {
|
||||
+ ast_log(LOG_WARNING, "MySQL RealTime: No database password found, using 'asterisk' as default.\n");
|
||||
+ strncpy(dbpass, "asterisk", sizeof(dbpass) - 1);
|
||||
+ } else {
|
||||
+ strncpy(dbpass, s, sizeof(dbpass) - 1);
|
||||
+ }
|
||||
+
|
||||
+ if(!(s=ast_variable_retrieve(config, "general", "dbhost"))) {
|
||||
+ ast_log(LOG_WARNING, "MySQL RealTime: No database host found, using localhost via socket.\n");
|
||||
+ dbhost[0] = '\0';
|
||||
+ } else {
|
||||
+ strncpy(dbhost, s, sizeof(dbhost) - 1);
|
||||
+ }
|
||||
+
|
||||
+ if(!(s=ast_variable_retrieve(config, "general", "dbname"))) {
|
||||
+ ast_log(LOG_WARNING, "MySQL RealTime: No database name found, using 'asterisk' as default.\n");
|
||||
+ strncpy(dbname, "asterisk", sizeof(dbname) - 1);
|
||||
+ } else {
|
||||
+ strncpy(dbname, s, sizeof(dbname) - 1);
|
||||
+ }
|
||||
+
|
||||
+ if(!(s=ast_variable_retrieve(config, "general", "dbport"))) {
|
||||
+ ast_log(LOG_WARNING, "MySQL RealTime: No database port found, using 3306 as default.\n");
|
||||
+ dbport = 3306;
|
||||
+ } else {
|
||||
+ dbport = atoi(s);
|
||||
+ }
|
||||
+
|
||||
+ if(dbhost && !(s=ast_variable_retrieve(config, "general", "dbsock"))) {
|
||||
+ ast_log(LOG_WARNING, "MySQL RealTime: No database socket found, using '/tmp/mysql.sock' as default.\n");
|
||||
+ strncpy(dbsock, "/tmp/mysql.sock", sizeof(dbsock) - 1);
|
||||
+ } else {
|
||||
+ strncpy(dbsock, s, sizeof(dbsock) - 1);
|
||||
+ }
|
||||
+ }
|
||||
+ ast_config_destroy(config);
|
||||
+
|
||||
+ if(dbhost) {
|
||||
+ ast_log(LOG_DEBUG, "MySQL RealTime Host: %s\n", dbhost);
|
||||
+ ast_log(LOG_DEBUG, "MySQL RealTime Port: %i\n", dbport);
|
||||
+ } else {
|
||||
+ ast_log(LOG_DEBUG, "MySQL RealTime Socket: %s\n", dbsock);
|
||||
+ }
|
||||
+ ast_log(LOG_DEBUG, "MySQL RealTime User: %s\n", dbuser);
|
||||
+ ast_log(LOG_DEBUG, "MySQL RealTime Password: %s\n", dbpass);
|
||||
+
|
||||
+ return 1;
|
||||
+}
|
||||
+
|
||||
+char *description (void)
|
||||
+{
|
||||
+ return res_config_mysql_desc;
|
||||
+}
|
||||
+
|
||||
+int usecount (void)
|
||||
+{
|
||||
+ /* Try and get a lock. If unsuccessful, than that means another thread is using the mysql object. */
|
||||
+ if(ast_mutex_trylock(&mysql_lock)) {
|
||||
+ ast_log(LOG_DEBUG, "MySQL RealTime: Module usage count is 1.\n");
|
||||
+ return 1;
|
||||
+ }
|
||||
+ ast_mutex_unlock(&mysql_lock);
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+char *key ()
|
||||
+{
|
||||
+ return ASTERISK_GPL_KEY;
|
||||
+}
|
||||
+
|
||||
+static int mysql_reconnect(const char *database)
|
||||
+{
|
||||
+ char my_database[50];
|
||||
+
|
||||
+ if(!database || ast_strlen_zero(database))
|
||||
+ ast_copy_string(my_database, dbname, sizeof(my_database));
|
||||
+ else
|
||||
+ ast_copy_string(my_database, database, sizeof(my_database));
|
||||
+
|
||||
+ /* mutex lock should have been locked before calling this function. */
|
||||
+
|
||||
+ if((!connected) && (dbhost || dbsock) && dbuser && dbpass && my_database) {
|
||||
+ if(!mysql_init(&mysql)) {
|
||||
+ ast_log(LOG_WARNING, "MySQL RealTime: Insufficient memory to allocate MySQL resource.\n");
|
||||
+ connected = 0;
|
||||
+ return 0;
|
||||
+ }
|
||||
+ if(mysql_real_connect(&mysql, dbhost, dbuser, dbpass, my_database, dbport, dbsock, 0)) {
|
||||
+ ast_log(LOG_DEBUG, "MySQL RealTime: Successfully connected to database.\n");
|
||||
+ connected = 1;
|
||||
+ connect_time = time(NULL);
|
||||
+ return 1;
|
||||
+ } else {
|
||||
+ ast_log(LOG_ERROR, "MySQL RealTime: Failed to connect database server %s on %s. Check debug for more info.\n", dbname, dbhost);
|
||||
+ ast_log(LOG_DEBUG, "MySQL RealTime: Cannot Connect: %s\n", mysql_error(&mysql));
|
||||
+ connected = 0;
|
||||
+ return 0;
|
||||
+ }
|
||||
+ } else {
|
||||
+ if(mysql_ping(&mysql) != 0) {
|
||||
+ connected = 0;
|
||||
+ ast_log(LOG_ERROR, "MySQL RealTime: Failed to reconnect. Check debug for more info.\n");
|
||||
+ ast_log(LOG_DEBUG, "MySQL RealTime: Server Error: %s\n", mysql_error(&mysql));
|
||||
+ return 0;
|
||||
+ }
|
||||
+
|
||||
+ connected = 1;
|
||||
+
|
||||
+ if(mysql_select_db(&mysql, my_database) != 0) {
|
||||
+ ast_log(LOG_WARNING, "MySQL RealTime: Unable to select database: %s. Still Connected.\n", my_database);
|
||||
+ ast_log(LOG_DEBUG, "MySQL RealTime: Database Select Failed: %s\n", mysql_error(&mysql));
|
||||
+ return 0;
|
||||
+ }
|
||||
+
|
||||
+ ast_log(LOG_DEBUG, "MySQL RealTime: Everything is fine.\n");
|
||||
+ return 1;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+static int realtime_mysql_status(int fd, int argc, char **argv)
|
||||
+{
|
||||
+ char status[256], status2[100] = "";
|
||||
+ int ctime = time(NULL) - connect_time;
|
||||
+
|
||||
+ if(mysql_reconnect(NULL)) {
|
||||
+ if(dbhost) {
|
||||
+ snprintf(status, 255, "Connected to %s@%s, port %d", dbname, dbhost, dbport);
|
||||
+ } else if(dbsock) {
|
||||
+ snprintf(status, 255, "Connected to %s on socket file %s", dbname, dbsock);
|
||||
+ } else {
|
||||
+ snprintf(status, 255, "Connected to %s@%s", dbname, dbhost);
|
||||
+ }
|
||||
+
|
||||
+ if(dbuser && *dbuser) {
|
||||
+ snprintf(status2, 99, " with username %s", dbuser);
|
||||
+ }
|
||||
+
|
||||
+ if (ctime > 31536000) {
|
||||
+ ast_cli(fd, "%s%s for %d years, %d days, %d hours, %d minutes, %d seconds.\n", status, status2, ctime / 31536000, (ctime % 31536000) / 86400, (ctime % 86400) / 3600, (ctime % 3600) / 60, ctime % 60);
|
||||
+ } else if (ctime > 86400) {
|
||||
+ ast_cli(fd, "%s%s for %d days, %d hours, %d minutes, %d seconds.\n", status, status2, ctime / 86400, (ctime % 86400) / 3600, (ctime % 3600) / 60, ctime % 60);
|
||||
+ } else if (ctime > 3600) {
|
||||
+ ast_cli(fd, "%s%s for %d hours, %d minutes, %d seconds.\n", status, status2, ctime / 3600, (ctime % 3600) / 60, ctime % 60);
|
||||
+ } else if (ctime > 60) {
|
||||
+ ast_cli(fd, "%s%s for %d minutes, %d seconds.\n", status, status2, ctime / 60, ctime % 60);
|
||||
+ } else {
|
||||
+ ast_cli(fd, "%s%s for %d seconds.\n", status, status2, ctime);
|
||||
+ }
|
||||
+
|
||||
+ return RESULT_SUCCESS;
|
||||
+ } else {
|
||||
+ return RESULT_FAILURE;
|
||||
+ }
|
||||
+}
|
|
@ -0,0 +1,11 @@
|
|||
--- asterisk-1.2.1/Makefile.orig 2005-12-09 10:22:06.000000000 +0100
|
||||
+++ asterisk-1.2.1/Makefile 2005-12-09 10:28:46.000000000 +0100
|
||||
@@ -322,8 +322,6 @@
|
||||
ifneq ($(wildcard .svn),)
|
||||
ASTERISKVERSIONNUM=999999
|
||||
ASTERISKVERSION=SVN-$(shell build_tools/make_svn_branch_name)
|
||||
- else
|
||||
- ASTERISKVERSIONNUM=000000
|
||||
endif
|
||||
endif
|
||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue