annotate tests/testmesg.c @ 1329:175f2eb883a0

Add function to retrieve pmd structure associated with a request. Returns NULL in case of error.
author Thomas Klausner <tk@giga.or.at>
date Mon, 27 Nov 2017 15:27:31 +0100
parents 3f1e79e1273e
children f6f12521c2aa
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1 /*********************************************************************************************************
13530e1f02e3 Initial files imported
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: 662
diff changeset
3 * Author: Sebastien Decugis <sdecugis@freediameter.net> *
0
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
4 * *
1281
ab6457399be2 Updated copyright information
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1268
diff changeset
5 * Copyright (c) 2015, WIDE Project and NICT *
0
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
6 * All rights reserved. *
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
7 * *
13530e1f02e3 Initial files imported
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 *
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
9 * permitted provided that the following conditions are met: *
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
10 * *
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
11 * * Redistributions of source code must retain the above *
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
12 * copyright notice, this list of conditions and the *
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
13 * following disclaimer. *
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
14 * *
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
15 * * Redistributions in binary form must reproduce the above *
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
16 * copyright notice, this list of conditions and the *
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
17 * following disclaimer in the documentation and/or other *
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
18 * materials provided with the distribution. *
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
19 * *
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
20 * * Neither the name of the WIDE Project or NICT nor the *
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
21 * names of its contributors may be used to endorse or *
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
22 * promote products derived from this software without *
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
23 * specific prior written permission of WIDE Project and *
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
24 * NICT. *
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
25 * *
13530e1f02e3 Initial files imported
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 *
13530e1f02e3 Initial files imported
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 *
13530e1f02e3 Initial files imported
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 *
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
29 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT *
13530e1f02e3 Initial files imported
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 *
13530e1f02e3 Initial files imported
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 *
13530e1f02e3 Initial files imported
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 *
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
33 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
34 *********************************************************************************************************/
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
35
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
36 #include "tests.h"
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
37
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
38 /* Main test routine */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
39 int main(int argc, char *argv[])
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
40 {
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
41 struct msg * acr = NULL;
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
42 struct avp * pi = NULL, *avp1, *avp2;
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
43 unsigned char * buf = NULL;
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
44
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
45 /* First, initialize the daemon modules */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
46 INIT_FD();
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
47
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
48 /* Create the message object from model */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
49 {
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
50 struct dict_object * acr_model = NULL;
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
51
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
52 /* Now find the ACR dictionary object */
10
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
53 CHECK( 0, fd_dict_search ( fd_g_config->cnf_dict, DICT_COMMAND, CMD_BY_NAME, "Accounting-Request", &acr_model, ENOENT ) );
0
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
54
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
55 /* Create the instance, using the templates */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
56 CHECK( 0, fd_msg_new ( acr_model, 0, &acr ) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
57
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
58 /* Check there is no child */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
59 CHECK( ENOENT, fd_msg_browse ( acr, MSG_BRW_FIRST_CHILD, NULL, NULL) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
60
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
61 #if 0
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
62 /* For debug: dump the object */
1088
1d1a20a0779d Second part of changeset 1083, now the code compiles again. Still missing some functions implementation, though
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1047
diff changeset
63 fd_log_debug("Dumping Accounting-Request empty message:");
1d1a20a0779d Second part of changeset 1083, now the code compiles again. Still missing some functions implementation, though
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1047
diff changeset
64 fd_log_debug("%s", fd_msg_dump_treeview(FD_DUMP_TEST_PARAMS, acr, fd_g_config->cnf_dict, 0, 1));
0
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
65 #endif
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
66 }
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
67
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
68 /* Create the Proxy-Info AVP from model */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
69 {
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
70 struct dict_object * pi_model = NULL;
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
71
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
72 /* Now find the ACR dictionary object */
10
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
73 CHECK( 0, fd_dict_search ( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Proxy-Info", &pi_model, ENOENT ) );
0
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
74
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
75 /* Create the instance, using the templates */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
76 CHECK( 0, fd_msg_avp_new ( pi_model, 0, &pi ) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
77
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
78 #if 0
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
79 /* For debug: dump the object */
974
2091bf698fb1 Remove newlines from fd_log_debug, TRACE_DEBUG, TRACE_ERROR, and TRACE_DEBUG_ERROR
Thomas Klausner <tk@giga.or.at>
parents: 931
diff changeset
80 fd_log_debug("Dumping Proxy-Info AVP");
1088
1d1a20a0779d Second part of changeset 1083, now the code compiles again. Still missing some functions implementation, though
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1047
diff changeset
81 fd_log_debug("%s", fd_msg_dump_treeview(FD_DUMP_TEST_PARAMS, pi, fd_g_config->cnf_dict, 0, 1));
974
2091bf698fb1 Remove newlines from fd_log_debug, TRACE_DEBUG, TRACE_ERROR, and TRACE_DEBUG_ERROR
Thomas Klausner <tk@giga.or.at>
parents: 931
diff changeset
82 fd_log_debug("Dumping dictionary model");
1088
1d1a20a0779d Second part of changeset 1083, now the code compiles again. Still missing some functions implementation, though
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1047
diff changeset
83 fd_log_debug("%s", fd_dict_dump_object(FD_DUMP_TEST_PARAMS, pi_model));
0
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
84 #endif
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
85
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
86 }
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
87
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
88 /* Get a reference to the current last AVP in the message */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
89 {
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
90 int diff = 0;
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
91
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
92 CHECK( 0, fd_msg_avp_new ( NULL, 0, &avp1 ) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
93 CHECK( 0, fd_msg_avp_add ( acr, MSG_BRW_LAST_CHILD, avp1) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
94
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
95 CHECK( 0, fd_msg_browse ( acr, MSG_BRW_LAST_CHILD, &avp2, &diff) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
96 CHECK( 1, diff );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
97 CHECK( avp1, avp2 );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
98
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
99 /* Check that we cannot add this AVP to another object since it is already linked */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
100 CHECK( EINVAL, fd_msg_avp_add( pi, MSG_BRW_LAST_CHILD, avp1) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
101 }
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
102
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
103 /* Now add the Proxy-Info AVP at the end of the message */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
104 {
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
105 CHECK( 0, fd_msg_avp_add( acr, MSG_BRW_LAST_CHILD, pi) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
106 #if 0
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
107 /* For debug: dump the object */
974
2091bf698fb1 Remove newlines from fd_log_debug, TRACE_DEBUG, TRACE_ERROR, and TRACE_DEBUG_ERROR
Thomas Klausner <tk@giga.or.at>
parents: 931
diff changeset
108 fd_log_debug("Dumping Accounting-Request with Proxy-Info AVP at the end");
1088
1d1a20a0779d Second part of changeset 1083, now the code compiles again. Still missing some functions implementation, though
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1047
diff changeset
109 fd_log_debug("%s", fd_msg_dump_treeview(FD_DUMP_TEST_PARAMS, acr, fd_g_config->cnf_dict, 0, 1));
0
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
110 #endif
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
111 }
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
112
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
113 /* Check the last child is now the proxy-Info */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
114 {
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
115 CHECK( 0, fd_msg_browse ( acr, MSG_BRW_LAST_CHILD, &avp2, NULL) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
116 CHECK( pi, avp2 );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
117 }
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
118
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
119 /* Check that the avp before the proxy-info is the previous last one */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
120 {
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
121 int diff = 0;
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
122 CHECK( 0, fd_msg_browse ( pi, MSG_BRW_PREV, &avp2, &diff) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
123 CHECK( avp1, avp2 );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
124 CHECK( 0, diff);
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
125 }
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
126
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
127 /* Check that there are no AVP after the proxy-info */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
128 CHECK( ENOENT, fd_msg_browse ( pi, MSG_BRW_NEXT, NULL, NULL) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
129
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
130 /* Test the fd_msg_free function unlinks the object properly */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
131 {
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
132 struct dict_object * rr_model = NULL;
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
133
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
134 /* Now find the dictionary object */
10
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
135 CHECK( 0, fd_dict_search ( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Route-Record", &rr_model, ENOENT ) );
0
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
136
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
137 /* Create the instance, using the templates */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
138 CHECK( 0, fd_msg_avp_new ( rr_model, 0, &avp1 ) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
139
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
140 /* Add the AVP at the end of the message */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
141 CHECK( 0, fd_msg_avp_add( pi, MSG_BRW_NEXT, avp1) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
142
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
143 /* Check the last AVP of the message is now this one */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
144 CHECK( 0, fd_msg_browse ( acr, MSG_BRW_LAST_CHILD, &avp2, NULL) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
145 CHECK( avp1, avp2 );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
146
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
147 /* Now delete it */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
148 CHECK( 0, fd_msg_free( avp1 ) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
149
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
150 /* Check the last AVP of the message is back to pi */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
151 CHECK( 0, fd_msg_browse ( acr, MSG_BRW_LAST_CHILD, &avp2, NULL) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
152 CHECK( pi, avp2 );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
153
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
154 /* Delete the whole message */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
155 CHECK( 0, fd_msg_free( acr ) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
156 }
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
157
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
158 /* Recreate the message object */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
159 {
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
160 struct dict_object * acr_model = NULL;
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
161
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
162 /* Now find the ACR dictionary object */
10
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
163 CHECK( 0, fd_dict_search ( fd_g_config->cnf_dict, DICT_COMMAND, CMD_BY_NAME, "Accounting-Request", &acr_model, ENOENT ) );
0
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
164
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
165 /* Create the instance, using the templates */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
166 CHECK( 0, fd_msg_new ( acr_model, 0, &acr ) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
167 }
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
168
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
169 /* Now let's create some additional Dictionary objects for the test */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
170 {
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
171 /* The constant values used here are totally arbitrary chosen */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
172 struct dict_object * vendor;
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
173 {
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
174 struct dict_vendor_data vendor_data = { 73565, "Vendor test" };
10
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
175 CHECK( 0, fd_dict_new ( fd_g_config->cnf_dict, DICT_VENDOR, &vendor_data , NULL, &vendor ) );
0
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
176 }
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
177
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
178 {
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
179 struct dict_application_data app_data = { 73566, "Application test" };
10
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
180 CHECK( 0, fd_dict_new ( fd_g_config->cnf_dict, DICT_APPLICATION, &app_data , vendor, NULL ) );
0
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
181 }
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
182
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
183 {
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
184 struct dict_avp_data avp_data = { 73567, 0, "AVP Test - no vendor - f32", 0, 0, AVP_TYPE_FLOAT32 };
10
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
185 CHECK( 0, fd_dict_new ( fd_g_config->cnf_dict, DICT_AVP, &avp_data , NULL, NULL ) );
0
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
186 }
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
187
890
19a261c9a2e1 Added test case to reproduce bug reported by Zack http://lists.freediameter.net/pipermail/help/2012-November/000538.html
Sebastien Decugis <sdecugis@freediameter.net>
parents: 740
diff changeset
188 {
19a261c9a2e1 Added test case to reproduce bug reported by Zack http://lists.freediameter.net/pipermail/help/2012-November/000538.html
Sebastien Decugis <sdecugis@freediameter.net>
parents: 740
diff changeset
189 struct dict_avp_data avp_data = { 139103, 0, "AVP Test - no vendor - f64", 0, 0, AVP_TYPE_FLOAT64 };
19a261c9a2e1 Added test case to reproduce bug reported by Zack http://lists.freediameter.net/pipermail/help/2012-November/000538.html
Sebastien Decugis <sdecugis@freediameter.net>
parents: 740
diff changeset
190 CHECK( 0, fd_dict_new ( fd_g_config->cnf_dict, DICT_AVP, &avp_data , NULL, NULL ) );
19a261c9a2e1 Added test case to reproduce bug reported by Zack http://lists.freediameter.net/pipermail/help/2012-November/000538.html
Sebastien Decugis <sdecugis@freediameter.net>
parents: 740
diff changeset
191 }
19a261c9a2e1 Added test case to reproduce bug reported by Zack http://lists.freediameter.net/pipermail/help/2012-November/000538.html
Sebastien Decugis <sdecugis@freediameter.net>
parents: 740
diff changeset
192
0
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
193 {
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
194 struct dict_object * type = NULL;
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
195 struct dict_type_data type_data = { AVP_TYPE_INTEGER64, "Int64 test" };
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
196 struct dict_avp_data avp_data = { 73568, 73565, "AVP Test - i64", AVP_FLAG_VENDOR, AVP_FLAG_VENDOR, AVP_TYPE_INTEGER64 };
10
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
197 CHECK( 0, fd_dict_new ( fd_g_config->cnf_dict, DICT_TYPE, &type_data , NULL, &type ) );
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
198 CHECK( 0, fd_dict_new ( fd_g_config->cnf_dict, DICT_AVP, &avp_data , type, NULL ) );
0
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
199 }
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
200
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
201 {
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
202 struct dict_object * type = NULL;
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
203 struct dict_type_data type_data = { AVP_TYPE_INTEGER32, "Enum32 test" };
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
204 struct dict_enumval_data val1 = { "i32 const test (val 1)", { .i32 = 1 } };
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
205 struct dict_enumval_data val2 = { "i32 const test (val 2)", { .i32 = 2 } };
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
206 struct dict_enumval_data val3 = { "i32 const test (val -5)",{ .i32 = -5 } };
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
207 struct dict_avp_data avp_data = { 73569, 73565, "AVP Test - enumi32", AVP_FLAG_VENDOR, AVP_FLAG_VENDOR, AVP_TYPE_INTEGER32 };
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
208
10
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
209 CHECK( 0, fd_dict_new ( fd_g_config->cnf_dict, DICT_TYPE, &type_data , NULL, &type ) );
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
210 CHECK( 0, fd_dict_new ( fd_g_config->cnf_dict, DICT_AVP, &avp_data , type, NULL ) );
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
211 CHECK( 0, fd_dict_new ( fd_g_config->cnf_dict, DICT_ENUMVAL, &val1 , type, NULL ) );
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
212 CHECK( 0, fd_dict_new ( fd_g_config->cnf_dict, DICT_ENUMVAL, &val2 , type, NULL ) );
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
213 CHECK( 0, fd_dict_new ( fd_g_config->cnf_dict, DICT_ENUMVAL, &val3 , type, NULL ) );
0
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
214 }
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
215
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
216 {
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
217 struct dict_object * type = NULL;
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
218 struct dict_type_data type_data = { AVP_TYPE_OCTETSTRING, "OS test" };
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
219 struct dict_avp_data avp_data = { 73570, 73565, "AVP Test - os", AVP_FLAG_VENDOR, AVP_FLAG_VENDOR, AVP_TYPE_OCTETSTRING };
10
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
220 CHECK( 0, fd_dict_new ( fd_g_config->cnf_dict, DICT_TYPE, &type_data , NULL, &type ) );
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
221 CHECK( 0, fd_dict_new ( fd_g_config->cnf_dict, DICT_AVP, &avp_data , type, NULL ) );
0
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
222 }
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
223
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
224 {
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
225 struct dict_object * type = NULL;
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
226 struct dict_type_data type_data = { AVP_TYPE_OCTETSTRING, "OS enum test" };
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
227 struct dict_enumval_data val1 = { "os const test (Test)", { .os = { (unsigned char *)"Test", 4 } } };
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
228 struct dict_enumval_data val2 = { "os const test (waaad)", { .os = { (unsigned char *)"waaad", 5 } } };
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
229 struct dict_enumval_data val3 = { "os const test (waa)", { .os = { (unsigned char *)"waaad", 3 } } };
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
230 struct dict_avp_data avp_data = { 73571, 73565, "AVP Test - enumos", AVP_FLAG_VENDOR, AVP_FLAG_VENDOR, AVP_TYPE_OCTETSTRING };
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
231
10
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
232 CHECK( 0, fd_dict_new ( fd_g_config->cnf_dict, DICT_TYPE, &type_data , NULL, &type ) );
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
233 CHECK( 0, fd_dict_new ( fd_g_config->cnf_dict, DICT_AVP, &avp_data , type, NULL ) );
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
234 CHECK( 0, fd_dict_new ( fd_g_config->cnf_dict, DICT_ENUMVAL, &val1 , type, NULL ) );
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
235 CHECK( 0, fd_dict_new ( fd_g_config->cnf_dict, DICT_ENUMVAL, &val2 , type, NULL ) );
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
236 CHECK( 0, fd_dict_new ( fd_g_config->cnf_dict, DICT_ENUMVAL, &val3 , type, NULL ) );
0
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
237 }
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
238
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
239 {
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
240 struct dict_object * gavp = NULL;
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
241 struct dict_avp_data avp_data = { 73572, 73565, "AVP Test - grouped", AVP_FLAG_VENDOR, AVP_FLAG_VENDOR, AVP_TYPE_GROUPED };
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
242
10
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
243 CHECK( 0, fd_dict_new ( fd_g_config->cnf_dict, DICT_AVP, &avp_data , NULL, &gavp ) );
0
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
244
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
245 /* Macro to search AVP and create a rule */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
246 #define ADD_RULE( _parent, _vendor, _avpname, _pos, _min, _max, _ord ) { \
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
247 struct dict_object * _avp = NULL; \
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
248 struct dict_avp_request _req = { (_vendor), 0, (_avpname) }; \
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
249 struct dict_rule_data _data; \
10
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
250 CHECK( 0, fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME_AND_VENDOR, &_req, &_avp, ENOENT));\
0
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
251 _data.rule_avp = _avp; \
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
252 _data.rule_position = (_pos); \
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
253 _data.rule_order = (_ord); \
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
254 _data.rule_min = (_min); \
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
255 _data.rule_max = (_max); \
10
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
256 CHECK( 0, fd_dict_new ( fd_g_config->cnf_dict, DICT_RULE, &_data , (_parent), NULL ) ); \
0
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
257 }
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
258
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
259 ADD_RULE(gavp, 73565, "AVP Test - os", RULE_OPTIONAL, -1, -1, 0);
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
260
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
261 }
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
262
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
263 {
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
264 struct dict_object * application = NULL;
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
265 struct dict_object * command = NULL;
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
266 struct dict_cmd_data cmd_data = { 73573, "Test-Command-Request", CMD_FLAG_REQUEST, CMD_FLAG_REQUEST };
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
267
10
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
268 CHECK( 0, fd_dict_search ( fd_g_config->cnf_dict, DICT_APPLICATION, APPLICATION_BY_NAME, "Application test", &application, ENOENT ) );
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
269 CHECK( 0, fd_dict_new ( fd_g_config->cnf_dict, DICT_COMMAND, &cmd_data , application, &command ) );
0
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
270 ADD_RULE(command, 0, "AVP Test - no vendor - f32", RULE_FIXED_HEAD, -1, 1, 1);
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
271 ADD_RULE(command, 73565, "AVP Test - i64", RULE_REQUIRED, -1, -1, 0);
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
272 ADD_RULE(command, 73565, "AVP Test - enumi32", RULE_OPTIONAL, -1, -1, 0);
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
273 ADD_RULE(command, 73565, "AVP Test - os", RULE_OPTIONAL, -1, -1, 0);
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
274 ADD_RULE(command, 73565, "AVP Test - enumos", RULE_OPTIONAL, -1, -1, 0);
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
275 ADD_RULE(command, 73565, "AVP Test - grouped", RULE_OPTIONAL, -1, -1, 0);
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
276 }
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
277
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
278 {
890
19a261c9a2e1 Added test case to reproduce bug reported by Zack http://lists.freediameter.net/pipermail/help/2012-November/000538.html
Sebastien Decugis <sdecugis@freediameter.net>
parents: 740
diff changeset
279 struct dict_object * application = NULL;
19a261c9a2e1 Added test case to reproduce bug reported by Zack http://lists.freediameter.net/pipermail/help/2012-November/000538.html
Sebastien Decugis <sdecugis@freediameter.net>
parents: 740
diff changeset
280 struct dict_object * command = NULL;
19a261c9a2e1 Added test case to reproduce bug reported by Zack http://lists.freediameter.net/pipermail/help/2012-November/000538.html
Sebastien Decugis <sdecugis@freediameter.net>
parents: 740
diff changeset
281 struct dict_cmd_data cmd_data = { 73573, "Test-Command-Answer", CMD_FLAG_REQUEST, 0 };
19a261c9a2e1 Added test case to reproduce bug reported by Zack http://lists.freediameter.net/pipermail/help/2012-November/000538.html
Sebastien Decugis <sdecugis@freediameter.net>
parents: 740
diff changeset
282
19a261c9a2e1 Added test case to reproduce bug reported by Zack http://lists.freediameter.net/pipermail/help/2012-November/000538.html
Sebastien Decugis <sdecugis@freediameter.net>
parents: 740
diff changeset
283 CHECK( 0, fd_dict_search ( fd_g_config->cnf_dict, DICT_APPLICATION, APPLICATION_BY_NAME, "Application test", &application, ENOENT ) );
19a261c9a2e1 Added test case to reproduce bug reported by Zack http://lists.freediameter.net/pipermail/help/2012-November/000538.html
Sebastien Decugis <sdecugis@freediameter.net>
parents: 740
diff changeset
284 CHECK( 0, fd_dict_new ( fd_g_config->cnf_dict, DICT_COMMAND, &cmd_data , application, &command ) );
19a261c9a2e1 Added test case to reproduce bug reported by Zack http://lists.freediameter.net/pipermail/help/2012-November/000538.html
Sebastien Decugis <sdecugis@freediameter.net>
parents: 740
diff changeset
285 }
19a261c9a2e1 Added test case to reproduce bug reported by Zack http://lists.freediameter.net/pipermail/help/2012-November/000538.html
Sebastien Decugis <sdecugis@freediameter.net>
parents: 740
diff changeset
286
19a261c9a2e1 Added test case to reproduce bug reported by Zack http://lists.freediameter.net/pipermail/help/2012-November/000538.html
Sebastien Decugis <sdecugis@freediameter.net>
parents: 740
diff changeset
287 {
0
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
288 struct dict_object * gavp = NULL;
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
289 struct dict_avp_data avp_data = { 73574, 73565, "AVP Test - rules", AVP_FLAG_VENDOR, AVP_FLAG_VENDOR, AVP_TYPE_GROUPED };
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
290
10
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
291 CHECK( 0, fd_dict_new ( fd_g_config->cnf_dict, DICT_AVP, &avp_data , NULL, &gavp ) );
0
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
292
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
293 ADD_RULE(gavp, 0, "AVP Test - no vendor - f32", RULE_FIXED_HEAD, 0, 1, 1);
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
294 ADD_RULE(gavp, 73565, "AVP Test - i64", RULE_FIXED_HEAD, -1, 1, 2);
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
295 ADD_RULE(gavp, 73565, "AVP Test - enumi32", RULE_FIXED_HEAD, -1, 1, 3);
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
296 ADD_RULE(gavp, 73565, "AVP Test - os", RULE_REQUIRED, 2, 3, 0);
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
297 ADD_RULE(gavp, 73565, "AVP Test - enumos", RULE_OPTIONAL, 0, 1, 0);
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
298 ADD_RULE(gavp, 73565, "AVP Test - grouped", RULE_FIXED_TAIL, -1, 1, 1);
35
6486e97f56ae Added test for modified message parsing
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
299 /* ABNF :
6486e97f56ae Added test for modified message parsing
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
300 < no vendor - f32 >
6486e97f56ae Added test for modified message parsing
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
301 < i64 >
6486e97f56ae Added test for modified message parsing
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
302 < enumi32 >
6486e97f56ae Added test for modified message parsing
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
303 2*3 { os }
6486e97f56ae Added test for modified message parsing
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
304 *1 [ enumos ]
6486e97f56ae Added test for modified message parsing
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
305 < grouped >
6486e97f56ae Added test for modified message parsing
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
306 */
0
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
307 #if 0
1088
1d1a20a0779d Second part of changeset 1083, now the code compiles again. Still missing some functions implementation, though
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1047
diff changeset
308 fd_log_debug("%s", fd_dict_dump_object(FD_DUMP_TEST_PARAMS, gavp));
0
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
309 #endif
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
310 }
1300
3f1e79e1273e Added new callbacks in the derived types definitions to improve value checks during message parsing. Thanks Ranjith for the suggestion.
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1281
diff changeset
311
3f1e79e1273e Added new callbacks in the derived types definitions to improve value checks during message parsing. Thanks Ranjith for the suggestion.
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1281
diff changeset
312 {
3f1e79e1273e Added new callbacks in the derived types definitions to improve value checks during message parsing. Thanks Ranjith for the suggestion.
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1281
diff changeset
313 struct dict_object * type = NULL;
3f1e79e1273e Added new callbacks in the derived types definitions to improve value checks during message parsing. Thanks Ranjith for the suggestion.
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1281
diff changeset
314 struct dict_type_data type_data = { AVP_TYPE_OCTETSTRING, "OS test2", NULL, NULL, NULL, fd_dictfct_CharInOS_check, "@." };
3f1e79e1273e Added new callbacks in the derived types definitions to improve value checks during message parsing. Thanks Ranjith for the suggestion.
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1281
diff changeset
315 struct dict_avp_data avp_data = { 73575, 73565, "AVP Test - os2", AVP_FLAG_VENDOR, AVP_FLAG_VENDOR, AVP_TYPE_OCTETSTRING };
3f1e79e1273e Added new callbacks in the derived types definitions to improve value checks during message parsing. Thanks Ranjith for the suggestion.
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1281
diff changeset
316 CHECK( 0, fd_dict_new ( fd_g_config->cnf_dict, DICT_TYPE, &type_data , NULL, &type ) );
3f1e79e1273e Added new callbacks in the derived types definitions to improve value checks during message parsing. Thanks Ranjith for the suggestion.
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1281
diff changeset
317 CHECK( 0, fd_dict_new ( fd_g_config->cnf_dict, DICT_AVP, &avp_data , type, NULL ) );
3f1e79e1273e Added new callbacks in the derived types definitions to improve value checks during message parsing. Thanks Ranjith for the suggestion.
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1281
diff changeset
318 }
3f1e79e1273e Added new callbacks in the derived types definitions to improve value checks during message parsing. Thanks Ranjith for the suggestion.
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1281
diff changeset
319
0
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
320 #if 0
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
321 {
1088
1d1a20a0779d Second part of changeset 1083, now the code compiles again. Still missing some functions implementation, though
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1047
diff changeset
322 fd_log_debug("%s", fd_dict_dump_object(FD_DUMP_TEST_PARAMS, vendor));
0
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
323 }
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
324 #endif
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
325 }
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
326
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
327 /* Now create some values and check the length is correctly handled */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
328 {
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
329 struct dict_object * cmd_model = NULL;
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
330 struct msg * msg = NULL;
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
331 struct dict_object * avp_model = NULL;
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
332 struct avp * avp = NULL;
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
333 union avp_value value;
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
334
10
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
335 CHECK( 0, fd_dict_search ( fd_g_config->cnf_dict, DICT_COMMAND, CMD_BY_NAME, "Test-Command-Request", &cmd_model, ENOENT ) );
0
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
336
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
337 /* Check an error is trigged if the AVP has no value set */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
338 {
10
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
339 CHECK( 0, fd_dict_search ( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "AVP Test - no vendor - f32", &avp_model, ENOENT ) );
0
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
340
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
341 CHECK( 0, fd_msg_new ( cmd_model, 0, &msg ) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
342 CHECK( 0, fd_msg_avp_new ( avp_model, 0, &avp ) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
343
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
344 CHECK( 0, fd_msg_avp_add ( msg, MSG_BRW_FIRST_CHILD, avp ) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
345
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
346 CHECK( EINVAL, fd_msg_update_length ( avp ) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
347 CHECK( EINVAL, fd_msg_update_length ( msg ) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
348
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
349 CHECK( 0, fd_msg_free( msg ) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
350 }
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
351
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
352 /* Check the sizes are handled properly */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
353 {
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
354 struct avp * avpi = NULL;
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
355 struct avp * avpch = NULL;
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
356 struct avp_hdr * avpdata = NULL;
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
357 struct msg_hdr * msgdata = NULL;
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
358 #define ADD_AVP( _parent, _position, _avpi, _avpvendor, _avpname) { \
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
359 struct dict_object * _avp = NULL; \
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
360 struct dict_avp_request _req = { (_avpvendor), 0, (_avpname) }; \
10
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
361 CHECK( 0, fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME_AND_VENDOR, &_req, &_avp, ENOENT));\
0
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
362 CHECK( 0, fd_msg_avp_new ( _avp, 0, &_avpi ) ); \
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
363 CHECK( 0, fd_msg_avp_add ( (_parent), (_position), _avpi ) ); \
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
364 }
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
365 /* Create a message with many AVP inside */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
366 CHECK( 0, fd_msg_new ( cmd_model, 0, &msg ) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
367 CHECK( 0, fd_msg_hdr ( msg, &msgdata ) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
368
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
369 /* Avp no vendor, float32 => size = 12 */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
370 ADD_AVP( msg, MSG_BRW_LAST_CHILD, avpi, 0, "AVP Test - no vendor - f32" );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
371 value.f32 = 3.1415;
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
372 CHECK( 0, fd_msg_avp_setvalue ( avpi, &value ) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
373 CHECK( 0, fd_msg_update_length ( avpi ) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
374 #if 0
974
2091bf698fb1 Remove newlines from fd_log_debug, TRACE_DEBUG, TRACE_ERROR, and TRACE_DEBUG_ERROR
Thomas Klausner <tk@giga.or.at>
parents: 931
diff changeset
375 fd_log_debug("AVP no vendor, value 3.1415:");
1088
1d1a20a0779d Second part of changeset 1083, now the code compiles again. Still missing some functions implementation, though
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1047
diff changeset
376 fd_log_debug("%s", fd_msg_dump_treeview(FD_DUMP_TEST_PARAMS, avpi, fd_g_config->cnf_dict, 0, 0));
0
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
377 #endif
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
378 CHECK( 0, fd_msg_avp_hdr ( avpi, &avpdata ) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
379 CHECK( 12, avpdata->avp_len );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
380
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
381 /* Check what happens when we delete the value */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
382 CHECK( 0, fd_msg_avp_setvalue ( avpi, NULL ) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
383 CHECK( EINVAL, fd_msg_update_length ( avpi ) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
384 CHECK( 0, fd_msg_avp_setvalue ( avpi, &value ) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
385
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
386 /* Add a vendor AVP, integer64 => size = 20 */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
387 ADD_AVP( msg, MSG_BRW_LAST_CHILD, avpi, 73565, "AVP Test - i64" );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
388 value.i64 = 0x123456789abcdeLL;
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
389 CHECK( 0, fd_msg_avp_setvalue ( avpi, &value ) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
390 CHECK( 0, fd_msg_update_length ( avpi ) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
391 #if 0
974
2091bf698fb1 Remove newlines from fd_log_debug, TRACE_DEBUG, TRACE_ERROR, and TRACE_DEBUG_ERROR
Thomas Klausner <tk@giga.or.at>
parents: 931
diff changeset
392 fd_log_debug("AVP vendor, value 0x123456789abcdeL:");
1088
1d1a20a0779d Second part of changeset 1083, now the code compiles again. Still missing some functions implementation, though
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1047
diff changeset
393 fd_log_debug("%s", fd_msg_dump_treeview(FD_DUMP_TEST_PARAMS, avpi, fd_g_config->cnf_dict, 0, 0));
0
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
394 #endif
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
395 CHECK( 0, fd_msg_avp_hdr ( avpi, &avpdata ) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
396 CHECK( 20, avpdata->avp_len );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
397
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
398 /* Check the size of the message is 20 (header) + 12 + 20 = 52 */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
399 CHECK( 0, fd_msg_update_length ( msg ) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
400 CHECK( 52, msgdata->msg_length );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
401
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
402 /* Add an AVP with an enum value */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
403 ADD_AVP( msg, MSG_BRW_LAST_CHILD, avpi, 73565, "AVP Test - enumi32" );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
404 {
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
405 struct dict_object * type_model = NULL;
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
406 struct dict_object * value_model = NULL;
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
407 struct dict_enumval_request request;
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
408
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
409 CHECK( 0, fd_msg_model ( avpi, &avp_model ) );
10
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
410 CHECK( 0, fd_dict_search ( fd_g_config->cnf_dict, DICT_TYPE, TYPE_OF_AVP, avp_model, &type_model, ENOENT ) );
0
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
411 memset(&request, 0, sizeof(request));
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
412 request.type_obj = type_model;
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
413 request.search.enum_name = "i32 const test (val 2)";
10
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
414 CHECK( 0, fd_dict_search ( fd_g_config->cnf_dict, DICT_ENUMVAL, ENUMVAL_BY_STRUCT, &request, &value_model, ENOENT ) );
0
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
415 CHECK( 0, fd_dict_getval ( value_model, &request.search ) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
416 CHECK( 0, fd_msg_avp_setvalue ( avpi, &request.search.enum_value ) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
417 #if 0
974
2091bf698fb1 Remove newlines from fd_log_debug, TRACE_DEBUG, TRACE_ERROR, and TRACE_DEBUG_ERROR
Thomas Klausner <tk@giga.or.at>
parents: 931
diff changeset
418 fd_log_debug("AVP enum i32, value 2 (from const):");
1088
1d1a20a0779d Second part of changeset 1083, now the code compiles again. Still missing some functions implementation, though
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1047
diff changeset
419 fd_log_debug("%s", fd_msg_dump_treeview(FD_DUMP_TEST_PARAMS, avpi, fd_g_config->cnf_dict, 0, 0));
0
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
420 #endif
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
421 }
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
422
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
423 /* Add an AVP with an enum value, negative */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
424 ADD_AVP( msg, MSG_BRW_LAST_CHILD, avpi, 73565, "AVP Test - enumi32" );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
425 {
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
426 struct dict_object * type_model = NULL;
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
427 struct dict_object * value_model = NULL;
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
428 struct dict_enumval_request request;
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
429
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
430 CHECK( 0, fd_msg_model ( avpi, &avp_model ) );
10
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
431 CHECK( 0, fd_dict_search ( fd_g_config->cnf_dict, DICT_TYPE, TYPE_OF_AVP, avp_model, &type_model, ENOENT ) );
0
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
432 memset(&request, 0, sizeof(request));
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
433 request.type_obj = type_model;
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
434 request.search.enum_name = "i32 const test (val -5)";
10
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
435 CHECK( 0, fd_dict_search ( fd_g_config->cnf_dict, DICT_ENUMVAL, ENUMVAL_BY_STRUCT, &request, &value_model, ENOENT ) );
0
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
436 CHECK( 0, fd_dict_getval ( value_model, &request.search ) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
437 CHECK( 0, fd_msg_avp_setvalue ( avpi, &request.search.enum_value ) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
438 #if 0
974
2091bf698fb1 Remove newlines from fd_log_debug, TRACE_DEBUG, TRACE_ERROR, and TRACE_DEBUG_ERROR
Thomas Klausner <tk@giga.or.at>
parents: 931
diff changeset
439 fd_log_debug("AVP enum i32, value -5 (from const):");
1088
1d1a20a0779d Second part of changeset 1083, now the code compiles again. Still missing some functions implementation, though
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1047
diff changeset
440 fd_log_debug("%s", fd_msg_dump_treeview(FD_DUMP_TEST_PARAMS, avpi, fd_g_config->cnf_dict, 0, 0));
0
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
441 #endif
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
442 /* Check the size is correct ( 12 for header + 4 for value ) */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
443 CHECK( 0, fd_msg_update_length ( avpi ) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
444 CHECK( 0, fd_msg_avp_hdr ( avpi, &avpdata ) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
445 CHECK( 16, avpdata->avp_len );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
446 }
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
447
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
448 /* Now add a value which is not a constant into an enumerated AVP */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
449 ADD_AVP( msg, MSG_BRW_LAST_CHILD, avpi, 73565, "AVP Test - enumi32" );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
450 value.i32 = -10;
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
451 CHECK( 0, fd_msg_avp_setvalue ( avpi, &value ) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
452 CHECK( 0, fd_msg_update_length ( avpi ) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
453 #if 0
974
2091bf698fb1 Remove newlines from fd_log_debug, TRACE_DEBUG, TRACE_ERROR, and TRACE_DEBUG_ERROR
Thomas Klausner <tk@giga.or.at>
parents: 931
diff changeset
454 fd_log_debug("AVP vendor enum i32, value -10 (not const):");
1088
1d1a20a0779d Second part of changeset 1083, now the code compiles again. Still missing some functions implementation, though
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1047
diff changeset
455 fd_log_debug("%s", fd_msg_dump_treeview(FD_DUMP_TEST_PARAMS, avpi, fd_g_config->cnf_dict, 0, 0));
0
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
456 #endif
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
457
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
458 /* Add an octetstring AVP */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
459 ADD_AVP( msg, MSG_BRW_LAST_CHILD, avpi, 73565, "AVP Test - os" );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
460 {
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
461 unsigned char buf[90];
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
462 memcpy(&buf, "This\0 is a buffer of dat\a. It is not a string so we can have any c\0ntr\0l character here...\0\0", 89);
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
463 value.os.data = buf;
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
464 value.os.len = 89;
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
465 CHECK( 0, fd_msg_avp_setvalue ( avpi, &value ) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
466 memset(&buf, 0, sizeof(buf)); /* Test that the OS value is really copied */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
467 CHECK( 0, fd_msg_update_length ( avpi ) );
2
d8ce06172629 Added a global debug level var
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 1
diff changeset
468 #if 0
974
2091bf698fb1 Remove newlines from fd_log_debug, TRACE_DEBUG, TRACE_ERROR, and TRACE_DEBUG_ERROR
Thomas Klausner <tk@giga.or.at>
parents: 931
diff changeset
469 fd_log_debug("AVP octet string, 'This\\0 is a b...'");
1088
1d1a20a0779d Second part of changeset 1083, now the code compiles again. Still missing some functions implementation, though
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1047
diff changeset
470 fd_log_debug("%s", fd_msg_dump_treeview(FD_DUMP_TEST_PARAMS, avpi, fd_g_config->cnf_dict, 0, 0));
0
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
471 #endif
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
472 CHECK( 0, fd_msg_avp_hdr ( avpi, &avpdata ) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
473 CHECK( 101, avpdata->avp_len );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
474 CHECK( 'T', avpdata->avp_value->os.data[0] );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
475 CHECK( 'i', avpdata->avp_value->os.data[6] );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
476 }
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
477
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
478 /* Check the size of the message is 20 (header) + 12 + 20 + 16 * 3 + 101 + 3 (padding) = 204 */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
479 CHECK( 0, fd_msg_update_length ( msg ) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
480 CHECK( 204, msgdata->msg_length );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
481
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
482 /* Add an octetstring from an enumerated constant */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
483 ADD_AVP( msg, MSG_BRW_LAST_CHILD, avpi, 73565, "AVP Test - enumos" );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
484 {
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
485 struct dict_object * type_model = NULL;
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
486 struct dict_object * value_model = NULL;
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
487 struct dict_enumval_request request;
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
488
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
489 CHECK( 0, fd_msg_model ( avpi, &avp_model ) );
10
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
490 CHECK( 0, fd_dict_search ( fd_g_config->cnf_dict, DICT_TYPE, TYPE_OF_AVP, avp_model, &type_model, ENOENT ) );
0
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
491 memset(&request, 0, sizeof(request));
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
492 request.type_obj = type_model;
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
493 request.search.enum_name = "os const test (waaad)";
10
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
494 CHECK( 0, fd_dict_search ( fd_g_config->cnf_dict, DICT_ENUMVAL, ENUMVAL_BY_STRUCT, &request, &value_model, ENOENT ) );
0
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
495 CHECK( 0, fd_dict_getval ( value_model, &request.search ) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
496 CHECK( 0, fd_msg_avp_setvalue ( avpi, &request.search.enum_value ) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
497 #if 0
974
2091bf698fb1 Remove newlines from fd_log_debug, TRACE_DEBUG, TRACE_ERROR, and TRACE_DEBUG_ERROR
Thomas Klausner <tk@giga.or.at>
parents: 931
diff changeset
498 fd_log_debug("AVP Enumuerated OctetString (from const):");
1088
1d1a20a0779d Second part of changeset 1083, now the code compiles again. Still missing some functions implementation, though
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1047
diff changeset
499 fd_log_debug("%s", fd_msg_dump_treeview(FD_DUMP_TEST_PARAMS, avpi, fd_g_config->cnf_dict, 0, 0));
0
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
500 #endif
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
501 /* Check the size is correct ( 12 for header + 5 for value ) */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
502 CHECK( 0, fd_msg_update_length ( avpi ) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
503 CHECK( 0, fd_msg_avp_hdr ( avpi, &avpdata ) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
504 CHECK( 17, avpdata->avp_len );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
505 }
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
506
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
507 /* Add an octetstring from an enumerated constant */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
508 ADD_AVP( msg, MSG_BRW_LAST_CHILD, avpi, 73565, "AVP Test - enumos" );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
509 {
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
510 struct dict_object * type_model = NULL;
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
511 struct dict_object * value_model = NULL;
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
512 struct dict_enumval_request request;
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
513
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
514 CHECK( 0, fd_msg_model ( avpi, &avp_model ) );
10
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
515 CHECK( 0, fd_dict_search ( fd_g_config->cnf_dict, DICT_TYPE, TYPE_OF_AVP, avp_model, &type_model, ENOENT ) );
0
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
516 memset(&request, 0, sizeof(request));
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
517 request.type_obj = type_model;
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
518 request.search.enum_name = "os const test (waa)";
10
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
519 CHECK( 0, fd_dict_search ( fd_g_config->cnf_dict, DICT_ENUMVAL, ENUMVAL_BY_STRUCT, &request, &value_model, ENOENT ) );
0
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
520 CHECK( 0, fd_dict_getval ( value_model, &request.search ) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
521 CHECK( 0, fd_msg_avp_setvalue ( avpi, &request.search.enum_value ) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
522 #if 0
974
2091bf698fb1 Remove newlines from fd_log_debug, TRACE_DEBUG, TRACE_ERROR, and TRACE_DEBUG_ERROR
Thomas Klausner <tk@giga.or.at>
parents: 931
diff changeset
523 fd_log_debug("AVP Enumuerated OctetString (from const):");
1088
1d1a20a0779d Second part of changeset 1083, now the code compiles again. Still missing some functions implementation, though
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1047
diff changeset
524 fd_log_debug("%s", fd_msg_dump_treeview(FD_DUMP_TEST_PARAMS, avpi, fd_g_config->cnf_dict, 0, 0));
0
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
525 #endif
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
526 /* Check the size is correct ( 12 for header + 3 for value ) */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
527 CHECK( 0, fd_msg_update_length ( avpi ) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
528 CHECK( 0, fd_msg_avp_hdr ( avpi, &avpdata ) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
529 CHECK( 15, avpdata->avp_len );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
530 }
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
531
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
532
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
533 /* Check the size of the message is 20 (header) + 12 + 20 + 16 * 3 + (101 + 3) + (17 + 3) + (15 + 1) = 240 */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
534 CHECK( 0, fd_msg_update_length ( msg ) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
535 CHECK( 240, msgdata->msg_length );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
536
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
537 /* Now test the grouped AVPs */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
538 ADD_AVP( msg, MSG_BRW_LAST_CHILD, avpi, 73565, "AVP Test - grouped" );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
539 ADD_AVP( avpi, MSG_BRW_LAST_CHILD, avpch, 73565, "AVP Test - os" );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
540 {
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
541 value.os.data = (unsigned char *)"12345678";
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
542 value.os.len = 8;
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
543 CHECK( 0, fd_msg_avp_setvalue ( avpch, &value ) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
544 #if 0
974
2091bf698fb1 Remove newlines from fd_log_debug, TRACE_DEBUG, TRACE_ERROR, and TRACE_DEBUG_ERROR
Thomas Klausner <tk@giga.or.at>
parents: 931
diff changeset
545 fd_log_debug("AVP octet string, '1234678'");
1088
1d1a20a0779d Second part of changeset 1083, now the code compiles again. Still missing some functions implementation, though
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1047
diff changeset
546 fd_log_debug("%s", fd_msg_dump_treeview(FD_DUMP_TEST_PARAMS, avpch, fd_g_config->cnf_dict, 0, 0));
0
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
547 #endif
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
548 CHECK( 0, fd_msg_update_length ( avpch ) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
549 CHECK( 0, fd_msg_avp_hdr ( avpch, &avpdata ) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
550 CHECK( 20, avpdata->avp_len );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
551 }
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
552 ADD_AVP( avpi, MSG_BRW_LAST_CHILD, avpch, 73565, "AVP Test - os" );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
553 {
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
554 value.os.data = (unsigned char *)"123456789";
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
555 value.os.len = 9;
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
556 CHECK( 0, fd_msg_avp_setvalue ( avpch, &value ) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
557 #if 0
974
2091bf698fb1 Remove newlines from fd_log_debug, TRACE_DEBUG, TRACE_ERROR, and TRACE_DEBUG_ERROR
Thomas Klausner <tk@giga.or.at>
parents: 931
diff changeset
558 fd_log_debug("AVP octet string, '12346789'");
1088
1d1a20a0779d Second part of changeset 1083, now the code compiles again. Still missing some functions implementation, though
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1047
diff changeset
559 fd_log_debug("%s", fd_msg_dump_treeview(FD_DUMP_TEST_PARAMS, avpch, fd_g_config->cnf_dict, 0, 0));
0
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
560 #endif
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
561 }
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
562
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
563 /* Check the size is updated recursively: (gavp hdr: 12) + (avp1: 20) + (avp2: 21 + 3) = 56 */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
564 CHECK( 0, fd_msg_update_length ( avpi ) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
565 CHECK( 0, fd_msg_avp_hdr ( avpi, &avpdata ) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
566 CHECK( 56, avpdata->avp_len );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
567
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
568 /* Add another similar grouped AVP, to have lot of padding */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
569 ADD_AVP( msg, MSG_BRW_LAST_CHILD, avpi, 73565, "AVP Test - grouped" );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
570 ADD_AVP( avpi, MSG_BRW_LAST_CHILD, avpch, 73565, "AVP Test - os" );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
571 {
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
572 value.os.data = (unsigned char *)"1";
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
573 value.os.len = 1;
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
574 CHECK( 0, fd_msg_avp_setvalue ( avpch, &value ) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
575 }
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
576 ADD_AVP( avpi, MSG_BRW_LAST_CHILD, avpch, 73565, "AVP Test - os" );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
577 {
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
578 value.os.data = (unsigned char *)"1234567";
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
579 value.os.len = 7;
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
580 CHECK( 0, fd_msg_avp_setvalue ( avpch, &value ) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
581 }
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
582
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
583 /* Now check the global size of the message, if padding is correctly handled */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
584 /* size = 20 (header) + 12 + 20 + 16 * 3 + (101 + 3) + (17 + 3) + (15 + 1)
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
585 * + ( 12 + ( 20 + 21) + 3 ) # padding for the grouped AVP = 3
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
586 * + ( 12 + ( (13 + 3) + 19 ) + 1 ) # and 1 for this one
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
587 * size = 240 + 56 + 48 = 344
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
588 */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
589 CHECK( 0, fd_msg_update_length ( msg ) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
590 #if 0
1088
1d1a20a0779d Second part of changeset 1083, now the code compiles again. Still missing some functions implementation, though
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1047
diff changeset
591 fd_log_debug("%s", fd_msg_dump_treeview(FD_DUMP_TEST_PARAMS, msg, fd_g_config->cnf_dict, 0, 1));
0
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
592 #endif
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
593 CHECK( 344, msgdata->msg_length );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
594
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
595 /* Set the application to the test application: 73566 */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
596 msgdata->msg_appl = 73566;
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
597
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
598 /* Set the hop-by-hop ID to a random value: 0x4b44b41d */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
599 msgdata->msg_hbhid = 0x4b44b41d;
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
600 /* Set the end-to-end ID to a random value: 0xe2ee2e1d */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
601 msgdata->msg_eteid = 0xe2ee2e1d;
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
602 }
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
603
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
604 /* Test the msg_bufferize function */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
605 {
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
606
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
607 CHECK( 0, fd_msg_bufferize( msg, &buf, NULL ) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
608
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
609 /* Test the first bytes */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
610 CHECK( 0x01, buf[0] ); /* Version */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
611 CHECK( 0x00, buf[1] ); /* Length: 344 = 0x000158 */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
612 CHECK( 0x01, buf[2] );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
613 CHECK( 0x58, buf[3] );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
614 CHECK( 0x80, buf[4] ); /* flags: only "R" is set. */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
615 CHECK( 0x01, buf[5] ); /* Command code: 73573 = 0x011F65 */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
616 CHECK( 0x1F, buf[6] );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
617 CHECK( 0x65, buf[7] );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
618 CHECK( 0x00, buf[8] ); /* App ID: 73566 = 0x00011F5E */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
619 CHECK( 0x01, buf[9] );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
620 CHECK( 0x1F, buf[10] );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
621 CHECK( 0x5E, buf[11] );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
622 CHECK( 0x4b, buf[12] ); /* hop-by-hop id: 0x4b44b41d */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
623 CHECK( 0x44, buf[13] );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
624 CHECK( 0xb4, buf[14] );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
625 CHECK( 0x1d, buf[15] );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
626 CHECK( 0xe2, buf[16] ); /* end-to-end id: 0xe2ee2e1d */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
627 CHECK( 0xee, buf[17] );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
628 CHECK( 0x2e, buf[18] );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
629 CHECK( 0x1d, buf[19] );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
630
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
631 CHECK( 0x00, buf[20] ); /* First AVP (AVP Test - no vendor - f32) begin: code 73567 = 0x00011F5F */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
632 CHECK( 0x01, buf[21] );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
633 CHECK( 0x1F, buf[22] );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
634 CHECK( 0x5F, buf[23] );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
635 CHECK( 0x00, buf[24] ); /* flags: 0 */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
636 CHECK( 0x00, buf[25] ); /* length: 12 = 0x00000c */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
637 CHECK( 0x00, buf[26] );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
638 CHECK( 0x0C, buf[27] );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
639 CHECK( 0x40, buf[28] ); /* Value: 3.1415: sign = '+' => most significant bit = 0 */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
640 CHECK( 0x49, buf[29] ); /* 2 <= 3.1415 < 4 => exponent = 1 => biaised (on 8 bits) = (decimal) 128 = (binary) 100 0000 0 */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
641 CHECK( 0x0e, buf[30] ); /* significand = (decimal) 1.57075 = (binary) 1.100 1001 0000 1110 0101 0110 */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
642 CHECK( 0x56, buf[31] ); /* total => 0100 0000 0100 1001 0000 1110 0101 0110 = (hexa) 40 49 0e 56*/
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
643
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
644 /* The other AVPs will be tested by successful parsing... */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
645 }
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
646
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
647 /* Now free the message, we keep only the buffer. */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
648 CHECK( 0, fd_msg_free( msg ) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
649
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
650 }
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
651
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
652 /* Test the parsing of buffers and messages */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
653 {
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
654 unsigned char * buf_cpy = NULL;
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
655 struct msg * msg;
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
656
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
657 #define CPYBUF() { \
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
658 buf_cpy = malloc(344); \
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
659 CHECK( buf_cpy ? 1 : 0, 1); \
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
660 memcpy(buf_cpy, buf, 344); \
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
661 }
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
662
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
663 /* Test the msg_parse_buffer function */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
664 {
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
665 CPYBUF();
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
666 CHECK( EBADMSG, fd_msg_parse_buffer( &buf_cpy, 340, &msg) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
667
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
668 CPYBUF();
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
669 CHECK( 0, fd_msg_parse_buffer( &buf_cpy, 344, &msg) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
670 #if 0
1088
1d1a20a0779d Second part of changeset 1083, now the code compiles again. Still missing some functions implementation, though
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1047
diff changeset
671 fd_log_debug("%s", fd_msg_dump_treeview(FD_DUMP_TEST_PARAMS, msg, fd_g_config->cnf_dict, 0, 1));
0
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
672 #endif
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
673
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
674 /* reinit the msg */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
675 CHECK( 0, fd_msg_free ( msg ) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
676
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
677 }
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
678
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
679 /* Test the fd_msg_search_avp function */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
680 {
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
681 struct dict_object * avp_model;
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
682 struct avp * found;
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
683 struct avp_hdr * avpdata = NULL;
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
684
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
685 /* Now find the ACR dictionary object */
10
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
686 CHECK( 0, fd_dict_search ( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "AVP Test - no vendor - f32", &avp_model, ENOENT ) );
0
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
687
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
688 CPYBUF();
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
689 CHECK( 0, fd_msg_parse_buffer( &buf_cpy, 344, &msg) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
690
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
691 /* Search this AVP instance in the msg */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
692 CHECK( 0, fd_msg_search_avp( msg, avp_model, &found ) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
693
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
694 /* Check the AVP value is 3.1415 */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
695 CHECK( 0, fd_msg_avp_hdr ( found, &avpdata ) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
696 CHECK( 3.1415F, avpdata->avp_value->f32 );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
697
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
698 /* reinit the msg */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
699 CHECK( 0, fd_msg_free ( msg ) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
700
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
701 }
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
702
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
703 /* Test the msg_parse_dict function */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
704 {
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
705 /* Test with an unknown command code */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
706 {
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
707 CPYBUF();
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
708
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
709 /* Change the command-code */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
710 buf_cpy[5] = 0x11;
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
711 CHECK( 0, fd_msg_parse_buffer( &buf_cpy, 344, &msg) );
114
5b3868944e2b Reporting errors in parse_dict function
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 35
diff changeset
712 CHECK( ENOTSUP, fd_msg_parse_dict( msg, fd_g_config->cnf_dict, NULL ) );
0
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
713
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
714 /* reset */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
715 CHECK( 0, fd_msg_free ( msg ) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
716 }
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
717
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
718 /* Test with an unknown Mandatory AVP */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
719 {
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
720 CPYBUF();
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
721
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
722 buf_cpy[20] = 0x11; /* New AVP code = 0x11011F5F, undefined */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
723 buf_cpy[24] = 0x40; /* Add the 'M' flag */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
724
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
725 /* Check that we cannot support this message now */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
726 CHECK( 0, fd_msg_parse_buffer( &buf_cpy, 344, &msg) );
114
5b3868944e2b Reporting errors in parse_dict function
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 35
diff changeset
727 CHECK( ENOTSUP, fd_msg_parse_dict( msg, fd_g_config->cnf_dict, NULL ) );
0
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
728
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
729 /* reset */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
730 CHECK( 0, fd_msg_free ( msg ) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
731 }
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
732
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
733 /* Test with an unknown optional AVP */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
734 {
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
735 CPYBUF();
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
736
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
737 buf_cpy[20] = 0x11; /* New AVP code = 0x11011F5F, undefined */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
738
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
739 /* Check that we can support this message now */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
740 CHECK( 0, fd_msg_parse_buffer( &buf_cpy, 344, &msg) );
114
5b3868944e2b Reporting errors in parse_dict function
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 35
diff changeset
741 CHECK( 0, fd_msg_parse_dict( msg, fd_g_config->cnf_dict, NULL ) );
0
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
742
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
743 #if 0
1088
1d1a20a0779d Second part of changeset 1083, now the code compiles again. Still missing some functions implementation, though
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1047
diff changeset
744 fd_log_debug("%s", fd_msg_dump_treeview(FD_DUMP_TEST_PARAMS, msg, fd_g_config->cnf_dict, 0, 1));
0
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
745 #endif
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
746
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
747 /* reset */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
748 CHECK( 0, fd_msg_free ( msg ) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
749 }
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
750
890
19a261c9a2e1 Added test case to reproduce bug reported by Zack http://lists.freediameter.net/pipermail/help/2012-November/000538.html
Sebastien Decugis <sdecugis@freediameter.net>
parents: 740
diff changeset
751 /* Test with an invalid AVP (definition mismatch with the dictionary) */
19a261c9a2e1 Added test case to reproduce bug reported by Zack http://lists.freediameter.net/pipermail/help/2012-November/000538.html
Sebastien Decugis <sdecugis@freediameter.net>
parents: 740
diff changeset
752 {
19a261c9a2e1 Added test case to reproduce bug reported by Zack http://lists.freediameter.net/pipermail/help/2012-November/000538.html
Sebastien Decugis <sdecugis@freediameter.net>
parents: 740
diff changeset
753 CPYBUF();
19a261c9a2e1 Added test case to reproduce bug reported by Zack http://lists.freediameter.net/pipermail/help/2012-November/000538.html
Sebastien Decugis <sdecugis@freediameter.net>
parents: 740
diff changeset
754
19a261c9a2e1 Added test case to reproduce bug reported by Zack http://lists.freediameter.net/pipermail/help/2012-November/000538.html
Sebastien Decugis <sdecugis@freediameter.net>
parents: 740
diff changeset
755 buf_cpy[21] = 0x02; /* New AVP code = 0x00021F5F, f64 type in the dictionary */
19a261c9a2e1 Added test case to reproduce bug reported by Zack http://lists.freediameter.net/pipermail/help/2012-November/000538.html
Sebastien Decugis <sdecugis@freediameter.net>
parents: 740
diff changeset
756
19a261c9a2e1 Added test case to reproduce bug reported by Zack http://lists.freediameter.net/pipermail/help/2012-November/000538.html
Sebastien Decugis <sdecugis@freediameter.net>
parents: 740
diff changeset
757
19a261c9a2e1 Added test case to reproduce bug reported by Zack http://lists.freediameter.net/pipermail/help/2012-November/000538.html
Sebastien Decugis <sdecugis@freediameter.net>
parents: 740
diff changeset
758 /* Check that we cannot support this message now */
19a261c9a2e1 Added test case to reproduce bug reported by Zack http://lists.freediameter.net/pipermail/help/2012-November/000538.html
Sebastien Decugis <sdecugis@freediameter.net>
parents: 740
diff changeset
759 CHECK( 0, fd_msg_parse_buffer( &buf_cpy, 344, &msg) );
19a261c9a2e1 Added test case to reproduce bug reported by Zack http://lists.freediameter.net/pipermail/help/2012-November/000538.html
Sebastien Decugis <sdecugis@freediameter.net>
parents: 740
diff changeset
760 CHECK( EBADMSG, fd_msg_parse_dict( msg, fd_g_config->cnf_dict, NULL ) );
19a261c9a2e1 Added test case to reproduce bug reported by Zack http://lists.freediameter.net/pipermail/help/2012-November/000538.html
Sebastien Decugis <sdecugis@freediameter.net>
parents: 740
diff changeset
761
19a261c9a2e1 Added test case to reproduce bug reported by Zack http://lists.freediameter.net/pipermail/help/2012-November/000538.html
Sebastien Decugis <sdecugis@freediameter.net>
parents: 740
diff changeset
762 /* reset */
19a261c9a2e1 Added test case to reproduce bug reported by Zack http://lists.freediameter.net/pipermail/help/2012-November/000538.html
Sebastien Decugis <sdecugis@freediameter.net>
parents: 740
diff changeset
763 CHECK( 0, fd_msg_free ( msg ) );
19a261c9a2e1 Added test case to reproduce bug reported by Zack http://lists.freediameter.net/pipermail/help/2012-November/000538.html
Sebastien Decugis <sdecugis@freediameter.net>
parents: 740
diff changeset
764 }
19a261c9a2e1 Added test case to reproduce bug reported by Zack http://lists.freediameter.net/pipermail/help/2012-November/000538.html
Sebastien Decugis <sdecugis@freediameter.net>
parents: 740
diff changeset
765
1300
3f1e79e1273e Added new callbacks in the derived types definitions to improve value checks during message parsing. Thanks Ranjith for the suggestion.
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1281
diff changeset
766 /* Test with a type verifier */
3f1e79e1273e Added new callbacks in the derived types definitions to improve value checks during message parsing. Thanks Ranjith for the suggestion.
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1281
diff changeset
767 {
3f1e79e1273e Added new callbacks in the derived types definitions to improve value checks during message parsing. Thanks Ranjith for the suggestion.
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1281
diff changeset
768 struct fd_pei error_info;
3f1e79e1273e Added new callbacks in the derived types definitions to improve value checks during message parsing. Thanks Ranjith for the suggestion.
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1281
diff changeset
769 CPYBUF();
3f1e79e1273e Added new callbacks in the derived types definitions to improve value checks during message parsing. Thanks Ranjith for the suggestion.
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1281
diff changeset
770 buf_cpy[103] = 0x67; /* Replaced AVP code = 0x00011F67, OS test2 type in the dictionary */
3f1e79e1273e Added new callbacks in the derived types definitions to improve value checks during message parsing. Thanks Ranjith for the suggestion.
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1281
diff changeset
771
3f1e79e1273e Added new callbacks in the derived types definitions to improve value checks during message parsing. Thanks Ranjith for the suggestion.
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1281
diff changeset
772 /* Check that we cannot support this message now */
3f1e79e1273e Added new callbacks in the derived types definitions to improve value checks during message parsing. Thanks Ranjith for the suggestion.
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1281
diff changeset
773 CHECK( 0, fd_msg_parse_buffer( &buf_cpy, 344, &msg) );
3f1e79e1273e Added new callbacks in the derived types definitions to improve value checks during message parsing. Thanks Ranjith for the suggestion.
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1281
diff changeset
774 CHECK( EBADMSG, fd_msg_parse_dict( msg, fd_g_config->cnf_dict, NULL ) );
3f1e79e1273e Added new callbacks in the derived types definitions to improve value checks during message parsing. Thanks Ranjith for the suggestion.
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1281
diff changeset
775
3f1e79e1273e Added new callbacks in the derived types definitions to improve value checks during message parsing. Thanks Ranjith for the suggestion.
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1281
diff changeset
776 /* reset */
3f1e79e1273e Added new callbacks in the derived types definitions to improve value checks during message parsing. Thanks Ranjith for the suggestion.
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1281
diff changeset
777 CHECK( 0, fd_msg_free ( msg ) );
3f1e79e1273e Added new callbacks in the derived types definitions to improve value checks during message parsing. Thanks Ranjith for the suggestion.
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1281
diff changeset
778
3f1e79e1273e Added new callbacks in the derived types definitions to improve value checks during message parsing. Thanks Ranjith for the suggestion.
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1281
diff changeset
779 CPYBUF();
3f1e79e1273e Added new callbacks in the derived types definitions to improve value checks during message parsing. Thanks Ranjith for the suggestion.
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1281
diff changeset
780 buf_cpy[103] = 0x67; /* Replaced AVP code = 0x00011F67, OS test2 type in the dictionary */
3f1e79e1273e Added new callbacks in the derived types definitions to improve value checks during message parsing. Thanks Ranjith for the suggestion.
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1281
diff changeset
781
3f1e79e1273e Added new callbacks in the derived types definitions to improve value checks during message parsing. Thanks Ranjith for the suggestion.
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1281
diff changeset
782 /* Check error reporting works */
3f1e79e1273e Added new callbacks in the derived types definitions to improve value checks during message parsing. Thanks Ranjith for the suggestion.
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1281
diff changeset
783 CHECK( 0, fd_msg_parse_buffer( &buf_cpy, 344, &msg) );
3f1e79e1273e Added new callbacks in the derived types definitions to improve value checks during message parsing. Thanks Ranjith for the suggestion.
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1281
diff changeset
784 CHECK( EBADMSG, fd_msg_parse_dict( msg, fd_g_config->cnf_dict, &error_info ) );
3f1e79e1273e Added new callbacks in the derived types definitions to improve value checks during message parsing. Thanks Ranjith for the suggestion.
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1281
diff changeset
785
3f1e79e1273e Added new callbacks in the derived types definitions to improve value checks during message parsing. Thanks Ranjith for the suggestion.
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1281
diff changeset
786 #if 1
3f1e79e1273e Added new callbacks in the derived types definitions to improve value checks during message parsing. Thanks Ranjith for the suggestion.
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1281
diff changeset
787 fd_log_debug("Error reported: %s\n in AVP: %s", error_info.pei_message, fd_msg_dump_treeview(FD_DUMP_TEST_PARAMS, error_info.pei_avp, fd_g_config->cnf_dict, 0, 1));
3f1e79e1273e Added new callbacks in the derived types definitions to improve value checks during message parsing. Thanks Ranjith for the suggestion.
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1281
diff changeset
788 #endif
3f1e79e1273e Added new callbacks in the derived types definitions to improve value checks during message parsing. Thanks Ranjith for the suggestion.
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1281
diff changeset
789
3f1e79e1273e Added new callbacks in the derived types definitions to improve value checks during message parsing. Thanks Ranjith for the suggestion.
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1281
diff changeset
790 /* reset */
3f1e79e1273e Added new callbacks in the derived types definitions to improve value checks during message parsing. Thanks Ranjith for the suggestion.
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1281
diff changeset
791 CHECK( 0, fd_msg_free ( msg ) );
3f1e79e1273e Added new callbacks in the derived types definitions to improve value checks during message parsing. Thanks Ranjith for the suggestion.
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1281
diff changeset
792
3f1e79e1273e Added new callbacks in the derived types definitions to improve value checks during message parsing. Thanks Ranjith for the suggestion.
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1281
diff changeset
793 CPYBUF();
3f1e79e1273e Added new callbacks in the derived types definitions to improve value checks during message parsing. Thanks Ranjith for the suggestion.
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1281
diff changeset
794 buf_cpy[103] = 0x67; /* Replaced AVP code = 0x00011F67, OS test2 type in the dictionary */
3f1e79e1273e Added new callbacks in the derived types definitions to improve value checks during message parsing. Thanks Ranjith for the suggestion.
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1281
diff changeset
795 buf_cpy[130] = '@';
3f1e79e1273e Added new callbacks in the derived types definitions to improve value checks during message parsing. Thanks Ranjith for the suggestion.
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1281
diff changeset
796 buf_cpy[140] = '.'; /* now we comply to the constraints */
3f1e79e1273e Added new callbacks in the derived types definitions to improve value checks during message parsing. Thanks Ranjith for the suggestion.
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1281
diff changeset
797
3f1e79e1273e Added new callbacks in the derived types definitions to improve value checks during message parsing. Thanks Ranjith for the suggestion.
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1281
diff changeset
798 /* Check that we cannot support this message now */
3f1e79e1273e Added new callbacks in the derived types definitions to improve value checks during message parsing. Thanks Ranjith for the suggestion.
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1281
diff changeset
799 CHECK( 0, fd_msg_parse_buffer( &buf_cpy, 344, &msg) );
3f1e79e1273e Added new callbacks in the derived types definitions to improve value checks during message parsing. Thanks Ranjith for the suggestion.
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1281
diff changeset
800 CHECK( 0, fd_msg_parse_dict( msg, fd_g_config->cnf_dict, NULL ) );
3f1e79e1273e Added new callbacks in the derived types definitions to improve value checks during message parsing. Thanks Ranjith for the suggestion.
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1281
diff changeset
801
3f1e79e1273e Added new callbacks in the derived types definitions to improve value checks during message parsing. Thanks Ranjith for the suggestion.
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1281
diff changeset
802 /* reset */
3f1e79e1273e Added new callbacks in the derived types definitions to improve value checks during message parsing. Thanks Ranjith for the suggestion.
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1281
diff changeset
803 CHECK( 0, fd_msg_free ( msg ) );
3f1e79e1273e Added new callbacks in the derived types definitions to improve value checks during message parsing. Thanks Ranjith for the suggestion.
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1281
diff changeset
804
3f1e79e1273e Added new callbacks in the derived types definitions to improve value checks during message parsing. Thanks Ranjith for the suggestion.
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1281
diff changeset
805
3f1e79e1273e Added new callbacks in the derived types definitions to improve value checks during message parsing. Thanks Ranjith for the suggestion.
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1281
diff changeset
806 }
3f1e79e1273e Added new callbacks in the derived types definitions to improve value checks during message parsing. Thanks Ranjith for the suggestion.
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1281
diff changeset
807
890
19a261c9a2e1 Added test case to reproduce bug reported by Zack http://lists.freediameter.net/pipermail/help/2012-November/000538.html
Sebastien Decugis <sdecugis@freediameter.net>
parents: 740
diff changeset
808 {
892
b2e8f1a3ef76 Allow the content of the Failed-AVP to be parseable to bufferize the message. The content is only padded currently
Sebastien Decugis <sdecugis@freediameter.net>
parents: 891
diff changeset
809 unsigned char * buftmp = NULL;
1103
d8591b1c56cd Implemented a few hooks
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1088
diff changeset
810 struct msg * error;
890
19a261c9a2e1 Added test case to reproduce bug reported by Zack http://lists.freediameter.net/pipermail/help/2012-November/000538.html
Sebastien Decugis <sdecugis@freediameter.net>
parents: 740
diff changeset
811 /* Check the parse or error works as expected */
19a261c9a2e1 Added test case to reproduce bug reported by Zack http://lists.freediameter.net/pipermail/help/2012-November/000538.html
Sebastien Decugis <sdecugis@freediameter.net>
parents: 740
diff changeset
812 CPYBUF();
19a261c9a2e1 Added test case to reproduce bug reported by Zack http://lists.freediameter.net/pipermail/help/2012-November/000538.html
Sebastien Decugis <sdecugis@freediameter.net>
parents: 740
diff changeset
813
19a261c9a2e1 Added test case to reproduce bug reported by Zack http://lists.freediameter.net/pipermail/help/2012-November/000538.html
Sebastien Decugis <sdecugis@freediameter.net>
parents: 740
diff changeset
814 buf_cpy[21] = 0x02; /* New AVP code = 0x00021F5F, f64 type in the dictionary */
19a261c9a2e1 Added test case to reproduce bug reported by Zack http://lists.freediameter.net/pipermail/help/2012-November/000538.html
Sebastien Decugis <sdecugis@freediameter.net>
parents: 740
diff changeset
815
19a261c9a2e1 Added test case to reproduce bug reported by Zack http://lists.freediameter.net/pipermail/help/2012-November/000538.html
Sebastien Decugis <sdecugis@freediameter.net>
parents: 740
diff changeset
816 /* Check that we cannot support this message now */
19a261c9a2e1 Added test case to reproduce bug reported by Zack http://lists.freediameter.net/pipermail/help/2012-November/000538.html
Sebastien Decugis <sdecugis@freediameter.net>
parents: 740
diff changeset
817 CHECK( 0, fd_msg_init() );
19a261c9a2e1 Added test case to reproduce bug reported by Zack http://lists.freediameter.net/pipermail/help/2012-November/000538.html
Sebastien Decugis <sdecugis@freediameter.net>
parents: 740
diff changeset
818 CHECK( 0, fd_msg_parse_buffer( &buf_cpy, 344, &msg) );
1103
d8591b1c56cd Implemented a few hooks
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1088
diff changeset
819 CHECK( EBADMSG, fd_msg_parse_or_error( &msg, &error ) );
d8591b1c56cd Implemented a few hooks
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1088
diff changeset
820 CHECK( NULL, msg );
d8591b1c56cd Implemented a few hooks
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1088
diff changeset
821 msg = error;
890
19a261c9a2e1 Added test case to reproduce bug reported by Zack http://lists.freediameter.net/pipermail/help/2012-November/000538.html
Sebastien Decugis <sdecugis@freediameter.net>
parents: 740
diff changeset
822
892
b2e8f1a3ef76 Allow the content of the Failed-AVP to be parseable to bufferize the message. The content is only padded currently
Sebastien Decugis <sdecugis@freediameter.net>
parents: 891
diff changeset
823 CHECK( 0, fd_msg_bufferize( msg, &buftmp, NULL ) );
890
19a261c9a2e1 Added test case to reproduce bug reported by Zack http://lists.freediameter.net/pipermail/help/2012-November/000538.html
Sebastien Decugis <sdecugis@freediameter.net>
parents: 740
diff changeset
824
1088
1d1a20a0779d Second part of changeset 1083, now the code compiles again. Still missing some functions implementation, though
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1047
diff changeset
825 fd_log_debug("%s", fd_msg_dump_treeview(FD_DUMP_TEST_PARAMS, msg, fd_g_config->cnf_dict, 0, 1));
890
19a261c9a2e1 Added test case to reproduce bug reported by Zack http://lists.freediameter.net/pipermail/help/2012-November/000538.html
Sebastien Decugis <sdecugis@freediameter.net>
parents: 740
diff changeset
826
892
b2e8f1a3ef76 Allow the content of the Failed-AVP to be parseable to bufferize the message. The content is only padded currently
Sebastien Decugis <sdecugis@freediameter.net>
parents: 891
diff changeset
827 TODO("Check the Failed-AVP is as expected");
b2e8f1a3ef76 Allow the content of the Failed-AVP to be parseable to bufferize the message. The content is only padded currently
Sebastien Decugis <sdecugis@freediameter.net>
parents: 891
diff changeset
828
b2e8f1a3ef76 Allow the content of the Failed-AVP to be parseable to bufferize the message. The content is only padded currently
Sebastien Decugis <sdecugis@freediameter.net>
parents: 891
diff changeset
829
890
19a261c9a2e1 Added test case to reproduce bug reported by Zack http://lists.freediameter.net/pipermail/help/2012-November/000538.html
Sebastien Decugis <sdecugis@freediameter.net>
parents: 740
diff changeset
830 /* reset */
19a261c9a2e1 Added test case to reproduce bug reported by Zack http://lists.freediameter.net/pipermail/help/2012-November/000538.html
Sebastien Decugis <sdecugis@freediameter.net>
parents: 740
diff changeset
831 CHECK( 0, fd_msg_free ( msg ) );
892
b2e8f1a3ef76 Allow the content of the Failed-AVP to be parseable to bufferize the message. The content is only padded currently
Sebastien Decugis <sdecugis@freediameter.net>
parents: 891
diff changeset
832 free(buftmp);
890
19a261c9a2e1 Added test case to reproduce bug reported by Zack http://lists.freediameter.net/pipermail/help/2012-November/000538.html
Sebastien Decugis <sdecugis@freediameter.net>
parents: 740
diff changeset
833 }
19a261c9a2e1 Added test case to reproduce bug reported by Zack http://lists.freediameter.net/pipermail/help/2012-November/000538.html
Sebastien Decugis <sdecugis@freediameter.net>
parents: 740
diff changeset
834
19a261c9a2e1 Added test case to reproduce bug reported by Zack http://lists.freediameter.net/pipermail/help/2012-November/000538.html
Sebastien Decugis <sdecugis@freediameter.net>
parents: 740
diff changeset
835
0
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
836 CHECK( 0, fd_msg_parse_buffer( &buf, 344, &msg) );
114
5b3868944e2b Reporting errors in parse_dict function
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 35
diff changeset
837 CHECK( 0, fd_msg_parse_dict( msg, fd_g_config->cnf_dict, NULL ) );
0
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
838 #if 0
1088
1d1a20a0779d Second part of changeset 1083, now the code compiles again. Still missing some functions implementation, though
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1047
diff changeset
839 fd_log_debug("%s", fd_msg_dump_treeview(FD_DUMP_TEST_PARAMS, msg, fd_g_config->cnf_dict, 0, 1));
0
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
840 #endif
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
841 }
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
842
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
843 /* Now test the msg_parse_rule function */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
844 {
35
6486e97f56ae Added test for modified message parsing
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
845 struct fd_pei pei;
0
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
846
35
6486e97f56ae Added test for modified message parsing
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
847 CHECK( 0, fd_msg_parse_rules( msg, fd_g_config->cnf_dict, &pei ) );
0
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
848
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
849 /* Use the "AVP Test - rules" AVP to test the rules */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
850 {
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
851 struct avp * tavp = NULL;
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
852 struct avp * tempavp = NULL;
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
853 struct avp * childavp = NULL;
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
854
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
855 ADD_AVP( msg, MSG_BRW_LAST_CHILD, tavp, 73565, "AVP Test - rules" );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
856
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
857 /* Create a conforming message first */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
858 ADD_AVP( tavp, MSG_BRW_LAST_CHILD, childavp, 0, "AVP Test - no vendor - f32" );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
859 ADD_AVP( tavp, MSG_BRW_LAST_CHILD, childavp, 73565, "AVP Test - i64" );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
860 ADD_AVP( tavp, MSG_BRW_LAST_CHILD, childavp, 73565, "AVP Test - enumi32" );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
861 ADD_AVP( tavp, MSG_BRW_LAST_CHILD, childavp, 73565, "AVP Test - os" );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
862 ADD_AVP( tavp, MSG_BRW_LAST_CHILD, childavp, 73565, "AVP Test - os" );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
863 ADD_AVP( tavp, MSG_BRW_LAST_CHILD, childavp, 73565, "AVP Test - grouped" );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
864
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
865 /* Check the message is still conform */
35
6486e97f56ae Added test for modified message parsing
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
866 CHECK( 0, fd_msg_parse_rules( msg, fd_g_config->cnf_dict, &pei ) );
0
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
867
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
868 /* The first avp is optional in fixed position, so remove it and check the message is still OK */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
869 CHECK( 0, fd_msg_browse ( tavp, MSG_BRW_FIRST_CHILD, &childavp, NULL) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
870 CHECK( 0, fd_msg_free ( childavp ) );
35
6486e97f56ae Added test for modified message parsing
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
871 CHECK( 0, fd_msg_parse_rules( msg, fd_g_config->cnf_dict, &pei ) );
0
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
872 ADD_AVP( tavp, MSG_BRW_FIRST_CHILD, childavp, 0, "AVP Test - no vendor - f32" );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
873
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
874
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
875 /* Now break some rules and check it is detected */
35
6486e97f56ae Added test for modified message parsing
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
876 #define CHECK_CONFLICT( _msg, _error, _conflictavp_name, _conflictavp_vnd ) { \
6486e97f56ae Added test for modified message parsing
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
877 struct fd_pei _pei; \
6486e97f56ae Added test for modified message parsing
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
878 CHECK( EBADMSG, fd_msg_parse_rules( _msg, fd_g_config->cnf_dict, &_pei ) ); \
6486e97f56ae Added test for modified message parsing
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
879 if (_error) { \
6486e97f56ae Added test for modified message parsing
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
880 CHECK( 0, strcmp( _error, _pei.pei_errcode ) ); \
6486e97f56ae Added test for modified message parsing
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
881 } \
6486e97f56ae Added test for modified message parsing
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
882 if ((_conflictavp_name) == NULL) { \
6486e97f56ae Added test for modified message parsing
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
883 CHECK( NULL, _pei.pei_avp); \
0
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
884 } else { \
35
6486e97f56ae Added test for modified message parsing
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
885 struct dict_avp_request _req = { (_conflictavp_vnd), 0, (_conflictavp_name) }; \
0
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
886 struct dict_object * _avp; \
35
6486e97f56ae Added test for modified message parsing
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
887 struct dict_object * _conflict; \
6486e97f56ae Added test for modified message parsing
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
888 CHECK( 1, (_pei.pei_avp) ? 1 : 0 ); \
6486e97f56ae Added test for modified message parsing
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
889 CHECK( 0, fd_msg_model( _pei.pei_avp, &_conflict ) ); \
10
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
890 CHECK( 0, fd_dict_search( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME_AND_VENDOR, &_req, &_avp, ENOENT)); \
35
6486e97f56ae Added test for modified message parsing
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
891 CHECK( _avp, _conflict ); \
0
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
892 } \
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
893 }
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
894
35
6486e97f56ae Added test for modified message parsing
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
895 /* ABNF :
6486e97f56ae Added test for modified message parsing
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
896 < no vendor - f32 >
6486e97f56ae Added test for modified message parsing
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
897 < i64 >
6486e97f56ae Added test for modified message parsing
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
898 < enumi32 >
6486e97f56ae Added test for modified message parsing
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
899 2*3 { os }
6486e97f56ae Added test for modified message parsing
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
900 *1 [ enumos ]
6486e97f56ae Added test for modified message parsing
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
901 < grouped >
6486e97f56ae Added test for modified message parsing
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
902 */
0
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
903 {
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
904 /* Test the FIXED_HEAD rules positions: add another AVP before the third */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
905 CHECK( 0, fd_msg_browse ( tavp, MSG_BRW_FIRST_CHILD, &tempavp, NULL) ); /* tempavp is the novendor avp */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
906 CHECK( 0, fd_msg_browse ( tempavp, MSG_BRW_NEXT, &tempavp, NULL) ); /* tempavp is the i64 avp */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
907 ADD_AVP( tempavp, MSG_BRW_NEXT, childavp, 73565, "AVP Test - os" );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
908
35
6486e97f56ae Added test for modified message parsing
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
909 CHECK_CONFLICT( msg, "DIAMETER_MISSING_AVP", "AVP Test - enumi32", 73565 );
0
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
910
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
911 /* Now remove this AVP */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
912 CHECK( 0, fd_msg_free ( childavp ) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
913 }
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
914 {
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
915 /* Remove the third AVP, same rule must conflict */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
916 CHECK( 0, fd_msg_browse ( tempavp, MSG_BRW_NEXT, &childavp, NULL) ); /* childavp is the enumi32 avp */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
917 CHECK( 0, fd_msg_free ( childavp ) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
918
35
6486e97f56ae Added test for modified message parsing
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
919 CHECK_CONFLICT( msg, "DIAMETER_MISSING_AVP", "AVP Test - enumi32", 73565 );
0
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
920
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
921 /* Add the AVP back */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
922 ADD_AVP( tempavp, MSG_BRW_NEXT, childavp, 73565, "AVP Test - enumi32" );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
923 }
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
924
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
925 {
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
926 /* Test the minimum value in the REQUIRED rule: delete one of the os AVPs */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
927 CHECK( 0, fd_msg_browse ( childavp, MSG_BRW_NEXT, &tempavp, NULL) ); /* tempavp is the os avp */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
928 CHECK( 0, fd_msg_free ( tempavp ) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
929
35
6486e97f56ae Added test for modified message parsing
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
930 CHECK_CONFLICT( msg, "DIAMETER_MISSING_AVP", "AVP Test - os", 73565 ); /* The rule requires at least 2 AVP, we have only 1 */
0
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
931
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
932 /* Now add this AVP */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
933 ADD_AVP( childavp, MSG_BRW_NEXT, tempavp, 73565, "AVP Test - os" );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
934 }
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
935 {
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
936 /* Test the maximum value in the REQUIRED rule: add more of the os AVPs */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
937 ADD_AVP( childavp, MSG_BRW_NEXT, tempavp, 73565, "AVP Test - os" );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
938 ADD_AVP( childavp, MSG_BRW_NEXT, tempavp, 73565, "AVP Test - os" );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
939
35
6486e97f56ae Added test for modified message parsing
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
940 CHECK_CONFLICT( msg, "DIAMETER_AVP_OCCURS_TOO_MANY_TIMES", "AVP Test - os", 73565 ); /* The rule requires at most 3 AVP, we have 4 */
0
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
941
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
942 /* Now delete these AVP */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
943 CHECK( 0, fd_msg_free ( tempavp ) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
944 CHECK( 0, fd_msg_browse ( childavp, MSG_BRW_NEXT, &tempavp, NULL) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
945 CHECK( 0, fd_msg_free ( tempavp ) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
946 }
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
947
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
948 {
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
949 /* Test the maximum value in the OPTIONAL rule: add 2 enumos AVPs */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
950 ADD_AVP( childavp, MSG_BRW_NEXT, tempavp, 73565, "AVP Test - enumos" );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
951
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
952 /* The message is still conform */
35
6486e97f56ae Added test for modified message parsing
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
953 CHECK( 0, fd_msg_parse_rules( msg, fd_g_config->cnf_dict, &pei ) );
0
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
954
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
955 /* Now break the rule */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
956 ADD_AVP( childavp, MSG_BRW_NEXT, tempavp, 73565, "AVP Test - enumos" );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
957
35
6486e97f56ae Added test for modified message parsing
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
958 CHECK_CONFLICT( msg, "DIAMETER_AVP_OCCURS_TOO_MANY_TIMES", "AVP Test - enumos", 73565 );
0
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
959
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
960 /* Now delete this AVP */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
961 CHECK( 0, fd_msg_free ( tempavp ) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
962 }
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
963
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
964 {
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
965 /* Test the RULE_FIXED_TAIL rules positions: add another AVP at the end */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
966 ADD_AVP( tavp, MSG_BRW_LAST_CHILD, childavp, 73565, "AVP Test - os" );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
967
35
6486e97f56ae Added test for modified message parsing
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 10
diff changeset
968 CHECK_CONFLICT( msg, "DIAMETER_MISSING_AVP", "AVP Test - grouped", 73565 );
0
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
969
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
970 /* Now remove this AVP */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
971 CHECK( 0, fd_msg_free ( childavp ) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
972 }
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
973 }
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
974 }
995
2016a0c46bda Fixed Proxy-Info duplication, added a test case for this
Sebastien Decugis <sdecugis@freediameter.net>
parents: 974
diff changeset
975
2016a0c46bda Fixed Proxy-Info duplication, added a test case for this
Sebastien Decugis <sdecugis@freediameter.net>
parents: 974
diff changeset
976 /* Test the fd_msg_new_answer_from_req function */
2016a0c46bda Fixed Proxy-Info duplication, added a test case for this
Sebastien Decugis <sdecugis@freediameter.net>
parents: 974
diff changeset
977 {
2016a0c46bda Fixed Proxy-Info duplication, added a test case for this
Sebastien Decugis <sdecugis@freediameter.net>
parents: 974
diff changeset
978 struct dict_object * cmd_model = NULL;
2016a0c46bda Fixed Proxy-Info duplication, added a test case for this
Sebastien Decugis <sdecugis@freediameter.net>
parents: 974
diff changeset
979 struct msg * msg = NULL;
2016a0c46bda Fixed Proxy-Info duplication, added a test case for this
Sebastien Decugis <sdecugis@freediameter.net>
parents: 974
diff changeset
980 struct avp * pi1, *pi2, *avp;
2016a0c46bda Fixed Proxy-Info duplication, added a test case for this
Sebastien Decugis <sdecugis@freediameter.net>
parents: 974
diff changeset
981 char * host1="host1", * host2="host2";
2016a0c46bda Fixed Proxy-Info duplication, added a test case for this
Sebastien Decugis <sdecugis@freediameter.net>
parents: 974
diff changeset
982 union avp_value value;
2016a0c46bda Fixed Proxy-Info duplication, added a test case for this
Sebastien Decugis <sdecugis@freediameter.net>
parents: 974
diff changeset
983 struct msg_hdr * msgdata = NULL;
2016a0c46bda Fixed Proxy-Info duplication, added a test case for this
Sebastien Decugis <sdecugis@freediameter.net>
parents: 974
diff changeset
984
2016a0c46bda Fixed Proxy-Info duplication, added a test case for this
Sebastien Decugis <sdecugis@freediameter.net>
parents: 974
diff changeset
985 CHECK( 0, fd_dict_search ( fd_g_config->cnf_dict, DICT_COMMAND, CMD_BY_NAME, "Test-Command-Request", &cmd_model, ENOENT ) );
2016a0c46bda Fixed Proxy-Info duplication, added a test case for this
Sebastien Decugis <sdecugis@freediameter.net>
parents: 974
diff changeset
986
2016a0c46bda Fixed Proxy-Info duplication, added a test case for this
Sebastien Decugis <sdecugis@freediameter.net>
parents: 974
diff changeset
987 /* Test default behavior without flags */
2016a0c46bda Fixed Proxy-Info duplication, added a test case for this
Sebastien Decugis <sdecugis@freediameter.net>
parents: 974
diff changeset
988 {
2016a0c46bda Fixed Proxy-Info duplication, added a test case for this
Sebastien Decugis <sdecugis@freediameter.net>
parents: 974
diff changeset
989 /* Create a message with some AVPs inside */
2016a0c46bda Fixed Proxy-Info duplication, added a test case for this
Sebastien Decugis <sdecugis@freediameter.net>
parents: 974
diff changeset
990 CHECK( 0, fd_msg_new ( cmd_model, 0, &msg ) );
2016a0c46bda Fixed Proxy-Info duplication, added a test case for this
Sebastien Decugis <sdecugis@freediameter.net>
parents: 974
diff changeset
991 CHECK( 0, fd_msg_hdr ( msg, &msgdata ) );
2016a0c46bda Fixed Proxy-Info duplication, added a test case for this
Sebastien Decugis <sdecugis@freediameter.net>
parents: 974
diff changeset
992
2016a0c46bda Fixed Proxy-Info duplication, added a test case for this
Sebastien Decugis <sdecugis@freediameter.net>
parents: 974
diff changeset
993 /* Add a session id */
1047
a130b6a13abb Fix some compilation warnings
Sebastien Decugis <sdecugis@freediameter.net>
parents: 995
diff changeset
994 CHECK( 0, fd_msg_new_session( msg, (os0_t)"testmsg", strlen("testmsg") ) );
995
2016a0c46bda Fixed Proxy-Info duplication, added a test case for this
Sebastien Decugis <sdecugis@freediameter.net>
parents: 974
diff changeset
995
2016a0c46bda Fixed Proxy-Info duplication, added a test case for this
Sebastien Decugis <sdecugis@freediameter.net>
parents: 974
diff changeset
996 /* Create two instances of Proxy-Info */
2016a0c46bda Fixed Proxy-Info duplication, added a test case for this
Sebastien Decugis <sdecugis@freediameter.net>
parents: 974
diff changeset
997 ADD_AVP( msg, MSG_BRW_LAST_CHILD, pi1, 0, "Proxy-Info");
2016a0c46bda Fixed Proxy-Info duplication, added a test case for this
Sebastien Decugis <sdecugis@freediameter.net>
parents: 974
diff changeset
998 ADD_AVP( msg, MSG_BRW_LAST_CHILD, pi2, 0, "Proxy-Info");
2016a0c46bda Fixed Proxy-Info duplication, added a test case for this
Sebastien Decugis <sdecugis@freediameter.net>
parents: 974
diff changeset
999
2016a0c46bda Fixed Proxy-Info duplication, added a test case for this
Sebastien Decugis <sdecugis@freediameter.net>
parents: 974
diff changeset
1000 ADD_AVP( pi1, MSG_BRW_LAST_CHILD, avp, 0, "Proxy-State");
1047
a130b6a13abb Fix some compilation warnings
Sebastien Decugis <sdecugis@freediameter.net>
parents: 995
diff changeset
1001 value.os.data = (os0_t)"ps_pi1";
a130b6a13abb Fix some compilation warnings
Sebastien Decugis <sdecugis@freediameter.net>
parents: 995
diff changeset
1002 value.os.len = strlen((char *)value.os.data);
995
2016a0c46bda Fixed Proxy-Info duplication, added a test case for this
Sebastien Decugis <sdecugis@freediameter.net>
parents: 974
diff changeset
1003 CHECK( 0, fd_msg_avp_setvalue ( avp, &value ) );
2016a0c46bda Fixed Proxy-Info duplication, added a test case for this
Sebastien Decugis <sdecugis@freediameter.net>
parents: 974
diff changeset
1004
2016a0c46bda Fixed Proxy-Info duplication, added a test case for this
Sebastien Decugis <sdecugis@freediameter.net>
parents: 974
diff changeset
1005 ADD_AVP( pi2, MSG_BRW_LAST_CHILD, avp, 0, "Proxy-State");
1047
a130b6a13abb Fix some compilation warnings
Sebastien Decugis <sdecugis@freediameter.net>
parents: 995
diff changeset
1006 value.os.data = (os0_t)"pi2_state";
a130b6a13abb Fix some compilation warnings
Sebastien Decugis <sdecugis@freediameter.net>
parents: 995
diff changeset
1007 value.os.len = strlen((char *)value.os.data);
995
2016a0c46bda Fixed Proxy-Info duplication, added a test case for this
Sebastien Decugis <sdecugis@freediameter.net>
parents: 974
diff changeset
1008 CHECK( 0, fd_msg_avp_setvalue ( avp, &value ) );
2016a0c46bda Fixed Proxy-Info duplication, added a test case for this
Sebastien Decugis <sdecugis@freediameter.net>
parents: 974
diff changeset
1009
2016a0c46bda Fixed Proxy-Info duplication, added a test case for this
Sebastien Decugis <sdecugis@freediameter.net>
parents: 974
diff changeset
1010 ADD_AVP( pi1, MSG_BRW_FIRST_CHILD, avp, 0, "Proxy-Host");
1047
a130b6a13abb Fix some compilation warnings
Sebastien Decugis <sdecugis@freediameter.net>
parents: 995
diff changeset
1011 value.os.data = (os0_t)host1;
995
2016a0c46bda Fixed Proxy-Info duplication, added a test case for this
Sebastien Decugis <sdecugis@freediameter.net>
parents: 974
diff changeset
1012 value.os.len = strlen(host1);
2016a0c46bda Fixed Proxy-Info duplication, added a test case for this
Sebastien Decugis <sdecugis@freediameter.net>
parents: 974
diff changeset
1013 CHECK( 0, fd_msg_avp_setvalue ( avp, &value ) );
2016a0c46bda Fixed Proxy-Info duplication, added a test case for this
Sebastien Decugis <sdecugis@freediameter.net>
parents: 974
diff changeset
1014
2016a0c46bda Fixed Proxy-Info duplication, added a test case for this
Sebastien Decugis <sdecugis@freediameter.net>
parents: 974
diff changeset
1015 ADD_AVP( pi2, MSG_BRW_LAST_CHILD, avp, 0, "Proxy-Host");
1047
a130b6a13abb Fix some compilation warnings
Sebastien Decugis <sdecugis@freediameter.net>
parents: 995
diff changeset
1016 value.os.data = (os0_t)host2;
995
2016a0c46bda Fixed Proxy-Info duplication, added a test case for this
Sebastien Decugis <sdecugis@freediameter.net>
parents: 974
diff changeset
1017 value.os.len = strlen(host2);
2016a0c46bda Fixed Proxy-Info duplication, added a test case for this
Sebastien Decugis <sdecugis@freediameter.net>
parents: 974
diff changeset
1018 CHECK( 0, fd_msg_avp_setvalue ( avp, &value ) );
2016a0c46bda Fixed Proxy-Info duplication, added a test case for this
Sebastien Decugis <sdecugis@freediameter.net>
parents: 974
diff changeset
1019
2016a0c46bda Fixed Proxy-Info duplication, added a test case for this
Sebastien Decugis <sdecugis@freediameter.net>
parents: 974
diff changeset
1020 ADD_AVP( pi2, MSG_BRW_LAST_CHILD, avp, 73565, "AVP Test - i64");
2016a0c46bda Fixed Proxy-Info duplication, added a test case for this
Sebastien Decugis <sdecugis@freediameter.net>
parents: 974
diff changeset
1021 value.i64 = 0x123456789abcdeLL;
2016a0c46bda Fixed Proxy-Info duplication, added a test case for this
Sebastien Decugis <sdecugis@freediameter.net>
parents: 974
diff changeset
1022 CHECK( 0, fd_msg_avp_setvalue ( avp, &value ) );
2016a0c46bda Fixed Proxy-Info duplication, added a test case for this
Sebastien Decugis <sdecugis@freediameter.net>
parents: 974
diff changeset
1023
2016a0c46bda Fixed Proxy-Info duplication, added a test case for this
Sebastien Decugis <sdecugis@freediameter.net>
parents: 974
diff changeset
1024
2016a0c46bda Fixed Proxy-Info duplication, added a test case for this
Sebastien Decugis <sdecugis@freediameter.net>
parents: 974
diff changeset
1025 /* Now call the fd_msg_new_answer_from_req function */
2016a0c46bda Fixed Proxy-Info duplication, added a test case for this
Sebastien Decugis <sdecugis@freediameter.net>
parents: 974
diff changeset
1026 CHECK( 0, fd_msg_new_answer_from_req ( fd_g_config->cnf_dict, &msg, 0 ) );
2016a0c46bda Fixed Proxy-Info duplication, added a test case for this
Sebastien Decugis <sdecugis@freediameter.net>
parents: 974
diff changeset
1027
2016a0c46bda Fixed Proxy-Info duplication, added a test case for this
Sebastien Decugis <sdecugis@freediameter.net>
parents: 974
diff changeset
1028 /* Check there is a Session-Id AVP */
2016a0c46bda Fixed Proxy-Info duplication, added a test case for this
Sebastien Decugis <sdecugis@freediameter.net>
parents: 974
diff changeset
1029 {
2016a0c46bda Fixed Proxy-Info duplication, added a test case for this
Sebastien Decugis <sdecugis@freediameter.net>
parents: 974
diff changeset
1030 struct session * sess;
2016a0c46bda Fixed Proxy-Info duplication, added a test case for this
Sebastien Decugis <sdecugis@freediameter.net>
parents: 974
diff changeset
1031 int new;
2016a0c46bda Fixed Proxy-Info duplication, added a test case for this
Sebastien Decugis <sdecugis@freediameter.net>
parents: 974
diff changeset
1032 CHECK( 0, fd_msg_sess_get(fd_g_config->cnf_dict, msg, &sess, &new) );
2016a0c46bda Fixed Proxy-Info duplication, added a test case for this
Sebastien Decugis <sdecugis@freediameter.net>
parents: 974
diff changeset
1033 CHECK( 1, sess == NULL ? 0 : 1 );
2016a0c46bda Fixed Proxy-Info duplication, added a test case for this
Sebastien Decugis <sdecugis@freediameter.net>
parents: 974
diff changeset
1034 CHECK( 0, new ? 1 : 0 );
2016a0c46bda Fixed Proxy-Info duplication, added a test case for this
Sebastien Decugis <sdecugis@freediameter.net>
parents: 974
diff changeset
1035 }
2016a0c46bda Fixed Proxy-Info duplication, added a test case for this
Sebastien Decugis <sdecugis@freediameter.net>
parents: 974
diff changeset
1036
2016a0c46bda Fixed Proxy-Info duplication, added a test case for this
Sebastien Decugis <sdecugis@freediameter.net>
parents: 974
diff changeset
1037 /* Check there are two Proxy-Info with the two hosts */
2016a0c46bda Fixed Proxy-Info duplication, added a test case for this
Sebastien Decugis <sdecugis@freediameter.net>
parents: 974
diff changeset
1038 {
2016a0c46bda Fixed Proxy-Info duplication, added a test case for this
Sebastien Decugis <sdecugis@freediameter.net>
parents: 974
diff changeset
1039 int got_h1 = 0, got_h2=0;
2016a0c46bda Fixed Proxy-Info duplication, added a test case for this
Sebastien Decugis <sdecugis@freediameter.net>
parents: 974
diff changeset
1040 CHECK( 0, fd_msg_browse ( msg, MSG_BRW_FIRST_CHILD, &avp, NULL) );
2016a0c46bda Fixed Proxy-Info duplication, added a test case for this
Sebastien Decugis <sdecugis@freediameter.net>
parents: 974
diff changeset
1041 while(avp) {
2016a0c46bda Fixed Proxy-Info duplication, added a test case for this
Sebastien Decugis <sdecugis@freediameter.net>
parents: 974
diff changeset
1042 struct avp_hdr * avpdata = NULL;
2016a0c46bda Fixed Proxy-Info duplication, added a test case for this
Sebastien Decugis <sdecugis@freediameter.net>
parents: 974
diff changeset
1043 CHECK( 0, fd_msg_avp_hdr ( avp, &avpdata ) );
2016a0c46bda Fixed Proxy-Info duplication, added a test case for this
Sebastien Decugis <sdecugis@freediameter.net>
parents: 974
diff changeset
1044 if (avpdata->avp_code == AC_PROXY_INFO) {
2016a0c46bda Fixed Proxy-Info duplication, added a test case for this
Sebastien Decugis <sdecugis@freediameter.net>
parents: 974
diff changeset
1045 struct avp * iavp;
2016a0c46bda Fixed Proxy-Info duplication, added a test case for this
Sebastien Decugis <sdecugis@freediameter.net>
parents: 974
diff changeset
1046 CHECK( 0, fd_msg_browse ( avp, MSG_BRW_FIRST_CHILD, &iavp, NULL) );
2016a0c46bda Fixed Proxy-Info duplication, added a test case for this
Sebastien Decugis <sdecugis@freediameter.net>
parents: 974
diff changeset
1047 while(iavp) {
2016a0c46bda Fixed Proxy-Info duplication, added a test case for this
Sebastien Decugis <sdecugis@freediameter.net>
parents: 974
diff changeset
1048 struct avp_hdr * iavpdata = NULL;
2016a0c46bda Fixed Proxy-Info duplication, added a test case for this
Sebastien Decugis <sdecugis@freediameter.net>
parents: 974
diff changeset
1049 CHECK( 0, fd_msg_avp_hdr ( iavp, &iavpdata ) );
2016a0c46bda Fixed Proxy-Info duplication, added a test case for this
Sebastien Decugis <sdecugis@freediameter.net>
parents: 974
diff changeset
1050 if (iavpdata->avp_code == AC_PROXY_HOST) {
2016a0c46bda Fixed Proxy-Info duplication, added a test case for this
Sebastien Decugis <sdecugis@freediameter.net>
parents: 974
diff changeset
1051 if (!memcmp(host1, iavpdata->avp_value->os.data, strlen(host1)))
2016a0c46bda Fixed Proxy-Info duplication, added a test case for this
Sebastien Decugis <sdecugis@freediameter.net>
parents: 974
diff changeset
1052 got_h1++;
2016a0c46bda Fixed Proxy-Info duplication, added a test case for this
Sebastien Decugis <sdecugis@freediameter.net>
parents: 974
diff changeset
1053 if (!memcmp(host2, iavpdata->avp_value->os.data, strlen(host2)))
2016a0c46bda Fixed Proxy-Info duplication, added a test case for this
Sebastien Decugis <sdecugis@freediameter.net>
parents: 974
diff changeset
1054 got_h2++;
2016a0c46bda Fixed Proxy-Info duplication, added a test case for this
Sebastien Decugis <sdecugis@freediameter.net>
parents: 974
diff changeset
1055 }
2016a0c46bda Fixed Proxy-Info duplication, added a test case for this
Sebastien Decugis <sdecugis@freediameter.net>
parents: 974
diff changeset
1056 CHECK( 0, fd_msg_browse ( iavp, MSG_BRW_NEXT, &iavp, NULL) );
2016a0c46bda Fixed Proxy-Info duplication, added a test case for this
Sebastien Decugis <sdecugis@freediameter.net>
parents: 974
diff changeset
1057 }
2016a0c46bda Fixed Proxy-Info duplication, added a test case for this
Sebastien Decugis <sdecugis@freediameter.net>
parents: 974
diff changeset
1058 }
2016a0c46bda Fixed Proxy-Info duplication, added a test case for this
Sebastien Decugis <sdecugis@freediameter.net>
parents: 974
diff changeset
1059
2016a0c46bda Fixed Proxy-Info duplication, added a test case for this
Sebastien Decugis <sdecugis@freediameter.net>
parents: 974
diff changeset
1060 CHECK( 0, fd_msg_browse ( avp, MSG_BRW_NEXT, &avp, NULL) );
2016a0c46bda Fixed Proxy-Info duplication, added a test case for this
Sebastien Decugis <sdecugis@freediameter.net>
parents: 974
diff changeset
1061 }
2016a0c46bda Fixed Proxy-Info duplication, added a test case for this
Sebastien Decugis <sdecugis@freediameter.net>
parents: 974
diff changeset
1062
2016a0c46bda Fixed Proxy-Info duplication, added a test case for this
Sebastien Decugis <sdecugis@freediameter.net>
parents: 974
diff changeset
1063 CHECK(1, got_h1);
2016a0c46bda Fixed Proxy-Info duplication, added a test case for this
Sebastien Decugis <sdecugis@freediameter.net>
parents: 974
diff changeset
1064 CHECK(1, got_h2);
2016a0c46bda Fixed Proxy-Info duplication, added a test case for this
Sebastien Decugis <sdecugis@freediameter.net>
parents: 974
diff changeset
1065 }
2016a0c46bda Fixed Proxy-Info duplication, added a test case for this
Sebastien Decugis <sdecugis@freediameter.net>
parents: 974
diff changeset
1066
1251
bdd7bf840c8d Validated previous fix, seems to work
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1103
diff changeset
1067 /* Now test the behavior of fd_msg_rescode_set with a grouped AVP */
bdd7bf840c8d Validated previous fix, seems to work
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1103
diff changeset
1068 CHECK( 0, fd_msg_rescode_set(msg, "DIAMETER_AVP_OCCURS_TOO_MANY_TIMES", NULL, pi1, 1) );
bdd7bf840c8d Validated previous fix, seems to work
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1103
diff changeset
1069
bdd7bf840c8d Validated previous fix, seems to work
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1103
diff changeset
1070 fd_log_debug("%s", fd_msg_dump_treeview(FD_DUMP_TEST_PARAMS, msg, fd_g_config->cnf_dict, 0, 1));
bdd7bf840c8d Validated previous fix, seems to work
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1103
diff changeset
1071
bdd7bf840c8d Validated previous fix, seems to work
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1103
diff changeset
1072 TODO("Check the Failed-AVP is as expected");
995
2016a0c46bda Fixed Proxy-Info duplication, added a test case for this
Sebastien Decugis <sdecugis@freediameter.net>
parents: 974
diff changeset
1073 }
2016a0c46bda Fixed Proxy-Info duplication, added a test case for this
Sebastien Decugis <sdecugis@freediameter.net>
parents: 974
diff changeset
1074
2016a0c46bda Fixed Proxy-Info duplication, added a test case for this
Sebastien Decugis <sdecugis@freediameter.net>
parents: 974
diff changeset
1075 }
0
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1076 }
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1077
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1078 /* Test the msg_avp_value_interpret and msg_avp_value_encode functions. use the Address type and Host-IP-Address AVPs */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1079 {
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1080 struct dict_object * cer_model = NULL;
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1081 struct msg * cer = NULL;
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1082
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1083 struct dict_object * hia_model = NULL;
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1084 struct avp *avp4, *avp6;
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1085 #define TEST_IP4 "192.168.100.101"
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1086 char buf4[INET_ADDRSTRLEN];
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1087 #define TEST_IP6 "1111:2222:3333:4444:1234:5678:9abc:def0"
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1088 char buf6[INET6_ADDRSTRLEN];
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1089
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1090 struct sockaddr_storage ss;
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1091 struct sockaddr_in sin, *psin;
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1092 struct sockaddr_in6 sin6, *psin6;
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1093
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1094 /* Find the CER dictionary object */
10
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
1095 CHECK( 0, fd_dict_search ( fd_g_config->cnf_dict, DICT_COMMAND, CMD_BY_NAME, "Capabilities-Exchange-Request", &cer_model, ENOENT ) );
0
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1096
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1097 /* Now find the Host-IP-Address dictionary object */
10
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
1098 CHECK( 0, fd_dict_search ( fd_g_config->cnf_dict, DICT_AVP, AVP_BY_NAME, "Host-IP-Address", &hia_model, ENOENT ) );
0
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1099
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1100 /* Create the msg instance */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1101 CHECK( 0, fd_msg_new ( cer_model, 0, &cer ) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1102
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1103 /* Create the avp instances */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1104 CHECK( 0, fd_msg_avp_new ( hia_model, 0, &avp4 ) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1105 CHECK( 0, fd_msg_avp_new ( hia_model, 0, &avp6 ) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1106
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1107 /* Set the value of the IP avp */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1108 sin.sin_family = AF_INET;
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1109 CHECK( 1, inet_pton( AF_INET, TEST_IP4, &sin.sin_addr.s_addr ) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1110 CHECK( 0, fd_msg_avp_value_encode ( &sin, avp4 ) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1111
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1112 /* Set the value of the IP6 avp */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1113 sin6.sin6_family = AF_INET6;
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1114 CHECK( 1, inet_pton( AF_INET6, TEST_IP6, &sin6.sin6_addr.s6_addr ) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1115 CHECK( 0, fd_msg_avp_value_encode ( &sin6, avp6 ) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1116
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1117 /* Add these AVPs in the message */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1118 CHECK( 0, fd_msg_avp_add( cer, MSG_BRW_LAST_CHILD, avp4) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1119 CHECK( 0, fd_msg_avp_add( cer, MSG_BRW_LAST_CHILD, avp6) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1120
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1121 /* Create the buffer for this message */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1122 CHECK( 0, fd_msg_bufferize( cer, &buf, NULL ) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1123
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1124 /* Now free the message, we keep only the buffer. */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1125 CHECK( 0, fd_msg_free( cer ) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1126
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1127 /* Check the content of the buffer is correct (skip command header) */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1128 CHECK( 0x00, buf[20] ); /* First AVP (IP4) begins: code 257 = 0x00000101 */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1129 CHECK( 0x00, buf[21] );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1130 CHECK( 0x01, buf[22] );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1131 CHECK( 0x01, buf[23] );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1132 CHECK( 0x40, buf[24] ); /* flags: M */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1133 CHECK( 0x00, buf[25] ); /* length: 8+6 = 0x00000e */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1134 CHECK( 0x00, buf[26] );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1135 CHECK( 0x0E, buf[27] );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1136 CHECK( 0x00, buf[28] ); /* Value: AddressType 1 */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1137 CHECK( 0x01, buf[29] );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1138 CHECK( 192, buf[30] ); /* 192.168.100.101 */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1139 CHECK( 168, buf[31] );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1140 CHECK( 100, buf[32] );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1141 CHECK( 101, buf[33] );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1142
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1143 CHECK( 0x00, buf[34] ); /* Padding */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1144 CHECK( 0x00, buf[35] );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1145
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1146 CHECK( 0x00, buf[36] ); /* Second AVP (IP6) begins: code 257 = 0x00000101 */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1147 CHECK( 0x00, buf[37] );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1148 CHECK( 0x01, buf[38] );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1149 CHECK( 0x01, buf[39] );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1150 CHECK( 0x40, buf[40] ); /* flags: M */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1151 CHECK( 0x00, buf[41] ); /* length: 8+18 = 0x00001a */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1152 CHECK( 0x00, buf[42] );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1153 CHECK( 0x1A, buf[43] );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1154 CHECK( 0x00, buf[44] ); /* Value: AddressType 2 */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1155 CHECK( 0x02, buf[45] );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1156 CHECK( 0x11, buf[46] ); /* 1111:2222:3333:4444:1234:5678:9abc:def0 */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1157 CHECK( 0x11, buf[47] );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1158 CHECK( 0x22, buf[48] );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1159 CHECK( 0x22, buf[49] );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1160 CHECK( 0x33, buf[50] );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1161 CHECK( 0x33, buf[51] );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1162 CHECK( 0x44, buf[52] );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1163 CHECK( 0x44, buf[53] );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1164 CHECK( 0x12, buf[54] );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1165 CHECK( 0x34, buf[55] );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1166 CHECK( 0x56, buf[56] );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1167 CHECK( 0x78, buf[57] );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1168 CHECK( 0x9a, buf[58] );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1169 CHECK( 0xbc, buf[59] );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1170 CHECK( 0xde, buf[60] );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1171 CHECK( 0xf0, buf[61] );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1172
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1173 /* Ok, now let's recreate the message */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1174 CHECK( 0, fd_msg_parse_buffer( &buf, 64, &cer) );
114
5b3868944e2b Reporting errors in parse_dict function
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 35
diff changeset
1175 CHECK( 0, fd_msg_parse_dict( cer, fd_g_config->cnf_dict, NULL ) );
0
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1176
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1177 /* Get the pointers to the first and last AVP */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1178 CHECK( 0, fd_msg_browse( cer, MSG_BRW_FIRST_CHILD, &avp4, NULL) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1179 CHECK( 0, fd_msg_browse( cer, MSG_BRW_LAST_CHILD, &avp6, NULL) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1180
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1181 /* Try and interpret the data in the AVPs */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1182 CHECK( 0, fd_msg_avp_value_interpret ( avp4, &ss ) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1183 psin = (struct sockaddr_in *)&ss;
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1184 CHECK( AF_INET, psin->sin_family );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1185 CHECK( 0, (inet_ntop( AF_INET, &psin->sin_addr.s_addr, buf4, sizeof(buf4) ) == NULL) ? errno : 0 );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1186 CHECK( 0, strcmp( buf4, TEST_IP4 ) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1187
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1188 CHECK( 0, fd_msg_avp_value_interpret ( avp6, &ss ) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1189 psin6 = (struct sockaddr_in6 *)&ss;
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1190 CHECK( AF_INET6, psin6->sin6_family );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1191 CHECK( 0, (inet_ntop( AF_INET6, &psin6->sin6_addr.s6_addr, buf6, sizeof(buf6) ) == NULL) ? errno : 0 );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1192 CHECK( 0, strcasecmp( buf6, TEST_IP6 ) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1193
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1194 /* Ok, it's done */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1195 CHECK( 0, fd_msg_free( cer ) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1196 }
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1197
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1198 /* Check proper encoding / decoding for all basic types of AVP */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1199 {
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1200 {
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1201 struct dict_avp_data avp_data = { 91001, 0, "AVP Test 2 - os", 0, 0, AVP_TYPE_OCTETSTRING };
10
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
1202 CHECK( 0, fd_dict_new ( fd_g_config->cnf_dict, DICT_AVP, &avp_data , NULL, NULL ) );
0
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1203 }
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1204 {
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1205 struct dict_avp_data avp_data = { 91002, 0, "AVP Test 2 - i32", 0, 0, AVP_TYPE_INTEGER32 };
10
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
1206 CHECK( 0, fd_dict_new ( fd_g_config->cnf_dict, DICT_AVP, &avp_data , NULL, NULL ) );
0
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1207 }
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1208 {
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1209 struct dict_avp_data avp_data = { 91003, 0, "AVP Test 2 - i64", 0, 0, AVP_TYPE_INTEGER64 };
10
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
1210 CHECK( 0, fd_dict_new ( fd_g_config->cnf_dict, DICT_AVP, &avp_data , NULL, NULL ) );
0
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1211 }
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1212 {
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1213 struct dict_avp_data avp_data = { 91004, 0, "AVP Test 2 - u32", 0, 0, AVP_TYPE_UNSIGNED32 };
10
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
1214 CHECK( 0, fd_dict_new ( fd_g_config->cnf_dict, DICT_AVP, &avp_data , NULL, NULL ) );
0
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1215 }
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1216 {
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1217 struct dict_avp_data avp_data = { 91005, 0, "AVP Test 2 - u64", 0, 0, AVP_TYPE_UNSIGNED64 };
10
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
1218 CHECK( 0, fd_dict_new ( fd_g_config->cnf_dict, DICT_AVP, &avp_data , NULL, NULL ) );
0
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1219 }
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1220 {
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1221 struct dict_avp_data avp_data = { 91006, 0, "AVP Test 2 - f32", 0, 0, AVP_TYPE_FLOAT32 };
10
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
1222 CHECK( 0, fd_dict_new ( fd_g_config->cnf_dict, DICT_AVP, &avp_data , NULL, NULL ) );
0
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1223 }
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1224 {
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1225 struct dict_avp_data avp_data = { 91007, 0, "AVP Test 2 - f64", 0, 0, AVP_TYPE_FLOAT64 };
10
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
1226 CHECK( 0, fd_dict_new ( fd_g_config->cnf_dict, DICT_AVP, &avp_data , NULL, NULL ) );
0
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1227 }
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1228
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1229 {
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1230 struct dict_object * cmd_model = NULL;
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1231 struct msg * msg = NULL;
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1232 struct avp * avp = NULL;
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1233 union avp_value value;
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1234 struct avp * avpi = NULL;
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1235 struct avp_hdr * avpdata = NULL;
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1236 struct msg_hdr * msgdata = NULL;
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1237
10
c5c99c73c2bf Added some extensions and functions in the daemon
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 8
diff changeset
1238 CHECK( 0, fd_dict_search ( fd_g_config->cnf_dict, DICT_COMMAND, CMD_BY_NAME, "Test-Command-Request", &cmd_model, ENOENT ) );
0
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1239
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1240 /* Create a message */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1241 CHECK( 0, fd_msg_new ( cmd_model, 0, &msg ) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1242 CHECK( 0, fd_msg_hdr ( msg, &msgdata ) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1243
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1244 ADD_AVP( msg, MSG_BRW_LAST_CHILD, avpi, 0, "AVP Test 2 - os" );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1245 value.os.data = (unsigned char *) "waaad";
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1246 value.os.len = 6;
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1247 CHECK( 0, fd_msg_avp_setvalue ( avpi, &value ) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1248
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1249 ADD_AVP( msg, MSG_BRW_LAST_CHILD, avpi, 0, "AVP Test 2 - i32" );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1250 value.i32 = 0x123456;
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1251 CHECK( 0, fd_msg_avp_setvalue ( avpi, &value ) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1252
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1253 ADD_AVP( msg, MSG_BRW_LAST_CHILD, avpi, 0, "AVP Test 2 - i32" );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1254 value.i32 = -0x123456;
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1255 CHECK( 0, fd_msg_avp_setvalue ( avpi, &value ) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1256
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1257 ADD_AVP( msg, MSG_BRW_LAST_CHILD, avpi, 0, "AVP Test 2 - i64" );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1258 value.i64 = 0x11223344556677LL;
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1259 CHECK( 0, fd_msg_avp_setvalue ( avpi, &value ) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1260
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1261 ADD_AVP( msg, MSG_BRW_LAST_CHILD, avpi, 0, "AVP Test 2 - i64" );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1262 value.i64 = -0x11223344556677LL;
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1263 CHECK( 0, fd_msg_avp_setvalue ( avpi, &value ) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1264
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1265 ADD_AVP( msg, MSG_BRW_LAST_CHILD, avpi, 0, "AVP Test 2 - u32" );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1266 value.u32 = 0xFEDCBA98;
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1267 CHECK( 0, fd_msg_avp_setvalue ( avpi, &value ) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1268
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1269 ADD_AVP( msg, MSG_BRW_LAST_CHILD, avpi, 0, "AVP Test 2 - u64" );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1270 value.u64 = 0x123456789abcdef0LL;
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1271 CHECK( 0, fd_msg_avp_setvalue ( avpi, &value ) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1272
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1273 ADD_AVP( msg, MSG_BRW_LAST_CHILD, avpi, 0, "AVP Test 2 - f32" );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1274 value.f32 = 2097153.0F;
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1275 CHECK( 0, fd_msg_avp_setvalue ( avpi, &value ) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1276
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1277 ADD_AVP( msg, MSG_BRW_LAST_CHILD, avpi, 0, "AVP Test 2 - f64" );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1278 value.f64 = -1099511627777LL;
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1279 CHECK( 0, fd_msg_avp_setvalue ( avpi, &value ) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1280
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1281 /* Ok now bufferize */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1282 CHECK( 0, fd_msg_bufferize( msg, &buf, NULL ) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1283
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1284 /* Test the first bytes */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1285 CHECK( 0x01, buf[0] ); /* Version */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1286 CHECK( 0x00, buf[1] ); /* Length: 148 = 0x000094 */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1287 CHECK( 0x00, buf[2] );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1288 CHECK( 0x94, buf[3] );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1289 CHECK( 0x80, buf[4] ); /* flags: only "R" is set. */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1290 CHECK( 0x01, buf[5] ); /* Command code: 73573 = 0x011F65 */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1291 CHECK( 0x1F, buf[6] );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1292 CHECK( 0x65, buf[7] );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1293 CHECK( 0x00, buf[8] ); /* App ID */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1294 CHECK( 0x01, buf[9] );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1295 CHECK( 0x1F, buf[10] );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1296 CHECK( 0x5E, buf[11] );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1297 CHECK( 0x00, buf[12] ); /* hop-by-hop id */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1298 CHECK( 0x00, buf[13] );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1299 CHECK( 0x00, buf[14] );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1300 CHECK( 0x00, buf[15] );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1301 CHECK( 0x00, buf[16] ); /* end-to-end id */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1302 CHECK( 0x00, buf[17] );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1303 CHECK( 0x00, buf[18] );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1304 CHECK( 0x00, buf[19] );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1305
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1306 CHECK( 0x00, buf[20] ); /* First AVP (AVP Test 2 - os) begin: code 91001 = 0x00016379 */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1307 CHECK( 0x01, buf[21] );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1308 CHECK( 0x63, buf[22] );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1309 CHECK( 0x79, buf[23] );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1310 CHECK( 0x00, buf[24] ); /* flags: 0 */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1311 CHECK( 0x00, buf[25] ); /* length: 14 = 0x00000e */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1312 CHECK( 0x00, buf[26] );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1313 CHECK( 0x0e, buf[27] );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1314
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1315 CHECK( 0x77, buf[28] ); /* "waaad\0" + padding */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1316 CHECK( 0x61, buf[29] );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1317 CHECK( 0x61, buf[30] );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1318 CHECK( 0x61, buf[31] );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1319 CHECK( 0x64, buf[32] );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1320 CHECK( 0x00, buf[33] );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1321 CHECK( 0x00, buf[34] );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1322 CHECK( 0x00, buf[35] );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1323
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1324 /* 36 ~ 43 : 2nd AVP header (size at last octet) */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1325 CHECK( 0x0c, buf[43] );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1326 CHECK( 0x00, buf[44] ); /* 0x123456 stored in integer32 in network byte order */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1327 CHECK( 0x12, buf[45] );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1328 CHECK( 0x34, buf[46] );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1329 CHECK( 0x56, buf[47] );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1330
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1331 /* 48 ~ 55 : next AVP header */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1332 CHECK( 0xff, buf[56] ); /* -0x123456 stored in integer32 in network byte order. */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1333 CHECK( 0xed, buf[57] ); /* We assume that two's complement is the correct representation, although it's not clearly specified. */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1334 CHECK( 0xcb, buf[58] ); /* 00 12 34 56 inversed => FF ED CB A9 */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1335 CHECK( 0xaa, buf[59] ); /* then "+1" => FF ED CB AA */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1336
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1337 /* 60 ~ 67 : next header */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1338 CHECK( 0x10, buf[67] ); /* (the size) */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1339 CHECK( 0x00, buf[68] ); /* 0x11223344556677 in network byte order */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1340 CHECK( 0x11, buf[69] );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1341 CHECK( 0x22, buf[70] );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1342 CHECK( 0x33, buf[71] );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1343 CHECK( 0x44, buf[72] );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1344 CHECK( 0x55, buf[73] );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1345 CHECK( 0x66, buf[74] );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1346 CHECK( 0x77, buf[75] );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1347
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1348 /* 76 ~ 83 : next header */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1349 CHECK( 0xFF, buf[84] ); /* - 0x11223344556677 (in two's complement) */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1350 CHECK( 0xEE, buf[85] ); /* gives FF EE DD CC BB AA 99 89 */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1351 CHECK( 0xDD, buf[86] );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1352 CHECK( 0xCC, buf[87] );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1353 CHECK( 0xBB, buf[88] );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1354 CHECK( 0xAA, buf[89] );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1355 CHECK( 0x99, buf[90] );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1356 CHECK( 0x89, buf[91] );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1357
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1358 /* 92 ~ 99 : next header */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1359 CHECK( 0x0c, buf[99] ); /* (the size) */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1360 CHECK( 0xFE, buf[100]); /* 0xFEDCBA98 in network byte order */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1361 CHECK( 0xDC, buf[101]);
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1362 CHECK( 0xBA, buf[102]);
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1363 CHECK( 0x98, buf[103]);
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1364
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1365 /* 104 ~ 111 : next header */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1366 CHECK( 0x10, buf[111] ); /* (the size) */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1367 CHECK( 0x12, buf[112]); /* 0x123456789abcdef0LL in network byte order */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1368 CHECK( 0x34, buf[113]);
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1369 CHECK( 0x56, buf[114]);
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1370 CHECK( 0x78, buf[115]);
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1371 CHECK( 0x9a, buf[116]);
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1372 CHECK( 0xbc, buf[117]);
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1373 CHECK( 0xde, buf[118]);
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1374 CHECK( 0xf0, buf[119]);
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1375
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1376 /* 120 ~ 127 : next header */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1377 CHECK( 0x0c, buf[127] ); /* (the size) */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1378 CHECK( 0x4a, buf[128]); /* http://en.wikipedia.org/wiki/IEEE_754-1985 to get descvription of the format */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1379 CHECK( 0x00, buf[129]); /* v = 2097153 = 2^21 + 2 ^ 0; sign : "+", 2^21 <= v < 2^22 => exponent = 21; biaised on 8 bits => 21 + 127 => 100 1010 0 */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1380 CHECK( 0x00, buf[130]); /* v = (+1) * (1 ^ 21) * ( 1 + 2^-21 ) => significand 000 0000 0000 0000 0000 0100 */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1381 CHECK( 0x04, buf[131]); /* result: 4a 00 00 04 */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1382
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1383 /* 132 ~ 139 : next header */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1384 CHECK( 0x10, buf[139] ); /* (the size) */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1385 CHECK( 0xc2, buf[140]); /* -1099511627777L ( 2^40 + 1 ) in network byte order */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1386 CHECK( 0x70, buf[141]); /* sign: - => most significant bit = 1 */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1387 CHECK( 0x00, buf[142]); /* 2^40 <= v < 2^41 => biaised exponent on 11 bits: 1023 + 40: 100 0010 0111 */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1388 CHECK( 0x00, buf[143]); /* significand: 1 + 2^-40 => 0000 0000 0000 0000 0000 0000 0000 0000 0000 0001 0000 0000 0000 */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1389 CHECK( 0x00, buf[144]); /* result: c2 70 00 00 00 00 10 00 */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1390 CHECK( 0x00, buf[145]);
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1391 CHECK( 0x10, buf[146]);
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1392 CHECK( 0x00, buf[147]);
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1393
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1394
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1395
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1396 /* Okay, now delete the message and parse the buffer, then check we obtain the same values back */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1397 #if 0
1088
1d1a20a0779d Second part of changeset 1083, now the code compiles again. Still missing some functions implementation, though
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1047
diff changeset
1398 fd_log_debug("%s", fd_msg_dump_treeview(FD_DUMP_TEST_PARAMS, msg, fd_g_config->cnf_dict, 0, 1));
0
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1399 #endif
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1400 CHECK( 0, fd_msg_free( msg ) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1401
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1402 CHECK( 0, fd_msg_parse_buffer( &buf, 148, &msg) );
114
5b3868944e2b Reporting errors in parse_dict function
Sebastien Decugis <sdecugis@nict.go.jp>
parents: 35
diff changeset
1403 CHECK( 0, fd_msg_parse_dict( msg, fd_g_config->cnf_dict, NULL ) );
0
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1404 #if 0
1088
1d1a20a0779d Second part of changeset 1083, now the code compiles again. Still missing some functions implementation, though
Sebastien Decugis <sdecugis@freediameter.net>
parents: 1047
diff changeset
1405 fd_log_debug("%s", fd_msg_dump_treeview(FD_DUMP_TEST_PARAMS, msg, fd_g_config->cnf_dict, 0, 1));
0
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1406 #endif
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1407
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1408 CHECK( 0, fd_msg_browse ( msg, MSG_BRW_FIRST_CHILD, &avp, NULL) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1409 CHECK( 0, fd_msg_avp_hdr ( avp, &avpdata ) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1410 CHECK( 6, avpdata->avp_value->os.len );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1411 CHECK( 'w', (char)(avpdata->avp_value->os.data[0]) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1412 CHECK( 'a', (char)(avpdata->avp_value->os.data[1]) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1413 CHECK( 'd', (char)(avpdata->avp_value->os.data[4]) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1414 CHECK( '\0', (char)(avpdata->avp_value->os.data[5]) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1415
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1416 CHECK( 0, fd_msg_browse ( avp, MSG_BRW_NEXT, &avp, NULL) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1417 CHECK( 0, fd_msg_avp_hdr ( avp, &avpdata ) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1418 CHECK( 0x123456, avpdata->avp_value->i32 );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1419
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1420 CHECK( 0, fd_msg_browse ( avp, MSG_BRW_NEXT, &avp, NULL) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1421 CHECK( 0, fd_msg_avp_hdr ( avp, &avpdata ) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1422 CHECK( -0x123456, avpdata->avp_value->i32 );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1423
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1424 CHECK( 0, fd_msg_browse ( avp, MSG_BRW_NEXT, &avp, NULL) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1425 CHECK( 0, fd_msg_avp_hdr ( avp, &avpdata ) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1426 CHECK( 0x11223344556677LL, avpdata->avp_value->i64 );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1427
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1428 CHECK( 0, fd_msg_browse ( avp, MSG_BRW_NEXT, &avp, NULL) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1429 CHECK( 0, fd_msg_avp_hdr ( avp, &avpdata ) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1430 CHECK( -0x11223344556677LL, avpdata->avp_value->i64 );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1431
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1432 CHECK( 0, fd_msg_browse ( avp, MSG_BRW_NEXT, &avp, NULL) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1433 CHECK( 0, fd_msg_avp_hdr ( avp, &avpdata ) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1434 CHECK( 0xFEDCBA98, avpdata->avp_value->u32 );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1435
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1436 CHECK( 0, fd_msg_browse ( avp, MSG_BRW_NEXT, &avp, NULL) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1437 CHECK( 0, fd_msg_avp_hdr ( avp, &avpdata ) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1438 CHECK( 0x123456789abcdef0LL, avpdata->avp_value->u64 );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1439
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1440 CHECK( 0, fd_msg_browse ( avp, MSG_BRW_NEXT, &avp, NULL) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1441 CHECK( 0, fd_msg_avp_hdr ( avp, &avpdata ) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1442 CHECK( 2097153.0F, avpdata->avp_value->f32 );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1443
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1444 CHECK( 0, fd_msg_browse ( avp, MSG_BRW_NEXT, &avp, NULL) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1445 CHECK( 0, fd_msg_avp_hdr ( avp, &avpdata ) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1446 CHECK( -1099511627777LL, avpdata->avp_value->f64 );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1447
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1448 CHECK( 0, fd_msg_free( msg ) );
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1449 }
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1450 }
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1451
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1452 /* That's all for the tests yet */
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1453 PASSTEST();
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1454 }
13530e1f02e3 Initial files imported
Sebastien Decugis <sdecugis@nict.go.jp>
parents:
diff changeset
1455
"Welcome to our mercurial repository"