dict_mip6a.c 33 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/*********************************************************************************************************
* Software License Agreement (BSD License)                                                               *
* Author: Francois Bard <francois@tera.ics.keio.ac.jp>							 *
*													 *
* Copyright (c) 2010, Teraoka Laboratory, Keio University						 *
* All rights reserved.											 *
* 													 *
* Redistribution and use of this software in source and binary forms, with or without modification, are  *
* permitted provided that the following conditions are met:						 *
* 													 *
* * Redistributions of source code must retain the above 						 *
*   copyright notice, this list of conditions and the 							 *
*   following disclaimer.										 *
*    													 *
* * Redistributions in binary form must reproduce the above 						 *
*   copyright notice, this list of conditions and the 							 *
*   following disclaimer in the documentation and/or other						 *
*   materials provided with the distribution.								 *
* 													 *
* * Neither the name of the Teraoka Laboratory nor the 							 *
*   names of its contributors may be used to endorse or 						 *
*   promote products derived from this software without 						 *
*   specific prior written permission of Teraoka Laboratory 						 *
*   													 *
* 													 *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED *
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR *
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 	 *
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 	 *
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR *
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF   *
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.								 *
*********************************************************************************************************/

36
37
/*

38
39
40
41
42
43
44
The following table complete the one in RFC 5778, page 18. The AVPs are implemented below following the order of this table.
We try to keep the structure of the grouped AVP by declaring the contained AVPs just before the grouped AVP they depend on.
The number of '+' indicates the depth of the contained AVP.

DEPTH	NAME					AVP	RFC		TYPE			NOTES

	MIP6-Feature-Vector			124	5447		Unsigned64
45
	User-Name				1	3588		UTF8String
46
47
48
	Service-Selection			493	5778		UTF8String
	MIP-MN-AAA-SPI				341	5778		Unsigned32
+	MIP-Home-Agent-Address			334	4004		Address
49
50
++	Destination-Host			293	3588		DiameterIdentity
++	Destination-Realm			283	3588		DiameterIdentity
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
+	MIP-Home-Agent-Host			348	4004		Grouped
+	MIP6-Home-Link-Prefix			125	5447		OctetString
	MIP6-Agent-Info				486	5447		Grouped
+	MIP-Replay-Mode				346	4004		Enumerated
+	MIP-Algorithm-Type			345	4004		Enumerated
+	MIP-MN-HA-SPI				491	5778		Unsigned32
+	MIP-MSA-Lifetime			367	4004		Unsigned32
+	MIP-Session-Key				343	4004		OctetString
	MIP-MN-HA-MSA				492	5778		Grouped			different from MIP-MN-to-HA-MSA (331)
	MIP-Mobile-Node-Address			333	4004		Address
	MIP-Careof-Address			487	5778		Address
	MIP-Authenticator			488	5778		OctetString
	MIP-MAC-Mobility-Data			489	5778		OctetString
	MIP-Timestamp				490	5778		OctetString
	Chargeable-User-Identity		89	5778		OctetString
	MIP6-Auth-Mode				494	5778		Enumerated

QoS AVPs (RFC 5777 - implemented in the corresponding dictionary)

	QoS-Capability				578	5777		Grouped
	QoS-Resources				508	5777		Grouped

ACCOUNTING AVPs (section 6.21)

	Accounting-Input-Octets			363	4004, 4005	Unsigned64
	Accounting-Output-Octets		364	4004, 4005	Unsigned64
	Accounting-Input-Packets		365	4004, 4005	Unsigned64
	Accounting-Output-Packets		366	4004, 4005	Unsigned64
79
	Acct-Multi-Session-Id			50	3588		UTF8String
80
81
82
83
84
85
86
87
88
89
	Acct-Session-Time			46	2866, 4004	Unsigned32
	MIP6-Feature-Vector			----------------------------------
	MIP-Mobile-Node-Address			----------------------------------
	MIP-Agent-Info				----------------------------------
	Chargeable-User-Identity		----------------------------------
	Service-Selection			----------------------------------
	QoS-Resources				----------------------------------
	QoS-Capability				----------------------------------
	MIP-Careof-Address			----------------------------------

90
91
92
93
94
95
96
97
98
99
100
RADIUS AVPs (contained in the MIR/MIA)

	NAS-Identifier				32	2865		radius (see avp)
	NAS-IP-Address				4	2865            radius (see avp)
	NAS-IPv6-Address			95	3162            radius (see avp)
	NAS-Port-Type				61	2865            radius (see avp)
	Called-Station-Id			30	2865            radius (see avp)
	Calling-Station-Id			31	2865            radius (see avp)


*/
101
102
103
104
105

/****************************************************************************************************************************************
*																	*
* This table is a copy of the registry named "MIP6 Authentication Mode Registry" and managed by IANA.					*
* source : http://www.iana.org/assignments/aaa-parameters/aaa-parameters.txt								*
106
* up to date on october 2010														*
107
108
109
110
111
112
113
114
115
116
117
*																	*
*      Value          Token       Reference												*
*        0       Reserved         [RFC5778]												*
*        1       MIP6_AUTH_MN_AAA [RFC5778]												*
*   2-4294967295 Unassigned														*
*																	*
****************************************************************************************************************************************/


/*

118
NOTES
119

120
check for omissions !
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178

*/

#include <freeDiameter/extension.h>

#define CHECK_dict_new( _type, _data, _parent, _ref )	\
	CHECK_FCT(  fd_dict_new( fd_g_config->cnf_dict, (_type), (_data), (_parent), (_ref))  );

#define CHECK_dict_search( _type, _criteria, _what, _result )	\
	CHECK_FCT(  fd_dict_search( fd_g_config->cnf_dict, (_type), (_criteria), (_what), (_result), ENOENT) );

struct local_rules_definition {
	char 			*avp_name;
	enum rule_position	position;
	int 			min;
	int			max;
};

#define RULE_ORDER( _position ) ((((_position) == RULE_FIXED_HEAD) || ((_position) == RULE_FIXED_TAIL)) ? 1 : 0 )

#define PARSE_loc_rules( _rulearray, _parent) {								\
	int __ar;											\
	for (__ar=0; __ar < sizeof(_rulearray) / sizeof((_rulearray)[0]); __ar++) {			\
		struct dict_rule_data __data = { NULL, 							\
			(_rulearray)[__ar].position,							\
			0, 										\
			(_rulearray)[__ar].min,								\
			(_rulearray)[__ar].max};							\
		__data.rule_order = RULE_ORDER(__data.rule_position);					\
		CHECK_FCT(  fd_dict_search( 								\
			fd_g_config->cnf_dict,								\
			DICT_AVP, 									\
			AVP_BY_NAME, 									\
			(_rulearray)[__ar].avp_name, 							\
			&__data.rule_avp, 0 ) );							\
		if ( !__data.rule_avp ) {								\
			TRACE_DEBUG(INFO, "AVP Not found: '%s'", (_rulearray)[__ar].avp_name );		\
			return ENOENT;									\
		}											\
		CHECK_FCT_DO( fd_dict_new( fd_g_config->cnf_dict, DICT_RULE, &__data, _parent, NULL),	\
			{							        		\
				TRACE_DEBUG(INFO, "Error on rule with AVP '%s'",      			\
					 (_rulearray)[__ar].avp_name );		      			\
				return EINVAL;					      			\
			} );							      			\
	}									      			\
}

#define enumval_def_u32( _val_, _str_ ) \
		{ _str_, 		{ .u32 = _val_ }}

#define enumval_def_os( _len_, _val_, _str_ ) \
		{ _str_, 		{ .os = { .data = (unsigned char *)_val_, .len = _len_ }}}



/* Defines if there are any */

179
//New Result-Code for MIP (RFC5778, Section 7.*)
180
181
#define DIAMETER_SUCCESS_RELOCATE_HA 2009
#define DIAMETER_ERROR_MIP6_AUTH_MODE 5041
182
183

//Others
184
185
186
187
#define MIP6_AUTH_MN_AAA 1

/* Dictionary */

188
int dict_mip6a_init(char * conffile)
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
{
	struct dict_object * mip6a;
	{
		struct dict_application_data data  = { 	8, "Diameter Mobile IPv6 Auth (MIP6A) Application" };
		CHECK_dict_new( DICT_APPLICATION, &data , NULL, &mip6a);
	}

	/***************/
	/* AVP section */
	/***************/
	{
		/* Loading all the derived data formats */

		struct dict_object * Address_type;
		struct dict_object * UTF8String_type;
		struct dict_object * DiameterIdentity_type;
		struct dict_object * DiameterURI_type;
		struct dict_object * Time_type;
		
		CHECK_dict_search( DICT_TYPE, TYPE_BY_NAME, "Address", &Address_type);
		CHECK_dict_search( DICT_TYPE, TYPE_BY_NAME, "UTF8String", &UTF8String_type);
		CHECK_dict_search( DICT_TYPE, TYPE_BY_NAME, "DiameterIdentity", &DiameterIdentity_type);
		CHECK_dict_search( DICT_TYPE, TYPE_BY_NAME, "DiameterURI", &DiameterURI_type);
		CHECK_dict_search( DICT_TYPE, TYPE_BY_NAME, "Time", &Time_type);

	///////////////////////////////////////////
	/* AVPs for Mobile IPv6 Auth Application */
	///////////////////////////////////////////

		/* MIP6-Feature-Vector - RFC 5447 */
		{
			/*

			*/

			struct dict_avp_data data = { 
					124, 					/* Code */
					0, 					/* Vendor */
					"MIP6-Feature-Vector", 			/* Name */
					AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, 	/* Fixed flags */
					AVP_FLAG_MANDATORY,		 	/* Fixed flag values */
					AVP_TYPE_UNSIGNED64			/* base type of data */
					};
			
			CHECK_dict_new( DICT_AVP, &data , NULL, NULL);
		}

		/* User-Name - RFC 3588 */

			/*
			Implemented in the base protocol
			*/

		/* Service-Selection - RFC 5778 */
		{
			/*

			*/

			struct dict_avp_data data = {
					493, 					/* Code */
					0, 					/* Vendor */
					"Service-Selection",			/* Name */
					AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, 	/* Fixed flags */
					AVP_FLAG_MANDATORY,		 	/* Fixed flag values */
					AVP_TYPE_OCTETSTRING 			/* base type of data */
					};

			CHECK_dict_new( DICT_AVP, &data , UTF8String_type, NULL);
		}

		/* MIP-MN-AAA-SPI - RFC 5778 */
		{
			/*

			*/

			struct dict_avp_data data = {
					341, 					/* Code */
					0, 					/* Vendor */
					"MIP-MN-AAA-SPI",			/* Name */
					AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, 	/* Fixed flags */
					AVP_FLAG_MANDATORY,		 	/* Fixed flag values */
					AVP_TYPE_UNSIGNED32 			/* base type of data */
					};

			CHECK_dict_new( DICT_AVP, &data , NULL, NULL);
		}

		/* Destination-Host - Base Protocol */

			/*
			Implemented in the base protocol
			*/

		/* Destination-Realm - Base Protocol */

			/*
			Implemented in the base protocol
			*/

		/* MIP-Home-Agent-Address - RFC 4004 */
		{
			/*

			*/

			struct dict_avp_data data = {
					334, 					/* Code */
					0, 					/* Vendor */
					"MIP-Home-Agent-Address",		/* Name */
					AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, 	/* Fixed flags */
					AVP_FLAG_MANDATORY,		 	/* Fixed flag values */
					AVP_TYPE_OCTETSTRING			/* base type of data */
					};

			CHECK_dict_new( DICT_AVP, &data , Address_type, NULL);
		}

		/* MIP-Home-Agent-Host - RFC 4004 */
		{
			/*

			*/
			struct dict_object * avp;
			struct dict_avp_data data = {
					348, 					/* Code */
					0, 					/* Vendor */
					"MIP-Home-Agent-Host",			/* Name */
					AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, 	/* Fixed flags */
					AVP_FLAG_MANDATORY,		 	/* Fixed flag values */
					AVP_TYPE_GROUPED 			/* base type of data */
					};

			struct local_rules_definition rules[] =
						{ 	 {  "Destination-Realm",	RULE_REQUIRED,	-1, 1 }
							,{  "Destination-Host",		RULE_REQUIRED,	-1, 1 }
						};

			CHECK_dict_new( DICT_AVP, &data , NULL, &avp);
			PARSE_loc_rules( rules, avp );
		}

		/* MIP6-Home-Link-Prefix - RFC 5447 */
		{
			/*

			*/

			struct dict_avp_data data = {
					125, 					/* Code */
					0, 					/* Vendor */
					"MIP6-Home-Link-Prefix", 		/* Name */
					AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, 	/* Fixed flags */
					AVP_FLAG_MANDATORY,		 	/* Fixed flag values */
					AVP_TYPE_OCTETSTRING			/* base type of data */
					};

			CHECK_dict_new( DICT_AVP, &data , NULL, NULL);
		}

		/* MIP6-Agent-Info - RFC 5447*/
		{
			/*
			
			*/
			struct dict_object * avp;
			struct dict_avp_data data = { 
					486, 					/* Code */
					0, 					/* Vendor */
					"MIP6-Agent-Info",			/* Name */
					AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, 	/* Fixed flags */
					AVP_FLAG_MANDATORY,		 	/* Fixed flag values */
					AVP_TYPE_GROUPED 			/* base type of data */
					};

			struct local_rules_definition rules[] = 
						{ 	 {  "MIP-Home-Agent-Address", 		RULE_OPTIONAL, -1, 2 }
							,{  "MIP-Home-Agent-Host",		RULE_OPTIONAL, -1, 1 }
							,{  "MIP6-Home-Link-Prefix",		RULE_OPTIONAL, -1, 1 }
						};
			
			CHECK_dict_new( DICT_AVP, &data , NULL, &avp);
			PARSE_loc_rules( rules, avp );
		}

		/* MIP-Replay-Mode - RFC 5778 & 4004 */
		{
			/*

			*/
			struct dict_object * 	 type;
			struct dict_type_data 	 tdata = { AVP_TYPE_INTEGER32, "Enumerated(MIP-Replay-Mode)", NULL, NULL, NULL };
			struct dict_enumval_data t_0 = { "None", 	{ .i32 = 1 }};
			struct dict_enumval_data t_1 = { "Timestamp", 	{ .i32 = 2 }};
			struct dict_avp_data data = {
					346, 					/* Code */
					0, 					/* Vendor */
					"MIP-Replay-Mode",			/* Name */
					AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, 	/* Fixed flags */
					AVP_FLAG_MANDATORY,		 	/* Fixed flag values */
					AVP_TYPE_INTEGER32 			/* base type of data */
					};

			/* Create the Enumerated type, and then the AVP */
			CHECK_dict_new( DICT_TYPE, &tdata , NULL, &type);
			CHECK_dict_new( DICT_ENUMVAL, &t_0 , type, NULL);
			CHECK_dict_new( DICT_ENUMVAL, &t_1 , type, NULL);
			CHECK_dict_new( DICT_AVP, &data , type, NULL);
		}

		/* MIP-Algorithm-Type - RFC 5778 & 4004 */
		{
			/*

			*/
			struct dict_object * 	 type;
			struct dict_type_data 	 tdata = { AVP_TYPE_INTEGER32, "Enumerated(MIP-Algorithm-Type)", NULL, NULL, NULL };
			struct dict_enumval_data t_2 = { "HMAC-SHA-1", { .i32 = 2 }};
			struct dict_avp_data data = {
					345, 					/* Code */
					0, 					/* Vendor */
					"MIP-Algorithm-Type",			/* Name */
					AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, 	/* Fixed flags */
					AVP_FLAG_MANDATORY,		 	/* Fixed flag values */
					AVP_TYPE_INTEGER32 			/* base type of data */
					};

			/* Create the Enumerated type, and then the AVP */
			CHECK_dict_new( DICT_TYPE, &tdata , NULL, &type);
			CHECK_dict_new( DICT_ENUMVAL, &t_2 , type, NULL);
			CHECK_dict_new( DICT_AVP, &data , type, NULL);
		}

		/* MIP-MN-HA-SPI - RFC 5778 */
		{
			/*

			*/
			struct dict_avp_data data = {
					491, 					/* Code */
					0, 					/* Vendor */
					"MIP-MN-HA-SPI",			/* Name */
					AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, 	/* Fixed flags */
					AVP_FLAG_MANDATORY,		 	/* Fixed flag values */
					AVP_TYPE_UNSIGNED32 			/* base type of data */
					};

			CHECK_dict_new( DICT_AVP, &data , NULL, NULL);
		}

		/* MIP-MSA-Lifetime - RFC 4004 */
		{
			/*

			*/
			struct dict_avp_data data = {
					367, 					/* Code */
					0, 					/* Vendor */
					"MIP-MSA-Lifetime",			/* Name */
					AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, 	/* Fixed flags */
					AVP_FLAG_MANDATORY,		 	/* Fixed flag values */
					AVP_TYPE_UNSIGNED32 			/* base type of data */
					};

			CHECK_dict_new( DICT_AVP, &data , NULL, NULL);
		}

		/* MIP-Session-Key - RFC 5778 */
		{
			/*

			*/
			struct dict_avp_data data = {
					343, 					/* Code */
					0, 					/* Vendor */
					"MIP-Session-Key",			/* Name */
					AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, 	/* Fixed flags */
					AVP_FLAG_MANDATORY,		 	/* Fixed flag values */
					AVP_TYPE_OCTETSTRING 			/* base type of data */
					};

			CHECK_dict_new( DICT_AVP, &data , NULL, NULL);
		}

		/* MIP-MN-HA-MSA - RFC 5778 */
		{
			/*
			
			*/
			struct dict_object * avp;
			struct dict_avp_data data = { 
					492, 					/* Code */
					0, 					/* Vendor */
					"MIP-MN-HA-MSA",			/* Name */
					AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, 	/* Fixed flags */
					AVP_FLAG_MANDATORY,		 	/* Fixed flag values */
					AVP_TYPE_GROUPED 			/* base type of data */
					};

			struct local_rules_definition rules[] = 
						{ 	 {  "MIP-Session-Key", 		RULE_REQUIRED, -1, 1 }
							,{  "MIP-MSA-Lifetime", 	RULE_REQUIRED, -1, 1 }
							,{  "MIP-MN-HA-SPI", 		RULE_OPTIONAL, -1, 1 }
							,{  "MIP-Algorithm-Type", 	RULE_OPTIONAL, -1, 1 }
							,{  "MIP-Replay-Mode", 		RULE_OPTIONAL, -1, 1 }
						};

			CHECK_dict_new( DICT_AVP, &data , NULL, &avp);
			PARSE_loc_rules( rules, avp );
		}

		/* MIP-Mobile-Node-Address - RFC 4004 */
		{
			/*

			*/

			struct dict_avp_data data = {
					333, 					/* Code */
					0, 					/* Vendor */
					"MIP-Mobile-Node-Address",		/* Name */
					AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, 	/* Fixed flags */
					AVP_FLAG_MANDATORY,		 	/* Fixed flag values */
					AVP_TYPE_OCTETSTRING			/* base type of data */
					};

			CHECK_dict_new( DICT_AVP, &data , Address_type, NULL);
		}

		/* MIP-Careof-Address - RFC 5778 */
		{
			/*

			*/
			struct dict_avp_data data = {
					487, 					/* Code */
					0, 					/* Vendor */
					"MIP-Careof-Address",			/* Name */
					AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, 	/* Fixed flags */
					AVP_FLAG_MANDATORY,		 	/* Fixed flag values */
					AVP_TYPE_OCTETSTRING 			/* base type of data */
					};

			CHECK_dict_new( DICT_AVP, &data , Address_type, NULL);
		}

		/* MIP-Authenticator - RFC 5778 */
		{
			/*
			
			*/
			struct dict_avp_data data = { 
					488, 					/* Code */
					0, 					/* Vendor */
					"MIP-Authenticator",			/* Name */
					AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, 	/* Fixed flags */
					AVP_FLAG_MANDATORY,		 	/* Fixed flag values */
					AVP_TYPE_OCTETSTRING 			/* base type of data */
					};

			CHECK_dict_new( DICT_AVP, &data , NULL, NULL);
		}

		/* MIP-MAC-Mobility-Data - RFC 5778 */
		{
			/*
			
			*/
			struct dict_avp_data data = { 
					489, 					/* Code */
					0, 					/* Vendor */
					"MIP-MAC-Mobility-Data",		/* Name */
					AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, 	/* Fixed flags */
					AVP_FLAG_MANDATORY,		 	/* Fixed flag values */
					AVP_TYPE_OCTETSTRING 			/* base type of data */
					};

			CHECK_dict_new( DICT_AVP, &data , NULL, NULL);
		}

		/* MIP-Timestamp - RFC 5778 */
		{
			/*
			
			*/
			struct dict_avp_data data = { 
					490, 					/* Code */
					0, 					/* Vendor */
					"MIP-Timestamp",			/* Name */
					AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, 	/* Fixed flags */
					AVP_FLAG_MANDATORY,		 	/* Fixed flag values */
					AVP_TYPE_OCTETSTRING 			/* base type of data */
					};

			CHECK_dict_new( DICT_AVP, &data , NULL, NULL);
		}

		/* Chargeable-User-Identity - RFC 5778 */
		{
			/*
			
			*/
			struct dict_avp_data data = { 
					89, 					/* Code */
					0, 					/* Vendor */
					"Chargeable-User-Identity",		/* Name */
					AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, 	/* Fixed flags */
					AVP_FLAG_MANDATORY,		 	/* Fixed flag values */
					AVP_TYPE_OCTETSTRING 			/* base type of data */
					};

			CHECK_dict_new( DICT_AVP, &data , NULL, NULL);
		}

		/* MIP6-Auth-Mode - RFC 5778 */
		{
			/*
			
			*/
			struct dict_object * 	 type;
			struct dict_type_data 	 tdata = { AVP_TYPE_INTEGER32, "Enumerated(MIP6-Auth-Mode)", NULL, NULL, NULL };
			struct dict_enumval_data t_0 = { "None", 	{ .i32 = MIP6_AUTH_MN_AAA }};
			struct dict_avp_data data = { 
					494, 					/* Code */
					0, 					/* Vendor */
					"MIP6-Auth-Mode",			/* Name */
					AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, 	/* Fixed flags */
					AVP_FLAG_MANDATORY,		 	/* Fixed flag values */
					AVP_TYPE_INTEGER32 			/* base type of data */
					};

			/* Create the Enumerated type, and then the AVP */
			CHECK_dict_new( DICT_TYPE, &tdata , NULL, &type);
			CHECK_dict_new( DICT_ENUMVAL, &t_0 , type, NULL);
			CHECK_dict_new( DICT_AVP, &data , type, NULL);
		}

	//////////////
	/* QoS AVPs */
	//////////////

		/* QoS-Capability */

			/*
			Implemented in RFC 5777
			*/

		/* QoS-Resources */

			/*
			Implemented in RFC 5777
			*/

	/////////////////////
	/* Accounting AVPs */
	/////////////////////

		/* Accounting-Input-Octets - RFC 4004 */
		{
			/*

			*/
			struct dict_avp_data data = {
					363, 					/* Code */
					0, 					/* Vendor */
					"Accounting-Input-Octets",		/* Name */
					AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, 	/* Fixed flags */
					AVP_FLAG_MANDATORY,		 	/* Fixed flag values */
					AVP_TYPE_UNSIGNED64 			/* base type of data */
					};

			CHECK_dict_new( DICT_AVP, &data , NULL, NULL);
		}

		/* Accounting-Output-Octets - RFC 4004 */
		{
			/*

			*/
			struct dict_avp_data data = {
					364, 					/* Code */
					0, 					/* Vendor */
					"Accounting-Output-Octets",		/* Name */
					AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, 	/* Fixed flags */
					AVP_FLAG_MANDATORY,		 	/* Fixed flag values */
					AVP_TYPE_UNSIGNED64 			/* base type of data */
					};

			CHECK_dict_new( DICT_AVP, &data , NULL, NULL);
		}

		/* Accounting-Input-Packets - RFC 4004 */
		{
			/*

			*/
			struct dict_avp_data data = {
					365, 					/* Code */
					0, 					/* Vendor */
					"Accounting-Input-Packets",		/* Name */
					AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, 	/* Fixed flags */
					AVP_FLAG_MANDATORY,		 	/* Fixed flag values */
					AVP_TYPE_UNSIGNED64 			/* base type of data */
					};

			CHECK_dict_new( DICT_AVP, &data , NULL, NULL);
		}

		/* Accounting-Output-Packets - RFC 4004 */
		{
			/*

			*/
			struct dict_avp_data data = {
					366, 					/* Code */
					0, 					/* Vendor */
					"Accounting-Output-Packets",		/* Name */
					AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, 	/* Fixed flags */
					AVP_FLAG_MANDATORY,		 	/* Fixed flag values */
					AVP_TYPE_UNSIGNED64 			/* base type of data */
					};

			CHECK_dict_new( DICT_AVP, &data , NULL, NULL);
		}

		/* Acct-Multi-Session-Id - RFC 3588 */

			/*
			Implemented in the base protocol
			*/

		/* Acct-Session-Time - RFC 4004 */
		{
			/*

			*/
			struct dict_avp_data data = {
					46, 					/* Code */
					0, 					/* Vendor */
					"Acct-Session-Time",			/* Name */
					AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, 	/* Fixed flags */
					AVP_FLAG_MANDATORY,		 	/* Fixed flag values */
					AVP_TYPE_UNSIGNED32 			/* base type of data */
					};

			CHECK_dict_new( DICT_AVP, &data , NULL, NULL);
		}

	/////////////////////////////////////
	/* Radius AVPs - used in MIR & MIA */
	/////////////////////////////////////

742
743
	/*
	We used the following correspondences for determining the type of the Radius AVPs
744

745
		Radius		Diameter
746

747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
		text		UTF8Sting
		string		OctetString
		address		Address
		integer		Unsigned32
		time		Time
	*/


		/* NAS-Identifier				32	3575 */
		{
			/*
			string -> OctetString
			*/

			struct dict_avp_data data = {
					32, 					/* Code */
					0, 					/* Vendor */
					"NAS-Identifier",			/* Name */
					AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, 	/* Fixed flags */
					AVP_FLAG_MANDATORY,		 	/* Fixed flag values */
					AVP_TYPE_OCTETSTRING			/* base type of data */
					};

			CHECK_dict_new( DICT_AVP, &data , NULL, NULL);
		}

		/* NAS-IP-Address				4	3575 */
		{
			/*
			address -> Address
			*/

			struct dict_avp_data data = {
					4, 					/* Code */
					0, 					/* Vendor */
					"NAS-IP-Address",			/* Name */
					AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, 	/* Fixed flags */
					AVP_FLAG_MANDATORY,		 	/* Fixed flag values */
					AVP_TYPE_OCTETSTRING			/* base type of data */
					};

			CHECK_dict_new( DICT_AVP, &data , Address_type, NULL);
		}

		/* NAS-IPv6-Address			95	3162 */
		{
			/*
			address -> Address
			*/

			struct dict_avp_data data = {
					95, 					/* Code */
					0, 					/* Vendor */
					"NAS-IPv6-Address",			/* Name */
					AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, 	/* Fixed flags */
					AVP_FLAG_MANDATORY,		 	/* Fixed flag values */
					AVP_TYPE_OCTETSTRING			/* base type of data */
					};

			CHECK_dict_new( DICT_AVP, &data , Address_type, NULL);
		}

		/* NAS-Port-Type			61	2865 */
		{
			/*
			integer -> Unsigned32

			   Value

			      The Value field is four octets.  "Virtual" refers to a connection
			      to the NAS via some transport protocol, instead of through a
			      physical port.  For example, if a user telnetted into a NAS to
			      authenticate himself as an Outbound-User, the Access-Request might
			      include NAS-Port-Type = Virtual as a hint to the RADIUS server
			      that the user was not on a physical port.

			      0       Async
			      1       Sync
			      2       ISDN Sync
			      3       ISDN Async V.120
			      4       ISDN Async V.110
			      5       Virtual
			      6       PIAFS
			      7       HDLC Clear Channel
			      8       X.25
			      9       X.75
			      10      G.3 Fax
			      11      SDSL - Symmetric DSL
			      12      ADSL-CAP - Asymmetric DSL, Carrierless Amplitude Phase
				      Modulation
			      13      ADSL-DMT - Asymmetric DSL, Discrete Multi-Tone
			      14      IDSL - ISDN Digital Subscriber Line
			      15      Ethernet
			      16      xDSL - Digital Subscriber Line of unknown type
			      17      Cable
			      18      Wireless - Other
			      19      Wireless - IEEE 802.11

			      PIAFS is a form of wireless ISDN commonly used in Japan, and
			      stands for PHS (Personal Handyphone System) Internet Access Forum
			      Standard (PIAFS).
			*/

			struct dict_avp_data data = {
					61, 					/* Code */
					0, 					/* Vendor */
					"NAS-Port-Type",			/* Name */
					AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, 	/* Fixed flags */
					AVP_FLAG_MANDATORY,		 	/* Fixed flag values */
					AVP_TYPE_UNSIGNED32			/* base type of data */
					};

			CHECK_dict_new( DICT_AVP, &data , NULL, NULL);
		}

		/* Called-Station-Id			30	2865 */
		{
			/*
			string -> OctetString
			*/

			struct dict_avp_data data = {
					30, 					/* Code */
					0, 					/* Vendor */
					"Called-Station-Id",			/* Name */
					AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, 	/* Fixed flags */
					AVP_FLAG_MANDATORY,		 	/* Fixed flag values */
					AVP_TYPE_OCTETSTRING			/* base type of data */
					};

			CHECK_dict_new( DICT_AVP, &data , NULL, NULL);
		}
		/* Calling-Station-Id			31	2865 */
		{
			/*
			string -> OctetString
			*/

			struct dict_avp_data data = {
					31, 					/* Code */
					0, 					/* Vendor */
					"Calling-Station-Id",			/* Name */
					AVP_FLAG_VENDOR | AVP_FLAG_MANDATORY, 	/* Fixed flags */
					AVP_FLAG_MANDATORY,		 	/* Fixed flag values */
					AVP_TYPE_OCTETSTRING			/* base type of data */
					};

			CHECK_dict_new( DICT_AVP, &data , NULL, NULL);
		}
	}

/*******************/
/* Command section */
/*******************/

	{
		/* MIP6-Request (MIR) */
		{
			/*

			The MIP6-Request (MIR), indicated by the Command-Code field set to
			325 and the 'R' bit set in the Command Flags field, is sent by the
			HA, acting as a Diameter client, in order to request the
			authentication and authorization of an MN.

			Although the HA provides the Diameter server with replay protection-
			related information, the HA is responsible for the replay protection.

			The message format is shown below.

			<MIP6-Request> ::= < Diameter Header: 325, REQ, PXY >
					   < Session-ID >
					   { Auth-Application-Id }
					   { User-Name }
					   { Destination-Realm }
					   { Origin-Host }
					   { Origin-Realm }
					   { Auth-Request-Type }
					   [ Destination-Host ]
					   [ Origin-State-Id ]
					   [ NAS-Identifier ]
					   [ NAS-IP-Address ]
					   [ NAS-IPv6-Address ]
					   [ NAS-Port-Type ]
					   [ Called-Station-Id ]
					   [ Calling-Station-Id ]
					   [ MIP6-Feature-Vector ]
					   { MIP6-Auth-Mode }
					   [ MIP-MN-AAA-SPI ]
					   [ MIP-MN-HA-SPI ]
					1*2{ MIP-Mobile-Node-Address }
					   { MIP6-Agent-Info }
					   { MIP-Careof-Address }
					   [ MIP-Authenticator ]
					   [ MIP-MAC-Mobility-Data ]
					   [ MIP-Timestamp ]
					   [ QoS-Capability ]
					 * [ QoS-Resources ]
					   [ Chargeable-User-Identity ]
					   [ Service-Selection ]
					   [ Authorization-Lifetime ]
					   [ Auth-Session-State ]
					 * [ Proxy-Info ]
					 * [ Route-Record ]
					 * [ AVP ]

			If the MN is both authenticated and authorized for the mobility
			service, then the Auth-Request-Type AVP is set to the value
			AUTHORIZE_AUTHENTICATE.  This is the case when the MIP6-Auth-Mode is
			set to the value MIP6_AUTH_MN_AAA.

			*/
			struct dict_object * cmd;
			struct dict_cmd_data data = {
					325, 					/* Code */
					"MIP6-Request", 			/* Name */
					CMD_FLAG_REQUEST | CMD_FLAG_PROXIABLE | CMD_FLAG_ERROR, 	/* Fixed flags */
					CMD_FLAG_PROXIABLE 						/* Fixed flag values */
					};
			struct local_rules_definition rules[] =
						{ 	 {  "Session-Id", 			RULE_FIXED_HEAD, -1, 1 }
							,{  "Auth-Application-Id", 		RULE_REQUIRED,   -1, 1 }
							,{  "User-Name", 			RULE_REQUIRED,   -1, 1 }
							,{  "Destination-Realm", 		RULE_REQUIRED,   -1, 1 }
							,{  "Origin-Host", 			RULE_REQUIRED,   -1, 1 }
							,{  "Origin-Realm", 			RULE_REQUIRED,   -1, 1 }
							,{  "Auth-Request-Type", 		RULE_REQUIRED,   -1, 1 }
							,{  "Destination-Host", 		RULE_OPTIONAL,   -1, 1 }
							,{  "Origin-State-Id",	 		RULE_OPTIONAL,   -1, 1 }
							,{  "NAS-Identifier", 			RULE_OPTIONAL,   -1, 1 }
							,{  "NAS-IP-Address", 			RULE_OPTIONAL,   -1, 1 }
							,{  "NAS-IPv6-Address", 		RULE_OPTIONAL,   -1, 1 }
							,{  "NAS-Port-Type", 			RULE_OPTIONAL,   -1, 1 }
							,{  "Called-Station-Id", 		RULE_OPTIONAL,   -1, 1 }
							,{  "Calling-Station-Id", 		RULE_OPTIONAL,   -1, 1 }
							,{  "MIP6-Feature-Vector", 		RULE_OPTIONAL,   -1, 1 }
							,{  "MIP6-Auth-Mode", 			RULE_OPTIONAL,   -1, 1 }
							,{  "MIP-MN-AAA-SPI", 			RULE_OPTIONAL,   -1, 1 }
							,{  "MIP-MN-HA-SPI", 			RULE_OPTIONAL,   -1, 1 }
							,{  "MIP-Mobile-Node-Address", 		RULE_OPTIONAL,    1, 2 }
							,{  "MIP6-Agent-Info", 			RULE_OPTIONAL,   -1, 1 }
							,{  "MIP-Careof-Address", 		RULE_OPTIONAL,   -1, 1 }
							,{  "MIP-Authenticator", 		RULE_OPTIONAL,   -1, 1 }
							,{  "MIP-MAC-Mobility-Data", 		RULE_OPTIONAL,   -1, 1 }
							,{  "MIP-Timestamp", 			RULE_OPTIONAL,   -1, 1 }
							,{  "QoS-Capability", 			RULE_OPTIONAL,   -1, 1 }
							,{  "QoS-Resources", 			RULE_OPTIONAL,   -1, -1 }
							,{  "Chargeable-User-Identity", 	RULE_OPTIONAL,   -1, 1 }
							,{  "Service-Selection", 		RULE_OPTIONAL,   -1, 1 }
							,{  "Authorization-Lifetime", 		RULE_OPTIONAL,   -1, 1 }
							,{  "Auth-Session-State", 		RULE_OPTIONAL,   -1, 1 }
							,{  "Proxy-Info", 			RULE_OPTIONAL,   -1, -1 }
							,{  "Route-Record", 			RULE_OPTIONAL,   -1, -1 }
						};

1002
			CHECK_dict_new( DICT_COMMAND, &data , mip6a, &cmd);
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
			PARSE_loc_rules( rules, cmd );
		}

		/* MIP6-Answer (MIA) */
		{
			/*

			The MIP6-Answer (MIA) message, indicated by the Command-Code field
			set to 325 and the 'R' bit cleared in the Command Flags field, is
			sent by the Diameter server in response to the MIP6-Request message.

			The User-Name AVP MAY be included in the MIA if it is present in the
			MIR.  The Result-Code AVP MAY contain one of the values defined in
			Section 7, in addition to the values defined in [RFC3588].

			An MIA message with the Result-Code AVP set to DIAMETER_SUCCESS MUST
			include the MIP-Mobile-Node-Address AVP.

			The message format is shown below.

			<MIP6-Answer> ::= < Diameter Header: 325, PXY >
					  < Session-Id >
					  { Auth-Application-Id }
					  { Result-Code }
					  { Origin-Host }
					  { Origin-Realm }
					  { Auth-Request-Type }
					  [ User-Name ]
					  [ Authorization-Lifetime ]
					  [ Auth-Session-State ]
					  [ Error-Message ]
					  [ Error-Reporting-Host ]
					  [ Re-Auth-Request-Type ]
					  [ MIP6-Feature-Vector ]
					  [ MIP-Agent-Info ]
					*2[ MIP-Mobile-Node-Address ]
					  [ MIP-MN-HA-MSA ]
					* [ QoS-Resources ]
					  [ Chargeable-User-Identity ]
					  [ Service-Selection ]
					  [ Origin-State-Id ]
					* [ Proxy-Info ]
					* [ Redirect-Host ]
					  [ Redirect-Host-Usage ]
					  [ Redirect-Max-Cache-Time ]
					* [ Failed-AVP ]
					* [ AVP ]

			*/
			struct dict_object * cmd;
			struct dict_cmd_data data = {
					325, 					/* Code */
					"MIP6-Answer", 				/* Name */
					CMD_FLAG_PROXIABLE | CMD_FLAG_ERROR, 	/* Fixed flags */
					CMD_FLAG_PROXIABLE 			/* Fixed flag values */
					};
			struct local_rules_definition rules[] =
						{ 	 {  "Session-Id", 			RULE_FIXED_HEAD, -1, 1 }
							,{  "Auth-Application-Id", 		RULE_REQUIRED,   -1, 1 }
							,{  "Result-Code", 			RULE_REQUIRED,   -1, 1 }
							,{  "Origin-Host", 			RULE_REQUIRED,   -1, 1 }
							,{  "Origin-Realm", 			RULE_REQUIRED,   -1, 1 }
							,{  "Auth-Request-Type", 		RULE_REQUIRED,   -1, 1 }
							,{  "User-Name", 			RULE_OPTIONAL,   -1, 1 }
							,{  "Authorization-Lifetime", 		RULE_OPTIONAL,   -1, 1 }
							,{  "Auth-Session-State", 		RULE_OPTIONAL,   -1, 1 }
							,{  "Error-Message", 			RULE_OPTIONAL,   -1, 1 }
							,{  "Error-Reporting-Host", 		RULE_OPTIONAL,   -1, 1 }
							,{  "Re-Auth-Request-Type", 		RULE_OPTIONAL,   -1, 1 }
							,{  "MIP6-Feature-Vector", 		RULE_OPTIONAL,   -1, 1 }
							,{  "MIP-Agent-Info", 			RULE_OPTIONAL,   -1, 1 }
							,{  "MIP-Mobile-Node-Address", 		RULE_OPTIONAL,   -1, 2 }
							,{  "MIP-MN-HA-MSA", 			RULE_OPTIONAL,   -1, 1 }
							,{  "QoS-Resources", 			RULE_OPTIONAL,   -1, -1 }
							,{  "Chargeable-User-Identity",		RULE_OPTIONAL,   -1, 1 }
							,{  "Service-Selection", 		RULE_OPTIONAL,   -1, 1 }
							,{  "Origin-State-Id", 			RULE_OPTIONAL,   -1, 1 }
							,{  "Proxy-Info", 			RULE_OPTIONAL,   -1, -1 }
							,{  "Redirect-Host", 			RULE_OPTIONAL,   -1, -1 }
							,{  "Redirect-Host-Usage", 		RULE_OPTIONAL,   -1, 1 }
							,{  "Redirect-Max-Cache-Time", 		RULE_OPTIONAL,   -1, 1 }
							,{  "Failed-AVP", 			RULE_OPTIONAL,   -1, -1 }
						};

1087
			CHECK_dict_new( DICT_COMMAND, &data , mip6a, &cmd);
1088
1089
1090
			PARSE_loc_rules( rules, cmd );
		}
	}
1091
1092
1093
1094
	TRACE_DEBUG(INFO, "Dictionary Extension 'Diameter Mobile IPv6 Auth (MIP6A)' initialized");
	return 0;
}
EXTENSION_ENTRY("dict_mip6a",dict_mip6a_init);