1%% 2%% %CopyrightBegin% 3%% 4%% Copyright Ericsson AB 2010-2018. All Rights Reserved. 5%% 6%% Licensed under the Apache License, Version 2.0 (the "License"); 7%% you may not use this file except in compliance with the License. 8%% You may obtain a copy of the License at 9%% 10%% http://www.apache.org/licenses/LICENSE-2.0 11%% 12%% Unless required by applicable law or agreed to in writing, software 13%% distributed under the License is distributed on an "AS IS" BASIS, 14%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15%% See the License for the specific language governing permissions and 16%% limitations under the License. 17%% 18%% %CopyrightEnd% 19%% 20 21%% Our Erlang application. 22-define(APPLICATION, diameter). 23 24%% The one and only. 25-define(DIAMETER_VERSION, 1). 26 27%% Exception for use within a module with decent protection against 28%% catching something we haven't thrown. Not foolproof but close 29%% enough. ?MODULE is rudmentary protection against catching across 30%% module boundaries, a root of much evil: always catch ?FAILURE(X), 31%% never X. 32-define(FAILURE(Reason), {{?MODULE}, {Reason}}). 33-define(THROW(Reason), throw(?FAILURE(Reason))). 34 35%% A corresponding error when failure is the best option. 36-define(ERROR(T), erlang:error({T, ?MODULE, ?LINE})). 37 38%% Warning report for unexpected messages in various processes. 39-define(UNEXPECTED(F,A), 40 diameter_lib:warning_report(unexpected, {?MODULE, F, A})). 41-define(UNEXPECTED(A), ?UNEXPECTED(?FUNC, A)). 42 43%% Something to trace on. 44-define(LOG(Slogan, Details), 45 diameter_lib:log(Slogan, ?MODULE, ?LINE, Details)). 46-define(LOGC(Bool, Slogan, Details), ((Bool) andalso ?LOG(Slogan, Details))). 47 48%% Compensate for no builtin ?FUNC for use in log reports. 49-define(FUNC, element(2, element(2, process_info(self(), current_function)))). 50 51%% Disjunctive match spec condition. 'false' is to ensure that there's at 52%% least one condition. 53-define(ORCOND(List), list_to_tuple(['orelse', false | List])). 54 55%% 3588, 2.4: 56-define(APP_ID_COMMON, 0). 57-define(APP_ID_RELAY, 16#FFFFFFFF). 58 59%%% --------------------------------------------------------- 60 61%%% RFC 3588, ch 2.6 Peer table 62-record(diameter_peer, 63 {host_id, 64 statusT, 65 is_dynamic, 66 expiration, 67 tls_enabled}). 68 69%%% RFC 3588, ch 2.7 Realm-based routing table 70-record(diameter_realm, 71 {name, 72 app_id, 73 local_action, % LOCAL | RELAY | PROXY | REDIRECT 74 server_id, 75 is_dynamic, 76 expiration}). 77