annotate extensions/app_acct/app_acct.c @ 741:d59decafe9c0

Updated copyright information
author Sebastien Decugis <sdecugis@nict.go.jp>
date Thu, 24 Mar 2011 15:00:38 +0900
parents 4a9f08d6b6ba
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
284
397cdcd41f53 New app_acct in progress, backup only
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1 /*********************************************************************************************************
397cdcd41f53 New app_acct in progress, backup only
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: 639
diff changeset
3 * Author: Sebastien Decugis <sdecugis@freediameter.net> *
284
397cdcd41f53 New app_acct in progress, backup only
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
4 * *
741
d59decafe9c0 Updated copyright information
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 740
diff changeset
5 * Copyright (c) 2011, WIDE Project and NICT *
284
397cdcd41f53 New app_acct in progress, backup only
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
6 * All rights reserved. *
397cdcd41f53 New app_acct in progress, backup only
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
7 * *
397cdcd41f53 New app_acct in progress, backup only
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 *
397cdcd41f53 New app_acct in progress, backup only
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
9 * permitted provided that the following conditions are met: *
397cdcd41f53 New app_acct in progress, backup only
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
10 * *
397cdcd41f53 New app_acct in progress, backup only
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
11 * * Redistributions of source code must retain the above *
397cdcd41f53 New app_acct in progress, backup only
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
12 * copyright notice, this list of conditions and the *
397cdcd41f53 New app_acct in progress, backup only
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
13 * following disclaimer. *
397cdcd41f53 New app_acct in progress, backup only
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
14 * *
397cdcd41f53 New app_acct in progress, backup only
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
15 * * Redistributions in binary form must reproduce the above *
397cdcd41f53 New app_acct in progress, backup only
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
16 * copyright notice, this list of conditions and the *
397cdcd41f53 New app_acct in progress, backup only
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
17 * following disclaimer in the documentation and/or other *
397cdcd41f53 New app_acct in progress, backup only
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
18 * materials provided with the distribution. *
397cdcd41f53 New app_acct in progress, backup only
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
19 * *
397cdcd41f53 New app_acct in progress, backup only
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
20 * * Neither the name of the WIDE Project or NICT nor the *
397cdcd41f53 New app_acct in progress, backup only
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
21 * names of its contributors may be used to endorse or *
397cdcd41f53 New app_acct in progress, backup only
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
22 * promote products derived from this software without *
397cdcd41f53 New app_acct in progress, backup only
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
23 * specific prior written permission of WIDE Project and *
397cdcd41f53 New app_acct in progress, backup only
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
24 * NICT. *
397cdcd41f53 New app_acct in progress, backup only
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
25 * *
397cdcd41f53 New app_acct in progress, backup only
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 *
397cdcd41f53 New app_acct in progress, backup only
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 *
397cdcd41f53 New app_acct in progress, backup only
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 *
397cdcd41f53 New app_acct in progress, backup only
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
29 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT *
397cdcd41f53 New app_acct in progress, backup only
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 *
397cdcd41f53 New app_acct in progress, backup only
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 *
397cdcd41f53 New app_acct in progress, backup only
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 *
397cdcd41f53 New app_acct in progress, backup only
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
33 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
397cdcd41f53 New app_acct in progress, backup only
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
34 *********************************************************************************************************/
397cdcd41f53 New app_acct in progress, backup only
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
35
397cdcd41f53 New app_acct in progress, backup only
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
36 /* The simple Accounting server for freeDiameter */
397cdcd41f53 New app_acct in progress, backup only
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
37
397cdcd41f53 New app_acct in progress, backup only
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
38 #include "app_acct.h"
397cdcd41f53 New app_acct in progress, backup only
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
39
286
43cdf237bb8c Added comment
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 285
diff changeset
40 /* Mandatory AVPs for the Accounting-Answer (any value in adding all the other AVPs?) */
285
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 284
diff changeset
41 static struct {
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 284
diff changeset
42 struct dict_object * Accounting_Record_Number;
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 284
diff changeset
43 struct dict_object * Accounting_Record_Type;
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 284
diff changeset
44 } acct_dict;
284
397cdcd41f53 New app_acct in progress, backup only
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
45
397cdcd41f53 New app_acct in progress, backup only
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
46
397cdcd41f53 New app_acct in progress, backup only
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
47 /* Callback for incoming Base Accounting Accounting-Request messages */
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: 403
diff changeset
48 static int acct_cb( struct msg ** msg, struct avp * avp, struct session * sess, void * opaque, enum disp_action * act)
284
397cdcd41f53 New app_acct in progress, backup only
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
49 {
285
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 284
diff changeset
50 struct msg * m;
284
397cdcd41f53 New app_acct in progress, backup only
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
51 struct avp * a = NULL;
285
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 284
diff changeset
52 struct avp_hdr * art=NULL, *arn=NULL; /* We keep a pointer on the Accounting-Record-{Type, Number} AVPs from the query */
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 284
diff changeset
53 struct acct_record_list rl;
284
397cdcd41f53 New app_acct in progress, backup only
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
54
397cdcd41f53 New app_acct in progress, backup only
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
55 TRACE_ENTRY("%p %p %p %p", msg, avp, sess, act);
397cdcd41f53 New app_acct in progress, backup only
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
56 if (msg == NULL)
397cdcd41f53 New app_acct in progress, backup only
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
57 return EINVAL;
397cdcd41f53 New app_acct in progress, backup only
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
58
285
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 284
diff changeset
59 m = *msg;
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 284
diff changeset
60
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 284
diff changeset
61 /* Prepare a new record list */
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 284
diff changeset
62 CHECK_FCT( acct_rec_prepare( &rl ) );
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 284
diff changeset
63
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 284
diff changeset
64 /* Maps the AVPs from the query with this record list */
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 284
diff changeset
65 CHECK_FCT( acct_rec_map( &rl, m ) );
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 284
diff changeset
66
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 284
diff changeset
67 /* Check that at least one AVP was mapped */
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 284
diff changeset
68 CHECK_FCT( acct_rec_validate( &rl ) );
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 284
diff changeset
69
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 284
diff changeset
70 /* Now, save these mapped AVPs in the database */
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 284
diff changeset
71 CHECK_FCT( acct_db_insert( &rl ) );
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 284
diff changeset
72
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 284
diff changeset
73 acct_rec_empty( &rl );
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 284
diff changeset
74
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 284
diff changeset
75 /* OK, we can send a positive reply now */
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 284
diff changeset
76
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 284
diff changeset
77 /* Get Accounting-Record-{Number,Type} values */
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 284
diff changeset
78 CHECK_FCT( fd_msg_search_avp ( m, acct_dict.Accounting_Record_Type, &a) );
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 284
diff changeset
79 if (a) {
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 284
diff changeset
80 CHECK_FCT( fd_msg_avp_hdr( a, &art ) );
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 284
diff changeset
81 }
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 284
diff changeset
82 CHECK_FCT( fd_msg_search_avp ( m, acct_dict.Accounting_Record_Number, &a) );
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 284
diff changeset
83 if (a) {
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 284
diff changeset
84 CHECK_FCT( fd_msg_avp_hdr( a, &arn ) );
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 284
diff changeset
85 }
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 284
diff changeset
86
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 284
diff changeset
87 /* Create the answer message */
284
397cdcd41f53 New app_acct in progress, backup only
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
88 CHECK_FCT( fd_msg_new_answer_from_req ( fd_g_config->cnf_dict, msg, 0 ) );
285
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 284
diff changeset
89 m = *msg;
284
397cdcd41f53 New app_acct in progress, backup only
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
90
397cdcd41f53 New app_acct in progress, backup only
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
91 /* Set the Origin-Host, Origin-Realm, Result-Code AVPs */
285
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 284
diff changeset
92 CHECK_FCT( fd_msg_rescode_set( m, "DIAMETER_SUCCESS", NULL, NULL, 1 ) );
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 284
diff changeset
93
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 284
diff changeset
94 /* Add the mandatory AVPs in the ACA */
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 284
diff changeset
95 if (art) {
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 284
diff changeset
96 CHECK_FCT( fd_msg_avp_new ( acct_dict.Accounting_Record_Type, 0, &a ) );
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 284
diff changeset
97 CHECK_FCT( fd_msg_avp_setvalue( a, art->avp_value ) );
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 284
diff changeset
98 CHECK_FCT( fd_msg_avp_add( m, MSG_BRW_LAST_CHILD, a ) );
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 284
diff changeset
99 }
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 284
diff changeset
100 if (arn) {
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 284
diff changeset
101 CHECK_FCT( fd_msg_avp_new ( acct_dict.Accounting_Record_Number, 0, &a ) );
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 284
diff changeset
102 CHECK_FCT( fd_msg_avp_setvalue( a, arn->avp_value ) );
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 284
diff changeset
103 CHECK_FCT( fd_msg_avp_add( m, MSG_BRW_LAST_CHILD, a ) );
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 284
diff changeset
104 }
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 284
diff changeset
105
284
397cdcd41f53 New app_acct in progress, backup only
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
106 /* Send the answer */
285
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 284
diff changeset
107 *act = DISP_ACT_SEND;
284
397cdcd41f53 New app_acct in progress, backup only
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
108 return 0;
397cdcd41f53 New app_acct in progress, backup only
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
109 }
397cdcd41f53 New app_acct in progress, backup only
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
110
397cdcd41f53 New app_acct in progress, backup only
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
111
397cdcd41f53 New app_acct in progress, backup only
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
112 /* entry point */
397cdcd41f53 New app_acct in progress, backup only
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
113 static int acct_entry(char * conffile)
397cdcd41f53 New app_acct in progress, backup only
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
114 {
397cdcd41f53 New app_acct in progress, backup only
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
115 struct disp_when data;
397cdcd41f53 New app_acct in progress, backup only
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
116
397cdcd41f53 New app_acct in progress, backup only
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
117 TRACE_ENTRY("%p", conffile);
397cdcd41f53 New app_acct in progress, backup only
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
118
285
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 284
diff changeset
119 #ifndef TEST_DEBUG /* We do this differently in the test scenario */
284
397cdcd41f53 New app_acct in progress, backup only
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
120 /* Initialize the configuration and parse the file */
397cdcd41f53 New app_acct in progress, backup only
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
121 CHECK_FCT( acct_conf_init() );
397cdcd41f53 New app_acct in progress, backup only
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
122 CHECK_FCT( acct_conf_parse(conffile) );
397cdcd41f53 New app_acct in progress, backup only
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
123 CHECK_FCT( acct_conf_check(conffile) );
285
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 284
diff changeset
124 #endif /* TEST_DEBUG */
284
397cdcd41f53 New app_acct in progress, backup only
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
125
397cdcd41f53 New app_acct in progress, backup only
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
126 /* Now initialize the database module */
397cdcd41f53 New app_acct in progress, backup only
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
127 CHECK_FCT( acct_db_init() );
397cdcd41f53 New app_acct in progress, backup only
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
128
285
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 284
diff changeset
129 /* Search the AVPs we will need in this file */
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 284
diff changeset
130 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Accounting-Record-Number", &acct_dict.Accounting_Record_Number, ENOENT) );
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 284
diff changeset
131 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Accounting-Record-Type", &acct_dict.Accounting_Record_Type, ENOENT) );
0daf6fc2b751 Added a test case for the app_acct extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 284
diff changeset
132
284
397cdcd41f53 New app_acct in progress, backup only
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
133 /* Register the dispatch callbacks */
397cdcd41f53 New app_acct in progress, backup only
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
134 memset(&data, 0, sizeof(data));
397cdcd41f53 New app_acct in progress, backup only
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
135 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_APPLICATION, APPLICATION_BY_NAME, "Diameter Base Accounting", &data.app, ENOENT) );
397cdcd41f53 New app_acct in progress, backup only
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
136 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_COMMAND, CMD_BY_NAME, "Accounting-Request", &data.command, ENOENT) );
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: 403
diff changeset
137 CHECK_FCT( fd_disp_register( acct_cb, DISP_HOW_CC, &data, NULL, NULL ) );
284
397cdcd41f53 New app_acct in progress, backup only
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
138
397cdcd41f53 New app_acct in progress, backup only
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
139 /* Advertise the support for the Diameter Base Accounting application in the peer */
397cdcd41f53 New app_acct in progress, backup only
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
140 CHECK_FCT( fd_disp_app_support ( data.app, NULL, 0, 1 ) );
397cdcd41f53 New app_acct in progress, backup only
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
141
397cdcd41f53 New app_acct in progress, backup only
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
142 return 0;
397cdcd41f53 New app_acct in progress, backup only
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
143 }
397cdcd41f53 New app_acct in progress, backup only
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
144
397cdcd41f53 New app_acct in progress, backup only
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
145 /* Unload */
397cdcd41f53 New app_acct in progress, backup only
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
146 void fd_ext_fini(void)
397cdcd41f53 New app_acct in progress, backup only
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
147 {
397cdcd41f53 New app_acct in progress, backup only
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
148 /* Close the db connection */
397cdcd41f53 New app_acct in progress, backup only
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
149 acct_db_free();
397cdcd41f53 New app_acct in progress, backup only
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
150
397cdcd41f53 New app_acct in progress, backup only
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
151 /* Destroy the configuration */
397cdcd41f53 New app_acct in progress, backup only
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
152 acct_conf_free();
397cdcd41f53 New app_acct in progress, backup only
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
153 }
397cdcd41f53 New app_acct in progress, backup only
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
154
397cdcd41f53 New app_acct in progress, backup only
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
155 EXTENSION_ENTRY("app_acct", acct_entry);
"Welcome to our mercurial repository"