Subject: Re: [AAA-WG]: [Issue] Proposed fix for Grouped AVP (Issue 11)

From: David Frascone <[email-masked]>
Date: Tue, 29 May 2001 14:37:57 -0500

On Tue, May 29, 2001 at 12:14:05PM -0700, Pat Calhoun wrote:
> 4.4  Grouped AVP Values
> 
>    The Diameter protocol allows AVP values of type 'Grouped.' This
>    implies that the Data field is actually a sequence of AVPs.  It is
>    possible to include an AVP with a Grouped type within a Grouped type,
>    that is, to nest them. AVPs within an AVP of type Grouped have the
>    same padding requirements as non-Grouped AVPs, as defined in section
>    4.0.

Small nit:  Since the avps within a group must be padded, and since the
avp header itself is padded by design, then isn't the last sentance here
redundant?

---

From: Pat Calhoun <[email-masked]>
Date: Tue, 29 May 2001 12:14:05 -0700

All,

Although Paul proposed a fix for the base protocol spec, I believe that
the ABNF needs to be well defined. Below is my proposed fix for this
issue.

Comments welcomed,

PatC
----

4.3  AVP Data Formats

  [...]

      Grouped
         The Data field is specified as a sequence of AVPs.  Each of
         these AVPs follows including their headers and padding.  The

Calhoun et al.            expires October 2001                 [Page 29]

Internet-Draft                                                  May 2001

         AVP Length field is set to 8 (12 if the 'V' bit is enabled)
         plus the total length of all included AVPs, including their
         headers and padding.

4.4  Grouped AVP Values

   Every Grouped AVP defined MUST include a corresponding ABNF [31]
   specification, which is used to define the AVPs that MUST, MAY and
   MUST NOT be present. The following format is used in the definition:

      avp-def          = name "::=" avp

      name-fmt         = ALPHA *(ALPHA / DIGIT / "-")

      name             = name-fmt
                          ; The name has to be the name of an AVP,
                          ; defined in the base or extended Diameter
                          ; specifications.

      avp              = header  [ *fixed] [ *required] [ *optional]
                         [ *fixed]

      header           = "<AVP-Header:" avpcode ">"

      avpcode          = 1*DIGIT
                          ; The AVP Code assigned to the Grouped AVP

      fixed            = [qual] "<" avp-spec ">"

      required         = [qual] "{" avp-spec "}"

      optional         = [qual] "[" avp-name "]"
                          ; The avp-name in the 'optional' rule cannot
                          ; evaluate to any AVP Name which is included
                          ; in a fixed or required rule.

      qual             = [min] "*" [max]
                          ; See ABNF conventions, RFC 2234 section 6.6.
                          ; The absence of any qualifiers implies that
                          ; one and only one such AVP MUST be present.

Calhoun et al.            expires October 2001                 [Page 30]

Internet-Draft                                                  May 2001

                          ;
                          ; NOTE:  "[" and "]" have a different meaning
                          ; than in ABNF (see the optional rule, above).
                          ; These braces cannot be used to express
                          ; optional fixed rules (such as an optional
                          ; ICV at the end.)  To do this, the convention
                          ; is '0*1fixed'.

      min              = 1*DIGIT
                          ; The minimum number of times the element may
                          ; be present.

      max              = 1*DIGIT
                          ; The maximum number of times the element may
                          ; be present.

      avp-spec         = name-fmt
                          ; The avp-spec has to be an AVP Name, defined
                          ; in the base or extended Diameter
                          ; specifications.

      avp-name         = avp-spec | "AVP"
                          ; The string "AVP" stands for *any* arbitrary
                          ; AVP Name, which does not conflict with the
                          ; required or fixed position AVPs defined in
                          ; the command code definition.

4.4.1  Example AVP with a Grouped Data type

   The Example AVP (AVP Code 999999) is of type Grouped and is used to
   clarify how Grouped AVP values work.  The Grouped Data field has the
   following ABNF grammar:

      Example-AVP  ::= < AVP Header: 999999 >
                       { Origin-Host }
                       { Host-IP-Address }

   An Example AVP with the Grouped Data Origin-Host = "example.com",
   Host-IP-Address = "10.10.10.10" would be encoded as follows:

Calhoun et al.            expires October 2001                 [Page 31]

Internet-Draft                                                  May 2001

          0       1       2       3       4       5       6       7
      +-------+-------+-------+-------+-------+-------+-------+-------+
    0 |     Example AVP Header (AVP Code = 999999), Length = 40       |
      +-------+-------+-------+-------+-------+-------+-------+-------+
    8 |     Origin-Host AVP Header (AVP Code = 264), Length = 19      |
      +-------+-------+-------+-------+-------+-------+-------+-------+
   16 |  'e'  |  'x'  |  'a'  |  'm'  |  'p'  |  'l'  |  'e'  |  '.'  |
      +-------+-------+-------+-------+-------+-------+-------+-------+
   24 |  'c'  |  'o'  |  'm'  |Padding|    Host-IP-Addr AVP Header    |
      +-------+-------+-------+-------+-------+-------+-------+-------+
   32 | (AVP Code = 257), Length = 12 |  0x0a |  0x0a |  0x0a | 0x0a  |
      +-------+-------+-------+-------+-------+-------+-------+-------+

---

From: Erik Guttman <[email-masked]>
Date: Wed, 30 May 2001 10:46:32 +0200 (MET DST)

> avp header itself is padded by design, then isn't the last sentance here

This clarifying text came out of implementor confusion.  We went back 
and forth on this a few times on the diameter list, if I recall.  
Sometimes redundancy is needed to help people along toward interoperable
implementations.

Erik

---

From: Erik Guttman <[email-masked]>
Date: Wed, 30 May 2001 11:59:52 +0200 (MET DST)

Pat,

A couple comments on resolution to Issue #11:

>    MUST NOT be present. 

This is no longer true.  The Diameter modified ABNF has special rules
for optional terms which are not in ABNF.  For instance, a term in 
the optional AVP section cannot evaluate to a term in a fixed or
required section.  Suggested fix:

   Every Grouped AVP defined MUST include a corresponding grammar,
   using ABNF [31] with Diameter extensions, as defined below.

>       Example-AVP  ::= < AVP Header: 999999 >

A better example, to show how flexible things are now, is to give
the following example:

                       1*{ Session-Id }
                        *[ AVP ]

   An Example AVP with Grouped Data follows.  

   The Origin-Host AVP is required.  In this case:
    
      Origin-Host = "example.com".  

   One or more Session-Ids must follow.  Here there are two: 

      Session-Id =     
        "grump.example.com:33041;23432;893;0AF3B81" 

      Session-Id =
        "grump.example.com:33054;23561;2358;0AF3B82"

   optional AVPs included are 

     Recovery-Policy = <binary>
        2163bc1d0ad82371f6bc09484133c3f09ad74a0dd5346d54195a7cf0b35
        2cabc881839a4fdcfbc1769e2677a4c1fb499284c5f70b48f58503a45c5
        c2d6943f82d5930f2b7c1da640f476f0e9c9572a50db8ea6e51e1c2c7bd
        f8bb43dc995144b8dbe297ac739493946803e1cee3e15d9b765008a1b2a
        cf4ac777c80041d72c01e691cf751dbf86e85f509f3988e5875dc905119
        26841f00f0e29a6d1ddc1a842289d440268681e052b30fb638045f7779c
        1d873c784f054f688f5001559ecff64865ef975f3e60d2fd7966b8c7f92

     Futuristic-Acct-Record = <binary>
        fe19da5802acd98b07a5b86cb4d5d03f0314ab9ef1ad0b67111ff3b90a0
        57fe29620bf3585fd2dd9fcc38ce62f6cc208c6163c008f4258d1bc88b8
        17694a74ccad3ec69269461b14b2e7a4c111fb239e33714da207983f58c
        41d018d56fe938f3cbf089aac12a912a2f0d1923a9390e5f789cb2e5067
        d3427475e49968f841

   The data for the optional AVPs is represented in hex since the
   format of these AVPs is neither known at the time of definition of
   the Example-AVP group, nor (likely) at the time when the example
   instance of this AVP is interpreted - except by Diameter 
   implementations which support the same set of AVPs.  The encoding
   example illustrates how padding is used, how length fields are
   calculated and how AVPs do not have to begin on 8 byte boundaries.
   Also note that AVPs may be present in the Grouped AVP value which
   the receiver cannot interpret (here, the Recover-Policy and 
   Futuristic-Acct-Record AVPs).

   This AVP would be encoded as follows:

           0       1       2       3       4       5       6       7
       +-------+-------+-------+-------+-------+-------+-------+-------+
     0 |     Example AVP Header (AVP Code = 999999), Length = 468      |
       +-------+-------+-------+-------+-------+-------+-------+-------+
     8 |     Origin-Host AVP Header (AVP Code = 264), Length = 19      |
       +-------+-------+-------+-------+-------+-------+-------+-------+
    16 |  'e'  |  'x'  |  'a'  |  'm'  |  'p'  |  'l'  |  'e'  |  '.'  |
       +-------+-------+-------+-------+-------+-------+-------+-------+
    24 |  'c'  |  'o'  |  'm'  |Padding|     Session-Id AVP Header     |
       +-------+-------+-------+-------+-------+-------+-------+-------+
    32 | (AVP Code = 263), Length = 50 |  'g'  |  'r'  |  'u'  |  'm'  |
       +-------+-------+-------+-------+-------+-------+-------+-------+
                                     . . .
       +-------+-------+-------+-------+-------+-------+-------+-------+
    64 |  'A'  |  'F'  |  '3'  |  'B'  |  '8'  |  '1'  |Padding|Padding|
       +-------+-------+-------+-------+-------+-------+-------+-------+
    68 |     Session-Id AVP Header (AVP Code = 263), Length = 51       |
       +-------+-------+-------+-------+-------+-------+-------+-------+
    72 |  'g'  |  'r'  |  'u'  |  'm'  |  'p'  |  '.'  |  'e'  |  'x'  |
       +-------+-------+-------+-------+-------+-------+-------+-------+
                                     . . .
       +-------+-------+-------+-------+-------+-------+-------+-------+
   104 |  '0'  |  'A'  |  'F'  |  '3'  |  'B'  |  '8'  |  '2'  |Padding|
       +-------+-------+-------+-------+-------+-------+-------+-------+
   112 |   Recovery-Policy Header (AVP Code = 8341), Length = 223      |
       +-------+-------+-------+-------+-------+-------+-------+-------+
   120 |  0x21 | 0x63  | 0xbc  | 0x1d  | 0x0a  | 0xd8  | 0x23  | 0x71  |
       +-------+-------+-------+-------+-------+-------+-------+-------+
                                     . . .
       +-------+-------+-------+-------+-------+-------+-------+-------+
   320 |  0x2f | 0xd7  | 0x96  | 0x6b  | 0x8c  | 0x7f  | 0x92  |Padding|
       +-------+-------+-------+-------+-------+-------+-------+-------+
   328 | Futuristic-Acct-Record Header (AVP Code = 15930), Length = 137|
       +-------+-------+-------+-------+-------+-------+-------+-------+
   336 |  0xfe | 0x19  | 0xda  | 0x58  | 0x02  | 0xac  | 0xd9  | 0x8b  |
       +-------+-------+-------+-------+-------+-------+-------+-------+
                                     . . .
       +-------+-------+-------+-------+-------+-------+-------+-------+
   464 |  0x41 |Padding|Padding|Padding|
       +-------+-------+-------+-------+

---
Erik

---

From: Patrice Calhoun <[email-masked]>
Date: Thu, 31 May 2001 07:11:58 -0700 (PDT)

>    using ABNF [31] with Diameter extensions, as defined below.

How about:
    Every Grouped AVP defined MUST include a corresponding grammar,
    using ABNF [31], as defined below.

(not sure what "with Diameter extensions" meant)

PatC