diff options
Diffstat (limited to 'lib/megaco')
-rw-r--r-- | lib/megaco/configure.in | 113 | ||||
-rw-r--r-- | lib/megaco/doc/src/Makefile | 3 | ||||
-rw-r--r-- | lib/megaco/doc/src/notes.xml | 12 | ||||
-rw-r--r-- | lib/megaco/src/app/megaco.appup.src | 34 | ||||
-rw-r--r-- | lib/megaco/src/engine/megaco_filter.erl | 286 | ||||
-rw-r--r-- | lib/megaco/src/flex/Makefile.in | 80 | ||||
-rw-r--r-- | lib/megaco/src/flex/megaco_flex_scanner_drv.flex.src | 13 | ||||
-rw-r--r-- | lib/megaco/src/flex/megaco_flex_scanner_handler.erl | 45 | ||||
-rw-r--r-- | lib/megaco/test/Makefile | 44 | ||||
-rw-r--r-- | lib/megaco/vsn.mk | 4 |
10 files changed, 399 insertions, 235 deletions
diff --git a/lib/megaco/configure.in b/lib/megaco/configure.in index 297d618369..8f94a4efcf 100644 --- a/lib/megaco/configure.in +++ b/lib/megaco/configure.in @@ -1,20 +1,20 @@ dnl Process this file with autoconf to produce a configure script. -*-m4-*- dnl dnl %CopyrightBegin% -dnl -dnl Copyright Ericsson AB 2001-2009. All Rights Reserved. -dnl +dnl +dnl Copyright Ericsson AB 2001-2010. All Rights Reserved. +dnl dnl The contents of this file are subject to the Erlang Public License, dnl Version 1.1, (the "License"); you may not use this file except in dnl compliance with the License. You should have received a copy of the dnl Erlang Public License along with this software. If not, it can be dnl retrieved online at http://www.erlang.org/. -dnl +dnl dnl Software distributed under the License is distributed on an "AS IS" dnl basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See dnl the License for the specific language governing rights and limitations dnl under the License. -dnl +dnl dnl %CopyrightEnd% dnl @@ -145,12 +145,14 @@ AC_ARG_ENABLE(megaco_flex_scanner_lineno, AC_SUBST(ENABLE_MEGACO_FLEX_SCANNER_LINENO) +dnl This is the os flavour, should be unix, vxworks or win32 +if test "X$host" = "Xwin32"; then + ERLANG_OSTYPE=win32 +else + ERLANG_OSTYPE=unix +fi -dnl -dnl C compiler (related) defs -dnl - -AC_PROG_CC +AC_SUBST(ERLANG_OSTYPE) dnl Magic test for clearcase. if test -d ../../system; then @@ -158,33 +160,55 @@ if test -d ../../system; then else OTP_EXTRA_FLAGS= fi +AC_SUBST(OTP_EXTRA_FLAGS) + +dnl +dnl If ${ERL_TOP}/make/otp_ded.mk.in exists and contains DED_MK_VSN > 0, +dnl every thing releted to compiling Dynamic Erlang Drivers can be found +dnl in $(ERL_TOP)/make/$(TARGET)/ded.mk at compile time. If not, try to +dnl figure these things out. +dnl + +AC_MSG_CHECKING([for usable Dynamic Erlang Driver configuration]) +[ + ded_mk_in="${ERL_TOP}/make/otp_ded.mk.in" + ded_mk_vsn= + test -r "$ded_mk_in" && + ded_mk_vsn=`sed -n "s/^DED_MK_VSN[ ]*=[ ]*\(.*\)/\1/p" < "$ded_mk_in"` + test "$ded_mk_vsn" != "" || ded_mk_vsn=0 +] + +if test $ded_mk_vsn -gt 0; then + +HAVE_USABLE_OTP_DED_MK=yes +AC_MSG_RESULT([yes]) +CC=false +AC_SUBST(CC) +DED_LD=false +AC_SUBST(DED_LD) + +else dnl --- begin no usable otp_ded.mk.in --- + +HAVE_USABLE_OTP_DED_MK=no +AC_MSG_RESULT([no]) dnl -dnl The ErlDrvEntry struct changed in R13 (another field) +dnl C compiler (related) defs dnl -AC_CHECK_MEMBERS([struct ErlDrvEntry.stop_select], - [ - CFLAGS="$CFLAGS -DMEGACO_DRV_ENTRY_HAS_STOP_SELECT" - ], - [], - [ - #include "erl_driver.h" - ]) +AC_PROG_CC dnl dnl Flags to the C compiler dnl -dnl make sure we find config.h -CFLAGS="$CFLAGS -I${ERL_TOP}/erts/$host -I${ERL_TOP}/erts/include/$host $OTP_EXTRA_FLAGS" if test "X$host" = "Xwin32"; then DED_CFLAGS="$CFLAGS" else case $host_os in darwin*) - CFLAGS="$CFLAGS -no-cpp-precomp" + CFLAGS="$CFLAGS -no-cpp-precomp -fno-common" ;; esac @@ -196,22 +220,10 @@ else fi dnl emulator includes needed -DED_INCLUDE="-I${ERL_TOP}/erts/emulator/beam -I${ERL_TOP}/erts/include -I${ERL_TOP}/erts/include/$host" - -DED_CFLAGS="$DED_INCLUDE $DED_CFLAGS" - - +DED_INCLUDES="-I${ERL_TOP}/erts/emulator/beam -I${ERL_TOP}/erts/include -I${ERL_TOP}/erts/include/$host -I${ERL_TOP}/erts/include/internal -I${ERL_TOP}/erts/include/internal/$host -I${ERL_TOP}/erts/emulator/sys/$ERLANG_OSTYPE" -AC_SUBST(DED_CFLAGS) - - -AC_CHECK_PROGS(DED_LD, [ld.sh ld], no_ld) -if test "$DED_LD" = no_ld; then - AC_MSG_ERROR([ld is required to build the flex scanner!]) -fi +DED_THR_DEFS="-D_THREAD_SAFE -D_REENTRANT" - -AC_MSG_CHECKING(for linker flags for loadable drivers) case $host_os in win32) DED_LDFLAGS="-dll" @@ -230,33 +242,36 @@ case $host_os in # Mach-O linker, a shared lib and a loadable # object file is not the same thing. DED_LDFLAGS="-bundle -flat_namespace -undefined suppress" - DED_CFLAGS="$DED_CFLAGS -fno-common" + DED_LD="$CC" ;; *) # assume GNU linker and ELF DED_LDFLAGS="-shared" ;; esac + +AC_CHECK_PROGS(DED_LD, [$LD ld.sh]) +AC_CHECK_TOOL(DED_LD, ld, no_ld) +if test "$DED_LD" = no_ld; then + AC_MSG_ERROR([ld is required to build the flex scanner!]) +fi + +AC_MSG_CHECKING(for linker flags for loadable drivers) DED_LDFLAGS="$LDFLAGS $DED_LDFLAGS" AC_MSG_RESULT([$DED_LDFLAGS]) -AC_SUBST(DED_LDFLAGS) +fi dnl --- end no usable otp_ded.mk.in --- + +AC_SUBST(HAVE_USABLE_OTP_DED_MK) +AC_SUBST(DED_CFLAGS) +AC_SUBST(DED_INCLUDES) +AC_SUBST(DED_THR_DEFS) +AC_SUBST(DED_LDFLAGS) AC_CHECK_PROG(PERL, perl, perl, no_perl) if test "$PERL" = no_perl; then AC_MSG_ERROR([Perl is required to build the flex scanner!]) fi - -dnl This is the os flavour, should be unix, vxworks or win32 -if test "X$host" = "Xwin32"; then - ERLANG_OSTYPE=win32 -else - ERLANG_OSTYPE=unix -fi - -AC_SUBST(ERLANG_OSTYPE) - - AC_OUTPUT(src/flex/$host/Makefile:src/flex/Makefile.in) diff --git a/lib/megaco/doc/src/Makefile b/lib/megaco/doc/src/Makefile index a82256b372..2355a1b8b9 100644 --- a/lib/megaco/doc/src/Makefile +++ b/lib/megaco/doc/src/Makefile @@ -107,8 +107,7 @@ INDEX_SRC = $(INDEX_FILE).src INDEX_TARGET = $(DOCDIR)/$(INDEX_FILE) STANDARD_DIR = ../standard -STANDARDS = $(STANDARD_DIR)/rfc3266.txt \ - $(STANDARD_DIR)/rfc3525.txt \ +STANDARDS = $(STANDARD_DIR)/rfc3525.txt \ $(STANDARD_DIR)/rfc4234.txt \ $(STANDARD_DIR)/rfc4566.txt \ $(STANDARD_DIR)/implementors_guide_v10-13.pdf diff --git a/lib/megaco/doc/src/notes.xml b/lib/megaco/doc/src/notes.xml index 61f3611029..59b1e59ce9 100644 --- a/lib/megaco/doc/src/notes.xml +++ b/lib/megaco/doc/src/notes.xml @@ -36,9 +36,9 @@ section is the version number of Megaco.</p> <section> - <title>Megaco 3.13.0.2</title> + <title>Megaco 3.13.1</title> - <p>Version 3.13.0.2 supports code replacement in runtime from/to + <p>Version 3.13.1 supports code replacement in runtime from/to version 3.13, 3.12 and 3.11.3.</p> <section> @@ -50,6 +50,12 @@ <list type="bulleted"> <item> + <p>Various changes to configure and makefile(s) to facilitate cross + compilation. </p> + <p>Own Id: OTP-8323</p> + </item> + + <item> <p>Added a help target in the test Makefile to explain the most useful make targets, used when testing the application using the test-server provided with megaco.</p> @@ -75,7 +81,7 @@ </section> - </section> <!-- 3.13.0.2 --> + </section> <!-- 3.13.1 --> <section> diff --git a/lib/megaco/src/app/megaco.appup.src b/lib/megaco/src/app/megaco.appup.src index 2d5ee2ddbd..3cf0e165b7 100644 --- a/lib/megaco/src/app/megaco.appup.src +++ b/lib/megaco/src/app/megaco.appup.src @@ -1,19 +1,19 @@ %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 2001-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 2001-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% @@ -122,29 +122,38 @@ %% 3.13 %% | %% v -%% 3.13.0.1 +%% 3.13.1 %% %% {"%VSN%", [ {"3.13", [ + {load_module, megaco_filter, soft_purge, soft_purge, []}, + {update, megaco_flex_scanner_handler, {advanced, downgrade_to_pre_3_13_1}, + soft_purge, soft_purge, []} ] }, {"3.12", [ + {load_module, megaco_filter, soft_purge, soft_purge, []}, {load_module, megaco_udp, soft_purge, soft_purge, []}, {load_module, megaco_messenger, soft_purge, soft_purge, [megaco_monitor]}, - {update, megaco_monitor, soft, soft_purge, soft_purge, []} + {update, megaco_monitor, soft, soft_purge, soft_purge, []}, + {update, megaco_flex_scanner_handler, {advanced, downgrade_to_pre_3_13_1}, + soft_purge, soft_purge, []} ] }, {"3.11.3", [ + {load_module, megaco_filter, soft_purge, soft_purge, []}, {load_module, megaco_udp, soft_purge, soft_purge, []}, {load_module, megaco_messenger, soft_purge, soft_purge, [megaco_config, megaco_monitor]}, {update, megaco_monitor, soft, soft_purge, soft_purge, []}, {update, megaco_config, {advanced, upgrade_from_pre_3_12}, + soft_purge, soft_purge, []}, + {update, megaco_flex_scanner_handler, {advanced, downgrade_to_pre_3_13_1}, soft_purge, soft_purge, []} ] } @@ -152,22 +161,31 @@ [ {"3.13", [ + {load_module, megaco_filter, soft_purge, soft_purge, []}, + {update, megaco_flex_scanner_handler, {advanced, upgrade_from_pre_3_13_1}, + soft_purge, soft_purge, []} ] }, {"3.12", [ + {load_module, megaco_filter, soft_purge, soft_purge, []}, {load_module, megaco_udp, soft_purge, soft_purge, []}, {load_module, megaco_messenger, soft_purge, soft_purge, [megaco_monitor]}, - {update, megaco_monitor, soft, soft_purge, soft_purge, []} + {update, megaco_monitor, soft, soft_purge, soft_purge, []}, + {update, megaco_flex_scanner_handler, {advanced, upgrade_from_pre_3_13_1}, + soft_purge, soft_purge, []} ] }, {"3.11.3", [ + {load_module, megaco_filter, soft_purge, soft_purge, []}, {load_module, megaco_udp, soft_purge, soft_purge, []}, {load_module, megaco_messenger, soft_purge, soft_purge, [megaco_config, megaco_monitor]}, {update, megaco_monitor, soft, soft_purge, soft_purge, []}, {update, megaco_config, {advanced, downgrade_to_pre_3_12}, + soft_purge, soft_purge, []}, + {update, megaco_flex_scanner_handler, {advanced, upgrade_from_pre_3_13_1}, soft_purge, soft_purge, []} ] } diff --git a/lib/megaco/src/engine/megaco_filter.erl b/lib/megaco/src/engine/megaco_filter.erl index 23a91b1f1d..9df752789c 100644 --- a/lib/megaco/src/engine/megaco_filter.erl +++ b/lib/megaco/src/engine/megaco_filter.erl @@ -1,37 +1,83 @@ %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 2000-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 2000-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% %% %%---------------------------------------------------------------------- -%% Purpose : megaco/H.248 customization of generic event tracer +%% Purpose : Megaco/H.248 customization of the Event Tracer tool %%---------------------------------------------------------------------- -module(megaco_filter). --export([start/0, start/1, filter/1, +-export([start/0, start/1, filter/1, raw_filter/1, pretty_error/1, string_to_term/1]). + -include_lib("megaco/include/megaco.hrl"). -include_lib("megaco/include/megaco_message_v1.hrl"). -include_lib("megaco/src/app/megaco_internal.hrl"). -include_lib("et/include/et.hrl"). +%%---------------------------------------------------------------------- +%% BUGBUG: There are some opportunities for improvements: +%% +%% * This version of the module does only handle version 1 of the messages. +%% +%% * The record definition of megaco_transaction_reply is copied from +%% megaco_message_internal.hrl as that header file contains some +%% records that already are defined in megaco_message_{v1,v2,v3}.hrl. +%% * The records megaco_udp and megaco_tcp are copied from the files +%% megaco_udp.hrl and megaco_tcp.hrl respectively, as we cannot include +%% both header files. They both defines the macros HEAP_SIZE and GC_MSG_LIMIT. + +%%-include("megaco_message_internal.hrl"). +-record('megaco_transaction_reply', + { + transactionId, + immAckRequired = asn1_NOVALUE, + transactionResult, + segmentNumber = asn1_NOVALUE, + segmentationComplete = asn1_NOVALUE + }). + +%% -include_lib("megaco/src/udp/megaco_udp.hrl"). +-record(megaco_udp, + {port, + options = [], + socket, + receive_handle, + module = megaco, + serialize = false % false: Spawn a new process for each message + }). + +%% -include_lib("megaco/src/tcp/megaco_tcp.hrl"). +-record(megaco_tcp, + {host, + port, + options = [], + socket, + proxy_pid, + receive_handle, + module = megaco, + serialize = false % false: Spawn a new process for each message + }). +%%---------------------------------------------------------------------- + start() -> start([]). @@ -47,11 +93,20 @@ start(ExtraOptions) -> {title, "Megaco tracer - Erlang/OTP"} | ExtraOptions], et_viewer:start(Options). -filter(E) when is_record(E, event) -> +filter(E) -> + case catch raw_filter(E) of + {'EXIT', Reason} = Error-> + io:format("~p: ~p\n", [?MODULE, Error]), + exit(Reason); + E2 -> + E2 + end. + +raw_filter(E) when is_record(E, event) -> From = filter_actor(E#event.from), To = filter_actor(E#event.to), E2 = E#event{from = From, to = To}, - E3 = filter_contents(E#event.contents, E2, []), + E3 = filter_contents(E#event.contents, E2), {true, E3}. filter_actors(From, To, E) @@ -101,6 +156,9 @@ filter_user_actor(Actor) -> do_filter_actor(CH) when is_record(CH, megaco_conn_handle) -> Mid = CH#megaco_conn_handle.local_mid, do_filter_actor(Mid); +do_filter_actor(RH) when is_record(RH, megaco_receive_handle) -> + Mid = RH#megaco_receive_handle.local_mid, + do_filter_actor(Mid); do_filter_actor(Actor) -> case Actor of {ip4Address, {'IP4Address', [A1,A2,A3,A4], asn1_NOVALUE}} -> @@ -130,86 +188,108 @@ do_filter_actor(Actor) -> "UNKNOWN" end. -filter_contents([], E, Contents) -> - E#event{contents = lists:flatten(lists:reverse(Contents))}; -filter_contents([H | T], E, Contents) -> + +filter_contents(Contents, E) -> + do_filter_contents(Contents, E, missing_conn_data, []). + +do_filter_contents([H | T], E, ConnData, Contents) -> case H of - {line, _Mod, _Line} -> - filter_contents(T, E, Contents); + Udp when is_record(Udp, megaco_udp) -> + RH = Udp#megaco_udp.receive_handle, + Actor = filter_actor(RH), + E2 = E#event{from = Actor, to = Actor}, + Pretty = + ["Port: ", integer_to_list(Udp#megaco_udp.port), "\n", + "Encoder: ", atom_to_list(RH#megaco_receive_handle.encoding_mod)], + do_filter_contents(T, E2, ConnData, [[Pretty, "\n"], Contents]); + Tcp when is_record(Tcp, megaco_tcp) -> + RH = Tcp#megaco_tcp.receive_handle, + Actor = filter_actor(RH), + E2 = E#event{from = Actor, to = Actor}, + Pretty = + ["Port: ", integer_to_list(Tcp#megaco_tcp.port), "\n", + "Encoder: ", atom_to_list(RH#megaco_receive_handle.encoding_mod)], + do_filter_contents(T, E2, ConnData, [[Pretty, "\n"], Contents]); CD when is_record(CD, conn_data) -> CH = CD#conn_data.conn_handle, From = CH#megaco_conn_handle.local_mid, - To = CH#megaco_conn_handle.remote_mid, + To = CH#megaco_conn_handle.remote_mid, E2 = filter_actors(From, To, E), Serial = CD#conn_data.serial, E3 = append_serial(Serial, E2), - filter_contents(T, E3, Contents); + do_filter_contents(T, E3, CD, Contents); CH when is_record(CH, megaco_conn_handle) -> From = CH#megaco_conn_handle.local_mid, - To = CH#megaco_conn_handle.remote_mid, + To = CH#megaco_conn_handle.remote_mid, E2 = filter_actors(From, To, E), - filter_contents(T, E2, Contents); - {orig_conn_handle, _CH} -> - filter_contents(T, E, Contents); + do_filter_contents(T, E2, ConnData, Contents); RH when is_record(RH, megaco_receive_handle) -> Actor = RH#megaco_receive_handle.local_mid, E2 = filter_actors(Actor, Actor, E), - filter_contents(T, E2, Contents); - {pid, Pid} when is_pid(Pid) -> - filter_contents(T, E, Contents); - pending -> - filter_contents(T, E, Contents); - reply -> - filter_contents(T, E, Contents); + do_filter_contents(T, E2, ConnData, Contents); {error, Reason} -> Pretty = pretty_error({error, Reason}), E2 = prepend_error(E), - filter_contents(T, E2, [[Pretty, "\n"], Contents]); + do_filter_contents(T, E2, ConnData, [[Pretty, "\n"], Contents]); {'EXIT', Reason} -> Pretty = pretty_error({'EXIT', Reason}), E2 = prepend_error(E), - filter_contents(T, E2, [[Pretty, "\n"], Contents]); + do_filter_contents(T, E2, ConnData, [[Pretty, "\n"], Contents]); ED when is_record(ED, 'ErrorDescriptor') -> Pretty = pretty_error(ED), E2 = prepend_error(E), - filter_contents(T, E2, [[Pretty, "\n"], Contents]); + do_filter_contents(T, E2, ConnData, [[Pretty, "\n"], Contents]); Trans when is_record(Trans, 'TransactionRequest') -> - Pretty = pretty({trans, {transactionRequest, Trans}}), - filter_contents([], E, [[Pretty, "\n"], Contents]); + Pretty = pretty(ConnData, {trans, {transactionRequest, Trans}}), + do_filter_contents([], E, ConnData, [[Pretty, "\n"], Contents]); + {transactionRequest, Trans} when is_record(Trans, 'TransactionRequest') -> + Pretty = pretty(ConnData, {trans, {transactionRequest, Trans}}), + do_filter_contents([], E, ConnData, [[Pretty, "\n"], Contents]); Trans when is_record(Trans, 'TransactionReply') -> - Pretty = pretty({trans, {transactionReply, Trans}}), - filter_contents([], E, [[Pretty, "\n"], Contents]); + Pretty = pretty(ConnData, {trans, {transactionReply, Trans}}), + do_filter_contents([], E, ConnData, [[Pretty, "\n"], Contents]); + Trans when is_record(Trans, megaco_transaction_reply) -> + %% BUGBUG: Version 1 special + TransV1 = + #'TransactionReply'{transactionId = Trans#megaco_transaction_reply.transactionId, + immAckRequired = Trans#megaco_transaction_reply.immAckRequired, + transactionResult = Trans#megaco_transaction_reply.transactionResult}, + Pretty = pretty(ConnData, {trans, {transactionReply, TransV1}}), + do_filter_contents([], E, ConnData, [[Pretty, "\n"], Contents]); Trans when is_record(Trans, 'TransactionPending') -> - Pretty = pretty({trans, {transactionPending, Trans}}), - filter_contents([], E, [[Pretty, "\n"], Contents]); + Pretty = pretty(ConnData, {trans, {transactionPending, Trans}}), + do_filter_contents([], E, ConnData, [[Pretty, "\n"], Contents]); Trans when is_record(Trans, 'TransactionAck') -> - Pretty = pretty({trans, {transactionResponseAck, [Trans]}}), + Pretty = pretty(ConnData, {trans, {transactionResponseAck, [Trans]}}), case Trans#'TransactionAck'.lastAck of asn1_NOVALUE -> - filter_contents([], E, [[Pretty, "\n"], Contents]); + do_filter_contents([], E, ConnData, [[Pretty, "\n"], Contents]); Last -> Label = term_to_string(E#event.label), E2 = E#event{label = Label ++ ".." ++ integer_to_list(Last)}, - filter_contents([], E2, [[Pretty, "\n"], Contents]) + do_filter_contents([], E2, ConnData, [[Pretty, "\n"], Contents]) end; {context_id, _ContextId} -> - Pretty = pretty(H), - filter_contents(T, E, [[Pretty, "\n"], Contents]); + Pretty = pretty(ConnData, H), + do_filter_contents(T, E, ConnData, [[Pretty, "\n"], Contents]); {command_request, CmdReq} -> - Pretty = pretty(CmdReq), - filter_contents(T, E, [[Pretty, "\n"], Contents]); + Pretty = pretty(ConnData, CmdReq), + do_filter_contents(T, E, ConnData, [[Pretty, "\n"], Contents]); {user_reply, {ok, ARS}} -> - Pretty = [[pretty(AR), "\n"] || AR <- ARS], - filter_contents(T, E, [["REPLY: \n", Pretty, "\n"], Contents]); + Pretty = [[pretty(ConnData, AR), "\n"] || AR <- ARS], + do_filter_contents(T, E, ConnData, [["USER REPLY OK: \n", Pretty, "\n"], Contents]); {user_reply, Error} -> Pretty = pretty_error(Error), - filter_contents(T, E, [["REPLY: \n", Pretty, "\n"], Contents]); + do_filter_contents(T, E, ConnData, [["USER REPLY ERROR: \n", Pretty, "\n"], Contents]); {actionReplies, ARS} -> - Pretty = [[pretty(AR), "\n"] || AR <- ARS], - filter_contents(T, E, [["REPLY: \n", Pretty, "\n"], Contents]); + Pretty = [[pretty(ConnData, AR), "\n"] || AR <- ARS], + do_filter_contents(T, E, ConnData, [["ACTION REPLIES: \n", Pretty, "\n"], Contents]); MegaMsg when is_record(MegaMsg, 'MegacoMessage') -> - Pretty = pretty(MegaMsg), - filter_contents(T, E, [["MESSAGE: \n", Pretty, "\n"], Contents]); + Pretty = pretty(ConnData, MegaMsg), + do_filter_contents(T, E, ConnData, [Pretty, "\n", Contents]); + {message, MegaMsg} when is_record(MegaMsg, 'MegacoMessage') -> + Pretty = pretty(ConnData, MegaMsg), + do_filter_contents(T, E, ConnData, [Pretty, "\n", Contents]); {bytes, Bin} when is_binary(Bin) -> E2 = case E#event.label of @@ -223,15 +303,37 @@ filter_contents([H | T], E, Contents) -> E end, CharList = erlang:binary_to_list(Bin), - filter_contents(T, E2, [[CharList , "\n"], Contents]); - [] -> - filter_contents(T, E, Contents); + do_filter_contents(T, E2, ConnData, [[CharList , "\n"], Contents]); + List when is_list(List) -> + %% BUGBUG: Workaround as megaco_messenger puts nested lists in its traces + do_filter_contents(List ++ T, E, ConnData, Contents); + Int when is_integer(Int) -> + %% BUGBUG: Workaround as megaco_messenger puts nested lists in its traces + do_filter_contents(T, E, ConnData, Contents); + {line, _Mod, _Line} -> + do_filter_contents(T, E, ConnData, Contents); + {orig_conn_handle, _CH} -> + do_filter_contents(T, E, ConnData, Contents); + {pid, Pid} when is_pid(Pid) -> + do_filter_contents(T, E, ConnData, Contents); + pending -> + do_filter_contents(T, E, ConnData, Contents); + reply -> + do_filter_contents(T, E, ConnData, Contents); {test_lib, _Mod, _Fun} -> - filter_contents(T, E, Contents); + do_filter_contents(T, E, ConnData, Contents); + {trans_id, _TransId} -> + do_filter_contents(T, E, ConnData, Contents); + {send_func, _FunName} -> + do_filter_contents(T, E, ConnData, Contents); + Pid when is_pid(Pid) -> + do_filter_contents(T, E, ConnData, Contents); Other -> - Pretty = pretty(Other), - filter_contents(T, E, [[Pretty, "\n"], Contents]) - end. + Pretty = pretty(ConnData, Other), + do_filter_contents(T, E, ConnData, [[Pretty, "\n"], Contents]) + end; +do_filter_contents([], E, _ConnData, Contents) -> + E#event{contents = lists:flatten(lists:reverse(Contents))}. append_serial(Serial, E) when is_integer(Serial) -> Label = term_to_string(E#event.label), @@ -243,7 +345,7 @@ prepend_error(E) -> Label = term_to_string(E#event.label), E#event{label = "<ERROR> " ++ Label}. -pretty({context_id, ContextId}) -> +pretty(_ConnData, {context_id, ContextId}) -> if ContextId =:= ?megaco_null_context_id -> ["CONTEXT ID: -\n"]; @@ -254,61 +356,33 @@ pretty({context_id, ContextId}) -> is_integer(ContextId) -> ["CONTEXT ID: ",integer_to_list(ContextId), "\n"] end; -pretty(MegaMsg) when is_record(MegaMsg, 'MegacoMessage') -> - case catch megaco_pretty_text_encoder:encode_message([], MegaMsg) of - {ok, Bin} -> - term_to_string(Bin); - _Bad -> - term_to_string(MegaMsg) - end; -pretty(CmdReq) when is_record(CmdReq, 'CommandRequest') -> - case catch megaco_pretty_text_encoder:encode_command_request(CmdReq) of - {ok, IoList} -> - IoList2 = lists:flatten(IoList), - term_to_string(IoList2); - _Bad -> - term_to_string(CmdReq) - end; -pretty({complete_success, ContextId, RepList} = Res) -> +pretty(_ConnData, MegaMsg) when is_record(MegaMsg, 'MegacoMessage') -> + {ok, Bin} = megaco_pretty_text_encoder:encode_message([], MegaMsg), + term_to_string(Bin); +pretty(_ConnData, CmdReq) when is_record(CmdReq, 'CommandRequest') -> + {ok, IoList} = megaco_pretty_text_encoder:encode_command_request(CmdReq), + term_to_string(lists:flatten(IoList)); +pretty(_ConnData, {complete_success, ContextId, RepList}) -> ActRep = #'ActionReply'{contextId = ContextId, commandReply = RepList}, - case catch megaco_pretty_text_encoder:encode_action_reply(ActRep) of - {ok, IoList} -> - IoList2 = lists:flatten(IoList), - term_to_string(IoList2); - _Bad -> - term_to_string(Res) - end; -pretty(AR) when is_record(AR, 'ActionReply') -> - case catch megaco_pretty_text_encoder:encode_action_reply(AR) of - {ok, IoList} -> - IoList2 = lists:flatten(IoList), - term_to_string(IoList2); - _Bad -> - term_to_string(AR) - end; -pretty({partial_failure, ContextId, RepList} = Res) -> + {ok, IoList} = megaco_pretty_text_encoder:encode_action_reply(ActRep), + term_to_string(lists:flatten(IoList)); +pretty(_ConnData, AR) when is_record(AR, 'ActionReply') -> + {ok, IoList} = megaco_pretty_text_encoder:encode_action_reply(AR), + term_to_string(lists:flatten(IoList)); +pretty(_ConnData, {partial_failure, ContextId, RepList}) -> ActRep = #'ActionReply'{contextId = ContextId, commandReply = RepList}, - case catch megaco_pretty_text_encoder:encode_action_reply(ActRep) of - {ok, IoList} -> - IoList2 = lists:flatten(IoList), - term_to_string(IoList2); - _Bad -> - term_to_string(Res) - end; -pretty({trans, Trans}) -> - case catch megaco_pretty_text_encoder:encode_transaction(Trans) of + {ok, IoList} = megaco_pretty_text_encoder:encode_action_reply(ActRep), + term_to_string(lists:flatten(IoList)); +pretty(_ConnData, {trans, Trans}) -> + case megaco_pretty_text_encoder:encode_transaction(Trans) of {ok, Bin} when is_binary(Bin) -> - IoList2 = lists:flatten(binary_to_list(Bin)), - term_to_string(IoList2); + term_to_string(binary_to_list(Bin)); {ok, IoList} -> - IoList2 = lists:flatten(IoList), - term_to_string(IoList2); - _Bad -> - term_to_string(Trans) + term_to_string(lists:flatten(IoList)) end; -pretty(Other) -> +pretty(__ConnData, Other) -> term_to_string(Other). pretty_error({error, Reason}) -> diff --git a/lib/megaco/src/flex/Makefile.in b/lib/megaco/src/flex/Makefile.in index 782d6a4807..6ce9b34617 100644 --- a/lib/megaco/src/flex/Makefile.in +++ b/lib/megaco/src/flex/Makefile.in @@ -1,19 +1,19 @@ # # %CopyrightBegin% -# -# Copyright Ericsson AB 2001-2009. All Rights Reserved. -# +# +# Copyright Ericsson AB 2001-2010. All Rights Reserved. +# # The contents of this file are subject to the Erlang Public License, # Version 1.1, (the "License"); you may not use this file except in # compliance with the License. You should have received a copy of the # Erlang Public License along with this software. If not, it can be # retrieved online at http://www.erlang.org/. -# +# # Software distributed under the License is distributed on an "AS IS" # basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See # the License for the specific language governing rights and limitations # under the License. -# +# # %CopyrightEnd% include $(ERL_TOP)/make/target.mk @@ -23,13 +23,30 @@ MEGACO_INCLUDEDIR = ../../include include $(ERL_TOP)/make/$(TARGET)/otp.mk - # ---------------------------------------------------- # Application version # ---------------------------------------------------- include ../../vsn.mk VSN=$(MEGACO_VSN) +# ---------------------------------------------------- +# Dynamic Erlang Driver +# ---------------------------------------------------- +HAVE_USABLE_OTP_DED_MK = @HAVE_USABLE_OTP_DED_MK@ + +ifeq ($(HAVE_USABLE_OTP_DED_MK),yes) +# otp_ded.mk will be used on R13B04 and later +include $(ERL_TOP)/make/$(TARGET)/otp_ded.mk +else +# megacos configure provide the info instead +DED_CC = @CC@ +DED__NOWARN_NOTHR_CFLAGS = @DED_CFLAGS@ +DED_THR_DEFS = @DED_THR_DEFS@ +DED_LD = @DED_LD@ +DED_LDFLAGS = @DED_LDFLAGS@ +DED_INCLUDES = @DED_INCLUDES@ +DED_EXT = so +endif # ---------------------------------------------------- # The following variables differ on different systems, we set @@ -39,16 +56,16 @@ VSN=$(MEGACO_VSN) FLEX_VSN = $(shell flex --version) -TMP_CFLAGS = @DED_CFLAGS@ +TMP_CFLAGS = $(DED__NOWARN_NOTHR_CFLAGS) @OTP_EXTRA_FLAGS@ ifeq ($(TYPE),valgrind) CFLAGS = $(subst -O2, , $(TMP_CFLAGS)) -DVALGRIND else CFLAGS = $(TMP_CFLAGS) endif -CC = @CC@ -CFLAGS_MT = $(CFLAGS) -D_THREAD_SAFE -D_REENTRANT -LD = @DED_LD@ -LDFLAGS = @DED_LDFLAGS@ +CC = $(DED_CC) +CFLAGS_MT = $(CFLAGS) $(DED_THR_DEFS) +LD = $(DED_LD) +LDFLAGS = $(DED_LDFLAGS) LEX = @LEX@ LEXLIB = @LEXLIB@ PERL = @PERL@ @@ -87,18 +104,13 @@ ENABLE_MEGACO_FLEX_SCANNER_LINENO = @ENABLE_MEGACO_FLEX_SCANNER_LINENO@ endif endif - -SYSINCLUDE = -I$(ERL_TOP)/erts/emulator/beam \ - -I$(ERL_TOP)/erts/emulator/sys/$(ERLANG_OSTYPE) ifeq ($(findstring vxworks,$(TARGET)),vxworks) - SYSINCLUDE += -I$(ERL_TOP)/erts/etc/vxworks + DED_INCLUDES += -I$(ERL_TOP)/erts/etc/vxworks endif -DRIVER_INCLUDES = $(SYSINCLUDE) - PRIVDIR = ../../priv LIBDIR = $(PRIVDIR)/lib/$(TARGET) - +OBJDIR = $(PRIVDIR)/obj/$(TARGET) # ---------------------------------------------------- # Release directory specification @@ -138,8 +150,8 @@ ifeq ($(findstring vxworks,$(TARGET)),vxworks) FLEX_SCANNER_SO = SOLIBS = $(FLEX_SCANNER_SO) else -FLEX_SCANNER_SO = $(LIBDIR)/$(STD_DRV).so -FLEX_SCANNER_MT_SO = $(LIBDIR)/$(MT_DRV).so +FLEX_SCANNER_SO = $(LIBDIR)/$(STD_DRV).$(DED_EXT) +FLEX_SCANNER_MT_SO = $(LIBDIR)/$(MT_DRV).$(DED_EXT) SOLIBS = $(FLEX_SCANNER_SO) $(FLEX_SCANNER_MT_SO) endif endif @@ -175,7 +187,7 @@ else CFLAGS += -DMFS_FLEX_DEBUG=0 endif -CFLAGS += $(DRIVER_INCLUDES) $(DRV_FLAGS) -funroll-loops -Wall +CFLAGS += $(DED_INCLUDES) -I$(ERL_TOP)/erts/$(TARGET) $(DRV_FLAGS) -funroll-loops -Wall #ifneq ($(FLEX_VSN),) #CFLAGS += -DFLEX_VERSION="$(FLEX_VSN)" @@ -379,18 +391,30 @@ $(STD_DRV).c: $(STD_DRV).flex $(MT_DRV).c: $(MT_DRV).flex $(LEX) $(MT_LEX_FLAGS) -P$* -o$@ $< -solibs: $(LIBDIR) $(SOLIBS) +solibs: $(LIBDIR) $(OBJDIR) $(SOLIBS) + +$(OBJDIR)/$(STD_DRV).o: $(STD_DRV).c + @echo "compiling std driver:" + $(CC) -c $(STD_DRV_NAME) $(CFLAGS) -o $@ $< + +$(OBJDIR)/$(MT_DRV).o: $(MT_DRV).c + @echo "compiling multi-threaded driver:" + $(CC) -c $(MT_DRV_NAME) $(CFLAGS_MT) -o $@ $< + # No need to link with -lfl as we have also defined %option noyywrap - # and having -lfl doesn't work under Darwin for some reason. - Sean -$(LIBDIR)/$(STD_DRV).so: $(STD_DRV).c - @echo "std driver:" - $(CC) $(STD_DRV_NAME) $(CFLAGS) $(LDFLAGS) -o $(LIBDIR)/$(STD_DRV).so $< +$(LIBDIR)/$(STD_DRV).$(DED_EXT): $(OBJDIR)/$(STD_DRV).o + @echo "linking std driver:" + $(LD) $(LDFLAGS) -o $@ $< -$(LIBDIR)/$(MT_DRV).so: $(MT_DRV).c - @echo "multi-threaded driver:" - $(CC) $(MT_DRV_NAME) $(CFLAGS_MT) $(LDFLAGS) -o $(LIBDIR)/$(MT_DRV).so $< +$(LIBDIR)/$(MT_DRV).$(DED_EXT): $(OBJDIR)/$(MT_DRV).o + @echo "linking multi-threaded driver:" + $(LD) $(LDFLAGS) -o $@ $< $(LIBDIR): -mkdir -p $(LIBDIR) +$(OBJDIR): + -mkdir -p $(OBJDIR) + diff --git a/lib/megaco/src/flex/megaco_flex_scanner_drv.flex.src b/lib/megaco/src/flex/megaco_flex_scanner_drv.flex.src index b96a69415d..9b4f717201 100644 --- a/lib/megaco/src/flex/megaco_flex_scanner_drv.flex.src +++ b/lib/megaco/src/flex/megaco_flex_scanner_drv.flex.src @@ -1,19 +1,19 @@ /* * %CopyrightBegin% - * - * Copyright Ericsson AB 2001-2009. All Rights Reserved. - * + * + * Copyright Ericsson AB 2001-2010. All Rights Reserved. + * * The contents of this file are subject to the Erlang Public License, * Version 1.1, (the "License"); you may not use this file except in * compliance with the License. You should have received a copy of the * Erlang Public License along with this software. If not, it can be * retrieved online at http://www.erlang.org/. - * + * * Software distributed under the License is distributed on an "AS IS" * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See * the License for the specific language governing rights and limitations * under the License. - * + * * %CopyrightEnd% * * ---------------------------------------------------------------------- @@ -354,9 +354,6 @@ static ErlDrvEntry mfs_entry = { MEGACO_DRIVER_FLAGS, /* driver_flags, used for port lock indication */ NULL, /* handle2, emulator internal use */ NULL /* process_exit, Called when a process monitor fires */ -#if defined(MEGACO_DRV_ENTRY_HAS_STOP_SELECT) - ,NULL /* stop_select, Called to close an event object */ -#endif }; diff --git a/lib/megaco/src/flex/megaco_flex_scanner_handler.erl b/lib/megaco/src/flex/megaco_flex_scanner_handler.erl index d09e0c6fff..420202134e 100644 --- a/lib/megaco/src/flex/megaco_flex_scanner_handler.erl +++ b/lib/megaco/src/flex/megaco_flex_scanner_handler.erl @@ -1,19 +1,19 @@ %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 2001-2009. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 2001-2010. All Rights Reserved. +%% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in %% compliance with the License. You should have received a copy of the %% Erlang Public License along with this software. If not, it can be %% retrieved online at http://www.erlang.org/. -%% +%% %% Software distributed under the License is distributed on an "AS IS" %% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See %% the License for the specific language governing rights and limitations %% under the License. -%% +%% %% %CopyrightEnd% %% @@ -180,27 +180,28 @@ terminate(_Reason, _S) -> %% Purpose: Called to change the internal state %% Returns: {ok, NewState} %%---------------------------------------------------------------------- -%% code_change({down, _Vsn}, #state{conf = Conf} = State, downgrade_to_pre_3_8) -> -%% Port = downgrade_flex_scanner(Conf), -%% {ok, State#state{conf = {flex, Port}}}; + +code_change({down, _Vsn}, #state{conf = Conf} = State, downgrade_to_pre_3_13_1) -> + NewPorts = bump_flex_scanner(Conf), + {ok, State#state{conf = {flex, NewPorts}}}; + +code_change(_Vsn, #state{conf = Conf} = State, upgrade_from_pre_3_13_1) -> + NewPorts = bump_flex_scanner(Conf), + {ok, State#state{conf = {flex, NewPorts}}}; code_change(_Vsn, State, _Extra) -> {ok, State}. -%% downgrade_flex_scanner({flex, Port}) when is_port(Port) -> -%% Port; -%% downgrade_flex_scanner({flex, [Port]}) when is_port(Port) -> -%% Port; -%% downgrade_flex_scanner({flex, Ports}) when is_list(Ports) -> -%% megaco_flex_scanner:stop(Ports), -%% case megaco_flex_scanner:start() of -%% {ok, Port} -> -%% Port; -%% Error -> -%% exit(Error) -%% end; -%% downgrade_flex_scanner(BadConfig) -> -%% exit({invalid_config, BadConfig}). +bump_flex_scanner({flex, Ports}) -> + megaco_flex_scanner:stop(Ports), + case start_flex_scanners() of + {ok, NewPorts} -> + NewPorts; + Error -> + exit(Error) + end; +bump_flex_scanner(BadConfig) -> + exit({invalid_config, BadConfig}). %%%---------------------------------------------------------------------- diff --git a/lib/megaco/test/Makefile b/lib/megaco/test/Makefile index e521194419..85c97359d7 100644 --- a/lib/megaco/test/Makefile +++ b/lib/megaco/test/Makefile @@ -52,10 +52,14 @@ endif include modules.mk +EBIN = . + HRL_FILES = megaco_test_lib.hrl ERL_FILES = $(MODULES:%=%.erl) +SOURCE = $(HRL_FILES) $(ERL_FILES) + TARGET_FILES = $(MODULES:%=%.$(EMULATOR)) COVER_SPEC_FILE = megaco.cover @@ -71,6 +75,18 @@ OP_CASES = mess mib mreq pending trans actions load ALL_CASES = $(APP_CASES) $(CODEC_CASES) $(MISC_CASES) $(OP_CASES) +EMAKEFILE = Emakefile +MAKE_EMAKE = $(wildcard $(ERL_TOP)/make/make_emakefile) + +ifeq ($(MAKE_EMAKE),) +BUILDTARGET = $(TARGET_FILES) +RELTEST_FILES = $(MEGACO_SPECS) $(COVER_SPEC_FILE) $(SOURCE) +else +BUILDTARGET = emakebuild +RELTEST_FILES = $(EMAKEFILE) $(MEGACO_SPECS) $(COVER_SPEC_FILE) $(SOURCE) +endif + + # ---------------------------------------------------- # FLAGS # ---------------------------------------------------- @@ -128,15 +144,30 @@ endif # Targets # ---------------------------------------------------- -tests debug opt: $(TARGET_FILES) +tests debug opt: $(BUILDTARGET) + +targets: $(TARGET_FILES) + +.PHONY: emakebuild + +emakebuild: $(EMAKEFILE) + +$(EMAKEFILE): + $(MAKE_EMAKE) $(ERL_COMPILE_FLAGS) -o$(EBIN) '*_SUITE_make' | grep -v Warning > $(EMAKEFILE) + $(MAKE_EMAKE) $(ERL_COMPILE_FLAGS) -o$(EBIN) $(MODULES) | grep -v Warning >> $(EMAKEFILE) clean: + rm -f $(EMAKEFILE) rm -f $(TARGET_FILES) rm -f errs core *~ docs: info: + @echo "MAKE_EMAKE = $(MAKE_EMAKE)" + @echo "EMAKEFILE = $(EMAKEFILE)" + @echo "BUILDTARGET = $(BUILDTARGET)" + @echo "" @echo "ERL_COMPILE_FLAGS = $(ERL_COMPILE_FLAGS)" @echo "ERL = $(ERL)" @echo "MERL = $(MERL)" @@ -314,8 +345,6 @@ all: make make: targets -targets: $(TARGET_FILES) - test: make $(MERL) $(ARGS) -sname megaco_test $(ERL_PATH) \ -s megaco_test_lib t $(SUITE) \ @@ -722,9 +751,10 @@ release_docs_spec: release_tests_spec: tests $(INSTALL_DIR) $(RELSYSDIR) - $(INSTALL_DATA) $(TEST_SPEC_FILE) $(COVER_SPEC_FILE) \ - $(HRL_FILES) $(ERL_FILES) \ - $(RELSYSDIR) - $(INSTALL_DATA) $(TARGET_FILES) $(RELSYSDIR) + $(INSTALL_DATA) $(RELTEST_FILES) $(RELSYSDIR) +# $(INSTALL_DATA) $(TEST_SPEC_FILE) $(COVER_SPEC_FILE) \ +# $(HRL_FILES) $(ERL_FILES) \ +# $(RELSYSDIR) +# chmod -f -R u+w $(RELSYSDIR) diff --git a/lib/megaco/vsn.mk b/lib/megaco/vsn.mk index 9e4ae4d242..b0574bbeef 100644 --- a/lib/megaco/vsn.mk +++ b/lib/megaco/vsn.mk @@ -19,10 +19,10 @@ APPLICATION = megaco MEGACO_VSN = 3.13.1 -PRE_VSN =-p01 +PRE_VSN =-p03 APP_VSN = "$(APPLICATION)-$(MEGACO_VSN)$(PRE_VSN)" -TICKETS = OTP-8317 OTP-8362 +TICKETS = OTP-8317 OTP-8323 OTP-8362 OTP-8403 TICKETS_3_13 = OTP-8205 OTP-8239 OTP-8249 |