1 /*********************************************************************************************************
2 * Software License Agreement (BSD License)                                                               *
3 * Author: Sebastien Decugis <sdecugis@freediameter.net>							 *
4 *													 *
5 * Copyright (c) 2020, WIDE Project and NICT								 *
6 * All rights reserved.											 *
7 * 													 *
8 * Redistribution and use of this software in source and binary forms, with or without modification, are  *
9 * permitted provided that the following conditions are met:						 *
10 * 													 *
11 * * Redistributions of source code must retain the above 						 *
12 *   copyright notice, this list of conditions and the 							 *
13 *   following disclaimer.										 *
14 *    													 *
15 * * Redistributions in binary form must reproduce the above 						 *
16 *   copyright notice, this list of conditions and the 							 *
17 *   following disclaimer in the documentation and/or other						 *
18 *   materials provided with the distribution.								 *
19 * 													 *
20 * * Neither the name of the WIDE Project or NICT nor the 						 *
21 *   names of its contributors may be used to endorse or 						 *
22 *   promote products derived from this software without 						 *
23 *   specific prior written permission of WIDE Project and 						 *
24 *   NICT.												 *
25 * 													 *
26 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED *
27 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
28 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR *
29 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 	 *
30 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 	 *
31 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR *
32 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF   *
33 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.								 *
34 *********************************************************************************************************/
35 
36 /* Diameter Base protocol definitions.
37  */
38 
39 #include "fdcore-internal.h"
40 
41 #include <netinet/in.h>
42 #include <sys/socket.h>
43 
44 /* The pointer for the global dictionary (initialized from main) */
45 struct dictionary * fd_g_dict = NULL;
46 
47 
48 
49 #define CHECK_dict_new( _type, _data, _parent, _ref )				\
50 	CHECK_FCT(  fd_dict_new( dict, (_type), (_data), (_parent), (_ref))  );
51 
52 #define CHECK_dict_search( _type, _criteria, _what, _result )					\
53 	CHECK_FCT(  fd_dict_search( dict, (_type), (_criteria), (_what), (_result), ENOENT)  );
54 
55 struct local_rules_definition {
56 	char 			*avp_name;
57 	enum rule_position	position;
58 	int 			min;
59 	int			max;
60 };
61 
62 #define RULE_ORDER( _position ) ((((_position) == RULE_FIXED_HEAD) || ((_position) == RULE_FIXED_TAIL)) ? 1 : 0 )
63 
64 #define PARSE_loc_rules( _rulearray, _parent) {						\
65 	int __ar;									\
66 	for (__ar=0; __ar < sizeof(_rulearray) / sizeof((_rulearray)[0]); __ar++) {	\
67 		struct dict_rule_data __data = { NULL, 					\
68 			(_rulearray)[__ar].position,					\
69 			0, 								\
70 			(_rulearray)[__ar].min,						\
71 			(_rulearray)[__ar].max};					\
72 		__data.rule_order = RULE_ORDER(__data.rule_position);			\
73 		CHECK_FCT(  fd_dict_search( 						\
74 			dict,								\
75 			DICT_AVP, 							\
76 			AVP_BY_NAME, 							\
77 			(_rulearray)[__ar].avp_name, 					\
78 			&__data.rule_avp, 0 ) );					\
79 		if ( !__data.rule_avp ) {						\
80 			TRACE_DEBUG(INFO, "AVP Not found: '%s'", (_rulearray)[__ar].avp_name );	\
81 			return ENOENT;							\
82 		}									\
83 		CHECK_FCT_DO( fd_dict_new( dict, DICT_RULE, &__data, _parent, NULL),	\
84 			{								\
85 				TRACE_DEBUG(INFO, "Error on rule with AVP '%s'",	\
86 					 (_rulearray)[__ar].avp_name );			\
87 				return EINVAL;						\
88 			} );								\
89 	}										\
90 }
91 
fd_dict_base_protocol(struct dictionary * dict)92 int fd_dict_base_protocol(struct dictionary * dict)
93 {
94 	TRACE_ENTRY("%p", dict);
95 	CHECK_PARAMS(dict);
96 
97 	/* Vendors section */
98 	{
99 		/* The base RFC has no vendor information */
100 		;
101 	}
102 
103 	/* Applications section */
104 	{
105 		/* base accounting application */
106 		{
107 			struct dict_application_data data = {          3, "Diameter Base Accounting" 	};
108 			CHECK_dict_new( DICT_APPLICATION, &data, NULL, NULL);
109 		}
110 
111 		/* relay application */
112 		{
113 			struct dict_application_data data  = { 0xffffffff, "Relay" 				};
114 			#if AI_RELAY != 0xffffffff
115 			#error "AI_RELAY definition mismatch"
116 			#endif
117 			CHECK_dict_new( DICT_APPLICATION, &data , NULL, NULL);
118 		}
119 	}
120 
121 	/* Derived AVP types section */
122 	{
123 		/* Address */
124 		{
125 			/*
126 				The Address format is derived from the OctetString AVP Base
127 				Format.  It is a discriminated union, representing, for example a
128 				32-bit (IPv4) [RFC791] or 128-bit (IPv6) [RFC4291] address, most
129 				significant octet first.  The first two octets of the Address AVP
130 				represents the AddressType, which contains an Address Family
131 				defined in [IANAADFAM].  The AddressType is used to discriminate
132 				the content and format of the remaining octets.
133 			*/
134 			struct dict_type_data data = { AVP_TYPE_OCTETSTRING,	"Address"		, fd_dictfct_Address_interpret	, fd_dictfct_Address_encode,	fd_dictfct_Address_dump	};
135 			CHECK_dict_new( DICT_TYPE, &data , NULL, NULL);
136 		}
137 
138 		/* Time */
139 		{
140 			/*
141 				The Time format is derived from the OctetString AVP Base Format.
142 				The string MUST contain four octets, in the same format as the
143 				first four bytes are in the NTP timestamp format.  The NTP
144 				Timestamp format is defined in chapter 3 of [RFC4330].
145 
146 				This represents the number of seconds since 0h on 1 January 1900
147 				with respect to the Coordinated Universal Time (UTC).
148 
149 				On 6h 28m 16s UTC, 7 February 2036 the time value will overflow.
150 				SNTP [RFC4330] describes a procedure to extend the time to 2104.
151 				This procedure MUST be supported by all DIAMETER nodes.
152 			*/
153 			struct dict_type_data data = { AVP_TYPE_OCTETSTRING,	"Time"			, fd_dictfct_Time_interpret	, fd_dictfct_Time_encode, 	fd_dictfct_Time_dump		};
154 			CHECK_dict_new( DICT_TYPE, &data , NULL, NULL);
155 		}
156 
157 		/* UTF8String */
158 		{
159 			/*
160 				The UTF8String format is derived from the OctetString AVP Base
161 				Format.  This is a human readable string represented using the
162 				ISO/IEC IS 10646-1 character set, encoded as an OctetString using
163 				the UTF-8 [RFC3629] transformation format described in RFC 3629.
164 
165 				Since additional code points are added by amendments to the 10646
166 				standard from time to time, implementations MUST be prepared to
167 				encounter any code point from 0x00000001 to 0x7fffffff.  Byte
168 				sequences that do not correspond to the valid encoding of a code
169 				point into UTF-8 charset or are outside this range are prohibited.
170 
171 				The use of control codes SHOULD be avoided.  When it is necessary
172 				to represent a new line, the control code sequence CR LF SHOULD be
173 				used.
174 
175 				The use of leading or trailing white space SHOULD be avoided.
176 
177 				For code points not directly supported by user interface hardware
178 				or software, an alternative means of entry and display, such as
179 				hexadecimal, MAY be provided.
180 
181 				For information encoded in 7-bit US-ASCII, the UTF-8 charset is
182 				identical to the US-ASCII charset.
183 
184 				UTF-8 may require multiple bytes to represent a single character /
185 				code point; thus the length of an UTF8String in octets may be
186 				different from the number of characters encoded.
187 
188 				Note that the AVP Length field of an UTF8String is measured in
189 				octets, not characters.
190 			*/
191 			struct dict_type_data data = { AVP_TYPE_OCTETSTRING,	"UTF8String"		, NULL			, NULL	, fd_dictfct_UTF8String_dump	};
192 			CHECK_dict_new( DICT_TYPE, &data , NULL, NULL);
193 		}
194 
195 		/* DiameterIdentity */
196 		{
197 			/*
198 				The DiameterIdentity format is derived from the OctetString AVP
199 				Base Format.
200 
201                 				DiameterIdentity  = FQDN
202 
203 
204 				DiameterIdentity value is used to uniquely identify a Diameter
205 				node for purposes of duplicate connection and routing loop
206 				detection.
207 
208 				The contents of the string MUST be the FQDN of the Diameter node.
209 				If multiple Diameter nodes run on the same host, each Diameter
210 				node MUST be assigned a unique DiameterIdentity.  If a Diameter
211 
212 				node can be identified by several FQDNs, a single FQDN should be
213 				picked at startup, and used as the only DiameterIdentity for that
214 				node, whatever the connection it is sent on.  Note that in this
215 				document, DiameterIdentity is in ASCII form in order to be
216 				compatible with existing DNS infrastructure.  See Appendix D for
217 				interactions between the Diameter protocol and Internationalized
218 				Domain Name (IDNs).
219 			*/
220 			struct dict_type_data data = { AVP_TYPE_OCTETSTRING,	"DiameterIdentity"	, NULL			, NULL		, fd_dictfct_UTF8String_dump	};
221 			CHECK_dict_new( DICT_TYPE, &data , NULL, NULL);
222 		}
223 
224 		/* DiameterURI */
225 		{
226 			/*
227 				The DiameterURI MUST follow the Uniform Resource Identifiers (URI)
228 				syntax [RFC3986] rules specified below:
229 
230 				 "aaa://" FQDN [ port ] [ transport ] [ protocol ]
231 
232                 				 ; No transport security
233 
234 				 "aaas://" FQDN [ port ] [ transport ] [ protocol ]
235 
236                 				 ; Transport security used
237 
238 				 FQDN               = Fully Qualified Host Name
239 
240 				 port               = ":" 1*DIGIT
241 
242                 				 ; One of the ports used to listen for
243                 				 ; incoming connections.
244                 				 ; If absent,
245                 				 ; the default Diameter port (3868) is
246                 				 ; assumed.
247 
248 				 transport          = ";transport=" transport-protocol
249 
250                 				 ; One of the transports used to listen
251                 				 ; for incoming connections.  If absent,
252                 				 ; the default SCTP [RFC2960] protocol is
253                 				 ; assumed. UDP MUST NOT be used when
254                 				 ; the aaa-protocol field is set to
255                 				 ; diameter.
256 
257 				transport-protocol = ( "tcp" / "sctp" / "udp" )
258 
259 				protocol           = ";protocol=" aaa-protocol
260 
261                 				 ; If absent, the default AAA protocol
262                 				 ; is diameter.
263 
264 				aaa-protocol       = ( "diameter" / "radius" / "tacacs+" )
265 
266 				The following are examples of valid Diameter host identities:
267 
268 				aaa://host.example.com;transport=tcp
269 				aaa://host.example.com:6666;transport=tcp
270 				aaa://host.example.com;protocol=diameter
271 				aaa://host.example.com:6666;protocol=diameter
272 				aaa://host.example.com:6666;transport=tcp;protocol=diameter
273 				aaa://host.example.com:1813;transport=udp;protocol=radius
274 			*/
275 			struct dict_type_data data = { AVP_TYPE_OCTETSTRING,	"DiameterURI"		, NULL			, NULL		, fd_dictfct_UTF8String_dump	};
276 			CHECK_dict_new( DICT_TYPE, &data , NULL, NULL);
277 		}
278 
279 		/* Enumerated */
280 		{
281 			/*
282 				Enumerated is derived from the Integer32 AVP Base Format.  The
283 				definition contains a list of valid values and their
284 				interpretation and is described in the Diameter application
285 				introducing the AVP.
286 			*/
287 
288 			/* We don't use a generic "Enumerated" type in freeDiameter. Instead, we define
289 			 * types of the form "Enumerated(<avpname>)" where <avpname> is replaced
290 			 * by the name of the AVP to which the type applies.
291 			 *  Example: Enumerated(Disconnect-Cause)
292 			 */
293 			;
294 		}
295 
296 		/* IPFilterRule */
297 		{
298 			/*
299 				The IPFilterRule format is derived from the OctetString AVP Base
300 				Format and uses the ASCII charset.  The rule syntax is a modified
301 				subset of ipfw(8) from FreeBSD.  Packets may be filtered based on
302 				the following information that is associated with it:
303 
304 				    Direction                          (in or out)
305 				    Source and destination IP address  (possibly masked)
306 				    Protocol
307 				    Source and destination port        (lists or ranges)
308 				    TCP flags
309 				    IP fragment flag
310 				    IP options
311 				    ICMP types
312 
313 				Rules for the appropriate direction are evaluated in order, with
314 				the first matched rule terminating the evaluation.  Each packet is
315 				evaluated once.  If no rule matches, the packet is dropped if the
316 				last rule evaluated was a permit, and passed if the last rule was
317 				a deny.
318 
319 				IPFilterRule filters MUST follow the format:
320 
321 				    action dir proto from src to dst [options]
322 
323 			(...skipped loooong explanation...)
324 
325 				There is one kind of packet that the access device MUST always
326 				discard, that is an IP fragment with a fragment offset of one.
327 				This is a valid packet, but it only has one use, to try to
328 				circumvent firewalls.
329 
330 				An access device that is unable to interpret or apply a deny rule
331 				MUST terminate the session.  An access device that is unable to
332 				interpret or apply a permit rule MAY apply a more restrictive
333 				rule.  An access device MAY apply deny rules of its own before the
334 				supplied rules, for example to protect the access device owner's
335 				infrastructure.
336 			*/
337 			struct dict_type_data data = { AVP_TYPE_OCTETSTRING,	"IPFilterRule"		, NULL			, NULL		, fd_dictfct_UTF8String_dump	};
338 			CHECK_dict_new( DICT_TYPE, &data , NULL, NULL);
339 		}
340 	}
341 
342 	/* AVP section */
343 	{
344 		struct dict_object * Address_type;
345 		struct dict_object * UTF8String_type;
346 		struct dict_object * DiameterIdentity_type;
347 		struct dict_object * DiameterURI_type;
348 		struct dict_object * Time_type;
349 
350 		CHECK_dict_search( DICT_TYPE, TYPE_BY_NAME, "Address", &Address_type);
351 		CHECK_dict_search( DICT_TYPE, TYPE_BY_NAME, "UTF8String", &UTF8String_type);
352 		CHECK_dict_search( DICT_TYPE, TYPE_BY_NAME, "DiameterIdentity", &DiameterIdentity_type);
353 		CHECK_dict_search( DICT_TYPE, TYPE_BY_NAME, "DiameterURI", &DiameterURI_type);
354 		CHECK_dict_search( DICT_TYPE, TYPE_BY_NAME, "Time", &Time_type);
355 
356 		/* Vendor-Id */
357 		{
358 			/*
359 				The Vendor-Id AVP (AVP Code 266) is of type Unsigned32 and contains
360 				the IANA "SMI Network Management Private Enterprise Codes" [RFC3232]
361 				value assigned to the vendor of the Diameter device.  It is
362 				envisioned that the combination of the Vendor-Id, Product-Name
363 				(Section 5.3.7) and the Firmware-Revision (Section 5.3.4) AVPs may
364 				provide useful debugging information.
365 
366 				A Vendor-Id value of zero in the CER or CEA messages is reserved and
367 				indicates that this field is ignored.
368 			*/
369 			struct dict_avp_data data = {
370 					266, 					/* Code */
371 					#if AC_VENDOR_ID != 266
372 					#error "AC_VENDOR_ID definition mismatch"
373 					#endif
374 					0, 					/* Vendor */
375 					"Vendor-Id", 				/* Name */
376 					AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, 	/* Fixed flags */
377 					AVP_FLAG_MANDATORY, 			/* Fixed flag values */
378 					AVP_TYPE_UNSIGNED32 			/* base type of data */
379 					};
380 			CHECK_dict_new( DICT_AVP, &data, NULL, NULL);
381 		}
382 
383 		/* Firmware-Revision */
384 		{
385 			/*
386 				The Firmware-Revision AVP (AVP Code 267) is of type Unsigned32 and is
387 				used to inform a Diameter peer of the firmware revision of the
388 				issuing device.
389 
390 				For devices that do not have a firmware revision (general purpose
391 				computers running Diameter software modules, for instance), the
392 				revision of the Diameter software module may be reported instead.
393 			*/
394 			struct dict_avp_data data = {
395 					267, 					/* Code */
396 					#if AC_FIRMWARE_REVISION != 267
397 					#error "AC_FIRMWARE_REVISION definition mismatch"
398 					#endif
399 					0, 					/* Vendor */
400 					"Firmware-Revision", 			/* Name */
401 					AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, 	/* Fixed flags */
402 					0,		 			/* Fixed flag values */
403 					AVP_TYPE_UNSIGNED32 			/* base type of data */
404 					};
405 			CHECK_dict_new( DICT_AVP, &data , NULL, NULL);
406 		}
407 
408 		/* Host-IP-Address */
409 		{
410 			/*
411 				The Host-IP-Address AVP (AVP Code 257) is of type Address and is used
412 				to inform a Diameter peer of the sender's IP address.  All source
413 				addresses that a Diameter node expects to use with SCTP [RFC2960]
414 				MUST be advertised in the CER and CEA messages by including a
415 				Host-IP- Address AVP for each address.  This AVP MUST ONLY be used in
416 				the CER and CEA messages.
417 			*/
418 			struct dict_avp_data data = {
419 					257, 					/* Code */
420 					#if AC_HOST_IP_ADDRESS != 257
421 					#error "AC_HOST_IP_ADDRESS definition mismatch"
422 					#endif
423 					0, 					/* Vendor */
424 					"Host-IP-Address", 			/* Name */
425 					AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, 	/* Fixed flags */
426 					AVP_FLAG_MANDATORY,			/* Fixed flag values */
427 					AVP_TYPE_OCTETSTRING 			/* base type of data */
428 					};
429 			CHECK_dict_new( DICT_AVP, &data , Address_type, NULL);
430 		}
431 
432 		/* Supported-Vendor-Id */
433 		{
434 			/*
435 				The Supported-Vendor-Id AVP (AVP Code 265) is of type Unsigned32 and
436 				contains the IANA "SMI Network Management Private Enterprise Codes"
437 				[RFC3232] value assigned to a vendor other than the device vendor but
438 				including the application vendor.  This is used in the CER and CEA
439 				messages in order to inform the peer that the sender supports (a
440 				subset of) the vendor-specific AVPs defined by the vendor identified
441 				in this AVP.  The value of this AVP SHOULD NOT be set to zero.
442 				Multiple instances of this AVP containing the same value SHOULD NOT
443 				be sent.
444 			*/
445 			struct dict_avp_data data = {
446 					265, 					/* Code */
447 					#if AC_SUPPORTED_VENDOR_ID != 265
448 					#error "AC_SUPPORTED_VENDOR_ID definition mismatch"
449 					#endif
450 					0, 					/* Vendor */
451 					"Supported-Vendor-Id", 			/* Name */
452 					AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, 	/* Fixed flags */
453 					AVP_FLAG_MANDATORY,			/* Fixed flag values */
454 					AVP_TYPE_UNSIGNED32 			/* base type of data */
455 					};
456 			CHECK_dict_new( DICT_AVP, &data , NULL, NULL);
457 		}
458 
459 		/* Product-Name */
460 		{
461 			/*
462 				The Product-Name AVP (AVP Code 269) is of type UTF8String, and
463 				contains the vendor assigned name for the product.  The Product-Name
464 				AVP SHOULD remain constant across firmware revisions for the same
465 				product.
466 			*/
467 			struct dict_avp_data data = {
468 					269, 					/* Code */
469 					#if AC_PRODUCT_NAME != 269
470 					#error "AC_PRODUCT_NAME definition mismatch"
471 					#endif
472 					0, 					/* Vendor */
473 					"Product-Name", 			/* Name */
474 					AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, 	/* Fixed flags */
475 					0,					/* Fixed flag values */
476 					AVP_TYPE_OCTETSTRING 			/* base type of data */
477 					};
478 			CHECK_dict_new( DICT_AVP, &data , UTF8String_type, NULL);
479 		}
480 
481 		/* Disconnect-Cause */
482 		{
483 			/*
484 				The Disconnect-Cause AVP (AVP Code 273) is of type Enumerated.  A
485 				Diameter node MUST include this AVP in the Disconnect-Peer-Request
486 				message to inform the peer of the reason for its intention to
487 				shutdown the transport connection.  The following values are
488 				supported:
489 
490 				REBOOTING                         0
491 				A scheduled reboot is imminent. Receiver of DPR with above result
492 				code MAY attempt reconnection.
493 
494 				BUSY                              1
495 				The peer's internal resources are constrained, and it has
496 				determined that the transport connection needs to be closed.
497 				Receiver of DPR with above result code SHOULD NOT attempt
498 				reconnection.
499 
500 				DO_NOT_WANT_TO_TALK_TO_YOU        2
501 				The peer has determined that it does not see a need for the
502 				transport connection to exist, since it does not expect any
503 				messages to be exchanged in the near future. Receiver of DPR
504 				with above result code SHOULD NOT attempt reconnection.
505 			*/
506 			struct dict_object 	* 	type;
507 			struct dict_type_data 		tdata = { AVP_TYPE_INTEGER32,	"Enumerated(Disconnect-Cause)"	, NULL, NULL, NULL };
508 			struct dict_enumval_data 	t_0 = { "REBOOTING", 			{ .i32 = 0 }};
509 			struct dict_enumval_data 	t_1 = { "BUSY", 			{ .i32 = 1 }};
510 			struct dict_enumval_data 	t_2 = { "DO_NOT_WANT_TO_TALK_TO_YOU", 	{ .i32 = 2 }};
511 			struct dict_avp_data 		data = {
512 					273, 					/* Code */
513 					#if AC_DISCONNECT_CAUSE != 273
514 					#error "AC_DISCONNECT_CAUSE definition mismatch"
515 					#endif
516 					0, 					/* Vendor */
517 					"Disconnect-Cause", 			/* Name */
518 					AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, 	/* Fixed flags */
519 					AVP_FLAG_MANDATORY,			/* Fixed flag values */
520 					AVP_TYPE_INTEGER32 			/* base type of data */
521 					};
522 			/* Create the Enumerated type, and then the AVP */
523 			CHECK_dict_new( DICT_TYPE, &tdata , NULL, &type);
524 			CHECK_dict_new( DICT_ENUMVAL, &t_0 , type, NULL);
525 			CHECK_dict_new( DICT_ENUMVAL, &t_1 , type, NULL);
526 			CHECK_dict_new( DICT_ENUMVAL, &t_2 , type, NULL);
527 			CHECK_dict_new( DICT_AVP, &data , type, NULL);
528 		}
529 
530 		/* Origin-Host */
531 		{
532 			/*
533 				The Origin-Host AVP (AVP Code 264) is of type DiameterIdentity, and
534 				MUST be present in all Diameter messages.  This AVP identifies the
535 				endpoint that originated the Diameter message.  Relay agents MUST NOT
536 				modify this AVP.
537 
538 				The value of the Origin-Host AVP is guaranteed to be unique within a
539 				single host.
540 
541 				Note that the Origin-Host AVP may resolve to more than one address as
542 				the Diameter peer may support more than one address.
543 
544 				This AVP SHOULD be placed as close to the Diameter header as
545 				possible.
546 			*/
547 			struct dict_avp_data data = {
548 					264, 					/* Code */
549 					#if AC_ORIGIN_HOST != 264
550 					#error "AC_ORIGIN_HOST definition mismatch"
551 					#endif
552 					0, 					/* Vendor */
553 					"Origin-Host", 				/* Name */
554 					AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, 	/* Fixed flags */
555 					AVP_FLAG_MANDATORY,			/* Fixed flag values */
556 					AVP_TYPE_OCTETSTRING 			/* base type of data */
557 					};
558 			CHECK_dict_new( DICT_AVP, &data , DiameterIdentity_type, NULL);
559 		}
560 
561 		/* Origin-Realm */
562 		{
563 			/*
564 				The Origin-Realm AVP (AVP Code 296) is of type DiameterIdentity.
565 				This AVP contains the Realm of the originator of any Diameter message
566 				and MUST be present in all messages.
567 
568 				This AVP SHOULD be placed as close to the Diameter header as
569 				possible.
570 			*/
571 			struct dict_avp_data data = {
572 					296, 					/* Code */
573 					#if AC_ORIGIN_REALM != 296
574 					#error "AC_ORIGIN_REALM definition mismatch"
575 					#endif
576 					0, 					/* Vendor */
577 					"Origin-Realm", 			/* Name */
578 					AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, 	/* Fixed flags */
579 					AVP_FLAG_MANDATORY,			/* Fixed flag values */
580 					AVP_TYPE_OCTETSTRING 			/* base type of data */
581 					};
582 			CHECK_dict_new( DICT_AVP, &data , DiameterIdentity_type, NULL);
583 		}
584 
585 		/* Destination-Host */
586 		{
587 			/*
588 				The Destination-Host AVP (AVP Code 293) is of type DiameterIdentity.
589 				This AVP MUST be present in all unsolicited agent initiated messages,
590 				MAY be present in request messages, and MUST NOT be present in Answer
591 				messages.
592 
593 				The absence of the Destination-Host AVP will cause a message to be
594 				sent to any Diameter server supporting the application within the
595 				realm specified in Destination-Realm AVP.
596 
597 				This AVP SHOULD be placed as close to the Diameter header as
598 				possible.
599 			*/
600 			struct dict_avp_data data = {
601 					293, 					/* Code */
602 					#if AC_DESTINATION_HOST != 293
603 					#error "AC_DESTINATION_HOST definition mismatch"
604 					#endif
605 					0, 					/* Vendor */
606 					"Destination-Host", 			/* Name */
607 					AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, 	/* Fixed flags */
608 					AVP_FLAG_MANDATORY,			/* Fixed flag values */
609 					AVP_TYPE_OCTETSTRING 			/* base type of data */
610 					};
611 			CHECK_dict_new( DICT_AVP, &data , DiameterIdentity_type, NULL);
612 		}
613 
614 		/* Destination-Realm */
615 		{
616 			/*
617 				The Destination-Realm AVP (AVP Code 283) is of type DiameterIdentity,
618 				and contains the realm the message is to be routed to.  The
619 				Destination-Realm AVP MUST NOT be present in Answer messages.
620 				Diameter Clients insert the realm portion of the User-Name AVP.
621 				Diameter servers initiating a request message use the value of the
622 				Origin-Realm AVP from a previous message received from the intended
623 				target host (unless it is known a priori).  When present, the
624 				Destination-Realm AVP is used to perform message routing decisions.
625 
626 				Request messages whose ABNF does not list the Destination-Realm AVP
627 				as a mandatory AVP are inherently non-routable messages.
628 
629 				This AVP SHOULD be placed as close to the Diameter header as
630 				possible.
631 			*/
632 			struct dict_avp_data data = {
633 					283, 					/* Code */
634 					#if AC_DESTINATION_REALM != 283
635 					#error "AC_DESTINATION_REALM definition mismatch"
636 					#endif
637 					0, 					/* Vendor */
638 					"Destination-Realm", 			/* Name */
639 					AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, 	/* Fixed flags */
640 					AVP_FLAG_MANDATORY,			/* Fixed flag values */
641 					AVP_TYPE_OCTETSTRING 			/* base type of data */
642 					};
643 			CHECK_dict_new( DICT_AVP, &data , DiameterIdentity_type, NULL);
644 		}
645 
646 		/* Route-Record */
647 		{
648 			/*
649 				The Route-Record AVP (AVP Code 282) is of type DiameterIdentity.  The
650 				identity added in this AVP MUST be the same as the one received in
651 				the Origin-Host of the Capabilities Exchange message.
652 			*/
653 			struct dict_avp_data data = {
654 					282, 					/* Code */
655 					#if AC_ROUTE_RECORD != 282
656 					#error "AC_ROUTE_RECORD definition mismatch"
657 					#endif
658 					0, 					/* Vendor */
659 					"Route-Record", 			/* Name */
660 					AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, 	/* Fixed flags */
661 					AVP_FLAG_MANDATORY,			/* Fixed flag values */
662 					AVP_TYPE_OCTETSTRING 			/* base type of data */
663 					};
664 			CHECK_dict_new( DICT_AVP, &data , DiameterIdentity_type, NULL);
665 		}
666 
667 		/* Proxy-Host */
668 		{
669 			/*
670 				The Proxy-Host AVP (AVP Code 280) is of type DiameterIdentity.  This
671 				AVP contains the identity of the host that added the Proxy-Info AVP.
672 			*/
673 			struct dict_avp_data adata = {
674 					280, 					/* Code */
675 					#if AC_PROXY_HOST != 280
676 					#error "AC_PROXY_HOST definition mismatch"
677 					#endif
678 					0, 					/* Vendor */
679 					"Proxy-Host", 				/* Name */
680 					AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, 	/* Fixed flags */
681 					AVP_FLAG_MANDATORY,			/* Fixed flag values */
682 					AVP_TYPE_OCTETSTRING 			/* base type of data */
683 					};
684 			CHECK_dict_new( DICT_AVP, &adata , DiameterIdentity_type, NULL);
685 		}
686 
687 		/* Proxy-State */
688 		{
689 			/*
690 				The Proxy-State AVP (AVP Code 33) is of type OctetString, and
691 				contains state local information, and MUST be treated as opaque data.
692 			*/
693 			struct dict_avp_data adata = {
694 					33, 					/* Code */
695 					#if AC_PROXY_STATE != 33
696 					#error "AC_PROXY_STATE definition mismatch"
697 					#endif
698 					0, 					/* Vendor */
699 					"Proxy-State", 				/* Name */
700 					AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, 	/* Fixed flags */
701 					AVP_FLAG_MANDATORY,			/* Fixed flag values */
702 					AVP_TYPE_OCTETSTRING 			/* base type of data */
703 					};
704 			CHECK_dict_new( DICT_AVP, &adata , NULL, NULL);
705 		}
706 
707 		/* Proxy-Info */
708 		{
709 			/*
710 				The Proxy-Info AVP (AVP Code 284) is of type Grouped.  The Grouped
711 				Data field has the following ABNF grammar:
712 
713 				 Proxy-Info ::= < AVP Header: 284 >
714                 				{ Proxy-Host }
715                 				{ Proxy-State }
716         				      * [ AVP ]
717 			*/
718 			struct dict_object * avp;
719 			struct dict_avp_data data = {
720 					284, 					/* Code */
721 					#if AC_PROXY_INFO != 284
722 					#error "AC_PROXY_INFO definition mismatch"
723 					#endif
724 					0, 					/* Vendor */
725 					"Proxy-Info", 				/* Name */
726 					AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, 	/* Fixed flags */
727 					AVP_FLAG_MANDATORY,			/* Fixed flag values */
728 					AVP_TYPE_GROUPED 			/* base type of data */
729 					};
730 			struct local_rules_definition rules[] =
731 						{ 	 {  "Proxy-Host", 			RULE_REQUIRED, -1, 1 }
732 							,{  "Proxy-State",			RULE_REQUIRED, -1, 1 }
733 						};
734 
735 			CHECK_dict_new( DICT_AVP, &data , NULL, &avp);
736 			PARSE_loc_rules( rules, avp );
737 		}
738 
739 		/* Auth-Application-Id */
740 		{
741 			/*
742 				The Auth-Application-Id AVP (AVP Code 258) is of type Unsigned32 and
743 				is used in order to advertise support of the Authentication and
744 				Authorization portion of an application (see Section 2.4).  If
745 				present in a message other than CER and CEA, the value of the Auth-
746 				Application-Id AVP MUST match the Application Id present in the
747 				Diameter message header.
748 			*/
749 			struct dict_avp_data data = {
750 					258, 					/* Code */
751 					#if AC_AUTH_APPLICATION_ID != 258
752 					#error "AC_AUTH_APPLICATION_ID definition mismatch"
753 					#endif
754 					0, 					/* Vendor */
755 					"Auth-Application-Id", 			/* Name */
756 					AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, 	/* Fixed flags */
757 					AVP_FLAG_MANDATORY,			/* Fixed flag values */
758 					AVP_TYPE_UNSIGNED32 			/* base type of data */
759 					};
760 			CHECK_dict_new( DICT_AVP, &data , NULL, NULL);
761 		}
762 
763 		/* Acct-Application-Id */
764 		{
765 			/*
766 				The Acct-Application-Id AVP (AVP Code 259) is of type Unsigned32 and
767 				is used in order to advertise support of the Accounting portion of an
768 				application (see Section 2.4).  If present in a message other than
769 				CER and CEA, the value of the Acct-Application-Id AVP MUST match the
770 				Application Id present in the Diameter message header.
771 			*/
772 			struct dict_avp_data data = {
773 					259, 					/* Code */
774 					#if AC_ACCT_APPLICATION_ID != 259
775 					#error "AC_ACCT_APPLICATION_ID definition mismatch"
776 					#endif
777 					0, 					/* Vendor */
778 					"Acct-Application-Id", 			/* Name */
779 					AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, 	/* Fixed flags */
780 					AVP_FLAG_MANDATORY,			/* Fixed flag values */
781 					AVP_TYPE_UNSIGNED32 			/* base type of data */
782 					};
783 			CHECK_dict_new( DICT_AVP, &data , NULL, NULL);
784 		}
785 
786 		/* Inband-Security-Id */
787 		{
788 			/*
789 				The Inband-Security-Id AVP (AVP Code 299) is of type Unsigned32 and
790 				is used in order to advertise support of the Security portion of the
791 				application.
792 
793 				Currently, the following values are supported, but there is ample
794 				room to add new security Ids.
795 
796 
797 				NO_INBAND_SECURITY 0
798 
799 				This peer does not support TLS.  This is the default value, if the
800 				AVP is omitted.
801 
802 				TLS 1
803 
804 				This node supports TLS security, as defined by [RFC4346].
805 			*/
806 
807 			/* Although the RFC does not specify an "Enumerated" type here, we go forward and create one.
808 			 * This is the reason for the "*" in the type name
809 			 */
810 
811 			struct dict_object 	* 	type;
812 			struct dict_type_data	 	tdata = { AVP_TYPE_UNSIGNED32,	"Enumerated(Inband-Security-Id)"	, NULL, NULL, NULL };
813 			struct dict_enumval_data 	t_0 = { "NO_INBAND_SECURITY", 		{ .u32 = ACV_ISI_NO_INBAND_SECURITY }};
814 			struct dict_enumval_data 	t_1 = { "TLS", 			{ .u32 = ACV_ISI_TLS }};
815 			struct dict_avp_data 		data = {
816 					299, 					/* Code */
817 					#if AC_INBAND_SECURITY_ID != 299
818 					#error "AC_INBAND_SECURITY_ID definition mismatch"
819 					#endif
820 					0, 					/* Vendor */
821 					"Inband-Security-Id", 			/* Name */
822 					AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, 	/* Fixed flags */
823 					AVP_FLAG_MANDATORY,			/* Fixed flag values */
824 					AVP_TYPE_UNSIGNED32 			/* base type of data */
825 					};
826 			/* Create the Enumerated type, and then the AVP */
827 			CHECK_dict_new( DICT_TYPE, &tdata , NULL, &type);
828 			CHECK_dict_new( DICT_ENUMVAL, &t_0 , type, NULL);
829 			CHECK_dict_new( DICT_ENUMVAL, &t_1 , type, NULL);
830 			CHECK_dict_new( DICT_AVP, &data , type, NULL);
831 		}
832 
833 		/* Vendor-Specific-Application-Id */
834 		{
835 			/*
836 				The Vendor-Specific-Application-Id AVP (AVP Code 260) is of type
837 				Grouped and is used to advertise support of a vendor-specific
838 				Diameter Application.  Exactly one instance of either Auth-
839 				Application-Id or Acct-Application-Id AVP MUST be present.  The
840 				Application Id carried by either Auth-Application-Id or Acct-
841 				Application-Id AVP MUST comply with vendor specific Application Id
842 				assignment described in Sec 11.3.  It MUST also match the Application
843 				Id present in the diameter header except when used in a CER or CEA
844 				messages.
845 
846 				The Vendor-Id AVP is an informational AVP pertaining to the vendor
847 				who may have authorship of the vendor-specific Diameter application.
848 				It MUST NOT be used as a means of defining a completely separate
849 				vendor-specific Application Id space.
850 
851 				This AVP MUST also be present as the first AVP in all experimental
852 				commands defined in the vendor-specific application.
853 
854 				This AVP SHOULD be placed as close to the Diameter header as
855 				possible.
856 
857 				AVP Format
858 
859 				<Vendor-Specific-Application-Id> ::= < AVP Header: 260 >
860                                 				   { Vendor-Id }
861                                 				   [ Auth-Application-Id ]
862                                 				   [ Acct-Application-Id ]
863 
864 				A Vendor-Specific-Application-Id AVP MUST contain exactly one of
865 				either Auth-Application-Id or Acct-Application-Id.  If a Vendor-
866 				Specific-Application-Id is received without any of these two AVPs,
867 				then the recipient SHOULD issue an answer with a Result-Code set to
868 				DIAMETER_MISSING_AVP.  The answer SHOULD also include a Failed-AVP
869 				which MUST contain an example of an Auth-Application-Id AVP and an
870 				Acct-Application-Id AVP.
871 
872 				If a Vendor-Specific-Application-Id is received that contains both
873 				Auth-Application-Id and Acct-Application-Id, then the recipient
874 				SHOULD issue an answer with Result-Code set to
875 				DIAMETER_AVP_OCCURS_TOO_MANY_TIMES.  The answer SHOULD also include a
876 				Failed-AVP which MUST contain the received Auth-Application-Id AVP
877 				and Acct-Application-Id AVP.
878 			*/
879 			struct dict_object 	* avp;
880 			struct dict_avp_data	  data = {
881 					260, 					/* Code */
882 					#if AC_VENDOR_SPECIFIC_APPLICATION_ID != 260
883 					#error "AC_VENDOR_SPECIFIC_APPLICATION_ID definition mismatch"
884 					#endif
885 					0, 					/* Vendor */
886 					"Vendor-Specific-Application-Id", 	/* Name */
887 					AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, 	/* Fixed flags */
888 					AVP_FLAG_MANDATORY,			/* Fixed flag values */
889 					AVP_TYPE_GROUPED 			/* base type of data */
890 					};
891 
892 			struct local_rules_definition rules[] =
893 						{
894 #ifndef WORKAROUND_ACCEPT_INVALID_VSAI
895 							/* ABNF from RFC6733 */
896 						 	 {  "Vendor-Id", 			RULE_REQUIRED, -1, 1 }
897 #else /* WORKAROUND_ACCEPT_INVALID_VSAI */
898 							/* ABNF from RFC3588 (including erratum, because original text is nonsense) */
899 						 	 {  "Vendor-Id", 			RULE_REQUIRED, -1, -1}
900 #endif /* WORKAROUND_ACCEPT_INVALID_VSAI */
901 							,{  "Auth-Application-Id",		RULE_OPTIONAL, -1, 1 }
902 							,{  "Acct-Application-Id",		RULE_OPTIONAL, -1, 1 }
903 						};
904 
905 			/* Create the grouped AVP */
906 			CHECK_dict_new( DICT_AVP, &data , NULL, &avp);
907 			PARSE_loc_rules( rules, avp );
908 
909 		}
910 
911 		/* Redirect-Host */
912 		{
913 			/*
914 				One or more of instances of this AVP MUST be present if the answer
915 				message's 'E' bit is set and the Result-Code AVP is set to
916 				DIAMETER_REDIRECT_INDICATION.
917 
918 				Upon receiving the above, the receiving Diameter node SHOULD forward
919 				the request directly to one of the hosts identified in these AVPs.
920 				The server contained in the selected Redirect-Host AVP SHOULD be used
921 				for all messages pertaining to this session.
922 			*/
923 			struct dict_avp_data data = {
924 					292, 					/* Code */
925 					#if AC_REDIRECT_HOST != 292
926 					#error "AC_REDIRECT_HOST definition mismatch"
927 					#endif
928 					0, 					/* Vendor */
929 					"Redirect-Host", 			/* Name */
930 					AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, 	/* Fixed flags */
931 					AVP_FLAG_MANDATORY,			/* Fixed flag values */
932 					AVP_TYPE_OCTETSTRING 			/* base type of data */
933 					};
934 			CHECK_dict_new( DICT_AVP, &data , DiameterURI_type, NULL);
935 		}
936 
937 		/* Redirect-Host-Usage */
938 		{
939 			/*
940 				The Redirect-Host-Usage AVP (AVP Code 261) is of type Enumerated.
941 				This AVP MAY be present in answer messages whose 'E' bit is set and
942 				the Result-Code AVP is set to DIAMETER_REDIRECT_INDICATION.
943 
944 				When present, this AVP dictates how the routing entry resulting from
945 				the Redirect-Host is to be used.  The following values are supported:
946 
947 
948 				DONT_CACHE 0
949 
950 				The host specified in the Redirect-Host AVP should not be cached.
951 				This is the default value.
952 
953 
954 				ALL_SESSION 1
955 
956 				All messages within the same session, as defined by the same value
957 				of the Session-ID AVP MAY be sent to the host specified in the
958 				Redirect-Host AVP.
959 
960 
961 				ALL_REALM 2
962 
963 				All messages destined for the realm requested MAY be sent to the
964 				host specified in the Redirect-Host AVP.
965 
966 
967 				REALM_AND_APPLICATION 3
968 
969 				All messages for the application requested to the realm specified
970 				MAY be sent to the host specified in the Redirect-Host AVP.
971 
972 				ALL_APPLICATION 4
973 
974 				All messages for the application requested MAY be sent to the host
975 				specified in the Redirect-Host AVP.
976 
977 
978 				ALL_HOST 5
979 
980 				All messages that would be sent to the host that generated the
981 				Redirect-Host MAY be sent to the host specified in the Redirect-
982 				Host AVP.
983 
984 
985 				ALL_USER 6
986 
987 				All messages for the user requested MAY be sent to the host
988 				specified in the Redirect-Host AVP.
989 
990 
991 				When multiple cached routes are created by redirect indications and
992 				they differ only in redirect usage and peers to forward requests to
993 				(see Section 6.1.8), a precedence rule MUST be applied to the
994 				redirect usage values of the cached routes during normal routing to
995 				resolve contentions that may occur.  The precedence rule is the order
996 				that dictate which redirect usage should be considered before any
997 				other as they appear.  The order is as follows:
998 
999 
1000 				1.  ALL_SESSION
1001 
1002 				2.  ALL_USER
1003 
1004 				3.  REALM_AND_APPLICATION
1005 
1006 				4.  ALL_REALM
1007 
1008 				5.  ALL_APPLICATION
1009 
1010 				6.  ALL_HOST
1011 			*/
1012 			struct dict_object 	* 	type;
1013 			struct dict_type_data	 	tdata = { AVP_TYPE_INTEGER32,	"Enumerated(Redirect-Host-Usage)"	, NULL, NULL, NULL };
1014 			struct dict_enumval_data 	t_0 = { "DONT_CACHE", 			{ .i32 = 0 }};
1015 			struct dict_enumval_data 	t_1 = { "ALL_SESSION", 			{ .i32 = 1 }};
1016 			struct dict_enumval_data 	t_2 = { "ALL_REALM", 			{ .i32 = 2 }};
1017 			struct dict_enumval_data 	t_3 = { "REALM_AND_APPLICATION", 	{ .i32 = 3 }};
1018 			struct dict_enumval_data 	t_4 = { "ALL_APPLICATION", 		{ .i32 = 4 }};
1019 			struct dict_enumval_data 	t_5 = { "ALL_HOST", 			{ .i32 = 5 }};
1020 			struct dict_enumval_data 	t_6 = { "ALL_USER", 			{ .i32 = 6 }};
1021 			struct dict_avp_data 		data = {
1022 					261, 					/* Code */
1023 					#if AC_REDIRECT_HOST_USAGE != 261
1024 					#error "AC_REDIRECT_HOST_USAGE definition mismatch"
1025 					#endif
1026 					0, 					/* Vendor */
1027 					"Redirect-Host-Usage", 			/* Name */
1028 					AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, 	/* Fixed flags */
1029 					AVP_FLAG_MANDATORY,			/* Fixed flag values */
1030 					AVP_TYPE_INTEGER32 			/* base type of data */
1031 					};
1032 			/* Create the Enumerated type, and then the AVP */
1033 			CHECK_dict_new( DICT_TYPE, &tdata , NULL, &type);
1034 			CHECK_dict_new( DICT_ENUMVAL, &t_0 , type, NULL);
1035 			CHECK_dict_new( DICT_ENUMVAL, &t_1 , type, NULL);
1036 			CHECK_dict_new( DICT_ENUMVAL, &t_2 , type, NULL);
1037 			CHECK_dict_new( DICT_ENUMVAL, &t_3 , type, NULL);
1038 			CHECK_dict_new( DICT_ENUMVAL, &t_4 , type, NULL);
1039 			CHECK_dict_new( DICT_ENUMVAL, &t_5 , type, NULL);
1040 			CHECK_dict_new( DICT_ENUMVAL, &t_6 , type, NULL);
1041 			CHECK_dict_new( DICT_AVP, &data , type, NULL);
1042 		}
1043 
1044 		/* Redirect-Max-Cache-Time */
1045 		{
1046 			/*
1047 				The Redirect-Max-Cache-Time AVP (AVP Code 262) is of type Unsigned32.
1048 				This AVP MUST be present in answer messages whose 'E' bit is set, the
1049 				Result-Code AVP is set to DIAMETER_REDIRECT_INDICATION and the
1050 				Redirect-Host-Usage AVP set to a non-zero value.
1051 
1052 				This AVP contains the maximum number of seconds the peer and route
1053 				table entries, created as a result of the Redirect-Host, will be
1054 				cached.  Note that once a host created due to a redirect indication
1055 				is no longer reachable, any associated peer and routing table entries
1056 				MUST be deleted.
1057 			*/
1058 			struct dict_avp_data data = {
1059 					262, 					/* Code */
1060 					#if AC_REDIRECT_MAX_CACHE_TIME != 262
1061 					#error "AC_REDIRECT_MAX_CACHE_TIME definition mismatch"
1062 					#endif
1063 					0, 					/* Vendor */
1064 					"Redirect-Max-Cache-Time", 		/* Name */
1065 					AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, 	/* Fixed flags */
1066 					AVP_FLAG_MANDATORY,			/* Fixed flag values */
1067 					AVP_TYPE_UNSIGNED32 			/* base type of data */
1068 					};
1069 			CHECK_dict_new( DICT_AVP, &data , NULL, NULL);
1070 		}
1071 
1072 		/* Result-Code */
1073 		{
1074 			/*
1075 				The Result-Code AVP (AVP Code 268) is of type Unsigned32 and
1076 				indicates whether a particular request was completed successfully or
1077 				whether an error occurred.  All Diameter answer messages defined in
1078 				IETF applications MUST include one Result-Code AVP.  A non-successful
1079 				Result-Code AVP (one containing a non 2xxx value other than
1080 				DIAMETER_REDIRECT_INDICATION) MUST include the Error-Reporting-Host
1081 				AVP if the host setting the Result-Code AVP is different from the
1082 				identity encoded in the Origin-Host AVP.
1083 
1084 				The Result-Code data field contains an IANA-managed 32-bit address
1085 				space representing errors (see Section 11.4).  Diameter provides the
1086 				following classes of errors, all identified by the thousands digit in
1087 				the decimal notation:
1088 
1089 				o  1xxx (Informational)
1090 
1091 				o  2xxx (Success)
1092 
1093 				o  3xxx (Protocol Errors)
1094 
1095 				o  4xxx (Transient Failures)
1096 
1097 				o  5xxx (Permanent Failure)
1098 
1099 				A non-recognized class (one whose first digit is not defined in this
1100 				section) MUST be handled as a permanent failure.
1101 			*/
1102 
1103 			/* Although the RFC does not specify an "Enumerated" type here, we go forward and create one.
1104 			 * This is the reason for the "*" in the type name
1105 			 */
1106 			struct dict_object * 	type;
1107 			struct dict_type_data 	tdata = { AVP_TYPE_UNSIGNED32,	"Enumerated(Result-Code)"	, NULL, NULL, NULL };
1108 			struct dict_avp_data 	data = {
1109 					268, 					/* Code */
1110 					#if AC_RESULT_CODE != 268
1111 					#error "AC_RESULT_CODE definition mismatch"
1112 					#endif
1113 					0, 					/* Vendor */
1114 					"Result-Code", 				/* Name */
1115 					AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, 	/* Fixed flags */
1116 					AVP_FLAG_MANDATORY,			/* Fixed flag values */
1117 					AVP_TYPE_UNSIGNED32 			/* base type of data */
1118 					};
1119 			/* Create the Enumerated type, and then the AVP */
1120 			CHECK_dict_new( DICT_TYPE, &tdata , NULL, &type);
1121 			CHECK_dict_new( DICT_AVP, &data , type, NULL);
1122 
1123 			/* Informational */
1124 			{
1125 				/* 1001 */
1126 				{
1127 					/*
1128 						This informational error is returned by a Diameter server to
1129 						inform the access device that the authentication mechanism being
1130 						used requires multiple round trips, and a subsequent request needs
1131 						to be issued in order for access to be granted.
1132 					*/
1133 					struct dict_enumval_data 	error_code = { "DIAMETER_MULTI_ROUND_AUTH", 	{ .u32 = ER_DIAMETER_MULTI_ROUND_AUTH }};
1134 					CHECK_dict_new( DICT_ENUMVAL, &error_code , type, NULL);
1135 				}
1136 			}
1137 			/* Success */
1138 			{
1139 				/* 2001 */
1140 				{
1141 					/*
1142 						The Request was successfully completed.
1143 					*/
1144 					struct dict_enumval_data 	error_code = { "DIAMETER_SUCCESS", 		{ .u32 = ER_DIAMETER_SUCCESS }};
1145 					#if ER_DIAMETER_SUCCESS != 2001
1146 					#error "ER_DIAMETER_SUCCESS definition mismatch"
1147 					#endif
1148 					CHECK_dict_new( DICT_ENUMVAL, &error_code , type, NULL);
1149 				}
1150 				/* 2002 */
1151 				{
1152 					/*
1153 						When returned, the request was successfully completed, but
1154 						additional processing is required by the application in order to
1155 						provide service to the user.
1156 					*/
1157 					struct dict_enumval_data 	error_code = { "DIAMETER_LIMITED_SUCCESS", 	{ .u32 = ER_DIAMETER_LIMITED_SUCCESS }};
1158 					CHECK_dict_new( DICT_ENUMVAL, &error_code , type, NULL);
1159 				}
1160 			}
1161 			/* Protocol Errors */
1162 			{
1163 				/* 3001 -- might be changed to 5xxx soon */
1164 				{
1165 					/*
1166 						The Request contained a Command-Code that the receiver did not
1167 						recognize or support.  This MUST be used when a Diameter node
1168 						receives an experimental command that it does not understand.
1169 					*/
1170 					struct dict_enumval_data 	error_code = { "DIAMETER_COMMAND_UNSUPPORTED", 	{ .u32 = ER_DIAMETER_COMMAND_UNSUPPORTED }};
1171 					CHECK_dict_new( DICT_ENUMVAL, &error_code , type, NULL);
1172 				}
1173 				/* 3002 */
1174 				{
1175 					/*
1176 						This error is given when Diameter can not deliver the message to
1177 						the destination, either because no host within the realm
1178 						supporting the required application was available to process the
1179 						request, or because Destination-Host AVP was given without the
1180 						associated Destination-Realm AVP.
1181 					*/
1182 					struct dict_enumval_data 	error_code = { "DIAMETER_UNABLE_TO_DELIVER", 	{ .u32 = ER_DIAMETER_UNABLE_TO_DELIVER }};
1183 					CHECK_dict_new( DICT_ENUMVAL, &error_code , type, NULL);
1184 				}
1185 				/* 3003 */
1186 				{
1187 					/*
1188 						The intended realm of the request is not recognized.
1189 					*/
1190 					struct dict_enumval_data 	error_code = { "DIAMETER_REALM_NOT_SERVED", 	{ .u32 = ER_DIAMETER_REALM_NOT_SERVED }};
1191 					CHECK_dict_new( DICT_ENUMVAL, &error_code , type, NULL);
1192 				}
1193 				/* 3004 */
1194 				{
1195 					/*
1196 						When returned, a Diameter node SHOULD attempt to send the message
1197 						to an alternate peer.  This error MUST only be used when a
1198 						specific server is requested, and it cannot provide the requested
1199 						service.
1200 					*/
1201 					struct dict_enumval_data 	error_code = { "DIAMETER_TOO_BUSY", 		{ .u32 = ER_DIAMETER_TOO_BUSY }};
1202 					CHECK_dict_new( DICT_ENUMVAL, &error_code , type, NULL);
1203 				}
1204 				/* 3005 */
1205 				{
1206 					/*
1207 						An agent detected a loop while trying to get the message to the
1208 						intended recipient.  The message MAY be sent to an alternate peer,
1209 						if one is available, but the peer reporting the error has
1210 						identified a configuration problem.
1211 					*/
1212 					struct dict_enumval_data 	error_code = { "DIAMETER_LOOP_DETECTED", 	{ .u32 = ER_DIAMETER_LOOP_DETECTED }};
1213 					CHECK_dict_new( DICT_ENUMVAL, &error_code , type, NULL);
1214 				}
1215 				/* 3006 */
1216 				{
1217 					/*
1218 						A redirect agent has determined that the request could not be
1219 						satisfied locally and the initiator of the request should direct
1220 						the request directly to the server, whose contact information has
1221 						been added to the response.  When set, the Redirect-Host AVP MUST
1222 						be present.
1223 					*/
1224 					struct dict_enumval_data 	error_code = { "DIAMETER_REDIRECT_INDICATION", 	{ .u32 = ER_DIAMETER_REDIRECT_INDICATION }};
1225 					CHECK_dict_new( DICT_ENUMVAL, &error_code , type, NULL);
1226 				}
1227 				/* 3007 */
1228 				{
1229 					/*
1230 						A request was sent for an application that is not supported.
1231 					*/
1232 					struct dict_enumval_data 	error_code = { "DIAMETER_APPLICATION_UNSUPPORTED",	{ .u32 = ER_DIAMETER_APPLICATION_UNSUPPORTED }};
1233 					CHECK_dict_new( DICT_ENUMVAL, &error_code , type, NULL);
1234 				}
1235 				/* 3008 -- will change to 5xxx soon */
1236 				{
1237 					/*
1238 						A request was received whose bits in the Diameter header were
1239 						either set to an invalid combination, or to a value that is
1240 						inconsistent with the command code's definition.
1241 					*/
1242 					struct dict_enumval_data 	error_code = { "DIAMETER_INVALID_HDR_BITS", 	{ .u32 = ER_DIAMETER_INVALID_HDR_BITS }};
1243 					CHECK_dict_new( DICT_ENUMVAL, &error_code , type, NULL);
1244 				}
1245 				/* 3009 -- will change to 5xxx soon */
1246 				{
1247 					/*
1248 						A request was received that included an AVP whose flag bits are
1249 						set to an unrecognized value, or that is inconsistent with the
1250 						AVP's definition.
1251 					*/
1252 					struct dict_enumval_data 	error_code = { "DIAMETER_INVALID_AVP_BITS", 	{ .u32 = ER_DIAMETER_INVALID_AVP_BITS }};
1253 					CHECK_dict_new( DICT_ENUMVAL, &error_code , type, NULL);
1254 				}
1255 				/* 3010  -- will change to 5xxx soon */
1256 				{
1257 					/*
1258 						 A CER was received from an unknown peer.
1259 					*/
1260 					struct dict_enumval_data 	error_code = { "DIAMETER_UNKNOWN_PEER", 	{ .u32 = ER_DIAMETER_UNKNOWN_PEER }};
1261 					CHECK_dict_new( DICT_ENUMVAL, &error_code , type, NULL);
1262 				}
1263 			}
1264 			/* Transient Failures */
1265 			{
1266 				/* 4001 */
1267 				{
1268 					/*
1269 						The authentication process for the user failed, most likely due to
1270 						an invalid password used by the user.  Further attempts MUST only
1271 						be tried after prompting the user for a new password.
1272 					*/
1273 					struct dict_enumval_data 	error_code = { "DIAMETER_AUTHENTICATION_REJECTED", 	{ .u32 = ER_DIAMETER_AUTHENTICATION_REJECTED }};
1274 					CHECK_dict_new( DICT_ENUMVAL, &error_code , type, NULL);
1275 				}
1276 				/* 4002 */
1277 				{
1278 					/*
1279 						A Diameter node received the accounting request but was unable to
1280 						commit it to stable storage due to a temporary lack of space.
1281 					*/
1282 					struct dict_enumval_data 	error_code = { "DIAMETER_OUT_OF_SPACE", 		{ .u32 = ER_DIAMETER_OUT_OF_SPACE }};
1283 					CHECK_dict_new( DICT_ENUMVAL, &error_code , type, NULL);
1284 				}
1285 				/* 4003 */
1286 				{
1287 					/*
1288 						The peer has determined that it has lost the election process and
1289 						has therefore disconnected the transport connection.
1290 					*/
1291 					struct dict_enumval_data 	error_code = { "ELECTION_LOST", 			{ .u32 = ER_ELECTION_LOST }};
1292 					CHECK_dict_new( DICT_ENUMVAL, &error_code , type, NULL);
1293 				}
1294 			}
1295 			/* Permanent Failures */
1296 			{
1297 				/* 5001 */
1298 				{
1299 					/*
1300 						The peer received a message that contained an AVP that is not
1301 						recognized or supported and was marked with the Mandatory bit.  A
1302 						Diameter message with this error MUST contain one or more Failed-
1303 						AVP AVP containing the AVPs that caused the failure.
1304 					*/
1305 					struct dict_enumval_data 	error_code = { "DIAMETER_AVP_UNSUPPORTED", 	{ .u32 = ER_DIAMETER_AVP_UNSUPPORTED }};
1306 					CHECK_dict_new( DICT_ENUMVAL, &error_code , type, NULL);
1307 				}
1308 				/* 5002 */
1309 				{
1310 					/*
1311 						The request contained an unknown Session-Id.
1312 					*/
1313 					struct dict_enumval_data 	error_code = { "DIAMETER_UNKNOWN_SESSION_ID", 	{ .u32 = ER_DIAMETER_UNKNOWN_SESSION_ID }};
1314 					CHECK_dict_new( DICT_ENUMVAL, &error_code , type, NULL);
1315 				}
1316 				/* 5003 */
1317 				{
1318 					/*
1319 						A request was received for which the user could not be authorized.
1320 						This error could occur if the service requested is not permitted
1321 						to the user.
1322 					*/
1323 					struct dict_enumval_data 	error_code = { "DIAMETER_AUTHORIZATION_REJECTED",{ .u32 = ER_DIAMETER_AUTHORIZATION_REJECTED }};
1324 					CHECK_dict_new( DICT_ENUMVAL, &error_code , type, NULL);
1325 				}
1326 				/* 5004 */
1327 				{
1328 					/*
1329 						The request contained an AVP with an invalid value in its data
1330 						portion.  A Diameter message indicating this error MUST include
1331 						the offending AVPs within a Failed-AVP AVP.
1332 					*/
1333 					struct dict_enumval_data 	error_code = { "DIAMETER_INVALID_AVP_VALUE",	{ .u32 = ER_DIAMETER_INVALID_AVP_VALUE }};
1334 					CHECK_dict_new( DICT_ENUMVAL, &error_code , type, NULL);
1335 				}
1336 				/* 5005 */
1337 				{
1338 					/*
1339 						The request did not contain an AVP that is required by the Command
1340 						Code definition.  If this value is sent in the Result-Code AVP, a
1341 						Failed-AVP AVP SHOULD be included in the message.  The Failed-AVP
1342 						AVP MUST contain an example of the missing AVP complete with the
1343 						Vendor-Id if applicable.  The value field of the missing AVP
1344 						should be of correct minimum length and contain zeroes.
1345 					*/
1346 					struct dict_enumval_data 	error_code = { "DIAMETER_MISSING_AVP",		{ .u32 = ER_DIAMETER_MISSING_AVP }};
1347 					CHECK_dict_new( DICT_ENUMVAL, &error_code , type, NULL);
1348 				}
1349 				/* 5006 */
1350 				{
1351 					/*
1352 						A request was received that cannot be authorized because the user
1353 						has already expended allowed resources.  An example of this error
1354 						condition is a user that is restricted to one dial-up PPP port,
1355 						attempts to establish a second PPP connection.
1356 					*/
1357 					struct dict_enumval_data 	error_code = { "DIAMETER_RESOURCES_EXCEEDED",	{ .u32 = ER_DIAMETER_RESOURCES_EXCEEDED }};
1358 					CHECK_dict_new( DICT_ENUMVAL, &error_code , type, NULL);
1359 				}
1360 				/* 5007 */
1361 				{
1362 					/*
1363 						The Home Diameter server has detected AVPs in the request that
1364 						contradicted each other, and is not willing to provide service to
1365 						the user.  The Failed-AVP AVPs MUST be present which contains the
1366 						AVPs that contradicted each other.
1367 					*/
1368 					struct dict_enumval_data 	error_code = { "DIAMETER_CONTRADICTING_AVPS",	{ .u32 = ER_DIAMETER_CONTRADICTING_AVPS }};
1369 					CHECK_dict_new( DICT_ENUMVAL, &error_code , type, NULL);
1370 				}
1371 				/* 5008 */
1372 				{
1373 					/*
1374 						A message was received with an AVP that MUST NOT be present.  The
1375 						Failed-AVP AVP MUST be included and contain a copy of the
1376 						offending AVP.
1377 					*/
1378 					struct dict_enumval_data 	error_code = { "DIAMETER_AVP_NOT_ALLOWED",	{ .u32 = ER_DIAMETER_AVP_NOT_ALLOWED }};
1379 					CHECK_dict_new( DICT_ENUMVAL, &error_code , type, NULL);
1380 				}
1381 				/* 5009 */
1382 				{
1383 					/*
1384 						A message was received that included an AVP that appeared more
1385 						often than permitted in the message definition.  The Failed-AVP
1386 						AVP MUST be included and contain a copy of the first instance of
1387 						the offending AVP that exceeded the maximum number of occurrences
1388 					*/
1389 					struct dict_enumval_data 	error_code = { "DIAMETER_AVP_OCCURS_TOO_MANY_TIMES",{ .u32 = ER_DIAMETER_AVP_OCCURS_TOO_MANY_TIMES }};
1390 					CHECK_dict_new( DICT_ENUMVAL, &error_code , type, NULL);
1391 				}
1392 				/* 5010 */
1393 				{
1394 					/*
1395 						This error is returned by a Diameter node that is not acting as a
1396 						relay when it receives a CER which advertises a set of
1397 						applications that it does not support.
1398 					*/
1399 					struct dict_enumval_data 	error_code = { "DIAMETER_NO_COMMON_APPLICATION",{ .u32 = ER_DIAMETER_NO_COMMON_APPLICATION }};
1400 					CHECK_dict_new( DICT_ENUMVAL, &error_code , type, NULL);
1401 				}
1402 				/* 5011 */
1403 				{
1404 					/*
1405 						This error is returned when a request was received, whose version
1406 						number is unsupported.
1407 					*/
1408 					struct dict_enumval_data 	error_code = { "DIAMETER_UNSUPPORTED_VERSION",	{ .u32 = ER_DIAMETER_UNSUPPORTED_VERSION }};
1409 					CHECK_dict_new( DICT_ENUMVAL, &error_code , type, NULL);
1410 				}
1411 				/* 5012 */
1412 				{
1413 					/*
1414 						This error is returned when a request is rejected for unspecified
1415 						reasons.
1416 					*/
1417 					struct dict_enumval_data 	error_code = { "DIAMETER_UNABLE_TO_COMPLY",	{ .u32 = ER_DIAMETER_UNABLE_TO_COMPLY }};
1418 					CHECK_dict_new( DICT_ENUMVAL, &error_code , type, NULL);
1419 				}
1420 				/* 5013 -- will change to 3xxx */
1421 				{
1422 					/*
1423 						This error is returned when an unrecognized bit in the Diameter
1424 						header is set to one (1).
1425 					*/
1426 					struct dict_enumval_data 	error_code = { "DIAMETER_INVALID_BIT_IN_HEADER", 	{ .u32 = ER_DIAMETER_INVALID_BIT_IN_HEADER }};
1427 					CHECK_dict_new( DICT_ENUMVAL, &error_code , type, NULL);
1428 				}
1429 				/* 5014 */
1430 				{
1431 					/*
1432 						The request contained an AVP with an invalid length.  A Diameter
1433 						message indicating this error MUST include the offending AVPs
1434 						within a Failed-AVP AVP.  In cases where the erroneous avp length
1435 						value exceeds the message length or is less than the minimum AVP
1436 						header length, it is sufficient to include the offending AVP
1437 						header and a zero filled payload of the minimum required length
1438 						for the payloads data type.  If the AVP is a grouped AVP, the
1439 						grouped AVP header with an empty payload would be sufficient to
1440 						indicate the offending AVP.  In the case where the offending AVP
1441 						header cannot be fully decoded when avp length is less than the
1442 						minimum AVP header length, it is sufficient to include an
1443 						offending AVP header that is formulated by padding the incomplete
1444 						AVP header with zero up to the minimum AVP header length.
1445 					*/
1446 					struct dict_enumval_data 	error_code = { "DIAMETER_INVALID_AVP_LENGTH",	{ .u32 = ER_DIAMETER_INVALID_AVP_LENGTH }};
1447 					CHECK_dict_new( DICT_ENUMVAL, &error_code , type, NULL);
1448 				}
1449 				/* 5015 -- will change to 3xxx */
1450 				{
1451 					/*
1452 						This error is returned when a request is received with an invalid
1453 						message length.
1454 					*/
1455 					struct dict_enumval_data 	error_code = { "DIAMETER_INVALID_MESSAGE_LENGTH", 	{ .u32 = ER_DIAMETER_INVALID_MESSAGE_LENGTH }};
1456 					CHECK_dict_new( DICT_ENUMVAL, &error_code , type, NULL);
1457 				}
1458 				/* 5016 */
1459 				{
1460 					/*
1461 						The request contained an AVP with which is not allowed to have the
1462 						given value in the AVP Flags field.  A Diameter message indicating
1463 						this error MUST include the offending AVPs within a Failed-AVP
1464 						AVP.
1465 					*/
1466 					struct dict_enumval_data 	error_code = { "DIAMETER_INVALID_AVP_BIT_COMBO", 	{ .u32 = ER_DIAMETER_INVALID_AVP_BIT_COMBO }};
1467 					CHECK_dict_new( DICT_ENUMVAL, &error_code , type, NULL);
1468 				}
1469 				/* 5017 */
1470 				{
1471 					/*
1472 						This error is returned when a CER message is received, and there
1473 						are no common security mechanisms supported between the peers.  A
1474 						Capabilities-Exchange-Answer (CEA) MUST be returned with the
1475 						Result-Code AVP set to DIAMETER_NO_COMMON_SECURITY.
1476 					*/
1477 					struct dict_enumval_data 	error_code = { "DIAMETER_NO_COMMON_SECURITY",	{ .u32 = ER_DIAMETER_NO_COMMON_SECURITY }};
1478 					CHECK_dict_new( DICT_ENUMVAL, &error_code , type, NULL);
1479 				}
1480 			}
1481 		}
1482 
1483 		/* Error-Message */
1484 		{
1485 			/*
1486 				The Error-Message AVP (AVP Code 281) is of type UTF8String.  It MAY
1487 				accompany a Result-Code AVP as a human readable error message.  The
1488 				Error-Message AVP is not intended to be useful in real-time, and
1489 				SHOULD NOT be expected to be parsed by network entities.
1490 			*/
1491 			struct dict_avp_data data = {
1492 					281, 					/* Code */
1493 					#if AC_ERROR_MESSAGE != 281
1494 					#error "AC_ERROR_MESSAGE definition mismatch"
1495 					#endif
1496 					0, 					/* Vendor */
1497 					"Error-Message", 			/* Name */
1498 					AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, 	/* Fixed flags */
1499 					0,					/* Fixed flag values */
1500 					AVP_TYPE_OCTETSTRING 			/* base type of data */
1501 					};
1502 			CHECK_dict_new( DICT_AVP, &data , UTF8String_type, NULL);
1503 		}
1504 
1505 		/* Error-Reporting-Host */
1506 		{
1507 			/*
1508 				The Error-Reporting-Host AVP (AVP Code 294) is of type
1509 				DiameterIdentity.  This AVP contains the identity of the Diameter
1510 				host that sent the Result-Code AVP to a value other than 2001
1511 				(Success), only if the host setting the Result-Code is different from
1512 				the one encoded in the Origin-Host AVP.  This AVP is intended to be
1513 				used for troubleshooting purposes, and MUST be set when the Result-
1514 				Code AVP indicates a failure.
1515 			*/
1516 			struct dict_avp_data data = {
1517 					294, 					/* Code */
1518 					#if AC_ERROR_REPORTING_HOST != 294
1519 					#error "AC_ERROR_REPORTING_HOST definition mismatch"
1520 					#endif
1521 					0, 					/* Vendor */
1522 					"Error-Reporting-Host", 		/* Name */
1523 					AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, 	/* Fixed flags */
1524 					0,					/* Fixed flag values */
1525 					AVP_TYPE_OCTETSTRING 			/* base type of data */
1526 					};
1527 			CHECK_dict_new( DICT_AVP, &data , DiameterIdentity_type, NULL);
1528 		}
1529 
1530 		/* Failed-AVP */
1531 		{
1532 			/*
1533 				The Failed-AVP AVP (AVP Code 279) is of type Grouped and provides
1534 				debugging information in cases where a request is rejected or not
1535 				fully processed due to erroneous information in a specific AVP.  The
1536 				value of the Result-Code AVP will provide information on the reason
1537 				for the Failed-AVP AVP.  A Diameter message SHOULD contain only one
1538 				Failed-AVP that corresponds to the error indicated by the Result-Code
1539 				AVP.  For practical purposes, this Failed-AVP would typically refer
1540 				to the first AVP processing error that a Diameter node encounters.
1541 
1542 				The possible reasons for this AVP are the presence of an improperly
1543 				constructed AVP, an unsupported or unrecognized AVP, an invalid AVP
1544 				value, the omission of a required AVP, the presence of an explicitly
1545 				excluded AVP (see tables in Section 10), or the presence of two or
1546 				more occurrences of an AVP which is restricted to 0, 1, or 0-1
1547 				occurrences.
1548 
1549 				A Diameter message SHOULD contain one Failed-AVP AVP, containing the
1550 				entire AVP that could not be processed successfully.  If the failure
1551 				reason is omission of a required AVP, an AVP with the missing AVP
1552 				code, the missing vendor id, and a zero filled payload of the minimum
1553 				required length for the omitted AVP will be added.  If the failure
1554 				reason is an invalid AVP length where the reported length is less
1555 				than the minimum AVP header length or greater than the reported
1556 				message length, a copy of the offending AVP header and a zero filled
1557 				payload of the minimum required length SHOULD be added.
1558 
1559 				In the case where the offending AVP is embedded within a grouped AVP,
1560 				the Failed-AVP MAY contain the grouped AVP which in turn contains the
1561 				single offending AVP.  The same method MAY be employed if the grouped
1562 				AVP itself is embedded in yet another grouped AVP and so on.  In this
1563 				case, the Failed-AVP MAY contain the grouped AVP heirarchy up to the
1564 				single offending AVP.  This enables the recipient to detect the
1565 				location of the offending AVP when embedded in a group.
1566 
1567 				AVP Format
1568 
1569 				 <Failed-AVP> ::= < AVP Header: 279 >
1570         				       1* {AVP}
1571 			*/
1572 			struct dict_avp_data data = {
1573 					279, 					/* Code */
1574 					#if AC_FAILED_AVP != 279
1575 					#error "AC_FAILED_AVP definition mismatch"
1576 					#endif
1577 					0, 					/* Vendor */
1578 					"Failed-AVP", 				/* Name */
1579 					AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, 	/* Fixed flags */
1580 					AVP_FLAG_MANDATORY,			/* Fixed flag values */
1581 					AVP_TYPE_GROUPED 			/* base type of data */
1582 					};
1583 			CHECK_dict_new( DICT_AVP, &data , NULL, NULL);
1584 		}
1585 
1586 		/* Experimental-Result-Code */
1587 		{
1588 			/*
1589 				The Experimental-Result-Code AVP (AVP Code 298) is of type Unsigned32
1590 				and contains a vendor-assigned value representing the result of
1591 				processing the request.
1592 
1593 				It is recommended that vendor-specific result codes follow the same
1594 				conventions given for the Result-Code AVP regarding the different
1595 				types of result codes and the handling of errors (for non 2xxx
1596 				values).
1597 			*/
1598 			/* Although the RFC does not specify an "Enumerated" type here, we go forward and create one.
1599 			 * This is the reason for the "*" in the type name. Vendors will have to define their values.
1600 			 */
1601 			struct dict_object *	type;
1602 			struct dict_type_data	tdata = { AVP_TYPE_UNSIGNED32,	"Enumerated(Experimental-Result-Code)"	, NULL, NULL, NULL };
1603 			struct dict_avp_data	data = {
1604 					298,					/* Code */
1605 					0,					/* Vendor */
1606 					"Experimental-Result-Code",		/* Name */
1607 					AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY,	/* Fixed flags */
1608 					AVP_FLAG_MANDATORY,			/* Fixed flag values */
1609 					AVP_TYPE_UNSIGNED32			/* base type of data */
1610 					};
1611 
1612 			CHECK_dict_new( DICT_TYPE, &tdata , NULL, &type);
1613 			CHECK_dict_new( DICT_AVP, &data , type, NULL);
1614 		}
1615 
1616 		/* Experimental-Result */
1617 		{
1618 			/*
1619 				The Experimental-Result AVP (AVP Code 297) is of type Grouped, and
1620 				indicates whether a particular vendor-specific request was completed
1621 				successfully or whether an error occurred.  Its Data field has the
1622 				following ABNF grammar:
1623 
1624 				AVP Format
1625 
1626 				 Experimental-Result ::= < AVP Header: 297 >
1627 							{ Vendor-Id }
1628 							{ Experimental-Result-Code }
1629 
1630 				The Vendor-Id AVP (see Section 5.3.3) in this grouped AVP identifies
1631 				the vendor responsible for the assignment of the result code which
1632 				follows.  All Diameter answer messages defined in vendor-specific
1633 				applications MUST include either one Result-Code AVP or one
1634 				Experimental-Result AVP.
1635 			*/
1636 			struct dict_object *	avp = NULL;
1637 			struct dict_avp_data	data = {
1638 					297,					/* Code */
1639 					0,					/* Vendor */
1640 					"Experimental-Result",			/* Name */
1641 					AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY,	/* Fixed flags */
1642 					AVP_FLAG_MANDATORY,			/* Fixed flag values */
1643 					AVP_TYPE_GROUPED			/* base type of data */
1644 					};
1645 			struct local_rules_definition rules[] = {
1646 				{ "Vendor-Id",			RULE_REQUIRED, -1, 1 },
1647 				{ "Experimental-Result-Code",	RULE_REQUIRED, -1, 1 },
1648 				};
1649 			CHECK_dict_new( DICT_AVP, &data , NULL, &avp);
1650 			PARSE_loc_rules( rules, avp );
1651 		}
1652 
1653 		/* Auth-Request-Type */
1654 		{
1655 			/*
1656 				The Auth-Request-Type AVP (AVP Code 274) is of type Enumerated and is
1657 				included in application-specific auth requests to inform the peers
1658 				whether a user is to be authenticated only, authorized only or both.
1659 				Note any value other than both MAY cause RADIUS interoperability
1660 				issues.  The following values are defined:
1661 
1662 
1663 				AUTHENTICATE_ONLY 1
1664 
1665 				The request being sent is for authentication only, and MUST
1666 				contain the relevant application specific authentication AVPs that
1667 				are needed by the Diameter server to authenticate the user.
1668 
1669 
1670 				AUTHORIZE_ONLY 2
1671 
1672 				The request being sent is for authorization only, and MUST contain
1673 				the application specific authorization AVPs that are necessary to
1674 				identify the service being requested/offered.
1675 
1676 
1677 				AUTHORIZE_AUTHENTICATE 3
1678 
1679 				The request contains a request for both authentication and
1680 				authorization.  The request MUST include both the relevant
1681 				application specific authentication information, and authorization
1682 				information necessary to identify the service being requested/
1683 				offered.
1684 			*/
1685 			struct dict_object 	* 	type;
1686 			struct dict_type_data 		tdata = { AVP_TYPE_INTEGER32,	"Enumerated(Auth-Request-Type)"	, NULL, NULL, NULL };
1687 			struct dict_enumval_data 	t_1 = { "AUTHENTICATE_ONLY", 		{ .i32 = 1 }};
1688 			struct dict_enumval_data 	t_2 = { "AUTHORIZE_ONLY", 		{ .i32 = 2 }};
1689 			struct dict_enumval_data 	t_3 = { "AUTHORIZE_AUTHENTICATE", 	{ .i32 = 3 }};
1690 			struct dict_avp_data 	data = {
1691 					274, 					/* Code */
1692 					0, 					/* Vendor */
1693 					"Auth-Request-Type", 			/* Name */
1694 					AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, 	/* Fixed flags */
1695 					AVP_FLAG_MANDATORY,			/* Fixed flag values */
1696 					AVP_TYPE_INTEGER32 			/* base type of data */
1697 					};
1698 			/* Create the Enumerated type, and then the AVP */
1699 			CHECK_dict_new( DICT_TYPE, &tdata , NULL, &type);
1700 			CHECK_dict_new( DICT_ENUMVAL, &t_1 , type, NULL);
1701 			CHECK_dict_new( DICT_ENUMVAL, &t_2 , type, NULL);
1702 			CHECK_dict_new( DICT_ENUMVAL, &t_3 , type, NULL);
1703 			CHECK_dict_new( DICT_AVP, &data , type, NULL);
1704 		}
1705 
1706 		/* Session-Id */
1707 		{
1708 			/*
1709 				The Session-Id AVP (AVP Code 263) is of type UTF8String and is used
1710 				to identify a specific session (see Section 8).  All messages
1711 				pertaining to a specific session MUST include only one Session-Id AVP
1712 				and the same value MUST be used throughout the life of a session.
1713 				When present, the Session-Id SHOULD appear immediately following the
1714 				Diameter Header (see Section 3).
1715 
1716 				The Session-Id MUST be globally and eternally unique, as it is meant
1717 				to uniquely identify a user session without reference to any other
1718 				information, and may be needed to correlate historical authentication
1719 				information with accounting information.  The Session-Id includes a
1720 				mandatory portion and an implementation-defined portion; a
1721 				recommended format for the implementation-defined portion is outlined
1722 				below.
1723 
1724 				(skipped, see RFC for detail)
1725 			*/
1726 			struct dict_avp_data data = {
1727 					263, 					/* Code */
1728 					#if AC_SESSION_ID != 263
1729 					#error "AC_SESSION_ID definition mismatch"
1730 					#endif
1731 					0, 					/* Vendor */
1732 					"Session-Id", 				/* Name */
1733 					AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, 	/* Fixed flags */
1734 					AVP_FLAG_MANDATORY,			/* Fixed flag values */
1735 					AVP_TYPE_OCTETSTRING 			/* base type of data */
1736 					};
1737 			CHECK_dict_new( DICT_AVP, &data , UTF8String_type, NULL);
1738 		}
1739 
1740 		/* Authorization-Lifetime */
1741 		{
1742 			/*
1743 				The Authorization-Lifetime AVP (AVP Code 291) is of type Unsigned32
1744 				and contains the maximum number of seconds of service to be provided
1745 				to the user before the user is to be re-authenticated and/or re-
1746 				authorized.  Great care should be taken when the Authorization-
1747 				Lifetime value is determined, since a low, non-zero, value could
1748 				create significant Diameter traffic, which could congest both the
1749 				network and the agents.
1750 
1751 				A value of zero (0) means that immediate re-auth is necessary by the
1752 				access device.  This is typically used in cases where multiple
1753 				authentication methods are used, and a successful auth response with
1754 				this AVP set to zero is used to signal that the next authentication
1755 				method is to be immediately initiated.  The absence of this AVP, or a
1756 				value of all ones (meaning all bits in the 32 bit field are set to
1757 				one) means no re-auth is expected.
1758 
1759 				If both this AVP and the Session-Timeout AVP are present in a
1760 				message, the value of the latter MUST NOT be smaller than the
1761 				Authorization-Lifetime AVP.
1762 
1763 				An Authorization-Lifetime AVP MAY be present in re-authorization
1764 				messages, and contains the number of seconds the user is authorized
1765 				to receive service from the time the re-auth answer message is
1766 				received by the access device.
1767 
1768 				This AVP MAY be provided by the client as a hint of the maximum
1769 				lifetime that it is willing to accept.  However, the server MAY
1770 				return a value that is equal to, or smaller, than the one provided by
1771 				the client.
1772 			*/
1773 			struct dict_avp_data data = {
1774 					291, 					/* Code */
1775 					0, 					/* Vendor */
1776 					"Authorization-Lifetime", 		/* Name */
1777 					AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, 	/* Fixed flags */
1778 					AVP_FLAG_MANDATORY,			/* Fixed flag values */
1779 					AVP_TYPE_UNSIGNED32 			/* base type of data */
1780 					};
1781 			CHECK_dict_new( DICT_AVP, &data , NULL, NULL);
1782 		}
1783 
1784 		/* Auth-Grace-Period */
1785 		{
1786 			/*
1787 				The Auth-Grace-Period AVP (AVP Code 276) is of type Unsigned32 and
1788 				contains the number of seconds the Diameter server will wait
1789 				following the expiration of the Authorization-Lifetime AVP before
1790 				cleaning up resources for the session.
1791 			*/
1792 			struct dict_avp_data data = {
1793 					276, 					/* Code */
1794 					0, 					/* Vendor */
1795 					"Auth-Grace-Period", 			/* Name */
1796 					AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, 	/* Fixed flags */
1797 					AVP_FLAG_MANDATORY,			/* Fixed flag values */
1798 					AVP_TYPE_UNSIGNED32 			/* base type of data */
1799 					};
1800 			CHECK_dict_new( DICT_AVP, &data , NULL, NULL);
1801 		}
1802 
1803 		/* Auth-Session-State */
1804 		{
1805 			/*
1806 				The Auth-Session-State AVP (AVP Code 277) is of type Enumerated and
1807 				specifies whether state is maintained for a particular session.  The
1808 				client MAY include this AVP in requests as a hint to the server, but
1809 				the value in the server's answer message is binding.  The following
1810 				values are supported:
1811 
1812 
1813 				STATE_MAINTAINED 0
1814 
1815 				This value is used to specify that session state is being
1816 				maintained, and the access device MUST issue a session termination
1817 				message when service to the user is terminated.  This is the
1818 				default value.
1819 
1820 
1821 				NO_STATE_MAINTAINED 1
1822 
1823 				This value is used to specify that no session termination messages
1824 				will be sent by the access device upon expiration of the
1825 				Authorization-Lifetime.
1826 			*/
1827 			struct dict_object 	* 	type;
1828 			struct dict_type_data	 	tdata = { AVP_TYPE_INTEGER32,	"Enumerated(Auth-Session-State)"	, NULL, NULL, NULL };
1829 			struct dict_enumval_data 	t_0 = { "STATE_MAINTAINED", 		{ .i32 = 0 }};
1830 			struct dict_enumval_data 	t_1 = { "NO_STATE_MAINTAINED", 		{ .i32 = 1 }};
1831 			struct dict_avp_data	 	data = {
1832 					277, 					/* Code */
1833 					0, 					/* Vendor */
1834 					"Auth-Session-State", 			/* Name */
1835 					AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, 	/* Fixed flags */
1836 					AVP_FLAG_MANDATORY,			/* Fixed flag values */
1837 					AVP_TYPE_INTEGER32 			/* base type of data */
1838 					};
1839 			/* Create the Enumerated type, and then the AVP */
1840 			CHECK_dict_new( DICT_TYPE, &tdata , NULL, &type);
1841 			CHECK_dict_new( DICT_ENUMVAL, &t_0 , type, NULL);
1842 			CHECK_dict_new( DICT_ENUMVAL, &t_1 , type, NULL);
1843 			CHECK_dict_new( DICT_AVP, &data , type, NULL);
1844 		}
1845 
1846 		/* Re-Auth-Request-Type */
1847 		{
1848 			/*
1849 				The Re-Auth-Request-Type AVP (AVP Code 285) is of type Enumerated and
1850 				is included in application-specific auth answers to inform the client
1851 				of the action expected upon expiration of the Authorization-Lifetime.
1852 				If the answer message contains an Authorization-Lifetime AVP with a
1853 				positive value, the Re-Auth-Request-Type AVP MUST be present in an
1854 				answer message.  The following values are defined:
1855 
1856 
1857 				AUTHORIZE_ONLY 0
1858 
1859 				An authorization only re-auth is expected upon expiration of the
1860 				Authorization-Lifetime.  This is the default value if the AVP is
1861 				not present in answer messages that include the Authorization-
1862 				Lifetime.
1863 
1864 
1865 				AUTHORIZE_AUTHENTICATE 1
1866 
1867 				An authentication and authorization re-auth is expected upon
1868 				expiration of the Authorization-Lifetime.
1869 			*/
1870 			struct dict_object 	* 	type;
1871 			struct dict_type_data	 	tdata = { AVP_TYPE_INTEGER32,	"Enumerated(Re-Auth-Request-Type)"	, NULL, NULL, NULL };
1872 			struct dict_enumval_data 	t_0 = { "AUTHORIZE_ONLY", 		{ .i32 = 0 }};
1873 			struct dict_enumval_data 	t_1 = { "AUTHORIZE_AUTHENTICATE",	{ .i32 = 1 }};
1874 			struct dict_avp_data	 	data = {
1875 					285, 					/* Code */
1876 					0, 					/* Vendor */
1877 					"Re-Auth-Request-Type",			/* Name */
1878 					AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, 	/* Fixed flags */
1879 					AVP_FLAG_MANDATORY,			/* Fixed flag values */
1880 					AVP_TYPE_INTEGER32 			/* base type of data */
1881 					};
1882 			/* Create the Enumerated type, and then the AVP */
1883 			CHECK_dict_new( DICT_TYPE, &tdata , NULL, &type);
1884 			CHECK_dict_new( DICT_ENUMVAL, &t_0 , type, NULL);
1885 			CHECK_dict_new( DICT_ENUMVAL, &t_1 , type, NULL);
1886 			CHECK_dict_new( DICT_AVP, &data , type, NULL);
1887 		}
1888 
1889 		/* Session-Timeout */
1890 		{
1891 			/*
1892 				The Session-Timeout AVP (AVP Code 27) [RFC2865] is of type Unsigned32
1893 				and contains the maximum number of seconds of service to be provided
1894 				to the user before termination of the session.  When both the
1895 				Session-Timeout and the Authorization-Lifetime AVPs are present in an
1896 				answer message, the former MUST be equal to or greater than the value
1897 				of the latter.
1898 
1899 				A session that terminates on an access device due to the expiration
1900 				of the Session-Timeout MUST cause an STR to be issued, unless both
1901 				the access device and the home server had previously agreed that no
1902 				session termination messages would be sent (see Section 8.11).
1903 
1904 				A Session-Timeout AVP MAY be present in a re-authorization answer
1905 				message, and contains the remaining number of seconds from the
1906 				beginning of the re-auth.
1907 
1908 				A value of zero, or the absence of this AVP, means that this session
1909 				has an unlimited number of seconds before termination.
1910 
1911 				This AVP MAY be provided by the client as a hint of the maximum
1912 				timeout that it is willing to accept.  However, the server MAY return
1913 				a value that is equal to, or smaller, than the one provided by the
1914 				client.
1915 			*/
1916 			struct dict_avp_data data = {
1917 					27, 					/* Code */
1918 					0, 					/* Vendor */
1919 					"Session-Timeout", 			/* Name */
1920 					AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, 	/* Fixed flags */
1921 					AVP_FLAG_MANDATORY,			/* Fixed flag values */
1922 					AVP_TYPE_UNSIGNED32 			/* base type of data */
1923 					};
1924 			CHECK_dict_new( DICT_AVP, &data , NULL, NULL);
1925 		}
1926 
1927 		/* User-Name */
1928 		{
1929 			/*
1930 				The User-Name AVP (AVP Code 1) [RFC2865] is of type UTF8String, which
1931 				contains the User-Name, in a format consistent with the NAI
1932 				specification [RFC4282].
1933 			*/
1934 			struct dict_avp_data data = {
1935 					1, 					/* Code */
1936 					0, 					/* Vendor */
1937 					"User-Name", 				/* Name */
1938 					AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, 	/* Fixed flags */
1939 					AVP_FLAG_MANDATORY,			/* Fixed flag values */
1940 					AVP_TYPE_OCTETSTRING 			/* base type of data */
1941 					};
1942 			CHECK_dict_new( DICT_AVP, &data , UTF8String_type, NULL);
1943 		}
1944 
1945 		/* Termination-Cause */
1946 		{
1947 			/*
1948 				The Termination-Cause AVP (AVP Code 295) is of type Enumerated, and
1949 				is used to indicate the reason why a session was terminated on the
1950 				access device.  The following values are defined:
1951 
1952 
1953 				DIAMETER_LOGOUT 1
1954 
1955 				The user initiated a disconnect
1956 
1957 
1958 				DIAMETER_SERVICE_NOT_PROVIDED 2
1959 
1960 				This value is used when the user disconnected prior to the receipt
1961 				of the authorization answer message.
1962 
1963 
1964 				DIAMETER_BAD_ANSWER 3
1965 
1966 				This value indicates that the authorization answer received by the
1967 				access device was not processed successfully.
1968 
1969 
1970 				DIAMETER_ADMINISTRATIVE 4
1971 
1972 				The user was not granted access, or was disconnected, due to
1973 				administrative reasons, such as the receipt of a Abort-Session-
1974 				Request message.
1975 
1976 
1977 				DIAMETER_LINK_BROKEN 5
1978 
1979 				The communication to the user was abruptly disconnected.
1980 
1981 
1982 				DIAMETER_AUTH_EXPIRED 6
1983 
1984 				The user's access was terminated since its authorized session time
1985 				has expired.
1986 
1987 
1988 				DIAMETER_USER_MOVED 7
1989 
1990 				The user is receiving services from another access device.
1991 
1992 
1993 				DIAMETER_SESSION_TIMEOUT 8
1994 
1995 				The user's session has timed out, and service has been terminated.
1996 			*/
1997 			struct dict_object 	* 	type;
1998 			struct dict_type_data	 	tdata = { AVP_TYPE_INTEGER32,	"Enumerated(Termination-Cause)"	, NULL, NULL, NULL };
1999 			struct dict_enumval_data 	t_1 = { "DIAMETER_LOGOUT",			{ .i32 = 1 }};
2000 			struct dict_enumval_data 	t_2 = { "DIAMETER_SERVICE_NOT_PROVIDED", 	{ .i32 = 2 }};
2001 			struct dict_enumval_data 	t_3 = { "DIAMETER_BAD_ANSWER",			{ .i32 = 3 }};
2002 			struct dict_enumval_data 	t_4 = { "DIAMETER_ADMINISTRATIVE", 		{ .i32 = 4 }};
2003 			struct dict_enumval_data 	t_5 = { "DIAMETER_LINK_BROKEN",			{ .i32 = 5 }};
2004 			struct dict_enumval_data 	t_6 = { "DIAMETER_AUTH_EXPIRED", 		{ .i32 = 6 }};
2005 			struct dict_enumval_data 	t_7 = { "DIAMETER_USER_MOVED",			{ .i32 = 7 }};
2006 			struct dict_enumval_data 	t_8 = { "DIAMETER_SESSION_TIMEOUT", 		{ .i32 = 8 }};
2007 			struct dict_avp_data 	data = {
2008 					295, 					/* Code */
2009 					0, 					/* Vendor */
2010 					"Termination-Cause",			/* Name */
2011 					AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, 	/* Fixed flags */
2012 					AVP_FLAG_MANDATORY,			/* Fixed flag values */
2013 					AVP_TYPE_INTEGER32 			/* base type of data */
2014 					};
2015 			/* Create the Enumerated type, and then the AVP */
2016 			CHECK_dict_new( DICT_TYPE, &tdata , NULL, &type);
2017 			CHECK_dict_new( DICT_ENUMVAL, &t_1 , type, NULL);
2018 			CHECK_dict_new( DICT_ENUMVAL, &t_2 , type, NULL);
2019 			CHECK_dict_new( DICT_ENUMVAL, &t_3 , type, NULL);
2020 			CHECK_dict_new( DICT_ENUMVAL, &t_4 , type, NULL);
2021 			CHECK_dict_new( DICT_ENUMVAL, &t_5 , type, NULL);
2022 			CHECK_dict_new( DICT_ENUMVAL, &t_6 , type, NULL);
2023 			CHECK_dict_new( DICT_ENUMVAL, &t_7 , type, NULL);
2024 			CHECK_dict_new( DICT_ENUMVAL, &t_8 , type, NULL);
2025 			CHECK_dict_new( DICT_AVP, &data , type, NULL);
2026 		}
2027 
2028 		/* Origin-State-Id */
2029 		{
2030 			/*
2031 				The Origin-State-Id AVP (AVP Code 278), of type Unsigned32, is a
2032 				monotonically increasing value that is advanced whenever a Diameter
2033 				entity restarts with loss of previous state, for example upon reboot.
2034 				Origin-State-Id MAY be included in any Diameter message, including
2035 				CER.
2036 
2037 				A Diameter entity issuing this AVP MUST create a higher value for
2038 				this AVP each time its state is reset.  A Diameter entity MAY set
2039 				Origin-State-Id to the time of startup, or it MAY use an incrementing
2040 				counter retained in non-volatile memory across restarts.
2041 
2042 				The Origin-State-Id, if present, MUST reflect the state of the entity
2043 				indicated by Origin-Host.  If a proxy modifies Origin-Host, it MUST
2044 				either remove Origin-State-Id or modify it appropriately as well.
2045 				Typically, Origin-State-Id is used by an access device that always
2046 				starts up with no active sessions; that is, any session active prior
2047 				to restart will have been lost.  By including Origin-State-Id in a
2048 				message, it allows other Diameter entities to infer that sessions
2049 				associated with a lower Origin-State-Id are no longer active.  If an
2050 				access device does not intend for such inferences to be made, it MUST
2051 				either not include Origin-State-Id in any message, or set its value
2052 				to 0.
2053 			*/
2054 			struct dict_avp_data data = {
2055 					278, 					/* Code */
2056 					0, 					/* Vendor */
2057 					"Origin-State-Id", 			/* Name */
2058 					AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, 	/* Fixed flags */
2059 					AVP_FLAG_MANDATORY,			/* Fixed flag values */
2060 					AVP_TYPE_UNSIGNED32 			/* base type of data */
2061 					};
2062 			CHECK_dict_new( DICT_AVP, &data , NULL, NULL);
2063 		}
2064 
2065 		/* Session-Binding */
2066 		{
2067 			/*
2068 				The Session-Binding AVP (AVP Code 270) is of type Unsigned32, and MAY
2069 				be present in application-specific authorization answer messages.  If
2070 				present, this AVP MAY inform the Diameter client that all future
2071 				application-specific re-auth messages for this session MUST be sent
2072 				to the same authorization server.  This AVP MAY also specify that a
2073 				Session-Termination-Request message for this session MUST be sent to
2074 				the same authorizing server.
2075 
2076 				This field is a bit mask, and the following bits have been defined:
2077 
2078 
2079 				RE_AUTH 1
2080 
2081 				When set, future re-auth messages for this session MUST NOT
2082 				include the Destination-Host AVP.  When cleared, the default
2083 				value, the Destination-Host AVP MUST be present in all re-auth
2084 				messages for this session.
2085 
2086 
2087 				STR 2
2088 
2089 				When set, the STR message for this session MUST NOT include the
2090 				Destination-Host AVP.  When cleared, the default value, the
2091 				Destination-Host AVP MUST be present in the STR message for this
2092 				session.
2093 
2094 
2095 				ACCOUNTING 4
2096 
2097 				When set, all accounting messages for this session MUST NOT
2098 				include the Destination-Host AVP.  When cleared, the default
2099 				value, the Destination-Host AVP, if known, MUST be present in all
2100 				accounting messages for this session.
2101 			*/
2102 
2103 			/* Although the RFC does not specify an "Enumerated" type here, we go forward and create one.
2104 			 * This is the reason for the "*" in the type name
2105 			 * The actual values of the AVP will not always be defined here, but at least it can be used in some cases.
2106 			 *  ... maybe the code will be changed later to support bitfields AVP ...
2107 			 */
2108 
2109 			struct dict_object 	* 	type;
2110 			struct dict_type_data	 	tdata = { AVP_TYPE_UNSIGNED32,	"Enumerated(Session-Binding)"	, NULL, NULL, NULL };
2111 			struct dict_enumval_data 	t_1 = { "RE_AUTH", 		{ .u32 = 1 }};
2112 			struct dict_enumval_data 	t_2 = { "STR", 			{ .u32 = 2 }};
2113 			struct dict_enumval_data 	t_4 = { "ACCOUNTING", 		{ .u32 = 4 }};
2114 			struct dict_avp_data 	data = {
2115 					270, 					/* Code */
2116 					0, 					/* Vendor */
2117 					"Session-Binding", 			/* Name */
2118 					AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, 	/* Fixed flags */
2119 					AVP_FLAG_MANDATORY,			/* Fixed flag values */
2120 					AVP_TYPE_UNSIGNED32 			/* base type of data */
2121 					};
2122 			/* Create the Enumerated type, and then the AVP */
2123 			CHECK_dict_new( DICT_TYPE, &tdata , NULL, &type);
2124 			CHECK_dict_new( DICT_ENUMVAL, &t_1 , type, NULL);
2125 			CHECK_dict_new( DICT_ENUMVAL, &t_2 , type, NULL);
2126 			CHECK_dict_new( DICT_ENUMVAL, &t_4 , type, NULL);
2127 			CHECK_dict_new( DICT_AVP, &data , type, NULL);
2128 		}
2129 
2130 		/* Session-Server-Failover */
2131 		{
2132 			/*
2133 				The Session-Server-Failover AVP (AVP Code 271) is of type Enumerated,
2134 				and MAY be present in application-specific authorization answer
2135 				messages that either do not include the Session-Binding AVP or
2136 				include the Session-Binding AVP with any of the bits set to a zero
2137 				value.  If present, this AVP MAY inform the Diameter client that if a
2138 				re-auth or STR message fails due to a delivery problem, the Diameter
2139 				client SHOULD issue a subsequent message without the Destination-Host
2140 				AVP.  When absent, the default value is REFUSE_SERVICE.
2141 
2142 				The following values are supported:
2143 
2144 
2145 				REFUSE_SERVICE 0
2146 
2147 				If either the re-auth or the STR message delivery fails, terminate
2148 				service with the user, and do not attempt any subsequent attempts.
2149 
2150 
2151 				TRY_AGAIN 1
2152 
2153 				If either the re-auth or the STR message delivery fails, resend
2154 				the failed message without the Destination-Host AVP present.
2155 
2156 
2157 				ALLOW_SERVICE 2
2158 
2159 				If re-auth message delivery fails, assume that re-authorization
2160 				succeeded.  If STR message delivery fails, terminate the session.
2161 
2162 
2163 				TRY_AGAIN_ALLOW_SERVICE 3
2164 
2165 				If either the re-auth or the STR message delivery fails, resend
2166 				the failed message without the Destination-Host AVP present.  If
2167 				the second delivery fails for re-auth, assume re-authorization
2168 				succeeded.  If the second delivery fails for STR, terminate the
2169 				session.
2170 			*/
2171 			struct dict_object  	* 	type;
2172 			struct dict_type_data	 	tdata = { AVP_TYPE_INTEGER32,	"Enumerated(Session-Server-Failover)"	, NULL, NULL, NULL };
2173 			struct dict_enumval_data 	t_0 = { "REFUSE_SERVICE", 		{ .i32 = 0 }};
2174 			struct dict_enumval_data 	t_1 = { "TRY_AGAIN",			{ .i32 = 1 }};
2175 			struct dict_enumval_data 	t_2 = { "ALLOW_SERVICE", 		{ .i32 = 2 }};
2176 			struct dict_enumval_data 	t_3 = { "TRY_AGAIN_ALLOW_SERVICE",	{ .i32 = 3 }};
2177 			struct dict_avp_data	 	data = {
2178 					271, 					/* Code */
2179 					0, 					/* Vendor */
2180 					"Session-Server-Failover",		/* Name */
2181 					AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, 	/* Fixed flags */
2182 					AVP_FLAG_MANDATORY,			/* Fixed flag values */
2183 					AVP_TYPE_INTEGER32 			/* base type of data */
2184 					};
2185 			/* Create the Enumerated type, and then the AVP */
2186 			CHECK_dict_new( DICT_TYPE, &tdata , NULL, &type);
2187 			CHECK_dict_new( DICT_ENUMVAL, &t_0 , type, NULL);
2188 			CHECK_dict_new( DICT_ENUMVAL, &t_1 , type, NULL);
2189 			CHECK_dict_new( DICT_ENUMVAL, &t_2 , type, NULL);
2190 			CHECK_dict_new( DICT_ENUMVAL, &t_3 , type, NULL);
2191 			CHECK_dict_new( DICT_AVP, &data , type, NULL);
2192 		}
2193 
2194 		/* Multi-Round-Time-Out */
2195 		{
2196 			/*
2197 				The Multi-Round-Time-Out AVP (AVP Code 272) is of type Unsigned32,
2198 				and SHOULD be present in application-specific authorization answer
2199 				messages whose Result-Code AVP is set to DIAMETER_MULTI_ROUND_AUTH.
2200 				This AVP contains the maximum number of seconds that the access
2201 				device MUST provide the user in responding to an authentication
2202 				request.
2203 			*/
2204 			struct dict_avp_data data = {
2205 					272, 					/* Code */
2206 					0, 					/* Vendor */
2207 					"Multi-Round-Time-Out", 			/* Name */
2208 					AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, 	/* Fixed flags */
2209 					AVP_FLAG_MANDATORY,			/* Fixed flag values */
2210 					AVP_TYPE_UNSIGNED32 			/* base type of data */
2211 					};
2212 			CHECK_dict_new( DICT_AVP, &data , NULL, NULL);
2213 		}
2214 
2215 		/* Class */
2216 		{
2217 			/*
2218 				The Class AVP (AVP Code 25) is of type OctetString and is used to by
2219 				Diameter servers to return state information to the access device.
2220 				When one or more Class AVPs are present in application-specific
2221 				authorization answer messages, they MUST be present in subsequent re-
2222 				authorization, session termination and accounting messages.  Class
2223 				AVPs found in a re-authorization answer message override the ones
2224 				found in any previous authorization answer message.  Diameter server
2225 				implementations SHOULD NOT return Class AVPs that require more than
2226 				4096 bytes of storage on the Diameter client.  A Diameter client that
2227 				receives Class AVPs whose size exceeds local available storage MUST
2228 				terminate the session.
2229 			*/
2230 			struct dict_avp_data data = {
2231 					25, 					/* Code */
2232 					0, 					/* Vendor */
2233 					"Class", 				/* Name */
2234 					AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, 	/* Fixed flags */
2235 					AVP_FLAG_MANDATORY,			/* Fixed flag values */
2236 					AVP_TYPE_OCTETSTRING 			/* base type of data */
2237 					};
2238 			CHECK_dict_new( DICT_AVP, &data , NULL, NULL);
2239 		}
2240 
2241 		/* Event-Timestamp */
2242 		{
2243 			/*
2244 				The Event-Timestamp (AVP Code 55) is of type Time, and MAY be
2245 				included in an Accounting-Request and Accounting-Answer messages to
2246 				record the time that the reported event occurred, in seconds since
2247 				January 1, 1900 00:00 UTC.
2248 			*/
2249 			struct dict_avp_data data = {
2250 					55, 					/* Code */
2251 					0, 					/* Vendor */
2252 					"Event-Timestamp", 			/* Name */
2253 					AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, 	/* Fixed flags */
2254 					AVP_FLAG_MANDATORY,			/* Fixed flag values */
2255 					AVP_TYPE_OCTETSTRING 			/* base type of data */
2256 					};
2257 			CHECK_dict_new( DICT_AVP, &data , Time_type, NULL);
2258 		}
2259 
2260 
2261 		/* Accounting-Record-Type */
2262 		{
2263 			/*
2264 				The Accounting-Record-Type AVP (AVP Code 480) is of type Enumerated
2265 				and contains the type of accounting record being sent.  The following
2266 				values are currently defined for the Accounting-Record-Type AVP:
2267 
2268 
2269 				EVENT_RECORD 1
2270 
2271 				An Accounting Event Record is used to indicate that a one-time
2272 				event has occurred (meaning that the start and end of the event
2273 				are simultaneous).  This record contains all information relevant
2274 				to the service, and is the only record of the service.
2275 
2276 
2277 				START_RECORD 2
2278 
2279 				An Accounting Start, Interim, and Stop Records are used to
2280 				indicate that a service of a measurable length has been given.  An
2281 				Accounting Start Record is used to initiate an accounting session,
2282 				and contains accounting information that is relevant to the
2283 				initiation of the session.
2284 
2285 
2286 				INTERIM_RECORD 3
2287 
2288 				An Interim Accounting Record contains cumulative accounting
2289 				information for an existing accounting session.  Interim
2290 				Accounting Records SHOULD be sent every time a re-authentication
2291 				or re-authorization occurs.  Further, additional interim record
2292 				triggers MAY be defined by application-specific Diameter
2293 				applications.  The selection of whether to use INTERIM_RECORD
2294 				records is done by the Acct-Interim-Interval AVP.
2295 
2296 
2297 				STOP_RECORD 4
2298 
2299 				An Accounting Stop Record is sent to terminate an accounting
2300 				session and contains cumulative accounting information relevant to
2301 				the existing session.
2302 			*/
2303 			struct dict_object 	* 	type;
2304 			struct dict_type_data	  	tdata = { AVP_TYPE_INTEGER32,	"Enumerated(Accounting-Record-Type)"	, NULL, NULL, NULL };
2305 			struct dict_enumval_data 	t_1 = { "EVENT_RECORD",			{ .i32 = 1 }};
2306 			struct dict_enumval_data 	t_2 = { "START_RECORD", 		{ .i32 = 2 }};
2307 			struct dict_enumval_data 	t_3 = { "INTERIM_RECORD",		{ .i32 = 3 }};
2308 			struct dict_enumval_data 	t_4 = { "STOP_RECORD", 			{ .i32 = 4 }};
2309 			struct dict_avp_data 	data = {
2310 					480, 					/* Code */
2311 					0, 					/* Vendor */
2312 					"Accounting-Record-Type",		/* Name */
2313 					AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, 	/* Fixed flags */
2314 					AVP_FLAG_MANDATORY,			/* Fixed flag values */
2315 					AVP_TYPE_INTEGER32 			/* base type of data */
2316 					};
2317 			/* Create the Enumerated type, and then the AVP */
2318 			CHECK_dict_new( DICT_TYPE, &tdata , NULL, &type);
2319 			CHECK_dict_new( DICT_ENUMVAL, &t_1 , type, NULL);
2320 			CHECK_dict_new( DICT_ENUMVAL, &t_2 , type, NULL);
2321 			CHECK_dict_new( DICT_ENUMVAL, &t_3 , type, NULL);
2322 			CHECK_dict_new( DICT_ENUMVAL, &t_4 , type, NULL);
2323 			CHECK_dict_new( DICT_AVP, &data , type, NULL);
2324 		}
2325 
2326 		/* Acct-Interim-Interval */
2327 		{
2328 			/*
2329 				The Acct-Interim-Interval AVP (AVP Code 85) is of type Unsigned32 and
2330 				is sent from the Diameter home authorization server to the Diameter
2331 				client.  The client uses information in this AVP to decide how and
2332 				when to produce accounting records.  With different values in this
2333 				AVP, service sessions can result in one, two, or two+N accounting
2334 				records, based on the needs of the home-organization.  The following
2335 				accounting record production behavior is directed by the inclusion of
2336 				this AVP:
2337 
2338 
2339 				1.  The omission of the Acct-Interim-Interval AVP or its inclusion
2340 				with Value field set to 0 means that EVENT_RECORD, START_RECORD,
2341 				and STOP_RECORD are produced, as appropriate for the service.
2342 
2343 
2344 				2.  The inclusion of the AVP with Value field set to a non-zero value
2345 				means that INTERIM_RECORD records MUST be produced between the
2346 				START_RECORD and STOP_RECORD records.  The Value field of this
2347 				AVP is the nominal interval between these records in seconds.
2348 
2349 				The Diameter node that originates the accounting information,
2350 				known as the client, MUST produce the first INTERIM_RECORD record
2351 				roughly at the time when this nominal interval has elapsed from
2352 				the START_RECORD, the next one again as the interval has elapsed
2353 				once more, and so on until the session ends and a STOP_RECORD
2354 				record is produced.
2355 
2356 				The client MUST ensure that the interim record production times
2357 				are randomized so that large accounting message storms are not
2358 				created either among records or around a common service start
2359 				time.
2360 			*/
2361 			struct dict_avp_data data = {
2362 					85, 					/* Code */
2363 					0, 					/* Vendor */
2364 					"Acct-Interim-Interval", 		/* Name */
2365 					AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, 	/* Fixed flags */
2366 					AVP_FLAG_MANDATORY,			/* Fixed flag values */
2367 					AVP_TYPE_UNSIGNED32 			/* base type of data */
2368 					};
2369 			CHECK_dict_new( DICT_AVP, &data , NULL, NULL);
2370 		}
2371 
2372 		/* Accounting-Record-Number */
2373 		{
2374 			/*
2375 				The Accounting-Record-Number AVP (AVP Code 485) is of type Unsigned32
2376 				and identifies this record within one session.  As Session-Id AVPs
2377 				are globally unique, the combination of Session-Id and Accounting-
2378 				Record-Number AVPs is also globally unique, and can be used in
2379 				matching accounting records with confirmations.  An easy way to
2380 				produce unique numbers is to set the value to 0 for records of type
2381 				EVENT_RECORD and START_RECORD, and set the value to 1 for the first
2382 				INTERIM_RECORD, 2 for the second, and so on until the value for
2383 				STOP_RECORD is one more than for the last INTERIM_RECORD.
2384 			*/
2385 			struct dict_avp_data data = {
2386 					485, 					/* Code */
2387 					0, 					/* Vendor */
2388 					"Accounting-Record-Number", 		/* Name */
2389 					AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, 	/* Fixed flags */
2390 					AVP_FLAG_MANDATORY,			/* Fixed flag values */
2391 					AVP_TYPE_UNSIGNED32 			/* base type of data */
2392 					};
2393 			CHECK_dict_new( DICT_AVP, &data , NULL, NULL);
2394 		}
2395 
2396 		/* Acct-Session-Id */
2397 		{
2398 			/*
2399 				The Acct-Session-Id AVP (AVP Code 44) is of type OctetString is only
2400 				used when RADIUS/Diameter translation occurs.  This AVP contains the
2401 				contents of the RADIUS Acct-Session-Id attribute.
2402 			*/
2403 			struct dict_avp_data data = {
2404 					44, 					/* Code */
2405 					0, 					/* Vendor */
2406 					"Acct-Session-Id", 			/* Name */
2407 					AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, 	/* Fixed flags */
2408 					AVP_FLAG_MANDATORY,			/* Fixed flag values */
2409 					AVP_TYPE_OCTETSTRING 			/* base type of data */
2410 					};
2411 			CHECK_dict_new( DICT_AVP, &data , NULL, NULL);
2412 		}
2413 
2414 		/* Acct-Multi-Session-Id */
2415 		{
2416 			/*
2417 				The Acct-Multi-Session-Id AVP (AVP Code 50) is of type UTF8String,
2418 				following the format specified in Section 8.8.  The Acct-Multi-
2419 				Session-Id AVP is used to link together multiple related accounting
2420 				sessions, where each session would have a unique Session-Id, but the
2421 				same Acct-Multi-Session-Id AVP.  This AVP MAY be returned by the
2422 				Diameter server in an authorization answer, and MUST be used in all
2423 				accounting messages for the given session.
2424 			*/
2425 			struct dict_avp_data data = {
2426 					50, 					/* Code */
2427 					0, 					/* Vendor */
2428 					"Acct-Multi-Session-Id", 		/* Name */
2429 					AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, 	/* Fixed flags */
2430 					AVP_FLAG_MANDATORY,			/* Fixed flag values */
2431 					AVP_TYPE_OCTETSTRING 			/* base type of data */
2432 					};
2433 			CHECK_dict_new( DICT_AVP, &data , UTF8String_type, NULL);
2434 		}
2435 
2436 		/* Accounting-Sub-Session-Id */
2437 		{
2438 			/*
2439 				The Accounting-Sub-Session-Id AVP (AVP Code 287) is of type
2440 				Unsigned64 and contains the accounting sub-session identifier.  The
2441 				combination of the Session-Id and this AVP MUST be unique per sub-
2442 				session, and the value of this AVP MUST be monotonically increased by
2443 				one for all new sub-sessions.  The absence of this AVP implies no
2444 				sub-sessions are in use, with the exception of an Accounting-Request
2445 				whose Accounting-Record-Type is set to STOP_RECORD.  A STOP_RECORD
2446 				message with no Accounting-Sub-Session-Id AVP present will signal the
2447 				termination of all sub-sessions for a given Session-Id.
2448 			*/
2449 			struct dict_avp_data data = {
2450 					287, 					/* Code */
2451 					0, 					/* Vendor */
2452 					"Accounting-Sub-Session-Id", 		/* Name */
2453 					AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, 	/* Fixed flags */
2454 					AVP_FLAG_MANDATORY,			/* Fixed flag values */
2455 					AVP_TYPE_UNSIGNED64 			/* base type of data */
2456 					};
2457 			CHECK_dict_new( DICT_AVP, &data , NULL, NULL);
2458 		}
2459 
2460 		/* Accounting-Realtime-Required */
2461 		{
2462 			/*
2463 				The Accounting-Realtime-Required AVP (AVP Code 483) is of type
2464 				Enumerated and is sent from the Diameter home authorization server to
2465 				the Diameter client or in the Accounting-Answer from the accounting
2466 				server.  The client uses information in this AVP to decide what to do
2467 				if the sending of accounting records to the accounting server has
2468 				been temporarily prevented due to, for instance, a network problem.
2469 
2470 
2471 				DELIVER_AND_GRANT 1
2472 
2473 				The AVP with Value field set to DELIVER_AND_GRANT means that the
2474 				service MUST only be granted as long as there is a connection to
2475 				an accounting server.  Note that the set of alternative accounting
2476 				servers are treated as one server in this sense.  Having to move
2477 				the accounting record stream to a backup server is not a reason to
2478 				discontinue the service to the user.
2479 
2480 
2481 				GRANT_AND_STORE 2
2482 
2483 				The AVP with Value field set to GRANT_AND_STORE means that service
2484 				SHOULD be granted if there is a connection, or as long as records
2485 				can still be stored as described in Section 9.4.
2486 
2487 				This is the default behavior if the AVP isn't included in the
2488 				reply from the authorization server.
2489 
2490 
2491 				GRANT_AND_LOSE 3
2492 
2493 				The AVP with Value field set to GRANT_AND_LOSE means that service
2494 				SHOULD be granted even if the records can not be delivered or
2495 				stored.
2496 			*/
2497 			struct dict_object  	* 	type;
2498 			struct dict_type_data	 	tdata = { AVP_TYPE_INTEGER32,	"Enumerated(Accounting-Realtime-Required)"	, NULL, NULL, NULL };
2499 			struct dict_enumval_data 	t_1 = { "DELIVER_AND_GRANT",		{ .i32 = 1 }};
2500 			struct dict_enumval_data 	t_2 = { "GRANT_AND_STORE", 		{ .i32 = 2 }};
2501 			struct dict_enumval_data 	t_3 = { "GRANT_AND_LOSE",		{ .i32 = 3 }};
2502 			struct dict_avp_data 		data = {
2503 					483, 					/* Code */
2504 					0, 					/* Vendor */
2505 					"Accounting-Realtime-Required",		/* Name */
2506 					AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, 	/* Fixed flags */
2507 					AVP_FLAG_MANDATORY,			/* Fixed flag values */
2508 					AVP_TYPE_INTEGER32 			/* base type of data */
2509 					};
2510 			/* Create the Enumerated type, and then the AVP */
2511 			CHECK_dict_new( DICT_TYPE, &tdata , NULL, &type);
2512 			CHECK_dict_new( DICT_ENUMVAL, &t_1 , type, NULL);
2513 			CHECK_dict_new( DICT_ENUMVAL, &t_2 , type, NULL);
2514 			CHECK_dict_new( DICT_ENUMVAL, &t_3 , type, NULL);
2515 			CHECK_dict_new( DICT_AVP, &data , type, NULL);
2516 		}
2517 
2518 	}
2519 
2520 	/* Commands section */
2521 	{
2522 		/* To avoid defining global variables for all the AVP that we use here, we do search the dictionary in each sub-block.
2523 		 * This is far from optimal, but the code is clearer like this, and the time it requires at execution is not noticeable.
2524 		 */
2525 
2526 		/* Generic message syntax when the 'E' bit is set */
2527 		{
2528 			/*
2529 				The 'E' (Error Bit) in the Diameter header is set when the request
2530 				caused a protocol-related error (see Section 7.1.3).  A message with
2531 				the 'E' bit MUST NOT be sent as a response to an answer message.
2532 				Note that a message with the 'E' bit set is still subjected to the
2533 				processing rules defined in Section 6.2.  When set, the answer
2534 				message will not conform to the ABNF specification for the command,
2535 				and will instead conform to the following ABNF:
2536 
2537 				Message Format
2538 
2539 				<answer-message> ::= < Diameter Header: code, ERR [PXY] >
2540                 				0*1< Session-Id >
2541                 				   { Origin-Host }
2542                 				   { Origin-Realm }
2543                 				   { Result-Code }
2544                 				   [ Origin-State-Id ]
2545                 				   [ Error-Message ]
2546                 				   [ Error-Reporting-Host ]
2547                 				   [ Failed-AVP ]
2548                 				 * [ Proxy-Info ]
2549                 				 * [ AVP ]
2550 
2551 				Note that the code used in the header is the same than the one found
2552 				in the request message, but with the 'R' bit cleared and the 'E' bit
2553 				set.  The 'P' bit in the header is set to the same value as the one
2554 				found in the request message.
2555 			*/
2556 			struct dict_object * cmd_error;
2557 			struct local_rules_definition rules[] =
2558 						{ 	 {  "Session-Id", 			RULE_FIXED_HEAD,0, 1 }
2559 							,{  "Origin-Host",			RULE_REQUIRED, -1, 1 }
2560 							,{  "Origin-Realm",			RULE_REQUIRED, -1, 1 }
2561 							,{  "Result-Code",			RULE_REQUIRED, -1, 1 }
2562 							,{  "Origin-State-Id",			RULE_OPTIONAL, -1, 1 }
2563 							,{  "Error-Message",			RULE_OPTIONAL, -1, 1 }
2564 							,{  "Error-Reporting-Host",		RULE_OPTIONAL, -1, 1 }
2565 							,{  "Failed-AVP",			RULE_OPTIONAL, -1, 1 }
2566 							,{  "Proxy-Info",			RULE_OPTIONAL, -1,-1 }
2567 						};
2568 			CHECK_FCT( fd_dict_get_error_cmd(dict, &cmd_error) );
2569 			PARSE_loc_rules( rules, cmd_error );
2570 		}
2571 
2572 		/* Capabilities-Exchange-Request */
2573 		{
2574 			/*
2575 				The Capabilities-Exchange-Request (CER), indicated by the Command-
2576 				Code set to 257 and the Command Flags' 'R' bit set, is sent to
2577 				exchange local capabilities.  Upon detection of a transport failure,
2578 				this message MUST NOT be sent to an alternate peer.
2579 
2580 				When Diameter is run over SCTP [RFC2960], which allows for
2581 				connections to span multiple interfaces and multiple IP addresses,
2582 				the Capabilities-Exchange-Request message MUST contain one Host-IP-
2583 				Address AVP for each potential IP address that MAY be locally used
2584 				when transmitting Diameter messages.
2585 
2586 				Message Format
2587 
2588 				 <CER> ::= < Diameter Header: 257, REQ >
2589         				   { Origin-Host }
2590         				   { Origin-Realm }
2591         				1* { Host-IP-Address }
2592         				   { Vendor-Id }
2593         				   { Product-Name }
2594         				   [ Origin-State-Id ]
2595         				 * [ Supported-Vendor-Id ]
2596         				 * [ Auth-Application-Id ]
2597         				 * [ Inband-Security-Id ]
2598         				 * [ Acct-Application-Id ]
2599         				 * [ Vendor-Specific-Application-Id ]
2600         				   [ Firmware-Revision ]
2601         				 * [ AVP ]
2602 			*/
2603 			struct dict_object * cmd;
2604 			struct dict_cmd_data data = {
2605 					257, 					/* Code */
2606 					#if CC_CAPABILITIES_EXCHANGE != 257
2607 					#error "CC_CAPABILITIES_EXCHANGE definition mismatch"
2608 					#endif
2609 					"Capabilities-Exchange-Request", 	/* Name */
2610 					CMD_FLAG_REQUEST | CMD_FLAG_PROXIABLE | CMD_FLAG_RETRANSMIT | CMD_FLAG_ERROR, 	/* Fixed flags */
2611 					CMD_FLAG_REQUEST 			/* Fixed flag values */
2612 					};
2613 			struct local_rules_definition rules[] =
2614 						{ 	 {  "Origin-Host", 			RULE_REQUIRED, -1, 1 }
2615 							,{  "Origin-Realm",			RULE_REQUIRED, -1, 1 }
2616 							,{  "Host-IP-Address",			RULE_REQUIRED, -1,-1 }
2617 							,{  "Vendor-Id",			RULE_REQUIRED, -1, 1 }
2618 							,{  "Product-Name",			RULE_REQUIRED, -1, 1 }
2619 							,{  "Origin-State-Id",			RULE_OPTIONAL, -1, 1 }
2620 							,{  "Supported-Vendor-Id",		RULE_OPTIONAL, -1,-1 }
2621 							,{  "Auth-Application-Id",		RULE_OPTIONAL, -1,-1 }
2622 							,{  "Inband-Security-Id",		RULE_OPTIONAL, -1,-1 }
2623 							,{  "Acct-Application-Id",		RULE_OPTIONAL, -1,-1 }
2624 							,{  "Vendor-Specific-Application-Id",	RULE_OPTIONAL, -1,-1 }
2625 							,{  "Firmware-Revision",		RULE_OPTIONAL, -1, 1 }
2626 						};
2627 
2628 			CHECK_dict_new( DICT_COMMAND, &data , NULL, &cmd);
2629 			PARSE_loc_rules( rules, cmd );
2630 		}
2631 
2632 		/* Capabilities-Exchange-Answer */
2633 		{
2634 			/*
2635 				The Capabilities-Exchange-Answer (CEA), indicated by the Command-Code
2636 				set to 257 and the Command Flags' 'R' bit cleared, is sent in
2637 				response to a CER message.
2638 
2639 				When Diameter is run over SCTP [RFC2960], which allows connections to
2640 				span multiple interfaces, hence, multiple IP addresses, the
2641 				Capabilities-Exchange-Answer message MUST contain one Host-IP-Address
2642 				AVP for each potential IP address that MAY be locally used when
2643 				transmitting Diameter messages.
2644 
2645 				Message Format
2646 
2647 				 <CEA> ::= < Diameter Header: 257 >
2648         				   { Result-Code }
2649         				   { Origin-Host }
2650         				   { Origin-Realm }
2651         				1* { Host-IP-Address }
2652         				   { Vendor-Id }
2653         				   { Product-Name }
2654         				   [ Origin-State-Id ]
2655         				   [ Error-Message ]
2656         				   [ Failed-AVP ]
2657         				 * [ Supported-Vendor-Id ]
2658         				 * [ Auth-Application-Id ]
2659         				 * [ Inband-Security-Id ]
2660         				 * [ Acct-Application-Id ]
2661         				 * [ Vendor-Specific-Application-Id ]
2662         				   [ Firmware-Revision ]
2663         				 * [ AVP ]
2664 			*/
2665 			struct dict_object * cmd;
2666 			struct dict_cmd_data data = {
2667 					257, 					/* Code */
2668 					#if CC_CAPABILITIES_EXCHANGE != 257
2669 					#error "CC_CAPABILITIES_EXCHANGE definition mismatch"
2670 					#endif
2671 					"Capabilities-Exchange-Answer", 	/* Name */
2672 					CMD_FLAG_REQUEST | CMD_FLAG_PROXIABLE | CMD_FLAG_RETRANSMIT, 	/* Fixed flags */
2673 					0 					/* Fixed flag values */
2674 					};
2675 			struct local_rules_definition rules[] =
2676 						{ 	 {  "Result-Code", 			RULE_REQUIRED, -1, 1 }
2677 						 	,{  "Origin-Host", 			RULE_REQUIRED, -1, 1 }
2678 							,{  "Origin-Realm",			RULE_REQUIRED, -1, 1 }
2679 							,{  "Host-IP-Address",			RULE_REQUIRED, -1,-1 }
2680 							,{  "Vendor-Id",			RULE_REQUIRED, -1, 1 }
2681 							,{  "Product-Name",			RULE_REQUIRED, -1, 1 }
2682 							,{  "Origin-State-Id",			RULE_OPTIONAL, -1, 1 }
2683 							,{  "Error-Message",			RULE_OPTIONAL, -1, 1 }
2684 							,{  "Failed-AVP",			RULE_OPTIONAL, -1, 1 }
2685 							,{  "Supported-Vendor-Id",		RULE_OPTIONAL, -1,-1 }
2686 							,{  "Auth-Application-Id",		RULE_OPTIONAL, -1,-1 }
2687 							,{  "Inband-Security-Id",		RULE_OPTIONAL, -1,-1 }
2688 							,{  "Acct-Application-Id",		RULE_OPTIONAL, -1,-1 }
2689 							,{  "Vendor-Specific-Application-Id",	RULE_OPTIONAL, -1,-1 }
2690 							,{  "Firmware-Revision",		RULE_OPTIONAL, -1, 1 }
2691 						};
2692 
2693 			CHECK_dict_new( DICT_COMMAND, &data , NULL, &cmd);
2694 			PARSE_loc_rules( rules, cmd );
2695 		}
2696 
2697 		/* Disconnect-Peer-Request */
2698 		{
2699 			/*
2700 				The Disconnect-Peer-Request (DPR), indicated by the Command-Code set
2701 				to 282 and the Command Flags' 'R' bit set, is sent to a peer to
2702 				inform its intentions to shutdown the transport connection.  Upon
2703 				detection of a transport failure, this message MUST NOT be sent to an
2704 				alternate peer.
2705 
2706 				Message Format
2707 
2708 				 <DPR>  ::= < Diameter Header: 282, REQ >
2709         				    { Origin-Host }
2710         				    { Origin-Realm }
2711         				    { Disconnect-Cause }
2712 			*/
2713 			struct dict_object * cmd;
2714 			struct dict_cmd_data data = {
2715 					282, 					/* Code */
2716 					#if CC_DISCONNECT_PEER != 282
2717 					#error "CC_DISCONNECT_PEER definition mismatch"
2718 					#endif
2719 					"Disconnect-Peer-Request", 		/* Name */
2720 					CMD_FLAG_REQUEST | CMD_FLAG_PROXIABLE | CMD_FLAG_RETRANSMIT | CMD_FLAG_ERROR, 	/* Fixed flags */
2721 					CMD_FLAG_REQUEST 			/* Fixed flag values */
2722 					};
2723 			struct local_rules_definition rules[] =
2724 						{ 	 {  "Origin-Host", 			RULE_REQUIRED, -1, 1 }
2725 							,{  "Origin-Realm",			RULE_REQUIRED, -1, 1 }
2726 							,{  "Disconnect-Cause",			RULE_REQUIRED, -1, 1 }
2727 						};
2728 
2729 			CHECK_dict_new( DICT_COMMAND, &data , NULL, &cmd);
2730 			PARSE_loc_rules( rules, cmd );
2731 		}
2732 
2733 		/* Disconnect-Peer-Answer */
2734 		{
2735 			/*
2736 				The Disconnect-Peer-Answer (DPA), indicated by the Command-Code set
2737 				to 282 and the Command Flags' 'R' bit cleared, is sent as a response
2738 				to the Disconnect-Peer-Request message.  Upon receipt of this
2739 				message, the transport connection is shutdown.
2740 
2741 				Message Format
2742 
2743 				 <DPA>  ::= < Diameter Header: 282 >
2744         				    { Result-Code }
2745         				    { Origin-Host }
2746         				    { Origin-Realm }
2747         				    [ Error-Message ]
2748         				    [ Failed-AVP ]
2749 			*/
2750 			struct dict_object * cmd;
2751 			struct dict_cmd_data data = {
2752 					282, 					/* Code */
2753 					#if CC_DISCONNECT_PEER != 282
2754 					#error "CC_DISCONNECT_PEER definition mismatch"
2755 					#endif
2756 					"Disconnect-Peer-Answer", 		/* Name */
2757 					CMD_FLAG_REQUEST | CMD_FLAG_PROXIABLE | CMD_FLAG_RETRANSMIT, 	/* Fixed flags */
2758 					0 					/* Fixed flag values */
2759 					};
2760 			struct local_rules_definition rules[] =
2761 						{ 	 {  "Result-Code", 			RULE_REQUIRED, -1, 1 }
2762 						 	,{  "Origin-Host", 			RULE_REQUIRED, -1, 1 }
2763 							,{  "Origin-Realm",			RULE_REQUIRED, -1, 1 }
2764 							,{  "Error-Message",			RULE_OPTIONAL, -1, 1 }
2765 							,{  "Failed-AVP",			RULE_OPTIONAL, -1, 1 }
2766 						};
2767 
2768 			CHECK_dict_new( DICT_COMMAND, &data , NULL, &cmd);
2769 			PARSE_loc_rules( rules, cmd );
2770 		}
2771 
2772 		/* Device-Watchdog-Request */
2773 		{
2774 			/*
2775 				The Device-Watchdog-Request (DWR), indicated by the Command-Code set
2776 				to 280 and the Command Flags' 'R' bit set, is sent to a peer when no
2777 				traffic has been exchanged between two peers (see Section 5.5.3).
2778 				Upon detection of a transport failure, this message MUST NOT be sent
2779 				to an alternate peer.
2780 
2781 				Message Format
2782 
2783 				 <DWR>  ::= < Diameter Header: 280, REQ >
2784         				    { Origin-Host }
2785         				    { Origin-Realm }
2786         				    [ Origin-State-Id ]
2787 			*/
2788 			struct dict_object * cmd;
2789 			struct dict_cmd_data data = {
2790 					280, 					/* Code */
2791 					#if CC_DEVICE_WATCHDOG != 280
2792 					#error "CC_DEVICE_WATCHDOG definition mismatch"
2793 					#endif
2794 					"Device-Watchdog-Request", 		/* Name */
2795 					CMD_FLAG_REQUEST | CMD_FLAG_PROXIABLE | CMD_FLAG_RETRANSMIT | CMD_FLAG_ERROR, 	/* Fixed flags */
2796 					CMD_FLAG_REQUEST 			/* Fixed flag values */
2797 					};
2798 			struct local_rules_definition rules[] =
2799 						{ 	 {  "Origin-Host", 			RULE_REQUIRED, -1, 1 }
2800 							,{  "Origin-Realm",			RULE_REQUIRED, -1, 1 }
2801 							,{  "Origin-State-Id",			RULE_OPTIONAL, -1, 1 }
2802 						};
2803 
2804 			CHECK_dict_new( DICT_COMMAND, &data , NULL, &cmd);
2805 			PARSE_loc_rules( rules, cmd );
2806 		}
2807 
2808 		/* Device-Watchdog-Answer */
2809 		{
2810 			/*
2811 				The Device-Watchdog-Answer (DWA), indicated by the Command-Code set
2812 				to 280 and the Command Flags' 'R' bit cleared, is sent as a response
2813 				to the Device-Watchdog-Request message.
2814 
2815 				Message Format
2816 
2817 				 <DWA>  ::= < Diameter Header: 280 >
2818         				    { Result-Code }
2819         				    { Origin-Host }
2820         				    { Origin-Realm }
2821         				    [ Error-Message ]
2822         				    [ Failed-AVP ]
2823         				    [ Origin-State-Id ]
2824 			*/
2825 			struct dict_object * cmd;
2826 			struct dict_cmd_data data = {
2827 					280, 					/* Code */
2828 					#if CC_DEVICE_WATCHDOG != 280
2829 					#error "CC_DEVICE_WATCHDOG definition mismatch"
2830 					#endif
2831 					"Device-Watchdog-Answer", 		/* Name */
2832 					CMD_FLAG_REQUEST | CMD_FLAG_PROXIABLE | CMD_FLAG_RETRANSMIT, 	/* Fixed flags */
2833 					0 					/* Fixed flag values */
2834 					};
2835 			struct local_rules_definition rules[] =
2836 						{ 	 {  "Result-Code", 			RULE_REQUIRED, -1, 1 }
2837 						 	,{  "Origin-Host", 			RULE_REQUIRED, -1, 1 }
2838 							,{  "Origin-Realm",			RULE_REQUIRED, -1, 1 }
2839 							,{  "Error-Message",			RULE_OPTIONAL, -1, 1 }
2840 							,{  "Failed-AVP",			RULE_OPTIONAL, -1, 1 }
2841 							,{  "Origin-State-Id",			RULE_OPTIONAL, -1, 1 }
2842 						};
2843 
2844 			CHECK_dict_new( DICT_COMMAND, &data , NULL, &cmd);
2845 			PARSE_loc_rules( rules, cmd );
2846 		}
2847 
2848 		/* Re-Auth-Request */
2849 		{
2850 			/*
2851 				The Re-Auth-Request (RAR), indicated by the Command-Code set to 258
2852 				and the message flags' 'R' bit set, may be sent by any server to the
2853 				access device that is providing session service, to request that the
2854 				user be re-authenticated and/or re-authorized.
2855 
2856 
2857 				Message Format
2858 
2859 				 <RAR>  ::= < Diameter Header: 258, REQ, PXY >
2860         				    < Session-Id >
2861         				    { Origin-Host }
2862         				    { Origin-Realm }
2863         				    { Destination-Realm }
2864         				    { Destination-Host }
2865         				    { Auth-Application-Id }
2866         				    { Re-Auth-Request-Type }
2867         				    [ User-Name ]
2868         				    [ Origin-State-Id ]
2869         				  * [ Proxy-Info ]
2870         				  * [ Route-Record ]
2871         				  * [ AVP ]
2872 			*/
2873 			struct dict_object * cmd;
2874 			struct dict_cmd_data data = {
2875 					258, 					/* Code */
2876 					#if CC_RE_AUTH != 258
2877 					#error "CC_RE_AUTH definition mismatch"
2878 					#endif
2879 					"Re-Auth-Request", 			/* Name */
2880 					CMD_FLAG_REQUEST | CMD_FLAG_PROXIABLE | CMD_FLAG_ERROR,	/* Fixed flags */
2881 					CMD_FLAG_REQUEST | CMD_FLAG_PROXIABLE	/* Fixed flag values */
2882 					};
2883 			struct local_rules_definition rules[] =
2884 						{ 	 {  "Session-Id", 			RULE_FIXED_HEAD, -1, 1 }
2885 						 	,{  "Origin-Host", 			RULE_REQUIRED,   -1, 1 }
2886 							,{  "Origin-Realm",			RULE_REQUIRED,   -1, 1 }
2887 							,{  "Destination-Realm",		RULE_REQUIRED,   -1, 1 }
2888 						 	,{  "Destination-Host", 		RULE_REQUIRED,   -1, 1 }
2889 						 	,{  "Auth-Application-Id", 		RULE_REQUIRED,   -1, 1 }
2890 						 	,{  "Re-Auth-Request-Type", 		RULE_REQUIRED,   -1, 1 }
2891 							,{  "User-Name",			RULE_OPTIONAL,   -1, 1 }
2892 							,{  "Origin-State-Id",			RULE_OPTIONAL,   -1, 1 }
2893 							,{  "Proxy-Info",			RULE_OPTIONAL,   -1,-1 }
2894 							,{  "Route-Record",			RULE_OPTIONAL,   -1,-1 }
2895 						};
2896 
2897 			CHECK_dict_new( DICT_COMMAND, &data , NULL, &cmd);
2898 			PARSE_loc_rules( rules, cmd );
2899 		}
2900 
2901 		/* Re-Auth-Answer */
2902 		{
2903 			/*
2904 				The Re-Auth-Answer (RAA), indicated by the Command-Code set to 258
2905 				and the message flags' 'R' bit clear, is sent in response to the RAR.
2906 				The Result-Code AVP MUST be present, and indicates the disposition of
2907 				the request.
2908 
2909 				A successful RAA message MUST be followed by an application-specific
2910 				authentication and/or authorization message.
2911 
2912 
2913 				Message Format
2914 
2915 				 <RAA>  ::= < Diameter Header: 258, PXY >
2916         				    < Session-Id >
2917         				    { Result-Code }
2918         				    { Origin-Host }
2919         				    { Origin-Realm }
2920         				    [ User-Name ]
2921         				    [ Origin-State-Id ]
2922         				    [ Error-Message ]
2923         				    [ Error-Reporting-Host ]
2924         				    [ Failed-AVP ]
2925         				  * [ Redirect-Host ]
2926         				    [ Redirect-Host-Usage ]
2927         				    [ Redirect-Max-Cache-Time ]
2928         				  * [ Proxy-Info ]
2929         				  * [ AVP ]
2930 			*/
2931 			struct dict_object * cmd;
2932 			struct dict_cmd_data data = {
2933 					258, 					/* Code */
2934 					#if CC_RE_AUTH != 258
2935 					#error "CC_RE_AUTH definition mismatch"
2936 					#endif
2937 					"Re-Auth-Answer", 			/* Name */
2938 					CMD_FLAG_REQUEST | CMD_FLAG_PROXIABLE,	/* Fixed flags */
2939 							   CMD_FLAG_PROXIABLE	/* Fixed flag values */
2940 					};
2941 			struct local_rules_definition rules[] =
2942 						{ 	 {  "Session-Id", 			RULE_FIXED_HEAD, -1, 1 }
2943  							,{  "Result-Code", 			RULE_REQUIRED,   -1, 1 }
2944 						 	,{  "Origin-Host", 			RULE_REQUIRED,   -1, 1 }
2945 							,{  "Origin-Realm",			RULE_REQUIRED,   -1, 1 }
2946 							,{  "User-Name",			RULE_OPTIONAL,   -1, 1 }
2947 							,{  "Origin-State-Id",			RULE_OPTIONAL,   -1, 1 }
2948 							,{  "Error-Message",			RULE_OPTIONAL,   -1, 1 }
2949 							,{  "Error-Reporting-Host",		RULE_OPTIONAL,   -1, 1 }
2950 							,{  "Failed-AVP",			RULE_OPTIONAL,   -1, 1 }
2951 							,{  "Redirect-Host",			RULE_OPTIONAL,   -1,-1 }
2952 							,{  "Redirect-Host-Usage",		RULE_OPTIONAL,   -1, 1 }
2953 							,{  "Redirect-Max-Cache-Time",		RULE_OPTIONAL,   -1, 1 }
2954 							,{  "Proxy-Info",			RULE_OPTIONAL,   -1,-1 }
2955 						};
2956 
2957 			CHECK_dict_new( DICT_COMMAND, &data , NULL, &cmd);
2958 			PARSE_loc_rules( rules, cmd );
2959 		}
2960 
2961 		/* Session-Termination-Request */
2962 		{
2963 			/*
2964 				The Session-Termination-Request (STR), indicated by the Command-Code
2965 				set to 275 and the Command Flags' 'R' bit set, is sent by the access
2966 				device to inform the Diameter Server that an authenticated and/or
2967 				authorized session is being terminated.
2968 
2969 
2970         				   Message Format
2971 
2972 				 <STR> ::= < Diameter Header: 275, REQ, PXY >
2973         				   < Session-Id >
2974         				   { Origin-Host }
2975         				   { Origin-Realm }
2976         				   { Destination-Realm }
2977         				   { Auth-Application-Id }
2978         				   { Termination-Cause }
2979         				   [ User-Name ]
2980         				   [ Destination-Host ]
2981         				 * [ Class ]
2982         				   [ Origin-State-Id ]
2983         				 * [ Proxy-Info ]
2984         				 * [ Route-Record ]
2985         				 * [ AVP ]
2986 			*/
2987 			struct dict_object * cmd;
2988 			struct dict_cmd_data data = {
2989 					275, 					/* Code */
2990 					#if CC_SESSION_TERMINATION != 275
2991 					#error "CC_SESSION_TERMINATION definition mismatch"
2992 					#endif
2993 					"Session-Termination-Request", 		/* Name */
2994 					CMD_FLAG_REQUEST | CMD_FLAG_PROXIABLE | CMD_FLAG_ERROR,	/* Fixed flags */
2995 					CMD_FLAG_REQUEST | CMD_FLAG_PROXIABLE	/* Fixed flag values */
2996 					};
2997 			struct local_rules_definition rules[] =
2998 						{ 	 {  "Session-Id", 			RULE_FIXED_HEAD, -1, 1 }
2999 						 	,{  "Origin-Host", 			RULE_REQUIRED,   -1, 1 }
3000 							,{  "Origin-Realm",			RULE_REQUIRED,   -1, 1 }
3001 							,{  "Destination-Realm",		RULE_REQUIRED,   -1, 1 }
3002 						 	,{  "Auth-Application-Id", 		RULE_REQUIRED,   -1, 1 }
3003 						 	,{  "Termination-Cause", 		RULE_REQUIRED,   -1, 1 }
3004 							,{  "User-Name",			RULE_OPTIONAL,   -1, 1 }
3005 							,{  "Destination-Host",			RULE_OPTIONAL,   -1, 1 }
3006 							,{  "Class",				RULE_OPTIONAL,   -1,-1 }
3007 							,{  "Origin-State-Id",			RULE_OPTIONAL,   -1, 1 }
3008 							,{  "Proxy-Info",			RULE_OPTIONAL,   -1,-1 }
3009 							,{  "Route-Record",			RULE_OPTIONAL,   -1,-1 }
3010 						};
3011 
3012 			CHECK_dict_new( DICT_COMMAND, &data , NULL, &cmd);
3013 			PARSE_loc_rules( rules, cmd );
3014 		}
3015 
3016 		/* Session-Termination-Answer */
3017 		{
3018 			/*
3019 				The Session-Termination-Answer (STA), indicated by the Command-Code
3020 				set to 275 and the message flags' 'R' bit clear, is sent by the
3021 				Diameter Server to acknowledge the notification that the session has
3022 				been terminated.  The Result-Code AVP MUST be present, and MAY
3023 				contain an indication that an error occurred while servicing the STR.
3024 
3025 				Upon sending or receipt of the STA, the Diameter Server MUST release
3026 				all resources for the session indicated by the Session-Id AVP.  Any
3027 				intermediate server in the Proxy-Chain MAY also release any
3028 				resources, if necessary.
3029 
3030         				    Message Format
3031 
3032 				 <STA>  ::= < Diameter Header: 275, PXY >
3033         				    < Session-Id >
3034         				    { Result-Code }
3035         				    { Origin-Host }
3036         				    { Origin-Realm }
3037         				    [ User-Name ]
3038         				  * [ Class ]
3039         				    [ Error-Message ]
3040         				    [ Error-Reporting-Host ]
3041         				    [ Failed-AVP ]
3042         				    [ Origin-State-Id ]
3043         				  * [ Redirect-Host ]
3044         				    [ Redirect-Host-Usage ]
3045         				    [ Redirect-Max-Cache-Time ]
3046         				  * [ Proxy-Info ]
3047         				  * [ AVP ]
3048 			*/
3049 			struct dict_object * cmd;
3050 			struct dict_cmd_data data = {
3051 					275, 					/* Code */
3052 					#if CC_SESSION_TERMINATION != 275
3053 					#error "CC_SESSION_TERMINATION definition mismatch"
3054 					#endif
3055 					"Session-Termination-Answer", 		/* Name */
3056 					CMD_FLAG_REQUEST | CMD_FLAG_PROXIABLE,	/* Fixed flags */
3057 							   CMD_FLAG_PROXIABLE	/* Fixed flag values */
3058 					};
3059 			struct local_rules_definition rules[] =
3060 						{ 	 {  "Session-Id", 			RULE_FIXED_HEAD, -1, 1 }
3061  							,{  "Result-Code", 			RULE_REQUIRED,   -1, 1 }
3062 						 	,{  "Origin-Host", 			RULE_REQUIRED,   -1, 1 }
3063 							,{  "Origin-Realm",			RULE_REQUIRED,   -1, 1 }
3064 							,{  "User-Name",			RULE_OPTIONAL,   -1, 1 }
3065 							,{  "Class",				RULE_OPTIONAL,   -1,-1 }
3066 							,{  "Error-Message",			RULE_OPTIONAL,   -1, 1 }
3067 							,{  "Error-Reporting-Host",		RULE_OPTIONAL,   -1, 1 }
3068 							,{  "Failed-AVP",			RULE_OPTIONAL,   -1, 1 }
3069 							,{  "Origin-State-Id",			RULE_OPTIONAL,   -1, 1 }
3070 							,{  "Redirect-Host",			RULE_OPTIONAL,   -1,-1 }
3071 							,{  "Redirect-Host-Usage",		RULE_OPTIONAL,   -1, 1 }
3072 							,{  "Redirect-Max-Cache-Time",		RULE_OPTIONAL,   -1, 1 }
3073 							,{  "Proxy-Info",			RULE_OPTIONAL,   -1,-1 }
3074 						};
3075 
3076 			CHECK_dict_new( DICT_COMMAND, &data , NULL, &cmd);
3077 			PARSE_loc_rules( rules, cmd );
3078 		}
3079 
3080 		/* Abort-Session-Request */
3081 		{
3082 			/*
3083 				The Abort-Session-Request (ASR), indicated by the Command-Code set to
3084 				274 and the message flags' 'R' bit set, may be sent by any server to
3085 				the access device that is providing session service, to request that
3086 				the session identified by the Session-Id be stopped.
3087 
3088 
3089         				    Message Format
3090 
3091 				 <ASR>  ::= < Diameter Header: 274, REQ, PXY >
3092         				    < Session-Id >
3093         				    { Origin-Host }
3094         				    { Origin-Realm }
3095         				    { Destination-Realm }
3096         				    { Destination-Host }
3097         				    { Auth-Application-Id }
3098         				    [ User-Name ]
3099         				    [ Origin-State-Id ]
3100         				  * [ Proxy-Info ]
3101         				  * [ Route-Record ]
3102         				  * [ AVP ]
3103 			*/
3104 			struct dict_object * cmd;
3105 			struct dict_cmd_data data = {
3106 					274, 					/* Code */
3107 					#if CC_ABORT_SESSION != 274
3108 					#error "CC_ABORT_SESSION definition mismatch"
3109 					#endif
3110 					"Abort-Session-Request", 		/* Name */
3111 					CMD_FLAG_REQUEST | CMD_FLAG_PROXIABLE | CMD_FLAG_ERROR,	/* Fixed flags */
3112 					CMD_FLAG_REQUEST | CMD_FLAG_PROXIABLE	/* Fixed flag values */
3113 					};
3114 			struct local_rules_definition rules[] =
3115 						{ 	 {  "Session-Id", 			RULE_FIXED_HEAD, -1, 1 }
3116 						 	,{  "Origin-Host", 			RULE_REQUIRED,   -1, 1 }
3117 							,{  "Origin-Realm",			RULE_REQUIRED,   -1, 1 }
3118 							,{  "Destination-Realm",		RULE_REQUIRED,   -1, 1 }
3119 							,{  "Destination-Host",			RULE_REQUIRED,   -1, 1 }
3120 						 	,{  "Auth-Application-Id", 		RULE_REQUIRED,   -1, 1 }
3121 							,{  "User-Name",			RULE_OPTIONAL,   -1, 1 }
3122 							,{  "Origin-State-Id",			RULE_OPTIONAL,   -1, 1 }
3123 							,{  "Proxy-Info",			RULE_OPTIONAL,   -1,-1 }
3124 							,{  "Route-Record",			RULE_OPTIONAL,   -1,-1 }
3125 						};
3126 
3127 			CHECK_dict_new( DICT_COMMAND, &data , NULL, &cmd);
3128 			PARSE_loc_rules( rules, cmd );
3129 		}
3130 
3131 		/* Abort-Session-Answer */
3132 		{
3133 			/*
3134 				The Abort-Session-Answer (ASA), indicated by the Command-Code set to
3135 				274 and the message flags' 'R' bit clear, is sent in response to the
3136 				ASR.  The Result-Code AVP MUST be present, and indicates the
3137 				disposition of the request.
3138 
3139 				If the session identified by Session-Id in the ASR was successfully
3140 				terminated, Result-Code is set to DIAMETER_SUCCESS.  If the session
3141 				is not currently active, Result-Code is set to
3142 				DIAMETER_UNKNOWN_SESSION_ID.  If the access device does not stop the
3143 				session for any other reason, Result-Code is set to
3144 				DIAMETER_UNABLE_TO_COMPLY.
3145 
3146         				    Message Format
3147 
3148 				 <ASA>  ::= < Diameter Header: 274, PXY >
3149         				    < Session-Id >
3150         				    { Result-Code }
3151         				    { Origin-Host }
3152         				    { Origin-Realm }
3153         				    [ User-Name ]
3154         				    [ Origin-State-Id ]
3155         				    [ Error-Message ]
3156         				    [ Error-Reporting-Host ]
3157         				    [ Failed-AVP ]
3158         				  * [ Redirect-Host ]
3159         				    [ Redirect-Host-Usage ]
3160         				    [ Redirect-Max-Cache-Time ]
3161         				  * [ Proxy-Info ]
3162         				  * [ AVP ]
3163 			*/
3164 			struct dict_object * cmd;
3165 			struct dict_cmd_data data = {
3166 					274, 					/* Code */
3167 					#if CC_ABORT_SESSION != 274
3168 					#error "CC_ABORT_SESSION definition mismatch"
3169 					#endif
3170 					"Abort-Session-Answer", 		/* Name */
3171 					CMD_FLAG_REQUEST | CMD_FLAG_PROXIABLE,	/* Fixed flags */
3172 							   CMD_FLAG_PROXIABLE	/* Fixed flag values */
3173 					};
3174 			struct local_rules_definition rules[] =
3175 						{ 	 {  "Session-Id", 			RULE_FIXED_HEAD, -1, 1 }
3176  							,{  "Result-Code", 			RULE_REQUIRED,   -1, 1 }
3177 						 	,{  "Origin-Host", 			RULE_REQUIRED,   -1, 1 }
3178 							,{  "Origin-Realm",			RULE_REQUIRED,   -1, 1 }
3179 							,{  "User-Name",			RULE_OPTIONAL,   -1, 1 }
3180 							,{  "Origin-State-Id",			RULE_OPTIONAL,   -1, 1 }
3181 							,{  "Error-Message",			RULE_OPTIONAL,   -1, 1 }
3182 							,{  "Error-Reporting-Host",		RULE_OPTIONAL,   -1, 1 }
3183 							,{  "Failed-AVP",			RULE_OPTIONAL,   -1, 1 }
3184 							,{  "Redirect-Host",			RULE_OPTIONAL,   -1,-1 }
3185 							,{  "Redirect-Host-Usage",		RULE_OPTIONAL,   -1, 1 }
3186 							,{  "Redirect-Max-Cache-Time",		RULE_OPTIONAL,   -1, 1 }
3187 							,{  "Proxy-Info",			RULE_OPTIONAL,   -1,-1 }
3188 						};
3189 
3190 			CHECK_dict_new( DICT_COMMAND, &data , NULL, &cmd);
3191 			PARSE_loc_rules( rules, cmd );
3192 		}
3193 
3194 		/* Accounting-Request */
3195 		{
3196 			/*
3197 				The Accounting-Request (ACR) command, indicated by the Command-Code
3198 				field set to 271 and the Command Flags' 'R' bit set, is sent by a
3199 				Diameter node, acting as a client, in order to exchange accounting
3200 				information with a peer.
3201 
3202 				One of Acct-Application-Id and Vendor-Specific-Application-Id AVPs
3203 				MUST be present.  If the Vendor-Specific-Application-Id grouped AVP
3204 				is present, it MUST include an Acct-Application-Id AVP.
3205 
3206 				The AVP listed below SHOULD include service specific accounting AVPs,
3207 				as described in Section 9.3.
3208 
3209 
3210 				Message Format
3211 
3212 				 <ACR> ::= < Diameter Header: 271, REQ, PXY >
3213         				   < Session-Id >
3214         				   { Origin-Host }
3215         				   { Origin-Realm }
3216         				   { Destination-Realm }
3217         				   { Accounting-Record-Type }
3218         				   { Accounting-Record-Number }
3219         				   [ Acct-Application-Id ]
3220         				   [ Vendor-Specific-Application-Id ]
3221         				   [ User-Name ]
3222         				   [ Destination-Host ]
3223         				   [ Accounting-Sub-Session-Id ]
3224         				   [ Acct-Session-Id ]
3225         				   [ Acct-Multi-Session-Id ]
3226         				   [ Acct-Interim-Interval ]
3227         				   [ Accounting-Realtime-Required ]
3228         				   [ Origin-State-Id ]
3229         				   [ Event-Timestamp ]
3230         				 * [ Proxy-Info ]
3231         				 * [ Route-Record ]
3232         				 * [ AVP ]
3233 			*/
3234 			struct dict_object * cmd;
3235 			struct dict_cmd_data data = {
3236 					271, 					/* Code */
3237 					#if CC_ACCOUNTING != 271
3238 					#error "CC_ACCOUNTING definition mismatch"
3239 					#endif
3240 					"Accounting-Request", 			/* Name */
3241 					CMD_FLAG_REQUEST | CMD_FLAG_PROXIABLE | CMD_FLAG_ERROR,	/* Fixed flags */
3242 					CMD_FLAG_REQUEST | CMD_FLAG_PROXIABLE	/* Fixed flag values */
3243 					};
3244 			struct local_rules_definition rules[] =
3245 						{ 	 {  "Session-Id", 			RULE_FIXED_HEAD, -1, 1 }
3246 						 	,{  "Origin-Host", 			RULE_REQUIRED,   -1, 1 }
3247 							,{  "Origin-Realm",			RULE_REQUIRED,   -1, 1 }
3248 							,{  "Destination-Realm",		RULE_REQUIRED,   -1, 1 }
3249 							,{  "Accounting-Record-Type",		RULE_REQUIRED,   -1, 1 }
3250 							,{  "Accounting-Record-Number",		RULE_REQUIRED,   -1, 1 }
3251 							,{  "Acct-Application-Id",		RULE_OPTIONAL,   -1, 1 }
3252 							,{  "Vendor-Specific-Application-Id",	RULE_OPTIONAL,   -1, 1 }
3253 							,{  "User-Name",			RULE_OPTIONAL,   -1, 1 }
3254 							,{  "Destination-Host",			RULE_OPTIONAL,   -1, 1 }
3255 							,{  "Accounting-Sub-Session-Id",	RULE_OPTIONAL,   -1, 1 }
3256 							,{  "Acct-Session-Id",			RULE_OPTIONAL,   -1, 1 }
3257 							,{  "Acct-Multi-Session-Id",		RULE_OPTIONAL,   -1, 1 }
3258 							,{  "Acct-Interim-Interval",		RULE_OPTIONAL,   -1, 1 }
3259 							,{  "Accounting-Realtime-Required",	RULE_OPTIONAL,   -1, 1 }
3260 							,{  "Origin-State-Id",			RULE_OPTIONAL,   -1, 1 }
3261 							,{  "Event-Timestamp",			RULE_OPTIONAL,   -1, 1 }
3262 							,{  "Proxy-Info",			RULE_OPTIONAL,   -1,-1 }
3263 							,{  "Route-Record",			RULE_OPTIONAL,   -1,-1 }
3264 						};
3265 
3266 			CHECK_dict_new( DICT_COMMAND, &data , NULL, &cmd);
3267 			PARSE_loc_rules( rules, cmd );
3268 		}
3269 
3270 		/* Accounting-Answer */
3271 		{
3272 			/*
3273 				The Accounting-Answer (ACA) command, indicated by the Command-Code
3274 				field set to 271 and the Command Flags' 'R' bit cleared, is used to
3275 				acknowledge an Accounting-Request command.  The Accounting-Answer
3276 				command contains the same Session-Id as the corresponding request.
3277 
3278 				Only the target Diameter Server, known as the home Diameter Server,
3279 				SHOULD respond with the Accounting-Answer command.
3280 
3281 				One of Acct-Application-Id and Vendor-Specific-Application-Id AVPs
3282 				MUST be present.  If the Vendor-Specific-Application-Id grouped AVP
3283 				is present, it MUST contain an Acct-Application-Id AVP.
3284 
3285 				The AVP listed below SHOULD include service specific accounting AVPs,
3286 				as described in Section 9.3.
3287 
3288 
3289 				Message Format
3290 
3291 				 <ACA> ::= < Diameter Header: 271, PXY >
3292         				   < Session-Id >
3293         				   { Result-Code }
3294         				   { Origin-Host }
3295         				   { Origin-Realm }
3296         				   { Accounting-Record-Type }
3297         				   { Accounting-Record-Number }
3298         				   [ Acct-Application-Id ]
3299         				   [ Vendor-Specific-Application-Id ]
3300         				   [ User-Name ]
3301         				   [ Accounting-Sub-Session-Id ]
3302         				   [ Acct-Session-Id ]
3303         				   [ Acct-Multi-Session-Id ]
3304         				   [ Error-Message ]
3305         				   [ Error-Reporting-Host ]
3306         				   [ Failed-AVP ]
3307         				   [ Acct-Interim-Interval ]
3308         				   [ Accounting-Realtime-Required ]
3309         				   [ Origin-State-Id ]
3310         				   [ Event-Timestamp ]
3311         				 * [ Proxy-Info ]
3312         				 * [ AVP ]
3313 			*/
3314 			struct dict_object * cmd;
3315 			struct dict_cmd_data data = {
3316 					271, 					/* Code */
3317 					#if CC_ACCOUNTING != 271
3318 					#error "CC_ACCOUNTING definition mismatch"
3319 					#endif
3320 					"Accounting-Answer", 			/* Name */
3321 					CMD_FLAG_REQUEST | CMD_FLAG_PROXIABLE,	/* Fixed flags */
3322 							   CMD_FLAG_PROXIABLE	/* Fixed flag values */
3323 					};
3324 			struct local_rules_definition rules[] =
3325 						{ 	 {  "Session-Id", 			RULE_FIXED_HEAD, -1, 1 }
3326  							,{  "Result-Code", 			RULE_REQUIRED,   -1, 1 }
3327 						 	,{  "Origin-Host", 			RULE_REQUIRED,   -1, 1 }
3328 							,{  "Origin-Realm",			RULE_REQUIRED,   -1, 1 }
3329 							,{  "Accounting-Record-Type",		RULE_REQUIRED,   -1, 1 }
3330 							,{  "Accounting-Record-Number",		RULE_REQUIRED,   -1, 1 }
3331 							,{  "Acct-Application-Id",		RULE_OPTIONAL,   -1, 1 }
3332 							,{  "Vendor-Specific-Application-Id",	RULE_OPTIONAL,   -1, 1 }
3333 							,{  "User-Name",			RULE_OPTIONAL,   -1, 1 }
3334 							,{  "Accounting-Sub-Session-Id",	RULE_OPTIONAL,   -1, 1 }
3335 							,{  "Acct-Session-Id",			RULE_OPTIONAL,   -1, 1 }
3336 							,{  "Acct-Multi-Session-Id",		RULE_OPTIONAL,   -1, 1 }
3337 							,{  "Error-Message",			RULE_OPTIONAL,   -1, 1 }
3338 							,{  "Error-Reporting-Host",		RULE_OPTIONAL,   -1, 1 }
3339 							,{  "Failed-AVP",			RULE_OPTIONAL,   -1, 1 }
3340 							,{  "Acct-Interim-Interval",		RULE_OPTIONAL,   -1, 1 }
3341 							,{  "Accounting-Realtime-Required",	RULE_OPTIONAL,   -1, 1 }
3342 							,{  "Origin-State-Id",			RULE_OPTIONAL,   -1, 1 }
3343 							,{  "Event-Timestamp",			RULE_OPTIONAL,   -1, 1 }
3344 							,{  "Proxy-Info",			RULE_OPTIONAL,   -1,-1 }
3345 						};
3346 
3347 			CHECK_dict_new( DICT_COMMAND, &data , NULL, &cmd);
3348 			PARSE_loc_rules( rules, cmd );
3349 		}
3350 	}
3351 
3352 	return 0;
3353 }
3354