aboutsummaryrefslogtreecommitdiffstats
path: root/lib/megaco/src/engine/megaco_user_default.erl
diff options
context:
space:
mode:
authorErlang/OTP <[email protected]>2009-11-20 14:54:40 +0000
committerErlang/OTP <[email protected]>2009-11-20 14:54:40 +0000
commit84adefa331c4159d432d22840663c38f155cd4c1 (patch)
treebff9a9c66adda4df2106dfd0e5c053ab182a12bd /lib/megaco/src/engine/megaco_user_default.erl
downloadotp-84adefa331c4159d432d22840663c38f155cd4c1.tar.gz
otp-84adefa331c4159d432d22840663c38f155cd4c1.tar.bz2
otp-84adefa331c4159d432d22840663c38f155cd4c1.zip
The R13B03 release.OTP_R13B03
Diffstat (limited to 'lib/megaco/src/engine/megaco_user_default.erl')
-rw-r--r--lib/megaco/src/engine/megaco_user_default.erl185
1 files changed, 185 insertions, 0 deletions
diff --git a/lib/megaco/src/engine/megaco_user_default.erl b/lib/megaco/src/engine/megaco_user_default.erl
new file mode 100644
index 0000000000..ff98107d57
--- /dev/null
+++ b/lib/megaco/src/engine/megaco_user_default.erl
@@ -0,0 +1,185 @@
+%%
+%% %CopyrightBegin%
+%%
+%% Copyright Ericsson AB 1999-2009. 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: Default implementation of user callbacks
+%%----------------------------------------------------------------------
+
+-module(megaco_user_default).
+
+-behaviour(megaco_user).
+
+-export([
+ handle_connect/2, handle_connect/3,
+ handle_disconnect/3,
+ handle_syntax_error/3, handle_syntax_error/4,
+ handle_message_error/3, handle_message_error/4,
+ handle_trans_request/3, handle_trans_request/4,
+ handle_trans_long_request/3, handle_trans_long_request/4,
+ handle_trans_reply/4, handle_trans_reply/5,
+ handle_trans_ack/4, handle_trans_ack/5,
+ handle_unexpected_trans/3, handle_unexpected_trans/4,
+ handle_trans_request_abort/4, handle_trans_request_abort/5,
+ handle_segment_reply/5, handle_segment_reply/6
+ ]).
+
+-include_lib("megaco/include/megaco.hrl").
+-include_lib("megaco/include/megaco_message_v1.hrl").
+-include_lib("megaco/src/app/megaco_internal.hrl").
+
+
+%%----------------------------------------------------------------------
+%% Invoked when a new connection is established
+%%----------------------------------------------------------------------
+
+handle_connect(_ConnHandle, _ProtocolVersion) ->
+ ok.
+
+handle_connect(_ConnHandle, _ProtocolVersion, _ConnectInfo) ->
+ ok.
+
+
+%%----------------------------------------------------------------------
+%% Invoked when a connection is teared down
+%%----------------------------------------------------------------------
+
+handle_disconnect(ConnHandle, _ProtocolVersion, Reason) ->
+ megaco:cancel(ConnHandle, Reason), % Cancel the outstanding messages
+ ok.
+
+
+%%----------------------------------------------------------------------
+%% Invoked when a received message had syntax errors
+%%----------------------------------------------------------------------
+
+handle_syntax_error(_ReceiveHandle, _ProtocolVersion, _ErrorDescriptor) ->
+ reply.
+
+handle_syntax_error(_ReceiveHandle, _ProtocolVersion, _ErrorDescriptor, _Extra) ->
+ reply.
+
+
+%%----------------------------------------------------------------------
+%% Invoked when a received message contained no transactions
+%%----------------------------------------------------------------------
+
+handle_message_error(_ConnHandle, _ProtocolVersion, _ErrorDescriptor) ->
+ no_reply.
+
+handle_message_error(_ConnHandle, _ProtocolVersion, _ErrorDescriptor, _Extra) ->
+ no_reply.
+
+
+%%----------------------------------------------------------------------
+%% Invoked for each transaction request
+%%----------------------------------------------------------------------
+
+handle_trans_request(ConnHandle, ProtocolVersion, ActionRequests) ->
+ Extra = ?default_user_callback_extra,
+ handle_trans_request(ConnHandle, ProtocolVersion, ActionRequests, Extra).
+
+handle_trans_request(_ConnHandle, ProtocolVersion, _ActionRequests, _Extra) ->
+ case ProtocolVersion of
+ 1 ->
+ ED = #'ErrorDescriptor'{errorCode = ?megaco_not_implemented,
+ errorText = "Trans requests not handled"},
+ {discard_ack, ED};
+ _ ->
+ ED = #'ErrorDescriptor'{errorCode = ?megaco_version_not_supported,
+ errorText = "Only version 1 is supported"},
+ {discard_ack, ED}
+ end.
+
+
+%%----------------------------------------------------------------------
+%% Optionally invoked for a time consuming transaction request
+%%----------------------------------------------------------------------
+
+handle_trans_long_request(ConnHandle, ProtocolVersion, ReqData) ->
+ Extra = ?default_user_callback_extra,
+ handle_trans_long_request(ConnHandle, ProtocolVersion, ReqData, Extra).
+
+handle_trans_long_request(_ConnHandle, _ProtocolVersion, _ReqData, _Extra) ->
+ ED = #'ErrorDescriptor'{errorCode = ?megaco_not_implemented,
+ errorText = "Long trans requests not handled"},
+ {discard_ack, ED}.
+
+
+%%----------------------------------------------------------------------
+%% Optionally invoked for a transaction reply
+%%----------------------------------------------------------------------
+
+handle_trans_reply(ConnHandle, ProtocolVersion, ActualReply, ReplyData) ->
+ Extra = ?default_user_callback_extra,
+ handle_trans_reply(ConnHandle, ProtocolVersion,
+ ActualReply, ReplyData, Extra).
+
+handle_trans_reply(ConnHandle, _, {error, {send_message_failed, Reason}}, _, _Extra) ->
+ megaco:disconnect(ConnHandle, {send_message_failed, Reason}),
+ ok;
+handle_trans_reply(_ConnHandle, _ProtocolVersion, _ActualReply, _ReplyData, _Extra) ->
+ ok.
+
+
+%%----------------------------------------------------------------------
+%% Optionally invoked for a transaction acknowledgement
+%%----------------------------------------------------------------------
+
+handle_trans_ack(_ConnHandle, _ProtocolVersion, _AckStatus, _AckData) ->
+ ok.
+
+handle_trans_ack(_ConnHandle, _ProtocolVersion, _AckStatus, _AckData, _Extra) ->
+ ok.
+
+
+%%----------------------------------------------------------------------
+%% Invoked when an unexpected message has been received
+%%----------------------------------------------------------------------
+
+handle_unexpected_trans(_ConnHandle, _ProtocolVersion, _Trans) ->
+ ok.
+
+handle_unexpected_trans(_ConnHandle, _ProtocolVersion, _Trans, _Extra) ->
+ ok.
+
+
+%%----------------------------------------------------------------------
+%% Invoked when an transaction has been aborted
+%% This happens when the originating pending limit has been exceeded
+%%----------------------------------------------------------------------
+
+handle_trans_request_abort(_ConnHandle, _ProtocolVersion, _TransId, _Pid) ->
+ ok.
+
+handle_trans_request_abort(_ConnHandle, _ProtocolVersion, _TransId, _Pid, _Extra) ->
+ ok.
+
+
+%%----------------------------------------------------------------------
+%% Invoked a segment reply has been received and the user has set
+%% config option segment_reply_ind = true.
+%%----------------------------------------------------------------------
+
+handle_segment_reply(_ConnHandle, _ProtocolVersion, _TransId, _SN, _SC) ->
+ ok.
+
+handle_segment_reply(_ConnHandle, _ProtocolVersion, _TransId, _SN, _SC, _Extra) ->
+ ok.
+