Skip to content

Commit

Permalink
@id required in dictionary files only when @messages is specified.
Browse files Browse the repository at this point in the history
@id defines an application identifier and this is used only when sending
or receiving messages. A dictionary can define only AVP's however,
to be included by other dictionaries using @inherits, in which case it
makes no sense to require @id.

Note that message definitions are not inherited with @inherits, only
AVP's
  • Loading branch information
Anders Svensson committed Aug 17, 2011
1 parent a7c0e43 commit 46bcbf8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
3 changes: 2 additions & 1 deletion lib/diameter/doc/src/diameter_dict.xml
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ quantity is insignificant.</p>
<p>
The tags, their arguments and the contents of each corresponding
section are as follows.
Each section can occur only once unless otherwise specified.
Each section can occur at most once unless otherwise specified.
The order in which sections are specified is unimportant.</p>

<taglist>
Expand All @@ -115,6 +115,7 @@ The order in which sections are specified is unimportant.</p>
<p>
Defines the integer Number as the Diameter Application Id of the
application in question.
Required if the dictionary defines <c>@messages</c>.
The section has empty content.</p>

<p>
Expand Down
17 changes: 13 additions & 4 deletions lib/diameter/src/compiler/diameter_codegen.erl
Original file line number Diff line number Diff line change
Expand Up @@ -250,9 +250,14 @@ f_name(Name) ->
%%% ------------------------------------------------------------------------

f_id(Spec) ->
Id = orddict:fetch(id, Spec),
{?function, id, 0,
[{?clause, [], [], [?INTEGER(Id)]}]}.
[c_id(orddict:find(id, Spec))]}.

c_id({ok, Id}) ->
{?clause, [], [], [?INTEGER(Id)]};

c_id(error) ->
?UNEXPECTED(0).

%%% ------------------------------------------------------------------------
%%% # vendor_id/0
Expand Down Expand Up @@ -537,10 +542,14 @@ f_msg_header(Spec) ->
{?function, msg_header, 1, msg_header(Spec) ++ [?UNEXPECTED(1)]}.

msg_header(Spec) ->
msg_header(get_value(messages, Spec), Spec).

msg_header([], _) ->
[];
msg_header(Msgs, Spec) ->
ApplId = orddict:fetch(id, Spec),

lists:map(fun({M,C,F,_,_}) -> c_msg_header(M, C, F, ApplId) end,
get_value(messages, Spec)).
lists:map(fun({M,C,F,_,_}) -> c_msg_header(M, C, F, ApplId) end, Msgs).

%% Note that any application id in the message header spec is ignored.

Expand Down

0 comments on commit 46bcbf8

Please sign in to comment.