User's Guide
Reference Manual
Release Notes
PDF
Top

Diameter
Reference Manual
Version 1.11.1

Expand All
Contract All

Table of Contents

- diameter
  - Top of manual page
  - add_transport/2
  - call/4
  - origin_state_id/0
  - remove_transport/2
  - service_info/2
  - services/0
  - session_id/1
  - start/0
  - start_service/2
  - stop/0
  - stop_service/1
  - subscribe/1
  - unsubscribe/1
- diameterc
- diameter_app
  - Top of manual page
  - Mod:peer_up/3
  - Mod:peer_down/3
  - Mod:pick_peer/4
  - Mod:prepare_request/3
  - Mod:prepare_retransmit/3
  - Mod:handle_answer/4
  - Mod:handle_error/4
  - Mod:handle_request/3
- diameter_codec
  - Top of manual page
  - decode/2
  - encode/2
- diameter_dict
- diameter_make
  - Top of manual page
  - codec/2
  - format/1
  - flatten/1
  - format_error/1
- diameter_transport
  - Top of manual page
  - Mod:start/3
- diameter_tcp
  - Top of manual page
  - start/3
- diameter_sctp
  - Top of manual page
  - start/3

# diameter_make

### MODULE

diameter_make

### MODULE SUMMARY

Diameter dictionary compilation.

### DESCRIPTION

The function codec/2 is used to compile a diameter dictionary file into Erlang source. The resulting source implements the interface diameter requires to encode and decode the dictionary's messages and AVPs.

The utility diameterc(1) provides an alternate compilation interface.

### EXPORTS

codec(File :: iolist() | binary(), [Opt]) -> ok | {ok, [Out]} | {error, Reason}

Compile a single dictionary file. The input File can be either a path or a literal dictionary, the occurrence of newline (ascii NL) or carriage return (ascii CR) identifying the latter. Opt determines the format of the results and whether they are written to file or returned, and can have the following types.

parse | forms | erl | hrl

  Specifies an output format. Whether the output is returned or written to file depends on whether or not option return is specified. When written to file, the resulting file(s) will have extensions .D, .F, .erl, and .hrl respectively, basenames defaulting to dictionary if the input dictionary is literal and does not specify @name. When returned, results are in the order of the corresponding format options. Format options default to erl and hrl (in this order) if unspecified.

  The parse format is an internal representation that can be passed to flatten/1 and format/1, while the forms format can be passed to compile:forms/2. The erl and hrl formats are returned as iolists.

{include, string()}

  Prepend the specified directory to the code path. Use to point at beam files compiled from inherited dictionaries, @inherits in a dictionary file creating a beam dependency, not an erl/hrl dependency.

  Multiple include options can be specified.

{outdir, string()}

  Write generated source to the specified directory. Defaults to the current working directory. Has no effect if option return is specified.

return

  Return results in a {ok, [Out]} tuple instead of writing to file and returning ok.

{name|prefix, string()}

  Transform the input dictionary before compilation, setting @name or @prefix to the specified string.

{inherits, string()}

  Transform the input dictionary before compilation, appending @inherits of the specified string.

  Two forms have special meaning:

      {inherits, "-"}
      {inherits, "Prev/Mod"}

  The first has the effect of clearing any previous inherits, the second of replacing a previous inherits of Prev to one of Mod. This allows the semantics of the input dictionary to be changed without modifying the file itself.

  Multiple inherits options can be specified.

Note that a dictionary's @name, together with the outdir option, determine the output paths when the return option is not specified. The @name of a literal input dictionary defaults to dictionary.

A returned error reason can be converted into a readable string using format_error/1.

format(Parsed) -> iolist()

Turns a parsed dictionary, as returned by codec/2, back into the dictionary format.

flatten(Parsed) -> term()

Reconstitute a parsed dictionary, as returned by codec/2, without using @inherits. That is, construct an equivalent dictionary in which all AVP's are definined in the dictionary itself. The return value is also a parsed dictionary.

format_error(Reason) -> string()

Turn an error reason returned by codec/2 into a readable string.

### BUGS

Unrecognized options are silently ignored.

### SEE ALSO

diameterc(1), diameter_dict(4)