Mercurial > hg > freeDiameter
annotate extensions/test_acct/test_acct.c @ 662:2e94ef0515d7 1.1.0-rc1
Updated copyright information
author | Sebastien Decugis <sdecugis@nict.go.jp> |
---|---|
date | Fri, 14 Jan 2011 16:27:21 +0900 |
parents | c23632480951 |
children | a49d05084fff |
rev | line source |
---|---|
279
a26655da5c14
Added a dummy accounting server for tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
1 /********************************************************************************************************* |
a26655da5c14
Added a dummy accounting server for tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
2 * Software License Agreement (BSD License) * |
a26655da5c14
Added a dummy accounting server for tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
3 * Author: Sebastien Decugis <sdecugis@nict.go.jp> * |
a26655da5c14
Added a dummy accounting server for tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
4 * * |
662
2e94ef0515d7
Updated copyright information
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
652
diff
changeset
|
5 * Copyright (c) 2011, WIDE Project and NICT * |
279
a26655da5c14
Added a dummy accounting server for tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
6 * All rights reserved. * |
a26655da5c14
Added a dummy accounting server for tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
7 * * |
a26655da5c14
Added a dummy accounting server for tests
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 * |
a26655da5c14
Added a dummy accounting server for tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
9 * permitted provided that the following conditions are met: * |
a26655da5c14
Added a dummy accounting server for tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
10 * * |
a26655da5c14
Added a dummy accounting server for tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
11 * * Redistributions of source code must retain the above * |
a26655da5c14
Added a dummy accounting server for tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
12 * copyright notice, this list of conditions and the * |
a26655da5c14
Added a dummy accounting server for tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
13 * following disclaimer. * |
a26655da5c14
Added a dummy accounting server for tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
14 * * |
a26655da5c14
Added a dummy accounting server for tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
15 * * Redistributions in binary form must reproduce the above * |
a26655da5c14
Added a dummy accounting server for tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
16 * copyright notice, this list of conditions and the * |
a26655da5c14
Added a dummy accounting server for tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
17 * following disclaimer in the documentation and/or other * |
a26655da5c14
Added a dummy accounting server for tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
18 * materials provided with the distribution. * |
a26655da5c14
Added a dummy accounting server for tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
19 * * |
a26655da5c14
Added a dummy accounting server for tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
20 * * Neither the name of the WIDE Project or NICT nor the * |
a26655da5c14
Added a dummy accounting server for tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
21 * names of its contributors may be used to endorse or * |
a26655da5c14
Added a dummy accounting server for tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
22 * promote products derived from this software without * |
a26655da5c14
Added a dummy accounting server for tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
23 * specific prior written permission of WIDE Project and * |
a26655da5c14
Added a dummy accounting server for tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
24 * NICT. * |
a26655da5c14
Added a dummy accounting server for tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
25 * * |
a26655da5c14
Added a dummy accounting server for tests
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 * |
a26655da5c14
Added a dummy accounting server for tests
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 * |
a26655da5c14
Added a dummy accounting server for tests
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 * |
a26655da5c14
Added a dummy accounting server for tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
29 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * |
a26655da5c14
Added a dummy accounting server for tests
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 * |
a26655da5c14
Added a dummy accounting server for tests
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 * |
a26655da5c14
Added a dummy accounting server for tests
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 * |
a26655da5c14
Added a dummy accounting server for tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
33 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * |
a26655da5c14
Added a dummy accounting server for tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
34 *********************************************************************************************************/ |
a26655da5c14
Added a dummy accounting server for tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
35 |
a26655da5c14
Added a dummy accounting server for tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
36 /* This extension simply receives ACR and sends positive ACA after displaying the content, |
a26655da5c14
Added a dummy accounting server for tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
37 but does not commit the data to any storage */ |
a26655da5c14
Added a dummy accounting server for tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
38 |
a26655da5c14
Added a dummy accounting server for tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
39 #include <freeDiameter/extension.h> |
a26655da5c14
Added a dummy accounting server for tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
40 |
a26655da5c14
Added a dummy accounting server for tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
41 static struct { |
a26655da5c14
Added a dummy accounting server for tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
42 struct dict_object * Accounting_Record_Number; |
a26655da5c14
Added a dummy accounting server for tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
43 struct dict_object * Accounting_Record_Type; |
a26655da5c14
Added a dummy accounting server for tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
44 } tac_dict; |
a26655da5c14
Added a dummy accounting server for tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
45 |
a26655da5c14
Added a dummy accounting server for tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
46 /* Callback for incoming Base Accounting application messages */ |
652
c23632480951
Fix updated API format
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
282
diff
changeset
|
47 static int tac_cb( struct msg ** msg, struct avp * avp, struct session * sess, void * data, enum disp_action * act) |
279
a26655da5c14
Added a dummy accounting server for tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
48 { |
a26655da5c14
Added a dummy accounting server for tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
49 struct msg_hdr *hdr = NULL; |
a26655da5c14
Added a dummy accounting server for tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
50 |
a26655da5c14
Added a dummy accounting server for tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
51 TRACE_ENTRY("%p %p %p %p", msg, avp, sess, act); |
a26655da5c14
Added a dummy accounting server for tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
52 |
a26655da5c14
Added a dummy accounting server for tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
53 if (msg == NULL) |
a26655da5c14
Added a dummy accounting server for tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
54 return EINVAL; |
a26655da5c14
Added a dummy accounting server for tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
55 |
282
3db90f9ce42f
Cleanup the output of the extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
279
diff
changeset
|
56 /* Check what we received */ |
279
a26655da5c14
Added a dummy accounting server for tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
57 CHECK_FCT( fd_msg_hdr(*msg, &hdr) ); |
a26655da5c14
Added a dummy accounting server for tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
58 |
a26655da5c14
Added a dummy accounting server for tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
59 if (hdr->msg_flags & CMD_FLAG_REQUEST) { |
a26655da5c14
Added a dummy accounting server for tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
60 /* It was a request, create an answer */ |
a26655da5c14
Added a dummy accounting server for tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
61 struct msg *ans, *qry; |
282
3db90f9ce42f
Cleanup the output of the extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
279
diff
changeset
|
62 struct avp * a = NULL; |
3db90f9ce42f
Cleanup the output of the extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
279
diff
changeset
|
63 struct avp_hdr * h = NULL; |
3db90f9ce42f
Cleanup the output of the extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
279
diff
changeset
|
64 char * s; |
279
a26655da5c14
Added a dummy accounting server for tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
65 |
a26655da5c14
Added a dummy accounting server for tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
66 qry = *msg; |
a26655da5c14
Added a dummy accounting server for tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
67 /* Create the answer message, including the Session-Id AVP */ |
a26655da5c14
Added a dummy accounting server for tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
68 CHECK_FCT( fd_msg_new_answer_from_req ( fd_g_config->cnf_dict, msg, 0 ) ); |
a26655da5c14
Added a dummy accounting server for tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
69 ans = *msg; |
a26655da5c14
Added a dummy accounting server for tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
70 |
a26655da5c14
Added a dummy accounting server for tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
71 /* Set the Origin-Host, Origin-Realm, Result-Code AVPs */ |
a26655da5c14
Added a dummy accounting server for tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
72 CHECK_FCT( fd_msg_rescode_set( ans, "DIAMETER_SUCCESS", NULL, NULL, 1 ) ); |
a26655da5c14
Added a dummy accounting server for tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
73 |
282
3db90f9ce42f
Cleanup the output of the extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
279
diff
changeset
|
74 fd_log_debug("--------------Received the following Accounting message:--------------\n"); |
3db90f9ce42f
Cleanup the output of the extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
279
diff
changeset
|
75 |
3db90f9ce42f
Cleanup the output of the extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
279
diff
changeset
|
76 CHECK_FCT( fd_sess_getsid ( sess, &s ) ); |
3db90f9ce42f
Cleanup the output of the extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
279
diff
changeset
|
77 fd_log_debug("Session: %s\n", s); |
3db90f9ce42f
Cleanup the output of the extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
279
diff
changeset
|
78 |
3db90f9ce42f
Cleanup the output of the extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
279
diff
changeset
|
79 /* The AVPs that we copy in the answer */ |
3db90f9ce42f
Cleanup the output of the extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
279
diff
changeset
|
80 CHECK_FCT( fd_msg_search_avp ( qry, tac_dict.Accounting_Record_Type, &a) ); |
3db90f9ce42f
Cleanup the output of the extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
279
diff
changeset
|
81 if (a) { |
3db90f9ce42f
Cleanup the output of the extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
279
diff
changeset
|
82 CHECK_FCT( fd_msg_avp_hdr( a, &h ) ); |
3db90f9ce42f
Cleanup the output of the extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
279
diff
changeset
|
83 fd_log_debug("Accounting-Record-Type: %d (%s)\n", h->avp_value->u32, |
3db90f9ce42f
Cleanup the output of the extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
279
diff
changeset
|
84 /* it would be better to search this in the dictionary, but it is only for debug, so ok */ |
3db90f9ce42f
Cleanup the output of the extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
279
diff
changeset
|
85 (h->avp_value->u32 == 1) ? "EVENT_RECORD" : |
3db90f9ce42f
Cleanup the output of the extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
279
diff
changeset
|
86 (h->avp_value->u32 == 2) ? "START_RECORD" : |
3db90f9ce42f
Cleanup the output of the extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
279
diff
changeset
|
87 (h->avp_value->u32 == 3) ? "INTERIM_RECORD" : |
3db90f9ce42f
Cleanup the output of the extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
279
diff
changeset
|
88 (h->avp_value->u32 == 4) ? "STOP_RECORD" : |
3db90f9ce42f
Cleanup the output of the extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
279
diff
changeset
|
89 "<unknown value>" |
3db90f9ce42f
Cleanup the output of the extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
279
diff
changeset
|
90 ); |
3db90f9ce42f
Cleanup the output of the extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
279
diff
changeset
|
91 CHECK_FCT( fd_msg_avp_new ( tac_dict.Accounting_Record_Type, 0, &a ) ); |
3db90f9ce42f
Cleanup the output of the extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
279
diff
changeset
|
92 CHECK_FCT( fd_msg_avp_setvalue( a, h->avp_value ) ); |
3db90f9ce42f
Cleanup the output of the extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
279
diff
changeset
|
93 CHECK_FCT( fd_msg_avp_add( ans, MSG_BRW_LAST_CHILD, a ) ); |
3db90f9ce42f
Cleanup the output of the extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
279
diff
changeset
|
94 } |
3db90f9ce42f
Cleanup the output of the extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
279
diff
changeset
|
95 CHECK_FCT( fd_msg_search_avp ( qry, tac_dict.Accounting_Record_Number, &a) ); |
3db90f9ce42f
Cleanup the output of the extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
279
diff
changeset
|
96 if (a) { |
3db90f9ce42f
Cleanup the output of the extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
279
diff
changeset
|
97 CHECK_FCT( fd_msg_avp_hdr( a, &h ) ); |
3db90f9ce42f
Cleanup the output of the extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
279
diff
changeset
|
98 fd_log_debug("Accounting-Record-Number: %d\n", h->avp_value->u32); |
3db90f9ce42f
Cleanup the output of the extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
279
diff
changeset
|
99 CHECK_FCT( fd_msg_avp_new ( tac_dict.Accounting_Record_Number, 0, &a ) ); |
3db90f9ce42f
Cleanup the output of the extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
279
diff
changeset
|
100 CHECK_FCT( fd_msg_avp_setvalue( a, h->avp_value ) ); |
3db90f9ce42f
Cleanup the output of the extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
279
diff
changeset
|
101 CHECK_FCT( fd_msg_avp_add( ans, MSG_BRW_LAST_CHILD, a ) ); |
3db90f9ce42f
Cleanup the output of the extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
279
diff
changeset
|
102 } |
3db90f9ce42f
Cleanup the output of the extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
279
diff
changeset
|
103 |
3db90f9ce42f
Cleanup the output of the extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
279
diff
changeset
|
104 /* We may also dump other data from the message, such as Accounting session Id, number of packets, ... */ |
279
a26655da5c14
Added a dummy accounting server for tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
105 |
282
3db90f9ce42f
Cleanup the output of the extension
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
279
diff
changeset
|
106 fd_log_debug("----------------------------------------------------------------------\n"); |
279
a26655da5c14
Added a dummy accounting server for tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
107 |
a26655da5c14
Added a dummy accounting server for tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
108 /* Send the answer */ |
a26655da5c14
Added a dummy accounting server for tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
109 CHECK_FCT( fd_msg_send( msg, NULL, NULL ) ); |
a26655da5c14
Added a dummy accounting server for tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
110 |
a26655da5c14
Added a dummy accounting server for tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
111 } else { |
a26655da5c14
Added a dummy accounting server for tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
112 /* We received an answer message, just discard it */ |
a26655da5c14
Added a dummy accounting server for tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
113 CHECK_FCT( fd_msg_free( *msg ) ); |
a26655da5c14
Added a dummy accounting server for tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
114 *msg = NULL; |
a26655da5c14
Added a dummy accounting server for tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
115 } |
a26655da5c14
Added a dummy accounting server for tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
116 |
a26655da5c14
Added a dummy accounting server for tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
117 return 0; |
a26655da5c14
Added a dummy accounting server for tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
118 } |
a26655da5c14
Added a dummy accounting server for tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
119 |
a26655da5c14
Added a dummy accounting server for tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
120 /* entry point: register handler for Base Accounting messages in the daemon */ |
a26655da5c14
Added a dummy accounting server for tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
121 static int tac_entry(char * conffile) |
a26655da5c14
Added a dummy accounting server for tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
122 { |
a26655da5c14
Added a dummy accounting server for tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
123 struct disp_when data; |
a26655da5c14
Added a dummy accounting server for tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
124 |
a26655da5c14
Added a dummy accounting server for tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
125 TRACE_ENTRY("%p", conffile); |
a26655da5c14
Added a dummy accounting server for tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
126 |
a26655da5c14
Added a dummy accounting server for tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
127 memset(&tac_dict, 0, sizeof(tac_dict)); |
a26655da5c14
Added a dummy accounting server for tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
128 memset(&data, 0, sizeof(data)); |
a26655da5c14
Added a dummy accounting server for tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
129 |
a26655da5c14
Added a dummy accounting server for tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
130 /* Initialize the dictionary objects we use */ |
a26655da5c14
Added a dummy accounting server for tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
131 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_APPLICATION, APPLICATION_BY_NAME, "Diameter Base Accounting", &data.app, ENOENT) ); |
a26655da5c14
Added a dummy accounting server for tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
132 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Accounting-Record-Number", &tac_dict.Accounting_Record_Number, ENOENT) ); |
a26655da5c14
Added a dummy accounting server for tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
133 CHECK_FCT( fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Accounting-Record-Type", &tac_dict.Accounting_Record_Type, ENOENT) ); |
a26655da5c14
Added a dummy accounting server for tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
134 |
a26655da5c14
Added a dummy accounting server for tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
135 /* Register the dispatch callback */ |
652
c23632480951
Fix updated API format
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
282
diff
changeset
|
136 CHECK_FCT( fd_disp_register( tac_cb, DISP_HOW_APPID, &data, NULL, NULL ) ); |
279
a26655da5c14
Added a dummy accounting server for tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
137 |
a26655da5c14
Added a dummy accounting server for tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
138 /* Advertise the support for the Diameter Base Accounting application in the peer */ |
a26655da5c14
Added a dummy accounting server for tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
139 CHECK_FCT( fd_disp_app_support ( data.app, NULL, 0, 1 ) ); |
a26655da5c14
Added a dummy accounting server for tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
140 |
a26655da5c14
Added a dummy accounting server for tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
141 return 0; |
a26655da5c14
Added a dummy accounting server for tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
142 } |
a26655da5c14
Added a dummy accounting server for tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
143 |
a26655da5c14
Added a dummy accounting server for tests
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff
changeset
|
144 EXTENSION_ENTRY("test_acct", tac_entry); |