megaco

v4.8.3

megaco

Main API of the Megaco application

Interface module for the Megaco application

Summary

Types

action_reply()

action_reps()

action_reqs()

action_request()

conn_handle()

conn_info_item()

This type is a basic (atom) lookup key (for info on an active connection). The corresponding value can be of any type.

counter()

counter_value()

digit_map_event()

digit_map_kind()

digit_map_letter()

digit_map_value()

error_desc()

global_counter()

megaco_message()

megaco_timer()

mid()

The Megaco Identifier.

property_group()

property_groups()

property_parm()

protocol_version()

receive_handle()

sdp()

sdp_property_group()

sdp_property_groups()

sdp_property_parm()

segment_no()

send_handle()

Opaque send handle whose contents is internal for the send module. May be any term.

system_info_item()

System info items.

trace_data()

The trace data passed to the trace handler fun (in the second argument) and returned by same. For instance this could be a file descriptor, that the trace handler fun can use to print the event to a file.

trace_event()

The trace event generated by dbg.

trace_handler()

The trace handler fun is used to "process" each trace event (for instance print to file or to stdout after formating).

trace_level()

How much trace events should be produced. min (=0) means no trace events are produced, which is the default.

transaction_id()

transaction_reply()

user_info_item()

void()

The type is used when a functions return is to be ignored.

Functions

call(ConnHandle, ActionRequests, SendOptions)

Sends one or more transaction request(s) and waits for the reply.

cancel(ConnHandle, CancelReason)

Cancel all outstanding messages for this connection

cast(ConnHandle, ActionRequests, SendOptions)

Sends one or more transaction request(s) but does NOT wait for a reply

conn_info(ConnHandle)

Equivalent to conn_info/2.

conn_info(ConnHandle, ConnInfo)

Lookup information about an active connection

connect(ReceiveHandle, RemoteMid, SendHandle, ControlPid)

Equivalent to connect/5.

connect(ReceiveHandle, RemoteMid, SendHandle, ControlPid, Extra)

Establish a "virtual" connection

decode_sdp(PP)

Decode (parse) a property parameter construct.

disable_trace()

This function is used to stop megaco tracing.

disconnect(ConnHandle, DiscoReason)

Tear down a "virtual" connection

enable_trace(Level, Destination)

This function is used to start megaco tracing at a given Level and direct result to the given Destination.

encode_actions(ConnHandle, ActionRequests, Options)

Encodes lists of action requests for one or more transaction request(s).

encode_sdp(SDP)

Encode (generate) an SDP construct.

eval_digit_map(DigitMap)

Equivalent to eval_digit_map/2.

eval_digit_map(DigitMap, Timers)

Collect digit map letters according to the digit map.

get_stats()

Retreive all (SNMP) statistic counters maintained by the megaco application.

get_stats(ConnHandleOrGCounter)

Retreive a (SNMP) (global) statistic counter maintained by the megaco application.

get_stats(ConnHandle, Counter)

Retreive a (SNMP) statistic counter maintained by the megaco application.

info()

This function produces a list of information about the megaco application. Such as users and their config, connections and their config, statistics and so on.

parse_digit_map(DigitMapBody)

Parses a digit map body

print_version_info()

Equivalent to print_version_info/1.

print_version_info(Versions)

Utility function to produce a formated printout of the versions info generated by the versions1 and versions2 functions.

process_received_message(ReceiveHandle, ControlPid, SendHandle, BinMsg)

Equivalent to process_received_message/5.

process_received_message(ReceiveHandle, ControlPid, SendHandle, BinMsg, Extra)

Process a received message

receive_message(ReceiveHandle, ControlPid, SendHandle, BinMsg)

Equivalent to receive_message/5.

receive_message(ReceiveHandle, ControlPid, SendHandle, BinMsg, Extra)

Process a received message

report_digit_event(DigitMapEvalPid, Events)

Send one or more events to the event collector process.

reset_stats()

Reset all (SNMP) statistics counters.

reset_stats(ConnHandleOrGCounter)

Reset the specified (SNMP) statistics counter.

set_trace(Level)

This function is used to change the megaco trace level.

start()

Starts the Megaco application

start_user(UserMid, Config)

Initial configuration of a user

stop()

Stops the Megaco application

stop_user(UserMid)

Delete the configuration of a user

system_info()

Equivalent to system_info/1.

system_info(Item)

Lookup system information.

test_digit_event(DigitMap, Events)

Feed digit map collector with events and return the result

test_reply(ConnHandle, Version, EncodingMod, EncodingConfig, Reply)

Tests if the Reply argument is correctly composed.

test_request(ConnHandle, Version, EncodingMod, EncodingConfig, ActionRequests)

Tests if the Actions argument is correctly composed.

token_tag2string(Tag)

Equivalent to token_tag2string/3.

token_tag2string(Tag, EncodingMod)

Equivalent to token_tag2string/3.

token_tag2string(Tag, EncodingMod, Version)

Convert a token tag to a string

update_conn_info(ConnHandle, Item, Value)

Update information about an active connection

update_user_info(UserMid, Item, Value)

Update information about a user

user_info(UserMid)

Equivalent to user_info/2.

user_info(UserMid, Input)

Lookup user information

versions1()

Equivalent to versions2/0.

versions2()

Utility functions used to retrieve some system and application info.

Types

action_reply()

-type action_reply() :: megaco_encoder:action_reply().

action_reps()

(not exported)

-type action_reps() :: [action_reply()].

action_reqs()

(not exported)

-type action_reqs() :: binary() | [action_request()].

action_request()

-type action_request() :: megaco_encoder:action_request().

conn_handle()

-type conn_handle() :: megaco_user:conn_handle().

conn_info_item()

(not exported)

-type conn_info_item() ::
          control_pid | send_handle | local_mid | remote_mid | receive_handle | trans_id |
          max_trans_id | request_timer | long_request_timer | request_keep_alive_timeout |
          long_request_resend | reply_timer | call_proxy_gc_timeout | auto_ack | trans_ack |
          trans_ack_maxcount | trans_req | trans_req_maxcount | trans_req_maxsize | trans_timer |
          pending_timer | sent_pending_limit | recv_pending_limit | send_mod | encoding_mod |
          encoding_config | protocol_version | strict_version | reply_data | threaded |
          resend_indication | segment_reply_ind | segment_recv_timer | segment_send | max_pdu_size.

This type is a basic (atom) lookup key (for info on an active connection). The corresponding value can be of any type.

control_pid - The process identifier of the controlling process for a connection.

Value type: pid()

send_handle - Opaque send handle whose contents is internal for the send module.

Value type: send_handle/0

local_mid - The local mid (of the connection, i.e. the own mid).

Value type: mid/0

remote_mid - The remote mid (of the connection).

Value type: mid/0

receive_handle - Construct a megaco_receive_handle record.

Value type: receive_handle/0

trans_id - Next transaction id.

Note that transaction id's are (currently) maintained on a per user basis so there is no way to be sure that the value returned will actually be used for a transaction sent on this connection (in case a user has several connections, which is not at all unlikely).

Value type: transaction_id/0 | undefined_serial

max_trans_id - Last transaction id.

Value type: transaction_id/0 | infinity

request_timer - Wait for reply.

The timer is cancelled when a reply is received.

When a pending message is received, the timer is cancelled and the long_request_timer is started instead (see below). No resends will be performed from this point (since we now know that the other side has received the request).

When the timer reaches an intermediate expire, the request is resent and the timer is restarted.

When the timer reaches the final expire, either the function megaco:call will return with {error, timeout} or the callback function handle_trans_reply will be called with UserReply = {error, timeout} (if megaco:cast was used).

Value type: megaco_timer/0

Defaults to #megaco_incr_timer{}.

long_request_timer - Wait for reply after having received a pending message.

When the timer reaches an intermediate expire, the timer restarted.

When a pending message is received, and the long_request_timer is not "on its final leg", the timer will be restarted, and, if long_request_resend = true, the request will be re-sent.

Value type: megaco_timer/0

Defaults to 60 seconds.

request_keep_alive_timeout - Specifies the timeout time for the request-keep-alive timer.

This timer is started when the first reply to an asynchronous request (issued using the megaco:cast/3 function) arrives. As long as this timer is running, replies will be delivered via the handle_trans_reply/4,5 callback function, with their "arrival number" (see UserReply of the handle_trans_reply/4,5 callback function).

Replies arriving after the timer has expired, will be delivered using the handle_unexpected_trans/3,4 callback function.

Value type: plain | non_neg_integer()

Defaults to plain.

long_request_resend - This option indicates weather the request should be resent until the reply is received, even though a pending message has been received.

Normally, after a pending message has been received, the request is not resent (since a pending message is an indication that the request has been received). But since the reply (to the request) can be lost, this behaviour has its values.

It is of course pointless to set this value to true unless the long_request_timer (see above) is also set to an incremental timer (#megaco_incr_timer{}).

Value type: boolean()

Defaults to false.

reply_timer - Wait for an ack.

When a request is received, some info related to the reply is store internally (e.g. the binary of the reply). This info will live until either an ack is received or this timer expires. For instance, if the same request is received again (e.g. a request with the same transaction id), the (stored) reply will be (re-) sent automatically by megaco.

If the timer is of type #megaco_incr_timer{}, then for each intermediate timout, the reply will be resent (this is valid until the ack is received or the timer expires).

Value type: megaco_timer/0

Defaults to 30000.

call_proxy_gc_timeout - Timeout time for the call proxy.

When a request is sent using the call/3 function, a proxy process is started to handle all replies. When the reply has been received and delivered to the user, the proxy process continue to exist for as long as this option specifies. Any received messages, is passed on to the user via the handle_unexpected_trans callback function.

The timeout time is in milliseconds. A value of 0 (zero) means that the proxy process will exit directly after the reply has been delivered.

Value type: non_neg_integer()

Defaults to 5000 (= 5 seconds).

auto_ack - Automatic send transaction ack when the transaction reply has been received (see trans_ack below).

This is used for three-way-handshake.

Value type: boolean()

Defaults to false.

trans_ack - Shall ack's be accumulated or not.

This property is only valid if auto_ack is true.

If auto_ack is true, then if trans_ack is false, ack's will be sent immediately. If trans_ack is true, then ack's will instead be sent to the transaction sender process for accumulation and later sending (see trans_ack_maxcount, trans_req_maxcount, trans_req_maxsize, trans_ack_maxcount and trans_timer).

See also transaction sender for more info.

Value type: boolean()

Defaults to false.

trans_ack_maxcount - Maximum number of accumulated ack's. At most this many ack's will be accumulated by the transaction sender (if started and configured to accumulate ack's).

See also transaction sender for more info.

Value type: non_neg_integer()

Defaults to 10.

trans_req - Shall requests be accumulated or not.

If trans_req is false, then request(s) will be sent immediately (in its own message).

If trans_req is true, then request(s) will instead be sent to the transaction sender process for accumulation and later sending (see trans_ack_maxcount, trans_req_maxcount, trans_req_maxsize, trans_ack_maxcount and trans_timer).

See also transaction sender for more info.

Value type: boolean()

Defaults to false.

trans_req_maxcount - Maximum number of accumulated requests. At most this many requests will be accumulated by the transaction sender (if started and configured to accumulate requests).

See also transaction sender for more info.

Value type: non_neg_integer()

Defaults to 10.

trans_req_maxsize - Maximum size of the accumulated requests. At most this much requests will be accumulated by the transaction sender (if started and configured to accumulate requests).

See also transaction sender for more info.

Value type: non_neg_integer()

Defaults to 2048.

trans_timer - Transaction sender timeout time. Has two functions. First, if the value is 0, then transactions will not be accumulated (e.g. the transaction sender process will not be started). Second, if the value is greater then 0 and auto_ack and trans_ack is true or if trans_req is true, then transaction sender will be started and transactions (which is depending on the values of auto_ack, trans_ack and trans_req) will be accumulated, for later sending.

See also transaction sender for more info.

Value type: non_neg_integer()

Defaults to 0.

pending_timer - Automatic send transaction pending if the timer expires before a transaction reply has been sent. This timer is also called provisional response timer.

Value type: megaco_timer/0

Defaults to 30000 (= 30 seconds).

sent_pending_limit - Sent pending limit (see the MGOriginatedPendingLimit and the MGCOriginatedPendingLimit of the megaco root package). This parameter specifies how many pending messages that can be sent (for a given received transaction request). When the limit is exceeded, the transaction is aborted (see handle_trans_request_abort) and an error message is sent to the other side.

Note that this has no effect on the actual sending of pending transactions. This is either implicit (e.g. when receiving a re-sent transaction request for a request which is being processed) or controlled by the pending_timer, see above.

Value type: pos_integer() | infinity

Defaults to infinity.

recv_pending_limit - Receive pending limit (see the MGOriginatedPendingLimit and the MGCOriginatedPendingLimit of the megaco root package). This parameter specifies how many pending messages that can be received (for a sent transaction request). When the limit is exceeded, the transaction is considered lost, and an error returned to the user (through the call-back function handle_trans_reply).

Value type: pos_integer() | infinity

Defaults to infinity.

send_mod - Send callback module which exports send_message/2. The function SendMod:send_message(SendHandle, Binary) is invoked when the bytes needs to be transmitted to the remote user.

Value type: module().

Defaults to megaco_tcp.

encoding_mod - Encoding callback module which exports encode_message/2 and decode_message/2. The function EncodingMod:encode_message(EncodingConfig, MegacoMessage) is invoked whenever a 'MegacoMessage' record needs to be translated into an Erlang binary. The function EncodingMod:decode_message(EncodingConfig, Binary) is invoked whenever an Erlang binary needs to be translated into a 'MegacoMessage' record.

Value type: module().

Defaults to megaco_pretty_text_encoder.

encoding_config - Encoding module config.

Value type: loist().

Defaults to [].

protocol_version - Actual protocol version.

Value type: protocol_version/0

Defaults to 1.

strict_version - Strict version control, i.e. when a message is received, verify that the version is that which was negotiated.

Value type: boolean()

Defaults to true.

reply_data - Default reply data.

Value type: term()

Defaults to undefined.

threaded - If a received message contains several transaction requests, this option indicates whether the requests should be handled sequentially in the same process (false), or if each request should be handled by its own process (true i.e. a separate process is spawned for each request).

Value type: boolean()

Defaults to false.

resend_indication - This option indicates weather the transport module should be told if a message send is a resend or not.

If false, megaco messages are sent using the send_message/2 function.

If true, megaco message re-sends are made using the resend_message function. The initial message send is still done using the send_message function.

The special value flag instead indicates that the function send_message/3 shall be used.

Value type: flag | boolean()

Defaults to false.

segment_reply_ind - This option specifies if the user shall be notified of received segment replies or not.

See handle_segment_reply callback function for more information.

Value type: boolean()

Defaults to false.

segment_recv_timer - This timer is started when the segment indicated by the segmentation complete token (e.g. the last of the segment which makes up the reply) is received, but all segments has not yet been received.

When the timer finally expires, a "megaco segments not received" (459) error message is sent to the other side and the user is notified with a segment timeout UserReply in either the handle_trans_reply callback function or the return value of the call/2 function.

Value type: megaco_timer/0

Defaults to 10000 (= 10 seconds).

segment_send - Shall outgoing messages be segmented or not.

Value type: none | pos_integer() | infinity

none - Do not segment outgoing reply messages. This is useful when either it is known that messages are never to large or that the transport protocol can handle such things on its own (e.g. TCP or SCTP).

pos_integer/0 - Outgoing reply messages will be segmented as needed (see max_pdu_size below). This value, K, indicate the outstanding window, i.e. how many segments can be outstanding (not acknowledged) at any given time.

infinity - Outgoing reply messages will be segmented as needed (see max_pdu_size below). Segment messages are sent all at once (i.e. no acknowledgement awaited before sending the next segment).

Defaults to none.

max_pdu_size - Max message size. If the encoded message (PDU) exceeds this size, the message should be segmented, and then encoded.

Value type: infinity | pos_integer()

Defaults to infinity.

counter()

(not exported)

-type counter() :: medGwyGatewayNumTimerRecovery | medGwyGatewayNumErrors.

counter_value()

(not exported)

-type counter_value() :: non_neg_integer().

digit_map_event()

-type digit_map_event() :: megaco_digit_map:event().

digit_map_kind()

-type digit_map_kind() :: megaco_digit_map:kind().

digit_map_letter()

-type digit_map_letter() :: megaco_digit_map:letter().

digit_map_value()

-type digit_map_value() :: megaco_digit_map:value().

error_desc()

-type error_desc() :: megaco_encoder:error_desc().

global_counter()

(not exported)

-type global_counter() :: medGwyGatewayNumErrors.

megaco_message()

(not exported)

-type megaco_message() :: megaco_encoder:megaco_message().

megaco_timer()

(not exported)

-type megaco_timer() :: megaco_user:megaco_timer().

mid()

-type mid() ::
          {ip4Address, megaco_encoder:ip4Address()} |
          {ip6Address, megaco_encoder:ip6Address()} |
          {domainName, megaco_encoder:domainName()} |
          {deviceName, megaco_encoder:deviceName()} |
          {mtpAddress, megaco_encoder:mtpAddress()}.

The Megaco Identifier.

property_group()

-type property_group() :: megaco_sdp:property_group().

property_groups()

-type property_groups() :: megaco_sdp:property_groups().

property_parm()

-type property_parm() :: megaco_sdp:property_parm().

protocol_version()

-type protocol_version() :: megaco_encoder:protocol_version().

receive_handle()

-type receive_handle() :: megaco_user:receive_handle().

sdp()

-type sdp() :: megaco_sdp:sdp().

sdp_property_group()

(not exported)

-type sdp_property_group() :: megaco_sdp:sdp_property_group().

sdp_property_groups()

(not exported)

-type sdp_property_groups() :: megaco_sdp:sdp_property_groups().

sdp_property_parm()

(not exported)

-type sdp_property_parm() :: megaco_sdp:sdp_property_parm().

segment_no()

(not exported)

-type segment_no() :: megaco_encoder:segment_no().

send_handle()

(not exported)

-type send_handle() :: term().

Opaque send handle whose contents is internal for the send module. May be any term.

system_info_item()

(not exported)

-type system_info_item() ::
          text_config | connections | users | n_active_requests | n_active_replies |
          n_active_connections | reply_counters | pending_counters.

System info items.

text_config - The text encoding config.

Value type: term()

connections - Lists all active connections. Returns a list of megaco_conn_handle records.

Value type: [conn_handle/0]

users - Lists all active users.

Value type: [mid/0]

n_active_requests - Returns number of requests that has originated from this Erlang node and still are active (and therefore consumes system resources).

Value type: non_neg_integer()

n_active_replies - Returns the number of replies that has originated from this Erlang node and still are active (and therefore consumes system resources).

Value type: non_neg_integer()

n_active_connections - Returns the number of active connections.

Value type: non_neg_integer()

reply_counters - Returns a list of the reply counters.

Value type: [{conn_handle/0, transaction_id/0, non_neg_integer()}]

pending_counters - Returns a list of the receive and sent pending counters.

Value type: [{recv | sent, [{transaction_id/0, non_neg_integer()}]}]

trace_data()

(not exported)

-type trace_data() :: term().

The trace data passed to the trace handler fun (in the second argument) and returned by same. For instance this could be a file descriptor, that the trace handler fun can use to print the event to a file.

trace_event()

(not exported)

-type trace_event() :: term().

The trace event generated by dbg.

trace_handler()

(not exported)

-type trace_handler() :: fun((trace_event(), trace_data()) -> trace_data()).

The trace handler fun is used to "process" each trace event (for instance print to file or to stdout after formating).

trace_level()

-type trace_level() :: min | max | 0..100.

How much trace events should be produced. min (=0) means no trace events are produced, which is the default.

transaction_id()

(not exported)

-type transaction_id() :: pos_integer().

transaction_reply()

-type transaction_reply() :: megaco_encoder:transaction_reply().

user_info_item()

(not exported)

-type user_info_item() ::
          connections | receive_handle | trans_id | min_trans_id | max_trans_id | request_timer |
          long_request_timer | long_request_resend | reply_timer | request_keep_alive_timeout |
          call_proxy_gc_timeout | auto_ack | trans_ack | trans_ack_maxcount | trans_req |
          trans_req_maxcount | trans_req_maxsize | trans_timer | pending_timer | sent_pending_limit |
          recv_pending_limit | send_mod | encoding_mod | encoding_config | protocol_version |
          strict_version | reply_data | user_mod | user_args | threaded | resend_indication |
          segment_reply_ind | segment_recv_timer | segment_send | max_pdu_size.

connections - Lists all active connections for this user. Returns a list of megaco_conn_handle records.

Value type: [conn_handle/0]

receive_handle - Construct a receive_handle from user config.

Value type: receive_handle/0

trans_id - Current transaction id.

Value type: transaction_id/0 | undefined_serial

min_trans_id - First transaction id.

Value type: transaction_id/0

Defaults to 1.

max_trans_id - Last transaction id.

Value type: transaction_id/0 | infinity

Defaults to infinity.

request_timer - Wait for reply.

The timer is cancelled when a reply is received.

When a pending message is received, the timer is cancelled and the long_request_timer is started instead (see below). No resends will be performed from this point (since we now know that the other side has received the request).

When the timer reaches an intermediate expire, the request is resent and the timer is restarted.

When the timer reaches the final expire, either the function megaco:call will return with {error, timeout} or the callback function handle_trans_reply will be called with UserReply = {error, timeout} (if megaco:cast was used).

Value type: megaco_timer/0

Defaults to #megaco_incr_timer{}.

long_request_timer - Wait for reply after having received a pending message.

When the timer reaches an intermediate expire, the timer is restarted.

When a pending message is received, and the long_request_timer is not "on its final leg", the timer will be restarted, and, if long_request_resend = true, the request will be re-sent.

Value type: megaco_timer/0

Defaults to 60000 (= 60 seconds).

long_request_resend - This option indicates weather the request should be resent until the reply is received, even though a pending message has been received.

Normally, after a pending message has been received, the request is not resent (since a pending message is an indication that the request has been received). But since the reply (to the request) can be lost, this behaviour has its values.

It is of course pointless to set this value to true unless the long_request_timer (see above) is also set to an incremental timer (#megaco_incr_timer{}).

Value type: boolean()

Defaults to false.

reply_timer - Wait for an ack.

When a request is received, some info related to the reply is store internally (e.g. the binary of the reply). This info will live until either an ack is received or this timer expires. For instance, if the same request is received again (e.g. a request with the same transaction id), the (stored) reply will be (re-) sent automatically by megaco.

If the timer is of type #megaco_incr_timer{}, then for each intermediate timout, the reply will be resent (this is valid until the ack is received or the timer expires).

Value type: megaco_timer/0

Defaults to 30 seconds.

request_keep_alive_timeout - Specifies the timeout time for the request-keep-alive timer.

This timer is started when the first reply to an asynchronous request (issued using the megaco:cast/3 function) arrives. As long as this timer is running, replies will be delivered via the handle_trans_reply/4,5 callback function, with their "arrival number" (see UserReply of the handle_trans_reply/4,5 callback function).

Replies arriving after the timer has expired, will be delivered using the handle_unexpected_trans/3,4 callback function.

Value type: plain | non_neg_integer()

Defaults to plain.

call_proxy_gc_timeout - Timeout time for the call proxy.

When a request is sent using the call/3 function, a proxy process is started to handle all replies. When the reply has been received and delivered to the user, the proxy process continue to exist for as long as this option specifies. Any received messages, is passed on to the user via the handle_unexpected_trans callback function.

The timeout time is in milliseconds. A value of 0 (zero) means that the proxy process will exit directly after the reply has been delivered.

Value type: pos_integer()

Defaults to 5000 (= 5 seconds).

auto_ack - Automatic send transaction ack when the transaction reply has been received (see trans_ack below).

This is used for three-way-handshake.

Value type: boolean()

Defaults to false.

trans_ack - Shall ack's be accumulated or not.

This property is only valid if auto_ack is true.

If auto_ack is true, then if trans_ack is false, ack's will be sent immediately. If trans_ack is true, then ack's will instead be sent to the transaction sender process for accumulation and later sending (see trans_ack_maxcount, trans_req_maxcount, trans_req_maxsize, trans_ack_maxcount and trans_timer).

See also transaction sender for more info.

Value type: boolean()

Defaults to false.

trans_ack_maxcount - Maximum number of accumulated ack's. At most this many ack's will be accumulated by the transaction sender (if started and configured to accumulate ack's).

See also transaction sender for more info.

Value type: integer()

Defaults to 10.

trans_req - Shall requests be accumulated or not.

If trans_req is false, then request(s) will be sent immediately (in its own message).

If trans_req is true, then request(s) will instead be sent to the transaction sender process for accumulation and later sending (see trans_ack_maxcount, trans_req_maxcount, trans_req_maxsize, trans_ack_maxcount and trans_timer).

See also transaction sender for more info.

Value type: boolean()

Defaults to false.

trans_req_maxcount - Maximum number of accumulated requests. At most this many requests will be accumulated by the transaction sender (if started and configured to accumulate requests).

See also transaction sender for more info.

Value type: integer()

Defaults to 10.

trans_req_maxsize - Maximum size of the accumulated requests. At most this much requests will be accumulated by the transaction sender (if started and configured to accumulate requests).

See also transaction sender for more info.

Value type: integer()

Defaults to 2048.

trans_timer - Transaction sender timeout time. Has two functions. First, if the value is 0, then transactions will not be accumulated (e.g. the transaction sender process will not be started). Second, if the value is greater then 0 and auto_ack and trans_ack are both true or if trans_req is true, then transaction sender will be started and transactions (which is depending on the values of auto_ack, trans_ack and trans_req) will be accumulated, for later sending.

See also transaction sender for more info.

Value type: integer()

Defaults to 0.

pending_timer - Automatically send pending if the timer expires before a transaction reply has been sent. This timer is also called provisional response timer.

Value type: megaco_timer/0

Defaults to 30000.

sent_pending_limit - Sent pending limit (see the MGOriginatedPendingLimit and the MGCOriginatedPendingLimit of the megaco root package). This parameter specifies how many pending messages that can be sent (for a given received transaction request). When the limit is exceeded, the transaction is aborted (see handle_trans_request_abort) and an error message is sent to the other side.

Note that this has no effect on the actual sending of pending transactions. This is either implicit (e.g. when receiving a re-sent transaction request for a request which is being processed) or controlled by the pending_timer, see above.

Value type: infinity | pos_integer()

Defaults to infinity.

recv_pending_limit - Receive pending limit (see the MGOriginatedPendingLimit and the MGCOriginatedPendingLimit of the megaco root package). This parameter specifies how many pending messages that can be received (for a sent transaction request). When the limit is exceeded, the transaction is considered lost, and an error returned to the user (through the call-back function handle_trans_reply).

Value type: infinity | pos_integer()

Defaults to infinity.

send_mod - Send callback module which exports send_message/2. The function SendMod:send_message(SendHandle, Binary) is invoked when the bytes needs to be transmitted to the remote user.

Value type: module()

Defaults to megaco_tcp.

encoding_mod - Encoding callback module which exports encode_message/2 and decode_message/2. The function EncodingMod:encode_message(EncodingConfig, MegacoMessage) is invoked whenever a 'MegacoMessage' record needs to be translated into an Erlang binary. The function EncodingMod:decode_message(EncodingConfig, Binary) is invoked whenever an Erlang binary needs to be translated into a 'MegacoMessage' record.

Value type: module()

Defaults to megaco_pretty_text_encoder.

encoding_config - Encoding module config.

Value type: list()

Defaults to [].

protocol_version - Actual protocol version.

Value type: protocol_version/0

Defaults to 1.

strict_version - Strict version control, i.e. when a message is received, verify that the version is that which was negotiated.

Value type: boolean()

Defaults to true.

reply_data - Default reply data.

Value type: term()

Defaults to undefined.

user_mod - Name of the user callback module. See the the reference manual for megaco_user for more info.

Value type: module()

Has no default value since its an mandatory config option.

user_args - List of extra arguments to the user callback functions. See the the reference manual for megaco_user for more info.

Value type: list()

threaded - If a received message contains several transaction requests, this option indicates whether the requests should be handled sequentially in the same process (false), or if each request should be handled by its own process (true i.e. a separate process is spawned for each request).

Value type: boolean()

Defaults to false.

resend_indication - This option indicates weather the transport module should be told if a message send is a resend or not.

If false, megaco messages are sent using the send_message function.

If true, megaco message re-sends are made using the resend_message function. The initial message send is still done using the send_message function.

The special value flag instead indicates that the function send_message/3 shall be used.

Value type: boolean()

Defaults to false.

segment_reply_ind - This option specifies if the user shall be notified of received segment replies or not.

See handle_segment_reply callback function for more information.

Value type: boolean()

Defaults to false.

segment_recv_timer - This timer is started when the segment indicated by the segmentation complete token is received, but all segments has not yet been received.

When the timer finally expires, a "megaco segments not received" (459) error message is sent to the other side and the user is notified with a segment timeout UserReply in either the handle_trans_reply callback function or the return value of the call/3 function.

Value type: megaco_timer/0

Defaults to 10000.

segment_send - Shall outgoing messages be segmented or not.

Value type: none | pos_integer() | infinity

none - Do not segment outgoing reply messages. This is useful when either it is known that messages are never to large or that the transport protocol can handle such things on its own (e.g. TCP or SCTP).

pos_integer/0 - Outgoing reply messages will be segmented as needed (see max_pdu_size below). This value, K, indicate the outstanding window, i.e. how many segments can be outstanding (not acknowledged) at any given time.

infinity - Outgoing reply messages will be segmented as needed (see max_pdu_size below). Segment messages are sent all at once (i.e. no acknowledgement awaited before sending the next segment).

Defaults to none.

max_pdu_size - Max message size. If the encoded message (PDU) exceeds this size, the message should be segmented, and then encoded.

Value type: infinity | pos_integer()

Defaults to infinity.

void()

-type void() :: term().

The type is used when a functions return is to be ignored.

Functions

call(ConnHandle, ActionRequests, SendOptions)

-spec call(ConnHandle, ActionRequests, SendOptions) -> {ProtocolVersion, UserReply | [UserReply]}
              when
                  ConnHandle :: conn_handle(),
                  ActionRequests :: action_reqs() | [action_reqs()],
                  SendOptions :: [SendOption],
                  SendOption ::
                      {request_timer, megaco_timer()} |
                      {long_request_timer, megaco_timer()} |
                      {send_handle, send_handle()} |
                      {protocol_version, protocol_version()} |
                      {call_proxy_gc_timeout, non_neg_integer()},
                  ProtocolVersion :: protocol_version(),
                  UserReply :: Success | Failure,
                  Success :: {ok, Result} | {ok, Result, SuccessExtra},
                  Result :: MessageResult | SegmentResult,
                  MessageResult :: action_reps(),
                  SegmentResult :: SegmentsOk,
                  SegmentsOk :: [{segment_no(), action_reps()}],
                  Failure :: {error, Reason} | {error, Reason, ErrorExtra},
                  Reason :: MessageReason | SegmentReason | UserCancelReason | SendReason | OtherReason,
                  MessageReason :: error_desc(),
                  SegmentReason ::
                      {segment, SegmentsOk, SegmentsErr} |
                      {segment_timeout, MissingSegments, SegmentsOk, SegmentsErr},
                  SegmentsErr :: {segment_no(), error_desc()},
                  MissingSegments :: [segment_no()],
                  UserCancelReason :: {user_cancel, ReasonForUserCancel},
                  ReasonForUserCancel :: term(),
                  SendReason :: SendCancelledReason | SendFailedReason,
                  SendCancelledReason :: {send_message_cancelled, term()},
                  SendFailedReason :: {send_message_failed, term()},
                  OtherReason ::
                      {wrong_mid, WrongMid :: mid(), RightMid :: mid(), transaction_reply()} | term(),
                  SuccessExtra :: term(),
                  ErrorExtra :: term().

Sends one or more transaction request(s) and waits for the reply.

When sending one transaction in a message, ActionRequests should be action_reqs/0 (the reply will then be UserReply). When sending several transactions in a message, ActionRequests should be [action_reqs()] (the reply will then be [UserReply]). Each element of the list is part of one transaction.

For some of our codecs (not binary), it is also possible to pre-encode the actions, in which case ActionRequests will be either a binary/0 or [binary()].

The function returns when the reply arrives, when the request timer eventually times out or when the outstanding requests are explicitly cancelled.

The default values of the send options are obtained by megaco:conn_info(ConnHandle, Item). But the send options above, may explicitly be overridden.

The ProtocolVersion version is the version actually encoded in the reply message.

At Success, the UserReply contains a list of 'ActionReply' records possibly containing error indications.

A Failure, indicates that the remote user has replied with an explicit transactionError.

A UserCancelReason, indicates that the request has been canceled by the user. ReasonForUserCancel is the reason given in the call to the cancel/2 function.

A send error (SendReason), indicates that the send function of the megaco transport callback module failed to send the request. There are two separate cases: SendCancelledReason and SendFailedReason. The first is the result of the send function returning {cancel, Reason} and the second is some other kind of erroneous return value. See the send_message function for more info.

An OtherReason, indicates some other error such as timeout.

For more info about the 'extra' part of the result (SuccessExtra and ErrorExtra), see the note in the user callback module documentation.

cancel(ConnHandle, CancelReason)

-spec cancel(ConnHandle, CancelReason) -> ok | {error, Reason}
                when ConnHandle :: conn_handle(), CancelReason :: term(), Reason :: term().

Cancel all outstanding messages for this connection

This causes outstanding megaco:call/3 requests to return. The callback functions UserMod:handle_reply/4 and UserMod:handle_trans_ack/4 are also invoked where it applies. See the megaco_user module for more info about the callback arguments.

cast(ConnHandle, ActionRequests, SendOptions)

-spec cast(ConnHandle, ActionRequests, SendOptions) -> ok | {error, Reason}
              when
                  ConnHandle :: conn_handle(),
                  ActionRequests :: action_reqs() | [action_reqs()],
                  SendOptions :: [SendOption],
                  SendOption ::
                      {request_keep_alive_timeout, RequestKeepAliveTimer} |
                      {request_timer, megaco_timer()} |
                      {long_request_timer, megaco_timer()} |
                      {send_handle, send_handle()} |
                      {reply_data, ReplyData} |
                      {protocol_version, ProtocolVersion},
                  RequestKeepAliveTimer :: plain | non_neg_integer(),
                  ReplyData :: term(),
                  ProtocolVersion :: protocol_version(),
                  Reason :: term().

Sends one or more transaction request(s) but does NOT wait for a reply

When sending one transaction in a message, ActionRequests should be action_reqs/0. When sending several transactions in a message, ActionRequests should be [action_reqs()]. Each element of the list is part of one transaction.

For some of our codecs (not binary), it is also possible to pre-encode the actions, in which case Actions will be either a binary/0 or [binary()].

The default values of the send options are obtained by megaco:conn_info(ConnHandle, Item). But the send options above, may explicitly be overridden.

The ProtocolVersion version is the version actually encoded in the reply message.

The callback function UserMod:handle_trans_reply/4 is invoked when the reply arrives, when the request timer eventually times out or when the outstanding requests are explicitly cancelled. See the megaco_user module for more info about the callback arguments.

Given as ReplyData argument to UserMod:handle_trans_reply/4.

conn_info(ConnHandle)

-spec conn_info(ConnHandle) -> [{Item, Value}]
                   when
                       ConnHandle :: conn_handle(),
                       Item :: requests | replies | conn_info_item(),
                       Value :: term().

Equivalent to conn_info/2.

conn_info(ConnHandle, ConnInfo)

-spec conn_info(ConnHandle, ConnInfo) -> Value
                   when
                       ConnHandle :: conn_handle(),
                       ConnInfo :: all | requests | replies | conn_info_item(),
                       Value :: term().

Lookup information about an active connection

Requires that the connection is active.

Failure: exit if, for instance, ConnHandle refers to a connection that no longer exists.

connect(ReceiveHandle, RemoteMid, SendHandle, ControlPid)

-spec connect(ReceiveHandle, RemoteMid, SendHandle, ControlPid) -> {ok, ConnHandle} | {error, Reason}
                 when
                     ReceiveHandle :: receive_handle(),
                     RemoteMid :: preliminary_mid | mid(),
                     SendHandle :: send_handle(),
                     ControlPid :: pid(),
                     ConnHandle :: conn_handle(),
                     Reason :: ConnectReason | HandleConnectReason | term(),
                     ConnectReason ::
                         {no_such_user, LocalMid} | {already_connected, ConnHandle} | term(),
                     LocalMid :: mid(),
                     HandleConnectReason :: {connection_refused, ConnData, ErrorInfo} | term(),
                     ConnData :: term(),
                     ErrorInfo :: term().

Equivalent to connect/5.

connect(ReceiveHandle, RemoteMid, SendHandle, ControlPid, Extra)

-spec connect(ReceiveHandle, RemoteMid, SendHandle, ControlPid, Extra) ->
                 {ok, ConnHandle} | {error, Reason}
                 when
                     ReceiveHandle :: receive_handle(),
                     RemoteMid :: preliminary_mid | mid(),
                     SendHandle :: send_handle(),
                     ControlPid :: pid(),
                     Extra :: term(),
                     ConnHandle :: conn_handle(),
                     Reason :: ConnectReason | HandleConnectReason | term(),
                     ConnectReason ::
                         {no_such_user, LocalMid} | {already_connected, ConnHandle} | term(),
                     LocalMid :: mid(),
                     HandleConnectReason :: {connection_refused, ConnData, ErrorInfo} | term(),
                     ConnData :: term(),
                     ErrorInfo :: term().

Establish a "virtual" connection

Activates a connection to a remote user. When this is done the connection can be used to send messages (with SendMod:send_message/2). The ControlPid is the identifier of a process that controls the connection. That process will be supervised and if it dies, this will be detected and the UserMod:handle_disconnect/2 callback function will be invoked. See the megaco_user module for more info about the callback arguments. The connection may also explicitly be deactivated by invoking megaco:disconnect/2.

The ControlPid may be the identity of a process residing on another Erlang node. This is useful when you want to distribute a user over several Erlang nodes. In such a case one of the nodes has the physical connection. When a user residing on one of the other nodes needs to send a request (with megaco:call/3 or megaco:cast/3), the message will encoded on the originating Erlang node, and then be forwarded to the node with the physical connection. When the reply arrives, it will be forwarded back to the originator. The distributed connection may explicitly be deactivated by a local call to megaco:disconnect/2 or implicitly when the physical connection is deactivated (with megaco:disconnect/2, killing the controlling process, halting the other node, ...).

The call of this function will trigger the callback function UserMod:handle_connect/2 to be invoked. See the megaco_user module for more info about the callback arguments.

A connection may be established in several ways:

provisioned MID - The MG may explicitly invoke megaco:connect/4 and use a provisioned MID of the MGC as the RemoteMid.

upgrade preliminary MID - The MG may explicitly invoke megaco:connect/4 with the atom 'preliminary_mid' as a temporary MID of the MGC, send an intial message, the Service Change Request, to the MGC and then wait for an initial message, the Service Change Reply. When the reply arrives, the Megaco application will pick the MID of the MGC from the message header and automatically upgrade the connection to be a "normal" connection. By using this method of establishing the connection, the callback function UserMod:handle_connect/2 to be invoked twice. First with a ConnHandle with the remote_mid-field set to preliminary_mid, and then when the connection upgrade is done with the remote_mid-field set to the actual MID of the MGC.

automatic - When the MGC receives its first message, the Service Change Request, the Megaco application will automatically establish the connection by using the MG MID found in the message header as remote mid.

distributed - When a user (MG/MGC) is distributed over several nodes, it is required that the node hosting the connection already has activated the connection and that it is in the "normal" state. The RemoteMid must be a real Megaco MID and not a preliminary_mid.

An initial megaco_receive_handle record may be obtained with megaco:user_info(UserMid, receive_handle)

The send handle is provided by the preferred transport module, e.g. megaco_tcp, megaco_udp. Read the documentation about each transport module about the details.

The connect is done in two steps: first an internal connection setup and then by calling the user handle_connect callback function. The first step could result in an error with Reason = ConnectReason and the second an error with Reason = HandleConnectReason:

ConnectReason - An error with this reason is generated by the megaco application itself.

HandleConnectReason - An error with this reason is caused by the user handle_connect callback function either returning an error or an invalid value.

Extra can be any term/0 except the atom ignore_extra. It is passed (back) to the user via the callback function handle_connect/3.

decode_sdp(PP)

-spec decode_sdp(PP) -> {ok, SDP} | {error, Reason}
                    when
                        PP :: property_parm() | property_group() | property_groups() | asn1_NOVALUE,
                        SDP :: sdp() | DecodeSdpPropertyGroup | DecodeSdpPropertyGroups | asn1_NOVALUE,
                        DecodeSdpPropertyGroup :: [DecodeSDP],
                        DecodeSdpPropertyGroups :: [DecodeSdpPropertyGroup],
                        DecodeSDP :: sdp() | {property_parm(), DecodeError},
                        DecodeError :: term(),
                        Reason :: term().

Decode (parse) a property parameter construct.

When decoding property_group/0 or property_groups/0, those property parameter constructs that cannot be decoded (either because of decode error or because they are unknown), will be returned as a two-tuple. The first element of which will be the (undecoded) property parameter and the other the actual reason. This means that the caller of this function has to expect not only sdp-records, but also this two-tuple construct.

This function performs the following transformation:

property_parm() -> sdp()

property_group() -> sdp_property_group()

property_groups() -> sdp_property_groups()

disable_trace()

-spec disable_trace() -> void().

This function is used to stop megaco tracing.

disconnect(ConnHandle, DiscoReason)

-spec disconnect(ConnHandle, DiscoReason) -> ok | {error, ErrReason}
                    when ConnHandle :: conn_handle(), DiscoReason :: term(), ErrReason :: term().

Tear down a "virtual" connection

Causes the UserMod:handle_disconnect/2 callback function to be invoked. See the megaco_user module for more info about the callback arguments.

enable_trace(Level, Destination)

-spec enable_trace(Level, Destination) -> void()
                      when
                          Level :: trace_level(),
                          Destination :: File | Port | HandlerSpec | io,
                          File :: string(),
                          Port :: integer(),
                          HandlerSpec :: {HandlerFun, InitialData},
                          HandlerFun :: trace_handler(),
                          InitialData :: trace_data().

This function is used to start megaco tracing at a given Level and direct result to the given Destination.

It starts a tracer server and then sets the proper match spec (according to Level).

In the case when Destination is File, the printable megaco trace events will be printed to the file File using plain io:format/2.

In the case when Destination is io, the printable megaco trace events will be printed on stdout using plain io:format/2.

See dbg for further information.

encode_actions(ConnHandle, ActionRequests, Options)

-spec encode_actions(ConnHandle, ActionRequests, Options) -> {ok, Result} | {error, Reason}
                        when
                            ConnHandle :: conn_handle(),
                            ActionRequests :: action_reqs() | [action_reqs()],
                            Options :: [Option],
                            Option ::
                                {request_timer, megaco_timer()} |
                                {long_request_timer, megaco_timer()} |
                                {send_handle, send_handle()} |
                                {protocol_version, protocol_version()},
                            Result :: binary() | [binary()],
                            Reason :: term().

Encodes lists of action requests for one or more transaction request(s).

When encoding action requests for one transaction, Actions should be action_reqs/0. When encoding action requests for several transactions, Actions should be [action_reqs()]. Each element of the list is part of one transaction.

encode_sdp(SDP)

-spec encode_sdp(SDP) -> {ok, PP} | {error, Reason}
                    when
                        SDP ::
                            sdp_property_parm() |
                            sdp_property_group() |
                            sdp_property_groups() |
                            asn1_NOVALUE,
                        PP :: property_parm() | property_group() | property_groups() | asn1_NOVALUE,
                        Reason :: term().

Encode (generate) an SDP construct.

If a property_parm/0 is found as part of the input (SDP) then it is left unchanged.

This function performs the following transformation:

sdp() -> property_parm()

sdp_property_group() -> property_group()

sdp_property_groups() -> property_groups()

eval_digit_map(DigitMap)

-spec eval_digit_map(DigitMap) -> {ok, MatchResult} | {error, Reason}
                        when
                            DigitMap :: digit_map_value() | ParsedDigitMap,
                            ParsedDigitMap :: term(),
                            MatchResult :: {Kind, Letters} | {Kind, Letters, Extra},
                            Kind :: digit_map_kind(),
                            Letters :: [digit_map_letter()],
                            Extra :: digit_map_letter(),
                            Reason :: term().

Equivalent to eval_digit_map/2.

eval_digit_map(DigitMap, Timers)

-spec eval_digit_map(DigitMap, Timers) -> {ok, MatchResult} | {error, Reason}
                        when
                            DigitMap :: digit_map_value() | ParsedDigitMap,
                            ParsedDigitMap :: term(),
                            Timers :: Ignore | Reject,
                            Ignore :: ignore | {ignore, digit_map_value()},
                            Reject :: reject | {reject, digit_map_value()} | digit_map_value(),
                            MatchResult :: {Kind, Letters} | {Kind, Letters, Extra},
                            Kind :: digit_map_kind(),
                            Letters :: [digit_map_letter()],
                            Extra :: digit_map_letter(),
                            Reason :: term().

Collect digit map letters according to the digit map.

When evaluating a digit map, a state machine waits for timeouts and letters reported by megaco:report_digit_event/2. The length of the various timeouts are defined in the digit_map_value() record.

When a complete sequence of valid events has been received, the result is returned as a list of letters.

There are two options for handling syntax errors (that is when an unexpected event is received when the digit map evaluator is expecting some other event). The unexpected events may either be ignored or rejected. The latter means that the evaluation is aborted and an error is returned.

get_stats()

-spec get_stats() -> {ok, [TotalStats]} | {error, Reason}
                   when
                       TotalStats :: {conn_handle(), [Stats]} | {global_counter(), counter_value()},
                       Stats :: {counter(), counter_value()},
                       Reason :: term().

Retreive all (SNMP) statistic counters maintained by the megaco application.

The global counters handle events that cannot be attributed to a single connection (e.g. protocol errors that occur before the connection has been properly setup).

get_stats(ConnHandleOrGCounter)

-spec get_stats(GCounter) -> {ok, Value} | {error, Reason}
                   when GCounter :: global_counter(), Value :: counter_value(), Reason :: term();
               (ConnHandle) -> {ok, [Stats]} | {error, Reason}
                   when
                       ConnHandle :: conn_handle(),
                       Stats :: {counter(), counter_value()},
                       Reason :: term().

Retreive a (SNMP) (global) statistic counter maintained by the megaco application.

The global counters handle events that cannot be attributed to a single connection (e.g. protocol errors that occur before the connection has been properly setup).

Retreive all (SNMP) statistic counters maintained by the megaco application, for a specific connection.

get_stats(ConnHandle, Counter)

-spec get_stats(ConnHandle, Counter) -> {ok, Value} | {error, Reason}
                   when
                       ConnHandle :: conn_handle(),
                       Counter :: counter(),
                       Value :: counter_value(),
                       Reason :: term().

Retreive a (SNMP) statistic counter maintained by the megaco application.

info()

-spec info() -> Info when Info :: [{Key, Value}], Key :: atom(), Value :: term().

This function produces a list of information about the megaco application. Such as users and their config, connections and their config, statistics and so on.

This information can be produced by the functions user_info/2, conn_info/2, system_info/1 and get_stats/2 but this is a simple way to get it all at once.

parse_digit_map(DigitMapBody)

-spec parse_digit_map(DigitMapBody) -> {ok, ParsedDigitMap} | {error, Reason}
                         when DigitMapBody :: string(), ParsedDigitMap :: term(), Reason :: term().

Parses a digit map body

Parses a digit map body, represented as a list of characters, into a list of state transitions suited to be evaluated by megaco:eval_digit_map/1,2.

print_version_info()

-spec print_version_info() -> void().

Equivalent to print_version_info/1.

print_version_info(Versions)

-spec print_version_info(Versions) -> void() when Versions :: [VersionInfo], VersionInfo :: term().

Utility function to produce a formated printout of the versions info generated by the versions1 and versions2 functions.

The function print_version_info/0 uses the result of function version1/0 as VersionInfo.

Example:

           {ok, V} = megaco:versions1(), megaco:format_versions(V).

process_received_message(ReceiveHandle, ControlPid, SendHandle, BinMsg)

-spec process_received_message(ReceiveHandle, ControlPid, SendHandle, BinMsg) -> ok
                                  when
                                      ReceiveHandle :: receive_handle(),
                                      ControlPid :: pid(),
                                      SendHandle :: send_handle(),
                                      BinMsg :: binary().

Equivalent to process_received_message/5.

process_received_message(ReceiveHandle, ControlPid, SendHandle, BinMsg, Extra)

-spec process_received_message(ReceiveHandle, ControlPid, SendHandle, BinMsg, Extra) -> ok
                                  when
                                      ReceiveHandle :: receive_handle(),
                                      ControlPid :: pid(),
                                      SendHandle :: send_handle(),
                                      BinMsg :: binary(),
                                      Extra :: term().

Process a received message

This function is intended to be invoked by some transport modules when get an incoming message. Which transport that actually is used is up to the user to choose.

The message is delivered as an Erlang binary and is decoded by the encoding module stated in the receive handle together with its encoding config (also in the receive handle). Depending of the outcome of the decoding various callback functions will be invoked. See megaco_user for more info about the callback arguments.

The argument Extra is just an opaque data structure passed to the user via the callback functions in the user callback module. Note however that if Extra has the value extra_undefined the argument will be ignored (same as if process_received_message/4 had been called). See the documentation for the behaviour of the callback module, megaco_user, for more info.

Note that all processing is done in the context of the calling process. A transport module could call this function via one of the spawn functions (e.g. spawn_opt). See also receive_message/4,5.

If the message cannot be decoded the following callback function will be invoked:

UserMod:handle_syntax_error/3

If the decoded message instead of transactions contains a message error, the following callback function will be invoked:

UserMod:handle_message_error/3

If the decoded message happens to be received before the connection is established, a new "virtual" connection is established. This is typically the case for the Media Gateway Controller (MGC) upon the first Service Change. When this occurs the following callback function will be invoked:

UserMod:handle_connect/2

For each transaction request in the decoded message the following callback function will be invoked:

UserMod:handle_trans_request/3

For each transaction reply in the decoded message the reply is returned to the user. Either the originating function megaco:call/3 will return. Or in case the originating function was megaco:case/3 the following callback function will be invoked:

UserMod:handle_trans_reply/4

When a transaction acknowledgement is received it is possible that user has decided not to bother about the acknowledgement. But in case the return value from UserMod:handle_trans_request/3 indicates that the acknowledgement is important the following callback function will be invoked:

UserMod:handle_trans_ack/4

See the megaco_user module for more info about the callback arguments.

receive_message(ReceiveHandle, ControlPid, SendHandle, BinMsg)

-spec receive_message(ReceiveHandle, ControlPid, SendHandle, BinMsg) -> ok
                         when
                             ReceiveHandle :: receive_handle(),
                             ControlPid :: pid(),
                             SendHandle :: send_handle(),
                             BinMsg :: binary().

Equivalent to receive_message/5.

receive_message(ReceiveHandle, ControlPid, SendHandle, BinMsg, Extra)

-spec receive_message(ReceiveHandle, ControlPid, SendHandle, BinMsg, Extra) -> ok
                         when
                             ReceiveHandle :: receive_handle(),
                             ControlPid :: pid(),
                             SendHandle :: send_handle(),
                             BinMsg :: binary(),
                             Extra :: term().

Process a received message

This is a callback function intended to be invoked by some transport modules when get an incoming message. Which transport that actually is used is up to the user to choose.

In principle, this function calls the process_received_message/4,5 function via a spawn to perform the actual processing.

report_digit_event(DigitMapEvalPid, Events)

-spec report_digit_event(DigitMapEvalPid, Events) -> ok | {error, Reason}
                            when
                                DigitMapEvalPid :: pid(),
                                Events :: digit_map_event() | [digit_map_event()],
                                Reason :: term().

Send one or more events to the event collector process.

Send one or more events to a process that is evaluating a digit map, that is a process that is executing megaco:eval_digit_map/1,2.

Note that the events $s | $S, l | $L and $z | $Z has nothing to do with the timers using the same characters.

reset_stats()

-spec reset_stats() -> void().

Reset all (SNMP) statistics counters.

reset_stats(ConnHandleOrGCounter)

-spec reset_stats(GCounter) -> void() when GCounter :: global_counter();
                 (ConnHandle) -> void() when ConnHandle :: conn_handle().

Reset the specified (SNMP) statistics counter.

Reset all (SNMP) statistics counters for a connection.

set_trace(Level)

-spec set_trace(Level) -> void() when Level :: trace_level().

This function is used to change the megaco trace level.

It is assumed that tracing has already been enabled (see enable_trace above).

start()

-spec start() -> ok | {error, Reason} when Reason :: term().

Starts the Megaco application

Users may either explicitly be registered with megaco:start_user/2 and/or be statically configured by setting the application environment variable 'users' to a list of {UserMid, Config} tuples. See the function megaco:start_user/2 for details.

start_user(UserMid, Config)

-spec start_user(UserMid, Config) -> ok | {error, Reason}
                    when
                        UserMid :: mid(),
                        Config :: [{Item, Value}],
                        Item :: user_info_item(),
                        Value :: term(),
                        Reason :: term().

Initial configuration of a user

Requires the megaco application to be started. A user is either a Media Gateway (MG) or a Media Gateway Controller (MGC). One Erlang node may host many users.

A user is identified by its UserMid, which must be a legal Megaco MID.

Config is a list of {Item, Value} tuples. See megaco:user_info/2 about which items and values that are valid.

stop()

-spec stop() -> ok | {error, Reason} when Reason :: term().

Stops the Megaco application

stop_user(UserMid)

-spec stop_user(UserMid) -> ok | {error, Reason} when UserMid :: mid(), Reason :: term().

Delete the configuration of a user

Requires that the user does not have any active connection.

system_info()

-spec system_info() -> [{Item, Value}] when Item :: system_info_item(), Value :: term().

Equivalent to system_info/1.

system_info(Item)

-spec system_info(Item) -> Value when Item :: system_info_item(), Value :: term().

Lookup system information.

test_digit_event(DigitMap, Events)

-spec test_digit_event(DigitMap, Events) -> {ok, Kind, Letters} | {error, Reason}
                          when
                              DigitMap :: digit_map_value() | ParsedDigitMap,
                              ParsedDigitMap :: term(),
                              Events :: digit_map_event() | [digit_map_event()],
                              Kind :: digit_map_kind(),
                              Letters :: [digit_map_letter()],
                              Reason :: term().

Feed digit map collector with events and return the result

This function starts the evaluation of a digit map with megaco:eval_digit_map/1 and sends a sequence of events to it with megaco:report_digit_event/2 in order to simplify testing of digit maps.

test_reply(ConnHandle, Version, EncodingMod, EncodingConfig, Reply)

-spec test_reply(ConnHandle, Version, EncodingMod, EncodingConfig, Reply) -> {MegaMsg, EncodeRes}
                    when
                        ConnHandle :: conn_handle(),
                        Version :: protocol_version(),
                        EncodingMod :: module(),
                        EncodingConfig :: list(),
                        Reply :: error_desc() | [action_reply()],
                        MegaMsg :: megaco_message(),
                        EncodeRes :: {ok, Bin} | {error, Reason},
                        Bin :: binary(),
                        Reason :: term().

Tests if the Reply argument is correctly composed.

This function is only intended for testing purposes. It's supposed to test the actual_reply() return value of the callback functions handle_trans_request and handle_trans_long_request functions (with the additions of the EncodingMod and EncodingConfig arguments). It composes a complete megaco message end attempts to encode it. The return value, will be a tuple of the composed megaco message and the encode result.

test_request(ConnHandle, Version, EncodingMod, EncodingConfig, ActionRequests)

-spec test_request(ConnHandle, Version, EncodingMod, EncodingConfig, ActionRequests) ->
                      {MegaMsg, EncodeRes}
                      when
                          ConnHandle :: conn_handle(),
                          Version :: protocol_version(),
                          EncodingMod :: module(),
                          EncodingConfig :: list(),
                          ActionRequests :: action_reqs() | [action_reqs()],
                          MegaMsg :: megaco_message(),
                          EncodeRes :: {ok, Bin} | {error, Reason},
                          Bin :: binary(),
                          Reason :: term().

Tests if the Actions argument is correctly composed.

This function is only intended for testing purposes. It's supposed to have a same kind of interface as the call/3 or cast/3 functions (with the additions of the EncodingMod and EncodingConfig arguments). It composes a complete megaco message end attempts to encode it. The return value, will be a tuple of the composed megaco message and the encode result.

token_tag2string(Tag)

-spec token_tag2string(Tag) -> Result
                          when Tag :: atom(), Result :: string() | {error, Reason}, Reason :: term().

Equivalent to token_tag2string/3.

token_tag2string(Tag, EncodingMod)

-spec token_tag2string(Tag, EncodingMod) -> Result
                          when
                              Tag :: atom(),
                              EncodingMod :: pretty | compact | module(),
                              Result :: string() | {error, Reason},
                              Reason :: term().

Equivalent to token_tag2string/3.

token_tag2string(Tag, EncodingMod, Version)

-spec token_tag2string(Tag, EncodingMod, Version) -> Result
                          when
                              Tag :: atom(),
                              EncodingMod :: pretty | compact | module(),
                              Version :: protocol_version() | v1 | v2 | v3,
                              Result :: string() | {error, Reason},
                              Reason :: term().

Convert a token tag to a string

If no encoder module is given, the default is used (which is pretty).

If no or an unknown version is given, the best version is used (which is v3).

If no match is found for Tag, Result will be the empty string ([]).

update_conn_info(ConnHandle, Item, Value)

-spec update_conn_info(ConnHandle, Item, Value) -> ok | {error, Reason}
                          when
                              ConnHandle :: conn_handle(),
                              Item :: conn_info_item(),
                              Value :: term(),
                              Reason :: term().

Update information about an active connection

Requires that the connection is activated. See conn_info_item/0 about which items and values that are valid.

update_user_info(UserMid, Item, Value)

-spec update_user_info(UserMid, Item, Value) -> ok | {error, Reason}
                          when
                              UserMid :: mid(),
                              Item :: user_info_item(),
                              Value :: term(),
                              Reason :: term().

Update information about a user

Requires that the user is started.

user_info(UserMid)

-spec user_info(UserMid) -> [{Item, Value}]
                   when UserMid :: mid(), Item :: requests | replies | user_info_item(), Value :: term().

Equivalent to user_info/2.

user_info(UserMid, Input)

-spec user_info(UserMid, Input) -> Result
                   when
                       Input :: Requests | Replies | Item,
                       Requests :: requests,
                       Replies :: replies,
                       Item :: user_info_item(),
                       UserMid :: mid(),
                       Conn :: conn_handle(),
                       Result :: RequestsResult | RepliesResult | ItemResult,
                       RequestsResult :: [{Conn, [TransId]}],
                       ItemResult :: term(),
                       RepliesResult :: [{Conn, [{TransId, ReplyState, Handler}]}],
                       TransId :: transaction_id(),
                       ReplyState :: prepare | eval_request | waiting_for_ack | aborted,
                       Handler :: undefined | pid().

Lookup user information

Lookup user information about currently active requests. Expected input type Input :: Requests with expected output type Result :: RequestsResult.

Lookup user information about currently active replies. Expected input type Input :: Replies with expected output type Result :: RepliesResult.

versions1()

-spec versions1() -> {ok, VersionInfo} | {error, Reason} when VersionInfo :: list(), Reason :: term().

Equivalent to versions2/0.

versions2()

-spec versions2() -> {ok, VersionInfo} | {error, Reason} when VersionInfo :: list(), Reason :: term().

Utility functions used to retrieve some system and application info.

The difference between the two functions is in how they get the modules to check. versions1 uses the app-file and versions2 uses the function application:get_key.

megaco_codec_meas

This module implements a simple megaco codec measurement tool.

Results are written to file (excel compatible text files) and on stdout.

Note that this module is not included in the runtime part of the application.

Summary

Functions

start()

Equivalent to start/1.

start(MessagePackage)

This function runs the measurement on all the official codecs; pretty, compact, ber, per and erlang.

Functions

start()

Equivalent to start/1.

start(MessagePackage)

-spec start([MessagePackage]) -> ok when MessagePackage :: atom();
           (MessagePackage) -> ok when MessagePackage :: atom();
           (Factor) -> ok when Factor :: pos_integer().

This function runs the measurement on all the official codecs; pretty, compact, ber, per and erlang.

This function is intended to be called from the meas script, which uses the '-s' arguments to run the function:

erl -s megaco_codec_meas start time_test

megaco_codec_mstone1

This module implements a simple megaco codec-based performance tool.

This module implements the mstone1 tool, a simple megaco codec-based performance tool.

The results, the mstone value(s), are written to stdout.

Note that this module is not included in the runtime part of the application.

Summary

Functions

start()

Equivalent to start/2.

start([MessagePackage, RunTime, Factor])

This function is intended to be called from the mstone1 script, which uses the '-s' arguments to run the function (argument order; message package, run time (in minutes in the example) and factor)

start(MessagePackage, Factor)

This function starts the mstone1 performance test with all codec configs. Factor (defaults to 1) processes are started for every supported codec config.

start_flex()

Equivalent to start_flex/2.

start_flex([MessagePackage, RunTime, Factor])

This function is intended to be called from the mstone1 script, which uses the '-s' arguments to run the function (argument order; message package, run time (in minutes in the example) and factor)

start_flex(MessagePackage, Factor)

This function starts the mstone1 performance test with only the flex codec configs (i.e. pretty and compact with flex). The same number of processes are started as when running the standard test (using the start/0,1 function). Each process encodes and decodes their messages. The number of messages processed in total (for all processes) is the mstone value.

start_no_drv()

Equivalent to start_no_drv/2.

start_no_drv([MessagePackage, RunTime, Factor])

This function is intended to be called from the mstone1 script, which uses the '-s' arguments to run the function (argument order; message package, run time (in minutes in the example) and factor)

start_no_drv(MessagePackage, Factor)

This function starts the mstone1 performance test with codec configs not using any drivers (i.e. pretty and compact without flex, ber and per without driver and erlang without compressed). The same number of processes are started as when running the standard test (using the start/0,1 function). Each process encodes and decodes their messages. The number of messages processed in total (for all processes) is the mstone value.

start_only_drv()

Equivalent to start_only_drv/2.

start_only_drv/1

start_no_drv([MessagePackage, RunTime, Factor])

start_only_drv(MessagePackage, Factor)

This function starts the mstone1 performance test with only the driver using codec configs (i.e. pretty and compact with flex, and ber and per with driver and erlang with compressed). The same number of processes are started as when running the standard test (using the start/0,1 function). Each process encodes and decodes their messages. The number of messages processed in total (for all processes) is the mstone value.

Functions

start()

Equivalent to start/2.

start([MessagePackage, RunTime, Factor])

This function is intended to be called from the mstone1 script, which uses the '-s' arguments to run the function (argument order; message package, run time (in minutes in the example) and factor):

erl -s megaco_codec_mstone1 start time_test 1 1

start(MessagePackage, Factor)

-spec start(RunTime, Factor) -> ok when RunTime :: pos_integer(), Factor :: default | pos_integer();
           (MessagePackage, Factor) -> ok when MessagePackage :: atom(), Factor :: pos_integer().

This function starts the mstone1 performance test with all codec configs. Factor (defaults to 1) processes are started for every supported codec config.

Each process encodes and decodes their messages. The number of messages processed in total (for all processes) is the mstone value.

start_flex()

Equivalent to start_flex/2.

start_flex([MessagePackage, RunTime, Factor])

This function is intended to be called from the mstone1 script, which uses the '-s' arguments to run the function (argument order; message package, run time (in minutes in the example) and factor):

erl -s megaco_codec_mstone1 start_flex time_test 1 1

start_flex(MessagePackage, Factor)

-spec start_flex(MessagePackage, Factor) -> ok when MessagePackage :: atom(), Factor :: pos_integer().

This function starts the mstone1 performance test with only the flex codec configs (i.e. pretty and compact with flex). The same number of processes are started as when running the standard test (using the start/0,1 function). Each process encodes and decodes their messages. The number of messages processed in total (for all processes) is the mstone value.

start_no_drv()

Equivalent to start_no_drv/2.

start_no_drv([MessagePackage, RunTime, Factor])

This function is intended to be called from the mstone1 script, which uses the '-s' arguments to run the function (argument order; message package, run time (in minutes in the example) and factor):

erl -s megaco_codec_mstone1 start_no_drv time_test 1 1

start_no_drv(MessagePackage, Factor)

-spec start_no_drv(MessagePackage, Factor) -> ok when MessagePackage :: atom(), Factor :: pos_integer().

This function starts the mstone1 performance test with codec configs not using any drivers (i.e. pretty and compact without flex, ber and per without driver and erlang without compressed). The same number of processes are started as when running the standard test (using the start/0,1 function). Each process encodes and decodes their messages. The number of messages processed in total (for all processes) is the mstone value.

start_only_drv()

Equivalent to start_only_drv/2.

start_only_drv/1

start_no_drv([MessagePackage, RunTime, Factor])

This function is intended to be called from the mstone1 script, which uses the '-s' arguments to run the function (argument order; message package, run time (in minutes in the example) and factor):

erl -s megaco_codec_mstone1 start_no_drv time_test 1 1

start_only_drv(MessagePackage, Factor)

-spec start_only_drv(MessagePackage, Factor) -> ok
                        when MessagePackage :: atom(), Factor :: pos_integer().

This function starts the mstone1 performance test with only the driver using codec configs (i.e. pretty and compact with flex, and ber and per with driver and erlang with compressed). The same number of processes are started as when running the standard test (using the start/0,1 function). Each process encodes and decodes their messages. The number of messages processed in total (for all processes) is the mstone value.

megaco_codec_mstone2

This module implements a simple megaco codec-based performance tool.

This module implements the mstone2 tool, a simple megaco codec-based performance tool.

The results, the mstone value(s), are written to stdout.

Note that this module is not included in the runtime part of the application.

Summary

Functions

start()

Equivalent to start/1.

start/1

start(RunTime | MessagePackage)

Functions

start()

Equivalent to start/1.

start/1

-spec start(RunTime) -> ok when RunTime :: pos_integer();
           (MessagePackage) -> ok when MessagePackage :: atom().

start(RunTime | MessagePackage)

This function starts the mstone2 performance test with all codec configs. Processes are created dynamically. Each process make one run through their messages (decoding and encoding messages) and then exits. When one process exits, a new is created with the same codec config and set of messages.

The number of messages processed in total (for all processes) is the mstone value.

megaco_codec_transform

Megaco message transformation utility.

This module implements a simple megaco message transformation utility.

Note that this module is not included in the runtime part of the application.

Summary

Functions

export_messages()

Equivalent to export_messages/1.

export_messages(MessagePackage)

Export the messages in the MessagePackage (default is time_test).

Functions

export_messages()

Equivalent to export_messages/1.

export_messages(MessagePackage)

-spec export_messages(MessagePackage) -> ok | {error, Reason}
                         when MessagePackage :: atom(), Reason :: term().

Export the messages in the MessagePackage (default is time_test).

The output produced by this function is a directory structure with the following structure:

<message package>/pretty/<message-files>
                  compact/<message-files>
                  per/<message-files>
                  ber/<message-files>
                  erlang/<message-files>

megaco_digit_map

Digit Map utility module.

This is a Digit Map utility module (types).

Version note

This module has existed in the megaco app for long time, but as of 27.0, its also documented.

Summary

Types

cancel()

$z | $Z | cancel

event()

kind()

letter()

$0..$9 | $a..$k | $A..$K

one_second()

$s | $S

pause()

ten_seconds()

$l | $L

value()

Types

cancel()

(since OTP 27.0)

-type cancel() :: $z | $Z | cancel.

$z | $Z | cancel

event()

(since OTP 27.0)

-type event() :: letter() | pause() | cancel().

kind()

(since OTP 27.0)

-type kind() :: full | unambiguous.

letter()

(since OTP 27.0)

-type letter() :: $0..$9 | $a..$k | $A..$K.

$0..$9 | $a..$k | $A..$K

one_second()

(since OTP 27.0)

-type one_second() :: $s | $S.

$s | $S

pause()

(since OTP 27.0)

-type pause() :: one_second() | ten_seconds().

ten_seconds()

(since OTP 27.0)

-type ten_seconds() :: $l | $L.

$l | $L

value()

(since OTP 27.0)

-type value() ::
          #'DigitMapValue'{startTimer :: term(),
                           shortTimer :: term(),
                           longTimer :: term(),
                           digitMapBody :: term(),
                           durationTimer :: term()}.

megaco_edist_compress behaviour

Megaco erlang dist compress behaviour.

The following functions should be exported from a megaco_edist_compress callback module:

Summary

Callbacks

decode(T, Version)

Decompress a megaco component.

encode(R, Version)

Compress a megaco component. The erlang dist encoder makes no assumption on the how or even if the component is compressed.

Callbacks

decode(T, Version)

-callback decode(T, Version) -> R
                    when
                        T :: term(),
                        Version :: megaco_encoder:protocol_version() | dynamic,
                        R ::
                            megaco_encoder:megaco_message() |
                            megaco_encoder:transaction() |
                            megaco_encoder:action_reply() |
                            megaco_encoder:action_request() |
                            megaco_encoder:command_request().

Decompress a megaco component.

encode(R, Version)

-callback encode(R, Version) -> T
                    when
                        R ::
                            megaco_encoder:megaco_message() |
                            megaco_encoder:transaction() |
                            megaco_encoder:action_reply() |
                            megaco_encoder:action_request() |
                            megaco_encoder:command_request(),
                        Version :: megaco_encoder:protocol_version(),
                        T :: term().

Compress a megaco component. The erlang dist encoder makes no assumption on the how or even if the component is compressed.

megaco_encoder behaviour

Megaco encoder behaviour.

The following functions should be exported from a megaco_encoder callback module:

DATA TYPES

Note

Note that the actual definition of (some of) these records depend on the megaco protocol version used. For instance, the 'TransactionReply' record has two more fields in version 3, so a simple erlang type definition cannot be made here.

protocol_version() = integer()
segment_no()       = integer()
megaco_message() = #'MegacoMessage{}'
transaction() = {transactionRequest,     transaction_request()}      |
                {transactionPending,     transaction_reply()}        |
                {transactionReply,       transaction_pending()}      |
                {transactionResponseAck, transaction_response_ack()} |
                {segmentReply,           segment_reply()}
transaction_request() = #'TransactionRequest'{}
transaction_pending() = #'TransactionPending'{}
transaction_reply() = #'TransactionReply'{}
transaction_response_ack() = [transaction_ack()]
transaction_ack() = #'TransactionAck'{}
segment_reply() = #'SegmentReply'{}
action_request() = #'ActionRequest'{}
action_reply() = #'ActionReply'{}
command_request() = #'CommandRequest'{}
error_desc()   = #'ErrorDescriptor'{}

Summary

Types

action_reply()

action_request()

alpha()

Alpha Numeric characters: A..Z | a..z

command_request()

deviceName()

digit()

Decimal digits: 0..9

domainName()

error_desc()

ip4Address()

ip6Address()

megaco_message()

mtpAddress()

There is no way to properly express this type in the Erlang type system, so this is the best we can do.

octet()

octet_string()

pathName()

There is no way to properly express this type in the Erlang type system, so this is the best we can do. The minimum length is 1 and the maximum length is 64.

protocol_version()

segment_no()

segment_reply()

transaction()

transaction_ack()

transaction_pending()

transaction_reply()

The problem with TransactionReply is that its definition depend on which version of the protocol we are using. As of version 3, it has two more fields.

transaction_request()

transaction_response_ack()

Callbacks

decode_message(EncodingConfig, Version, Bin)

Decode a megaco message.

decode_mini_message(EncodingConfig, Version, Bin)

Perform a minimal decode of a megaco message.

encode_action_reply(EncodingConfig, Version, AR)

Encode a megaco action reply. If this, for whatever reason, is not supported, the function should return the error reason not_implemented.

encode_action_requests(EncodingConfig, Version, ARs)

Encode megaco action requests. This function is called when the user calls the function encode_actions/3. If that function is never used or if the codec cannot support this (the encoding of individual actions), then return with error reason not_implemented.

encode_message(EncodingConfig, Version, Message)

Encode a megaco message.

encode_transaction(EncodingConfig, Version, Transaction)

Encode a megaco transaction. If this, for whatever reason, is not supported, the function should return the error reason not_implemented.

Types

action_reply()

-type action_reply() :: {'ActionReply', _, _, _, _}.

action_request()

-type action_request() :: {'ActionRequest', _, _, _, _}.

alpha()

-type alpha() :: 65..90 | 97..122.

Alpha Numeric characters: A..Z | a..z

command_request()

-type command_request() :: {'CommandRequest', _, _, _}.

deviceName()

-type deviceName() :: pathName().

digit()

-type digit() :: 48..57.

Decimal digits: 0..9

domainName()

-type domainName() :: #'DomainName'{name :: term(), portNumber :: term()}.

error_desc()

-type error_desc() :: #'ErrorDescriptor'{errorCode :: term(), errorText :: term()}.

ip4Address()

-type ip4Address() :: #'IP4Address'{address :: term(), portNumber :: term()}.

ip6Address()

-type ip6Address() :: #'IP6Address'{address :: term(), portNumber :: term()}.

megaco_message()

-type megaco_message() :: #'MegacoMessage'{authHeader :: term(), mess :: term()}.

mtpAddress()

-type mtpAddress() :: octet_string().

There is no way to properly express this type in the Erlang type system, so this is the best we can do.

A proper definition would be: -type mtpAddress() :: octet_string(2..4).

octet()

-type octet() :: 0..255.

octet_string()

-type octet_string() :: [octet()].

pathName()

-type pathName() :: [$* | alpha() | digit() | $_ | $/ | $$ | $@ | $- | $.].

There is no way to properly express this type in the Erlang type system, so this is the best we can do. The minimum length is 1 and the maximum length is 64.

Here is the ABNF (copied from the megaco standard) to fill in the blanks:

# Total length of pathNAME must not exceed 64 chars.

pathNAME = ["*"] NAME *("/" / "*"/ ALPHA / DIGIT /"_" / "$" ) ["@" pathDomainName ]

# ABNF allows two or more consecutive "." although it is meaningless in a path domain name.

pathDomainName = (ALPHA / DIGIT / "*" ) *63(ALPHA / DIGIT / "-" / "*" / ".")

NAME = ALPHA *63(ALPHA / DIGIT / "_" )

protocol_version()

-type protocol_version() :: pos_integer().

segment_no()

-type segment_no() :: 0..65535.

segment_reply()

-type segment_reply() ::
          #'SegmentReply'{transactionId :: term(),
                          segmentNumber :: term(),
                          segmentationComplete :: term()}.

transaction()

-type transaction() ::
          {transactionRequest, transaction_request()} |
          {transactionPending, transaction_reply()} |
          {transactionReply, transaction_pending()} |
          {transactionResponseAck, transaction_response_ack()} |
          {segmentReply, segment_reply()}.

transaction_ack()

-type transaction_ack() :: #'TransactionAck'{firstAck :: term(), lastAck :: term()}.

transaction_pending()

-type transaction_pending() :: #'TransactionPending'{transactionId :: term()}.

transaction_reply()

-type transaction_reply() :: {'TransactionReply', _, _} | {'TransactionReply', _, _, _, _}.

The problem with TransactionReply is that its definition depend on which version of the protocol we are using. As of version 3, it has two more fields.

transaction_request()

-type transaction_request() :: #'TransactionRequest'{transactionId :: term(), actions :: term()}.

transaction_response_ack()

-type transaction_response_ack() :: [transaction_ack()].

Callbacks

decode_message(EncodingConfig, Version, Bin)

-callback decode_message(EncodingConfig, Version, Bin) -> {ok, Message} | Error
                            when
                                EncodingConfig :: list(),
                                Version :: protocol_version() | dynamic,
                                Bin :: binary(),
                                Message :: megaco_message(),
                                Error :: term().

Decode a megaco message.

Note that if the Version argument is dynamic, the decoder should try to figure out the actual version from the message itself and then use the proper decoder, e.g. version 1.
If on the other hand the Version argument is an integer, it means that this is the expected version of the message and the decoder for that version should be used.

decode_mini_message(EncodingConfig, Version, Bin)

-callback decode_mini_message(EncodingConfig, Version, Bin) -> {ok, Message} | Error
                                 when
                                     EncodingConfig :: list(),
                                     Version :: protocol_version() | dynamic,
                                     Bin :: binary(),
                                     Message :: megaco_message(),
                                     Error :: term().

Perform a minimal decode of a megaco message.

The purpose of this function is to do a minimal decode of Megaco message. A successfull result is a 'MegacoMessage' in which only version and mid has been initiated. This function is used by the megaco_messenger module when the decode_message/3 function fails to figure out the mid (the actual sender) of the message.

Note again that a successfull decode only returns a partially initiated message.

encode_action_reply(EncodingConfig, Version, AR)

(optional)

-callback encode_action_reply(EncodingConfig, Version, AR) -> {ok, Bin} | {error, Reason}
                                 when
                                     EncodingConfig :: list(),
                                     Version :: protocol_version(),
                                     AR :: action_reply(),
                                     Bin :: binary(),
                                     Reason :: not_implemented | term().

Encode a megaco action reply. If this, for whatever reason, is not supported, the function should return the error reason not_implemented.

This function is used when segmentation has been configured. So, for this to work, this function must be fully supported!

encode_action_requests(EncodingConfig, Version, ARs)

-callback encode_action_requests(EncodingConfig, Version, ARs) -> {ok, Bin} | {error, Reason}
                                    when
                                        EncodingConfig :: list(),
                                        Version :: protocol_version(),
                                        ARs :: [action_request()],
                                        Bin :: binary(),
                                        Reason :: not_implemented | term().

Encode megaco action requests. This function is called when the user calls the function encode_actions/3. If that function is never used or if the codec cannot support this (the encoding of individual actions), then return with error reason not_implemented.

encode_message(EncodingConfig, Version, Message)

-callback encode_message(EncodingConfig, Version, Message) -> {ok, Bin} | Error
                            when
                                EncodingConfig :: list(),
                                Version :: protocol_version(),
                                Message :: megaco_message(),
                                Bin :: binary(),
                                Error :: term().

Encode a megaco message.

encode_transaction(EncodingConfig, Version, Transaction)

-callback encode_transaction(EncodingConfig, Version, Transaction) -> {ok, Bin} | {error, Reason}
                                when
                                    EncodingConfig :: list(),
                                    Version :: protocol_version(),
                                    Transaction :: transaction(),
                                    Bin :: binary(),
                                    Reason :: not_implemented | term().

Encode a megaco transaction. If this, for whatever reason, is not supported, the function should return the error reason not_implemented.

This functionality is used both when the transaction sender is used and for segmentation. So, for either of those to work, this function must be fully supported!

megaco_flex_scanner

Interface module to the flex scanner linked in driver.

This module contains the public interface to the flex scanner linked in driver. The flex scanner performs the scanning phase of text message decoding.

The flex scanner is written using a tool called flex. In order to be able to compile the flex scanner driver, this tool has to be available.

By default the flex scanner reports line-number of an error. But it can be built without line-number reporting. Instead token number is used. This will speed up the scanning some 5-10%. Use --disable-megaco-flex-scanner-lineno when configuring the application.

The scanner will, by default, be built as a reentrant scanner if the flex utility supports this (it depends on the version of flex). It is possible to explicitly disable this even when flex support this. Use --disable-megaco-reentrant-flex-scanner when configuring the application.

Summary

Types

megaco_ports()

Return value of a successful (flex) scanner start.

Functions

is_reentrant_enabled()

Is the flex scanner reentrant or not.

is_scanner_port(Port, PortOrPorts)

Checks if a port is a flex scanner port or not (useful when if a port exits).

scan(Binary, PortOrPorts)

Scans a megaco message and generates a token list to be passed on the parser.

start()

This function is used to start the flex scanner. It locates the library and loads the linked in driver.

stop(PortOrPorts)

This function is used to stop the flex scanner. It also unloads the driver.

Types

megaco_ports()

-type megaco_ports() :: port() | tuple().

Return value of a successful (flex) scanner start.

Functions

is_reentrant_enabled()

-spec is_reentrant_enabled() -> boolean().

Is the flex scanner reentrant or not.

is_scanner_port(Port, PortOrPorts)

-spec is_scanner_port(Port, PortOrPorts) -> boolean() when Port :: port(), PortOrPorts :: megaco_ports().

Checks if a port is a flex scanner port or not (useful when if a port exits).

scan(Binary, PortOrPorts)

-spec scan(Binary, PortOrPorts) -> {ok, Tokens, Version, LatestLine} | {error, Reason, LatestLine}
              when
                  Binary :: binary(),
                  PortOrPorts :: megaco_ports(),
                  Tokens :: list(),
                  Version :: megaco_encoder:protocol_version(),
                  LatestLine :: non_neg_integer(),
                  Reason :: term().

Scans a megaco message and generates a token list to be passed on the parser.

start()

-spec start() -> {ok, PortOrPorts} | {error, Reason}
               when PortOrPorts :: megaco_ports(), Reason :: term().

This function is used to start the flex scanner. It locates the library and loads the linked in driver.

On a single core system or if it's a non-reentrant scanner, a single port is created. On a multi-core system with a reentrant scanner, several ports will be created (one for each scheduler).

Note that the process that calls this function must be permanent. If it dies, the port(s) will exit and the driver unload.

stop(PortOrPorts)

-spec stop(PortOrPorts) -> stopped when PortOrPorts :: megaco_ports().

This function is used to stop the flex scanner. It also unloads the driver.

megaco_sdp

SDP utility module.

This module contains various things related to SDP.

Version note

This module has existed in the megaco app for long time, but as of 27.0 its also documented.

Summary

Types

property_group()

property_groups()

property_parm()

sdp()

sdp_a()

Session attribute.

sdp_a_fmtp()

sdp_a_ptime()

sdp_a_quality()

sdp_a_rtpmap()

sdp_b()

Bandwidth information.

sdp_c()

Connection information.

sdp_e()

Email address.

sdp_i()

Session information.

sdp_k()

Encryption key.

sdp_m()

Media name and transport address.

sdp_o()

Owner/creator and session identifier.

sdp_p()

Phone number.

sdp_property_group()

sdp_property_groups()

sdp_property_parm()

sdp_r()

Repeat times.

sdp_s()

Session name.

sdp_t()

sdp_u()

URI of description.

sdp_v()

Protocol version.

sdp_z()

Time zone adjustment.

Types

property_group()

(since OTP 27.0)

-type property_group() :: [property_parm()].

property_groups()

(since OTP 27.0)

-type property_groups() :: [property_group()].

property_parm()

(since OTP 27.0)

-type property_parm() :: #'PropertyParm'{name :: term(), value :: term(), extraInfo :: term()}.

sdp()

(since OTP 27.0)

-type sdp() ::
          sdp_o() |
          sdp_s() |
          sdp_i() |
          sdp_u() |
          sdp_e() |
          sdp_p() |
          sdp_c() |
          sdp_b() |
          sdp_k() |
          sdp_a() |
          sdp_a_rtpmap() |
          sdp_a_ptime() |
          sdp_z() |
          sdp_t() |
          sdp_r() |
          sdp_m().

sdp_a()

(since OTP 27.0)

-type sdp_a() :: #megaco_sdp_a{attribute :: term(), value :: term()}.

Session attribute.

sdp_a_fmtp()

(since OTP 27.0)

-type sdp_a_fmtp() :: #megaco_sdp_a_fmtp{format :: term(), param :: term()}.

sdp_a_ptime()

(since OTP 27.0)

-type sdp_a_ptime() :: #megaco_sdp_a_ptime{packet_time :: term()}.

sdp_a_quality()

(since OTP 27.0)

-type sdp_a_quality() :: #megaco_sdp_a_quality{quality :: term()}.

sdp_a_rtpmap()

(since OTP 27.0)

-type sdp_a_rtpmap() ::
          #megaco_sdp_a_rtpmap{payload_type :: term(),
                               encoding_name :: term(),
                               clock_rate :: term(),
                               encoding_parms :: term()}.

sdp_b()

(since OTP 27.0)

-type sdp_b() :: #megaco_sdp_b{bwtype :: term(), bandwidth :: term()}.

Bandwidth information.

sdp_c()

(since OTP 27.0)

-type sdp_c() ::
          #megaco_sdp_c{network_type :: term(), address_type :: term(), connection_addr :: term()}.

Connection information.

sdp_e()

(since OTP 27.0)

-type sdp_e() :: #megaco_sdp_e{email :: term()}.

Email address.

sdp_i()

(since OTP 27.0)

-type sdp_i() :: #megaco_sdp_i{session_descriptor :: term()}.

Session information.

sdp_k()

(since OTP 27.0)

-type sdp_k() :: #megaco_sdp_k{method :: term(), encryption_key :: term()}.

Encryption key.

sdp_m()

(since OTP 27.0)

-type sdp_m() ::
          #megaco_sdp_m{media :: term(),
                        port :: term(),
                        num_ports :: term(),
                        transport :: term(),
                        fmt_list :: term()}.

Media name and transport address.

sdp_o()

(since OTP 27.0)

-type sdp_o() ::
          #megaco_sdp_o{user_name :: term(),
                        session_id :: term(),
                        version :: term(),
                        network_type :: term(),
                        address_type :: term(),
                        address :: term()}.

Owner/creator and session identifier.

sdp_p()

(since OTP 27.0)

-type sdp_p() :: #megaco_sdp_p{phone_number :: term()}.

Phone number.

sdp_property_group()

(since OTP 27.0)

-type sdp_property_group() :: [sdp_property_parm()].

sdp_property_groups()

(since OTP 27.0)

-type sdp_property_groups() :: [sdp_property_group()].

sdp_property_parm()

(since OTP 27.0)

-type sdp_property_parm() :: sdp() | property_parm().

sdp_r()

(since OTP 27.0)

-type sdp_r() ::
          #megaco_sdp_r{repeat_interval :: term(), active_duration :: term(), list_of_offsets :: term()}.

Repeat times.

sdp_s()

(since OTP 27.0)

-type sdp_s() :: #megaco_sdp_s{name :: term()}.

Session name.

sdp_t()

(since OTP 27.0)

-type sdp_t() :: #megaco_sdp_t{start :: term(), stop :: term()}.

sdp_u()

(since OTP 27.0)

-type sdp_u() :: #megaco_sdp_u{uri :: term()}.

URI of description.

sdp_v()

(since OTP 27.0)

-type sdp_v() :: #megaco_sdp_v{version :: term()}.

Protocol version.

sdp_z()

(since OTP 27.0)

-type sdp_z() :: #megaco_sdp_z{list_of_adjustments :: term()}.

Time zone adjustment.

megaco_tcp

Interface module to TPKT transport protocol for Megaco/H.248.

This module contains the public interface to the TPKT (TCP/IP) version transport protocol for Megaco/H.248.

Summary

Types

counter()

Defines the different counters handled by this transport.

handle()

An opaque data type representing a TPKT connection.

Functions

block(Handle)

Stop receiving incoming messages on the socket.

close(Handle)

This function is used for closing an active TPKT connection.

connect(TransportRef, Opts)

This function is used to open a TPKT connection.

get_stats()

Get all counter values for all known connections.

get_stats(Handle)

Get all counter values for a given (connection) handle.

get_stats(Handle, Counter)

Get the value of a specific counter.

listen(TransportRef, Options)

This function is used for starting new TPKT listening socket for TCP/IP. The option list contains the socket definitions.

reset_stats()

Reset all counters for all connections.

reset_stats(Handle)

Reset all counters for the given connection.

send_message(Handle, Msg)

Sends a message on a TPKT connection.

socket(Handle)

This function is used to convert a socket handle() to a inet socket().

start_transport()

This function is used for starting the TCP/IP transport service. Use exit(TransportRef, Reason) to stop the transport service.

unblock(Handle)

Starting to receive incoming messages from the socket again.

upgrade_receive_handle(ControlPid, NewRecvHandle)

Upgrade the receive handle of the control process (e.g. after having changed protocol version).

Types

counter()

-type counter() ::
          medGwyGatewayNumInMessages | medGwyGatewayNumInOctets | medGwyGatewayNumOutMessages |
          medGwyGatewayNumOutOctets | medGwyGatewayNumErrors.

Defines the different counters handled by this transport.

handle()

-opaque handle()

An opaque data type representing a TPKT connection.

Functions

block(Handle)

-spec block(Handle) -> ok when Handle :: handle().

Stop receiving incoming messages on the socket.

close(Handle)

-spec close(Handle) -> ok when Handle :: handle().

This function is used for closing an active TPKT connection.

connect(TransportRef, Opts)

-spec connect(TransportRef, Opts) -> {ok, Handle, ControlPid} | {error, Reason}
                 when
                     TransportRef :: pid() | RegName,
                     RegName :: atom(),
                     Opts :: [Option],
                     Option ::
                         {inet_backend, default | inet | socket} |
                         {host, Host} |
                         {port, PortNum} |
                         {options, list()} |
                         {receive_handle, term()} |
                         {module, atom()},
                     Host :: inet:socket_address() | inet:hostname(),
                     PortNum :: inet:port_number(),
                     Handle :: handle(),
                     ControlPid :: pid(),
                     Reason :: term().

This function is used to open a TPKT connection.

module - This option makes it possible for the user to provide their own callback module. The receive_message/4 or process_received_message/4 functions of this module is called when a new message is received. Which one is called depends on the size of the message;

small - receive_message

large - process_received_message

Default value is megaco.

inet_backend - Choose the inet-backend.

This option make it possible to use a different inet-backend ('default', 'inet' or 'socket').

Default is default (system default).

get_stats()

-spec get_stats() -> {ok, TotalStats} | {error, Reason}
                   when
                       TotalStats :: [{Handle, [{Counter, integer()}]}],
                       Handle :: handle(),
                       Counter :: counter(),
                       Reason :: term().

Get all counter values for all known connections.

get_stats(Handle)

-spec get_stats(Handle) -> {ok, Stats} | {error, Reason}
                   when
                       Handle :: handle(),
                       Stats :: [{Counter, integer()}],
                       Counter :: counter(),
                       Reason :: term().

Get all counter values for a given (connection) handle.

get_stats(Handle, Counter)

-spec get_stats(Handle, Counter) -> {ok, integer()} | {error, Reason}
                   when Handle :: handle(), Counter :: counter(), Reason :: term().

Get the value of a specific counter.

listen(TransportRef, Options)

-spec listen(TransportRef, Options) -> ok
                when
                    TransportRef :: pid() | RegName,
                    RegName :: atom(),
                    Options :: [Option],
                    Option ::
                        {inet_backend, default | inet | socket} |
                        {port, inet:port_number()} |
                        {options, list()} |
                        {receive_handle, term()}.

This function is used for starting new TPKT listening socket for TCP/IP. The option list contains the socket definitions.

inet_backend - Choose the inet-backend.

This option make it possible to use a different inet-backend ('default', 'inet' or 'socket').

Default is default (system default).

reset_stats()

-spec reset_stats() -> megaco:void().

Reset all counters for all connections.

reset_stats(Handle)

-spec reset_stats(Handle) -> megaco:void() when Handle :: handle().

Reset all counters for the given connection.

send_message(Handle, Msg)

-spec send_message(Handle, Msg) -> ok when Handle :: handle(), Msg :: binary() | iolist().

Sends a message on a TPKT connection.

socket(Handle)

-spec socket(Handle) -> Socket when Handle :: handle(), Socket :: inet:socket().

This function is used to convert a socket handle() to a inet socket().

start_transport()

-spec start_transport() -> {ok, TransportRef} when TransportRef :: pid().

This function is used for starting the TCP/IP transport service. Use exit(TransportRef, Reason) to stop the transport service.

unblock(Handle)

-spec unblock(Handle) -> ok when Handle :: handle().

Starting to receive incoming messages from the socket again.

upgrade_receive_handle(ControlPid, NewRecvHandle)

-spec upgrade_receive_handle(ControlPid, NewRecvHandle) -> ok
                                when ControlPid :: pid(), NewRecvHandle :: term().

Upgrade the receive handle of the control process (e.g. after having changed protocol version).

megaco_transport behaviour

Megaco transport behaviour.

The following functions should be exported from a megaco_transport callback module:

send_message/2 [mandatory]

send_message/3 [optional]

resend_message/2 [optional]

Summary

Callbacks

resend_message(Handle, Msg)

Re-send a megaco message.

send_message(Handle, Msg)

Equivalent to send_message/3.

send_message(Handle, Msg, Resend)

Send a megaco message.

Callbacks

resend_message(Handle, Msg)

(optional)

-callback resend_message(Handle, Msg) -> ok | {cancel, Reason :: term()} | Error
                            when Handle :: term(), Msg :: iodata(), Error :: term().

Re-send a megaco message.

Note that this function will only be called if the user has set the resend_indication config option to trueand it is in fact a message resend. If not both of these condition's are meet, send_message will be called.

If the function returns {cancel, Reason}, this means the transport module decided not to send the message. This is not an error. No error messages will be issued and no error counters incremented. What actions this will result in depends on what kind of message was sent.

In the case of requests, megaco will cancel the message in much the same way as if megaco:cancel had been called (after a successfull send). The information will be propagated back to the user differently depending on how the request(s) where issued: For requests issued using megaco:call, the info will be delivered in the return value. For requests issued using megaco:cast the info will be delivered via a call to the callback function handle_trans_reply.

In the case of reply, megaco will cancel the reply and information of this will be returned to the user via a call to the callback function handle_trans_ack.

send_message(Handle, Msg)

-callback send_message(Handle, Msg) -> ok | {cancel, Reason :: term()} | Error
                          when Handle :: term(), Msg :: iodata(), Error :: term().

Equivalent to send_message/3.

send_message(Handle, Msg, Resend)

(optional)

-callback send_message(Handle, Msg, Resend) -> ok | {cancel, Reason :: term()} | Error
                          when Handle :: term(), Msg :: iodata(), Resend :: boolean(), Error :: term().

Send a megaco message.

If the function returns {cancel, Reason}, this means the transport module decided not to send the message. This is not an error. No error messages will be issued and no error counters incremented. What actions this will result in depends on what kind of message was sent.

In the case of requests, megaco will cancel the message in much the same way as if megaco:cancel had been called (after a successfull send). The information will be propagated back to the user differently depending on how the request(s) where issued: For requests issued using megaco:call/3, the info will be delivered in the return value. For requests issued using megaco:cast the info will be delivered via a call to the callback function handle_trans_reply.

In the case of reply, megaco will cancel the reply and information of this will be returned to the user via a call to the callback function handle_trans_ack.

The function send_message/3 will only be called if the resend_indication config option has been set to the value flag. The third argument, Resend then indicates if the message send is a resend or not.

megaco_udp

Interface module to UDP transport protocol for Megaco/H.248.

This module contains the public interface to the UDP/IP version transport protocol for Megaco/H.248.

Summary

Types

counter()

Defines the different counters handled by this transport.

handle()

An opaque data type representing an UDP socket.

send_handle()

An opaque data type representing an UDP socket, used when sending.

Functions

block(Handle)

Stop receiving incoming messages on the socket.

close(Handle)

This function is used for closing an active UDP socket.

create_send_handle(Handle, Host, Port)

Creates a send handle from a transport handle. The send handle is intended to be used by megaco_udp:send_message/2.

get_stats()

Get all counter values for all known connections.

get_stats(SH)

Get all counter values for a given handle.

get_stats(SH, Counter)

Get the value of a specific counter.

open(TransportRef, Opts)

This function is used to open an UDP/IP socket.

reset_stats()

Reset all counters for all UDP handles.

reset_stats(SH)

Reset all counters for the given UDP handle.

send_message(SH, Msg)

Sends a message on a socket. The send handle is obtained by megacoudp:create_send_handle/3. Increments the NumOutMessages and NumOutOctets counters if message successfully sent. In case of a failure to send, the NumErrors counter is _not incremented. This is done elsewhere in the megaco app.

socket(Handle)

This function is used to convert a socket handle() to a inet socket().

start_transport()

This function is used for starting the UDP/IP transport service. Use exit(TransportRef, Reason) to stop the transport service.

unblock(Handle)

Starting to receive incoming messages from the socket again.

upgrade_receive_handle(ControlPid, NewRecvHandle)

Update the receive handle of the control process (e.g. after having changed protocol version).

Types

counter()

-type counter() ::
          medGwyGatewayNumInMessages | medGwyGatewayNumInOctets | medGwyGatewayNumOutMessages |
          medGwyGatewayNumOutOctets | medGwyGatewayNumErrors.

Defines the different counters handled by this transport.

handle()

-opaque handle()

An opaque data type representing an UDP socket.

send_handle()

-opaque send_handle()

An opaque data type representing an UDP socket, used when sending.

Functions

block(Handle)

-spec block(Handle) -> ok when Handle :: handle() | send_handle().

Stop receiving incoming messages on the socket.

close(Handle)

-spec close(Handle) -> ok when Handle :: handle() | send_handle().

This function is used for closing an active UDP socket.

create_send_handle(Handle, Host, Port)

-spec create_send_handle(Handle, Host, Port) -> send_handle()
                            when
                                Handle :: handle(),
                                Host :: inet:ip4_address() | inet:hostname(),
                                Port :: inet:port_number().

Creates a send handle from a transport handle. The send handle is intended to be used by megaco_udp:send_message/2.

get_stats()

-spec get_stats() -> {ok, TotalStats} | {error, Reason}
                   when
                       TotalStats :: [{SH, [{Counter, integer()}]}],
                       SH :: send_handle(),
                       Counter :: counter(),
                       Reason :: term().

Get all counter values for all known connections.

get_stats(SH)

-spec get_stats(SH) -> {ok, Stats} | {error, Reason}
                   when
                       SH :: send_handle(),
                       Stats :: [{Counter, integer()}],
                       Counter :: counter(),
                       Reason :: term().

Get all counter values for a given handle.

get_stats(SH, Counter)

-spec get_stats(SH, Counter) -> {ok, integer()} | {error, Reason}
                   when SH :: send_handle(), Counter :: counter(), Reason :: term().

Get the value of a specific counter.

open(TransportRef, Opts)

-spec open(TransportRef, Opts) -> {ok, Handle, ControlPid} | {error, Reason}
              when
                  TransportRef :: pid(),
                  Opts ::
                      {inet_backend, default | inet | socket} |
                      {port, PortNum} |
                      {options, list()} |
                      {receive_handle, term()} |
                      {module, atom()},
                  PortNum :: inet:port_number(),
                  Handle :: handle(),
                  ControlPid :: pid(),
                  Reason :: term().

This function is used to open an UDP/IP socket.

module - The option makes it possible for the user to provide their own callback module. The functions receive_message/4 or process_received_message/4 of this module is called when a new message is received. Which one depends on the size of the message:

small - receive_message

large - process_received_message

Default value is megaco.

inet_backend - Choose the inet-backend.

This option make it possible to use a different inet-backend ('default', 'inet' or 'socket').

Default is default (system default).

reset_stats()

-spec reset_stats() -> megaco:void().

Reset all counters for all UDP handles.

reset_stats(SH)

-spec reset_stats(SH) -> megaco:void() when SH :: send_handle().

Reset all counters for the given UDP handle.

send_message(SH, Msg)

-spec send_message(SH, Msg) -> ok when SH :: send_handle(), Msg :: binary() | iolist().

Sends a message on a socket. The send handle is obtained by megacoudp:create_send_handle/3. Increments the NumOutMessages and NumOutOctets counters if message successfully sent. In case of a failure to send, the NumErrors counter is _not incremented. This is done elsewhere in the megaco app.

socket(Handle)

-spec socket(Handle) -> Socket when Handle :: handle() | send_handle(), Socket :: inet:socket().

This function is used to convert a socket handle() to a inet socket().

start_transport()

-spec start_transport() -> {ok, TransportRef} when TransportRef :: pid().

This function is used for starting the UDP/IP transport service. Use exit(TransportRef, Reason) to stop the transport service.

unblock(Handle)

-spec unblock(Handle) -> ok when Handle :: handle() | send_handle().

Starting to receive incoming messages from the socket again.

upgrade_receive_handle(ControlPid, NewRecvHandle)

-spec upgrade_receive_handle(ControlPid, NewRecvHandle) -> ok
                                when ControlPid :: pid(), NewRecvHandle :: term().

Update the receive handle of the control process (e.g. after having changed protocol version).

megaco_user behaviour

Callback module for users of the Megaco application

This module defines the callback behaviour of Megaco users. A megaco_user compliant callback module must export the following functions:

handle_connect/2,3

handle_disconnect/3

handle_syntax_error/3,4

handle_message_error/3,4

handle_trans_request/3,4

handle_trans_long_request/3,4

handle_trans_reply/4,5

handle_trans_ack/4,5

handle_unexpected_trans/3,4

handle_trans_request_abort/4,5

handle_segment_reply/5,6

The semantics of them and their exact signatures are explained below.

The user_args configuration parameter which may be used to extend the argument list of the callback functions. For example, the handle_connect function takes by default two arguments:

handle_connect(Handle, Version)

but if the user_args parameter is set to a longer list, such as [SomePid,SomeTableRef], the callback function is expected to have these (in this case two) extra arguments last in the argument list:

handle_connect(Handle, Version, SomePid, SomeTableRef)

Note

Must of the functions below has an optional Extra argument (e.g. handle_unexpected_trans/4). The functions which takes this argument will be called if and only if one of the functions receive_message/5 or process_received_message/5 was called with the Extra argument different than ignore_extra.

DATA TYPES

action_request() = #'ActionRequest'{}
action_reply() = #'ActionReply'{}
error_desc() = #'ErrorDescriptor'{}
segment_no() = integer()

conn_handle() = #megaco_conn_handle{}

The record initially returned by megaco:connect/4,5. It identifies a "virtual" connection and may be reused after a reconnect (disconnect + connect).

protocol_version() = integer()

Is the actual protocol version. In most cases the protocol version is retrieved from the processed message, but there are exceptions:

When handle_connect/2,3 is triggered by an explicit call to megaco:connect/4,5.

handle_disconnect/3

handle_syntax_error/3

In these cases, the ProtocolVersion default version is obtained from the static connection configuration:

megaco:conn_info(ConnHandle, protocol_version).

Summary

Types

conn_handle()

megaco_timer()

receive_handle()

Callbacks

handle_connect(ConnHandle, ProtocolVersion)

Equivalent to handle_connect/3.

handle_connect(ConnHandle, ProtocolVersion, Extra)

Invoked when a new connection is established

handle_disconnect(ConnHandle, ProtocolVersion, Reason)

Invoked when a connection is teared down

handle_message_error(ConnHandle, ProtocolVersion, ErrorDescr)

Equivalent to handle_message_error/4.

handle_message_error(ConnHandle, ProtocolVersion, ErrorDescr, Extra)

Invoked when a received message just contains an error instead of a list of transactions.

handle_segment_reply(ConnHandle, ProtocolVersion, TransNo, SegNo, SegCompl)

Equivalent to handle_segment_reply/6.

handle_segment_reply(ConnHandle, ProtocolVersion, TransNo, SegNo, SegCompl, Extra)

This function is called when a segment reply has been received if the segment_reply_ind config option has been set to true.

handle_syntax_error(ReceiveHandle, ProtocolVersion, DefaultED)

Equivalent to handle_syntax_error/4.

handle_syntax_error(ReceiveHandle, ProtocolVersion, DefaultED, Extra)

Invoked when a received message had syntax errors

handle_trans_ack(ConnHandle, ProtocolVersion, AckStatus, AckData)

Equivalent to handle_trans_ack/5.

handle_trans_ack(ConnHandle, ProtocolVersion, AckStatus, AckData, Extra)

Optionally invoked for a transaction acknowledgement

handle_trans_long_request(ConnHandle, ProtocolVersion, ReqData)

Equivalent to handle_trans_long_request/4.

handle_trans_long_request(ConnHandle, ProtocolVersion, ReqData, Extra)

Optionally invoked for a time consuming transaction request

handle_trans_reply(ConnHandle, ProtocolVersion, UserReply, ReplyData)

Equivalent to handle_trans_reply/5.

handle_trans_reply(ConnHandle, ProtocolVersion, UserReply, ReplyData, Extra)

Optionally invoked for a transaction reply

handle_trans_request(ConnHandle, ProtocolVersion, ActionRequests)

Equivalent to handle_trans_request/4.

handle_trans_request(ConnHandle, ProtocolVersion, ActionRequests, Extra)

Invoked for each transaction request

handle_trans_request_abort(ConnHandle, ProtocolVersion, TransNo, Pid)

Equivalent to handle_trans_request_abort/5.

handle_trans_request_abort(ConnHandle, ProtocolVersion, TransNo, Pid, Extra)

Invoked when a transaction request has been aborted

handle_unexpected_trans(ConnHandle, ProtocolVersion, Trans)

Equivalent to handle_unexpected_trans/4.

handle_unexpected_trans(ConnHandle, ProtocolVersion, Trans, Extra)

Invoked when a unexpected message is received

Types

conn_handle()

-type conn_handle() :: #megaco_conn_handle{local_mid :: term(), remote_mid :: term()}.

megaco_timer()

-type megaco_timer() ::
          infinity |
          non_neg_integer() |
          #megaco_incr_timer{wait_for :: term(),
                             factor :: term(),
                             incr :: term(),
                             max_retries :: term()}.

receive_handle()

-type receive_handle() ::
          #megaco_receive_handle{local_mid :: term(),
                                 encoding_mod :: term(),
                                 encoding_config :: term(),
                                 send_mod :: term(),
                                 protocol_version :: term()}.

Callbacks

handle_connect(ConnHandle, ProtocolVersion)

(optional)

-callback handle_connect(ConnHandle, ProtocolVersion) -> ok | error | {error, ErrorDescr}
                            when
                                ConnHandle :: conn_handle(),
                                ProtocolVersion :: megaco_encoder:protocol_version(),
                                ErrorDescr :: megaco_encoder:error_desc().

Equivalent to handle_connect/3.

handle_connect(ConnHandle, ProtocolVersion, Extra)

(optional)

-callback handle_connect(ConnHandle, ProtocolVersion, Extra) -> ok | error | {error, ErrorDescr}
                            when
                                ConnHandle :: conn_handle(),
                                ProtocolVersion :: megaco_encoder:protocol_version(),
                                Extra :: term(),
                                ErrorDescr :: megaco_encoder:error_desc().

Invoked when a new connection is established

Connections may either be established by an explicit call to megaco:connect/4 or implicitly at the first invocation of megaco:receive_message/3.

Normally a Media Gateway (MG) connects explicitly while a Media Gateway Controller (MGC) connects implicitly.

At the Media Gateway Controller (MGC) side it is possible to reject a connection request (and send a message error reply to the gateway) by returning {error, ErrorDescr} or simply error which generates an error descriptor with code 402 (unauthorized) and reason "Connection refused by user" (this is also the case for all unknown results, such as exit signals or throw).

See note above about the Extra argument in handle_message_error/4.

handle_connect/3 (with Extra) can also be called as a result of a call to the megaco:connect/5 function (if that function is called with the Extra argument different than ignore_extra.

handle_disconnect(ConnHandle, ProtocolVersion, Reason)

(optional)

-callback handle_disconnect(ConnHandle, ProtocolVersion, Reason) -> megaco:void()
                               when
                                   ConnHandle :: conn_handle(),
                                   ProtocolVersion :: megaco_encoder:protocol_version(),
                                   Reason :: term().

Invoked when a connection is teared down

The disconnect may either be made explicitly by a call to megaco:disconnect/2 or implicitly when the control process of the connection dies.

handle_message_error(ConnHandle, ProtocolVersion, ErrorDescr)

(optional)

-callback handle_message_error(ConnHandle, ProtocolVersion, ErrorDescr) -> megaco:void()
                                  when
                                      ConnHandle :: conn_handle(),
                                      ProtocolVersion :: megaco_encoder:protocol_version(),
                                      ErrorDescr :: megaco_encoder:error_desc().

Equivalent to handle_message_error/4.

handle_message_error(ConnHandle, ProtocolVersion, ErrorDescr, Extra)

(optional)

-callback handle_message_error(ConnHandle, ProtocolVersion, ErrorDescr, Extra) -> megaco:void()
                                  when
                                      ConnHandle :: conn_handle(),
                                      ProtocolVersion :: megaco_encoder:protocol_version(),
                                      ErrorDescr :: megaco_encoder:error_desc(),
                                      Extra :: term().

Invoked when a received message just contains an error instead of a list of transactions.

Incoming messages is delivered by megaco:receive_message/4 and successfully decoded. Normally a message contains a list of transactions, but it may instead contain an ErrorDescriptor on top level of the message.

Message errors are detected remotely on the other side of the protocol. And you probably don't want to reply to it, but it may indicate that you have outstanding transactions that not will get any response (request -> reply; reply -> ack).

See note above about the Extra argument in handle_message_error/4.

handle_segment_reply(ConnHandle, ProtocolVersion, TransNo, SegNo, SegCompl)

(optional)

-callback handle_segment_reply(ConnHandle, ProtocolVersion, TransNo, SegNo, SegCompl) -> ok
                                  when
                                      ConnHandle :: conn_handle(),
                                      ProtocolVersion :: megaco_encoder:protocol_version(),
                                      TransNo :: integer(),
                                      SegNo :: integer(),
                                      SegCompl :: asn1_NOVALUE | 'NULL'.

Equivalent to handle_segment_reply/6.

handle_segment_reply(ConnHandle, ProtocolVersion, TransNo, SegNo, SegCompl, Extra)

(optional)

-callback handle_segment_reply(ConnHandle, ProtocolVersion, TransNo, SegNo, SegCompl, Extra) -> ok
                                  when
                                      ConnHandle :: conn_handle(),
                                      ProtocolVersion :: megaco_encoder:protocol_version(),
                                      TransNo :: integer(),
                                      SegNo :: megaco_encoder:segment_no(),
                                      SegCompl :: asn1_NOVALUE | 'NULL',
                                      Extra :: term().

This function is called when a segment reply has been received if the segment_reply_ind config option has been set to true.

This is in effect a progress report.

See note above about the Extra argument in handle_segment_reply/6.

handle_syntax_error(ReceiveHandle, ProtocolVersion, DefaultED)

(optional)

-callback handle_syntax_error(ReceiveHandle, ProtocolVersion, DefaultED) ->
                                 reply | {reply, ED} | no_reply | {no_reply, ED}
                                 when
                                     ReceiveHandle :: receive_handle(),
                                     ProtocolVersion :: megaco_encoder:protocol_version(),
                                     DefaultED :: megaco_encoder:error_desc(),
                                     ED :: megaco_encoder:error_desc().

Equivalent to handle_syntax_error/4.

handle_syntax_error(ReceiveHandle, ProtocolVersion, DefaultED, Extra)

(optional)

-callback handle_syntax_error(ReceiveHandle, ProtocolVersion, DefaultED, Extra) ->
                                 reply | {reply, ED} | no_reply | {no_reply, ED}
                                 when
                                     ReceiveHandle :: receive_handle(),
                                     ProtocolVersion :: megaco_encoder:protocol_version(),
                                     DefaultED :: megaco_encoder:error_desc(),
                                     ED :: megaco_encoder:error_desc(),
                                     Extra :: term().

Invoked when a received message had syntax errors

Incoming messages is delivered by megaco:receive_message/4 and normally decoded successfully. But if the decoding failed this function is called in order to decide if the originator should get a reply message (reply) or if the reply silently should be discarded (no_reply).

Syntax errors are detected locally on this side of the protocol and may have many causes, e.g. a malfunctioning transport layer, wrong encoder/decoder selected, bad configuration of the selected encoder/decoder etc.

The error descriptor defaults to DefaultED, but can be overridden with an alternate one by returning {reply,ED} or {no_reply,ED} instead of reply and no_reply respectively.

Any other return values (including exit signals or throw) and the DefaultED will be used.

See note above about the Extra argument in handle_syntax_error/4.

handle_trans_ack(ConnHandle, ProtocolVersion, AckStatus, AckData)

(optional)

-callback handle_trans_ack(ConnHandle, ProtocolVersion, AckStatus, AckData) -> ok
                              when
                                  ConnHandle :: conn_handle(),
                                  ProtocolVersion :: megaco_encoder:protocol_version(),
                                  AckStatus :: ok | {error, Reason},
                                  AckData :: term(),
                                  Reason :: UserCancelReason | SendReason | OtherReason,
                                  UserCancelReason :: {user_cancel, ReasonForUserCancel},
                                  ReasonForUserCancel :: term(),
                                  SendReason :: SendCancelledReason | SendFailedReason,
                                  SendCancelledReason :: {send_message_cancelled, ReasonForSendCancel},
                                  ReasonForSendCancel :: term(),
                                  SendFailedReason :: {send_message_failed, ReasonForSendFailure},
                                  ReasonForSendFailure :: term(),
                                  OtherReason :: term().

Equivalent to handle_trans_ack/5.

handle_trans_ack(ConnHandle, ProtocolVersion, AckStatus, AckData, Extra)

(optional)

-callback handle_trans_ack(ConnHandle, ProtocolVersion, AckStatus, AckData, Extra) -> ok
                              when
                                  ConnHandle :: conn_handle(),
                                  ProtocolVersion :: megaco_encoder:protocol_version(),
                                  AckStatus :: ok | {error, Reason},
                                  AckData :: term(),
                                  Extra :: term(),
                                  Reason :: UserCancelReason | SendReason | OtherReason,
                                  UserCancelReason :: {user_cancel, ReasonForUserCancel},
                                  ReasonForUserCancel :: term(),
                                  SendReason :: SendCancelledReason | SendFailedReason,
                                  SendCancelledReason :: {send_message_cancelled, ReasonForSendCancel},
                                  ReasonForSendCancel :: term(),
                                  SendFailedReason :: {send_message_failed, ReasonForSendFailure},
                                  ReasonForSendFailure :: term(),
                                  OtherReason :: term().

Optionally invoked for a transaction acknowledgement

If this function gets invoked or not, is controlled by the reply from the preceding call to handle_trans_request/3. The handle_trans_request/3 function may decide to return {handle_ack, ack_data()} or {handle_sloppy_ack, ack_data()} meaning that you need an immediate acknowledgement of the reply and that this function should be invoked to handle the acknowledgement.

The ack_data() argument to this function is the Erlang term returned by handle_trans_request/3.

If the AckStatus is ok, it is indicating that this is a true acknowledgement of the transaction reply.

If the AckStatus is {error, Reason}, it is an indication that the acknowledgement or even the reply (for which this is an acknowledgement) was not delivered, but there is no point in waiting any longer for it to arrive. This happens when:

reply_timer - The reply_timer eventually times out.

reply send failure - When megaco fails to send the reply (see handle_trans_reply), for whatever reason.

cancel - The user has explicitly cancelled the wait (megaco:cancel/2).

See note above about the Extra argument in handle_trans_ack/5.

handle_trans_long_request(ConnHandle, ProtocolVersion, ReqData)

(optional)

-callback handle_trans_long_request(ConnHandle, ProtocolVersion, ReqData) -> Reply
                                       when
                                           ConnHandle :: conn_handle(),
                                           ProtocolVersion :: megaco_encoder:protocol_version(),
                                           ReqData :: term(),
                                           Reply ::
                                               {AckAction, ActualReply} |
                                               {AckAction, ActualReply, SendOptions},
                                           AckAction ::
                                               discard_ack |
                                               {handle_ack, AckData} |
                                               {handle_sloppy_ack, AckData},
                                           ActualReply ::
                                               [megaco_encoder:action_reply()] | megaco_encoder:error_desc(),
                                           AckData :: term(),
                                           SendOptions :: [SendOption],
                                           SendOption ::
                                               {reply_timer, megaco_timer()} |
                                               {send_handle, term()} |
                                               {protocol_version, megaco_encoder:protocol_version()}.

Equivalent to handle_trans_long_request/4.

handle_trans_long_request(ConnHandle, ProtocolVersion, ReqData, Extra)

(optional)

-callback handle_trans_long_request(ConnHandle, ProtocolVersion, ReqData, Extra) -> Reply
                                       when
                                           ConnHandle :: conn_handle(),
                                           ProtocolVersion :: megaco_encoder:protocol_version(),
                                           ReqData :: term(),
                                           Extra :: term(),
                                           Reply ::
                                               {AckAction, ActualReply} |
                                               {AckAction, ActualReply, SendOptions},
                                           AckAction ::
                                               discard_ack |
                                               {handle_ack, AckData} |
                                               {handle_sloppy_ack, AckData},
                                           ActualReply ::
                                               [megaco_encoder:action_reply()] | megaco_encoder:error_desc(),
                                           AckData :: term(),
                                           SendOptions :: [SendOption],
                                           SendOption ::
                                               {reply_timer, megaco_timer()} |
                                               {send_handle, term()} |
                                               {protocol_version, megaco_encoder:protocol_version()}.

Optionally invoked for a time consuming transaction request

If this function gets invoked or not is controlled by the reply from the preceding call to handle_trans_request/3. The handle_trans_request/3 function may decide to process the action requests itself or to delegate the processing to this function.

The req_data() argument to this function is the Erlang term returned by handle_trans_request/3.

Any other return values (including exit signals or throw) will result in an error descriptor with code 500 (internal gateway error) and the module name (of the callback module) as reason.

See note above about the Extra argument in handle_trans_long_request/4.

handle_trans_reply(ConnHandle, ProtocolVersion, UserReply, ReplyData)

(optional)

-callback handle_trans_reply(ConnHandle, ProtocolVersion, UserReply, ReplyData) -> ok
                                when
                                    ConnHandle :: conn_handle(),
                                    ProtocolVersion :: megaco_encoder:protocol_version(),
                                    UserReply :: Success | Failure,
                                    ReplyData :: term(),
                                    Success :: {ok, Result},
                                    Result :: TransactionResult | SegmentResult,
                                    TransactionResult :: [megaco_encoder:action_reply()],
                                    SegmentResult ::
                                        {megaco_encoder:segment_no(),
                                         LastSegment,
                                         [megaco_encoder:action_reply()]},
                                    Failure :: {error, Reason} | {error, ReplyNo, Reason},
                                    Reason ::
                                        TransactionReason | SegmentReason | UserCancelReason | SendReason |
                                        OtherReason,
                                    TransactionReason :: megaco_encoder:error_desc(),
                                    SegmentReason ::
                                        {megaco_encoder:segment_no(),
                                         LastSegment,
                                         megaco_encoder:error_desc()},
                                    OtherReason ::
                                        timeout |
                                        {segment_timeout, MissingSegments} |
                                        exceeded_recv_pending_limit |
                                        term(),
                                    LastSegment :: boolean(),
                                    MissingSegments :: [megaco_encoder:segment_no()],
                                    UserCancelReason :: {user_cancel, ReasonForUserCancel},
                                    ReasonForUserCancel :: term(),
                                    SendReason :: SendCancelledReason | SendFailedReason,
                                    SendCancelledReason :: {send_message_cancelled, ReasonForSendCancel},
                                    ReasonForSendCancel :: term(),
                                    SendFailedReason :: {send_message_failed, ReasonForSendFailure},
                                    ReasonForSendFailure :: term(),
                                    ReplyNo :: pos_integer().

Equivalent to handle_trans_reply/5.

handle_trans_reply(ConnHandle, ProtocolVersion, UserReply, ReplyData, Extra)

(optional)

-callback handle_trans_reply(ConnHandle, ProtocolVersion, UserReply, ReplyData, Extra) -> ok
                                when
                                    ConnHandle :: conn_handle(),
                                    ProtocolVersion :: megaco_encoder:protocol_version(),
                                    UserReply :: Success | Failure,
                                    ReplyData :: term(),
                                    Extra :: term(),
                                    Success :: {ok, Result},
                                    Result :: TransactionResult | SegmentResult,
                                    TransactionResult :: [megaco_encoder:action_reply()],
                                    SegmentResult ::
                                        {megaco_encoder:segment_no(),
                                         LastSegment,
                                         [megaco_encoder:action_reply()]},
                                    Failure :: {error, Reason} | {error, ReplyNo, Reason},
                                    Reason ::
                                        TransactionReason | SegmentReason | UserCancelReason | SendReason |
                                        OtherReason,
                                    TransactionReason :: megaco_encoder:error_desc(),
                                    SegmentReason ::
                                        {megaco_encoder:segment_no(),
                                         LastSegment,
                                         megaco_encoder:error_desc()},
                                    OtherReason ::
                                        timeout |
                                        {segment_timeout, MissingSegments} |
                                        exceeded_recv_pending_limit |
                                        term(),
                                    LastSegment :: boolean(),
                                    MissingSegments :: [megaco_encoder:segment_no()],
                                    UserCancelReason :: {user_cancel, ReasonForUserCancel},
                                    ReasonForUserCancel :: term(),
                                    SendReason :: SendCancelledReason | SendFailedReason,
                                    SendCancelledReason :: {send_message_cancelled, ReasonForSendCancel},
                                    ReasonForSendCancel :: term(),
                                    SendFailedReason :: {send_message_failed, ReasonForSendFailure},
                                    ReasonForSendFailure :: term(),
                                    ReplyNo :: pos_integer().

Optionally invoked for a transaction reply

The sender of a transaction request has the option of deciding, whether the originating Erlang process should synchronously wait (megaco:call/3) for a reply or if the message should be sent asynchronously (megaco:cast/3) and the processing of the reply should be delegated this callback function.

Note that if the reply is segmented (split into several smaller messages; segments), then some extra info, segment number and an indication if all segments of a reply has been received or not, is also included in the UserReply.

The ReplyData defaults to megaco:lookup(ConnHandle, reply_data), but may be explicitly overridden by a megaco:cast/3 option in order to forward info about the calling context of the originating process.

At success(), the UserReply either contains:

A list of 'ActionReply' records possibly containing error indications.

A tuple of size three containing: the segment number, the last segment indicator and finally a list of 'ActionReply' records possibly containing error indications. This is of course only possible if the reply was segmented.

failure() indicates an local or external error and can be one of the following:

A transaction_reason(), indicates that the remote user has replied with an explicit transactionError.

A segment_reason(), indicates that the remote user has replied with an explicit transactionError for this segment. This is of course only possible if the reply was segmented.

A user_cancel_reason(), indicates that the request has been canceled by the user. reason_for_user_cancel() is the reason given in the call to the cancel function.

A send_reason(), indicates that the transport module send_message function did not send the message. The reason for this can be:

send_cancelled_reason() - the message sending was deliberately cancelled. reason_for_send_cancel() is the reason given in the cancel return from the send_message function.

send_failed_reason() - an error occurred while attempting to send the message.

An other_reason(), indicates some other error such as:

timeout - the reply failed to arrive before the request timer expired.

{segment_timeout, missing_segments()} - one or more segments was not delivered before the expire of the segment timer.

exceeded_recv_pending_limit - the pending limit was exceeded for this request.

See note above about the Extra argument in handle_trans_reply/5.

handle_trans_request(ConnHandle, ProtocolVersion, ActionRequests)

(optional)

-callback handle_trans_request(ConnHandle, ProtocolVersion, ActionRequests) ->
                                  Pending | Reply | ignore_trans_request
                                  when
                                      ConnHandle :: conn_handle(),
                                      ProtocolVersion :: megaco_encoder:protocol_version(),
                                      ActionRequests :: [megaco_encoder:action_request()],
                                      Pending :: {pending, ReqData},
                                      ReqData :: term(),
                                      Reply ::
                                          {AckAction, ActualReply} | {AckAction, ActualReply, SendOptions},
                                      AckAction ::
                                          discard_ack |
                                          {handle_ack, AckData} |
                                          {handle_pending_ack, AckData} |
                                          {handle_sloppy_ack, AckData},
                                      ActualReply ::
                                          [megaco_encoder:action_reply()] | megaco_encoder:error_desc(),
                                      AckData :: term(),
                                      SendOptions :: [SendOption],
                                      SendOption ::
                                          {reply_timer, megaco_timer()} |
                                          {send_handle, term()} |
                                          {protocol_version, integer()}.

Equivalent to handle_trans_request/4.

handle_trans_request(ConnHandle, ProtocolVersion, ActionRequests, Extra)

(optional)

-callback handle_trans_request(ConnHandle, ProtocolVersion, ActionRequests, Extra) ->
                                  Pending | Reply | ignore_trans_request
                                  when
                                      ConnHandle :: conn_handle(),
                                      ProtocolVersion :: megaco_encoder:protocol_version(),
                                      ActionRequests :: [megaco_encoder:action_request()],
                                      Extra :: term(),
                                      Pending :: {pending, ReqData},
                                      ReqData :: term(),
                                      Reply ::
                                          {AckAction, ActualReply} | {AckAction, ActualReply, SendOptions},
                                      AckAction ::
                                          discard_ack |
                                          {handle_ack, AckData} |
                                          {handle_pending_ack, AckData} |
                                          {handle_sloppy_ack, AckData},
                                      ActualReply ::
                                          [megaco_encoder:action_reply()] | megaco_encoder:error_desc(),
                                      AckData :: term(),
                                      SendOptions :: [SendOption],
                                      SendOption ::
                                          {reply_timer, megaco_timer()} |
                                          {send_handle, term()} |
                                          {protocol_version, integer()}.

Invoked for each transaction request

Incoming messages is delivered by megaco:receive_message/4 and successfully decoded. Normally a message contains a list of transactions and this function is invoked for each TransactionRequest in the message.

This function takes a list of 'ActionRequest' records and has three main options:

Return ignore_trans_request - Decide that these action requests shall be ignored completely.

Return pending() - Decide that the processing of these action requests will take a long time and that the originator should get an immediate 'TransactionPending' reply as interim response. The actual processing of these action requests instead should be delegated to the the handle_trans_long_request/3 callback function with the req_data() as one of its arguments.

Return reply() - Process the action requests and either return an error_descr() indicating some fatal error or a list of action replies (wildcarded or not).

If for some reason megaco is unable to deliver the reply, the reason for this will be passed to the user via a call to the callback function handle_trans_ack, unless ack_action() = discard_ack.

The ack_action() is either:

discard_ack - Meaning that you don't care if the reply is acknowledged or not.

{handle_ack, ack_data()} | {handle_ack, ack_data(), send_options()} - Meaning that you want an immediate acknowledgement when the other part receives this transaction reply. When the acknowledgement eventually is received, the handle_trans_ack/4 callback function will be invoked with the ack_data() as one of its arguments. ack_data() may be any Erlang term.

{handle_pending_ack, ack_data()} | {handle_pending_ack, ack_data(), send_options()} - This has the same effect as the above, if and only if megaco has sent at least one pending message for this request (during the processing of the request). If no pending message has been sent, then immediate acknowledgement will not be requested.

Note that this only works as specified if the sent_pending_limit config option has been set to an integer value.

{handle_sloppy_ack, ack_data()}| {handle_sloppy_ack, ack_data(), send_options()} - Meaning that you want an acknowledgement sometime. When the acknowledgement eventually is received, the handle_trans_ack/4 callback function will be invoked with the ack_data() as one of its arguments. ack_data() may be any Erlang term.

Any other return values (including exit signals or throw) will result in an error descriptor with code 500 (internal gateway error) and the module name (of the callback module) as reason.

See note above about the Extra argument in handle_trans_request/4.

handle_trans_request_abort(ConnHandle, ProtocolVersion, TransNo, Pid)

(optional)

-callback handle_trans_request_abort(ConnHandle, ProtocolVersion, TransNo, Pid) -> ok
                                        when
                                            ConnHandle :: conn_handle(),
                                            ProtocolVersion :: megaco_encoder:protocol_version(),
                                            TransNo :: integer(),
                                            Pid :: undefined | pid().

Equivalent to handle_trans_request_abort/5.

handle_trans_request_abort(ConnHandle, ProtocolVersion, TransNo, Pid, Extra)

(optional)

-callback handle_trans_request_abort(ConnHandle, ProtocolVersion, TransNo, Pid, Extra) -> ok
                                        when
                                            ConnHandle :: conn_handle(),
                                            ProtocolVersion :: megaco_encoder:protocol_version(),
                                            TransNo :: integer(),
                                            Pid :: undefined | pid(),
                                            Extra :: term().

Invoked when a transaction request has been aborted

This function is invoked if the originating pending limit has been exceeded. This usually means that a request has taken abnormally long time to complete.

See note above about the Extra argument in handle_trans_request_abort/5.

handle_unexpected_trans(ConnHandle, ProtocolVersion, Trans)

(optional)

-callback handle_unexpected_trans(ConnHandle, ProtocolVersion, Trans) -> ok
                                     when
                                         ConnHandle :: conn_handle(),
                                         ProtocolVersion :: megaco_encoder:protocol_version(),
                                         Trans ::
                                             megaco_encoder:transaction_pending() |
                                             megaco_encoder:transaction_reply() |
                                             megaco_encoder:transaction_response_ack().

Equivalent to handle_unexpected_trans/4.

handle_unexpected_trans(ConnHandle, ProtocolVersion, Trans, Extra)

(optional)

-callback handle_unexpected_trans(ConnHandle, ProtocolVersion, Trans, Extra) -> ok
                                     when
                                         ConnHandle :: conn_handle(),
                                         ProtocolVersion :: megaco_encoder:protocol_version(),
                                         Trans ::
                                             megaco_encoder:transaction_pending() |
                                             megaco_encoder:transaction_reply() |
                                             megaco_encoder:transaction_response_ack(),
                                         Extra :: term().

Invoked when a unexpected message is received

If a reply to a request is not received in time, the megaco stack removes all info about the request from its tables. If a reply should arrive after this has been done the app has no way of knowing where to send this message. The message is delivered to the "user" by calling this function on the local node (the node which has the link).

See note above about the Extra argument in handle_unexpected_trans/4.