The type is used when a functions return is to be ignored.
megaco
Data Types
mid() =
{ip4Address, megaco_encoder:ip4Address()} |
{ip6Address, megaco_encoder:ip6Address()} |
{domainName, megaco_encoder:domainName()} |
{deviceName, megaco_encoder:deviceName()} |
{mtpAddress, megaco_encoder:mtpAddress()}
{ip4Address, megaco_encoder:ip4Address()} |
{ip6Address, megaco_encoder:ip6Address()} |
{domainName, megaco_encoder:domainName()} |
{deviceName, megaco_encoder:deviceName()} |
{mtpAddress, megaco_encoder:mtpAddress()}
The Megaco Identifier.
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
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()
- local_mid
-
The local mid (of the connection, i.e. the own mid).
Value type: mid()
- remote_mid
-
The remote mid (of the connection).
Value type: mid()
- receive_handle
-
Construct a megaco_receive_handle record.
Value type: receive_handle()
- 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() | undefined_serial
- max_trans_id
-
Last transaction id.
Value type: transaction_id() | 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()
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()
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()
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()
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()
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 function.
Value type: megaco_timer()
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()
-
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.
Opaque send handle whose contents is internal for the send module. May be any term.
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.
The trace event generated by dbg.
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_handler() =
fun((trace_event(), trace_data()) -> trace_data())
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).
counter() =
medGwyGatewayNumTimerRecovery | medGwyGatewayNumErrors
medGwyGatewayNumTimerRecovery | medGwyGatewayNumErrors
global_counter() = medGwyGatewayNumErrors
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 | 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()]
- receive_handle
-
Construct a receive_handle from user config.
Value type: receive_handle()
- trans_id
-
Current transaction id.
Value type: transaction_id() | undefined_serial
- min_trans_id
-
First transaction id.
Value type: transaction_id()
Defaults to 1.
- max_trans_id
-
Last transaction id.
Value type: transaction_id() | 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()
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()
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()
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()
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()
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 function.
Value type: megaco_timer()
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()
-
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.
system_info_item() =
text_config | connections | users | n_active_requests |
n_active_replies | n_active_connections | reply_counters |
pending_counters
text_config | connections | users | n_active_requests |
n_active_replies | n_active_connections | reply_counters |
pending_counters
- 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()]
- users
-
Lists all active users.
Value type: [mid()]
- 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(), transaction_id(), non_neg_integer()}]
- pending_counters
-
Returns a list of the receive and sent pending counters.
Value type: [{recv | sent, [{transaction_id(), non_neg_integer()}]}]
start() -> ok | {error, Reason}
Types
stop() -> ok | {error, Reason}
Types
start_user(UserMid, Config) -> ok | {error, Reason}
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_user(UserMid) -> ok | {error, Reason}
user_info(UserMid) -> [{Item, Value}]
user_info(UserMid, Item) -> Value
user_info(UserMid, Item :: requests) -> [{Conn, [TransId]}]
user_info(UserMid, Item :: replies) ->
[{Conn, [{TransId, ReplyState, Handler}]}]
Types
update_user_info(UserMid, Item, Value) -> ok | {error, Reason}
conn_info(ConnHandle) -> [{Item, Value}]
conn_info(ConnHandle, Item) -> Value
conn_info(ConnHandle, Item :: all) -> [{Item, Value}]
Lookup all connection information about an active connection
See conn_info for more info.
Failure: exit if, for instance, ConnHandle refers to a connection that no longer exists.
conn_info(ConnHandle, Item :: requests) -> [TransId]
conn_info(ConnHandle, Item :: replies) ->
[{TransId, ReplyState, Handler}]
Types
update_conn_info(ConnHandle, Item, Value) -> ok | {error, Reason}
Update information about an active connection
Requires that the connection is activated. See conn_info_item() about which items and values that are valid.
system_info() -> [{Item, Value}]
system_info(Item) -> Value
info() -> 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.
This information can be produced by the functions user_info, conn_info, system_info and get_stats but this is a simple way to get it all at once.
connect(ReceiveHandle, RemoteMid, SendHandle, ControlPid) ->
{ok, ConnHandle} | {error, Reason}
connect(ReceiveHandle, RemoteMid, SendHandle, ControlPid, Extra) ->
{ok, ConnHandle} | {error, Reason}
Types
{no_such_user, LocalMid} |
{already_connected, ConnHandle} |
term()
{connection_refused, ConnData, 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() except the atom ignore_extra. It is passed (back) to the user via the callback function handle_connect/3.
disconnect(ConnHandle, DiscoReason) -> ok | {error, ErrReason}
call(ConnHandle, ActionRequests, SendOptions) ->
{ProtocolVersion, UserReply | [UserReply]}
Types
{request_timer, megaco_timer()} |
{long_request_timer, megaco_timer()} |
{send_handle, send_handle()} |
{protocol_version, protocol_version()} |
{call_proxy_gc_timeout, integer() >= 0}
MessageReason | SegmentReason | UserCancelReason |
SendReason | OtherReason
{segment, SegmentsOk, SegmentsErr} |
{segment_timeout, MissingSegments, SegmentsOk, SegmentsErr}
{wrong_mid,
WrongMid :: mid(),
RightMid :: mid(),
transaction_reply()} |
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() (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() 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 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.
cast(ConnHandle, ActionRequests, SendOptions) ->
ok | {error, Reason}
Types
{request_keep_alive_timeout, RequestKeepAliveTimer} |
{request_timer, megaco_timer()} |
{long_request_timer, megaco_timer()} |
{send_handle, send_handle()} |
{reply_data, ReplyData} |
{protocol_version, ProtocolVersion}
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(). 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() 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.
encode_actions(ConnHandle, ActionRequests, Options) ->
{ok, Result} | {error, Reason}
Types
{request_timer, megaco_timer()} |
{long_request_timer, megaco_timer()} |
{send_handle, send_handle()} |
{protocol_version, protocol_version()}
Encodes lists of action requests for one or more transaction request(s).
When encoding action requests for one transaction, Actions should be action_reqs(). When encoding action requests for several transactions, Actions should be [action_reqs()]. Each element of the list is part of one transaction.
token_tag2string(Tag) -> Result
token_tag2string(Tag, EncodingMod) -> Result
token_tag2string(Tag, EncodingMod, Version) -> Result
Types
cancel(ConnHandle, CancelReason) -> ok | {error, Reason}
process_received_message(ReceiveHandle, ControlPid, SendHandle,
BinMsg) ->
ok
process_received_message(ReceiveHandle, ControlPid, SendHandle,
BinMsg, Extra) ->
ok
Types
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) ->
ok
receive_message(ReceiveHandle, ControlPid, SendHandle, BinMsg,
Extra) ->
ok
Types
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.
For further information see the process_received_message/4,5 function.
parse_digit_map(DigitMapBody) ->
{ok, ParsedDigitMap} | {error, Reason}
eval_digit_map(DigitMap) -> {ok, MatchResult} | {error, Reason}
eval_digit_map(DigitMap, Timers) ->
{ok, MatchResult} | {error, Reason}
Types
reject | {reject, digit_map_value()} | digit_map_value()
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.
report_digit_event(DigitMapEvalPid, Events) ->
ok | {error, Reason}
test_digit_event(DigitMap, Events) ->
{ok, Kind, Letters} | {error, Reason}
Types
encode_sdp(SDP) -> {ok, PP} | {error, Reason}
Types
sdp_property_parm() |
sdp_property_group() |
sdp_property_groups() |
asn1_NOVALUE
property_parm() |
property_group() |
property_groups() |
asn1_NOVALUE
decode_sdp(PP) -> {ok, SDP} | {error, Reason}
Types
property_parm() |
property_group() |
property_groups() |
asn1_NOVALUE
sdp() |
DecodeSdpPropertyGroup | DecodeSdpPropertyGroups |
asn1_NOVALUE
Decode (parse) a property parameter construct.
When decoding property_group() or property_groups(), 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()
versions1() -> {ok, VersionInfo} | {error, Reason}
versions2() -> {ok, VersionInfo} | {error, Reason}
print_version_info() -> void()
print_version_info(Versions) -> void()
enable_trace(Level, Destination) -> void()
Types
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.
disable_trace() -> void()
set_trace(Level) -> void()
Types
get_stats() -> {ok, [TotalStats]} | {error, Reason}
Types
{conn_handle(), [Stats]} | {global_counter(), counter_value()}
get_stats(GCounter) -> {ok, Value} | {error, Reason}
get_stats(ConnHandle) -> {ok, [Stats]} | {error, Reason}
get_stats(ConnHandle, Counter) -> {ok, Value} | {error, Reason}
reset_stats() -> void()
reset_stats(GCounter) -> void()
Types
reset_stats(ConnHandle) -> void()
Types
test_request(ConnHandle, Version, EncodingMod, EncodingConfig,
ActionRequests) ->
{MegaMsg, EncodeRes}
Types
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 or cast 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_reply(ConnHandle, Version, EncodingMod, EncodingConfig,
Reply) ->
{MegaMsg, EncodeRes}
Types
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.