annotate extensions/app_radgw/rgwx_acct.c @ 541:fac6907479ad

Free state memory after use.
author Sebastien Decugis <sdecugis@nict.go.jp>
date Sat, 11 Sep 2010 09:21:28 +0900
parents 616848d6f020
children 603f70bf1453
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
259
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1 /*********************************************************************************************************
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
2 * Software License Agreement (BSD License) *
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
3 * Author: Sebastien Decugis <sdecugis@nict.go.jp> *
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
4 * *
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
5 * Copyright (c) 2010, WIDE Project and NICT *
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
6 * All rights reserved. *
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
7 * *
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
8 * Redistribution and use of this software in source and binary forms, with or without modification, are *
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
9 * permitted provided that the following conditions are met: *
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
10 * *
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
11 * * Redistributions of source code must retain the above *
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
12 * copyright notice, this list of conditions and the *
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
13 * following disclaimer. *
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
14 * *
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
15 * * Redistributions in binary form must reproduce the above *
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
16 * copyright notice, this list of conditions and the *
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
17 * following disclaimer in the documentation and/or other *
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
18 * materials provided with the distribution. *
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
19 * *
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
20 * * Neither the name of the WIDE Project or NICT nor the *
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
21 * names of its contributors may be used to endorse or *
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
22 * promote products derived from this software without *
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
23 * specific prior written permission of WIDE Project and *
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
24 * NICT. *
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
25 * *
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
26 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED *
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
27 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
28 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR *
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
29 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT *
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
30 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS *
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
31 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR *
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
32 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF *
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
33 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
34 *********************************************************************************************************/
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
35
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
36 /* RADIUS Accounting-Request messages translation plugin */
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
37
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
38 #include "rgw_common.h"
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
39
271
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
40
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
41 /* Other constants we use */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
42 #define AI_ACCT 3 /* Diameter Base Accounting application */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
43 #define CC_AC 271 /* ACR/ACA */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
44 #define ACV_ART_START_RECORD 2 /* START_RECORD */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
45 #define ACV_ART_INTERIM_RECORD 3 /* INTERIM_RECORD */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
46 #define ACV_ART_STOP_RECORD 4 /* STOP_RECORD */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
47 #define ACV_ART_AUTHORIZE_AUTHENTICATE 3 /* AUTHORIZE_AUTHENTICATE */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
48 #define ER_DIAMETER_LIMITED_SUCCESS 2002
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
49
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
50
259
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
51 /* The state we keep for this plugin */
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
52 struct rgwp_config {
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
53 struct {
277
c94e4ea39f97 Add missing mandatory AVP
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 275
diff changeset
54 struct dict_object * Accounting_Record_Number; /* Accounting-Record-Number */
271
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
55 struct dict_object * Accounting_Record_Type; /* Accounting-Record-Type */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
56 struct dict_object * Acct_Application_Id; /* Acct-Application-Id */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
57 struct dict_object * Acct_Delay_Time; /* Acct-Delay-Time */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
58 struct dict_object * Accounting_Input_Octets; /* Accounting-Input-Octets */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
59 struct dict_object * Accounting_Output_Octets; /* Accounting-Output-Octets */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
60 struct dict_object * Accounting_Input_Packets; /* Accounting-Input-Packets */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
61 struct dict_object * Accounting_Output_Packets; /* Accounting-Output-Packets */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
62 struct dict_object * Acct_Link_Count; /* Acct-Link-Count */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
63 struct dict_object * Acct_Authentic; /* Acct-Authentic */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
64 struct dict_object * Acct_Multi_Session_Id; /* Acct-Multi-Session-Id */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
65 struct dict_object * Acct_Session_Id; /* Acct-Session-Id */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
66 struct dict_object * Acct_Session_Time; /* Acct-Session-Time */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
67
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
68 struct dict_object * ARAP_Password; /* ARAP-Password */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
69 struct dict_object * ARAP_Security; /* ARAP-Security */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
70 struct dict_object * ARAP_Security_Data; /* ARAP-Security-Data */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
71 struct dict_object * Auth_Application_Id; /* Auth-Application-Id */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
72 struct dict_object * Auth_Request_Type; /* Auth-Request-Type */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
73 struct dict_object * Authorization_Lifetime; /* Authorization-Lifetime */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
74 struct dict_object * Callback_Number; /* Callback-Number */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
75 struct dict_object * Callback_Id; /* Callback-Id */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
76 struct dict_object * Called_Station_Id; /* Called-Station-Id */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
77 struct dict_object * Calling_Station_Id; /* Calling-Station-Id */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
78 struct dict_object * Class; /* Class */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
79 struct dict_object * CHAP_Algorithm; /* CHAP-Algorithm */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
80 struct dict_object * CHAP_Auth; /* CHAP-Auth */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
81 struct dict_object * CHAP_Challenge; /* CHAP-Challenge */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
82 struct dict_object * CHAP_Ident; /* CHAP-Ident */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
83 struct dict_object * CHAP_Response; /* CHAP-Response */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
84 struct dict_object * Connect_Info; /* Connect-Info */
273
bce8e5b7bf78 Added code to send an STR after a STOP accounting record in RADIUS
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 271
diff changeset
85 struct dict_object * Destination_Host; /* Destination-Host */
bce8e5b7bf78 Added code to send an STR after a STOP accounting record in RADIUS
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 271
diff changeset
86 struct dict_object * Destination_Realm; /* Destination-Realm */
271
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
87 struct dict_object * EAP_Payload; /* EAP-Payload */
259
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
88 struct dict_object * Error_Message; /* Error-Message */
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
89 struct dict_object * Error_Reporting_Host; /* Error-Reporting-Host */
271
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
90 struct dict_object * Event_Timestamp; /* Event-Timestamp */
259
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
91 struct dict_object * Failed_AVP; /* Failed-AVP */
271
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
92 struct dict_object * Framed_AppleTalk_Link; /* Framed-AppleTalk-Link */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
93 struct dict_object * Framed_AppleTalk_Network; /* Framed-AppleTalk-Network */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
94 struct dict_object * Framed_AppleTalk_Zone; /* Framed-AppleTalk-Zone */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
95 struct dict_object * Framed_Compression; /* Framed-Compression */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
96 struct dict_object * Framed_IP_Address; /* Framed-IP-Address */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
97 struct dict_object * Framed_IP_Netmask; /* Framed-IP-Netmask */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
98 struct dict_object * Framed_Interface_Id; /* Framed-Interface-Id */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
99 struct dict_object * Framed_IPv6_Prefix; /* Framed-IPv6-Prefix */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
100 struct dict_object * Framed_IPX_Network; /* Framed-IPX-Network */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
101 struct dict_object * Framed_MTU; /* Framed-MTU */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
102 struct dict_object * Framed_Protocol; /* Framed-Protocol */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
103 struct dict_object * Framed_Pool; /* Framed-Pool */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
104 struct dict_object * Framed_IPv6_Route; /* Framed-IPv6-Route */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
105 struct dict_object * Framed_IPv6_Pool; /* Framed-IPv6-Pool */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
106 struct dict_object * Framed_Route; /* Framed-Route */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
107 struct dict_object * Framed_Routing; /* Framed-Routing */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
108 struct dict_object * Filter_Id; /* Filter-Id */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
109 struct dict_object * Idle_Timeout; /* Idle-Timeout */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
110 struct dict_object * Login_IP_Host; /* Login-IP-Host */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
111 struct dict_object * Login_IPv6_Host; /* Login-IPv6-Host */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
112 struct dict_object * Login_LAT_Group; /* Login-LAT-Group */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
113 struct dict_object * Login_LAT_Node; /* Login-LAT-Node */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
114 struct dict_object * Login_LAT_Port; /* Login-LAT-Port */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
115 struct dict_object * Login_LAT_Service; /* Login-LAT-Service */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
116 struct dict_object * Login_Service; /* Login-Service */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
117 struct dict_object * Login_TCP_Port; /* Login-TCP-Port */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
118 struct dict_object * NAS_Identifier; /* NAS-Identifier */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
119 struct dict_object * NAS_IP_Address; /* NAS-IP-Address */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
120 struct dict_object * NAS_IPv6_Address; /* NAS-IPv6-Address */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
121 struct dict_object * NAS_Port; /* NAS-Port */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
122 struct dict_object * NAS_Port_Id; /* NAS-Port-Id */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
123 struct dict_object * NAS_Port_Type; /* NAS-Port-Type */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
124 struct dict_object * Origin_AAA_Protocol; /* Origin-AAA-Protocol */
259
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
125 struct dict_object * Origin_Host; /* Origin-Host */
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
126 struct dict_object * Origin_Realm; /* Origin-Realm */
271
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
127 struct dict_object * Originating_Line_Info; /* Originating-Line-Info */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
128 struct dict_object * Port_Limit; /* Port-Limit */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
129 struct dict_object * Re_Auth_Request_Type; /* Re-Auth-Request-Type */
259
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
130 struct dict_object * Result_Code; /* Result-Code */
271
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
131 struct dict_object * Service_Type; /* Service-Type */
259
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
132 struct dict_object * Session_Id; /* Session-Id */
271
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
133 struct dict_object * Session_Timeout; /* Session-Timeout */
259
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
134 struct dict_object * State; /* State */
273
bce8e5b7bf78 Added code to send an STR after a STOP accounting record in RADIUS
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 271
diff changeset
135 struct dict_object * Termination_Cause; /* Termination-Cause */
271
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
136 struct dict_object * Tunneling; /* Tunneling */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
137 struct dict_object * Tunnel_Type; /* Tunnel-Type */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
138 struct dict_object * Tunnel_Assignment_Id; /* Tunnel-Assignment-Id */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
139 struct dict_object * Tunnel_Medium_Type; /* Tunnel-Medium-Type */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
140 struct dict_object * Tunnel_Client_Endpoint; /* Tunnel-Client-Endpoint */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
141 struct dict_object * Tunnel_Server_Endpoint; /* Tunnel-Server-Endpoint */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
142 struct dict_object * Tunnel_Private_Group_Id; /* Tunnel-Private-Group-Id */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
143 struct dict_object * Tunnel_Preference; /* Tunnel-Preference */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
144 struct dict_object * Tunnel_Client_Auth_Id; /* Tunnel-Client-Auth-Id */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
145 struct dict_object * Tunnel_Server_Auth_Id; /* Tunnel-Server-Auth-Id */
259
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
146 struct dict_object * User_Name; /* User-Name */
273
bce8e5b7bf78 Added code to send an STR after a STOP accounting record in RADIUS
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 271
diff changeset
147
bce8e5b7bf78 Added code to send an STR after a STOP accounting record in RADIUS
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 271
diff changeset
148 struct dict_object * Session_Termination_Request;/* STR */
259
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
149 } dict; /* cache of the dictionary objects we use */
271
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
150 struct session_handler * sess_hdl; /* We store RADIUS request authenticator information in the session */
259
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
151 char * confstr;
526
6fe3e5cf9fb2 Added a flag to disable NAI routing in RADIUS/Diameter gw
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 448
diff changeset
152
6fe3e5cf9fb2 Added a flag to disable NAI routing in RADIUS/Diameter gw
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 448
diff changeset
153 int ignore_nai;
259
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
154 };
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
155
271
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
156 /* The state we store in the session */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
157 struct sess_state {
273
bce8e5b7bf78 Added code to send an STR after a STOP accounting record in RADIUS
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 271
diff changeset
158 application_id_t auth_appl; /* Auth-Application-Id used for this session, if available (stored in a Class attribute) */
bce8e5b7bf78 Added code to send an STR after a STOP accounting record in RADIUS
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 271
diff changeset
159 int send_str; /* If not 0, we must send a STR when the ACA is received. */
bce8e5b7bf78 Added code to send an STR after a STOP accounting record in RADIUS
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 271
diff changeset
160 uint32_t term_cause; /* If not 0, the Termination-Cause to put in the STR. */
271
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
161 };
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
162
259
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
163 /* Initialize the plugin */
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
164 static int acct_conf_parse(char * conffile, struct rgwp_config ** state)
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
165 {
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
166 struct rgwp_config * new;
271
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
167 struct dict_object * app;
259
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
168
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
169 TRACE_ENTRY("%p %p", conffile, state);
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
170 CHECK_PARAMS( state );
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
171
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
172 CHECK_MALLOC( new = malloc(sizeof(struct rgwp_config)) );
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
173 memset(new, 0, sizeof(struct rgwp_config));
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
174
537
616848d6f020 Backed out changeset: f95cfc35d960
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 536
diff changeset
175 CHECK_FCT( fd_sess_handler_create( &new->sess_hdl, free ) );
259
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
176 new->confstr = conffile;
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
177
532
4cb8f63a0f67 Fix segfault when no configuration string is given to the plugins
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 530
diff changeset
178 if (conffile && strstr(conffile, "nonai"))
526
6fe3e5cf9fb2 Added a flag to disable NAI routing in RADIUS/Diameter gw
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 448
diff changeset
179 new->ignore_nai = 1;
6fe3e5cf9fb2 Added a flag to disable NAI routing in RADIUS/Diameter gw
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 448
diff changeset
180
259
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
181 /* Resolve all dictionary objects we use */
277
c94e4ea39f97 Add missing mandatory AVP
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 275
diff changeset
182 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Accounting-Record-Number", &new->dict.Accounting_Record_Number, ENOENT) );
271
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
183 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Accounting-Record-Type", &new->dict.Accounting_Record_Type, ENOENT) );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
184 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Acct-Application-Id", &new->dict.Acct_Application_Id, ENOENT) );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
185 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Acct-Delay-Time", &new->dict.Acct_Delay_Time, ENOENT) );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
186 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Accounting-Input-Octets", &new->dict.Accounting_Input_Octets, ENOENT) );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
187 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Accounting-Output-Octets", &new->dict.Accounting_Output_Octets, ENOENT) );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
188 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Accounting-Input-Packets", &new->dict.Accounting_Input_Packets, ENOENT) );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
189 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Accounting-Output-Packets", &new->dict.Accounting_Output_Packets, ENOENT) );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
190 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Acct-Authentic", &new->dict.Acct_Authentic, ENOENT) );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
191 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Acct-Link-Count", &new->dict.Acct_Link_Count, ENOENT) );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
192 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Acct-Multi-Session-Id", &new->dict.Acct_Multi_Session_Id, ENOENT) );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
193 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Acct-Session-Id", &new->dict.Acct_Session_Id, ENOENT) );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
194 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Acct-Session-Time", &new->dict.Acct_Session_Time, ENOENT) );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
195
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
196 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "ARAP-Password", &new->dict.ARAP_Password, ENOENT) );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
197 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "ARAP-Security", &new->dict.ARAP_Security, ENOENT) );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
198 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "ARAP-Security-Data", &new->dict.ARAP_Security_Data, ENOENT) );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
199 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Auth-Application-Id", &new->dict.Auth_Application_Id, ENOENT) );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
200 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Auth-Request-Type", &new->dict.Auth_Request_Type, ENOENT) );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
201 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Authorization-Lifetime", &new->dict.Authorization_Lifetime, ENOENT) );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
202 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Callback-Number", &new->dict.Callback_Number, ENOENT) );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
203 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Callback-Id", &new->dict.Callback_Id, ENOENT) );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
204 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Called-Station-Id", &new->dict.Called_Station_Id, ENOENT) );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
205 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Calling-Station-Id", &new->dict.Calling_Station_Id, ENOENT) );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
206 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Class", &new->dict.Class, ENOENT) );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
207 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Connect-Info", &new->dict.Connect_Info, ENOENT) );
273
bce8e5b7bf78 Added code to send an STR after a STOP accounting record in RADIUS
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 271
diff changeset
208 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Destination-Host", &new->dict.Destination_Host, ENOENT) );
bce8e5b7bf78 Added code to send an STR after a STOP accounting record in RADIUS
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 271
diff changeset
209 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Destination-Realm", &new->dict.Destination_Realm, ENOENT) );
271
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
210 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "EAP-Payload", &new->dict.EAP_Payload, ENOENT) );
259
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
211 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Error-Message", &new->dict.Error_Message, ENOENT) );
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
212 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Error-Reporting-Host", &new->dict.Error_Reporting_Host, ENOENT) );
271
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
213 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Event-Timestamp", &new->dict.Event_Timestamp, ENOENT) );
259
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
214 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Failed-AVP", &new->dict.Failed_AVP, ENOENT) );
271
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
215 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Framed-AppleTalk-Link", &new->dict.Framed_AppleTalk_Link, ENOENT) );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
216 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Framed-AppleTalk-Network", &new->dict.Framed_AppleTalk_Network, ENOENT) );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
217 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Framed-AppleTalk-Zone", &new->dict.Framed_AppleTalk_Zone, ENOENT) );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
218 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Framed-Compression", &new->dict.Framed_Compression, ENOENT) );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
219 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Framed-IP-Address", &new->dict.Framed_IP_Address, ENOENT) );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
220 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Framed-IP-Netmask", &new->dict.Framed_IP_Netmask, ENOENT) );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
221 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Framed-Interface-Id", &new->dict.Framed_Interface_Id, ENOENT) );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
222 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Framed-IPv6-Prefix", &new->dict.Framed_IPv6_Prefix, ENOENT) );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
223 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Framed-IPX-Network", &new->dict.Framed_IPX_Network, ENOENT) );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
224 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Framed-MTU", &new->dict.Framed_MTU, ENOENT) );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
225 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Framed-Protocol", &new->dict.Framed_Protocol, ENOENT) );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
226 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Framed-Pool", &new->dict.Framed_Pool, ENOENT) );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
227 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Framed-Route", &new->dict.Framed_Route, ENOENT) );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
228 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Framed-IPv6-Route", &new->dict.Framed_IPv6_Route, ENOENT) );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
229 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Framed-IPv6-Pool", &new->dict.Framed_IPv6_Pool, ENOENT) );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
230 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Framed-Routing", &new->dict.Framed_Routing, ENOENT) );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
231 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Filter-Id", &new->dict.Filter_Id, ENOENT) );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
232 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Idle-Timeout", &new->dict.Idle_Timeout, ENOENT) );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
233 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Login-IP-Host", &new->dict.Login_IP_Host, ENOENT) );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
234 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Login-IPv6-Host", &new->dict.Login_IPv6_Host, ENOENT) );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
235 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Login-LAT-Group", &new->dict.Login_LAT_Group, ENOENT) );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
236 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Login-LAT-Node", &new->dict.Login_LAT_Node, ENOENT) );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
237 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Login-LAT-Port", &new->dict.Login_LAT_Port, ENOENT) );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
238 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Login-LAT-Service", &new->dict.Login_LAT_Service, ENOENT) );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
239 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Login-Service", &new->dict.Login_Service, ENOENT) );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
240 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Login-TCP-Port", &new->dict.Login_TCP_Port, ENOENT) );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
241 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "NAS-Identifier", &new->dict.NAS_Identifier, ENOENT) );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
242 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "NAS-IP-Address", &new->dict.NAS_IP_Address, ENOENT) );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
243 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "NAS-IPv6-Address", &new->dict.NAS_IPv6_Address, ENOENT) );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
244 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "NAS-Port", &new->dict.NAS_Port, ENOENT) );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
245 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "NAS-Port-Id", &new->dict.NAS_Port_Id, ENOENT) );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
246 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "NAS-Port-Type", &new->dict.NAS_Port_Type, ENOENT) );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
247 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Origin-AAA-Protocol", &new->dict.Origin_AAA_Protocol, ENOENT) );
259
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
248 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Origin-Host", &new->dict.Origin_Host, ENOENT) );
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
249 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Origin-Realm", &new->dict.Origin_Realm, ENOENT) );
271
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
250 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Originating-Line-Info", &new->dict.Originating_Line_Info, ENOENT) );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
251 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Port-Limit", &new->dict.Port_Limit, ENOENT) );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
252 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Re-Auth-Request-Type", &new->dict.Re_Auth_Request_Type, ENOENT) );
259
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
253 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Result-Code", &new->dict.Result_Code, ENOENT) );
271
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
254 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Service-Type", &new->dict.Service_Type, ENOENT) );
259
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
255 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Session-Id", &new->dict.Session_Id, ENOENT) );
271
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
256 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Session-Timeout", &new->dict.Session_Timeout, ENOENT) );
259
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
257 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "State", &new->dict.State, ENOENT) );
273
bce8e5b7bf78 Added code to send an STR after a STOP accounting record in RADIUS
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 271
diff changeset
258 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Termination-Cause", &new->dict.Termination_Cause, ENOENT) );
271
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
259 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Tunneling", &new->dict.Tunneling, ENOENT) );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
260 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Tunnel-Assignment-Id", &new->dict.Tunnel_Assignment_Id, ENOENT) );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
261 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Tunnel-Type", &new->dict.Tunnel_Type, ENOENT) );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
262 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Tunnel-Medium-Type", &new->dict.Tunnel_Medium_Type, ENOENT) );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
263 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Tunnel-Client-Endpoint", &new->dict.Tunnel_Client_Endpoint, ENOENT) );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
264 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Tunnel-Server-Endpoint", &new->dict.Tunnel_Server_Endpoint, ENOENT) );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
265 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Tunnel-Private-Group-Id", &new->dict.Tunnel_Private_Group_Id, ENOENT) );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
266 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Tunnel-Preference", &new->dict.Tunnel_Preference, ENOENT) );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
267 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Tunnel-Client-Auth-Id", &new->dict.Tunnel_Client_Auth_Id, ENOENT) );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
268 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Tunnel-Server-Auth-Id", &new->dict.Tunnel_Server_Auth_Id, ENOENT) );
259
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
269 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "User-Name", &new->dict.User_Name, ENOENT) );
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
270
273
bce8e5b7bf78 Added code to send an STR after a STOP accounting record in RADIUS
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 271
diff changeset
271 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_COMMAND, CMD_BY_NAME, "Session-Termination-Request", &new->dict.Session_Termination_Request, ENOENT) );
bce8e5b7bf78 Added code to send an STR after a STOP accounting record in RADIUS
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 271
diff changeset
272
271
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
273 /* This plugin provides the following Diameter authentication applications support: */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
274 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_APPLICATION, APPLICATION_BY_NAME, "Diameter Base Accounting", &app, ENOENT) );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
275 CHECK_FCT( fd_disp_app_support ( app, NULL, 0, 1 ) );
268
b364ffffa2ed Ported the Echo/Drop plugin from waaad
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 262
diff changeset
276
262
cc2c568ef319 Missing affectation
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 259
diff changeset
277 *state = new;
259
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
278 return 0;
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
279 }
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
280
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
281 /* deinitialize */
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
282 static void acct_conf_free(struct rgwp_config * state)
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
283 {
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
284 TRACE_ENTRY("%p", state);
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
285 CHECK_PARAMS_DO( state, return );
448
9493b8d8a35f Fix small problem
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 403
diff changeset
286 CHECK_FCT_DO( fd_sess_handler_destroy( &state->sess_hdl ), );
259
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
287 free(state);
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
288 return;
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
289 }
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
290
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
291 /* Incoming RADIUS request */
356
e203fc0c95e3 Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 296
diff changeset
292 static int acct_rad_req( struct rgwp_config * cs, struct session ** session, struct radius_msg * rad_req, struct radius_msg ** rad_ans, struct msg ** diam_fw, struct rgw_client * cli )
259
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
293 {
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
294 int idx;
271
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
295 int send_str=0;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
296 uint32_t str_cause=0;
277
c94e4ea39f97 Add missing mandatory AVP
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 275
diff changeset
297 uint32_t e2eid = 0;
273
bce8e5b7bf78 Added code to send an STR after a STOP accounting record in RADIUS
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 271
diff changeset
298 application_id_t auth_appl=0;
259
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
299 int got_id = 0;
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
300 uint32_t status_type;
271
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
301 uint32_t termination_action = 0;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
302 uint32_t gigawords_in=0, gigawords_out=0;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
303 size_t nattr_used = 0;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
304 union avp_value value;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
305 struct avp ** avp_tun = NULL, *avp = NULL;
259
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
306
356
e203fc0c95e3 Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 296
diff changeset
307 const char * prefix = "Diameter/";
e203fc0c95e3 Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 296
diff changeset
308 size_t pref_len;
403
26aafbbc1640 Cleanup all compilation warnings in base code for 32 bit arch
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 376
diff changeset
309 uint8_t * si = NULL;
356
e203fc0c95e3 Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 296
diff changeset
310 size_t si_len = 0;
403
26aafbbc1640 Cleanup all compilation warnings in base code for 32 bit arch
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 376
diff changeset
311 uint8_t * un = NULL;
358
7ea43915cade Fix: added the Destination-Realm also
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 356
diff changeset
312 size_t un_len = 0;
356
e203fc0c95e3 Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 296
diff changeset
313
259
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
314 TRACE_ENTRY("%p %p %p %p %p %p", cs, session, rad_req, rad_ans, diam_fw, cli);
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
315 CHECK_PARAMS(rad_req && (rad_req->hdr->code == RADIUS_CODE_ACCOUNTING_REQUEST) && rad_ans && diam_fw && *diam_fw);
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
316
356
e203fc0c95e3 Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 296
diff changeset
317 pref_len = strlen(prefix);
e203fc0c95e3 Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 296
diff changeset
318
271
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
319 /*
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
320 Either NAS-IP-Address or NAS-Identifier MUST be present in a
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
321 RADIUS Accounting-Request. It SHOULD contain a NAS-Port or NAS-
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
322 Port-Type attribute or both unless the service does not involve a
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
323 port or the NAS does not distinguish among its ports.
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
324 */
356
e203fc0c95e3 Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 296
diff changeset
325 /* We also enforce that the message contains a CLASS attribute with Diameter/ prefix containing the Session-Id. */
259
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
326 for (idx = 0; idx < rad_req->attr_used; idx++) {
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
327 struct radius_attr_hdr * attr = (struct radius_attr_hdr *)(rad_req->buf + rad_req->attr_pos[idx]);
271
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
328 uint8_t * v = (uint8_t *)(attr + 1);
358
7ea43915cade Fix: added the Destination-Realm also
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 356
diff changeset
329 size_t attr_len = attr->length - sizeof(struct radius_attr_hdr);
7ea43915cade Fix: added the Destination-Realm also
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 356
diff changeset
330
259
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
331 switch (attr->type) {
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
332 case RADIUS_ATTR_NAS_IP_ADDRESS:
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
333 case RADIUS_ATTR_NAS_IDENTIFIER:
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
334 case RADIUS_ATTR_NAS_IPV6_ADDRESS:
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
335 got_id = 1;
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
336 break;
271
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
337
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
338 case RADIUS_ATTR_TERMINATION_ACTION:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
339 CHECK_PARAMS( attr->length == 6 );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
340 termination_action = (v[0] << 24)
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
341 | (v[1] << 16)
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
342 | (v[2] << 8)
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
343 | v[3] ;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
344 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
345
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
346 case RADIUS_ATTR_ACCT_INPUT_GIGAWORDS:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
347 CHECK_PARAMS( attr->length == 6 );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
348 gigawords_in = (v[0] << 24)
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
349 | (v[1] << 16)
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
350 | (v[2] << 8)
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
351 | v[3] ;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
352 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
353
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
354 case RADIUS_ATTR_ACCT_OUTPUT_GIGAWORDS:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
355 CHECK_PARAMS( attr->length == 6 );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
356 gigawords_out = (v[0] << 24)
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
357 | (v[1] << 16)
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
358 | (v[2] << 8)
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
359 | v[3] ;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
360 break;
356
e203fc0c95e3 Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 296
diff changeset
361
e203fc0c95e3 Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 296
diff changeset
362 case RADIUS_ATTR_CLASS:
358
7ea43915cade Fix: added the Destination-Realm also
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 356
diff changeset
363 if ((attr_len > pref_len ) && ! strncmp((char *)v, prefix, pref_len)) {
7ea43915cade Fix: added the Destination-Realm also
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 356
diff changeset
364 int i;
403
26aafbbc1640 Cleanup all compilation warnings in base code for 32 bit arch
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 376
diff changeset
365 si = v + pref_len;
358
7ea43915cade Fix: added the Destination-Realm also
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 356
diff changeset
366 si_len = attr_len - pref_len;
7ea43915cade Fix: added the Destination-Realm also
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 356
diff changeset
367 TRACE_DEBUG(ANNOYING, "Found Class attribute with '%s' prefix (attr #%d), SI:'%.*s'.", prefix, idx, si_len, si);
7ea43915cade Fix: added the Destination-Realm also
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 356
diff changeset
368 /* Remove from the message */
7ea43915cade Fix: added the Destination-Realm also
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 356
diff changeset
369 for (i = idx + 1; i < rad_req->attr_used; i++)
7ea43915cade Fix: added the Destination-Realm also
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 356
diff changeset
370 rad_req->attr_pos[i - 1] = rad_req->attr_pos[i];
7ea43915cade Fix: added the Destination-Realm also
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 356
diff changeset
371 rad_req->attr_used -= 1;
356
e203fc0c95e3 Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 296
diff changeset
372 }
e203fc0c95e3 Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 296
diff changeset
373 break;
e203fc0c95e3 Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 296
diff changeset
374
358
7ea43915cade Fix: added the Destination-Realm also
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 356
diff changeset
375 case RADIUS_ATTR_USER_NAME:
7ea43915cade Fix: added the Destination-Realm also
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 356
diff changeset
376 if (attr_len) {
403
26aafbbc1640 Cleanup all compilation warnings in base code for 32 bit arch
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 376
diff changeset
377 un = v;
358
7ea43915cade Fix: added the Destination-Realm also
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 356
diff changeset
378 un_len = attr_len;
7ea43915cade Fix: added the Destination-Realm also
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 356
diff changeset
379 TRACE_DEBUG(ANNOYING, "Found a User-Name attribute: '%.*s'", un_len, un);
7ea43915cade Fix: added the Destination-Realm also
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 356
diff changeset
380 }
7ea43915cade Fix: added the Destination-Realm also
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 356
diff changeset
381 break;
7ea43915cade Fix: added the Destination-Realm also
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 356
diff changeset
382
259
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
383 }
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
384 }
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
385
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
386 /* Check basic information is there */
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
387 if (!got_id || radius_msg_get_attr_int32(rad_req, RADIUS_ATTR_ACCT_STATUS_TYPE, &status_type)) {
271
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
388 TRACE_DEBUG(INFO, "[acct.rgwx] RADIUS Account-Request from %s did not contain a NAS ip/identifier or Acct-Status-Type attribute, reject.", rgw_clients_id(cli));
259
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
389 return EINVAL;
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
390 }
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
391
271
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
392 /*
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
393 -- RFC2866:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
394 In Accounting-Request Packets, the Authenticator value is a 16
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
395 octet MD5 [5] checksum, called the Request Authenticator.
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
396
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
397 The NAS and RADIUS accounting server share a secret. The Request
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
398 Authenticator field in Accounting-Request packets contains a one-
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
399 way MD5 hash calculated over a stream of octets consisting of the
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
400 Code + Identifier + Length + 16 zero octets + request attributes +
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
401 shared secret (where + indicates concatenation). The 16 octet MD5
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
402 hash value is stored in the Authenticator field of the
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
403 Accounting-Request packet.
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
404
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
405 Note that the Request Authenticator of an Accounting-Request can
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
406 not be done the same way as the Request Authenticator of a RADIUS
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
407 Access-Request, because there is no User-Password attribute in an
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
408 Accounting-Request.
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
409
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
410
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
411 -- RFC5080:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
412 The Request Authenticator field MUST contain the correct data, as
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
413 given by the above calculation. Invalid packets are silently
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
414 discarded. Note that some early implementations always set the
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
415 Request Authenticator to all zeros. New implementations of RADIUS
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
416 clients MUST use the above algorithm to calculate the Request
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
417 Authenticator field. New RADIUS server implementations MUST
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
418 silently discard invalid packets.
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
419
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
420 */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
421 {
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
422 uint8_t save[MD5_MAC_LEN];
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
423 uint8_t * secret;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
424 size_t secret_len;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
425
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
426 /* Get the shared secret */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
427 CHECK_FCT(rgw_clients_getkey(cli, &secret, &secret_len));
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
428
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
429 /* Copy the received Request Authenticator */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
430 memcpy(&save[0], &rad_req->hdr->authenticator[0], MD5_MAC_LEN);
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
431
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
432 /* Compute the same authenticator */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
433 radius_msg_finish_acct(rad_req, secret, secret_len);
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
434
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
435 /* And now compare with the received value */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
436 if (memcmp(&save[0], &rad_req->hdr->authenticator[0], MD5_MAC_LEN)) {
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
437 /* Invalid authenticator */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
438 TRACE_DEBUG_BUFFER(FULL+1, "Received ReqAuth: ", &save[0], MD5_MAC_LEN, "" );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
439 TRACE_DEBUG_BUFFER(FULL+1, "Expected ReqAuth: ", &rad_req->hdr->authenticator[0], MD5_MAC_LEN, "" );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
440 TRACE_DEBUG(INFO, "[acct.rgwx] Invalid Request Authenticator in Account-Request from %s, discarding the message.", rgw_clients_id(cli));
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
441 return EINVAL;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
442 }
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
443 }
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
444
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
445
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
446 /* Handle the Accounting-On case: nothing to do, just reply OK */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
447 if (status_type == RADIUS_ACCT_STATUS_TYPE_ACCOUNTING_ON) {
259
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
448 TRACE_DEBUG(FULL, "[acct.rgwx] Received Accounting-On Acct-Status-Type attribute, replying without translation to Diameter.");
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
449 CHECK_MALLOC( *rad_ans = radius_msg_new(RADIUS_CODE_ACCOUNTING_RESPONSE, rad_req->hdr->identifier) );
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
450 return -2;
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
451 }
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
452
271
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
453 if (status_type == RADIUS_ACCT_STATUS_TYPE_ACCOUNTING_OFF) {
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
454 TRACE_DEBUG(FULL, "[acct.rgwx] Received Accounting-Off Acct-Status-Type attribute, we must terminate all active sessions.");
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
455 TODO("RADIUS side is rebooting, send STR on all sessions?");
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
456 return ENOTSUP;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
457 }
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
458
356
e203fc0c95e3 Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 296
diff changeset
459 /* Check if we got a valid session information, otherwise the server will not be able to handle the data... */
e203fc0c95e3 Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 296
diff changeset
460 if (!*session && !si) {
e203fc0c95e3 Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 296
diff changeset
461 TRACE_DEBUG(INFO, "[acct.rgwx] RADIUS Account-Request from %s did not contain a CLASS attribute with Diameter session information, reject.", rgw_clients_id(cli));
e203fc0c95e3 Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 296
diff changeset
462 return EINVAL;
e203fc0c95e3 Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 296
diff changeset
463 }
e203fc0c95e3 Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 296
diff changeset
464
358
7ea43915cade Fix: added the Destination-Realm also
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 356
diff changeset
465 /* Add the Destination-Realm */
7ea43915cade Fix: added the Destination-Realm also
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 356
diff changeset
466 CHECK_FCT( fd_msg_avp_new ( cs->dict.Destination_Realm, 0, &avp ) );
7ea43915cade Fix: added the Destination-Realm also
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 356
diff changeset
467 idx = 0;
526
6fe3e5cf9fb2 Added a flag to disable NAI routing in RADIUS/Diameter gw
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 448
diff changeset
468 if (un && ! cs->ignore_nai) {
358
7ea43915cade Fix: added the Destination-Realm also
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 356
diff changeset
469 /* Is there an '@' in the user name? We don't care for decorated NAI here */
7ea43915cade Fix: added the Destination-Realm also
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 356
diff changeset
470 for (idx = un_len - 2; idx > 0; idx--) {
7ea43915cade Fix: added the Destination-Realm also
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 356
diff changeset
471 if (un[idx] == '@') {
7ea43915cade Fix: added the Destination-Realm also
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 356
diff changeset
472 idx++;
7ea43915cade Fix: added the Destination-Realm also
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 356
diff changeset
473 break;
7ea43915cade Fix: added the Destination-Realm also
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 356
diff changeset
474 }
7ea43915cade Fix: added the Destination-Realm also
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 356
diff changeset
475 }
7ea43915cade Fix: added the Destination-Realm also
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 356
diff changeset
476 }
7ea43915cade Fix: added the Destination-Realm also
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 356
diff changeset
477 if (idx == 0) {
7ea43915cade Fix: added the Destination-Realm also
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 356
diff changeset
478 /* Not found in the User-Name => we use the local domain of this gateway */
403
26aafbbc1640 Cleanup all compilation warnings in base code for 32 bit arch
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 376
diff changeset
479 value.os.data = (uint8_t *)fd_g_config->cnf_diamrlm;
358
7ea43915cade Fix: added the Destination-Realm also
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 356
diff changeset
480 value.os.len = fd_g_config->cnf_diamrlm_len;
7ea43915cade Fix: added the Destination-Realm also
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 356
diff changeset
481 } else {
7ea43915cade Fix: added the Destination-Realm also
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 356
diff changeset
482 value.os.data = un + idx;
7ea43915cade Fix: added the Destination-Realm also
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 356
diff changeset
483 value.os.len = un_len - idx;
7ea43915cade Fix: added the Destination-Realm also
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 356
diff changeset
484 }
7ea43915cade Fix: added the Destination-Realm also
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 356
diff changeset
485 CHECK_FCT( fd_msg_avp_setvalue ( avp, &value ) );
7ea43915cade Fix: added the Destination-Realm also
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 356
diff changeset
486 CHECK_FCT( fd_msg_avp_add ( *diam_fw, *session ? MSG_BRW_LAST_CHILD : MSG_BRW_FIRST_CHILD, avp) );
7ea43915cade Fix: added the Destination-Realm also
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 356
diff changeset
487
356
e203fc0c95e3 Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 296
diff changeset
488 /* Create the Session-Id AVP if needed */
e203fc0c95e3 Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 296
diff changeset
489 if (!*session) {
403
26aafbbc1640 Cleanup all compilation warnings in base code for 32 bit arch
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 376
diff changeset
490 CHECK_FCT( fd_sess_fromsid ( (char *)/* cast should be removed later */si, si_len, session, NULL) );
356
e203fc0c95e3 Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 296
diff changeset
491
535
72c511043f05 A few bug fixes on the RADIUS/Diameter gateway.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 532
diff changeset
492 TRACE_DEBUG(FULL, "[acct.rgwx] Translating new accounting message for session '%.*s'...", si_len, si);
356
e203fc0c95e3 Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 296
diff changeset
493
e203fc0c95e3 Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 296
diff changeset
494 /* Add the Session-Id AVP as first AVP */
e203fc0c95e3 Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 296
diff changeset
495 CHECK_FCT( fd_msg_avp_new ( cs->dict.Session_Id, 0, &avp ) );
e203fc0c95e3 Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 296
diff changeset
496 value.os.data = (unsigned char *)si;
e203fc0c95e3 Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 296
diff changeset
497 value.os.len = si_len;
e203fc0c95e3 Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 296
diff changeset
498 CHECK_FCT( fd_msg_avp_setvalue ( avp, &value ) );
e203fc0c95e3 Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 296
diff changeset
499 CHECK_FCT( fd_msg_avp_add ( *diam_fw, MSG_BRW_FIRST_CHILD, avp) );
e203fc0c95e3 Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 296
diff changeset
500 }
358
7ea43915cade Fix: added the Destination-Realm also
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 356
diff changeset
501
356
e203fc0c95e3 Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 296
diff changeset
502
271
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
503 /* Add the command code */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
504 {
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
505 struct msg_hdr * header = NULL;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
506 CHECK_FCT( fd_msg_hdr ( *diam_fw, &header ) );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
507 header->msg_flags = CMD_FLAG_REQUEST | CMD_FLAG_PROXIABLE;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
508 header->msg_code = CC_AC;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
509 header->msg_appl = AI_ACCT;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
510
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
511 /* Add the Acct-Application-Id */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
512 CHECK_FCT( fd_msg_avp_new ( cs->dict.Acct_Application_Id, 0, &avp ) );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
513 value.i32 = header->msg_appl;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
514 CHECK_FCT( fd_msg_avp_setvalue ( avp, &value ) );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
515 CHECK_FCT( fd_msg_avp_add ( *diam_fw, MSG_BRW_LAST_CHILD, avp) );
277
c94e4ea39f97 Add missing mandatory AVP
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 275
diff changeset
516
c94e4ea39f97 Add missing mandatory AVP
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 275
diff changeset
517 /* save the end to end id */
c94e4ea39f97 Add missing mandatory AVP
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 275
diff changeset
518 e2eid = header->msg_eteid;
271
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
519 }
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
520
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
521 /* Convert the RADIUS attributes, as they appear in the message */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
522 for (idx = 0; idx < rad_req->attr_used; idx++) {
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
523 struct radius_attr_hdr * attr = (struct radius_attr_hdr *)(rad_req->buf + rad_req->attr_pos[idx]);
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
524
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
525 switch (attr->type) {
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
526 /*
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
527 Any attribute valid in a RADIUS Access-Request or Access-Accept
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
528 packet is valid in a RADIUS Accounting-Request packet, except that
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
529 the following attributes MUST NOT be present in an Accounting-
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
530 Request: User-Password, CHAP-Password, Reply-Message, State.
259
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
531 */
271
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
532 case RADIUS_ATTR_USER_PASSWORD:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
533 case RADIUS_ATTR_CHAP_PASSWORD:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
534 case RADIUS_ATTR_REPLY_MESSAGE:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
535 case RADIUS_ATTR_STATE:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
536 case RADIUS_ATTR_MESSAGE_AUTHENTICATOR:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
537 case RADIUS_ATTR_EAP_MESSAGE:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
538 TRACE_DEBUG(INFO, "[acct.rgwx] RADIUS Account-Request contains a forbidden attribute (%hhd), reject.", attr->type);
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
539 return EINVAL;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
540
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
541
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
542 /* This macro converts a RADIUS attribute to a Diameter AVP of type OctetString */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
543 #define CONV2DIAM_STR( _dictobj_ ) \
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
544 CHECK_PARAMS( attr->length >= 2 ); \
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
545 /* Create the AVP with the specified dictionary model */ \
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
546 CHECK_FCT( fd_msg_avp_new ( cs->dict._dictobj_, 0, &avp ) ); \
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
547 value.os.len = attr->length - 2; \
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
548 value.os.data = (unsigned char *)(attr + 1); \
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
549 CHECK_FCT( fd_msg_avp_setvalue ( avp, &value ) ); \
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
550 /* Add the AVP in the Diameter message. */ \
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
551 CHECK_FCT( fd_msg_avp_add ( *diam_fw, MSG_BRW_LAST_CHILD, avp) ); \
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
552
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
553 /* Same thing, for scalar AVPs of 32 bits */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
554 #define CONV2DIAM_32B( _dictobj_ ) \
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
555 CHECK_PARAMS( attr->length == 6 ); \
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
556 CHECK_FCT( fd_msg_avp_new ( cs->dict._dictobj_, 0, &avp ) ); \
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
557 { \
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
558 uint8_t * v = (uint8_t *)(attr + 1); \
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
559 value.u32 = (v[0] << 24) \
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
560 | (v[1] << 16) \
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
561 | (v[2] << 8) \
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
562 | v[3] ; \
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
563 } \
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
564 CHECK_FCT( fd_msg_avp_setvalue ( avp, &value ) ); \
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
565 CHECK_FCT( fd_msg_avp_add ( *diam_fw, MSG_BRW_LAST_CHILD, avp) ); \
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
566
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
567 /* And the 64b version */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
568 #define CONV2DIAM_64B( _dictobj_ ) \
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
569 CHECK_PARAMS( attr->length == 10); \
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
570 CHECK_FCT( fd_msg_avp_new ( cs->dict._dictobj_, 0, &avp ) ); \
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
571 { \
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
572 uint8_t * v = (uint8_t *)(attr + 1); \
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
573 value.u64 = ((uint64_t)(v[0]) << 56) \
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
574 | ((uint64_t)(v[1]) << 48) \
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
575 | ((uint64_t)(v[2]) << 40) \
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
576 | ((uint64_t)(v[3]) << 32) \
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
577 | ((uint64_t)(v[4]) << 24) \
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
578 | ((uint64_t)(v[5]) << 16) \
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
579 | ((uint64_t)(v[6]) << 8) \
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
580 | (uint64_t)(v[7]) ; \
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
581 } \
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
582 CHECK_FCT( fd_msg_avp_setvalue ( avp, &value ) ); \
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
583 CHECK_FCT( fd_msg_avp_add ( *diam_fw, MSG_BRW_LAST_CHILD, avp) ); \
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
584
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
585
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
586 /* Attributes as listed in RFC2866, section 5.13 and RFC4005, section 10.2.1 */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
587 case RADIUS_ATTR_USER_NAME:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
588 CONV2DIAM_STR( User_Name );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
589 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
590
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
591 case RADIUS_ATTR_NAS_IP_ADDRESS:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
592 CONV2DIAM_STR( NAS_IP_Address );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
593 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
594
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
595 case RADIUS_ATTR_NAS_PORT:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
596 CONV2DIAM_32B( NAS_Port );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
597 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
598
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
599 case RADIUS_ATTR_SERVICE_TYPE:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
600 CONV2DIAM_32B( Service_Type );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
601 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
602
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
603 case RADIUS_ATTR_FRAMED_PROTOCOL:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
604 CONV2DIAM_32B( Framed_Protocol );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
605 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
606
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
607 case RADIUS_ATTR_FRAMED_IP_ADDRESS:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
608 CONV2DIAM_STR( Framed_IP_Address );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
609 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
610
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
611 case RADIUS_ATTR_FRAMED_IP_NETMASK:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
612 CONV2DIAM_STR( Framed_IP_Netmask );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
613 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
614
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
615 case RADIUS_ATTR_FRAMED_ROUTING:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
616 CONV2DIAM_32B( Framed_Routing );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
617 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
618
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
619 case RADIUS_ATTR_FILTER_ID:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
620 CONV2DIAM_STR( Filter_Id );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
621 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
622
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
623 case RADIUS_ATTR_FRAMED_MTU:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
624 CONV2DIAM_32B( Framed_MTU );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
625 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
626
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
627 case RADIUS_ATTR_FRAMED_COMPRESSION:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
628 CONV2DIAM_32B( Framed_Compression );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
629 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
630
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
631 case RADIUS_ATTR_LOGIN_IP_HOST:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
632 CONV2DIAM_STR( Login_IP_Host );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
633 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
634
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
635 case RADIUS_ATTR_LOGIN_SERVICE:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
636 CONV2DIAM_32B( Login_Service );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
637 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
638
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
639 case RADIUS_ATTR_LOGIN_TCP_PORT:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
640 CONV2DIAM_32B( Login_TCP_Port );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
641 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
642
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
643 case RADIUS_ATTR_CALLBACK_NUMBER:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
644 CONV2DIAM_STR( Callback_Number );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
645 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
646
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
647 case RADIUS_ATTR_CALLBACK_ID:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
648 CONV2DIAM_STR( Callback_Id );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
649 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
650
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
651 case RADIUS_ATTR_FRAMED_ROUTE:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
652 CONV2DIAM_STR( Framed_Route );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
653 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
654
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
655 case RADIUS_ATTR_FRAMED_IPX_NETWORK:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
656 CONV2DIAM_32B( Framed_IPX_Network );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
657 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
658
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
659 case RADIUS_ATTR_CLASS:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
660 CONV2DIAM_STR( Class );
273
bce8e5b7bf78 Added code to send an STR after a STOP accounting record in RADIUS
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 271
diff changeset
661 /* In addition, save the data in the session if it is "our" CLASS_AAI_PREFIX Class attribute */
bce8e5b7bf78 Added code to send an STR after a STOP accounting record in RADIUS
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 271
diff changeset
662 {
bce8e5b7bf78 Added code to send an STR after a STOP accounting record in RADIUS
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 271
diff changeset
663 char buf[32];
bce8e5b7bf78 Added code to send an STR after a STOP accounting record in RADIUS
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 271
diff changeset
664 char * attr_val, *auth_val;
bce8e5b7bf78 Added code to send an STR after a STOP accounting record in RADIUS
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 271
diff changeset
665 attr_val = (char *)(attr + 1);
bce8e5b7bf78 Added code to send an STR after a STOP accounting record in RADIUS
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 271
diff changeset
666 auth_val = attr_val + strlen(CLASS_AAI_PREFIX);
bce8e5b7bf78 Added code to send an STR after a STOP accounting record in RADIUS
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 271
diff changeset
667 if ( (attr->length > sizeof(struct radius_attr_hdr) + strlen(CLASS_AAI_PREFIX) )
bce8e5b7bf78 Added code to send an STR after a STOP accounting record in RADIUS
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 271
diff changeset
668 && (attr->length < sizeof(struct radius_attr_hdr) + strlen(CLASS_AAI_PREFIX) + sizeof(buf))
bce8e5b7bf78 Added code to send an STR after a STOP accounting record in RADIUS
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 271
diff changeset
669 && ! strncmp(attr_val, CLASS_AAI_PREFIX, strlen(CLASS_AAI_PREFIX))) {
bce8e5b7bf78 Added code to send an STR after a STOP accounting record in RADIUS
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 271
diff changeset
670
bce8e5b7bf78 Added code to send an STR after a STOP accounting record in RADIUS
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 271
diff changeset
671 memset(buf, 0, sizeof(buf));
bce8e5b7bf78 Added code to send an STR after a STOP accounting record in RADIUS
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 271
diff changeset
672 memcpy(buf, auth_val, attr->length - sizeof(struct radius_attr_hdr) - strlen(CLASS_AAI_PREFIX));
bce8e5b7bf78 Added code to send an STR after a STOP accounting record in RADIUS
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 271
diff changeset
673 if (sscanf(buf, "%u", &auth_appl) == 1) {
bce8e5b7bf78 Added code to send an STR after a STOP accounting record in RADIUS
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 271
diff changeset
674 TRACE_DEBUG(ANNOYING, "Found Class attribute with '%s' prefix (attr #%d), AAI:%u.", CLASS_AAI_PREFIX, idx, auth_appl);
bce8e5b7bf78 Added code to send an STR after a STOP accounting record in RADIUS
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 271
diff changeset
675 }
bce8e5b7bf78 Added code to send an STR after a STOP accounting record in RADIUS
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 271
diff changeset
676 }
bce8e5b7bf78 Added code to send an STR after a STOP accounting record in RADIUS
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 271
diff changeset
677 }
271
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
678 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
679
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
680 case RADIUS_ATTR_VENDOR_SPECIFIC:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
681 if (attr->length >= 6) {
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
682 uint32_t vendor_id;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
683 uint8_t * c = (uint8_t *)(attr + 1);
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
684
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
685 vendor_id = c[0] << 24 | c[1] << 16 | c[2] << 8 | c[3];
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
686 c += 4;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
687
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
688 switch (vendor_id) {
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
689
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
690 /* For the vendors we KNOW they follow the VSA recommended format, we convert following the rules of RFC4005 (9.6.2) */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
691 case RADIUS_VENDOR_ID_MICROSOFT : /* RFC 2548 */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
692 /* other vendors ? */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
693 {
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
694 size_t left;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
695 struct radius_attr_vendor *vtlv;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
696
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
697 left = attr->length - 6;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
698 vtlv = (struct radius_attr_vendor *)c;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
699
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
700 while ((left >= 2) && (vtlv->vendor_length <= left)) {
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
701 /* Search our dictionary for corresponding Vendor's AVP */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
702 struct dict_avp_request req;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
703 struct dict_object * avp_model = NULL;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
704 memset(&req, 0, sizeof(struct dict_avp_request));
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
705 req.avp_vendor = vendor_id;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
706 req.avp_code = vtlv->vendor_type;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
707
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
708 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_CODE_AND_VENDOR, &req, &avp_model, 0) );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
709 if (!avp_model) {
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
710 TRACE_DEBUG(FULL, "Unknown attribute (vendor 0x%x, code 0x%x) ignored.", req.avp_vendor, req.avp_code);
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
711 } else {
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
712 CHECK_FCT( fd_msg_avp_new ( avp_model, 0, &avp ) );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
713 value.os.len = vtlv->vendor_length - 2;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
714 value.os.data = (unsigned char *)(vtlv + 1);
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
715 CHECK_FCT( fd_msg_avp_setvalue ( avp, &value ) );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
716 CHECK_FCT( fd_msg_avp_add ( *diam_fw, MSG_BRW_LAST_CHILD, avp) );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
717 }
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
718 c += vtlv->vendor_length;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
719 left -= vtlv->vendor_length;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
720 vtlv = (struct radius_attr_vendor *)c;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
721 }
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
722 }
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
723 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
724
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
725 /* Other vendors we KNOw how to convert the attributes would be added here... */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
726 /* case RADIUS_VENDOR_ID_CISCO :
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
727 break; */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
728 /* case RADIUS_VENDOR_ID_IETF : (extended RADIUS attributes)
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
729 break; */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
730
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
731 /* When we don't know, just discard the attribute... VSA are optional with regards to RADIUS anyway */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
732 default:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
733 /* do nothing */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
734 TRACE_DEBUG(FULL, "VSA attribute from vendor %d discarded", vendor_id);
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
735
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
736 }
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
737 }
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
738 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
739
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
740 case RADIUS_ATTR_SESSION_TIMEOUT:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
741 /* Translation depends on Termination-Action : rfc4005#section-9.2.1 */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
742 if (termination_action != RADIUS_TERMINATION_ACTION_RADIUS_REQUEST) {
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
743 CONV2DIAM_32B( Session_Timeout );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
744 } else {
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
745 CONV2DIAM_32B( Authorization_Lifetime );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
746 /* And add this additional AVP */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
747 CHECK_FCT( fd_msg_avp_new ( cs->dict.Re_Auth_Request_Type, 0, &avp ) );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
748 value.u32 = ACV_ART_AUTHORIZE_AUTHENTICATE;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
749 CHECK_FCT( fd_msg_avp_setvalue ( avp, &value ) );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
750 CHECK_FCT( fd_msg_avp_add ( *diam_fw, MSG_BRW_LAST_CHILD, avp) );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
751 }
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
752 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
753
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
754 case RADIUS_ATTR_IDLE_TIMEOUT:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
755 CONV2DIAM_32B( Idle_Timeout );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
756 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
757
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
758 case RADIUS_ATTR_TERMINATION_ACTION:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
759 /* Just remove */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
760 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
761
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
762 case RADIUS_ATTR_CALLED_STATION_ID:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
763 CONV2DIAM_STR( Called_Station_Id );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
764 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
765
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
766 case RADIUS_ATTR_CALLING_STATION_ID:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
767 CONV2DIAM_STR( Calling_Station_Id );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
768 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
769
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
770 case RADIUS_ATTR_NAS_IDENTIFIER:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
771 CONV2DIAM_STR( NAS_Identifier );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
772 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
773
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
774 /* Proxy-State is handled by echo_drop.rgwx plugin, we ignore it here */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
775
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
776 case RADIUS_ATTR_LOGIN_LAT_SERVICE:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
777 CONV2DIAM_STR( Login_LAT_Service );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
778 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
779
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
780 case RADIUS_ATTR_LOGIN_LAT_NODE:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
781 CONV2DIAM_STR( Login_LAT_Node );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
782 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
783
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
784 case RADIUS_ATTR_LOGIN_LAT_GROUP:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
785 CONV2DIAM_STR( Login_LAT_Group );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
786 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
787
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
788 case RADIUS_ATTR_FRAMED_APPLETALK_LINK:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
789 CONV2DIAM_32B( Framed_AppleTalk_Link );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
790 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
791
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
792 case RADIUS_ATTR_FRAMED_APPLETALK_NETWORK:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
793 CONV2DIAM_32B( Framed_AppleTalk_Network );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
794 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
795
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
796 case RADIUS_ATTR_FRAMED_APPLETALK_ZONE:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
797 CONV2DIAM_STR( Framed_AppleTalk_Zone );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
798 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
799
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
800 case RADIUS_ATTR_ACCT_STATUS_TYPE:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
801 /*
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
802 - If the RADIUS message received is an Accounting-Request, the
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
803 Acct-Status-Type attribute value must be converted to a
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
804 Accounting-Record-Type AVP value. If the Acct-Status-Type
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
805 attribute value is STOP, the local server MUST issue a
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
806 Session-Termination-Request message once the Diameter
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
807 Accounting-Answer message has been received.
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
808 */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
809 switch (status_type) {
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
810 case RADIUS_ACCT_STATUS_TYPE_START:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
811 value.u32 = ACV_ART_START_RECORD;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
812 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
813 case RADIUS_ACCT_STATUS_TYPE_STOP:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
814 value.u32 = ACV_ART_STOP_RECORD;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
815 send_str = 1; /* Register this info in the session */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
816 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
817 case RADIUS_ACCT_STATUS_TYPE_INTERIM_UPDATE:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
818 value.u32 = ACV_ART_INTERIM_RECORD;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
819 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
820 default:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
821 TRACE_DEBUG(INFO, "Unknown RADIUS_ATTR_ACCT_STATUS_TYPE value %d, abording...", status_type);
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
822 return ENOTSUP;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
823 }
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
824 CHECK_FCT( fd_msg_avp_new ( cs->dict.Accounting_Record_Type, 0, &avp ) );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
825 CHECK_FCT( fd_msg_avp_setvalue ( avp, &value ) );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
826 CHECK_FCT( fd_msg_avp_add ( *diam_fw, MSG_BRW_LAST_CHILD, avp) );
277
c94e4ea39f97 Add missing mandatory AVP
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 275
diff changeset
827
c94e4ea39f97 Add missing mandatory AVP
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 275
diff changeset
828 /* While here, we also add the Accouting-Record-Number AVP.
530
825a2992e3b9 Improved duplicate detection in RADIUS/Diameter gw. It will be changed again soon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 526
diff changeset
829 The Accounting-Record-Number AVP (AVP Code 485) is of type Unsigned32
825a2992e3b9 Improved duplicate detection in RADIUS/Diameter gw. It will be changed again soon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 526
diff changeset
830 and identifies this record within one session. As Session-Id AVPs
825a2992e3b9 Improved duplicate detection in RADIUS/Diameter gw. It will be changed again soon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 526
diff changeset
831 are globally unique, the combination of Session-Id and Accounting-
825a2992e3b9 Improved duplicate detection in RADIUS/Diameter gw. It will be changed again soon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 526
diff changeset
832 Record-Number AVPs is also globally unique, and can be used in
825a2992e3b9 Improved duplicate detection in RADIUS/Diameter gw. It will be changed again soon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 526
diff changeset
833 matching accounting records with confirmations. An easy way to
825a2992e3b9 Improved duplicate detection in RADIUS/Diameter gw. It will be changed again soon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 526
diff changeset
834 produce unique numbers is to set the value to 0 for records of type
825a2992e3b9 Improved duplicate detection in RADIUS/Diameter gw. It will be changed again soon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 526
diff changeset
835 EVENT_RECORD and START_RECORD, and set the value to 1 for the first
825a2992e3b9 Improved duplicate detection in RADIUS/Diameter gw. It will be changed again soon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 526
diff changeset
836 INTERIM_RECORD, 2 for the second, and so on until the value for
825a2992e3b9 Improved duplicate detection in RADIUS/Diameter gw. It will be changed again soon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 526
diff changeset
837 STOP_RECORD is one more than for the last INTERIM_RECORD.
825a2992e3b9 Improved duplicate detection in RADIUS/Diameter gw. It will be changed again soon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 526
diff changeset
838
825a2992e3b9 Improved duplicate detection in RADIUS/Diameter gw. It will be changed again soon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 526
diff changeset
839 -- we actually use the end-to-end id of the message here, which remains constant
825a2992e3b9 Improved duplicate detection in RADIUS/Diameter gw. It will be changed again soon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 526
diff changeset
840 if we send a duplicate, so it has the same properties as the suggested algorithm.
825a2992e3b9 Improved duplicate detection in RADIUS/Diameter gw. It will be changed again soon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 526
diff changeset
841 Anyway, it assumes that we are not converting twice the same RADIUS message.
825a2992e3b9 Improved duplicate detection in RADIUS/Diameter gw. It will be changed again soon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 526
diff changeset
842 . */
277
c94e4ea39f97 Add missing mandatory AVP
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 275
diff changeset
843 CHECK_FCT( fd_msg_avp_new ( cs->dict.Accounting_Record_Number, 0, &avp ) );
c94e4ea39f97 Add missing mandatory AVP
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 275
diff changeset
844 value.u32 = e2eid;
c94e4ea39f97 Add missing mandatory AVP
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 275
diff changeset
845 CHECK_FCT( fd_msg_avp_setvalue ( avp, &value ) );
c94e4ea39f97 Add missing mandatory AVP
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 275
diff changeset
846 CHECK_FCT( fd_msg_avp_add ( *diam_fw, MSG_BRW_LAST_CHILD, avp) );
c94e4ea39f97 Add missing mandatory AVP
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 275
diff changeset
847
271
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
848 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
849
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
850 case RADIUS_ATTR_ACCT_DELAY_TIME:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
851 CONV2DIAM_32B( Acct_Delay_Time );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
852 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
853
259
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
854 /*
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
855 - If the RADIUS message contains the Accounting-Input-Octets,
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
856 Accounting-Input-Packets, Accounting-Output-Octets, or
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
857 Accounting-Output-Packets, these attributes must be converted
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
858 to the Diameter equivalents. Further, if the Acct-Input-
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
859 Gigawords or Acct-Output-Gigawords attributes are present,
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
860 these must be used to properly compute the Diameter accounting
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
861 AVPs.
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
862 */
271
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
863 case RADIUS_ATTR_ACCT_INPUT_OCTETS:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
864 memset(&value, 0, sizeof(value));
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
865 {
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
866 uint8_t * v = (uint8_t *)(attr + 1);
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
867 value.u64 = (v[0] << 24)
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
868 | (v[1] << 16)
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
869 | (v[2] << 8)
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
870 | v[3] ;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
871 }
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
872 value.u64 += ((uint64_t)gigawords_in << 32);
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
873 CHECK_FCT( fd_msg_avp_new ( cs->dict.Accounting_Input_Octets, 0, &avp ) );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
874 CHECK_FCT( fd_msg_avp_setvalue ( avp, &value ) );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
875 CHECK_FCT( fd_msg_avp_add ( *diam_fw, MSG_BRW_LAST_CHILD, avp) );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
876 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
877
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
878 case RADIUS_ATTR_ACCT_OUTPUT_OCTETS:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
879 memset(&value, 0, sizeof(value));
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
880 {
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
881 uint8_t * v = (uint8_t *)(attr + 1);
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
882 value.u64 = (v[0] << 24)
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
883 | (v[1] << 16)
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
884 | (v[2] << 8)
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
885 | v[3] ;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
886 }
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
887 value.u64 += ((uint64_t)gigawords_out << 32);
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
888 CHECK_FCT( fd_msg_avp_new ( cs->dict.Accounting_Output_Octets, 0, &avp ) );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
889 CHECK_FCT( fd_msg_avp_setvalue ( avp, &value ) );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
890 CHECK_FCT( fd_msg_avp_add ( *diam_fw, MSG_BRW_LAST_CHILD, avp) );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
891 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
892
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
893 case RADIUS_ATTR_ACCT_SESSION_ID:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
894 CONV2DIAM_STR( Acct_Session_Id );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
895 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
896
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
897 case RADIUS_ATTR_ACCT_AUTHENTIC:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
898 CONV2DIAM_32B( Acct_Authentic );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
899 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
900
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
901 case RADIUS_ATTR_ACCT_SESSION_TIME:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
902 CONV2DIAM_32B( Acct_Session_Time );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
903 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
904
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
905 case RADIUS_ATTR_ACCT_INPUT_PACKETS:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
906 memset(&value, 0, sizeof(value));
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
907 {
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
908 uint8_t * v = (uint8_t *)(attr + 1);
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
909 value.u64 = (v[0] << 24)
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
910 | (v[1] << 16)
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
911 | (v[2] << 8)
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
912 | v[3] ;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
913 }
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
914 /* value.u64 += (gigawords_in << 32); */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
915 CHECK_FCT( fd_msg_avp_new ( cs->dict.Accounting_Input_Packets, 0, &avp ) );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
916 CHECK_FCT( fd_msg_avp_setvalue ( avp, &value ) );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
917 CHECK_FCT( fd_msg_avp_add ( *diam_fw, MSG_BRW_LAST_CHILD, avp) );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
918 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
919
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
920 case RADIUS_ATTR_ACCT_OUTPUT_PACKETS:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
921 memset(&value, 0, sizeof(value));
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
922 {
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
923 uint8_t * v = (uint8_t *)(attr + 1);
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
924 value.u64 = (v[0] << 24)
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
925 | (v[1] << 16)
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
926 | (v[2] << 8)
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
927 | v[3] ;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
928 }
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
929 /* value.u64 += (gigawords_out << 32); */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
930 CHECK_FCT( fd_msg_avp_new ( cs->dict.Accounting_Output_Packets, 0, &avp ) );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
931 CHECK_FCT( fd_msg_avp_setvalue ( avp, &value ) );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
932 CHECK_FCT( fd_msg_avp_add ( *diam_fw, MSG_BRW_LAST_CHILD, avp) );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
933 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
934
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
935 /*
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
936 - If the Accounting message contains an Acct-Termination-Cause
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
937 attribute, it should be translated to the equivalent
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
938 Termination-Cause AVP value.
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
939 */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
940 case RADIUS_ATTR_ACCT_TERMINATE_CAUSE:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
941 /* rfc4005#section-9.3.5 */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
942 {
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
943 uint8_t * v = (uint8_t *)(attr + 1);
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
944 str_cause = (v[0] << 24)
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
945 | (v[1] << 16)
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
946 | (v[2] << 8)
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
947 | v[3] ;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
948 }
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
949 str_cause += 10; /* This seems to be the rule, we can modify later if needed */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
950 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
951
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
952 case RADIUS_ATTR_ACCT_MULTI_SESSION_ID:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
953 CONV2DIAM_STR( Acct_Multi_Session_Id );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
954 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
955
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
956 case RADIUS_ATTR_ACCT_LINK_COUNT:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
957 CONV2DIAM_32B( Acct_Link_Count );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
958 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
959
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
960 /* CHAP-Challenge is not present in Accounting-Request */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
961
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
962 case RADIUS_ATTR_NAS_PORT_TYPE:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
963 CONV2DIAM_32B( NAS_Port_Type );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
964 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
965
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
966 case RADIUS_ATTR_PORT_LIMIT:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
967 CONV2DIAM_32B( Port_Limit );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
968 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
969
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
970 case RADIUS_ATTR_LOGIN_LAT_PORT:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
971 CONV2DIAM_STR( Login_LAT_Port );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
972 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
973
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
974 /* RFC 3162 */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
975 case RADIUS_ATTR_NAS_IPV6_ADDRESS:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
976 CONV2DIAM_STR( NAS_IPv6_Address );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
977 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
978
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
979 case RADIUS_ATTR_FRAMED_INTERFACE_ID:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
980 CONV2DIAM_64B( Framed_Interface_Id );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
981 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
982
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
983 case RADIUS_ATTR_FRAMED_IPV6_PREFIX:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
984 CONV2DIAM_STR( Framed_IPv6_Prefix );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
985 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
986
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
987 case RADIUS_ATTR_LOGIN_IPV6_HOST:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
988 CONV2DIAM_STR( Login_IPv6_Host );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
989 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
990
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
991 case RADIUS_ATTR_FRAMED_IPV6_ROUTE:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
992 CONV2DIAM_STR( Framed_IPv6_Route );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
993 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
994
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
995 case RADIUS_ATTR_FRAMED_IPV6_POOL:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
996 CONV2DIAM_STR( Framed_IPv6_Pool );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
997 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
998
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
999 /* RFC 2868 */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1000 /* Prepare the top-level Tunneling AVP for each tag values, as needed, and add to the Diameter message.
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1001 This macro is called when an AVP is added inside the group, so we will not have empty grouped AVPs */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1002 #define AVP_TUN_PREPARE() { \
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1003 if (avp_tun == NULL) { \
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1004 CHECK_MALLOC( avp_tun = calloc(sizeof(struct avp *), 32 ) ); \
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1005 } \
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1006 tag = *(uint8_t *)(attr + 1); \
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1007 if (tag > 0x1F) tag = 0; \
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1008 if (avp_tun[tag] == NULL) { \
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1009 CHECK_FCT( fd_msg_avp_new ( cs->dict.Tunneling, 0, &avp_tun[tag] ) ); \
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1010 CHECK_FCT( fd_msg_avp_add (*diam_fw, MSG_BRW_LAST_CHILD, avp_tun[tag]));\
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1011 } \
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1012 }
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1013
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1014 /* Convert an attribute to an OctetString AVP and add inside the Tunneling AVP corresponding to the tag */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1015 #define CONV2DIAM_TUN_STR( _dictobj_ ) { \
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1016 uint8_t tag; \
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1017 CHECK_PARAMS( attr->length >= 3); \
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1018 AVP_TUN_PREPARE(); \
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1019 CHECK_FCT( fd_msg_avp_new ( cs->dict._dictobj_, 0, &avp ) ); \
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1020 value.os.len = attr->length - (tag ? 3 : 2); \
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1021 value.os.data = ((unsigned char *)(attr + 1)) + (tag ? 1 : 0); \
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1022 CHECK_FCT( fd_msg_avp_setvalue ( avp, &value ) ); \
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1023 CHECK_FCT( fd_msg_avp_add ( avp_tun[tag], MSG_BRW_LAST_CHILD, avp) ); \
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1024 }
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1025
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1026 /* Convert an attribute to a scalar AVP and add inside the Tunneling AVP corresponding to the tag */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1027 #define CONV2DIAM_TUN_24B( _dictobj_ ) { \
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1028 uint8_t tag; \
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1029 CHECK_PARAMS( attr->length == 6); \
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1030 AVP_TUN_PREPARE(); \
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1031 CHECK_FCT( fd_msg_avp_new ( cs->dict._dictobj_, 0, &avp ) ); \
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1032 { \
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1033 uint8_t * v = (uint8_t *)(attr + 1); \
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1034 value.u32 = (v[1] << 16) | (v[2] <<8) | v[3] ; \
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1035 } \
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1036 CHECK_FCT( fd_msg_avp_setvalue ( avp, &value ) ); \
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1037 CHECK_FCT( fd_msg_avp_add ( avp_tun[tag], MSG_BRW_LAST_CHILD, avp) ); \
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1038 }
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1039
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1040 /*
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1041 - If the RADIUS message contains Tunnel information [RADTunnels],
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1042 the attributes or tagged groups should each be converted to a
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1043 Diameter Tunneling Grouped AVP set. If the tunnel information
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1044 contains a Tunnel-Password attribute, the RADIUS encryption
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1045 must be resolved, and the password forwarded, by using Diameter
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1046 security methods.
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1047 -> If the RADIUS message does not use properly the Tag info, result is unpredictable here..
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1048 */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1049 case RADIUS_ATTR_TUNNEL_TYPE:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1050 CONV2DIAM_TUN_24B( Tunnel_Type );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1051 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1052
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1053 case RADIUS_ATTR_TUNNEL_MEDIUM_TYPE:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1054 CONV2DIAM_TUN_24B( Tunnel_Medium_Type );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1055 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1056
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1057 case RADIUS_ATTR_TUNNEL_CLIENT_ENDPOINT:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1058 CONV2DIAM_TUN_STR( Tunnel_Client_Endpoint );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1059 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1060
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1061 case RADIUS_ATTR_TUNNEL_SERVER_ENDPOINT:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1062 CONV2DIAM_TUN_STR( Tunnel_Server_Endpoint );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1063 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1064
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1065 /* Tunnel-Password never present in an Accounting-Request */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1066
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1067 case RADIUS_ATTR_TUNNEL_PRIVATE_GROUP_ID:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1068 CONV2DIAM_TUN_STR( Tunnel_Private_Group_Id );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1069 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1070
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1071 case RADIUS_ATTR_TUNNEL_ASSIGNMENT_ID:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1072 CONV2DIAM_TUN_STR( Tunnel_Assignment_Id );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1073 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1074
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1075 /* Tunnel-Reference never present in an Accounting-Request */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1076
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1077 case RADIUS_ATTR_TUNNEL_CLIENT_AUTH_ID:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1078 CONV2DIAM_TUN_STR( Tunnel_Client_Auth_Id );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1079 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1080
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1081 case RADIUS_ATTR_TUNNEL_SERVER_AUTH_ID:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1082 CONV2DIAM_TUN_STR( Tunnel_Server_Auth_Id );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1083 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1084
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1085 /* RFC 2869 */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1086 /*
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1087 Acct-Input-Gigawords, Acct-Output-
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1088 Gigawords, Event-Timestamp, and NAS-Port-Id may have 0-1 instances in
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1089 an Accounting-Request packet. Connect-Info may have 0+ instances in
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1090 an Accounting-Request packet. The other attributes added in this
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1091 document must not be present in an Accounting-Request.
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1092 */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1093 case RADIUS_ATTR_ACCT_INPUT_GIGAWORDS:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1094 break; /* we already saved the value in gigawords_in */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1095
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1096 case RADIUS_ATTR_ACCT_OUTPUT_GIGAWORDS:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1097 break; /* we already saved the value in gigawords_out */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1098
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1099 case RADIUS_ATTR_EVENT_TIMESTAMP:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1100 /* RADIUS:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1101 The Value field is four octets encoding an unsigned integer with
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1102 the number of seconds since January 1, 1970 00:00 UTC.
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1103 Diameter:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1104 The Time format is derived from the OctetString AVP Base Format.
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1105 The string MUST contain four octets, in the same format as the
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1106 first four bytes are in the NTP timestamp format. The NTP
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1107 Timestamp format is defined in Chapter 3 of [RFC4330].
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1108
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1109 This represents the number of seconds since 0h on 1 January 1900
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1110 with respect to the Coordinated Universal Time (UTC).
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1111
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1112 -- RFC4330:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1113 NTP timestamps are represented as a 64-bit unsigned
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1114 fixed-point number, in seconds relative to 0h on 1 January 1900. The
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1115 integer part is in the first 32 bits, and the fraction part in the
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1116 last 32 bits. In the fraction part, the non-significant low-order
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1117 bits are not specified and are ordinarily set to 0.
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1118 */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1119 {
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1120 uint32_t ts;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1121
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1122 uint8_t * v = (uint8_t *)(attr + 1);
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1123 /* Read the RADIUS attribute value */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1124 ts = (v[0] << 24)
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1125 | (v[1] << 16)
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1126 | (v[2] << 8)
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1127 | v[3] ;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1128
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1129 /* Add the 70 missing years */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1130 ts += 2208988800U; /* 60 * 60 * 24 * ( 365 * 70 + 17 ) */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1131
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1132 /* Convert to network byte order */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1133 ts = htonl(ts);
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1134
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1135 /* Diameter Time datatype is derived from OctetString */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1136 value.os.data = (void *) &ts;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1137 value.os.len = sizeof(uint32_t);
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1138
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1139 CHECK_FCT( fd_msg_avp_new ( cs->dict.Event_Timestamp, 0, &avp ) );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1140 CHECK_FCT( fd_msg_avp_setvalue ( avp, &value ) );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1141 CHECK_FCT( fd_msg_avp_add ( *diam_fw, MSG_BRW_LAST_CHILD, avp) );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1142 }
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1143 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1144
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1145 case RADIUS_ATTR_NAS_PORT_ID:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1146 CONV2DIAM_STR( NAS_Port_Id );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1147 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1148
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1149 case RADIUS_ATTR_CONNECT_INFO:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1150 CONV2DIAM_STR( Connect_Info );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1151 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1152
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1153 case RADIUS_ATTR_FRAMED_POOL: /* To follow the IPv6 version */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1154 CONV2DIAM_STR( Framed_Pool );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1155 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1156
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1157
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1158 /* RFC 3579 */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1159 /*
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1160 The EAP-Message and Message-Authenticator attributes specified in
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1161 this document MUST NOT be present in an Accounting-Request.
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1162 */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1163 case RADIUS_ATTR_ORIGINATING_LINE_INFO:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1164 CONV2DIAM_STR( Originating_Line_Info );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1165 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1166
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1167 /* Default */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1168 default: /* unknown attribute */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1169 /* We just keep the attribute in the RADIUS message */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1170 rad_req->attr_pos[nattr_used++] = rad_req->attr_pos[idx];
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1171 }
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1172 }
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1173
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1174 /* Update the radius message to remove all handled attributes */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1175 rad_req->attr_used = nattr_used;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1176
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1177 /* Store useful information in the session */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1178 {
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1179 struct sess_state * st;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1180 CHECK_PARAMS(session);
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1181
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1182 CHECK_MALLOC( st = malloc(sizeof(struct sess_state)) );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1183 memset(st, 0, sizeof(struct sess_state));
273
bce8e5b7bf78 Added code to send an STR after a STOP accounting record in RADIUS
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 271
diff changeset
1184 st->auth_appl = auth_appl;
296
e11a9f90a65a Do not send STR if the auth server sent NO_STATE_MAINTAINED
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 295
diff changeset
1185 if (auth_appl) { /* We use the value 0 for servers which indicated NO STATE MAINTAINED, hence have no need for STR */
e11a9f90a65a Do not send STR if the auth server sent NO_STATE_MAINTAINED
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 295
diff changeset
1186 st->send_str = send_str;
e11a9f90a65a Do not send STR if the auth server sent NO_STATE_MAINTAINED
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 295
diff changeset
1187 }
271
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1188 st->term_cause = str_cause;
356
e203fc0c95e3 Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 296
diff changeset
1189 CHECK_FCT( fd_sess_state_store( cs->sess_hdl, *session, &st ) );
271
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1190 }
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1191
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1192 return 0;
259
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1193 }
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1194
273
bce8e5b7bf78 Added code to send an STR after a STOP accounting record in RADIUS
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 271
diff changeset
1195 /* Callback when an STA is received after having sent an STR. */
bce8e5b7bf78 Added code to send an STR after a STOP accounting record in RADIUS
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 271
diff changeset
1196 static void handle_sta(void * data, struct msg ** answer)
bce8e5b7bf78 Added code to send an STR after a STOP accounting record in RADIUS
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 271
diff changeset
1197 {
bce8e5b7bf78 Added code to send an STR after a STOP accounting record in RADIUS
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 271
diff changeset
1198 struct rgwp_config * cs = data;
bce8e5b7bf78 Added code to send an STR after a STOP accounting record in RADIUS
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 271
diff changeset
1199 struct avp *avp;
bce8e5b7bf78 Added code to send an STR after a STOP accounting record in RADIUS
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 271
diff changeset
1200 struct avp_hdr *ahdr;
bce8e5b7bf78 Added code to send an STR after a STOP accounting record in RADIUS
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 271
diff changeset
1201
bce8e5b7bf78 Added code to send an STR after a STOP accounting record in RADIUS
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 271
diff changeset
1202 CHECK_PARAMS_DO( data && answer && *answer, goto out );
bce8e5b7bf78 Added code to send an STR after a STOP accounting record in RADIUS
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 271
diff changeset
1203
bce8e5b7bf78 Added code to send an STR after a STOP accounting record in RADIUS
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 271
diff changeset
1204 /* Check the Diameter error code */
bce8e5b7bf78 Added code to send an STR after a STOP accounting record in RADIUS
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 271
diff changeset
1205 CHECK_FCT_DO( fd_msg_search_avp (*answer, cs->dict.Result_Code, &avp), goto out );
bce8e5b7bf78 Added code to send an STR after a STOP accounting record in RADIUS
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 271
diff changeset
1206 CHECK_PARAMS_DO( avp, goto out );
bce8e5b7bf78 Added code to send an STR after a STOP accounting record in RADIUS
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 271
diff changeset
1207 CHECK_FCT_DO( fd_msg_avp_hdr ( avp, &ahdr ), goto out );
bce8e5b7bf78 Added code to send an STR after a STOP accounting record in RADIUS
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 271
diff changeset
1208 if (ahdr->avp_value->u32 != ER_DIAMETER_SUCCESS)
bce8e5b7bf78 Added code to send an STR after a STOP accounting record in RADIUS
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 271
diff changeset
1209 goto out;
bce8e5b7bf78 Added code to send an STR after a STOP accounting record in RADIUS
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 271
diff changeset
1210
bce8e5b7bf78 Added code to send an STR after a STOP accounting record in RADIUS
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 271
diff changeset
1211 /* OK, discard the message without complaining */
bce8e5b7bf78 Added code to send an STR after a STOP accounting record in RADIUS
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 271
diff changeset
1212 fd_msg_free(*answer);
bce8e5b7bf78 Added code to send an STR after a STOP accounting record in RADIUS
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 271
diff changeset
1213 *answer = NULL;
bce8e5b7bf78 Added code to send an STR after a STOP accounting record in RADIUS
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 271
diff changeset
1214
bce8e5b7bf78 Added code to send an STR after a STOP accounting record in RADIUS
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 271
diff changeset
1215 out:
bce8e5b7bf78 Added code to send an STR after a STOP accounting record in RADIUS
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 271
diff changeset
1216 if (answer && *answer) {
bce8e5b7bf78 Added code to send an STR after a STOP accounting record in RADIUS
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 271
diff changeset
1217 TRACE_DEBUG(INFO, "Received the following problematic STA message, discarding...");
bce8e5b7bf78 Added code to send an STR after a STOP accounting record in RADIUS
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 271
diff changeset
1218 fd_msg_dump_walk( INFO, *answer );
bce8e5b7bf78 Added code to send an STR after a STOP accounting record in RADIUS
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 271
diff changeset
1219 fd_msg_free(*answer);
bce8e5b7bf78 Added code to send an STR after a STOP accounting record in RADIUS
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 271
diff changeset
1220 *answer = NULL;
bce8e5b7bf78 Added code to send an STR after a STOP accounting record in RADIUS
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 271
diff changeset
1221 }
bce8e5b7bf78 Added code to send an STR after a STOP accounting record in RADIUS
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 271
diff changeset
1222 return;
bce8e5b7bf78 Added code to send an STR after a STOP accounting record in RADIUS
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 271
diff changeset
1223 }
bce8e5b7bf78 Added code to send an STR after a STOP accounting record in RADIUS
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 271
diff changeset
1224
356
e203fc0c95e3 Updated the app_radgw extension to allow more souple management of sessions, and stateful gateway features.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 296
diff changeset
1225 static int acct_diam_ans( struct rgwp_config * cs, struct session * session, struct msg ** diam_ans, struct radius_msg ** rad_fw, struct rgw_client * cli, int * stateful )
259
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1226 {
271
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1227 struct sess_state * st = NULL;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1228 struct avp *avp, *next;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1229 struct avp_hdr *ahdr, *sid, *oh, *or;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1230
259
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1231 TRACE_ENTRY("%p %p %p %p %p", cs, session, diam_ans, rad_fw, cli);
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1232 CHECK_PARAMS(cs);
271
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1233
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1234 if (session) {
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1235 CHECK_FCT( fd_sess_state_retrieve( cs->sess_hdl, session, &st ) );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1236 }
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1237
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1238 if (!st) {
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1239 TRACE_DEBUG(INFO, "Received an ACA without corresponding session information, cannot translate to RADIUS");
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1240 return EINVAL;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1241 }
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1242
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1243 /* Search these AVPs first */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1244 CHECK_FCT( fd_msg_search_avp (*diam_ans, cs->dict.Session_Id, &avp) );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1245 CHECK_FCT( fd_msg_avp_hdr ( avp, &sid ) );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1246
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1247 CHECK_FCT( fd_msg_search_avp (*diam_ans, cs->dict.Origin_Host, &avp) );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1248 CHECK_FCT( fd_msg_avp_hdr ( avp, &oh ) );
259
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1249
271
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1250 CHECK_FCT( fd_msg_search_avp (*diam_ans, cs->dict.Origin_Realm, &avp) );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1251 CHECK_FCT( fd_msg_avp_hdr ( avp, &or ) );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1252
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1253 /* Check the Diameter error code */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1254 CHECK_FCT( fd_msg_search_avp (*diam_ans, cs->dict.Result_Code, &avp) );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1255 ASSERT( avp ); /* otherwise the message should have been discarded a lot earlier because of ABNF */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1256 CHECK_FCT( fd_msg_avp_hdr ( avp, &ahdr ) );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1257 switch (ahdr->avp_value->u32) {
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1258 case ER_DIAMETER_SUCCESS:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1259 case ER_DIAMETER_LIMITED_SUCCESS:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1260 (*rad_fw)->hdr->code = RADIUS_CODE_ACCOUNTING_RESPONSE;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1261 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1262
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1263 default:
535
72c511043f05 A few bug fixes on the RADIUS/Diameter gateway.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 532
diff changeset
1264 fd_log_debug("[acct.rgwx] Received Diameter answer with error code '%d' from server '%.*s', session %.*s, not translating into Accounting-Response\n",
271
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1265 ahdr->avp_value->u32,
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1266 oh->avp_value->os.len, oh->avp_value->os.data,
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1267 sid->avp_value->os.len, sid->avp_value->os.data);
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1268 CHECK_FCT( fd_msg_search_avp (*diam_ans, cs->dict.Error_Message, &avp) );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1269 if (avp) {
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1270 CHECK_FCT( fd_msg_avp_hdr ( avp, &ahdr ) );
535
72c511043f05 A few bug fixes on the RADIUS/Diameter gateway.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 532
diff changeset
1271 fd_log_debug("[acct.rgwx] Error-Message content: '%.*s'\n",
271
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1272 ahdr->avp_value->os.len, ahdr->avp_value->os.data);
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1273 }
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1274 CHECK_FCT( fd_msg_search_avp (*diam_ans, cs->dict.Error_Reporting_Host, &avp) );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1275 if (avp) {
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1276 CHECK_FCT( fd_msg_avp_hdr ( avp, &ahdr ) );
535
72c511043f05 A few bug fixes on the RADIUS/Diameter gateway.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 532
diff changeset
1277 fd_log_debug("[acct.rgwx] Error-Reporting-Host: '%.*s'\n",
271
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1278 ahdr->avp_value->os.len, ahdr->avp_value->os.data);
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1279 }
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1280 CHECK_FCT( fd_msg_search_avp (*diam_ans, cs->dict.Failed_AVP, &avp) );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1281 if (avp) {
535
72c511043f05 A few bug fixes on the RADIUS/Diameter gateway.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 532
diff changeset
1282 fd_log_debug("[acct.rgwx] Failed-AVP was included in the message.\n");
271
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1283 /* Dump its content ? */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1284 }
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1285 return -1;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1286 }
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1287 /* Remove this Result-Code avp */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1288 CHECK_FCT( fd_msg_free( avp ) );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1289
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1290 /* If it was a response to a STOP record, we must send an STR for this session */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1291 if (st->send_str) {
273
bce8e5b7bf78 Added code to send an STR after a STOP accounting record in RADIUS
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 271
diff changeset
1292 struct msg * str = NULL;
294
0e940240c436 Fix application id in the STR header. Not sure what is really expected there, though...
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 277
diff changeset
1293 struct msg_hdr * hdr = NULL;
273
bce8e5b7bf78 Added code to send an STR after a STOP accounting record in RADIUS
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 271
diff changeset
1294 char * fqdn;
bce8e5b7bf78 Added code to send an STR after a STOP accounting record in RADIUS
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 271
diff changeset
1295 char * realm;
bce8e5b7bf78 Added code to send an STR after a STOP accounting record in RADIUS
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 271
diff changeset
1296 union avp_value avp_val;
bce8e5b7bf78 Added code to send an STR after a STOP accounting record in RADIUS
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 271
diff changeset
1297
bce8e5b7bf78 Added code to send an STR after a STOP accounting record in RADIUS
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 271
diff changeset
1298 /* Create a new STR message */
bce8e5b7bf78 Added code to send an STR after a STOP accounting record in RADIUS
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 271
diff changeset
1299 CHECK_FCT( fd_msg_new ( cs->dict.Session_Termination_Request, MSGFL_ALLOC_ETEID, &str ) );
bce8e5b7bf78 Added code to send an STR after a STOP accounting record in RADIUS
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 271
diff changeset
1300
294
0e940240c436 Fix application id in the STR header. Not sure what is really expected there, though...
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 277
diff changeset
1301 /* Set the application-id to the auth application if available, accouting otherwise (not sure what is actually expected...) */
0e940240c436 Fix application id in the STR header. Not sure what is really expected there, though...
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 277
diff changeset
1302 CHECK_FCT( fd_msg_hdr ( str, &hdr ) );
0e940240c436 Fix application id in the STR header. Not sure what is really expected there, though...
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 277
diff changeset
1303 hdr->msg_appl = st->auth_appl ?: AI_ACCT;
0e940240c436 Fix application id in the STR header. Not sure what is really expected there, though...
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 277
diff changeset
1304
273
bce8e5b7bf78 Added code to send an STR after a STOP accounting record in RADIUS
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 271
diff changeset
1305 /* Add the Session-Id AVP as first AVP */
bce8e5b7bf78 Added code to send an STR after a STOP accounting record in RADIUS
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 271
diff changeset
1306 CHECK_FCT( fd_msg_avp_new ( cs->dict.Session_Id, 0, &avp ) );
bce8e5b7bf78 Added code to send an STR after a STOP accounting record in RADIUS
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 271
diff changeset
1307 CHECK_FCT( fd_msg_avp_setvalue ( avp, sid->avp_value ) );
bce8e5b7bf78 Added code to send an STR after a STOP accounting record in RADIUS
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 271
diff changeset
1308 CHECK_FCT( fd_msg_avp_add ( str, MSG_BRW_FIRST_CHILD, avp) );
bce8e5b7bf78 Added code to send an STR after a STOP accounting record in RADIUS
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 271
diff changeset
1309
bce8e5b7bf78 Added code to send an STR after a STOP accounting record in RADIUS
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 271
diff changeset
1310 /* Add the Destination-Realm as next AVP */
bce8e5b7bf78 Added code to send an STR after a STOP accounting record in RADIUS
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 271
diff changeset
1311 CHECK_FCT( fd_msg_avp_new ( cs->dict.Destination_Realm, 0, &avp ) );
bce8e5b7bf78 Added code to send an STR after a STOP accounting record in RADIUS
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 271
diff changeset
1312 CHECK_FCT( fd_msg_avp_setvalue ( avp, or->avp_value ) );
bce8e5b7bf78 Added code to send an STR after a STOP accounting record in RADIUS
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 271
diff changeset
1313 CHECK_FCT( fd_msg_avp_add ( str, MSG_BRW_LAST_CHILD, avp) );
bce8e5b7bf78 Added code to send an STR after a STOP accounting record in RADIUS
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 271
diff changeset
1314
bce8e5b7bf78 Added code to send an STR after a STOP accounting record in RADIUS
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 271
diff changeset
1315 /* Get information on the NAS */
bce8e5b7bf78 Added code to send an STR after a STOP accounting record in RADIUS
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 271
diff changeset
1316 CHECK_FCT( rgw_clients_get_origin(cli, &fqdn, &realm) );
bce8e5b7bf78 Added code to send an STR after a STOP accounting record in RADIUS
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 271
diff changeset
1317
bce8e5b7bf78 Added code to send an STR after a STOP accounting record in RADIUS
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 271
diff changeset
1318 /* Add the Origin-Host as next AVP */
bce8e5b7bf78 Added code to send an STR after a STOP accounting record in RADIUS
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 271
diff changeset
1319 CHECK_FCT( fd_msg_avp_new ( cs->dict.Origin_Host, 0, &avp ) );
bce8e5b7bf78 Added code to send an STR after a STOP accounting record in RADIUS
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 271
diff changeset
1320 memset(&avp_val, 0, sizeof(avp_val));
bce8e5b7bf78 Added code to send an STR after a STOP accounting record in RADIUS
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 271
diff changeset
1321 avp_val.os.data = (unsigned char *)fqdn;
bce8e5b7bf78 Added code to send an STR after a STOP accounting record in RADIUS
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 271
diff changeset
1322 avp_val.os.len = strlen(fqdn);
bce8e5b7bf78 Added code to send an STR after a STOP accounting record in RADIUS
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 271
diff changeset
1323 CHECK_FCT( fd_msg_avp_setvalue ( avp, &avp_val ) );
bce8e5b7bf78 Added code to send an STR after a STOP accounting record in RADIUS
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 271
diff changeset
1324 CHECK_FCT( fd_msg_avp_add ( str, MSG_BRW_LAST_CHILD, avp) );
bce8e5b7bf78 Added code to send an STR after a STOP accounting record in RADIUS
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 271
diff changeset
1325
bce8e5b7bf78 Added code to send an STR after a STOP accounting record in RADIUS
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 271
diff changeset
1326 /* Add the Origin-Realm as next AVP */
bce8e5b7bf78 Added code to send an STR after a STOP accounting record in RADIUS
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 271
diff changeset
1327 CHECK_FCT( fd_msg_avp_new ( cs->dict.Origin_Realm, 0, &avp ) );
bce8e5b7bf78 Added code to send an STR after a STOP accounting record in RADIUS
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 271
diff changeset
1328 memset(&avp_val, 0, sizeof(avp_val));
bce8e5b7bf78 Added code to send an STR after a STOP accounting record in RADIUS
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 271
diff changeset
1329 avp_val.os.data = (unsigned char *)realm;
bce8e5b7bf78 Added code to send an STR after a STOP accounting record in RADIUS
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 271
diff changeset
1330 avp_val.os.len = strlen(realm);
bce8e5b7bf78 Added code to send an STR after a STOP accounting record in RADIUS
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 271
diff changeset
1331 CHECK_FCT( fd_msg_avp_setvalue ( avp, &avp_val ) );
bce8e5b7bf78 Added code to send an STR after a STOP accounting record in RADIUS
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 271
diff changeset
1332 CHECK_FCT( fd_msg_avp_add ( str, MSG_BRW_LAST_CHILD, avp) );
bce8e5b7bf78 Added code to send an STR after a STOP accounting record in RADIUS
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 271
diff changeset
1333
bce8e5b7bf78 Added code to send an STR after a STOP accounting record in RADIUS
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 271
diff changeset
1334 /* Auth-Application-Id -- if we did not get it from our Class attribute, we just set "0" */
bce8e5b7bf78 Added code to send an STR after a STOP accounting record in RADIUS
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 271
diff changeset
1335 CHECK_FCT( fd_msg_avp_new ( cs->dict.Auth_Application_Id, 0, &avp ) );
bce8e5b7bf78 Added code to send an STR after a STOP accounting record in RADIUS
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 271
diff changeset
1336 avp_val.u32 = st->auth_appl;
bce8e5b7bf78 Added code to send an STR after a STOP accounting record in RADIUS
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 271
diff changeset
1337 CHECK_FCT( fd_msg_avp_setvalue ( avp, &avp_val ) );
bce8e5b7bf78 Added code to send an STR after a STOP accounting record in RADIUS
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 271
diff changeset
1338 CHECK_FCT( fd_msg_avp_add ( str, MSG_BRW_LAST_CHILD, avp) );
bce8e5b7bf78 Added code to send an STR after a STOP accounting record in RADIUS
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 271
diff changeset
1339
bce8e5b7bf78 Added code to send an STR after a STOP accounting record in RADIUS
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 271
diff changeset
1340 /* Termination-Cause */
bce8e5b7bf78 Added code to send an STR after a STOP accounting record in RADIUS
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 271
diff changeset
1341 CHECK_FCT( fd_msg_avp_new ( cs->dict.Termination_Cause, 0, &avp ) );
bce8e5b7bf78 Added code to send an STR after a STOP accounting record in RADIUS
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 271
diff changeset
1342 avp_val.u32 = st->term_cause;
bce8e5b7bf78 Added code to send an STR after a STOP accounting record in RADIUS
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 271
diff changeset
1343 CHECK_FCT( fd_msg_avp_setvalue ( avp, &avp_val ) );
bce8e5b7bf78 Added code to send an STR after a STOP accounting record in RADIUS
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 271
diff changeset
1344 CHECK_FCT( fd_msg_avp_add ( str, MSG_BRW_LAST_CHILD, avp) );
bce8e5b7bf78 Added code to send an STR after a STOP accounting record in RADIUS
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 271
diff changeset
1345
bce8e5b7bf78 Added code to send an STR after a STOP accounting record in RADIUS
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 271
diff changeset
1346 /* Send this message */
bce8e5b7bf78 Added code to send an STR after a STOP accounting record in RADIUS
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 271
diff changeset
1347 CHECK_FCT( fd_msg_send ( &str, handle_sta, cs ) );
271
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1348 }
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1349
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1350 /*
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1351 No attributes should be found in
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1352 Accounting-Response packets except Proxy-State and possibly Vendor-
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1353 Specific.
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1354 */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1355
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1356 /* Now loop in the list of AVPs and convert those that we know how */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1357 CHECK_FCT( fd_msg_browse(*diam_ans, MSG_BRW_FIRST_CHILD, &next, NULL) );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1358
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1359 while (next) {
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1360 int handled = 1;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1361 avp = next;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1362 CHECK_FCT( fd_msg_browse(avp, MSG_BRW_NEXT, &next, NULL) );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1363
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1364 CHECK_FCT( fd_msg_avp_hdr ( avp, &ahdr ) );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1365
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1366 if (!(ahdr->avp_flags & AVP_FLAG_VENDOR)) {
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1367 switch (ahdr->avp_code) {
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1368 /* Based on RFC4005, sec 3.10 */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1369 case DIAM_ATTR_SESSION_ID:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1370 case DIAM_ATTR_ORIGIN_HOST:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1371 case DIAM_ATTR_ORIGIN_REALM:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1372 case DIAM_ATTR_ACCOUNTING_RECORD_TYPE:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1373 case DIAM_ATTR_ACCOUNTING_RECORD_NUMBER:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1374 case DIAM_ATTR_ACCT_APPLICATION_ID:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1375 case DIAM_ATTR_VENDOR_SPECIFIC_APPLICATION_ID:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1376 case DIAM_ATTR_USER_NAME:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1377 case DIAM_ATTR_ACCOUNTING_SUB_SESSION_ID:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1378 case DIAM_ATTR_ACCT_SESSION_ID:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1379 case DIAM_ATTR_ACCT_MULTI_SESSION_ID:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1380 case DIAM_ATTR_EVENT_TIMESTAMP:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1381 case DIAM_ATTR_ORIGIN_AAA_PROTOCOL:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1382 case DIAM_ATTR_ORIGIN_STATE_ID:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1383 case DIAM_ATTR_NAS_IDENTIFIER:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1384 case DIAM_ATTR_NAS_IP_ADDRESS:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1385 case DIAM_ATTR_NAS_IPV6_ADDRESS:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1386 case DIAM_ATTR_NAS_PORT:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1387 case DIAM_ATTR_NAS_PORT_ID:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1388 case DIAM_ATTR_NAS_PORT_TYPE:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1389 case DIAM_ATTR_SERVICE_TYPE:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1390 case DIAM_ATTR_TERMINATION_CAUSE:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1391 case DIAM_ATTR_ACCOUNTING_REALTIME_REQUIRED:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1392 case DIAM_ATTR_ACCT_INTERIM_INTERVAL:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1393 case DIAM_ATTR_CLASS:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1394 /* We just remove these AVP, they are not expected in RADIUS client */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1395 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1396
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1397 default:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1398 /* Leave the AVP in the message for further treatment */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1399 handled = 0;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1400 }
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1401 } else {
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1402 /* Vendor-specific AVPs */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1403 switch (ahdr->avp_vendor) {
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1404
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1405 default: /* unknown vendor */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1406 handled = 0;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1407 }
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1408 }
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1409
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1410 if (handled) {
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1411 CHECK_FCT( fd_msg_free( avp ) );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1412 }
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1413 }
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1414
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1415 /*
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1416 The Authenticator field in an Accounting-Response packet is called
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1417 the Response Authenticator, and contains a one-way MD5 hash
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1418 calculated over a stream of octets consisting of the Accounting-
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1419 Response Code, Identifier, Length, the Request Authenticator field
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1420 from the Accounting-Request packet being replied to, and the
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1421 response attributes if any, followed by the shared secret. The
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1422 resulting 16 octet MD5 hash value is stored in the Authenticator
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1423 field of the Accounting-Response packet.
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1424
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1425 -- done in radius_msg_finish_srv
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1426 */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1427
541
fac6907479ad Free state memory after use.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 537
diff changeset
1428 free(st);
fac6907479ad Free state memory after use.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 537
diff changeset
1429
271
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1430 return 0;
259
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1431 }
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1432
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1433 /* The exported symbol */
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1434 struct rgw_api rgwp_descriptor = {
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1435 .rgwp_name = "acct",
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1436 .rgwp_conf_parse = acct_conf_parse,
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1437 .rgwp_conf_free = acct_conf_free,
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1438 .rgwp_rad_req = acct_rad_req,
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1439 .rgwp_diam_ans = acct_diam_ans
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1440 };
"Welcome to our mercurial repository"