Search documentation of megaco

# View Source megaco_udp (megaco v4.6)

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

Link to this type

# counter()

View Source

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

Defines the different counters handled by this transport.

Link to this opaque

# handle()

View Source

    -opaque handle()

An opaque data type representing an UDP socket.

Link to this opaque

# send_handle()

View Source

    -opaque send_handle()

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

# Functions

Link to this function

# block(Handle)

View Source

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

Stop receiving incoming messages on the socket.

Link to this function

# close(Handle)

View Source

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

This function is used for closing an active UDP socket.

Link to this function

# create_send_handle(Handle, Host, Port)

View Source

    -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.

Link to this function

# get_stats()

View Source

    -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.

Link to this function

# get_stats(SH)

View Source

    -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.

Link to this function

# get_stats(SH, Counter)

View Source

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

Get the value of a specific counter.

Link to this function

# open(TransportRef, Opts)

View Source

    -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).

Link to this function

# reset_stats()

View Source

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

Reset all counters for all UDP handles.

Link to this function

# reset_stats(SH)

View Source

Reset all counters for the given UDP handle.

Link to this function

# send_message(SH, Msg)

View Source

    -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.

Link to this function

# socket(Handle)

View Source

    -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()`.

Link to this function

# start_transport()

View Source

    -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.

Link to this function

# unblock(Handle)

View Source

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

Starting to receive incoming messages from the socket again.

Link to this function

# upgrade_receive_handle(ControlPid, NewRecvHandle)

View Source

    -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).