annotate extensions/app_radgw/rgwx_acct.c @ 1088:1d1a20a0779d

Second part of changeset 1083, now the code compiles again. Still missing some functions implementation, though
author Sebastien Decugis <sdecugis@freediameter.net>
date Sat, 04 May 2013 21:25:27 +0200
parents 0117a7746b21
children 6b4a417d2845
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) *
740
4a9f08d6b6ba Updated my mail address
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 706
diff changeset
3 * Author: Sebastien Decugis <sdecugis@freediameter.net> *
259
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
4 * *
703
b1d7d7cad733 Updated copyright information
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 688
diff changeset
5 * Copyright (c) 2011, WIDE Project and NICT *
259
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
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
49
259
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
50 /* The state we keep for this plugin */
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
51 struct rgwp_config {
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
52 struct {
277
c94e4ea39f97 Add missing mandatory AVP
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 275
diff changeset
53 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
54 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
55 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
56 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
57 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
58 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
59 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
60 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
61 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
62 struct dict_object * Acct_Authentic; /* Acct-Authentic */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
63 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
64 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
65 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
66
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
67 struct dict_object * ARAP_Password; /* ARAP-Password */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
68 struct dict_object * ARAP_Security; /* ARAP-Security */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
69 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
70 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
71 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
72 struct dict_object * Authorization_Lifetime; /* Authorization-Lifetime */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
73 struct dict_object * Callback_Number; /* Callback-Number */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
74 struct dict_object * Callback_Id; /* Callback-Id */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
75 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
76 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
77 struct dict_object * Class; /* Class */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
78 struct dict_object * CHAP_Algorithm; /* CHAP-Algorithm */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
79 struct dict_object * CHAP_Auth; /* CHAP-Auth */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
80 struct dict_object * CHAP_Challenge; /* CHAP-Challenge */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
81 struct dict_object * CHAP_Ident; /* CHAP-Ident */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
82 struct dict_object * CHAP_Response; /* CHAP-Response */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
83 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
84 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
85 struct dict_object * Destination_Realm; /* Destination-Realm */
271
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
86 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
87 struct dict_object * Error_Message; /* Error-Message */
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
88 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
89 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
90 struct dict_object * Failed_AVP; /* Failed-AVP */
271
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
91 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
92 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
93 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
94 struct dict_object * Framed_Compression; /* Framed-Compression */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
95 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
96 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
97 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
98 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
99 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
100 struct dict_object * Framed_MTU; /* Framed-MTU */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
101 struct dict_object * Framed_Protocol; /* Framed-Protocol */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
102 struct dict_object * Framed_Pool; /* Framed-Pool */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
103 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
104 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
105 struct dict_object * Framed_Route; /* Framed-Route */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
106 struct dict_object * Framed_Routing; /* Framed-Routing */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
107 struct dict_object * Filter_Id; /* Filter-Id */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
108 struct dict_object * Idle_Timeout; /* Idle-Timeout */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
109 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
110 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
111 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
112 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
113 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
114 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
115 struct dict_object * Login_Service; /* Login-Service */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
116 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
117 struct dict_object * NAS_Identifier; /* NAS-Identifier */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
118 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
119 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
120 struct dict_object * NAS_Port; /* NAS-Port */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
121 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
122 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
123 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
124 struct dict_object * Origin_Host; /* Origin-Host */
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
125 struct dict_object * Origin_Realm; /* Origin-Realm */
271
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
126 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
127 struct dict_object * Port_Limit; /* Port-Limit */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
128 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
129 struct dict_object * Result_Code; /* Result-Code */
271
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
130 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
131 struct dict_object * Session_Id; /* Session-Id */
271
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
132 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
133 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
134 struct dict_object * Termination_Cause; /* Termination-Cause */
271
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
135 struct dict_object * Tunneling; /* Tunneling */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
136 struct dict_object * Tunnel_Type; /* Tunnel-Type */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
137 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
138 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
139 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
140 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
141 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
142 struct dict_object * Tunnel_Preference; /* Tunnel-Preference */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
143 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
144 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
145 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
146
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 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
148 } 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
149 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
150 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
151
6fe3e5cf9fb2 Added a flag to disable NAI routing in RADIUS/Diameter gw
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 448
diff changeset
152 int ignore_nai;
259
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
153 };
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
154
271
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
155 /* The state we store in the session */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
156 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
157 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
158 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
159 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
160 };
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
161
1088
1d1a20a0779d Second part of changeset 1083, now the code compiles again. Still missing some functions implementation, though
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1027
diff changeset
162 static DECLARE_FD_DUMP_PROTOTYPE(acct_conf_session_state_dump, struct sess_state * st)
1d1a20a0779d Second part of changeset 1083, now the code compiles again. Still missing some functions implementation, though
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1027
diff changeset
163 {
1d1a20a0779d Second part of changeset 1083, now the code compiles again. Still missing some functions implementation, though
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1027
diff changeset
164 return fd_dump_extend( FD_DUMP_STD_PARAMS, "[rgwx sess_state](@%p): aai:%x str:%d TC:%u", st, st->auth_appl, st->send_str, st->term_cause);
1d1a20a0779d Second part of changeset 1083, now the code compiles again. Still missing some functions implementation, though
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1027
diff changeset
165 }
1d1a20a0779d Second part of changeset 1083, now the code compiles again. Still missing some functions implementation, though
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1027
diff changeset
166
259
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
167 /* Initialize the plugin */
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
168 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
169 {
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
170 struct rgwp_config * new;
271
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
171 struct dict_object * app;
259
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
172
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
173 TRACE_ENTRY("%p %p", conffile, state);
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
174 CHECK_PARAMS( state );
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
175
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
176 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
177 memset(new, 0, sizeof(struct rgwp_config));
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
178
1088
1d1a20a0779d Second part of changeset 1083, now the code compiles again. Still missing some functions implementation, though
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1027
diff changeset
179 CHECK_FCT( fd_sess_handler_create( &new->sess_hdl, (void *)free, acct_conf_session_state_dump, NULL ) );
259
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
180 new->confstr = conffile;
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
181
532
4cb8f63a0f67 Fix segfault when no configuration string is given to the plugins
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 530
diff changeset
182 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
183 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
184
259
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
185 /* Resolve all dictionary objects we use */
277
c94e4ea39f97 Add missing mandatory AVP
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 275
diff changeset
186 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
187 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
188 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
189 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
190 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
191 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
192 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
193 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
194 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
195 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
196 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
197 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
198 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
199
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, "ARAP-Password", &new->dict.ARAP_Password, 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, "ARAP-Security", &new->dict.ARAP_Security, 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, "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
203 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
204 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
205 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
206 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
207 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
208 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
209 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
210 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
211 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
212 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
213 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
214 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
215 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
216 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
217 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
218 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
219 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
220 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
221 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
222 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
223 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
224 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
225 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
226 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
227 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
228 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
229 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
230 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
231 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
232 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
233 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
234 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
235 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
236 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
237 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
238 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
239 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
240 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
241 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
242 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
243 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
244 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
245 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
246 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
247 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
248 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
249 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
250 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
251 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
252 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
253 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
254 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
255 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
256 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
257 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
258 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
259 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
260 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
261 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
262 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
263 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
264 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
265 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
266 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
267 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
268 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
269 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
270 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
271 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
272 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
273 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
274
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
275 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
276
271
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
277 /* 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
278 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
279 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
280
262
cc2c568ef319 Missing affectation
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 259
diff changeset
281 *state = new;
259
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
282 return 0;
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
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
285 /* deinitialize */
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
286 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
287 {
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
288 TRACE_ENTRY("%p", state);
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
289 CHECK_PARAMS_DO( state, return );
639
95a784729cac Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 564
diff changeset
290 CHECK_FCT_DO( fd_sess_handler_destroy( &state->sess_hdl, NULL ), );
259
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
291 free(state);
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
292 return;
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
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
295 /* Incoming RADIUS request */
996
cf09fde3d7f5 Fix management of sessions in app_radgw: sessions are simply associated with messages, that is sufficient
Sebastien Decugis <sdecugis@freediameter.net>
parents: 974
diff changeset
296 static int acct_rad_req( struct rgwp_config * cs, 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
297 {
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
298 int idx;
271
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
299 int send_str=0;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
300 uint32_t str_cause=0;
277
c94e4ea39f97 Add missing mandatory AVP
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 275
diff changeset
301 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
302 application_id_t auth_appl=0;
259
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
303 int got_id = 0;
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
304 uint32_t status_type;
271
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
305 uint32_t termination_action = 0;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
306 uint32_t gigawords_in=0, gigawords_out=0;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
307 size_t nattr_used = 0;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
308 union avp_value value;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
309 struct avp ** avp_tun = NULL, *avp = NULL;
996
cf09fde3d7f5 Fix management of sessions in app_radgw: sessions are simply associated with messages, that is sufficient
Sebastien Decugis <sdecugis@freediameter.net>
parents: 974
diff changeset
310 struct session * sess;
259
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
311
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
312 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
313 size_t pref_len;
706
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 705
diff changeset
314 os0_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
315 size_t si_len = 0;
706
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 705
diff changeset
316 os0_t un = NULL;
358
7ea43915cade Fix: added the Destination-Realm also
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 356
diff changeset
317 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
318
996
cf09fde3d7f5 Fix management of sessions in app_radgw: sessions are simply associated with messages, that is sufficient
Sebastien Decugis <sdecugis@freediameter.net>
parents: 974
diff changeset
319 TRACE_ENTRY("%p %p %p %p %p", cs, rad_req, rad_ans, diam_fw, cli);
259
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
320 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
321
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
322 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
323
271
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
324 /*
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
325 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
326 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
327 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
328 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
329 */
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
330 /* 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
331 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
332 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
333 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
334 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
335
259
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
336 switch (attr->type) {
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
337 case RADIUS_ATTR_NAS_IP_ADDRESS:
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
338 case RADIUS_ATTR_NAS_IDENTIFIER:
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
339 case RADIUS_ATTR_NAS_IPV6_ADDRESS:
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
340 got_id = 1;
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
341 break;
271
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
342
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
343 case RADIUS_ATTR_TERMINATION_ACTION:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
344 CHECK_PARAMS( attr->length == 6 );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
345 termination_action = (v[0] << 24)
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
346 | (v[1] << 16)
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
347 | (v[2] << 8)
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
348 | v[3] ;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
349 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
350
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
351 case RADIUS_ATTR_ACCT_INPUT_GIGAWORDS:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
352 CHECK_PARAMS( attr->length == 6 );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
353 gigawords_in = (v[0] << 24)
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
354 | (v[1] << 16)
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
355 | (v[2] << 8)
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
356 | v[3] ;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
357 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
358
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
359 case RADIUS_ATTR_ACCT_OUTPUT_GIGAWORDS:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
360 CHECK_PARAMS( attr->length == 6 );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
361 gigawords_out = (v[0] << 24)
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
362 | (v[1] << 16)
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
363 | (v[2] << 8)
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
364 | v[3] ;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
365 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
366
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
367 case RADIUS_ATTR_CLASS:
358
7ea43915cade Fix: added the Destination-Realm also
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 356
diff changeset
368 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
369 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
370 si = v + pref_len;
358
7ea43915cade Fix: added the Destination-Realm also
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 356
diff changeset
371 si_len = attr_len - pref_len;
1027
0117a7746b21 Fix a number of errors and warnings introduced/highlighted by recent commits
Sebastien Decugis <sdecugis@freediameter.net>
parents: 996
diff changeset
372 TRACE_DEBUG(ANNOYING, "Found Class attribute with '%s' prefix (attr #%d), SI:'%.*s'.", prefix, idx, (int)si_len, si);
358
7ea43915cade Fix: added the Destination-Realm also
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 356
diff changeset
373 /* Remove from the message */
7ea43915cade Fix: added the Destination-Realm also
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 356
diff changeset
374 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
375 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
376 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
377 }
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
378 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
379
358
7ea43915cade Fix: added the Destination-Realm also
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 356
diff changeset
380 case RADIUS_ATTR_USER_NAME:
7ea43915cade Fix: added the Destination-Realm also
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 356
diff changeset
381 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
382 un = v;
358
7ea43915cade Fix: added the Destination-Realm also
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 356
diff changeset
383 un_len = attr_len;
1027
0117a7746b21 Fix a number of errors and warnings introduced/highlighted by recent commits
Sebastien Decugis <sdecugis@freediameter.net>
parents: 996
diff changeset
384 TRACE_DEBUG(ANNOYING, "Found a User-Name attribute: '%.*s'", (int)un_len, un);
358
7ea43915cade Fix: added the Destination-Realm also
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 356
diff changeset
385 }
7ea43915cade Fix: added the Destination-Realm also
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 356
diff changeset
386 break;
7ea43915cade Fix: added the Destination-Realm also
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 356
diff changeset
387
259
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
388 }
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
389 }
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 /* Check basic information is there */
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
392 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
393 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
394 return EINVAL;
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
395 }
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
396
271
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
397 /*
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
398 -- RFC2866:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
399 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
400 octet MD5 [5] checksum, called the Request Authenticator.
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
401
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
402 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
403 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
404 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
405 Code + Identifier + Length + 16 zero octets + request attributes +
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
406 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
407 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
408 Accounting-Request packet.
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 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
411 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
412 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
413 Accounting-Request.
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
414
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
415
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
416 -- RFC5080:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
417 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
418 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
419 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
420 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
421 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
422 Authenticator field. New RADIUS server implementations MUST
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
423 silently discard invalid packets.
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
424
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 {
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
427 uint8_t save[MD5_MAC_LEN];
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
428 uint8_t * secret;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
429 size_t secret_len;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
430
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
431 /* Get the shared secret */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
432 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
433
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
434 /* Copy the received Request Authenticator */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
435 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
436
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
437 /* Compute the same authenticator */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
438 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
439
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
440 /* And now compare with the received value */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
441 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
442 /* Invalid authenticator */
965
9b37f34c1b1f Some modifications to logging code:
Sebastien Decugis <sdecugis@freediameter.net>
parents: 740
diff changeset
443 TRACE_BUFFER(FD_LOG_DEBUG, FULL+1, "Received ReqAuth: ", &save[0], MD5_MAC_LEN, "" );
9b37f34c1b1f Some modifications to logging code:
Sebastien Decugis <sdecugis@freediameter.net>
parents: 740
diff changeset
444 TRACE_BUFFER(FD_LOG_DEBUG, FULL+1, "Expected ReqAuth: ", &rad_req->hdr->authenticator[0], MD5_MAC_LEN, "" );
271
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
445 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
446 return EINVAL;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
447 }
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
448 }
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
449
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
450
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
451 /* 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
452 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
453 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
454 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
455 return -2;
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
456 }
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
457
271
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
458 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
459 TRACE_DEBUG(FULL, "[acct.rgwx] Received Accounting-Off Acct-Status-Type attribute, we must terminate all active sessions.");
996
cf09fde3d7f5 Fix management of sessions in app_radgw: sessions are simply associated with messages, that is sufficient
Sebastien Decugis <sdecugis@freediameter.net>
parents: 974
diff changeset
460 TODO("RADIUS side is rebooting, send STR on all sessions???");
271
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
461 return ENOTSUP;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
462 }
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
463
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
464 /* Check if we got a valid session information, otherwise the server will not be able to handle the data... */
996
cf09fde3d7f5 Fix management of sessions in app_radgw: sessions are simply associated with messages, that is sufficient
Sebastien Decugis <sdecugis@freediameter.net>
parents: 974
diff changeset
465 if (!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
466 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
467 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
468 }
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
469
358
7ea43915cade Fix: added the Destination-Realm also
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 356
diff changeset
470 /* Add the Destination-Realm */
7ea43915cade Fix: added the Destination-Realm also
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 356
diff changeset
471 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
472 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
473 if (un && ! cs->ignore_nai) {
358
7ea43915cade Fix: added the Destination-Realm also
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 356
diff changeset
474 /* 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
475 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
476 if (un[idx] == '@') {
7ea43915cade Fix: added the Destination-Realm also
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 356
diff changeset
477 idx++;
7ea43915cade Fix: added the Destination-Realm also
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 356
diff changeset
478 break;
7ea43915cade Fix: added the Destination-Realm also
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 356
diff changeset
479 }
7ea43915cade Fix: added the Destination-Realm also
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 356
diff changeset
480 }
7ea43915cade Fix: added the Destination-Realm also
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 356
diff changeset
481 }
7ea43915cade Fix: added the Destination-Realm also
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 356
diff changeset
482 if (idx == 0) {
7ea43915cade Fix: added the Destination-Realm also
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 356
diff changeset
483 /* 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
484 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
485 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
486 } else {
7ea43915cade Fix: added the Destination-Realm also
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 356
diff changeset
487 value.os.data = un + idx;
7ea43915cade Fix: added the Destination-Realm also
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 356
diff changeset
488 value.os.len = un_len - idx;
7ea43915cade Fix: added the Destination-Realm also
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 356
diff changeset
489 }
7ea43915cade Fix: added the Destination-Realm also
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 356
diff changeset
490 CHECK_FCT( fd_msg_avp_setvalue ( avp, &value ) );
996
cf09fde3d7f5 Fix management of sessions in app_radgw: sessions are simply associated with messages, that is sufficient
Sebastien Decugis <sdecugis@freediameter.net>
parents: 974
diff changeset
491 CHECK_FCT( fd_msg_avp_add ( *diam_fw, MSG_BRW_FIRST_CHILD, avp) );
358
7ea43915cade Fix: added the Destination-Realm also
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 356
diff changeset
492
996
cf09fde3d7f5 Fix management of sessions in app_radgw: sessions are simply associated with messages, that is sufficient
Sebastien Decugis <sdecugis@freediameter.net>
parents: 974
diff changeset
493 /* Create the Session-Id AVP */
cf09fde3d7f5 Fix management of sessions in app_radgw: sessions are simply associated with messages, that is sufficient
Sebastien Decugis <sdecugis@freediameter.net>
parents: 974
diff changeset
494 {
cf09fde3d7f5 Fix management of sessions in app_radgw: sessions are simply associated with messages, that is sufficient
Sebastien Decugis <sdecugis@freediameter.net>
parents: 974
diff changeset
495 CHECK_FCT( fd_sess_fromsid_msg ( si, si_len, &sess, 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
496
1027
0117a7746b21 Fix a number of errors and warnings introduced/highlighted by recent commits
Sebastien Decugis <sdecugis@freediameter.net>
parents: 996
diff changeset
497 TRACE_DEBUG(FULL, "[acct.rgwx] Translating new accounting message for session '%.*s'...", (int)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
498
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 /* 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
500 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
501 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
502 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
503 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
504 CHECK_FCT( fd_msg_avp_add ( *diam_fw, MSG_BRW_FIRST_CHILD, avp) );
996
cf09fde3d7f5 Fix management of sessions in app_radgw: sessions are simply associated with messages, that is sufficient
Sebastien Decugis <sdecugis@freediameter.net>
parents: 974
diff changeset
505 CHECK_FCT( fd_msg_sess_set(*diam_fw, sess) );
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
506 }
358
7ea43915cade Fix: added the Destination-Realm also
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 356
diff changeset
507
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
508
271
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
509 /* Add the command code */
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 struct msg_hdr * header = NULL;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
512 CHECK_FCT( fd_msg_hdr ( *diam_fw, &header ) );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
513 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
514 header->msg_code = CC_AC;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
515 header->msg_appl = AI_ACCT;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
516
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
517 /* Add the Acct-Application-Id */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
518 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
519 value.i32 = header->msg_appl;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
520 CHECK_FCT( fd_msg_avp_setvalue ( avp, &value ) );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
521 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
522
c94e4ea39f97 Add missing mandatory AVP
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 275
diff changeset
523 /* save the end to end id */
c94e4ea39f97 Add missing mandatory AVP
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 275
diff changeset
524 e2eid = header->msg_eteid;
271
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
525 }
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 /* 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
528 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
529 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
530
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
531 switch (attr->type) {
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
532 /*
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
533 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
534 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
535 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
536 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
537 */
271
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
538 case RADIUS_ATTR_USER_PASSWORD:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
539 case RADIUS_ATTR_CHAP_PASSWORD:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
540 case RADIUS_ATTR_REPLY_MESSAGE:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
541 case RADIUS_ATTR_STATE:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
542 case RADIUS_ATTR_MESSAGE_AUTHENTICATOR:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
543 case RADIUS_ATTR_EAP_MESSAGE:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
544 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
545 return EINVAL;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
546
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
547
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
548 /* 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
549 #define CONV2DIAM_STR( _dictobj_ ) \
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
550 CHECK_PARAMS( attr->length >= 2 ); \
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
551 /* Create the AVP with the specified dictionary model */ \
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
552 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
553 value.os.len = attr->length - 2; \
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
554 value.os.data = (unsigned char *)(attr + 1); \
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
555 CHECK_FCT( fd_msg_avp_setvalue ( avp, &value ) ); \
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
556 /* Add the AVP in the Diameter message. */ \
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
557 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
558
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
559 /* Same thing, for scalar AVPs of 32 bits */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
560 #define CONV2DIAM_32B( _dictobj_ ) \
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
561 CHECK_PARAMS( attr->length == 6 ); \
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
562 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
563 { \
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
564 uint8_t * v = (uint8_t *)(attr + 1); \
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
565 value.u32 = (v[0] << 24) \
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
566 | (v[1] << 16) \
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
567 | (v[2] << 8) \
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
568 | v[3] ; \
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
569 } \
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
570 CHECK_FCT( fd_msg_avp_setvalue ( avp, &value ) ); \
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
571 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
572
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
573 /* And the 64b version */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
574 #define CONV2DIAM_64B( _dictobj_ ) \
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
575 CHECK_PARAMS( attr->length == 10); \
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
576 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
577 { \
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
578 uint8_t * v = (uint8_t *)(attr + 1); \
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
579 value.u64 = ((uint64_t)(v[0]) << 56) \
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
580 | ((uint64_t)(v[1]) << 48) \
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
581 | ((uint64_t)(v[2]) << 40) \
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
582 | ((uint64_t)(v[3]) << 32) \
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
583 | ((uint64_t)(v[4]) << 24) \
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
584 | ((uint64_t)(v[5]) << 16) \
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
585 | ((uint64_t)(v[6]) << 8) \
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
586 | (uint64_t)(v[7]) ; \
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
587 } \
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
588 CHECK_FCT( fd_msg_avp_setvalue ( avp, &value ) ); \
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
589 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
590
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
591
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
592 /* 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
593 case RADIUS_ATTR_USER_NAME:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
594 CONV2DIAM_STR( User_Name );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
595 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
596
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
597 case RADIUS_ATTR_NAS_IP_ADDRESS:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
598 CONV2DIAM_STR( NAS_IP_Address );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
599 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
600
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
601 case RADIUS_ATTR_NAS_PORT:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
602 CONV2DIAM_32B( NAS_Port );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
603 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
604
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
605 case RADIUS_ATTR_SERVICE_TYPE:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
606 CONV2DIAM_32B( Service_Type );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
607 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
608
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
609 case RADIUS_ATTR_FRAMED_PROTOCOL:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
610 CONV2DIAM_32B( Framed_Protocol );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
611 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
612
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
613 case RADIUS_ATTR_FRAMED_IP_ADDRESS:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
614 CONV2DIAM_STR( Framed_IP_Address );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
615 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
616
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
617 case RADIUS_ATTR_FRAMED_IP_NETMASK:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
618 CONV2DIAM_STR( Framed_IP_Netmask );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
619 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
620
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
621 case RADIUS_ATTR_FRAMED_ROUTING:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
622 CONV2DIAM_32B( Framed_Routing );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
623 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
624
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
625 case RADIUS_ATTR_FILTER_ID:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
626 CONV2DIAM_STR( Filter_Id );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
627 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
628
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
629 case RADIUS_ATTR_FRAMED_MTU:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
630 CONV2DIAM_32B( Framed_MTU );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
631 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
632
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
633 case RADIUS_ATTR_FRAMED_COMPRESSION:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
634 CONV2DIAM_32B( Framed_Compression );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
635 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
636
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
637 case RADIUS_ATTR_LOGIN_IP_HOST:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
638 CONV2DIAM_STR( Login_IP_Host );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
639 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
640
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
641 case RADIUS_ATTR_LOGIN_SERVICE:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
642 CONV2DIAM_32B( Login_Service );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
643 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
644
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
645 case RADIUS_ATTR_LOGIN_TCP_PORT:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
646 CONV2DIAM_32B( Login_TCP_Port );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
647 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
648
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
649 case RADIUS_ATTR_CALLBACK_NUMBER:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
650 CONV2DIAM_STR( Callback_Number );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
651 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
652
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
653 case RADIUS_ATTR_CALLBACK_ID:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
654 CONV2DIAM_STR( Callback_Id );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
655 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
656
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
657 case RADIUS_ATTR_FRAMED_ROUTE:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
658 CONV2DIAM_STR( Framed_Route );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
659 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
660
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
661 case RADIUS_ATTR_FRAMED_IPX_NETWORK:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
662 CONV2DIAM_32B( Framed_IPX_Network );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
663 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
664
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
665 case RADIUS_ATTR_CLASS:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
666 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
667 /* 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
668 {
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 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
670 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
671 attr_val = (char *)(attr + 1);
706
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 705
diff changeset
672 auth_val = attr_val + CONSTSTRLEN(CLASS_AAI_PREFIX);
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 705
diff changeset
673 if ( (attr->length > sizeof(struct radius_attr_hdr) + CONSTSTRLEN(CLASS_AAI_PREFIX) )
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 705
diff changeset
674 && (attr->length < sizeof(struct radius_attr_hdr) + CONSTSTRLEN(CLASS_AAI_PREFIX) + sizeof(buf))
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 705
diff changeset
675 && ! strncmp(attr_val, CLASS_AAI_PREFIX, CONSTSTRLEN(CLASS_AAI_PREFIX))) {
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
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 memset(buf, 0, sizeof(buf));
706
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 705
diff changeset
678 memcpy(buf, auth_val, attr->length - sizeof(struct radius_attr_hdr) - CONSTSTRLEN(CLASS_AAI_PREFIX));
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
679 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
680 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
681 }
bce8e5b7bf78 Added code to send an STR after a STOP accounting record in RADIUS
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 271
diff changeset
682 }
bce8e5b7bf78 Added code to send an STR after a STOP accounting record in RADIUS
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 271
diff changeset
683 }
271
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
684 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
685
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
686 case RADIUS_ATTR_VENDOR_SPECIFIC:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
687 if (attr->length >= 6) {
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
688 uint32_t vendor_id;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
689 uint8_t * c = (uint8_t *)(attr + 1);
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
690
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
691 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
692 c += 4;
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 switch (vendor_id) {
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
695
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
696 /* 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
697 case RADIUS_VENDOR_ID_MICROSOFT : /* RFC 2548 */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
698 /* other vendors ? */
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 size_t left;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
701 struct radius_attr_vendor *vtlv;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
702
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
703 left = attr->length - 6;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
704 vtlv = (struct radius_attr_vendor *)c;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
705
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
706 while ((left >= 2) && (vtlv->vendor_length <= left)) {
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
707 /* Search our dictionary for corresponding Vendor's AVP */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
708 struct dict_avp_request req;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
709 struct dict_object * avp_model = NULL;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
710 memset(&req, 0, sizeof(struct dict_avp_request));
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
711 req.avp_vendor = vendor_id;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
712 req.avp_code = vtlv->vendor_type;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
713
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
714 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
715 if (!avp_model) {
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
716 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
717 } else {
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
718 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
719 value.os.len = vtlv->vendor_length - 2;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
720 value.os.data = (unsigned char *)(vtlv + 1);
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
721 CHECK_FCT( fd_msg_avp_setvalue ( avp, &value ) );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
722 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
723 }
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
724 c += vtlv->vendor_length;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
725 left -= vtlv->vendor_length;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
726 vtlv = (struct radius_attr_vendor *)c;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
727 }
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
728 }
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 /* 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
732 /* case RADIUS_VENDOR_ID_CISCO :
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
733 break; */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
734 /* case RADIUS_VENDOR_ID_IETF : (extended RADIUS attributes)
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
735 break; */
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 /* 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
738 default:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
739 /* do nothing */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
740 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
741
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
742 }
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
743 }
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
744 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
745
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
746 case RADIUS_ATTR_SESSION_TIMEOUT:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
747 /* 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
748 if (termination_action != RADIUS_TERMINATION_ACTION_RADIUS_REQUEST) {
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
749 CONV2DIAM_32B( Session_Timeout );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
750 } else {
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
751 CONV2DIAM_32B( Authorization_Lifetime );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
752 /* And add this additional AVP */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
753 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
754 value.u32 = ACV_ART_AUTHORIZE_AUTHENTICATE;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
755 CHECK_FCT( fd_msg_avp_setvalue ( avp, &value ) );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
756 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
757 }
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
758 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
759
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
760 case RADIUS_ATTR_IDLE_TIMEOUT:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
761 CONV2DIAM_32B( Idle_Timeout );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
762 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
763
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
764 case RADIUS_ATTR_TERMINATION_ACTION:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
765 /* Just remove */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
766 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
767
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
768 case RADIUS_ATTR_CALLED_STATION_ID:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
769 CONV2DIAM_STR( Called_Station_Id );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
770 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
771
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
772 case RADIUS_ATTR_CALLING_STATION_ID:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
773 CONV2DIAM_STR( Calling_Station_Id );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
774 break;
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_NAS_IDENTIFIER:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
777 CONV2DIAM_STR( NAS_Identifier );
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 /* 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
781
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
782 case RADIUS_ATTR_LOGIN_LAT_SERVICE:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
783 CONV2DIAM_STR( Login_LAT_Service );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
784 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
785
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
786 case RADIUS_ATTR_LOGIN_LAT_NODE:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
787 CONV2DIAM_STR( Login_LAT_Node );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
788 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
789
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
790 case RADIUS_ATTR_LOGIN_LAT_GROUP:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
791 CONV2DIAM_STR( Login_LAT_Group );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
792 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
793
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
794 case RADIUS_ATTR_FRAMED_APPLETALK_LINK:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
795 CONV2DIAM_32B( Framed_AppleTalk_Link );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
796 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
797
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
798 case RADIUS_ATTR_FRAMED_APPLETALK_NETWORK:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
799 CONV2DIAM_32B( Framed_AppleTalk_Network );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
800 break;
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 case RADIUS_ATTR_FRAMED_APPLETALK_ZONE:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
803 CONV2DIAM_STR( Framed_AppleTalk_Zone );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
804 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
805
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
806 case RADIUS_ATTR_ACCT_STATUS_TYPE:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
807 /*
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
808 - 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
809 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
810 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
811 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
812 Session-Termination-Request message once the Diameter
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
813 Accounting-Answer message has been received.
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
814 */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
815 switch (status_type) {
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
816 case RADIUS_ACCT_STATUS_TYPE_START:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
817 value.u32 = ACV_ART_START_RECORD;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
818 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
819 case RADIUS_ACCT_STATUS_TYPE_STOP:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
820 value.u32 = ACV_ART_STOP_RECORD;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
821 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
822 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
823 case RADIUS_ACCT_STATUS_TYPE_INTERIM_UPDATE:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
824 value.u32 = ACV_ART_INTERIM_RECORD;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
825 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
826 default:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
827 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
828 return ENOTSUP;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
829 }
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
830 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
831 CHECK_FCT( fd_msg_avp_setvalue ( avp, &value ) );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
832 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
833
c94e4ea39f97 Add missing mandatory AVP
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 275
diff changeset
834 /* 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
835 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
836 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
837 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
838 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
839 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
840 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
841 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
842 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
843 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
844
825a2992e3b9 Improved duplicate detection in RADIUS/Diameter gw. It will be changed again soon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 526
diff changeset
845 -- 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
846 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
847 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
848 . */
277
c94e4ea39f97 Add missing mandatory AVP
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 275
diff changeset
849 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
850 value.u32 = e2eid;
c94e4ea39f97 Add missing mandatory AVP
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 275
diff changeset
851 CHECK_FCT( fd_msg_avp_setvalue ( avp, &value ) );
c94e4ea39f97 Add missing mandatory AVP
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 275
diff changeset
852 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
853
271
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
854 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
855
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
856 case RADIUS_ATTR_ACCT_DELAY_TIME:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
857 CONV2DIAM_32B( Acct_Delay_Time );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
858 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
859
259
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
860 /*
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
861 - 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
862 Accounting-Input-Packets, Accounting-Output-Octets, or
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
863 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
864 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
865 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
866 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
867 AVPs.
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
868 */
271
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
869 case RADIUS_ATTR_ACCT_INPUT_OCTETS:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
870 memset(&value, 0, sizeof(value));
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 uint8_t * v = (uint8_t *)(attr + 1);
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
873 value.u64 = (v[0] << 24)
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
874 | (v[1] << 16)
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
875 | (v[2] << 8)
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
876 | v[3] ;
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 value.u64 += ((uint64_t)gigawords_in << 32);
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
879 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
880 CHECK_FCT( fd_msg_avp_setvalue ( avp, &value ) );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
881 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
882 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
883
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
884 case RADIUS_ATTR_ACCT_OUTPUT_OCTETS:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
885 memset(&value, 0, sizeof(value));
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 uint8_t * v = (uint8_t *)(attr + 1);
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
888 value.u64 = (v[0] << 24)
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
889 | (v[1] << 16)
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
890 | (v[2] << 8)
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
891 | v[3] ;
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 value.u64 += ((uint64_t)gigawords_out << 32);
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
894 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
895 CHECK_FCT( fd_msg_avp_setvalue ( avp, &value ) );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
896 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
897 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
898
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
899 case RADIUS_ATTR_ACCT_SESSION_ID:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
900 CONV2DIAM_STR( Acct_Session_Id );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
901 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
902
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
903 case RADIUS_ATTR_ACCT_AUTHENTIC:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
904 CONV2DIAM_32B( Acct_Authentic );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
905 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
906
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
907 case RADIUS_ATTR_ACCT_SESSION_TIME:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
908 CONV2DIAM_32B( Acct_Session_Time );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
909 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
910
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
911 case RADIUS_ATTR_ACCT_INPUT_PACKETS:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
912 memset(&value, 0, sizeof(value));
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 uint8_t * v = (uint8_t *)(attr + 1);
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
915 value.u64 = (v[0] << 24)
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
916 | (v[1] << 16)
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
917 | (v[2] << 8)
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
918 | v[3] ;
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 /* value.u64 += (gigawords_in << 32); */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
921 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
922 CHECK_FCT( fd_msg_avp_setvalue ( avp, &value ) );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
923 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
924 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
925
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
926 case RADIUS_ATTR_ACCT_OUTPUT_PACKETS:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
927 memset(&value, 0, sizeof(value));
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 uint8_t * v = (uint8_t *)(attr + 1);
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
930 value.u64 = (v[0] << 24)
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
931 | (v[1] << 16)
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
932 | (v[2] << 8)
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
933 | v[3] ;
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 /* value.u64 += (gigawords_out << 32); */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
936 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
937 CHECK_FCT( fd_msg_avp_setvalue ( avp, &value ) );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
938 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
939 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
940
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
941 /*
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
942 - 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
943 attribute, it should be translated to the equivalent
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
944 Termination-Cause AVP value.
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
945 */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
946 case RADIUS_ATTR_ACCT_TERMINATE_CAUSE:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
947 /* rfc4005#section-9.3.5 */
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 uint8_t * v = (uint8_t *)(attr + 1);
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
950 str_cause = (v[0] << 24)
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
951 | (v[1] << 16)
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
952 | (v[2] << 8)
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
953 | v[3] ;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
954 }
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
955 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
956 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
957
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
958 case RADIUS_ATTR_ACCT_MULTI_SESSION_ID:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
959 CONV2DIAM_STR( Acct_Multi_Session_Id );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
960 break;
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_ACCT_LINK_COUNT:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
963 CONV2DIAM_32B( Acct_Link_Count );
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 /* CHAP-Challenge is not present in Accounting-Request */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
967
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
968 case RADIUS_ATTR_NAS_PORT_TYPE:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
969 CONV2DIAM_32B( NAS_Port_Type );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
970 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
971
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
972 case RADIUS_ATTR_PORT_LIMIT:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
973 CONV2DIAM_32B( Port_Limit );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
974 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
975
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
976 case RADIUS_ATTR_LOGIN_LAT_PORT:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
977 CONV2DIAM_STR( Login_LAT_Port );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
978 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
979
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
980 /* RFC 3162 */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
981 case RADIUS_ATTR_NAS_IPV6_ADDRESS:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
982 CONV2DIAM_STR( NAS_IPv6_Address );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
983 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
984
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
985 case RADIUS_ATTR_FRAMED_INTERFACE_ID:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
986 CONV2DIAM_64B( Framed_Interface_Id );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
987 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
988
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
989 case RADIUS_ATTR_FRAMED_IPV6_PREFIX:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
990 CONV2DIAM_STR( Framed_IPv6_Prefix );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
991 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
992
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
993 case RADIUS_ATTR_LOGIN_IPV6_HOST:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
994 CONV2DIAM_STR( Login_IPv6_Host );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
995 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
996
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
997 case RADIUS_ATTR_FRAMED_IPV6_ROUTE:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
998 CONV2DIAM_STR( Framed_IPv6_Route );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
999 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1000
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1001 case RADIUS_ATTR_FRAMED_IPV6_POOL:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1002 CONV2DIAM_STR( Framed_IPv6_Pool );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1003 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1004
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1005 /* RFC 2868 */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1006 /* 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
1007 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
1008 #define AVP_TUN_PREPARE() { \
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1009 if (avp_tun == NULL) { \
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1010 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
1011 } \
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1012 tag = *(uint8_t *)(attr + 1); \
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1013 if (tag > 0x1F) tag = 0; \
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1014 if (avp_tun[tag] == NULL) { \
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1015 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
1016 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
1017 } \
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1018 }
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1019
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1020 /* 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
1021 #define CONV2DIAM_TUN_STR( _dictobj_ ) { \
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1022 uint8_t tag; \
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1023 CHECK_PARAMS( attr->length >= 3); \
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1024 AVP_TUN_PREPARE(); \
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1025 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
1026 value.os.len = attr->length - (tag ? 3 : 2); \
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1027 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
1028 CHECK_FCT( fd_msg_avp_setvalue ( avp, &value ) ); \
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1029 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
1030 }
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1031
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1032 /* 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
1033 #define CONV2DIAM_TUN_24B( _dictobj_ ) { \
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1034 uint8_t tag; \
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1035 CHECK_PARAMS( attr->length == 6); \
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1036 AVP_TUN_PREPARE(); \
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1037 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
1038 { \
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1039 uint8_t * v = (uint8_t *)(attr + 1); \
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1040 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
1041 } \
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1042 CHECK_FCT( fd_msg_avp_setvalue ( avp, &value ) ); \
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1043 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
1044 }
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1045
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1046 /*
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1047 - If the RADIUS message contains Tunnel information [RADTunnels],
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1048 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
1049 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
1050 contains a Tunnel-Password attribute, the RADIUS encryption
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1051 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
1052 security methods.
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1053 -> 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
1054 */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1055 case RADIUS_ATTR_TUNNEL_TYPE:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1056 CONV2DIAM_TUN_24B( Tunnel_Type );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1057 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1058
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1059 case RADIUS_ATTR_TUNNEL_MEDIUM_TYPE:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1060 CONV2DIAM_TUN_24B( Tunnel_Medium_Type );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1061 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1062
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1063 case RADIUS_ATTR_TUNNEL_CLIENT_ENDPOINT:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1064 CONV2DIAM_TUN_STR( Tunnel_Client_Endpoint );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1065 break;
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_SERVER_ENDPOINT:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1068 CONV2DIAM_TUN_STR( Tunnel_Server_Endpoint );
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 /* Tunnel-Password never present in an Accounting-Request */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1072
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1073 case RADIUS_ATTR_TUNNEL_PRIVATE_GROUP_ID:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1074 CONV2DIAM_TUN_STR( Tunnel_Private_Group_Id );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1075 break;
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_ASSIGNMENT_ID:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1078 CONV2DIAM_TUN_STR( Tunnel_Assignment_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 /* Tunnel-Reference never present in an Accounting-Request */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1082
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1083 case RADIUS_ATTR_TUNNEL_CLIENT_AUTH_ID:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1084 CONV2DIAM_TUN_STR( Tunnel_Client_Auth_Id );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1085 break;
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 case RADIUS_ATTR_TUNNEL_SERVER_AUTH_ID:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1088 CONV2DIAM_TUN_STR( Tunnel_Server_Auth_Id );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1089 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1090
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1091 /* RFC 2869 */
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 Acct-Input-Gigawords, Acct-Output-
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1094 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
1095 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
1096 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
1097 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
1098 */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1099 case RADIUS_ATTR_ACCT_INPUT_GIGAWORDS:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1100 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
1101
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1102 case RADIUS_ATTR_ACCT_OUTPUT_GIGAWORDS:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1103 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
1104
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1105 case RADIUS_ATTR_EVENT_TIMESTAMP:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1106 /* RADIUS:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1107 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
1108 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
1109 Diameter:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1110 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
1111 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
1112 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
1113 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
1114
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1115 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
1116 with respect to the Coordinated Universal Time (UTC).
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1117
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1118 -- RFC4330:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1119 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
1120 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
1121 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
1122 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
1123 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
1124 */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1125 {
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1126 uint32_t ts;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1127
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1128 uint8_t * v = (uint8_t *)(attr + 1);
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1129 /* Read the RADIUS attribute value */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1130 ts = (v[0] << 24)
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1131 | (v[1] << 16)
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1132 | (v[2] << 8)
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1133 | v[3] ;
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 /* Add the 70 missing years */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1136 ts += 2208988800U; /* 60 * 60 * 24 * ( 365 * 70 + 17 ) */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1137
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1138 /* Convert to network byte order */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1139 ts = htonl(ts);
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1140
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1141 /* Diameter Time datatype is derived from OctetString */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1142 value.os.data = (void *) &ts;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1143 value.os.len = sizeof(uint32_t);
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 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
1146 CHECK_FCT( fd_msg_avp_setvalue ( avp, &value ) );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1147 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
1148 }
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1149 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1150
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1151 case RADIUS_ATTR_NAS_PORT_ID:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1152 CONV2DIAM_STR( NAS_Port_Id );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1153 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1154
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1155 case RADIUS_ATTR_CONNECT_INFO:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1156 CONV2DIAM_STR( Connect_Info );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1157 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1158
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1159 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
1160 CONV2DIAM_STR( Framed_Pool );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1161 break;
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
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1164 /* RFC 3579 */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1165 /*
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1166 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
1167 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
1168 */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1169 case RADIUS_ATTR_ORIGINATING_LINE_INFO:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1170 CONV2DIAM_STR( Originating_Line_Info );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1171 break;
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 /* Default */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1174 default: /* unknown attribute */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1175 /* 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
1176 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
1177 }
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
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1180 /* 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
1181 rad_req->attr_used = nattr_used;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1182
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1183 /* Store useful information in the session */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1184 {
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1185 struct sess_state * st;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1186
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1187 CHECK_MALLOC( st = malloc(sizeof(struct sess_state)) );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1188 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
1189 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
1190 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
1191 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
1192 }
271
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1193 st->term_cause = str_cause;
996
cf09fde3d7f5 Fix management of sessions in app_radgw: sessions are simply associated with messages, that is sufficient
Sebastien Decugis <sdecugis@freediameter.net>
parents: 974
diff changeset
1194 CHECK_FCT( fd_sess_state_store( cs->sess_hdl, sess, &st ) );
271
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1195 }
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1196
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1197 return 0;
259
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1198 }
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1199
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
1200 /* 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
1201 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
1202 {
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 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
1204 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
1205 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
1206
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_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
1208
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 /* 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
1210 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
1211 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
1212 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
1213 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
1214 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
1215
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 /* 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
1217 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
1218 *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
1219
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 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
1221 if (answer && *answer) {
688
8c3dc8584dab Prepared capability for messages logging to separate files / folders
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 639
diff changeset
1222 TRACE_DEBUG(INFO, "Received the following problematic STA message, discarding anyway...");
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
1223 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
1224 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
1225 *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
1226 }
bce8e5b7bf78 Added code to send an STR after a STOP accounting record in RADIUS
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 271
diff changeset
1227 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
1228 }
bce8e5b7bf78 Added code to send an STR after a STOP accounting record in RADIUS
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 271
diff changeset
1229
996
cf09fde3d7f5 Fix management of sessions in app_radgw: sessions are simply associated with messages, that is sufficient
Sebastien Decugis <sdecugis@freediameter.net>
parents: 974
diff changeset
1230 static int acct_diam_ans( struct rgwp_config * cs, struct msg ** diam_ans, struct radius_msg ** rad_fw, struct rgw_client * cli )
259
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1231 {
996
cf09fde3d7f5 Fix management of sessions in app_radgw: sessions are simply associated with messages, that is sufficient
Sebastien Decugis <sdecugis@freediameter.net>
parents: 974
diff changeset
1232 struct session * sess;
564
603f70bf1453 Cleanly destroy Diameter message when an Accounting Response is not generated in gateway
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 541
diff changeset
1233 struct sess_state * st = NULL, stloc;
271
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1234 struct avp *avp, *next;
996
cf09fde3d7f5 Fix management of sessions in app_radgw: sessions are simply associated with messages, that is sufficient
Sebastien Decugis <sdecugis@freediameter.net>
parents: 974
diff changeset
1235 struct avp_hdr *ahdr, *oh, *or;
cf09fde3d7f5 Fix management of sessions in app_radgw: sessions are simply associated with messages, that is sufficient
Sebastien Decugis <sdecugis@freediameter.net>
parents: 974
diff changeset
1236 os0_t sid = NULL;
cf09fde3d7f5 Fix management of sessions in app_radgw: sessions are simply associated with messages, that is sufficient
Sebastien Decugis <sdecugis@freediameter.net>
parents: 974
diff changeset
1237 size_t sidlen;
271
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1238
996
cf09fde3d7f5 Fix management of sessions in app_radgw: sessions are simply associated with messages, that is sufficient
Sebastien Decugis <sdecugis@freediameter.net>
parents: 974
diff changeset
1239 TRACE_ENTRY("%p %p %p %p", cs, diam_ans, rad_fw, cli);
259
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1240 CHECK_PARAMS(cs);
271
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1241
996
cf09fde3d7f5 Fix management of sessions in app_radgw: sessions are simply associated with messages, that is sufficient
Sebastien Decugis <sdecugis@freediameter.net>
parents: 974
diff changeset
1242 CHECK_FCT( fd_msg_sess_get(fd_g_config->cnf_dict, *diam_ans, &sess, NULL) );
cf09fde3d7f5 Fix management of sessions in app_radgw: sessions are simply associated with messages, that is sufficient
Sebastien Decugis <sdecugis@freediameter.net>
parents: 974
diff changeset
1243 if (sess) {
cf09fde3d7f5 Fix management of sessions in app_radgw: sessions are simply associated with messages, that is sufficient
Sebastien Decugis <sdecugis@freediameter.net>
parents: 974
diff changeset
1244 CHECK_FCT( fd_sess_state_retrieve( cs->sess_hdl, sess, &st ) );
cf09fde3d7f5 Fix management of sessions in app_radgw: sessions are simply associated with messages, that is sufficient
Sebastien Decugis <sdecugis@freediameter.net>
parents: 974
diff changeset
1245 CHECK_FCT( fd_sess_getsid(sess, &sid, &sidlen) );
271
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
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1248 if (!st) {
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1249 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
1250 return EINVAL;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1251 }
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1252
564
603f70bf1453 Cleanly destroy Diameter message when an Accounting Response is not generated in gateway
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 541
diff changeset
1253 /* Free the state */
603f70bf1453 Cleanly destroy Diameter message when an Accounting Response is not generated in gateway
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 541
diff changeset
1254 memcpy(&stloc, st, sizeof(struct sess_state));
603f70bf1453 Cleanly destroy Diameter message when an Accounting Response is not generated in gateway
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 541
diff changeset
1255 free(st);
603f70bf1453 Cleanly destroy Diameter message when an Accounting Response is not generated in gateway
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 541
diff changeset
1256 st = &stloc;
603f70bf1453 Cleanly destroy Diameter message when an Accounting Response is not generated in gateway
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 541
diff changeset
1257
271
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1258 /* Search these AVPs first */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1259 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
1260 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
1261
271
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1262 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
1263 CHECK_FCT( fd_msg_avp_hdr ( avp, &or ) );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1264
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1265 /* Check the Diameter error code */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1266 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
1267 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
1268 CHECK_FCT( fd_msg_avp_hdr ( avp, &ahdr ) );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1269 switch (ahdr->avp_value->u32) {
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1270 case ER_DIAMETER_SUCCESS:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1271 case ER_DIAMETER_LIMITED_SUCCESS:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1272 (*rad_fw)->hdr->code = RADIUS_CODE_ACCOUNTING_RESPONSE;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1273 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1274
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1275 default:
974
2091bf698fb1 Remove newlines from fd_log_debug, TRACE_DEBUG, TRACE_ERROR, and TRACE_DEBUG_ERROR
Thomas Klausner <tk@giga.or.at>
parents: 965
diff changeset
1276 fd_log_debug("[acct.rgwx] Received Diameter answer with error code '%d' from server '%.*s', session %.*s, not translating into Accounting-Response",
271
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1277 ahdr->avp_value->u32,
1027
0117a7746b21 Fix a number of errors and warnings introduced/highlighted by recent commits
Sebastien Decugis <sdecugis@freediameter.net>
parents: 996
diff changeset
1278 (int)oh->avp_value->os.len, oh->avp_value->os.data,
0117a7746b21 Fix a number of errors and warnings introduced/highlighted by recent commits
Sebastien Decugis <sdecugis@freediameter.net>
parents: 996
diff changeset
1279 (int)sidlen, sid);
271
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.Error_Message, &avp) );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1281 if (avp) {
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1282 CHECK_FCT( fd_msg_avp_hdr ( avp, &ahdr ) );
974
2091bf698fb1 Remove newlines from fd_log_debug, TRACE_DEBUG, TRACE_ERROR, and TRACE_DEBUG_ERROR
Thomas Klausner <tk@giga.or.at>
parents: 965
diff changeset
1283 fd_log_debug("[acct.rgwx] Error-Message content: '%.*s'",
1027
0117a7746b21 Fix a number of errors and warnings introduced/highlighted by recent commits
Sebastien Decugis <sdecugis@freediameter.net>
parents: 996
diff changeset
1284 (int)ahdr->avp_value->os.len, ahdr->avp_value->os.data);
271
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1285 }
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1286 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
1287 if (avp) {
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1288 CHECK_FCT( fd_msg_avp_hdr ( avp, &ahdr ) );
974
2091bf698fb1 Remove newlines from fd_log_debug, TRACE_DEBUG, TRACE_ERROR, and TRACE_DEBUG_ERROR
Thomas Klausner <tk@giga.or.at>
parents: 965
diff changeset
1289 fd_log_debug("[acct.rgwx] Error-Reporting-Host: '%.*s'",
1027
0117a7746b21 Fix a number of errors and warnings introduced/highlighted by recent commits
Sebastien Decugis <sdecugis@freediameter.net>
parents: 996
diff changeset
1290 (int)ahdr->avp_value->os.len, ahdr->avp_value->os.data);
271
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1291 }
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1292 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
1293 if (avp) {
974
2091bf698fb1 Remove newlines from fd_log_debug, TRACE_DEBUG, TRACE_ERROR, and TRACE_DEBUG_ERROR
Thomas Klausner <tk@giga.or.at>
parents: 965
diff changeset
1294 fd_log_debug("[acct.rgwx] Failed-AVP was included in the message.");
271
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1295 /* Dump its content ? */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1296 }
564
603f70bf1453 Cleanly destroy Diameter message when an Accounting Response is not generated in gateway
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 541
diff changeset
1297
603f70bf1453 Cleanly destroy Diameter message when an Accounting Response is not generated in gateway
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 541
diff changeset
1298 /* Now, destroy the Diameter message, since we know it is not converted to RADIUS */
603f70bf1453 Cleanly destroy Diameter message when an Accounting Response is not generated in gateway
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 541
diff changeset
1299 CHECK_FCT( fd_msg_free(*diam_ans) );
603f70bf1453 Cleanly destroy Diameter message when an Accounting Response is not generated in gateway
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 541
diff changeset
1300 *diam_ans = NULL;
603f70bf1453 Cleanly destroy Diameter message when an Accounting Response is not generated in gateway
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 541
diff changeset
1301
271
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1302 return -1;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1303 }
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1304 /* Remove this Result-Code avp */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1305 CHECK_FCT( fd_msg_free( avp ) );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1306
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1307 /* 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
1308 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
1309 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
1310 struct msg_hdr * hdr = NULL;
706
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 705
diff changeset
1311 DiamId_t fqdn;
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 705
diff changeset
1312 size_t fqdn_len;
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 705
diff changeset
1313 DiamId_t realm;
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 705
diff changeset
1314 size_t realm_len;
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
1315 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
1316
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 /* 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
1318 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
1319
996
cf09fde3d7f5 Fix management of sessions in app_radgw: sessions are simply associated with messages, that is sufficient
Sebastien Decugis <sdecugis@freediameter.net>
parents: 974
diff changeset
1320 /* Set the application-id to the auth application if available, accounting otherwise (not sure what is actually expected...) */
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
1321 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
1322 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
1323
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
1324 /* 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
1325 CHECK_FCT( fd_msg_avp_new ( cs->dict.Session_Id, 0, &avp ) );
996
cf09fde3d7f5 Fix management of sessions in app_radgw: sessions are simply associated with messages, that is sufficient
Sebastien Decugis <sdecugis@freediameter.net>
parents: 974
diff changeset
1326 avp_val.os.data = sid;
cf09fde3d7f5 Fix management of sessions in app_radgw: sessions are simply associated with messages, that is sufficient
Sebastien Decugis <sdecugis@freediameter.net>
parents: 974
diff changeset
1327 avp_val.os.len = sidlen;
cf09fde3d7f5 Fix management of sessions in app_radgw: sessions are simply associated with messages, that is sufficient
Sebastien Decugis <sdecugis@freediameter.net>
parents: 974
diff changeset
1328 CHECK_FCT( fd_msg_avp_setvalue ( avp, &avp_val ) );
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
1329 CHECK_FCT( fd_msg_avp_add ( str, MSG_BRW_FIRST_CHILD, avp) );
996
cf09fde3d7f5 Fix management of sessions in app_radgw: sessions are simply associated with messages, that is sufficient
Sebastien Decugis <sdecugis@freediameter.net>
parents: 974
diff changeset
1330 CHECK_FCT( fd_sess_ref_msg(sess) );
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
1331
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 /* 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
1333 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
1334 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
1335 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
1336
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 /* Get information on the NAS */
706
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 705
diff changeset
1338 CHECK_FCT( rgw_clients_get_origin(cli, &fqdn, &fqdn_len, &realm, &realm_len) );
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
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 /* 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
1341 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
1342 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
1343 avp_val.os.data = (unsigned char *)fqdn;
706
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 705
diff changeset
1344 avp_val.os.len = fqdn_len;
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
1345 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
1346 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
1347
bce8e5b7bf78 Added code to send an STR after a STOP accounting record in RADIUS
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 271
diff changeset
1348 /* 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
1349 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
1350 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
1351 avp_val.os.data = (unsigned char *)realm;
706
4ffbc9f1e922 Large UNTESTED commit with the following changes:
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 705
diff changeset
1352 avp_val.os.len = realm_len;
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
1353 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
1354 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
1355
bce8e5b7bf78 Added code to send an STR after a STOP accounting record in RADIUS
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 271
diff changeset
1356 /* 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
1357 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
1358 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
1359 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
1360 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
1361
bce8e5b7bf78 Added code to send an STR after a STOP accounting record in RADIUS
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 271
diff changeset
1362 /* 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
1363 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
1364 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
1365 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
1366 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
1367
bce8e5b7bf78 Added code to send an STR after a STOP accounting record in RADIUS
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 271
diff changeset
1368 /* 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
1369 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
1370 }
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1371
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1372 /*
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1373 No attributes should be found in
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1374 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
1375 Specific.
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1376 */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1377
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1378 /* 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
1379 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
1380
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1381 while (next) {
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1382 int handled = 1;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1383 avp = next;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1384 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
1385
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1386 CHECK_FCT( fd_msg_avp_hdr ( avp, &ahdr ) );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1387
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1388 if (!(ahdr->avp_flags & AVP_FLAG_VENDOR)) {
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1389 switch (ahdr->avp_code) {
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1390 /* Based on RFC4005, sec 3.10 */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1391 case DIAM_ATTR_SESSION_ID:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1392 case DIAM_ATTR_ORIGIN_HOST:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1393 case DIAM_ATTR_ORIGIN_REALM:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1394 case DIAM_ATTR_ACCOUNTING_RECORD_TYPE:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1395 case DIAM_ATTR_ACCOUNTING_RECORD_NUMBER:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1396 case DIAM_ATTR_ACCT_APPLICATION_ID:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1397 case DIAM_ATTR_VENDOR_SPECIFIC_APPLICATION_ID:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1398 case DIAM_ATTR_USER_NAME:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1399 case DIAM_ATTR_ACCOUNTING_SUB_SESSION_ID:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1400 case DIAM_ATTR_ACCT_SESSION_ID:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1401 case DIAM_ATTR_ACCT_MULTI_SESSION_ID:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1402 case DIAM_ATTR_EVENT_TIMESTAMP:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1403 case DIAM_ATTR_ORIGIN_AAA_PROTOCOL:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1404 case DIAM_ATTR_ORIGIN_STATE_ID:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1405 case DIAM_ATTR_NAS_IDENTIFIER:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1406 case DIAM_ATTR_NAS_IP_ADDRESS:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1407 case DIAM_ATTR_NAS_IPV6_ADDRESS:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1408 case DIAM_ATTR_NAS_PORT:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1409 case DIAM_ATTR_NAS_PORT_ID:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1410 case DIAM_ATTR_NAS_PORT_TYPE:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1411 case DIAM_ATTR_SERVICE_TYPE:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1412 case DIAM_ATTR_TERMINATION_CAUSE:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1413 case DIAM_ATTR_ACCOUNTING_REALTIME_REQUIRED:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1414 case DIAM_ATTR_ACCT_INTERIM_INTERVAL:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1415 case DIAM_ATTR_CLASS:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1416 /* 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
1417 break;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1418
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1419 default:
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1420 /* 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
1421 handled = 0;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1422 }
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1423 } else {
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1424 /* Vendor-specific AVPs */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1425 switch (ahdr->avp_vendor) {
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 default: /* unknown vendor */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1428 handled = 0;
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1429 }
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1430 }
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1431
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1432 if (handled) {
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1433 CHECK_FCT( fd_msg_free( avp ) );
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1434 }
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1435 }
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1436
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1437 /*
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1438 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
1439 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
1440 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
1441 Response Code, Identifier, Length, the Request Authenticator field
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1442 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
1443 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
1444 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
1445 field of the Accounting-Response packet.
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1446
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1447 -- done in radius_msg_finish_srv
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1448 */
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1449
411314907b43 Added translation of Accounting messages
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 268
diff changeset
1450 return 0;
259
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1451 }
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1452
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1453 /* The exported symbol */
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1454 struct rgw_api rgwp_descriptor = {
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1455 .rgwp_name = "acct",
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1456 .rgwp_conf_parse = acct_conf_parse,
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1457 .rgwp_conf_free = acct_conf_free,
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1458 .rgwp_rad_req = acct_rad_req,
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1459 .rgwp_diam_ans = acct_diam_ans
359e8e394423 Ported the incomplete acct plugin (from waaad)
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1460 };
"Welcome to our mercurial repository"