aboutsummaryrefslogtreecommitdiffstats
path: root/lib/diameter/src
AgeCommit message (Collapse)Author
2017-09-04Rename field in codec map: dictionary -> app_dictionaryAnders Svensson
To better reflect what the field is: field 'module' is the dictionary module that's calling diameter_gen to decode a list of AVP, while field 'app_dictionary' is the dictionary module defining the message being decoded.
2017-09-04Add RFC 7683 Diameter Overload Indicator Conveyance text and dictionaryAnders Svensson
Which motivates the avp_dictionaries config that will be added in a subsequent commit.
2017-09-04Fix decode undefAnders Svensson
Function avp/5 isn't exported from dictionary modules. Not necessarily intentional, but don't just export it since that requires recompilation of all dictionary modules, since the function is in diameter_gen.hrl. Not having to recompile was the main motivation for moving most of the included code to module diameter_gen in commit 205521d3. This reveals a weakness in the decode of answers setting the E-bit: any AVP that isn't defined by the common application won't be decoded; the diameter_avp records that these are packed into (in the 'AVP' field of a message record, or equivalent) will have value = undefined. This is nothing new (same in OTP 19), but the values should be decoded. Fix it (and the lack of test coverage) in a subsequent commit that will add avp_dictionaries config.
2017-09-04Fix dictionary compilation error messageAnders Svensson
Adding a second {Vendor-Id} to the common CER definition results in this error: ** AVP CER at line 85 already referenced at line 84 That is, the error incorrectly refers to the message name (CER) where the AVP name (Vendor-Id) is expected.
2017-09-01Rename decode_format false to noneAnders Svensson
Which reads better and makes it easier to distinguish this false from others.
2017-09-01Tweak {decode_format, false} semanticsAnders Svensson
Represent the decoded message by its atom-valued name in diameter_packet.msg, which makes trace much more readable. A diameter_avp.value is untouched (ie. undefined): the AVP name is already in the name field.
2017-09-01Fix dialyzer specAnders Svensson
Which dialyzer hasn't noticed.
2017-09-01Merge branch 'anders/diameter/config_consistency/OTP-14555' into ↵Anders Svensson
anders/diameter/decode_format/OTP-14511 * anders/diameter/config_consistency/OTP-14555: Fix strict_arities blunder Fix minor error-handling blunder Let strict_mbit and incoming_maxlen be configured per transport Let a service configure default transport options Rename type evaluable -> eval Document transport_opt() strict_capx Rename transport_opt() capx_strictness to strict_capx
2017-09-01Fix strict_arities blunderAnders Svensson
Remove value from the merged map, not from the maps being merged. Bundled in commit 5f3becad.
2017-08-31Fix minor error-handling blunderAnders Svensson
Leading to this admonition from dialyzer: diameter_config.erl:670: The variable No can never match since previous clauses completely covered the type 'ok' The throw was caught, but resulted in an error return without the intended information.
2017-08-31Fix handling of Proxy-Info in answers formulated by diameterAnders Svensson
RFC 6733 says this: 6.2. Diameter Answer Processing When a request is locally processed, the following procedures MUST be applied to create the associated answer, in addition to any additional procedures that MAY be discussed in the Diameter application defining the command: ... o Any Proxy-Info AVPs in the request MUST be added to the answer message, in the same order they were present in the request. This wasn't done when a handle_request callback returned a Result-Code in an 'answer-message' or protocol_error tuple, causing diameter itself to construct the answer message. This form of answer is just a convenience, since the callback can always return an answer that it constructs itself.
2017-08-31Fix extraction of Experimental-Result for counter keysAnders Svensson
The introduction of decode_format in commit 722fa415 (and then 55e65b26) meant the value was not necessarily the intended tuple.
2017-08-31Rename variableAnders Svensson
It's no longer the AVP name as of the parent commit, but the name of the field/member the value will be stored in. Typically the AVP name, but possibly 'AVP'.
2017-08-31Fix decode of too many generic AVPsAnders Svensson
That is, when the arity of an 'AVP' field has an upper bound. This shouldn't happen in practice, but if an AVP is known but its name not explicit in the message grammar then its count was confused with that of AVPs packed into the 'AVP' field.
2017-08-31Enumerate AVPs in diameter_avp.index (again)Anders Svensson
Commit 96cd627a changed the way the index field was used, but the enumeration is used in at least one known application (as a pointer from elements of diameter_packet.errors to elements of diameter_packet.avps) and the motivation for the change is questionable: the lookup that was avoided was unnecessary given that it was already performed in incrementing a counter. Revert to enumerating as before in the non-relay case, but not in the relay case since there's no corresponding usecase.
2017-08-28Fix influence of decode_format on service eventsAnders Svensson
Decoded CER/CEA messages are passed in events messages that can be subscribed to using diameter:subscribe/1. A configured decode_format was not reflected in these, messages always being passed as records. Clarify that strict_arities only applies to message callbacks.
2017-08-25Let strict_mbit and incoming_maxlen be configured per transportAnders Svensson
Since these can make sense per peer. The remaining service-only options either belong there or make little sense being configured per transport.
2017-08-25Let a service configure default transport optionsAnders Svensson
Only a default spawn_opt has been possible to configure, but there's no reason why most others should need to be configured per transport. Those options that still only make sense on a transport are transport_module/config (because of the semantics of multiple values), applications/capabilities (since these override service options), and private (since it's only to allow user-specific options in a backwards compatible way).
2017-08-24Rename type evaluable -> evalAnders Svensson
Export the old type as a synonym for backwards compatability. The name evaluable is a bit too awkward.
2017-08-24Rename transport_opt() capx_strictness to strict_capxAnders Svensson
To follow the naming of options like strict_mbit and more. Still accept capx_strictness since this is known to be used. Introduced in commit e4f28f3b.
2017-08-10Add service_opt() traffic_countersAnders Svensson
To be able to disable the counting of messages for which application callbacks take place. Messages sent/handled by diameter itself are always counted.
2017-08-10Fix type specAnders Svensson
That dialyzer hasn't noticed is broken.
2017-08-10Split AVPs at decodeAnders Svensson
Despite what the Efficiency Guide says about match being more efficient, split_binary appears to be slightly faster. (Although this one extraction is a drop in the bucket.) Binary optimizations aren't an issue during decode.
2017-08-10Avoid unnecessary copying of binaries in diameter_tcpAnders Svensson
Since messages are accumulated by appending binaries as of three commits back, the accumulated binary is prone to being copied, as discussed in the Efficiency Guide. Matching the Message Length header as bytes are being accumulated is one cause of this, so work around it by splitting the binary and extracting the length without a match. This doesn't feel like something that should be necessary: that matching a binary would cause an append to copy isn't obvious. The first attempt at simplifying the accumulation was simply to append an incoming binary to the current fragment, match against <<_, Len:24, _/binary>> to extract the length, and then test if there are enough bytes for a message. This lead to horrible performance (response times for 2 MB messages approximately 100 times worse than previously), and it wasn't at all obvious that the reason was the accumulated binary being copied with each append as a result of the match. Using split_binary avoids the match context that forces the copying.
2017-08-10Don't update diameter_tcp state unnecessarilyAnders Svensson
Not with each setopts to re-activate the socket.
2017-08-10Don't update diameter_tcp state unnecessarilyAnders Svensson
Only reset the fragment after all messages have been extracted.
2017-08-10Simplify extraction of incoming Diameter messages in diameter_tcpAnders Svensson
Appending to a binary is efficient, so just append message fragments Only match out the length once per message since doing so for every packet from TCP causes the binary to be copied.
2017-08-10Restructure/simplify message reception in diameter_peer_fsmAnders Svensson
Create less garbage.
2017-08-10Fix type specAnders Svensson
That dialyzer hasn't noticed is broken.
2017-08-03Optimize sub-binariesAnders Svensson
Also inline incr/8 and associated functions that were needed for the compiler to accept the optimization, since this does make for a measuable improvement.
2017-08-03Optimize sub-binariesAnders Svensson
With ERL_COMPILER_OPTIONS=bin_opt_info, before: base/diameter_codec.erl:508: Warning: NOT OPTIMIZED: the binary matching instruction that follows in the same function have problems that prevent delayed sub binary optimization (probably indicated by INFO warnings) And after: base/diameter_codec.erl:508: Warning: OPTIMIZED: creation of sub binary delayed This has a surprisingly large impact on the performance of diameter_codec:collect_avps/2: about 15% faster in one testcase on a RAR with 7 AVPs.
2017-08-03Count AVPs in #diameter_avp.indexAnders Svensson
The index field in record diameter_avp was previously used to enumerate AVPs so that the list could be returned in some cases, since diameter_codec:collect_avps/2 (now /1) reversed the order. That's no longer the case as of the grandparent commit, so use the field to enumerate instances of the same AVP instead, and only when arities are being checked, to save having to look them up in the map when checking for 5009 errors, or counting AVPs at all in diameter_codec:collect_avps/1.
2017-08-03Don't extract options unnecessarily at encodeAnders Svensson
Extract strict_arities once and pass it through as an argument.
2017-08-03Redo message decode as a single passAnders Svensson
Decode has previously been two passes: first chunk the message into a reversed list of toplevel diameter_avp records, then fold through the reversed list to build the full result. Various workarounds have made it a bit more convoluted than it should be however. Rework it completely, turning the previous 2-pass tail-recursive implementation into a 1-pass body recursive one. The relay decode still exists in diameter_codec, as a stripped down version of the full decode in diameter_gen.
2017-08-03Be forgiving of non-list values at encodeAnders Svensson
2017-08-03Add service_opt() strict_aritiesAnders Svensson
To be able to disable the relatively expensive check that the number of AVPs received in a message or grouped AVP agrees with the dictionary in question. The may well be easier for the user in handle_request/answer callbacks, when digesting the received message, and in some cases may not be important. The check at encode can also be disabled, allowing messages that don't agree with the dictionary in question to be sent, which can be useful in test (at least).
2017-08-03Fix detection of 5009 errorsAnders Svensson
As noted in the parent commit, the wrong AVPs were reported, being counted from the back of the message instead of the front. Both 5005 and 5009 errors are now detected after the message is decoded.
2017-08-03Don't count AVPs unnecessarily at encodeAnders Svensson
Stop counting when there can be no arity errors.
2017-08-03Don't take length of AVP lists unnecessarily at encodeAnders Svensson
Count as AVPs are encoded instead.
2017-08-03Tweak map-valued decodeAnders Svensson
Use the same [MsgName | Avps] representation as for the list decode, but with Avps a map instead of a AVP name/values list. As a result, don't set the message/AVP name on an additional key in the map, which felt a bit odd. Messages are [MsgName :: atom() | map()], Grouped AVPs are just map(). Fix at least one problem in the traffic suite along the way: with decode_format false, the own decode in to_map/2 didn't know whether or not to decode strings, resulting on some failures.
2017-08-03Add decode_format record_from_mapAnders Svensson
Undocumented, for transforming a map decode to record. The record decode becomes more expensive the larger the number of AVPs in the message definition in question, since the record is recreated each time an AVP value is set in it. The map decode can potentially do better.
2017-08-03Rename record_decode -> decode_formatAnders Svensson
{record_decode, map} is a bit too quirky.
2017-08-03Let messages and grouped AVPs be decoded to listsAnders Svensson
That is, decode to the same format that encode already accepts. Only a message has its name at the head of the list since AVPs are already name/value pairs.
2017-08-03Let messages and grouped AVPs be encoded/decoded from/to mapsAnders Svensson
With {record_decode, map}. The option name is arguably a bit misleading now, but not too objectionable given that the encode/decode in question has historically only been of records. One advantage of the map decode is that the map only contains values for those AVPs existing in the message or grouped AVP in question. The name of the message or grouped AVP is stored in with key ':name', the leading colon ensuring that the key isn't a diameter-name. Decoding to maps makes the hrl files generated from dictionary files largely irrelevant. There are value defines generated into these, but they're typically so long as to be unusable.
2017-08-03Add service_opt() record_decodeAnders Svensson
To control whether or not messages and grouped AVPs are decoded to records, in #diameter_packet.msg and #diameter_avp.value respectively. The decode became unnecessary for diameter's needs in parent commit, which decoupled it from the checking of AVP arities.
2017-08-03Count AVP arities during decodeAnders Svensson
Instead of after, during the check that AVPs have sufficient arity. This makes the arity checks independent of the record decode, which will allow the latter to be made optional.
2017-08-03Fix obsolete diameter_gen.hrl commentsAnders Svensson
Most of the contents were moved to module diameter_gen in commit 205521d3.
2017-06-14Update copyright yearHans Nilsson
2017-06-14Merge branch 'anders/diameter/20.0/OTP-14398'Anders Svensson
* anders/diameter/20.0/OTP-14398: vsn -> 2.0 Update appup for 20.0
2017-06-14Merge branch 'anders/diameter/capx_vs_dpr/OTP-14338'Anders Svensson
* anders/diameter/capx_vs_dpr/OTP-14338: Let candidate peers be passed to diameter:call/4 Comment on RFC ambiguity regarding application identifiers Remove trailing whitespace