This repository has been archived by the owner on Oct 16, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrlm_osp.c
5614 lines (5038 loc) · 246 KB
/
rlm_osp.c
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
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
/*
* rlm_osp.c
*
* Version: $Id$
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*
* Copyright 2000,2006 The FreeRADIUS server project
* Copyright 2000 TransNexus, Inc. <[email protected]>
*/
#include <freeradius-devel/ident.h>
RCSID("$Id$")
/*
* Note: TURE/FALSE are defined in <freeradius-devel/radiusd.h>
*/
#include <freeradius-devel/radiusd.h>
#include <freeradius-devel/modules.h>
#ifdef HAVE_REGEX_H
#include <regex.h>
#endif
#include "osp/osp.h"
#include "osp/osputils.h"
#include "osp/ospb64.h"
/*
* OSP module version
*/
#define OSP_MODULE_VERSION_MAJOR 2
#define OSP_MODULE_VERSION_MINOR 5
#define OSP_MODULE_VERSION_BUGFIX 1
/*
* OSP module buffer size constants.
*/
#define OSP_TZNAME_SIZE 16
#define OSP_STRBUF_SIZE 256
#define OSP_KEYBUF_SIZE 1024
#define OSP_LOGBUF_SIZE 1024
/* Module configurations */
#define OSP_LOGLEVEL_DEF "1" /* Mapping default log level, long */
#define OSP_TZFILE_DEF "${raddbdir}/timezone.conf" /* Time zone configuration file */
#define OSP_TZ_DELIMITER " \t" /* Time zone item delimiter */
#define OSP_TZ_COMMENT '#' /* Time zone file comment */
#define OSP_TZ_MAX 512 /* Max number of time zones */
#define OSP_TZ_CACHE 8 /* Time zone cache size */
#define OSP_HWACCE_DEF "no" /* Mapping default hardware accelerate flag */
#define OSP_SECURITY_DEF "no" /* Mapping default security flag */
#define OSP_SPNUM_MAX 4 /* OSP max number of service points */
#define OSP_SPURI_DEF "http://osptestserver.transnexus.com:5045/osp" /* OSP default service point URI */
#define OSP_SPWEIGHT_DEF "1000" /* Mapping default service point weight */
#define OSP_AUDITURL_DEF "http://localhost:1234" /* OSP default Audit URL */
#define OSP_PRIVATEKEY_DEF "${raddbdir}/pkey.pem" /* OSP default private key file */
#define OSP_LOCALCERT_DEF "${raddbdir}/localcert.pem" /* OSP default localcert file */
#define OSP_CANUM_MAX 4 /* OSP max number of cacert files */
#define OSP_CACERT_DEF "${raddbdir}/cacert_0.pem" /* OSP default cacert file */
#define OSP_VALIDATION_DEF 1 /* OSP default token validation, locally */
#define OSP_SSLLIFETIME_DEF "300" /* Mapping default SSL life time in seconds */
#define OSP_SSLLIFETIME_MIN 0 /* OSP min SSL life time */
#define OSP_MAXCONN_DEF "20" /* Mapping default max number of connections */
#define OSP_MAXCONN_MIN 1 /* OSP min max number of connections */
#define OSP_MAXCONN_MAX 1000 /* OSP max max number of connections */
#define OSP_PERSISTENCE_DEF "60" /* Mapping default HTTP persistence in seconds */
#define OSP_PERSISTENCE_MIN 0 /* OSP min HTTP persistence */
#define OSP_RETRYDELAY_DEF "0" /* Mapping default retry delay */
#define OSP_RETRYDELAY_MIN 0 /* OSP min retry delay */
#define OSP_RETRYDELAY_MAX 10 /* OSP max retry delay */
#define OSP_RETRYLIMIT_DEF "2" /* Mapping default retry times */
#define OSP_RETRYLIMIT_MIN 0 /* OSP min retry times */
#define OSP_RETRYLIMIT_MAX 100 /* OSP max retry times */
#define OSP_TIMEOUT_DEF "10000" /* Mapping default timeout */
#define OSP_TIMEOUT_MIN 200 /* OSP min timeout in milliseconds */
#define OSP_TIMEOUT_MAX 60000 /* OSP max timeout in milliseconds */
#define OSP_DEVICEIP_DEF "localhost" /* Mapping default device IP */
#define OSP_DEVICEPORT_DEF "5060" /* Mapping default device port */
#define OSP_CUSTOMERID_DEF "" /* OSP default customer ID */
#define OSP_DEVICEID_DEF "" /* OSP default device ID */
/* VSA configurations */
#define OSP_IP_DEF 0 /* OSP default IP */
#define OSP_PORT_DEF 0 /* OSP default port */
#define OSP_DESTCOUNT_DEF 0 /* OSP default destination count, unknown */
#define OSP_CAUSE_DEF 0 /* OSP default termination cause */
#define OSP_CAUSE_UNKNOWN -1 /* OSP unknown termination cause */
#define OSP_TIME_DEF 0 /* OSP default time value */
#define OSP_STATSINT_DEF ((int)-1) /* OSP default statistics, integer */
#define OSP_STATSFLOAT_DEF ((float)-1.0) /* OSP default statistics, float */
#define OSP_SUBNET_MAX 4 /* OSP max number of subnets in a subnet list */
#define OSP_NETMASK_DEF 0xFFFFFFFF /* OSP default subnet mask */
#define OSP_NET_DELIMITER "/" /* OSP delimiter string for subnet (ip/mask) */
#define OSP_LIST_DELIMITER ",; " /* OSP delimiter string for subnet list */
#define OSP_CUSTOMINFO_MAX 8 /* OSP max number of custom info */
/*
* Default RADIUS OSP mapping
*/
#define OSP_MAP_NULL "NULL" /* Empty map */
#define OSP_MAP_IDITEM NULL /* RADIUS record identity VSA name */
#define OSP_MAP_IDVALUE NULL /* RADIUS record identity VSA value */
#define OSP_MAP_REPORT "yes" /* Report Stop, Start or Interim-Update RADIUS records */
#define OSP_MAP_CLIENTTYPE "0" /* RADIUS client type, undefined */
#define OSP_MAP_NETLIST NULL /* Subnet list */
#define OSP_MAP_SUBTYPE NULL /* Sub status type */
#define OSP_MAP_DIRECTION NULL /* Call direction */
#define OSP_MAP_IGNORERAD "no" /* Ingore inbound or outbound RADIUS records */
#define OSP_MAP_TRANSID NULL /* Transaction ID */
#define OSP_MAP_CALLID "%{Acct-Session-Id}" /* Call-ID, RFC 2866 */
#define OSP_MAP_NUMFORMAT "0" /* Calling/called number format, E.164 */
#define OSP_MAP_CALLING "%{Calling-Station-Id}" /* Calling number, RFC 2865 */
#define OSP_MAP_CALLED "%{Called-Station-Id}" /* Called number, RFC 2865 */
#define OSP_MAP_PARSETRANSFER "yes" /* Parse transfer VSAs in RADIUS records */
#define OSP_MAP_TRANSFERCALLING NULL /* Transfer calling number */
#define OSP_MAP_TRANSFERCALLED NULL /* Transfer called called number */
#define OSP_MAP_TRANSFERRET NULL /* Transfer result */
#define OSP_MAP_TRANSFERID NULL /* Transfer ID */
#define OSP_MAP_ANSWERIND NULL /* Answer indicator */
#define OSP_MAP_ASSERTEDID NULL /* P-Asserted-Identity */
#define OSP_MAP_RPID NULL /* Remote-Party-ID */
#define OSP_MAP_SOURCE "%{NAS-IP-Address}" /* Source, RFC 2865 */
#define OSP_MAP_PROXY NULL /* Proxy */
#define OSP_MAP_SRCDEV NULL /* Source device */
#define OSP_MAP_DESTINATION NULL /* Destination */
#define OSP_MAP_DESTDEV NULL /* Destination device */
#define OSP_MAP_DESTCOUNT NULL /* Destination count */
#define OSP_MAP_DEVICE NULL /* General device */
#define OSP_MAP_NETWORKID NULL /* Network ID */
#define OSP_MAP_DIVUSER NULL /* Diversion user */
#define OSP_MAP_DIVHOST NULL /* Diversion host */
#define OSP_MAP_TIMEFORMAT "0" /* Time string format, integer string */
#define OSP_MAP_START "%{Acct-Session-Start-Time}" /* Call start time, FreeRADIUS internal */
#define OSP_MAP_ALERT NULL /* Call alert time */
#define OSP_MAP_CONNECT NULL /* Call connect time */
#define OSP_MAP_END NULL /* Call end time */
#define OSP_MAP_DURATION "%{Acct-Session-Time}" /* Call duration, RFC 2866 */
#define OSP_MAP_PDDUNIT "1" /* PDD unit, millisecond */
#define OSP_MAP_PDD NULL /* Post dial delay */
#define OSP_MAP_PROVIDERPDD NULL /* Provider post dial delay */
#define OSP_MAP_RELEASE NULL /* Release source */
#define OSP_MAP_CAUSE NULL /* Release cause per protocol */
#define OSP_MAP_Q850CAUSE "%{Acct-Terminate-Cause}" /* Release cause, RFC 2866 */
#define OSP_MAP_PROTOCOL NULL /* Signaling protocol */
#define OSP_MAP_SESSIONID NULL /* Session ID */
#define OSP_MAP_CODEC NULL /* Codec */
#define OSP_MAP_CONFID NULL /* Conference ID */
#define OSP_MAP_CUSTOMINFO NULL /* User-defined info */
#define OSP_MAP_REALM NULL /* Realm */
#define OSP_MAP_CALLPARTYINFO NULL /* Call party info */
#define OSP_MAP_NETTRANSCALLED NULL /* Network translated called number */
#define OSP_MAP_SVCPROVIDERID NULL /* Service provider ID */
#define OSP_MAP_RELATEDREASON NULL /* Related Call-ID reason */
#define OSP_MAP_RECORDID NULL /* Record ID */
#define OSP_MAP_FROMDISPLAYFORMAT "0" /* Display name format, string */
#define OSP_MAP_FROMDISPLAY NULL /* Display name */
#define OSP_MAP_SRCAUDIOADDR NULL /* Source audio address */
#define OSP_MAP_SRCVIDEOADDR NULL /* Source video address */
#define OSP_MAP_DESTAUDIOADDR NULL /* Destination audio address */
#define OSP_MAP_DESTVIDEOADDR NULL /* Destination video address */
#define OSP_MAP_INGRESSADDR NULL /* Proxy ingress address */
#define OSP_MAP_EGRESSADDR NULL /* Proxy egress address */
#define OSP_MAP_JIP NULL /* JIP */
#define OSP_MAP_STATS NULL /* Statistics */
#define OSP_MAP_SCALE "4" /* Scale, 1 */
/* OSP module name */
#define OSP_STR_OSP "osp"
/* OSP module running parameter names */
#define OSP_STR_RUNNING "running"
#define OSP_STR_LOGLEVEL "loglevel"
#define OSP_STR_TZFILE "timezonefile"
/* OSP provider parameter names */
#define OSP_STR_PROVIDER "provider"
#define OSP_STR_ACCELERATE "accelerate"
#define OSP_STR_SECURITY "security"
#define OSP_STR_SPNUM "spnumber"
#define OSP_STR_SPURI "spuri"
#define OSP_STR_SPURI1 "spuri1"
#define OSP_STR_SPURI2 "spuri2"
#define OSP_STR_SPURI3 "spuri3"
#define OSP_STR_SPURI4 "spuri4"
#define OSP_STR_SPWEIGHT "spweight"
#define OSP_STR_SPWEIGHT1 "spweight1"
#define OSP_STR_SPWEIGHT2 "spweight2"
#define OSP_STR_SPWEIGHT3 "spweight3"
#define OSP_STR_SPWEIGHT4 "spweight4"
#define OSP_STR_PRIVATEKEY "privatekey"
#define OSP_STR_LOCALCERT "localcert"
#define OSP_STR_CANUM "canumber"
#define OSP_STR_CACERT "cacert"
#define OSP_STR_CACERT0 "cacert0"
#define OSP_STR_CACERT1 "cacert1"
#define OSP_STR_CACERT2 "cacert2"
#define OSP_STR_CACERT3 "cacert3"
#define OSP_STR_SSLLIFETIME "ssllifetime"
#define OSP_STR_MAXCONN "maxconnections"
#define OSP_STR_PERSISTENCE "persistence"
#define OSP_STR_RETRYDELAY "retrydelay"
#define OSP_STR_RETRYLIMIT "retrylimit"
#define OSP_STR_TIMEOUT "timeout"
#define OSP_STR_DEVICEIP "deviceip"
#define OSP_STR_DEVICEPORT "deviceport"
/* RADIUS OSP mapping parameter names */
#define OSP_STR_MAPPING "mapping"
#define OSP_STR_IDITEM "identityitem"
#define OSP_STR_IDVALUE "identityvalue"
#define OSP_STR_REPORTSTART "reportstart"
#define OSP_STR_REPORTSTOP "reportstop"
#define OSP_STR_REPORTINTERIM "reportinterim"
#define OSP_STR_CLIENTTYPE "clienttype"
#define OSP_STR_SUBTYPE "substatustype"
#define OSP_STR_IGNOREDDESTLIST "ignoreddestinationlist"
#define OSP_STR_DIRECTION "calldirection"
#define OSP_STR_IGNOREIN "ignoreinbound"
#define OSP_STR_IGNOREOUT "ignoreoutbound"
#define OSP_STR_TRANSACTIONID "transactionid"
#define OSP_STR_CALLID "callid"
#define OSP_STR_CALLINGFORMAT "callingnumberformat"
#define OSP_STR_CALLEDFORMAT "callednumberformat"
#define OSP_STR_CALLINGNUMBER "callingnumber"
#define OSP_STR_CALLEDNUMBER "callednumber"
#define OSP_STR_PARSETRANSFER "parsetransfer"
#define OSP_STR_TRANSFERCALLINGNUM "transfercallingnumber"
#define OSP_STR_TRANSFERCALLEDNUM "transfercallednumber"
#define OSP_STR_TRANSFERRET "transferresult"
#define OSP_STR_TRANSFERID "transferid"
#define OSP_STR_ASSERTEDID "assertedid"
#define OSP_STR_RPID "remotepartyid"
#define OSP_STR_SOURCE "source"
#define OSP_STR_PROXY "proxy"
#define OSP_STR_SRCDEVICE "sourcedevice"
#define OSP_STR_DESTINATION "destination"
#define OSP_STR_DESTDEVICE "destinationdevice"
#define OSP_STR_DESTCOUNT "destinationcount"
#define OSP_STR_ACCESSDEVICE "accessdevice"
#define OSP_STR_ROUTEDEVICE "routedevice"
#define OSP_STR_SRCNETWORKID "sourcenetworkid"
#define OSP_STR_DESTNETWORKID "destinationnetworkid"
#define OSP_STR_DIVERSIONUSER "diversionuser"
#define OSP_STR_DIVERSIONHOST "diversionhost"
#define OSP_STR_TIMEFORMAT "timestringformat"
#define OSP_STR_STARTTIME "starttime"
#define OSP_STR_ALERTTIME "alerttime"
#define OSP_STR_CONNECTTIME "connecttime"
#define OSP_STR_ENDTIME "endtime"
#define OSP_STR_DURATION "duration"
#define OSP_STR_PDDUNIT "postdialdelayunit"
#define OSP_STR_PDD "postdialdelay"
#define OSP_STR_PROVIDERPDD "providerpostdialdelay"
#define OSP_STR_RELEASE "releasesource"
#define OSP_STR_Q850CAUSE "q850releasecause"
#define OSP_STR_SIPCAUSE "sipreleasecause"
#define OSP_STR_PROTOCOL "signalingprotocol"
#define OSP_STR_SRCPROTOCOL "sourceprotocol"
#define OSP_STR_DESTPROTOCOL "destinationprotocol"
#define OSP_STR_SRCSESSIONID "sourcesessionid"
#define OSP_STR_DESTSESSIONID "destinationsessionid"
#define OSP_STR_CORRSESSIONID "correlationsessionid"
#define OSP_STR_ACCESSCALLID "accesscallid"
#define OSP_STR_ROUTECALLID "routecallid"
#define OSP_STR_LOCALCALLID "localcallid"
#define OSP_STR_REMOTECALLID "remotecallid"
#define OSP_STR_SRCCODEC "sourcecodec"
#define OSP_STR_DESTCODEC "destinationcodec"
#define OSP_STR_SRCVIDEOCODEC "sourcevideocodec"
#define OSP_STR_DESTVIDEOCODEC "destinationvideocodec"
#define OSP_STR_CONFID "conferenceid"
#define OSP_STR_CUSTOMINFO "custominfo"
#define OSP_STR_CUSTOMINFO1 "custominfo1"
#define OSP_STR_CUSTOMINFO2 "custominfo2"
#define OSP_STR_CUSTOMINFO3 "custominfo3"
#define OSP_STR_CUSTOMINFO4 "custominfo4"
#define OSP_STR_CUSTOMINFO5 "custominfo5"
#define OSP_STR_CUSTOMINFO6 "custominfo6"
#define OSP_STR_CUSTOMINFO7 "custominfo7"
#define OSP_STR_CUSTOMINFO8 "custominfo8"
#define OSP_STR_SRCREALM "sourcerealm"
#define OSP_STR_DESTREALM "destinationrealm"
#define OSP_STR_OTHERPARTY "otherpartyinfo"
#define OSP_STR_CALLINGUSERNAME "callingpartyusername"
#define OSP_STR_CALLINGUSERID "callingpartyuserid"
#define OSP_STR_CALLINGUSERGROUP "callingpartyusergroup"
#define OSP_STR_CALLEDUSERNAME "calledpartyusername"
#define OSP_STR_CALLEDUSERID "calledpartyuserid"
#define OSP_STR_CALLEDUSERGROUP "calledpartyusergroup"
#define OSP_STR_NETTRANSCALLEDFORMAT "networktranslatedcallednumberformat"
#define OSP_STR_NETTRANSCALLED "networktranslatedcallednumber"
#define OSP_STR_SVCPROVIDERID "serviceproviderid"
#define OSP_STR_RELATEDREASON "relatedcallidreason"
#define OSP_STR_RECORDID "recordid"
#define OSP_STR_FROMDISPLAYFORMAT "fromdisplaynameformat"
#define OSP_STR_FROMDISPLAY "fromdisplayname"
#define OSP_STR_SRCAUDIOADDR "sourceaudioaddress"
#define OSP_STR_SRCVIDEOADDR "sourcevideoaddress"
#define OSP_STR_DESTAUDIOADDR "destinationaudioaddress"
#define OSP_STR_DESTVIDEOADDR "destinationvideoaddress"
#define OSP_STR_INGRESSADDR "proxyingressaddress"
#define OSP_STR_EGRESSADDR "proxyegressaddress"
#define OSP_STR_JIP "jip"
/* Statistics parameter names */
#define OSP_STR_REPORTSTATS "reportstatistics"
#define OSP_STR_SLOSTPACKETS "sendlostpackets"
#define OSP_STR_SLOSTFRACTION "sendlostfraction"
#define OSP_STR_RLOSTPACKETS "receivelostpackets"
#define OSP_STR_RLOSTFRACTION "receivelostfraction"
#define OSP_STR_RTPSRCREPOCTETS "rtpsourcetoreporteroctets"
#define OSP_STR_RTPDESTREPOCTETS "rtpdestinationtoreporteroctets"
#define OSP_STR_RTPSRCREPPACKETS "rtpsourcetoreporterpackets"
#define OSP_STR_RTPDESTREPPACKETS "rtpdestinationtoreporterpackets"
#define OSP_STR_RTPSRCREPLOST "rtpsourcetoreporterlost"
#define OSP_STR_RTPDESTREPLOST "rtpdestinationtoreporterlost"
#define OSP_STR_RTPSRCREPJITTERMEAN "rtpsourcetoreporterjittermean"
#define OSP_STR_RTPDESTREPJITTERMEAN "rtpdestinationtoreporterjittermean"
#define OSP_STR_RTPSRCREPJITTERMAX "rtpsourcetoreporterjittermax"
#define OSP_STR_RTPDESTREPJITTERMAX "rtpdestinationtoreporterjittermax"
#define OSP_STR_RTCPSRCDESTLOST "rtcpsourcetodestinationlost"
#define OSP_STR_RTCPDESTSRCLOST "rtcpdestinationtosourcelost"
#define OSP_STR_RTCPSRCDESTJITTERMEAN "rtcpsourcetodestinationjittermean"
#define OSP_STR_RTCPDESTSRCJITTERMEAN "rtcpdestinationtosourcejittermean"
#define OSP_STR_RTCPSRCDESTJITTERMAX "rtcpsourcetodestinationjittermax"
#define OSP_STR_RTCPDESTSRCJITTERMAX "rtcpdestinationtosourcejittermax"
#define OSP_STR_RTCPSRCRTDELAYMEAN "rtcpsourceroundtripdelaymean"
#define OSP_STR_RTCPDESTRTDELAYMEAN "rtcpdestinationroundtripdelaymean"
#define OSP_STR_RTCPSRCRTDELAYMAX "rtcpsourceroundtripdelaymax"
#define OSP_STR_RTCPDESTRTDELAYMAX "rtcpdestinationroundtripdelaymax"
#define OSP_STR_RFACTORSCALE "rfactorscaleindex"
#define OSP_STR_SRCREPRFACTOR "sourcetoreporterrfactor"
#define OSP_STR_DESTREPRFACTOR "destinationtoreporterrfactor"
#define OSP_STR_MOSSCALE "mosscaleindex"
#define OSP_STR_SRCREPMOS "sourcetoreportermos"
#define OSP_STR_DESTREPMOS "destinationtoreportermos"
#define OSP_STR_RTPSRCREPVIDEOOCTETS "rtpsourcetoreportervideooctets"
#define OSP_STR_RTPDESTREPVIDEOOCTETS "rtpdestinationtoreportervideooctets"
#define OSP_STR_RTPSRCREPVIDEOPACKETS "rtpsourcetoreportervideopackets"
#define OSP_STR_RTPDESTREPVIDEOPACKETS "rtpdestinationtoreportervideopackets"
#define OSP_STR_RTPSRCREPVIDEOLOST "rtpsourcetoreportervideolost"
#define OSP_STR_RTPDESTREPVIDEOLOST "rtpdestinationtoreportervideolost"
#define OSP_STR_RTPSRCREPVIDEOJITTERMEAN "rtpsourcetoreportervideojittermean"
#define OSP_STR_RTPDESTREPVIDEOJITTERMEAN "rtpdestinationtoreportervideojittermean"
#define OSP_STR_RTPSRCREPVIDEOJITTERMAX "rtpsourcetoreportervideojittermax"
#define OSP_STR_RTPDESTREPVIDEOJITTERMAX "rtpdestinationtoreportervideojittermax"
#define OSP_STR_RTCPSRCDESTVIDEOLOST "rtcpsourcetodestinationvideolost"
#define OSP_STR_RTCPDESTSRCVIDEOLOST "rtcpdestinationtosourcevideolost"
#define OSP_STR_RTCPSRCDESTVIDEOJITTERMEAN "rtcpsourcetodestinationvideojittermean"
#define OSP_STR_RTCPDESTSRCVIDEOJITTERMEAN "rtcpdestinationtosourcevideojittermean"
#define OSP_STR_RTCPSRCDESTVIDEOJITTERMAX "rtcpsourcetodestinationvideojittermax"
#define OSP_STR_RTCPDESTSRCVIDEOJITTERMAX "rtcpdestinationtosourcevideojittermax"
#define OSP_STR_RTCPSRCVIDEORTDELAYMEAN "rtcpsourcevideoroundtripdelaymean"
#define OSP_STR_RTCPDESTVIDEORTDELAYMEAN "rtcpdestinationvideoroundtripdelaymean"
#define OSP_STR_RTCPSRCVIDEORTDELAYMAX "rtcpsourcevideoroundtripdelaymax"
#define OSP_STR_RTCPDESTVIDEORTDELAYMAX "rtcpdestinationvideoroundtripdelaymax"
/* NAS */
#define OSP_STR_NASIP "NAS-IP-Address"
#define OSP_MAP_NASIP "%{NAS-IP-Address}"
/*
* OSP log level
*/
typedef enum {
OSP_LOG_SHORT = 0, /* Log short message */
OSP_LOG_LONG /* Log long message */
} osp_loglevel_e;
/*
* OSP mapping define level
*/
typedef enum {
OSP_DEF_MUST = 0, /* Mapping must be defined */
OSP_DEF_MAY /* Mapping may be defined */
} osp_deflevel_e;
/*
* General scale
*/
typedef enum {
OSP_SCALE_MIN = 0,
OSP_SCALE_00001 = OSP_SCALE_MIN, /* 0.0001 */
OSP_SCALE_0001, /* 0.001 */
OSP_SCALE_001, /* 0.01 */
OSP_SCALE_01, /* 0.1 */
OSP_SCALE_1, /* 1 */
OSP_SCALE_10, /* 10 */
OSP_SCALE_100, /* 100 */
OSP_SCALE_1000, /* 1000 */
OSP_SCALE_10000, /* 10000 */
OSP_SCALE_MAX = OSP_SCALE_10000,
OSP_SCALE_NUMBER
} osp_scale_e;
static const float OSP_SCALE_TABLE[OSP_SCALE_NUMBER] = { 0.0001, 0.001, 0.01, 0.1, 1, 10, 100, 1000, 10000 };
/*
* Time unit
*/
typedef enum {
OSP_TIMEUNIT_MIN = 0,
OSP_TIMEUNIT_S = OSP_TIMEUNIT_MIN, /* Second */
OSP_TIMEUNIT_MS, /* Millisecond */
OSP_TIMEUNIT_MAX = OSP_TIMEUNIT_MS,
OSP_TIMEUNIT_NUMBER
} osp_timeunit_e;
static const int OSP_TIMEUNIT_SCALE[OSP_TIMEUNIT_NUMBER] = { 1000, 1 };
/*
* Integer string format types
*/
typedef enum {
OSP_INTSTR_MIN = 0,
OSP_INTSTR_DEC = OSP_INTSTR_MIN, /* Decimal */
OSP_INTSTR_HEX, /* Hex */
OSP_INTSTR_MAX = OSP_INTSTR_HEX,
OSP_INTSTR_NUMBER
} osp_intstr_e;
/*
* RADIUS client types
*/
typedef enum {
OSP_CLIENT_MIN = 0,
OSP_CLIENT_UNDEF = OSP_CLIENT_MIN, /* Undefined */
OSP_CLIENT_ACME, /* Acme */
OSP_CLIENT_GENBANDS3, /* GENBAND S3 */
OSP_CLIENT_CISCO, /* Cisco */
OSP_CLIENT_BROADWORKS, /* BroadWorks */
OSP_CLIENT_MAX = OSP_CLIENT_BROADWORKS,
OSP_CLIENT_NUMBER
} osp_client_e;
#define OSP_CLIENTNAME_ACME "Acme" /* Acme */
#define OSP_CLIENTNAME_GENBANDS3 "GENBANDS3" /* GENBAND S3 */
#define OSP_CLIENTNAME_CISCO "Cisco" /* Cisco */
#define OSP_CLIENTNAME_BROADWORKS "BroadWorks" /* BroadWorks */
/*
* OSP time string types
*/
typedef enum {
OSP_TIMESTR_MIN = 0,
OSP_TIMESTR_T = OSP_TIMESTR_MIN, /* time_t, integer string */
OSP_TIMESTR_C, /* ctime, WWW MMM DD hh:mm:ss YYYY */
OSP_TIMESTR_ACME, /* Acme, hh:mm:ss.kkk ZON MMM DD YYYY */
OSP_TIMESTR_NTP, /* NTP, hh:mm:ss.kkk ZON WWW MMM DD YYYY */
OSP_TIMESTR_CISCO, /* NTP, {'*'|'.'}hh:mm:ss.kkk ZON WWW MMM DD YYYY */
OSP_TIMESTR_BW, /* BroadWorks, YYYYMMDDhhmmss.kkk */
OSP_TIMESTR_MAX = OSP_TIMESTR_BW,
OSP_TIMESTR_NUMBER
} osp_timestr_e;
/*
* Calling/called number format types
*/
typedef enum {
OSP_CALLNUM_MIN = 0,
OSP_CALLNUM_E164 = OSP_CALLNUM_MIN, /* E.164 */
OSP_CALLNUM_SIPURI, /* SIP URI */
OSP_CALLNUM_E164SIPURI, /* E.164 or SIP URI */
OSP_CALLNUM_CISCO, /* Cisco, ton:0~7,npi:0~15,pi:0~3,si:0~3,#:E.164 */
OSP_CALLNUM_MAX = OSP_CALLNUM_CISCO,
OSP_CALLNUM_NUMBER
} osp_callnum_e;
/*
* Display name format types
*/
typedef enum {
OSP_DISPLAY_MIN = 0,
OSP_DISPLAY_STRING = OSP_DISPLAY_MIN, /* String */
OSP_DISPLAY_NAMEADDR, /* name-addr */
OSP_DISPLAY_MAX = OSP_DISPLAY_NAMEADDR,
OSP_DISPLAY_NUMBER
} osp_display_e;
/*
* Media stream type
*/
typedef enum {
OSP_MEDIA_MIN = 0,
OSP_MEDIA_VOICE = OSP_MEDIA_MIN, /* Voice */
OSP_MEDIA_VIDEO, /* Video */
OSP_MEDIA_MAX = OSP_MEDIA_VIDEO,
OSP_MEDIA_NUMBER
} osp_media_e;
/*
* Cisco h323-call-origin value strings
*/
#define OSP_CISCOCALL_IN "answer" /* Call answer, inbound */
#define OSP_CISCOCALL_OUT "originate" /* Call originate, outbound */
/*
* BroadWorks BWAS-Direction value strings
*/
#define OSP_BWCALL_IN "Originating" /* Call originating, inbound */
#define OSP_BWCALL_OUT "Terminating" /* Call termianting, outbound */
/*
* Call direction types
*/
typedef enum {
OSP_DIRECTION_IN = 0, /* Inbound */
OSP_DIRECTION_OUT, /* Outbound */
} osp_direction_e;
/*
* Acme release source
*/
typedef enum {
OSP_ACMEREL_UNDEF = 0, /* Unknown */
OSP_ACMEREL_SRC, /* Source releases the call */
OSP_ACMEREL_DEST, /* Destination releases the call */
OSP_ACMEREL_INT, /* Internal releases the call */
} osp_acmerelease_e;
/*
* Cisco release source
*/
typedef enum {
OSP_CISCOREL_UNDEF = 0,
OSP_CISCOREL_CALLINGPSTN,
OSP_CISCOREL_CALLINGVOIP,
OSP_CISCOREL_CALLEDPSTN,
OSP_CISCOREL_CALLEDVOIP,
OSP_CISCOREL_INTPOST,
OSP_CISCOREL_INTVOIP,
OSP_CISCOREL_INTAPPL,
OSP_CISCOREL_INTAAA,
OSP_CISCOREL_CONSOLE,
OSP_CISCOREL_EXTRADIUS,
OSP_CISCOREL_EXTAPPL,
OSP_CISCOREL_EXTAGENT
} osp_ciscorelease_e;
/*
* BroadWorks record ID regular expression
*/
#define OSP_BWRID_NMATCH 3
#define OSP_BWRID_PATTERN "([0-9]{10})(.*)([0-9]{14}\\.[0-9]{3})(.*)"
/*
* BroadWorks release source
*/
#define OSP_BWREL_NONE "none"
#define OSP_BWREL_LOCAL "local"
#define OSP_BWREL_REMOTE "remote"
/*
* BroadWorks sub status type
*/
#define OSP_BWTYPE_START "Start" /* Start */
#define OSP_BWTYPE_END "End" /* End */
#define OSP_BWTYPE_DURATION "Long Diration" /* Long Duration */
#define OSP_BWTYPE_NORMAL "Normal" /* Normal */
#define OSP_BWTYPE_INTERIM "Interim" /* Interim */
#define OSP_BWTYPE_FAILOVER "Failover" /* Failover */
/*
* BroadWorks special device names
*/
#define OSP_BWDEV_GROUP "Group"
#define OSP_BWDEV_ENTERPRISE "Enterprise"
#define OSP_BWDEV_UNCONFIRMED "unconfirmed"
#define OSP_BWDEV_UNAVAILABLE "unavailable"
/*
* BroadWorks transfer results
*/
#define OSP_BWTRANSFERRET_FAILURE "Failure"
#define OSP_BWTRANSFERRET_SUCCESS "Success"
/*
* Normal string buffer type
*/
typedef char osp_string_t[OSP_STRBUF_SIZE];
/*
* Time zone
*/
typedef struct {
char name[OSP_TZNAME_SIZE];
int offset;
} osp_timezone_t;
/*
* OSP module running parameter structure
*/
typedef struct {
int loglevel;
char* tzfile;
int tzlist_size;
osp_timezone_t tzlist[OSP_TZ_MAX];
regex_t bwrid;
} osp_running_t;
/*
* OSP module provider parameter structure.
*/
typedef struct {
int accelerate; /* Hardware accelerate flag */
int security; /* Security flag */
int spnumber; /* Number of service points */
char* spuris[OSP_SPNUM_MAX]; /* Service point URIs */
int spweights[OSP_SPNUM_MAX]; /* Service point weights */
char* privatekey; /* Private key file name */
char* localcert; /* Local cert file name */
int canumber; /* Number of cacerts */
char* cacerts[OSP_CANUM_MAX]; /* Cacert file names */
int ssllifetime; /* SSL life time */
int maxconn; /* Max number of HTTP connections */
int persistence; /* Persistence */
int retrydelay; /* Retry delay */
int retrylimit; /* Times of retry */
int timeout; /* Timeout */
uint32_t deviceip; /* OSP reporting IP address */
int deviceport; /* OSP reporting IP port */
OSPTPROVHANDLE handle; /* OSP provider handle */
} osp_provider_t;
/*
* Subnet
*/
typedef struct {
uint32_t ip; /* Subnet IP */
uint32_t mask; /* Subnet mask */
} osp_subnet_t;
/*
* Subnet list
*/
typedef struct {
int number; /* Number of subnets */
osp_subnet_t subnet[OSP_SUBNET_MAX]; /* Subnets */
} osp_netlist_t;
typedef struct {
char* pack; /* Packets lost in packets mapping */
char* fract; /* Packets lost in fraction mapping */
} osp_packmap_t;
typedef struct {
int reportstats; /* If to report statistics */
osp_packmap_t slost; /* Lost send mapping */
osp_packmap_t rlost; /* Lost receive mapping */
char* rtp_src_rep_octets[OSP_MEDIA_NUMBER]; /* RTP source-to-reporter octets */
char* rtp_dest_rep_octets[OSP_MEDIA_NUMBER]; /* RTP destination-to-reporter octets */
char* rtp_src_rep_packets[OSP_MEDIA_NUMBER]; /* RTP source-to-reporter packets */
char* rtp_dest_rep_packets[OSP_MEDIA_NUMBER]; /* RTP destination-to-reporter packets */
char* rtp_src_rep_lost[OSP_MEDIA_NUMBER]; /* RTP source-to-reporter lost packets */
char* rtp_dest_rep_lost[OSP_MEDIA_NUMBER]; /* RTP destination-to-reporter lost packets */
char* rtp_src_rep_jitter_mean[OSP_MEDIA_NUMBER]; /* RTP source-to-reporter jitter mean */
char* rtp_dest_rep_jitter_mean[OSP_MEDIA_NUMBER]; /* RTP destination-to-reporter jitter mean */
char* rtp_src_rep_jitter_max[OSP_MEDIA_NUMBER]; /* RTP source-to-reporter jitter max */
char* rtp_dest_rep_jitter_max[OSP_MEDIA_NUMBER]; /* RTP destination-to-reporter jitter max */
char* rtcp_src_dest_lost[OSP_MEDIA_NUMBER]; /* RTCP source-to-destination lost packets */
char* rtcp_dest_src_lost[OSP_MEDIA_NUMBER]; /* RTCP destination-to-source lost packets */
char* rtcp_src_dest_jitter_mean[OSP_MEDIA_NUMBER]; /* RTCP source-to-destination jitter mean */
char* rtcp_dest_src_jitter_mean[OSP_MEDIA_NUMBER]; /* RTCP destination-to-source jitter mean */
char* rtcp_src_dest_jitter_max[OSP_MEDIA_NUMBER]; /* RTCP source-to-destination jitter max */
char* rtcp_dest_src_jitter_max[OSP_MEDIA_NUMBER]; /* RTCP destination-to-source jitter max */
char* rtcp_src_rtdelay_mean[OSP_MEDIA_NUMBER]; /* RTCP source round trip delay mean */
char* rtcp_dest_rtdelay_mean[OSP_MEDIA_NUMBER]; /* RTCP destination round trip delay mean */
char* rtcp_src_rtdelay_max[OSP_MEDIA_NUMBER]; /* RTCP source round trip delay max */
char* rtcp_dest_rtdelay_max[OSP_MEDIA_NUMBER]; /* RTCP destination round trip delay max */
int rfactorscale; /* R-Factor scale index */
char* src_rep_rfactor; /* Source-to-reporter R-Factor */
char* dest_rep_rfactor; /* Destination-to-reporter R-Factor */
int mosscale; /* MOS scale index */
char* src_rep_mos; /* Source-to-reporter MOS */
char* dest_rep_mos; /* Destination-to-reporter MOS */
} osp_statsmap_t;
/*
* OSP module mapping parameter structure.
*/
typedef struct {
char* iditem; /* RADIUS record identity VSA name */
char* idvalue; /* RADIUS record identity VSA value */
int reportstart; /* If to report RADIUS Start records */
int reportstop; /* If to report RADIUS Stop records */
int reportinterim; /* If to report RADIUS Interim-Update records */
int clienttype; /* RADIUS client type */
char* subtype; /* Sub status type */
char* ignoreddeststr; /* Ignored destination subnet list string */
osp_netlist_t ignoreddestlist; /* Ignored destination subnet list */
char* direction; /* Call direction */
int ignorein; /* Ignore inbound records */
int ignoreout; /* Ignore outbound records */
char* transid; /* Transaction ID */
char* callid; /* Call-ID */
int callingformat; /* Calling number format */
int calledformat; /* Called number format */
char* calling; /* Calling number */
char* called; /* Called number */
int parsetransfer; /* If to parse transfer VSAs in RADIUS records */
char* transfercalling; /* Transfer calling number */
char* transfercalled; /* Transfer called number */
char* transferret; /* Transfer result */
char* transferid; /* Transfer ID */
char* assertedid; /* P-Asserted-Identity */
char* rpid; /* Remote-Party-ID */
char* source; /* Source */
char* proxy; /* Proxy, only for call leg type records */
char* srcdev; /* Source device */
char* destination; /* Destination */
char* destdev; /* Destination device */
char* destcount; /* Destination count */
char* accessdev; /* Access device */
char* routedev; /* Route device */
char* srcnid; /* Source network ID */
char* destnid; /* Destination network ID */
char* divuser; /* Diversion user */
char* divhost; /* Diversion host */
int timeformat; /* Time string format */
char* start; /* Call start time */
char* alert; /* Call alert time */
char* connect; /* Call connect time */
char* end; /* Call end time */
char* duration; /* Call duration */
int pddunit; /* Post dial delay unit */
char* pdd; /* Post dial delay */
char* release; /* Release source */
char* q850cause; /* Release cause, Q850 */
char* sipcause; /* Release cause, SIP */
char* protocol; /* Signaling protocol */
char* srcprotocol; /* Source protocol */
char* destprotocol; /* Destination protocol */
char* srcsessionid; /* Source sessionID */
char* destsessionid; /* Destination session ID */
char* corrsessionid; /* Correlation session ID */
char* accesscallid; /* Access call ID */
char* routecallid; /* Route call ID */
char* localcallid; /* Local call ID */
char* remotecallid; /* Remote call ID */
char* srccodec[OSP_MEDIA_NUMBER]; /* Source codec */
char* destcodec[OSP_MEDIA_NUMBER]; /* Destination codec */
char* confid; /* Conference ID */
char* custinfo[OSP_CUSTOMINFO_MAX]; /* Custom info */
char* srcrealm; /* Source realm */
char* destrealm; /* Destination realm */
char* otherparty; /* Other party info */
char* callingusername; /* Calling party user name */
char* callinguserid; /* Calling party user ID */
char* callingusergroup; /* Calling party user group */
char* calledusername; /* Called party user name */
char* calleduserid; /* Called party user ID */
char* calledusergroup; /* Called party user group */
int nettranscalledformat; /* Network translated called number format */
char* nettranscalled; /* Network translated called number */
char* svcproviderid; /* Service provider ID */
char* relatedreason; /* Related Call-ID reason */
char* recordid; /* Record ID */
int fromdisplayformat; /* From display name format */
char* fromdisplay; /* From display name */
char* srcaudioaddr; /* Source audio address */
char* srcvideoaddr; /* Source video address */
char* destaudioaddr; /* Destination audio address */
char* destvideoaddr; /* Destination video address */
char* ingressaddr; /* Proxy ingress address */
char* egressaddr; /* Proxy egress address */
char* providerpdd; /* Provider post dial delay */
char* jip; /* JIP */
osp_statsmap_t stats; /* Statistics */
} osp_mapping_t;
/*
* OSP module instance data structure.
*/
typedef struct {
osp_running_t running; /* OSP module running parameters */
osp_provider_t provider; /* OSP provider parameters */
osp_mapping_t mapping; /* OSP mapping parameters */
} rlm_osp_t;
typedef struct {
int pack; /* Packets lost in packets */
int fract; /* Packets lost in fraction */
} osp_pack_t;
typedef struct {
osp_pack_t slost; /* Send packets lost */
osp_pack_t rlost; /* Receive packets lost */
int rtp_src_rep_octets[OSP_MEDIA_NUMBER]; /* RTP source-to-reporter octets */
int rtp_dest_rep_octets[OSP_MEDIA_NUMBER]; /* RTP destination-to-reporter octets */
int rtp_src_rep_packets[OSP_MEDIA_NUMBER]; /* RTP source-to-reporter packets */
int rtp_dest_rep_packets[OSP_MEDIA_NUMBER]; /* RTP destination-to-reporter packets */
int rtp_src_rep_lost[OSP_MEDIA_NUMBER]; /* RTP source-to-reporter lost packets */
int rtp_dest_rep_lost[OSP_MEDIA_NUMBER]; /* RTP destination-to-reporter lost packets */
int rtp_src_rep_jitter_mean[OSP_MEDIA_NUMBER]; /* RTP source-to-reporter jitter mean */
int rtp_dest_rep_jitter_mean[OSP_MEDIA_NUMBER]; /* RTP destination-to-reporter jitter mean */
int rtp_src_rep_jitter_max[OSP_MEDIA_NUMBER]; /* RTP source-to-reporter jitter max */
int rtp_dest_rep_jitter_max[OSP_MEDIA_NUMBER]; /* RTP destination-to-reporter jitter max */
int rtcp_src_dest_lost[OSP_MEDIA_NUMBER]; /* RTCP source-to-destination lost packets */
int rtcp_dest_src_lost[OSP_MEDIA_NUMBER]; /* RTCP destination-to-source lost packets */
int rtcp_src_dest_jitter_mean[OSP_MEDIA_NUMBER]; /* RTCP source-to-destination jitter mean */
int rtcp_dest_src_jitter_mean[OSP_MEDIA_NUMBER]; /* RTCP destination-to-source jitter mean */
int rtcp_src_dest_jitter_max[OSP_MEDIA_NUMBER]; /* RTCP source-to-destination jitter max */
int rtcp_dest_src_jitter_max[OSP_MEDIA_NUMBER]; /* RTCP destination-to-source jitter max */
int rtcp_src_rtdelay_mean[OSP_MEDIA_NUMBER]; /* RTCP source round trip delay mean */
int rtcp_dest_rtdelay_mean[OSP_MEDIA_NUMBER]; /* RTCP destination round trip delay mean */
int rtcp_src_rtdelay_max[OSP_MEDIA_NUMBER]; /* RTCP source round trip delay max */
int rtcp_dest_rtdelay_max[OSP_MEDIA_NUMBER]; /* RTCP destination round trip delay max */
float src_rep_rfactor; /* Source-to-reporter R-Factor */
float dest_rep_rfactor; /* Destination-to-reporter R-Factor */
float src_rep_mos; /* Source-to-reporter MOS */
float dest_rep_mos; /* Destination-to-reporter MOS */
} osp_stats_t;
/*
* Usage information structure.
*/
typedef struct {
osp_string_t nas; /* NAS-IP-Address */
osp_string_t subtype; /* Sub status type */
int direction; /* Call direction */
OSPTUINT64 transid; /* Transaction ID */
osp_string_t callid; /* Call-ID */
osp_string_t calling; /* Calling number */
osp_string_t called; /* Called number */
osp_string_t transferid; /* Transfer ID */
OSPE_TRANSFER_STATUS transfer; /* Transfer status */
osp_string_t assertedid; /* P-Asserted-Identity */
osp_string_t rpid; /* Remote-Party-ID */
osp_string_t source; /* Source */
osp_string_t srcdev; /* Source device */
osp_string_t destination; /* Destination */
osp_string_t destdev; /* Destination device */
int destcount; /* Destination count */
osp_string_t srcnid; /* Source network ID */
osp_string_t destnid; /* Destination network ID */
osp_string_t divuser; /* Diversion user */
osp_string_t divhost; /* Diversion host */
time_t start; /* Call start time */
time_t alert; /* Call alert time */
time_t connect; /* Call connect time */
time_t end; /* Call end time */
time_t duration; /* Length of call */
int pdd; /* Post Dial Delay, in milliseconds */
OSPE_RELEASE release; /* EP that released the call */
int q850cause; /* Release reason, Q850 */
int sipcause; /* Release reason, SIP */
OSPE_PROTOCOL_NAME protocol; /* Signaling protocol */
OSPE_PROTOCOL_NAME srcprotocol; /* Source protocol */
OSPE_PROTOCOL_NAME destprotocol; /* Destination protocol */
osp_string_t srcsessionid; /* Source session ID */
osp_string_t destsessionid; /* Destination session ID */
osp_string_t corrsessionid; /* Correlation session ID */
osp_string_t localcallid; /* Local call ID */
osp_string_t remotecallid; /* Remote call ID */
osp_string_t srccodec[OSP_MEDIA_NUMBER]; /* Source codec */
osp_string_t destcodec[OSP_MEDIA_NUMBER]; /* Destination codec */
osp_string_t confid; /* Conference ID */
osp_string_t custinfo[OSP_CUSTOMINFO_MAX]; /* Custom info */
osp_string_t srcrealm; /* Source realm */
osp_string_t destrealm; /* Destination realm */
osp_string_t otherparty; /* Other party info */
osp_string_t callingusername; /* Calling party user name */
osp_string_t callinguserid; /* Calling party user ID */
osp_string_t callingusergroup; /* Calling party user group */
osp_string_t calledusername; /* Called party user name */
osp_string_t calleduserid; /* Called party user ID */
osp_string_t calledusergroup; /* Called party user group */
osp_string_t nettranscalled; /* Network translated called number */
osp_string_t svcproviderid; /* Service provider ID */
osp_string_t relatedreason; /* Related Call-ID reason */
osp_string_t recordid; /* Record ID */
osp_string_t fromdisplay; /* From display name */
osp_string_t srcaudioaddr; /* Source audio address */
osp_string_t srcvideoaddr; /* Source video address */
osp_string_t destaudioaddr; /* Destination audio address */
osp_string_t destvideoaddr; /* Destination video address */
osp_string_t ingressaddr; /* Proxy ingress address */
osp_string_t egressaddr; /* Proxy egress address */
int providerpdd; /* Provider post dial delay, in milliseconds */
osp_string_t jip; /* JIP */
osp_stats_t stats; /* Statistics */
} osp_usage_t;
/*
* Macros
*/
/*
* Check empty string
*
* param _str String to be checked
*/
#define OSP_CHECK_STRING(_str) ((_str != NULL) && (_str[0] != '\0'))
/*
* Check value min
*
* param _name Variable name
* param _val Variable value
* param _min Min value
*/
#define OSP_CHECK_MIN(_name, _val, _min) { \
if (_val <= _min) { \
radlog(L_ERR, "rlm_osp: '%s' must be larger than '%d', not '%d'.", _name, _min - 1, _val); \
return -1; \
} \
DEBUG2("rlm_osp: '%s' = '%d'", _name, _val); \
}
/*
* Check value range
*
* param _name Variable name
* param _val Variable value
* param _min Min value
* param _max Max value
*/
#define OSP_CHECK_RANGE(_name, _val, _min, _max) { \
if ((_val < _min) || (_val > _max)) { \
radlog(L_ERR, "rlm_osp: '%s' must be an integer from '%d' to '%d', not '%d'.", _name, _min, _max, _val); \
return -1; \
} \
DEBUG2("rlm_osp: '%s' = '%d'", _name, _val); \
}
/*
* Check item mapping
*
* param _name Item name
* param _lev Must or may be defined
* param _map Item mapping string
*/
#define OSP_CHECK_ITEMMAP(_name, _lev, _map) { \
DEBUG3("rlm_osp: check '%s' mapping", _name); \
if (OSP_CHECK_STRING(_map) && !strcasecmp(_map, OSP_MAP_NULL)) { \
_map = NULL; \
} \
if (osp_check_itemmap(_map, _lev) < 0) { \
if (OSP_CHECK_STRING(_map)) { \
radlog(L_ERR, "rlm_osp: Incorrect '%s' mapping '%s'.", _name, _map); \
} else { \
radlog(L_ERR, "rlm_osp: Incorrect '%s' mapping 'NULL'.", _name); \
} \
return -1; \
} \
if (OSP_CHECK_STRING(_map)) { \
DEBUG2("rlm_osp: '%s' = '%s'", _name, _map); \
} else { \
/* Undefined may be defined item */ \
DEBUG2("rlm_osp: '%s' = 'NULL'", _name); \
} \
}
/*
* Get integer
*
* param _req FreeRADIUS request
* param _flag Parse flag
* param _name Item name
* param _lev Must or may be defined
* param _map Item mapping string
* param _fmt Integer string format
* param _def Item default value
* param _buf Buffer
* param _val Item value
*/
#define OSP_GET_INTEGER(_req, _flag, _name, _lev, _map, _fmt, _def, _buf, _val) { \
if (_flag) { \
if (OSP_CHECK_STRING(_map)) { \
radius_xlat(_buf, sizeof(_buf), _map, _req, NULL); \
if (_buf[0] == '\0') { \
/* Has checked string NULL */ \
if (_lev == OSP_DEF_MUST) { \
radlog(L_ERR, "rlm_osp: Failed to parse '%s' in request for '%s'.", _map, _name); \
return -1; \
} else { \
DEBUG("rlm_osp: failed to parse '%s' in request for '%s'.", _map, _name); \
_val = _def; \
} \
} else { \
if (_fmt == OSP_INTSTR_HEX) { \
sscanf(_buf, "%x", &_val); \
} else { \
_val = atoi(_buf); \
} \
} \
} else { \
if (_lev == OSP_DEF_MUST) { \
radlog(L_ERR, "rlm_osp: '%s' mapping undefined.", _name); \