4
%% Copyright Ericsson AB 2010-2011. All Rights Reserved.
6
%% The contents of this file are subject to the Erlang Public License,
7
%% Version 1.1, (the "License"); you may not use this file except in
8
%% compliance with the License. You should have received a copy of the
9
%% Erlang Public License along with this software. If not, it can be
10
%% retrieved online at http://www.erlang.org/.
12
%% Software distributed under the License is distributed on an "AS IS"
13
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
14
%% the License for the specific language governing rights and limitations
20
-ifndef(diameter_hrl).
21
-define(diameter_hrl, true).
24
-define(DIAMETER_APP_ID_COMMON, 0).
25
-define(DIAMETER_APP_ID_ACCOUNTING, 3).
26
-define(DIAMETER_APP_ID_RELAY, 16#FFFFFFFF).
28
%% Corresponding dictionaries:
29
-define(DIAMETER_DICT_COMMON, diameter_gen_base_rfc3588).
30
-define(DIAMETER_DICT_ACCOUNTING, diameter_gen_base_accounting).
31
-define(DIAMETER_DICT_RELAY, diameter_gen_relay).
33
%% Events sent to processes that have subscribed with
34
%% diameter:subscribe/1.
36
-record(diameter_event,
40
%% diameter_packet records are passed through the encode/decode
41
%% interface supplied by a dictionary module configured on a Diameter
42
%% application. For an incoming message the bin field contains the
43
%% received binary and the header, avps, msg and errors fields the
44
%% result of decoding.
46
-record(diameter_packet,
47
{header, %% #diameter_header{}
48
avps, %% deep list() of #diameter_avp{}
49
msg, %% fully decoded message
50
bin, %% binary received/sent over the wire
51
errors = [],%% list() of Result-Code | {Result-Code, #diameter_avp{}}
54
-record(diameter_header,
55
{version, %% 8-bit unsigned
56
length, %% 24-bit unsigned
57
cmd_code, %% 8-bit unsigned
58
application_id, %% 24-bit unsigned
59
hop_by_hop_id, %% 32-bit unsigned
60
end_to_end_id, %% 32-bit unsigned
61
is_request, %% boolean() R flag
62
is_proxiable, %% boolean() P flag
63
is_error, %% boolean() E flag
64
is_retransmitted}). %% boolean() T flag
67
{code, %% 32-bit unsigned
68
vendor_id, %% 32-bit unsigned
69
is_mandatory = false, %% boolean() M flag
70
need_encryption = false, %% boolean() P flag
71
data, %% encoded binary()
72
name, %% atom() AVP name
73
value, %% decoded term() decoded | undefined
74
type, %% atom() type name,
75
index}). %% non_neg_integer() | undefined
77
%% A diameter_caps record corresponds to capabilities configuration on
78
%% diameter:start_service/2. In application callbacks is identifies
79
%% the peer connection for which the callback is taking place, and in
80
%% this case each field is a 2-tuple specifying the host (ie. local)
81
%% and peer (ie. remote) values, host values having been configured
82
%% and peer values having been received at capabilities exchange.
84
-record(diameter_caps,
85
{origin_host, %% 'DiameterIdentity'()
86
origin_realm, %% 'DiameterIdentity'()
87
host_ip_address = [], %% ['Address'()]
88
vendor_id, %% 'Unsigned32'()
89
product_name, %% 'OctetString'()
90
origin_state_id = [], %% ['Unsigned32'()]
91
supported_vendor_id = [], %% ['Unsigned32'()]
92
auth_application_id = [], %% ['Unsigned32'()]
93
inband_security_id = [], %% ['Unsigned32'()]
94
acct_application_id = [], %% ['Unsigned32'()]
95
vendor_specific_application_id = [], %% ['Grouped'()]
96
firmware_revision = [], %% ['Unsigned32()]
99
%% AVP's of type DiameterURI are encoded as a diameter_uri record.
100
%% Note that AVP's of type IPFilterRule and QoSFilterRule are currently
101
%% encoded simply as OctetString's.
103
-record(diameter_uri,
106
port = 3868, %% non_neg_integer(),
107
transport = sctp, %% | tcp,
108
protocol = diameter}). %% | radius | 'tacacs+'
110
%% A diameter_callback record can be specified as an application
111
%% module in order to selectively receive callbacks or alter their
113
-record(diameter_callback,
125
%% The diameter service and diameter_apps records are only passed
126
%% through the transport interface when starting a transport process,
127
%% although typically a transport implementation will (and probably
128
%% should) only be interested host_ip_address.
130
-record(diameter_service,
132
capabilities, %% #diameter_caps{}
133
applications = []}). %% [#diameter_app{}]
135
-record(diameter_app,
136
{alias, %% option 'alias'
137
dictionary, %% option 'dictionary', module()
138
module, %% [Mod | Args] callback module() and extra args
139
init_state, %% option 'state', initial callback state
140
id, %% 32-bit unsigned application identifier = Dict:id()
141
mutable = false, %% boolean(), do traffic callbacks modify state?
142
answer_errors = report}). %% | callback | discard
143
%% how to handle containing errors?
145
-endif. %% -ifdef(diameter_hrl).