aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnders Svensson <[email protected]>2011-08-17 11:50:23 +0200
committerAnders Svensson <[email protected]>2011-08-17 11:50:23 +0200
commit46bcbf8b8c5e53d3b9aaa1be987947fc0b927f8d (patch)
treeb814e88ab7ae189f07ac6bd362817b7fa6a67c3d
parenta7c0e439ee84d25ce18f65959be06315063a7de8 (diff)
downloadotp-46bcbf8b8c5e53d3b9aaa1be987947fc0b927f8d.tar.gz
otp-46bcbf8b8c5e53d3b9aaa1be987947fc0b927f8d.tar.bz2
otp-46bcbf8b8c5e53d3b9aaa1be987947fc0b927f8d.zip
@id required in dictionary files only when @messages is specified.
@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
-rw-r--r--lib/diameter/doc/src/diameter_dict.xml3
-rw-r--r--lib/diameter/src/compiler/diameter_codegen.erl17
2 files changed, 15 insertions, 5 deletions
diff --git a/lib/diameter/doc/src/diameter_dict.xml b/lib/diameter/doc/src/diameter_dict.xml
index a87f59bad5..749b518a06 100644
--- a/lib/diameter/doc/src/diameter_dict.xml
+++ b/lib/diameter/doc/src/diameter_dict.xml
@@ -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>
@@ -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>
diff --git a/lib/diameter/src/compiler/diameter_codegen.erl b/lib/diameter/src/compiler/diameter_codegen.erl
index 213ba0d22c..6895f38248 100644
--- a/lib/diameter/src/compiler/diameter_codegen.erl
+++ b/lib/diameter/src/compiler/diameter_codegen.erl
@@ -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
@@ -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.