megaco_encoder(3erl)
π the megaco_encoder behaviour β bestie edition π
okay so this is the megaco_encoder(3erl) page, aka the Erlang module definition for the Megaco encoder behaviour. pull up a chair, we're getting into it π«Άβ¨
πΈ NAME πΈ
megaco_encoder β Megaco encoder behaviour. literally the callback behaviour for encoding/decoding Megaco messages, no cap π
π¦ DESCRIPTION π¦
bestie, here's the vibe: these are the functions that should be exported from a megaco_encoder callback module:
π DATA TYPES π
π Note
quick heads-up: the actual definition of some of these records depends on the Megaco protocol version you're using. for example, the 'TransactionReply' record has two more fields in version 3, so a simple Erlang type definition cannot be made here. iykyk π
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'{}
β¨ EXPORTS β¨
π Module:encode_message(EncodingConfig, Version, Message) -> {ok, Bin} | Error
Module:encode_message(EncodingConfig, Version, Message) -> {ok, Bin} | Error
Types:
EncodingConfig = list()
Version = integer()
Message = megaco_message()
Bin = binary()
Error = term()
encode a Megaco message. that's the whole mood π
π Module:decode_message(EncodingConfig, Version, Bin) -> {ok, Message} | Error
Module:decode_message(EncodingConfig, Version, Bin) -> {ok, Message} | Error
Types:
EncodingConfig = list()
Version = integer() | dynamic
Message = megaco_message()
Bin = binary()
Error = term()
decode a Megaco message. slay π₯
here's the important bit: 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, like version 1. if instead the Version argument is an integer, that means it's the expected version of the message, and the decoder for that version should be used. periodt π
π Module:decode_mini_message(EncodingConfig, Version, Bin) -> {ok, Message} | Error
Module:decode_mini_message(EncodingConfig, Version, Bin) -> {ok, Message} | Error
Types:
EncodingConfig = list()
Version = integer() | dynamic
Message = megaco_message()
Bin = binary()
Error = term()
do a minimal decode of a Megaco message. the purpose of this function is to do a minimal decode of a 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.
and note again, bestie: a successfull decode only returns a partially initiated message. don't forget that part π
π Module:encode_transaction(EncodingConfig, Version, Transaction) -> OK | Error
Module:encode_transaction(EncodingConfig, Version, Transaction) -> OK | Error
Types:
EncodingConfig = list()
Version = integer()
Transaction = transaction()
OK = {ok, Bin}
Bin = binary()
Error = {error, Reason}
Reason = not_implemented | OtherReason
OtherReason = 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! no pressure, but alsoβ¦ pressure ππ₯
π Module:encode_action_requests(EncodingConfig, Version, ARs) -> OK | Error
Module:encode_action_requests(EncodingConfig, Version, ARs) -> OK | Error
Types:
EncodingConfig = list()
Version = integer()
ARs = action_requests()
action_requests() = [action_request()]
OK = {ok, Bin}
Bin = binary()
Error = {error, Reason}
Reason = not_implemented | OtherReason
OtherReason = 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.
π Module:encode_action_reply(EncodingConfig, Version, AR) -> OK | Error
Module:encode_action_reply(EncodingConfig, Version, AR) -> OK | Error
Types:
EncodingConfig = list()
Version = integer()
AR = action_reply()
OK = {ok, Bin}
Bin = binary()
Error = {error, Reason}
Reason = not_implemented | OtherReason
OtherReason = 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! iconic behaviour required πβ¨
mwah π β signed off with love from Ericsson AB β’ megaco 4.4.3 β’ megaco_encoder(3erl) π«Άπ
π¦ where this page comes from
- ubuntu noble: erlang-manpages 1:25.3.2.8+dfsg-1ubuntu4 Β· Apache-2.0
- ubuntu noble: erlang-manpages 1:25.3.2.8+dfsg-1ubuntu4.8 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms