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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
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
179
180
181
182
183
184
185
186
187
188
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
742
743
744
745
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
|
$NetBSD: patch-ab,v 1.1 2005/03/16 12:55:02 rillig Exp $
--- radproto.cxx.orig Tue Aug 10 01:32:11 2004
+++ radproto.cxx Wed Mar 16 12:38:12 2005
@@ -238,16 +238,20 @@ unsigned GetRadiusInteger(
} // anonymous namespace
-RadiusAttr::RadiusAttr() : m_type(0), m_length(0)
+RadiusAttr::RadiusAttr()
{
+ s.m_type = 0;
+ s.m_length = 0;
}
RadiusAttr::RadiusAttr(
unsigned char attrType, /// type of the attribute
const void* attrValue, /// actual attribute value data
PINDEX valueLength /// length for the attribute value
- ) : m_type(attrType), m_length(FixedHeaderLength)
+ )
{
+ s.m_type = attrType;
+ s.m_length = FixedHeaderLength;
if (valueLength > 0)
PAssertNULL(attrValue);
@@ -259,9 +263,9 @@ RadiusAttr::RadiusAttr(
valueLength = MaxValueLength;
if (valueLength > 0) {
- m_length = m_length + (unsigned char)valueLength;
+ s.m_length = s.m_length + (unsigned char)valueLength;
if (attrValue != NULL)
- memcpy(m_value, attrValue, valueLength);
+ memcpy(s.m_value, attrValue, valueLength);
}
}
@@ -270,10 +274,13 @@ RadiusAttr::RadiusAttr(
PINDEX valueLength, /// data length (bytes)
int vendorId, /// 32 bit vendor identifier
unsigned char vendorType /// vendor-specific attribute type
- ) : m_type(VendorSpecific), m_length(VsaRfc2865FixedHeaderLength),
- m_vendorType(vendorType), m_vendorLength(2)
+ )
{
- SetRadiusInteger(m_vendorId, vendorId);
+ s.m_type = VendorSpecific;
+ s.m_length = VsaRfc2865FixedHeaderLength;
+ s.s.m_vendorType = vendorType;
+ s.s.m_vendorLength = 2;
+ SetRadiusInteger(s.s.m_vendorId, vendorId);
if (valueLength > 0)
PAssertNULL(attrValue);
@@ -286,18 +293,20 @@ RadiusAttr::RadiusAttr(
valueLength = VsaMaxRfc2865ValueLength;
if (valueLength > 0) {
- m_length = m_length + (unsigned char)valueLength;
- m_vendorLength = m_vendorLength + (unsigned char)valueLength;
+ s.m_length = s.m_length + (unsigned char)valueLength;
+ s.s.m_vendorLength = s.s.m_vendorLength + (unsigned char)valueLength;
if (attrValue != NULL)
- memcpy(m_vendorValue, attrValue, valueLength);
+ memcpy(s.s.m_vendorValue, attrValue, valueLength);
}
}
RadiusAttr::RadiusAttr(
unsigned char attrType, /// Attribute Type (see #enum AttrTypes#)
const PString& stringValue /// string to be stored in the attribute Value data
- ) : m_type(attrType), m_length(FixedHeaderLength)
+ )
{
+ s.m_type = attrType;
+ s.m_length = FixedHeaderLength;
if (attrType == VendorSpecific)
PAssertAlways(PInvalidParameter);
@@ -307,46 +316,53 @@ RadiusAttr::RadiusAttr(
attrLength = MaxValueLength;
if (attrLength > 0) {
- m_length = m_length + (unsigned char)attrLength;
- memcpy(m_value, (const char*)stringValue, attrLength);
+ s.m_length = s.m_length + (unsigned char)attrLength;
+ memcpy(s.m_value, (const char*)stringValue, attrLength);
}
}
RadiusAttr::RadiusAttr(
unsigned char attrType, /// Attribute Type (see #enum AttrTypes#)
int intValue /// 32 bit integer to be stored in the attribute Value
- ) : m_type(attrType), m_length(FixedHeaderLength + 4)
+ )
{
+ s.m_type = attrType;
+ s.m_length = FixedHeaderLength + 4;
if (attrType == VendorSpecific)
PAssertAlways(PInvalidParameter);
- SetRadiusInteger(m_value, intValue);
+ SetRadiusInteger(s.m_value, intValue);
}
RadiusAttr::RadiusAttr(
unsigned char attrType, /// Attribute Type (see #enum AttrTypes#)
const PIPSocket::Address& addressValue /// IPv4 address to be stored in the attribute Value
- ) : m_type(attrType), m_length(FixedHeaderLength + 4)
+ )
{
+ s.m_type = attrType;
+ s.m_length = FixedHeaderLength + 4;
if (attrType == VendorSpecific)
PAssertAlways(PInvalidParameter);
const DWORD addr = (DWORD)addressValue;
- m_value[0] = ((const BYTE*)&addr)[0];
- m_value[1] = ((const BYTE*)&addr)[1];
- m_value[2] = ((const BYTE*)&addr)[2];
- m_value[3] = ((const BYTE*)&addr)[3];
+ s.m_value[0] = ((const BYTE*)&addr)[0];
+ s.m_value[1] = ((const BYTE*)&addr)[1];
+ s.m_value[2] = ((const BYTE*)&addr)[2];
+ s.m_value[3] = ((const BYTE*)&addr)[3];
}
RadiusAttr::RadiusAttr(
const PString& stringValue, /// string to be stored in the attribute Value
int vendorId, /// 32 bit vendor identifier
unsigned char vendorType /// vendor-specific attribute type
- ) : m_type(VendorSpecific), m_length(VsaRfc2865FixedHeaderLength),
- m_vendorType(vendorType), m_vendorLength(2)
+ )
{
- SetRadiusInteger(m_vendorId, vendorId);
+ s.m_type = VendorSpecific;
+ s.m_length = VsaRfc2865FixedHeaderLength;
+ s.s.m_vendorType = vendorType;
+ s.s.m_vendorLength = 2;
+ SetRadiusInteger(s.s.m_vendorId, vendorId);
PINDEX vsaLength = stringValue.GetLength();
@@ -357,9 +373,9 @@ RadiusAttr::RadiusAttr(
vsaLength = VsaMaxRfc2865ValueLength;
if (vsaLength > 0) {
- m_length = m_length + (unsigned char)vsaLength;
- m_vendorLength = m_vendorLength + (unsigned char)vsaLength;
- memcpy(m_vendorValue, (const char*)stringValue, vsaLength);
+ s.m_length = s.m_length + (unsigned char)vsaLength;
+ s.s.m_vendorLength = s.s.m_vendorLength + (unsigned char)vsaLength;
+ memcpy(s.s.m_vendorValue, (const char*)stringValue, vsaLength);
}
}
@@ -367,71 +383,82 @@ RadiusAttr::RadiusAttr(
int intValue, /// 32 bit integer to be stored in the attribute Value
int vendorId, /// 32 bit vendor identifier
unsigned char vendorType /// vendor-specific attribute type
- ) : m_type(VendorSpecific), m_length(VsaRfc2865FixedHeaderLength + 4),
- m_vendorType(vendorType), m_vendorLength(2 + 4)
+ )
{
- SetRadiusInteger(m_vendorId, vendorId);
- SetRadiusInteger(m_vendorValue, intValue);
+ s.m_type=VendorSpecific;
+ s.m_length=VsaRfc2865FixedHeaderLength + 4;
+ s.s.m_vendorType=vendorType;
+ s.s.m_vendorLength=2 + 4;
+ SetRadiusInteger(s.s.m_vendorId, vendorId);
+ SetRadiusInteger(s.s.m_vendorValue, intValue);
}
RadiusAttr::RadiusAttr(
const PIPSocket::Address& addressValue, /// IPv4 address to be stored in the attribute Value
int vendorId, /// 32 bit vendor identifier
unsigned char vendorType /// vendor-specific attribute type
- ) : m_type(VendorSpecific), m_length(VsaRfc2865FixedHeaderLength + 4),
- m_vendorType(vendorType), m_vendorLength(2 + 4)
+ )
{
- SetRadiusInteger(m_vendorId, vendorId);
+ s.m_type = VendorSpecific;
+ s.m_length = VsaRfc2865FixedHeaderLength + 4;
+ s.s.m_vendorType = vendorType;
+ s.s.m_vendorLength = 2 + 4;
+ SetRadiusInteger(s.s.m_vendorId, vendorId);
const DWORD addr = (DWORD)addressValue;
- m_vendorValue[0] = ((BYTE*)&addr)[0];
- m_vendorValue[1] = ((BYTE*)&addr)[1];
- m_vendorValue[2] = ((BYTE*)&addr)[2];
- m_vendorValue[3] = ((BYTE*)&addr)[3];
+ s.s.m_vendorValue[0] = ((BYTE*)&addr)[0];
+ s.s.m_vendorValue[1] = ((BYTE*)&addr)[1];
+ s.s.m_vendorValue[2] = ((BYTE*)&addr)[2];
+ s.s.m_vendorValue[3] = ((BYTE*)&addr)[3];
}
RadiusAttr::RadiusAttr(
unsigned char type, /// Cisco-specific attribute type
bool vsaHack, /// true to not prepend attribute name to its value
const PString& stringValue /// string to be stored in the attribute Value
- ) : m_type(VendorSpecific), m_length(VsaRfc2865FixedHeaderLength),
- m_vendorType(type), m_vendorLength(2)
+ )
{
- SetRadiusInteger(m_vendorId, CiscoVendorId);
+ s.m_type = VendorSpecific;
+ s.m_length = VsaRfc2865FixedHeaderLength;
+ s.s.m_vendorType = type;
+ s.s.m_vendorLength = 2;
+ SetRadiusInteger(s.s.m_vendorId, CiscoVendorId);
if (!vsaHack) {
int i = 0;
while (CiscoAttrNames[i].m_name != NULL)
if (CiscoAttrNames[i].m_type == type) {
- memcpy(m_vendorValue, CiscoAttrNames[i].m_name, CiscoAttrNames[i].m_nameLen);
- m_length = m_length + (unsigned char)CiscoAttrNames[i].m_nameLen;
- m_vendorLength = m_vendorLength + (unsigned char)CiscoAttrNames[i].m_nameLen;
- m_data[m_length++] = '=';
- m_vendorLength++;
+ memcpy(s.s.m_vendorValue, CiscoAttrNames[i].m_name, CiscoAttrNames[i].m_nameLen);
+ s.m_length = s.m_length + (unsigned char)CiscoAttrNames[i].m_nameLen;
+ s.s.m_vendorLength = s.s.m_vendorLength + (unsigned char)CiscoAttrNames[i].m_nameLen;
+ m_data[s.m_length++] = '=';
+ s.s.m_vendorLength++;
break;
} else
i++;
}
const PINDEX len = stringValue.GetLength();
- if (((PINDEX)m_length + len) > MaxLength)
+ if (((PINDEX)s.m_length + len) > MaxLength)
return;
- memcpy(m_data + (PINDEX)m_length, (const char*)stringValue, len);
- m_length = m_length + (unsigned char)len;
- m_vendorLength = m_vendorLength + (unsigned char)len;
+ memcpy(m_data + (PINDEX)s.m_length, (const char*)stringValue, len);
+ s.m_length = s.m_length + (unsigned char)len;
+ s.s.m_vendorLength = s.s.m_vendorLength + (unsigned char)len;
}
RadiusAttr::RadiusAttr(
const void* rawData, /// buffer with the attribute raw data
PINDEX rawLength /// length (bytes) of the buffer
- ) : m_type(0), m_length(0)
+ )
{
+ s.m_type = 0;
+ s.m_length = 0;
Read(rawData, rawLength);
}
int RadiusAttr::GetVsaVendorId() const
{
- return GetRadiusInteger(m_vendorId);
+ return GetRadiusInteger(s.s.m_vendorId);
}
bool RadiusAttr::Write(
@@ -446,7 +473,7 @@ bool RadiusAttr::Write(
if (offset == P_MAX_INDEX)
offset = buffer.GetSize();
- const PINDEX len = m_length;
+ const PINDEX len = s.m_length;
memcpy(buffer.GetPointer(offset + len) + offset, m_data, len);
written = len;
@@ -455,7 +482,7 @@ bool RadiusAttr::Write(
bool RadiusAttr::Read(const void* rawData, PINDEX rawLength)
{
- m_type = m_length = 0;
+ s.m_type = s.m_length = 0;
#ifdef _DEBUG
PAssertNULL(rawData);
@@ -483,9 +510,9 @@ void RadiusAttr::PrintOn(
if (!IsValid()) {
strm << "(Invalid) {\n";
- if (m_length > 0) {
+ if (s.m_length > 0) {
const _Ios_Fmtflags flags = strm.flags();
- const PBYTEArray value((const BYTE*)m_data, m_length, FALSE);
+ const PBYTEArray value((const BYTE*)m_data, s.m_length, FALSE);
strm << hex << setfill('0') << resetiosflags(ios::floatfield)
<< setprecision(indent) << setw(16);
@@ -508,12 +535,12 @@ void RadiusAttr::PrintOn(
strm << "{\n";
#if PTRACING
- strm << setw(indent+7) << "type = " << (unsigned)m_type
- << " (" << PMAP_ATTR_TYPE_TO_NAME(m_type) << ")\n";
+ strm << setw(indent+7) << "type = " << (unsigned)s.m_type
+ << " (" << PMAP_ATTR_TYPE_TO_NAME(s.m_type) << ")\n";
#else
- strm << setw(indent+7) << "type = " << (unsigned)m_type << '\n';
+ strm << setw(indent+7) << "type = " << (unsigned)s.m_type << '\n';
#endif
- const PINDEX totalLen = m_length;
+ const PINDEX totalLen = s.m_length;
strm << setw(indent+9) << "length = " << totalLen << " octets\n";
@@ -521,7 +548,7 @@ void RadiusAttr::PrintOn(
const _Ios_Fmtflags flags = strm.flags();
const PINDEX valueLen = (totalLen <= FixedHeaderLength)
? 0 : (totalLen - FixedHeaderLength);
- const PBYTEArray value((const BYTE*)m_value, valueLen, FALSE);
+ const PBYTEArray value((const BYTE*)s.m_value, valueLen, FALSE);
strm << setw(indent+8) << "value = " << value.GetSize() << " octets {\n";
strm << hex << setfill('0') << resetiosflags(ios::floatfield)
@@ -552,9 +579,9 @@ void RadiusAttr::PrintOn(
valueLen -= 2;
headerLen += 2;
strm << setw(indent+13) << "vendorType = "
- << (unsigned)m_vendorType << '\n';
+ << (unsigned)s.s.m_vendorType << '\n';
strm << setw(indent+15) << "vendorLength = "
- << (unsigned)m_vendorLength << '\n';
+ << (unsigned)s.s.m_vendorLength << '\n';
}
const PBYTEArray value((const BYTE*)(m_data + headerLen), valueLen, FALSE);
@@ -582,13 +609,13 @@ void RadiusAttr::PrintOn(
PINDEX RadiusAttr::GetVsaValueLength() const
{
- PINDEX len = m_length;
+ PINDEX len = s.m_length;
len = (len <= VsaRfc2865FixedHeaderLength)
? 0 : (len - VsaRfc2865FixedHeaderLength);
PINDEX len2 = 0;
if (len > 0) {
- len2 = m_vendorLength;
+ len2 = s.s.m_vendorLength;
len2 = (len2 <= 2) ? 0 : (len2 - 2);
}
if (len2 < len)
@@ -626,7 +653,7 @@ bool RadiusAttr::GetVsaValue(PBYTEArray&
offset = buffer.GetSize();
if (len > 0)
- memcpy(buffer.GetPointer(len + offset) + offset, m_vendorValue, len);
+ memcpy(buffer.GetPointer(len + offset) + offset, s.s.m_vendorValue, len);
return true;
}
@@ -636,8 +663,8 @@ PString RadiusAttr::AsString() const
if (!IsValid())
return PString();
- const PINDEX len = m_length;
- const PINDEX headerLen = (m_type == VendorSpecific)
+ const PINDEX len = s.m_length;
+ const PINDEX headerLen = (s.m_type == VendorSpecific)
? VsaFixedHeaderLength : FixedHeaderLength;
if (len <= headerLen)
@@ -648,52 +675,52 @@ PString RadiusAttr::AsString() const
int RadiusAttr::AsInteger() const
{
- if (m_length < (FixedHeaderLength+4) || m_type == VendorSpecific)
+ if (s.m_length < (FixedHeaderLength+4) || s.m_type == VendorSpecific)
return 0;
- return GetRadiusInteger(m_value);
+ return GetRadiusInteger(s.m_value);
}
PIPSocket::Address RadiusAttr::AsAddress() const
{
- if (m_length < (FixedHeaderLength+4) || m_type == VendorSpecific)
+ if (s.m_length < (FixedHeaderLength+4) || s.m_type == VendorSpecific)
return 0;
DWORD addr = 0;
-
- ((BYTE*)&addr)[0] = m_value[0];
- ((BYTE*)&addr)[1] = m_value[1];
- ((BYTE*)&addr)[2] = m_value[2];
- ((BYTE*)&addr)[3] = m_value[3];
+
+ ((BYTE*)&addr)[0] = s.m_value[0];
+ ((BYTE*)&addr)[1] = s.m_value[1];
+ ((BYTE*)&addr)[2] = s.m_value[2];
+ ((BYTE*)&addr)[3] = s.m_value[3];
return addr;
}
PString RadiusAttr::AsVsaString() const
{
- if (!IsValid() || m_type != VendorSpecific)
+ if (!IsValid() || s.m_type != VendorSpecific)
return PString();
- const PINDEX len = m_length;
+ const PINDEX len = s.m_length;
if (len <= VsaRfc2865FixedHeaderLength)
return PString();
else
- return PString((const char*)m_vendorValue, len - VsaRfc2865FixedHeaderLength);
+ return PString((const char*)s.s.m_vendorValue, len - VsaRfc2865FixedHeaderLength);
}
PString RadiusAttr::AsCiscoString() const
{
- if (!IsValid() || m_type != VendorSpecific
- || GetRadiusInteger(m_vendorId) != CiscoVendorId)
+ if (!IsValid() || s.m_type != VendorSpecific
+ || GetRadiusInteger(s.s.m_vendorId) != CiscoVendorId)
return PString();
- const PINDEX len = m_length;
+ const PINDEX len = s.m_length;
PINDEX offset = VsaRfc2865FixedHeaderLength;
int i = 0;
while (CiscoAttrNames[i].m_name != NULL)
- if (CiscoAttrNames[i].m_type == m_vendorType) {
+ if (CiscoAttrNames[i].m_type == s.s.m_vendorType) {
if (CiscoAttrNames[i].m_nameLen < (size_t)(len - offset))
if (memcmp(m_data + offset, CiscoAttrNames[i].m_name,
CiscoAttrNames[i].m_nameLen) == 0
@@ -711,30 +738,32 @@ PString RadiusAttr::AsCiscoString() cons
int RadiusAttr::AsVsaInteger() const
{
- if (m_length < (VsaRfc2865FixedHeaderLength+4) || m_type != VendorSpecific)
+ if (s.m_length < (VsaRfc2865FixedHeaderLength+4) || s.m_type != VendorSpecific)
return 0;
- return GetRadiusInteger(m_vendorValue);
+ return GetRadiusInteger(s.s.m_vendorValue);
}
PIPSocket::Address RadiusAttr::AsVsaAddress() const
{
- if (m_length < (VsaRfc2865FixedHeaderLength+4) || m_type != VendorSpecific)
+ if (s.m_length < (VsaRfc2865FixedHeaderLength+4) || s.m_type != VendorSpecific)
return 0;
DWORD addr = 0;
- ((BYTE*)&addr)[0] = m_vendorValue[0];
- ((BYTE*)&addr)[1] = m_vendorValue[1];
- ((BYTE*)&addr)[2] = m_vendorValue[2];
- ((BYTE*)&addr)[3] = m_vendorValue[3];
+ ((BYTE*)&addr)[0] = s.s.m_vendorValue[0];
+ ((BYTE*)&addr)[1] = s.s.m_vendorValue[1];
+ ((BYTE*)&addr)[2] = s.s.m_vendorValue[2];
+ ((BYTE*)&addr)[3] = s.s.m_vendorValue[3];
return addr;
}
-RadiusPDU::RadiusPDU() : m_code(Invalid), m_id(0)
+RadiusPDU::RadiusPDU()
{
+ s.m_code = 0;
+ s.m_id = 0;
SetLength(FixedHeaderLength);
}
@@ -748,8 +777,10 @@ RadiusPDU::RadiusPDU(
RadiusPDU::RadiusPDU(
unsigned char packetCode, /// code - see #Codes enum#
unsigned char packetId /// packet id (sequence number)
- ) : m_code(packetCode), m_id(packetId)
+ )
{
+ s.m_code = packetCode;
+ s.m_id = packetId;
SetLength(FixedHeaderLength);
}
@@ -759,7 +790,7 @@ RadiusPDU::RadiusPDU(
)
{
if (!Read(rawData, rawLength)) {
- m_code = m_id = Invalid;
+ s.m_code = s.m_id = Invalid;
SetLength(FixedHeaderLength);
}
}
@@ -773,16 +804,16 @@ void RadiusPDU::PrintOn(
strm << ((!IsValid()) ? "(Invalid) {\n" : "{\n");
#if PTRACING
- strm << setw(indent+7) << "code = " << (unsigned)m_code
- << " (" << PMAP_CODE_TO_NAME(m_code) << ")\n";
+ strm << setw(indent+7) << "code = " << (unsigned)s.m_code
+ << " (" << PMAP_CODE_TO_NAME(s.m_code) << ")\n";
#else
- strm << setw(indent+7) << "code = " << (unsigned)m_code << '\n';
+ strm << setw(indent+7) << "code = " << (unsigned)s.m_code << '\n';
#endif
- strm << setw(indent+5) << "id = " << (unsigned)m_id << '\n';
+ strm << setw(indent+5) << "id = " << (unsigned)s.m_id << '\n';
strm << setw(indent+9) << "length = " << GetLength() << " octets\n";
const _Ios_Fmtflags flags = strm.flags();
- const PBYTEArray value((const BYTE*)m_authenticator, AuthenticatorLength, FALSE);
+ const PBYTEArray value((const BYTE*)s.m_authenticator, AuthenticatorLength, FALSE);
strm << setw(indent+28) << "authenticator = 16 octets {\n";
strm << hex << setfill('0') << resetiosflags(ios::floatfield)
@@ -816,7 +847,7 @@ void RadiusPDU::PrintOn(
bool RadiusPDU::IsValid() const
{
- if (m_code == Invalid)
+ if (s.m_code == Invalid)
return false;
const PINDEX len = GetLength();
@@ -842,7 +873,7 @@ void RadiusPDU::GetAuthenticator(PBYTEAr
if (offset == P_MAX_INDEX)
offset = vector.GetSize();
memcpy(vector.GetPointer(offset + AuthenticatorLength) + offset,
- m_authenticator, AuthenticatorLength
+ s.m_authenticator, AuthenticatorLength
);
}
@@ -855,7 +886,7 @@ bool RadiusPDU::SetAuthenticator(const P
len -= offset;
if (len > 0)
- memcpy(m_authenticator, ((const BYTE*)vector)+offset,
+ memcpy(s.m_authenticator, ((const BYTE*)vector)+offset,
(len < AuthenticatorLength) ? len : AuthenticatorLength
);
@@ -870,32 +901,32 @@ bool RadiusPDU::SetAuthenticator(const v
if (data == NULL)
return false;
- memcpy(m_authenticator, data, AuthenticatorLength);
+ memcpy(s.m_authenticator, data, AuthenticatorLength);
return true;
}
void RadiusPDU::SetAuthenticator(PRandom& random)
{
DWORD r = (DWORD)random;
- m_authenticator[0] = ((const BYTE*)&r)[0];
- m_authenticator[1] = ((const BYTE*)&r)[1];
- m_authenticator[2] = ((const BYTE*)&r)[2];
- m_authenticator[3] = ((const BYTE*)&r)[3];
+ s.m_authenticator[0] = ((const BYTE*)&r)[0];
+ s.m_authenticator[1] = ((const BYTE*)&r)[1];
+ s.m_authenticator[2] = ((const BYTE*)&r)[2];
+ s.m_authenticator[3] = ((const BYTE*)&r)[3];
r = (DWORD)random;
- m_authenticator[4] = ((const BYTE*)&r)[0];
- m_authenticator[5] = ((const BYTE*)&r)[1];
- m_authenticator[6] = ((const BYTE*)&r)[2];
- m_authenticator[7] = ((const BYTE*)&r)[3];
+ s.m_authenticator[4] = ((const BYTE*)&r)[0];
+ s.m_authenticator[5] = ((const BYTE*)&r)[1];
+ s.m_authenticator[6] = ((const BYTE*)&r)[2];
+ s.m_authenticator[7] = ((const BYTE*)&r)[3];
r = (DWORD)random;
- m_authenticator[8] = ((const BYTE*)&r)[0];
- m_authenticator[9] = ((const BYTE*)&r)[1];
- m_authenticator[10] = ((const BYTE*)&r)[2];
- m_authenticator[11] = ((const BYTE*)&r)[3];
+ s.m_authenticator[8] = ((const BYTE*)&r)[0];
+ s.m_authenticator[9] = ((const BYTE*)&r)[1];
+ s.m_authenticator[10] = ((const BYTE*)&r)[2];
+ s.m_authenticator[11] = ((const BYTE*)&r)[3];
r = (DWORD)random;
- m_authenticator[12] = ((const BYTE*)&r)[0];
- m_authenticator[13] = ((const BYTE*)&r)[1];
- m_authenticator[14] = ((const BYTE*)&r)[2];
- m_authenticator[15] = ((const BYTE*)&r)[3];
+ s.m_authenticator[12] = ((const BYTE*)&r)[0];
+ s.m_authenticator[13] = ((const BYTE*)&r)[1];
+ s.m_authenticator[14] = ((const BYTE*)&r)[2];
+ s.m_authenticator[15] = ((const BYTE*)&r)[3];
}
void RadiusPDU::SetAuthenticator(
@@ -903,11 +934,11 @@ void RadiusPDU::SetAuthenticator(
PMessageDigest5& md5
)
{
- if (m_code == AccountingRequest) {
+ if (s.m_code == AccountingRequest) {
const PINDEX pduLength = GetLength();
const PINDEX secretLength = secret.GetLength();
- memset(m_authenticator, 0, AuthenticatorLength);
+ memset(s.m_authenticator, 0, AuthenticatorLength);
md5.Start();
md5.Process(m_data, pduLength);
@@ -916,7 +947,7 @@ void RadiusPDU::SetAuthenticator(
PMessageDigest::Result digest;
md5.CompleteDigest(digest);
- memcpy(m_authenticator, digest.GetPointer(), AuthenticatorLength);
+ memcpy(s.m_authenticator, digest.GetPointer(), AuthenticatorLength);
} else {
PRandom random;
SetAuthenticator(random);
@@ -950,9 +981,9 @@ bool RadiusPDU::AppendAttr(
return false;
RadiusAttr* const attr = reinterpret_cast<RadiusAttr*>(m_data + len);
- attr->m_type = attrType;
- attr->m_length = attrLen;
- memcpy(attr->m_value, attrValue, valueLength);
+ attr->s.m_type = attrType;
+ attr->s.m_length = attrLen;
+ memcpy(attr->s.m_value, attrValue, valueLength);
SetLength(len + attrLen);
return true;
@@ -969,9 +1000,9 @@ bool RadiusPDU::AppendAttr(
return false;
RadiusAttr* const attr = reinterpret_cast<RadiusAttr*>(m_data + len);
- attr->m_type = attrType;
- attr->m_length = attrLen;
- memcpy(attr->m_value, (const char*)stringValue, stringValue.GetLength());
+ attr->s.m_type = attrType;
+ attr->s.m_length = attrLen;
+ memcpy(attr->s.m_value, (const char*)stringValue, stringValue.GetLength());
SetLength(len + attrLen);
return true;
@@ -988,9 +1019,9 @@ bool RadiusPDU::AppendAttr(
return false;
RadiusAttr* const attr = reinterpret_cast<RadiusAttr*>(m_data + len);
- attr->m_type = attrType;
- attr->m_length = attrLen;
- SetRadiusInteger(attr->m_value, intValue);
+ attr->s.m_type = attrType;
+ attr->s.m_length = attrLen;
+ SetRadiusInteger(attr->s.m_value, intValue);
SetLength(len + attrLen);
return true;
@@ -1008,12 +1039,12 @@ bool RadiusPDU::AppendAttr(
const DWORD addr = (DWORD)addressValue;
RadiusAttr* const attr = reinterpret_cast<RadiusAttr*>(m_data + len);
- attr->m_type = attrType;
- attr->m_length = attrLen;
- attr->m_value[0] = ((const BYTE*)&addr)[0];
- attr->m_value[1] = ((const BYTE*)&addr)[1];
- attr->m_value[2] = ((const BYTE*)&addr)[2];
- attr->m_value[3] = ((const BYTE*)&addr)[3];
+ attr->s.m_type = attrType;
+ attr->s.m_length = attrLen;
+ attr->s.m_value[0] = ((const BYTE*)&addr)[0];
+ attr->s.m_value[1] = ((const BYTE*)&addr)[1];
+ attr->s.m_value[2] = ((const BYTE*)&addr)[2];
+ attr->s.m_value[3] = ((const BYTE*)&addr)[3];
SetLength(len + attrLen);
return true;
@@ -1032,12 +1063,12 @@ bool RadiusPDU::AppendVsaAttr(
return false;
RadiusAttr* const attr = reinterpret_cast<RadiusAttr*>(m_data + len);
- attr->m_type = RadiusAttr::VendorSpecific;
- attr->m_length = attrLen;
- SetRadiusInteger(attr->m_vendorId, vendorId);
- attr->m_vendorType = vendorType;
- attr->m_vendorLength = valueLength + 2;
- memcpy(attr->m_vendorValue, attrValue, valueLength);
+ attr->s.m_type = RadiusAttr::VendorSpecific;
+ attr->s.m_length = attrLen;
+ SetRadiusInteger(attr->s.s.m_vendorId, vendorId);
+ attr->s.s.m_vendorType = vendorType;
+ attr->s.s.m_vendorLength = valueLength + 2;
+ memcpy(attr->s.s.m_vendorValue, attrValue, valueLength);
SetLength(len + attrLen);
return true;
@@ -1056,12 +1087,12 @@ bool RadiusPDU::AppendVsaAttr(
return false;
RadiusAttr* const attr = reinterpret_cast<RadiusAttr*>(m_data + len);
- attr->m_type = RadiusAttr::VendorSpecific;
- attr->m_length = attrLen;
- SetRadiusInteger(attr->m_vendorId, vendorId);
- attr->m_vendorType = vendorType;
- attr->m_vendorLength = valueLen + 2;
- memcpy(attr->m_vendorValue, (const char*)stringValue, valueLen);
+ attr->s.m_type = RadiusAttr::VendorSpecific;
+ attr->s.m_length = attrLen;
+ SetRadiusInteger(attr->s.s.m_vendorId, vendorId);
+ attr->s.s.m_vendorType = vendorType;
+ attr->s.s.m_vendorLength = valueLen + 2;
+ memcpy(attr->s.s.m_vendorValue, (const char*)stringValue, valueLen);
SetLength(len + attrLen);
return true;
@@ -1079,12 +1110,12 @@ bool RadiusPDU::AppendVsaAttr(
return false;
RadiusAttr* const attr = reinterpret_cast<RadiusAttr*>(m_data + len);
- attr->m_type = RadiusAttr::VendorSpecific;
- attr->m_length = attrLen;
- SetRadiusInteger(attr->m_vendorId, vendorId);
- attr->m_vendorType = vendorType;
- attr->m_vendorLength = 4 + 2;
- SetRadiusInteger(attr->m_vendorValue, intValue);
+ attr->s.m_type = RadiusAttr::VendorSpecific;
+ attr->s.m_length = attrLen;
+ SetRadiusInteger(attr->s.s.m_vendorId, vendorId);
+ attr->s.s.m_vendorType = vendorType;
+ attr->s.s.m_vendorLength = 4 + 2;
+ SetRadiusInteger(attr->s.s.m_vendorValue, intValue);
SetLength(len + attrLen);
return true;
@@ -1103,15 +1134,15 @@ bool RadiusPDU::AppendVsaAttr(
const DWORD addr = (DWORD)addressValue;
RadiusAttr* const attr = reinterpret_cast<RadiusAttr*>(m_data + len);
- attr->m_type = RadiusAttr::VendorSpecific;
- attr->m_length = attrLen;
- SetRadiusInteger(attr->m_vendorId, vendorId);
- attr->m_vendorType = vendorType;
- attr->m_vendorLength = 4 + 2;
- attr->m_vendorValue[0] = ((const BYTE*)&addr)[0];
- attr->m_vendorValue[1] = ((const BYTE*)&addr)[1];
- attr->m_vendorValue[2] = ((const BYTE*)&addr)[2];
- attr->m_vendorValue[3] = ((const BYTE*)&addr)[3];
+ attr->s.m_type = RadiusAttr::VendorSpecific;
+ attr->s.m_length = attrLen;
+ SetRadiusInteger(attr->s.s.m_vendorId, vendorId);
+ attr->s.s.m_vendorType = vendorType;
+ attr->s.s.m_vendorLength = 4 + 2;
+ attr->s.s.m_vendorValue[0] = ((const BYTE*)&addr)[0];
+ attr->s.s.m_vendorValue[1] = ((const BYTE*)&addr)[1];
+ attr->s.s.m_vendorValue[2] = ((const BYTE*)&addr)[2];
+ attr->s.s.m_vendorValue[3] = ((const BYTE*)&addr)[3];
SetLength(len + attrLen);
return true;
@@ -1130,11 +1161,11 @@ bool RadiusPDU::AppendCiscoAttr(
return false;
RadiusAttr* const attr = reinterpret_cast<RadiusAttr*>(m_data + len);
- attr->m_type = RadiusAttr::VendorSpecific;
- attr->m_length = attrLen;
- SetRadiusInteger(attr->m_vendorId, RadiusAttr::CiscoVendorId);
- attr->m_vendorType = vendorType;
- attr->m_vendorLength = 2;
+ attr->s.m_type = RadiusAttr::VendorSpecific;
+ attr->s.m_length = attrLen;
+ SetRadiusInteger(attr->s.s.m_vendorId, RadiusAttr::CiscoVendorId);
+ attr->s.s.m_vendorType = vendorType;
+ attr->s.s.m_vendorLength = 2;
if (!vsaHack) {
int i = 0;
@@ -1143,26 +1174,26 @@ bool RadiusPDU::AppendCiscoAttr(
attrLen += CiscoAttrNames[i].m_nameLen + 1;
if ((len + attrLen) > MaxPduLength)
return false;
- memcpy(attr->m_vendorValue, CiscoAttrNames[i].m_name, CiscoAttrNames[i].m_nameLen);
- attr->m_length = attr->m_length
+ memcpy(attr->s.s.m_vendorValue, CiscoAttrNames[i].m_name, CiscoAttrNames[i].m_nameLen);
+ attr->s.m_length = attr->s.m_length
+ (unsigned char)CiscoAttrNames[i].m_nameLen;
- attr->m_vendorLength = attr->m_vendorLength
+ attr->s.s.m_vendorLength = attr->s.s.m_vendorLength
+ (unsigned char)CiscoAttrNames[i].m_nameLen;
- attr->m_data[attr->m_length++] = '=';
- attr->m_vendorLength++;
+ attr->m_data[attr->s.m_length++] = '=';
+ attr->s.s.m_vendorLength++;
break;
} else
i++;
}
const PINDEX strLen = stringValue.GetLength();
attrLen += strLen;
- if (((PINDEX)attr->m_length + strLen) > RadiusAttr::MaxLength
+ if (((PINDEX)attr->s.m_length + strLen) > RadiusAttr::MaxLength
|| (len + attrLen) > MaxPduLength)
return false;
- memcpy(attr->m_data + (PINDEX)attr->m_length, (const char*)stringValue, strLen);
- attr->m_length = attr->m_length + (unsigned char)strLen;
- attr->m_vendorLength = attr->m_vendorLength + (unsigned char)strLen;
+ memcpy(attr->m_data + (PINDEX)attr->s.m_length, (const char*)stringValue, strLen);
+ attr->s.m_length = attr->s.m_length + (unsigned char)strLen;
+ attr->s.s.m_vendorLength = attr->s.s.m_vendorLength + (unsigned char)strLen;
SetLength(len + attrLen);
return true;
@@ -1247,7 +1278,7 @@ bool RadiusPDU::Read(const void* rawData
PAssert(rawLength >= MinPduLength, PInvalidParameter);
#endif
- m_code = m_id = Invalid;
+ s.m_code = s.m_id = Invalid;
SetLength(FixedHeaderLength);
if (rawData == NULL || rawLength < MinPduLength)
@@ -1260,13 +1291,13 @@ bool RadiusPDU::Read(const void* rawData
const PINDEX length = GetLength();
if (length > rawLength || length < MinPduLength || length > MaxPduLength) {
- m_code = m_id = Invalid;
+ s.m_code = s.m_id = Invalid;
SetLength(FixedHeaderLength);
return false;
}
if (length > FixedHeaderLength) {
- memcpy(m_attributes, buffptr, length - FixedHeaderLength);
+ memcpy(s.m_attributes, buffptr, length - FixedHeaderLength);
}
return true;
@@ -1291,13 +1322,13 @@ void RadiusPDU::CopyContents(const Radiu
const PINDEX len = GetLength();
if (len < MinPduLength || len > MaxPduLength) {
- m_code = m_id = Invalid;
+ s.m_code = s.m_id = Invalid;
SetLength(FixedHeaderLength);
return;
}
if (len > FixedHeaderLength)
- memcpy(m_attributes, pdu.m_attributes, len - FixedHeaderLength);
+ memcpy(s.m_attributes, pdu.s.m_attributes, len - FixedHeaderLength);
}
bool RadiusPDU::EncryptPasswords(
@@ -1316,7 +1347,7 @@ bool RadiusPDU::EncryptPasswords(
md5.Start();
if (secretLength > 0)
md5.Process((const char*)secret, secretLength);
- md5.Process(m_authenticator, AuthenticatorLength);
+ md5.Process(s.m_authenticator, AuthenticatorLength);
md5.CompleteDigest(digest);
// calculate length of the new and the old User-Password value
@@ -1330,14 +1361,14 @@ bool RadiusPDU::EncryptPasswords(
// the encrypted password attribute will be appended as the last attribute
RadiusAttr* const encPwdAttr = reinterpret_cast<RadiusAttr*>(m_data + len);
- encPwdAttr->m_type = RadiusAttr::UserPassword;
- encPwdAttr->m_length = encPwdLength + RadiusAttr::FixedHeaderLength;
- memset(encPwdAttr->m_value, 0, encPwdLength);
+ encPwdAttr->s.m_type = RadiusAttr::UserPassword;
+ encPwdAttr->s.m_length = encPwdLength + RadiusAttr::FixedHeaderLength;
+ memset(encPwdAttr->s.m_value, 0, encPwdLength);
if (origPwdLength > 0)
- memcpy(encPwdAttr->m_value, pwdAttr->m_value, origPwdLength);
+ memcpy(encPwdAttr->s.m_value, pwdAttr->s.m_value, origPwdLength);
// encrypt first 16 bytes of the password
- DWORD* buf1ptr = reinterpret_cast<DWORD*>(encPwdAttr->m_value);
+ DWORD* buf1ptr = reinterpret_cast<DWORD*>(encPwdAttr->s.m_value);
const DWORD* buf2ptr = reinterpret_cast<const DWORD*>(digest.GetPointer());
// XOR either byte-wise or dword-wise (if the memory block is aligned properly)
|